From d5c43bfcba023bb949802e6fb8f6527fd31fc661 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 22 Jan 2017 19:59:26 +1100 Subject: [PATCH] [Project64] Update mem pak handling to deal with reseting save --- Source/Project64-core/N64System/Mips/Mempak.H | 1 + Source/Project64-core/N64System/Mips/Mempak.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/Mempak.H b/Source/Project64-core/N64System/Mips/Mempak.H index 73ec31a38..052e78c88 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.H +++ b/Source/Project64-core/N64System/Mips/Mempak.H @@ -30,4 +30,5 @@ private: uint8_t m_Mempaks[4][128 * 256]; /* [CONTROLLERS][PAGES][BYTES_PER_PAGE] */ CFile m_MempakHandle[4]; bool m_Formatted[4]; + bool m_SaveExists[4]; }; \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/Mempak.cpp b/Source/Project64-core/N64System/Mips/Mempak.cpp index 40a978dfb..87d7e14eb 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.cpp +++ b/Source/Project64-core/N64System/Mips/Mempak.cpp @@ -19,7 +19,8 @@ CMempak::CMempak() for (uint32_t i = 0; i < sizeof(m_Formatted) / sizeof(m_Formatted[0]); i++) { m_Formatted[i] = 0; - } + m_SaveExists[i] = true; + } memset(m_Mempaks, 0, sizeof(m_Mempaks)); } @@ -41,6 +42,7 @@ void CMempak::LoadMempak(int32_t Control, bool Create) CMempak::Format(Control); m_Formatted[Control] = true; } + m_SaveExists[Control] = false; return; } @@ -66,6 +68,7 @@ void CMempak::LoadMempak(int32_t Control, bool Create) else { 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 (!m_Formatted[Control] && !m_MempakHandle[Control].IsOpen()) + if (m_SaveExists[Control] && !m_MempakHandle[Control].IsOpen()) { LoadMempak(Control, false); }