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
This commit is contained in:
Jesse Talavera-Greenberg
2023-03-27 16:36:26 -04:00
committed by GitHub
parent 808292e424
commit b078ca802f
5 changed files with 99 additions and 0 deletions

View File

@ -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;