[Project64] Update mem pak handling to deal with reseting save

This commit is contained in:
zilmar 2017-01-22 19:59:26 +11:00
parent 2d09818eb2
commit d5c43bfcba
2 changed files with 6 additions and 2 deletions

View File

@ -30,4 +30,5 @@ private:
uint8_t m_Mempaks[4][128 * 256]; /* [CONTROLLERS][PAGES][BYTES_PER_PAGE] */ uint8_t m_Mempaks[4][128 * 256]; /* [CONTROLLERS][PAGES][BYTES_PER_PAGE] */
CFile m_MempakHandle[4]; CFile m_MempakHandle[4];
bool m_Formatted[4]; bool m_Formatted[4];
bool m_SaveExists[4];
}; };

View File

@ -19,7 +19,8 @@ CMempak::CMempak()
for (uint32_t i = 0; i < sizeof(m_Formatted) / sizeof(m_Formatted[0]); i++) for (uint32_t i = 0; i < sizeof(m_Formatted) / sizeof(m_Formatted[0]); i++)
{ {
m_Formatted[i] = 0; m_Formatted[i] = 0;
} m_SaveExists[i] = true;
}
memset(m_Mempaks, 0, sizeof(m_Mempaks)); memset(m_Mempaks, 0, sizeof(m_Mempaks));
} }
@ -41,6 +42,7 @@ void CMempak::LoadMempak(int32_t Control, bool Create)
CMempak::Format(Control); CMempak::Format(Control);
m_Formatted[Control] = true; m_Formatted[Control] = true;
} }
m_SaveExists[Control] = false;
return; return;
} }
@ -66,6 +68,7 @@ void CMempak::LoadMempak(int32_t Control, bool Create)
else else
{ {
m_MempakHandle[Control].Read(m_Mempaks[Control], 0x8000); m_MempakHandle[Control].Read(m_Mempaks[Control], 0x8000);
m_Formatted[Control] = true;
} }
} }
@ -137,7 +140,7 @@ void CMempak::ReadFrom(int32_t Control, uint32_t address, uint8_t * data)
{ {
if (address < 0x8000) if (address < 0x8000)
{ {
if (!m_Formatted[Control] && !m_MempakHandle[Control].IsOpen()) if (m_SaveExists[Control] && !m_MempakHandle[Control].IsOpen())
{ {
LoadMempak(Control, false); LoadMempak(Control, false);
} }