mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 15:50:00 -06:00
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:

committed by
GitHub

parent
808292e424
commit
b078ca802f
@ -52,6 +52,9 @@ public:
|
||||
|
||||
virtual u8 SPIWrite(u8 val, u32 pos, bool last);
|
||||
|
||||
virtual u8* GetSaveMemory() const;
|
||||
virtual u32 GetSaveMemoryLength() const;
|
||||
|
||||
protected:
|
||||
void ReadROM(u32 addr, u32 len, u8* data, u32 offset);
|
||||
|
||||
@ -88,6 +91,9 @@ public:
|
||||
|
||||
virtual u8 SPIWrite(u8 val, u32 pos, bool last) override;
|
||||
|
||||
virtual u8* GetSaveMemory() const override;
|
||||
virtual u32 GetSaveMemoryLength() const override;
|
||||
|
||||
protected:
|
||||
void ReadROM_B7(u32 addr, u32 len, u8* data, u32 offset);
|
||||
|
||||
@ -223,6 +229,19 @@ bool LoadROM(const u8* romdata, u32 romlen);
|
||||
void LoadSave(const u8* savedata, u32 savelen);
|
||||
void SetupDirectBoot(std::string romname);
|
||||
|
||||
/// This function is intended to allow frontends to save and load SRAM
|
||||
/// without using melonDS APIs.
|
||||
/// Modifying the emulated SRAM for any other reason is strongly discouraged.
|
||||
/// The returned pointer may be invalidated if the emulator is reset,
|
||||
/// or when a new game is loaded.
|
||||
/// Consequently, don't store the returned pointer for any longer than necessary.
|
||||
/// @returns Pointer to this cart's SRAM if a cart is loaded and supports SRAM, otherwise \c nullptr.
|
||||
u8* GetSaveMemory();
|
||||
|
||||
/// @returns The length of the buffer returned by ::GetSaveMemory()
|
||||
/// if a cart is loaded and supports SRAM, otherwise zero.
|
||||
u32 GetSaveMemoryLength();
|
||||
|
||||
void EjectCart();
|
||||
|
||||
void ResetCart();
|
||||
|
Reference in New Issue
Block a user