diff --git a/Source/Project64-core/N64System/Mips/Eeprom.cpp b/Source/Project64-core/N64System/Mips/Eeprom.cpp index 303c5a981..7de9eaa9e 100644 --- a/Source/Project64-core/N64System/Mips/Eeprom.cpp +++ b/Source/Project64-core/N64System/Mips/Eeprom.cpp @@ -74,22 +74,22 @@ void CEeprom::EepromCommand(uint8_t * Command) case 4: // Read from Eeprom if (Command[0] != 2 && HaveDebugger()) { - g_Notify->DisplayError("What am I meant to do with this Eeprom Command"); + ProcessingError(Command); } if (Command[1] != 8 && HaveDebugger()) { - g_Notify->DisplayError("What am I meant to do with this Eeprom Command"); + ProcessingError(Command); } ReadFrom(&Command[4], Command[3]); break; case 5: //Write to Eeprom if (Command[0] != 10 && HaveDebugger()) { - g_Notify->DisplayError("What am I meant to do with this Eeprom Command"); + ProcessingError(Command); } if (Command[1] != 1 && HaveDebugger()) { - g_Notify->DisplayError("What am I meant to do with this Eeprom Command"); + ProcessingError(Command); } WriteTo(&Command[4], Command[3]); break; @@ -126,13 +126,13 @@ void CEeprom::EepromCommand(uint8_t * Command) break; case 8: //Write RTC, unimplemented - if (g_Settings->LoadDword(Debugger_ShowPifErrors)) + if (bShowPifRamErrors()) { g_Notify->DisplayError("Write RTC, unimplemented"); } break; default: - if (g_Settings->LoadDword(Debugger_ShowPifErrors)) + if (bShowPifRamErrors()) { g_Notify->DisplayError(stdstr_f("Unknown EepromCommand %d", Command[2]).c_str()); } @@ -200,4 +200,12 @@ void CEeprom::WriteTo(uint8_t * Buffer, int32_t line) m_File.Seek(line * 8, CFile::begin); m_File.Write(Buffer, 8); } -} \ No newline at end of file +} + +void CEeprom::ProcessingError(uint8_t * /*Command*/) +{ + if (bShowPifRamErrors()) + { + g_Notify->DisplayError("What am I meant to do with this Eeprom Command"); + } +} diff --git a/Source/Project64-core/N64System/Mips/Eeprom.h b/Source/Project64-core/N64System/Mips/Eeprom.h index 2fb633854..035a9e5dc 100644 --- a/Source/Project64-core/N64System/Mips/Eeprom.h +++ b/Source/Project64-core/N64System/Mips/Eeprom.h @@ -12,7 +12,7 @@ #include class CEeprom : - private CDebugSettings + protected CDebugSettings { public: CEeprom(bool ReadOnly); @@ -25,6 +25,7 @@ private: CEeprom(const CEeprom&); // Disable copy constructor CEeprom& operator=(const CEeprom&); // Disable assignment + void ProcessingError(uint8_t * Command); void LoadEeprom(); void ReadFrom(uint8_t * Buffer, int32_t line); void WriteTo(uint8_t * Buffer, int32_t line); diff --git a/Source/Project64-core/N64System/Mips/PifRam.cpp b/Source/Project64-core/N64System/Mips/PifRam.cpp index 9583070f4..3e102ad5a 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.cpp +++ b/Source/Project64-core/N64System/Mips/PifRam.cpp @@ -22,35 +22,8 @@ #include #include -int32_t CPifRamSettings::m_RefCount = 0; -bool CPifRamSettings::m_bShowPifRamErrors = false; - -CPifRamSettings::CPifRamSettings() -{ - m_RefCount += 1; - if (m_RefCount == 1) - { - g_Settings->RegisterChangeCB(Debugger_ShowPifErrors, NULL, RefreshSettings); - RefreshSettings(NULL); - } -} - -CPifRamSettings::~CPifRamSettings() -{ - m_RefCount -= 1; - if (m_RefCount == 0) - { - g_Settings->UnregisterChangeCB(Debugger_ShowPifErrors, NULL, RefreshSettings); - } -} - -void CPifRamSettings::RefreshSettings(void *) -{ - m_bShowPifRamErrors = g_Settings->LoadBool(Debugger_ShowPifErrors); -} - CPifRam::CPifRam(bool SavesReadOnly) : -CEeprom(SavesReadOnly) + CEeprom(SavesReadOnly) { Reset(); } diff --git a/Source/Project64-core/N64System/Mips/PifRam.h b/Source/Project64-core/N64System/Mips/PifRam.h index c440417f4..f9a40d951 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.h +++ b/Source/Project64-core/N64System/Mips/PifRam.h @@ -13,28 +13,8 @@ #include #include -class CPifRamSettings -{ -protected: - CPifRamSettings(); - virtual ~CPifRamSettings(); - - bool bShowPifRamErrors() const - { - return m_bShowPifRamErrors; - } - -private: - static void RefreshSettings(void*); - - static bool m_bShowPifRamErrors; - - static int32_t m_RefCount; -}; - class CPifRam : public CLogging, - private CPifRamSettings, private CEeprom { public: diff --git a/Source/Project64-core/Settings/DebugSettings.cpp b/Source/Project64-core/Settings/DebugSettings.cpp index 3ec21d99a..407068bd0 100644 --- a/Source/Project64-core/Settings/DebugSettings.cpp +++ b/Source/Project64-core/Settings/DebugSettings.cpp @@ -27,6 +27,7 @@ bool CDebugSettings::m_RecordExecutionTimes = false; bool CDebugSettings::m_HaveExecutionBP = false; bool CDebugSettings::m_HaveWriteBP = false; bool CDebugSettings::m_HaveReadBP = false; +bool CDebugSettings::m_bShowPifRamErrors = false; CDebugSettings::CDebugSettings() { @@ -45,6 +46,7 @@ CDebugSettings::CDebugSettings() g_Settings->RegisterChangeCB(Debugger_WriteBPExists, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_ReadBPExists, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_WaitingForStep, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); + g_Settings->RegisterChangeCB(Debugger_ShowPifErrors, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); RefreshSettings(); } @@ -65,6 +67,7 @@ CDebugSettings::~CDebugSettings() g_Settings->UnregisterChangeCB(Debugger_HaveExecutionBP, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_WriteBPExists, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_WaitingForStep, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); + g_Settings->UnregisterChangeCB(Debugger_ShowPifErrors, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); } } @@ -81,6 +84,7 @@ void CDebugSettings::RefreshSettings() m_HaveExecutionBP = m_HaveDebugger && g_Settings->LoadBool(Debugger_HaveExecutionBP); m_HaveWriteBP = m_HaveDebugger && g_Settings->LoadBool(Debugger_WriteBPExists); m_HaveReadBP = m_HaveDebugger && g_Settings->LoadBool(Debugger_ReadBPExists); + m_bShowPifRamErrors = m_HaveDebugger && g_Settings->LoadBool(Debugger_ShowPifErrors); m_Debugging = m_HaveDebugger && (m_HaveExecutionBP || m_WaitingForStep || m_HaveWriteBP || m_HaveReadBP); } \ No newline at end of file diff --git a/Source/Project64-core/Settings/DebugSettings.h b/Source/Project64-core/Settings/DebugSettings.h index 600778ec8..0a27fa915 100644 --- a/Source/Project64-core/Settings/DebugSettings.h +++ b/Source/Project64-core/Settings/DebugSettings.h @@ -30,7 +30,8 @@ public: static inline bool HaveExecutionBP(void) { return m_HaveExecutionBP; } static inline bool HaveWriteBP(void) { return m_HaveWriteBP; } static inline bool HaveReadBP(void) { return m_HaveReadBP; } - + static inline bool bShowPifRamErrors(void) { return m_bShowPifRamErrors; } + private: static void StaticRefreshSettings(CDebugSettings * _this) { @@ -51,7 +52,8 @@ private: static bool m_HaveExecutionBP; static bool m_HaveWriteBP; static bool m_HaveReadBP; - + static bool m_bShowPifRamErrors; + static int32_t m_RefCount; static bool m_Registered; };