From 971793a53ca0c5cb397477bebacfd4dfd0df7f01 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 18 Oct 2025 15:39:11 +0100 Subject: [PATCH] Breakpoint card: add save/load state support --- source/Card.cpp | 8 +++++++- source/Debugger/BreakpointCard.cpp | 27 +++++++++++++++++++++++++++ source/Debugger/BreakpointCard.h | 5 +++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/source/Card.cpp b/source/Card.cpp index 67d2e832..e409e63e 100644 --- a/source/Card.cpp +++ b/source/Card.cpp @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Uthernet1.h" #include "Uthernet2.h" +#include "BreakpointCard.h" #include "Mockingboard.h" #include "ParallelPrinter.h" -#include "z80emu.h" #include "FourPlay.h" #include "LanguageCard.h" #include "MouseInterface.h" @@ -163,6 +163,8 @@ std::string Card::GetCardName(const SS_CARDTYPE cardType) return MockingboardCard::GetSnapshotCardNameMegaAudio(); case CT_SDMusic: return MockingboardCard::GetSnapshotCardNameSDMusic(); + case CT_BreakpointCard: + return BreakpointCard::GetSnapshotCardName(); default: return "Unknown"; } @@ -242,6 +244,10 @@ SS_CARDTYPE Card::GetCardType(const std::string & card) { return CT_SDMusic; } + else if (card == BreakpointCard::GetSnapshotCardName()) + { + return CT_BreakpointCard; + } else { throw std::runtime_error("Slots: Unknown card: " + card); // todo: don't throw - just ignore & continue diff --git a/source/Debugger/BreakpointCard.cpp b/source/Debugger/BreakpointCard.cpp index 748cb59a..dfc76e48 100644 --- a/source/Debugger/BreakpointCard.cpp +++ b/source/Debugger/BreakpointCard.cpp @@ -70,6 +70,7 @@ #include "Debug.h" #include "BreakpointCard.h" #include "Memory.h" +#include "YamlHelper.h" BreakpointCard::BreakpointCard(UINT slot) : Card(CT_BreakpointCard, slot), @@ -235,3 +236,29 @@ void BreakpointCard::Deferred(uint8_t type, uint16_t addrStart, uint16_t addrEnd } } + +//=========================================================================== + +static const UINT kUNIT_VERSION = 1; + +const std::string& BreakpointCard::GetSnapshotCardName(void) +{ + static const std::string name("Breakpoint"); + return name; +} + +void BreakpointCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper) +{ + YamlSaveHelper::Slot slot(yamlSaveHelper, GetSnapshotCardName(), m_slot, kUNIT_VERSION); + + YamlSaveHelper::Label unit(yamlSaveHelper, "%s: null\n", SS_YAML_KEY_STATE); + // NB. No state for this card +} + +bool BreakpointCard::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) +{ + if (version < 1 || version > kUNIT_VERSION) + ThrowErrorInvalidVersion(version); + + return true; +} diff --git a/source/Debugger/BreakpointCard.h b/source/Debugger/BreakpointCard.h index 7317bb11..eee38652 100644 --- a/source/Debugger/BreakpointCard.h +++ b/source/Debugger/BreakpointCard.h @@ -63,8 +63,9 @@ public: static void CbFunction(uint8_t slot, INTERCEPTBREAKPOINT interceptBreakpoint); - virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper) {} - virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) { return false; } + static const std::string& GetSnapshotCardName(void); + virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper); + virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version); private: static int SyncEventCallback(int id, int cycles, ULONG uExecutedCycles);