diff options
author | Jesse Talavera-Greenberg <jesse@jesse.tg> | 2023-03-27 16:36:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 22:36:26 +0200 |
commit | b078ca802f8f38e5602c8ce89d9b340ff0a6aacd (patch) | |
tree | 6b55e20ee7b733e5305648626279c64153696b27 /src/NDSCart.cpp | |
parent | 808292e424a2554b7e2b3f0fd0e86120c1dbabd5 (diff) |
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
Diffstat (limited to 'src/NDSCart.cpp')
-rw-r--r-- | src/NDSCart.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
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; |