From b078ca802f8f38e5602c8ce89d9b340ff0a6aacd Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Mon, 27 Mar 2023 16:36:26 -0400 Subject: Expose SRAM pointers for frontends that manage save data their own way (#1643) * Add a clarifying comment - In case it saves some poor bastard hours of fruitless work * Expose GBA and NDS save memory - Add GetSaveMemory and GetSaveMemoryLength functions - Where unsupported, they return null and zero --- src/NDSCart.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/NDSCart.cpp') diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index eaa6487..1e5a45b 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -383,6 +383,16 @@ void CartCommon::SetIRQ() NDS::SetIRQ(1, NDS::IRQ_CartIREQMC); } +u8 *CartCommon::GetSaveMemory() const +{ + return nullptr; +} + +u32 CartCommon::GetSaveMemoryLength() const +{ + return 0; +} + void CartCommon::ReadROM(u32 addr, u32 len, u8* data, u32 offset) { if (addr >= ROMLength) return; @@ -553,6 +563,16 @@ u8 CartRetail::SPIWrite(u8 val, u32 pos, bool last) } } +u8 *CartRetail::GetSaveMemory() const +{ + return SRAM; +} + +u32 CartRetail::GetSaveMemoryLength() const +{ + return SRAMLength; +} + void CartRetail::ReadROM_B7(u32 addr, u32 len, u8* data, u32 offset) { addr &= (ROMLength-1); @@ -1732,6 +1752,16 @@ void SetupDirectBoot(std::string romname) Cart->SetupDirectBoot(romname); } +u8* GetSaveMemory() +{ + return Cart ? Cart->GetSaveMemory() : nullptr; +} + +u32 GetSaveMemoryLength() +{ + return Cart ? Cart->GetSaveMemoryLength() : 0; +} + void EjectCart() { if (!CartInserted) return; -- cgit v1.2.3