From dc3778ce557f89396bbbd1096cd3813f7f38de8b Mon Sep 17 00:00:00 2001 From: Nikita Zimin Date: Mon, 16 Dec 2024 03:44:04 +0300 Subject: [PATCH] Save/restore debugger breakpoints. --- emulator/Emulator.cpp | 9 ++++++++- emulator/main.h | 2 ++ emulator/settings.cpp | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/emulator/Emulator.cpp b/emulator/Emulator.cpp index b045e3d..22960a2 100644 --- a/emulator/Emulator.cpp +++ b/emulator/Emulator.cpp @@ -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 @@ -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); diff --git a/emulator/main.h b/emulator/main.h index 1698f16..cdd281f 100644 --- a/emulator/main.h +++ b/emulator/main.h @@ -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(); diff --git a/emulator/settings.cpp b/emulator/settings.cpp index 53457d3..cef4adc 100644 --- a/emulator/settings.cpp +++ b/emulator/settings.cpp @@ -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);