[Debugger] Make eeprom alerts to be able to turn on or off

This commit is contained in:
zilmar 2018-02-16 16:38:00 +11:00
parent 3fb6710bb3
commit 3388a053f3
6 changed files with 26 additions and 58 deletions

View File

@ -74,22 +74,22 @@ void CEeprom::EepromCommand(uint8_t * Command)
case 4: // Read from Eeprom case 4: // Read from Eeprom
if (Command[0] != 2 && HaveDebugger()) 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()) 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]); ReadFrom(&Command[4], Command[3]);
break; break;
case 5: //Write to Eeprom case 5: //Write to Eeprom
if (Command[0] != 10 && HaveDebugger()) 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()) 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]); WriteTo(&Command[4], Command[3]);
break; break;
@ -126,13 +126,13 @@ void CEeprom::EepromCommand(uint8_t * Command)
break; break;
case 8: case 8:
//Write RTC, unimplemented //Write RTC, unimplemented
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) if (bShowPifRamErrors())
{ {
g_Notify->DisplayError("Write RTC, unimplemented"); g_Notify->DisplayError("Write RTC, unimplemented");
} }
break; break;
default: default:
if (g_Settings->LoadDword(Debugger_ShowPifErrors)) if (bShowPifRamErrors())
{ {
g_Notify->DisplayError(stdstr_f("Unknown EepromCommand %d", Command[2]).c_str()); g_Notify->DisplayError(stdstr_f("Unknown EepromCommand %d", Command[2]).c_str());
} }
@ -201,3 +201,11 @@ void CEeprom::WriteTo(uint8_t * Buffer, int32_t line)
m_File.Write(Buffer, 8); m_File.Write(Buffer, 8);
} }
} }
void CEeprom::ProcessingError(uint8_t * /*Command*/)
{
if (bShowPifRamErrors())
{
g_Notify->DisplayError("What am I meant to do with this Eeprom Command");
}
}

View File

@ -12,7 +12,7 @@
#include <Project64-core/Settings/DebugSettings.h> #include <Project64-core/Settings/DebugSettings.h>
class CEeprom : class CEeprom :
private CDebugSettings protected CDebugSettings
{ {
public: public:
CEeprom(bool ReadOnly); CEeprom(bool ReadOnly);
@ -25,6 +25,7 @@ private:
CEeprom(const CEeprom&); // Disable copy constructor CEeprom(const CEeprom&); // Disable copy constructor
CEeprom& operator=(const CEeprom&); // Disable assignment CEeprom& operator=(const CEeprom&); // Disable assignment
void ProcessingError(uint8_t * Command);
void LoadEeprom(); void LoadEeprom();
void ReadFrom(uint8_t * Buffer, int32_t line); void ReadFrom(uint8_t * Buffer, int32_t line);
void WriteTo(uint8_t * Buffer, int32_t line); void WriteTo(uint8_t * Buffer, int32_t line);

View File

@ -22,33 +22,6 @@
#include <Project64-core/N64System/Mips/Mempak.h> #include <Project64-core/N64System/Mips/Mempak.h>
#include <Project64-core/Logging.h> #include <Project64-core/Logging.h>
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) : CPifRam::CPifRam(bool SavesReadOnly) :
CEeprom(SavesReadOnly) CEeprom(SavesReadOnly)
{ {

View File

@ -13,28 +13,8 @@
#include <Project64-core/Logging.h> #include <Project64-core/Logging.h>
#include <Project64-core/N64System/Mips/Eeprom.h> #include <Project64-core/N64System/Mips/Eeprom.h>
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 : class CPifRam :
public CLogging, public CLogging,
private CPifRamSettings,
private CEeprom private CEeprom
{ {
public: public:

View File

@ -27,6 +27,7 @@ bool CDebugSettings::m_RecordExecutionTimes = false;
bool CDebugSettings::m_HaveExecutionBP = false; bool CDebugSettings::m_HaveExecutionBP = false;
bool CDebugSettings::m_HaveWriteBP = false; bool CDebugSettings::m_HaveWriteBP = false;
bool CDebugSettings::m_HaveReadBP = false; bool CDebugSettings::m_HaveReadBP = false;
bool CDebugSettings::m_bShowPifRamErrors = false;
CDebugSettings::CDebugSettings() CDebugSettings::CDebugSettings()
{ {
@ -45,6 +46,7 @@ CDebugSettings::CDebugSettings()
g_Settings->RegisterChangeCB(Debugger_WriteBPExists, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_WriteBPExists, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_ReadBPExists, 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_WaitingForStep, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_ShowPifErrors, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
RefreshSettings(); RefreshSettings();
} }
@ -65,6 +67,7 @@ CDebugSettings::~CDebugSettings()
g_Settings->UnregisterChangeCB(Debugger_HaveExecutionBP, this, (CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_HaveExecutionBP, this, (CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_WriteBPExists, 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_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_HaveExecutionBP = m_HaveDebugger && g_Settings->LoadBool(Debugger_HaveExecutionBP);
m_HaveWriteBP = m_HaveDebugger && g_Settings->LoadBool(Debugger_WriteBPExists); m_HaveWriteBP = m_HaveDebugger && g_Settings->LoadBool(Debugger_WriteBPExists);
m_HaveReadBP = m_HaveDebugger && g_Settings->LoadBool(Debugger_ReadBPExists); 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); m_Debugging = m_HaveDebugger && (m_HaveExecutionBP || m_WaitingForStep || m_HaveWriteBP || m_HaveReadBP);
} }

View File

@ -30,6 +30,7 @@ public:
static inline bool HaveExecutionBP(void) { return m_HaveExecutionBP; } static inline bool HaveExecutionBP(void) { return m_HaveExecutionBP; }
static inline bool HaveWriteBP(void) { return m_HaveWriteBP; } static inline bool HaveWriteBP(void) { return m_HaveWriteBP; }
static inline bool HaveReadBP(void) { return m_HaveReadBP; } static inline bool HaveReadBP(void) { return m_HaveReadBP; }
static inline bool bShowPifRamErrors(void) { return m_bShowPifRamErrors; }
private: private:
static void StaticRefreshSettings(CDebugSettings * _this) static void StaticRefreshSettings(CDebugSettings * _this)
@ -51,6 +52,7 @@ private:
static bool m_HaveExecutionBP; static bool m_HaveExecutionBP;
static bool m_HaveWriteBP; static bool m_HaveWriteBP;
static bool m_HaveReadBP; static bool m_HaveReadBP;
static bool m_bShowPifRamErrors;
static int32_t m_RefCount; static int32_t m_RefCount;
static bool m_Registered; static bool m_Registered;