Skip to content

Commit

Permalink
Save/restore debugger breakpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Dec 16, 2024
1 parent a0e6323 commit dc3778c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion emulator/Emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ bool Emulator_Init()
m_wEmulatorCPUBpsCount = 0;
for (int i = 0; i <= MAX_BREAKPOINTCOUNT; i++)
{
m_EmulatorCPUBps[i] = 0177777;
uint16_t address = Settings_GetDebugBreakpoint(i);
m_EmulatorCPUBps[i] = address;
if (address != 0177777) m_wEmulatorCPUBpsCount = i + 1;
}

g_pBoard = new CMotherboard();

// Allocate memory for old RAM values
Expand Down Expand Up @@ -213,6 +216,10 @@ void Emulator_Done()
{
ASSERT(g_pBoard != nullptr);

// Save breakpoints
for (int i = 0; i < MAX_BREAKPOINTCOUNT; i++)
Settings_SetDebugBreakpoint(i, i < m_wEmulatorCPUBpsCount ? m_EmulatorCPUBps[i] : 0177777);

CProcessor::Done();

g_pBoard->SetSoundGenCallback(nullptr);
Expand Down
2 changes: 2 additions & 0 deletions emulator/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void Settings_SetAutostart(bool flag);
bool Settings_GetAutostart();
void Settings_SetSound(bool flag);
bool Settings_GetSound();
void Settings_SetDebugBreakpoint(int bpno, quint16 address);
quint16 Settings_GetDebugBreakpoint(int bpno);
void Settings_SetDebugMemoryAddress(quint16 address);
quint16 Settings_GetDebugMemoryAddress();
bool Settings_GetDebugMemoryByte();
Expand Down
17 changes: 17 additions & 0 deletions emulator/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ bool Settings_GetSound()
return value.toBool();
}

void Settings_SetDebugBreakpoint(int bpno, quint16 address)
{
char bufValueName[] = "DebugBreakpt0";
bufValueName[12] = bpno < 10 ? '0' + (char)bpno : 'A' + (char)(bpno - 10);
if (address == 0177777)
Global_getSettings()->remove(bufValueName);
else
Global_getSettings()->setValue(bufValueName, address);
}
quint16 Settings_GetDebugBreakpoint(int bpno)
{
char bufValueName[] = "DebugBreakpt0";
bufValueName[12] = bpno < 10 ? '0' + (char)bpno : 'A' + (char)(bpno - 10);
QVariant value = Global_getSettings()->value(bufValueName, 0177777);
return (quint16)value.toUInt();
}

void Settings_SetDebugMemoryAddress(quint16 mode)
{
Global_getSettings()->setValue("DebugMemoryAddress", mode);
Expand Down

0 comments on commit dc3778c

Please # to comment.