diff options
Diffstat (limited to 'src/NDSCart.h')
-rw-r--r-- | src/NDSCart.h | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/NDSCart.h b/src/NDSCart.h index 9f39988..10286ac 100644 --- a/src/NDSCart.h +++ b/src/NDSCart.h @@ -1,5 +1,5 @@ /* - Copyright 2016-2021 Arisotura + Copyright 2016-2022 melonDS team This file is part of melonDS. @@ -19,7 +19,10 @@ #ifndef NDSCART_H #define NDSCART_H +#include <string> + #include "types.h" +#include "Savestate.h" #include "NDS_Header.h" #include "FATStorage.h" @@ -33,15 +36,16 @@ public: CartCommon(u8* rom, u32 len, u32 chipid); virtual ~CartCommon(); + virtual u32 Type() { return 0x001; } + virtual u32 Checksum(); + virtual void Reset(); - virtual void SetupDirectBoot(); + virtual void SetupDirectBoot(std::string romname); virtual void DoSavestate(Savestate* file); - virtual void LoadSave(const char* path, u32 type); - virtual void RelocateSave(const char* path, bool write); - virtual int ImportSRAM(const u8* data, u32 length); - virtual void FlushSRAMFile(); + virtual void SetupSave(u32 type); + virtual void LoadSave(const u8* savedata, u32 savelen); virtual int ROMCommandStart(u8* cmd, u8* data, u32 len); virtual void ROMCommandFinish(u8* cmd, u8* data, u32 len); @@ -71,14 +75,14 @@ public: CartRetail(u8* rom, u32 len, u32 chipid); virtual ~CartRetail() override; + virtual u32 Type() override { return 0x101; } + virtual void Reset() override; virtual void DoSavestate(Savestate* file) override; - virtual void LoadSave(const char* path, u32 type) override; - virtual void RelocateSave(const char* path, bool write) override; - virtual int ImportSRAM(const u8* data, u32 length) override; - virtual void FlushSRAMFile() override; + virtual void SetupSave(u32 type) override; + virtual void LoadSave(const u8* savedata, u32 savelen) override; virtual int ROMCommandStart(u8* cmd, u8* data, u32 len) override; @@ -95,11 +99,9 @@ protected: u32 SRAMLength; u32 SRAMType; - char SRAMPath[1024]; - bool SRAMFileDirty; - u8 SRAMCmd; u32 SRAMAddr; + u32 SRAMFirstAddr; u8 SRAMStatus; }; @@ -110,12 +112,13 @@ public: CartRetailNAND(u8* rom, u32 len, u32 chipid); ~CartRetailNAND() override; + virtual u32 Type() override { return 0x102; } + void Reset() override; void DoSavestate(Savestate* file) override; - void LoadSave(const char* path, u32 type) override; - int ImportSRAM(const u8* data, u32 length) override; + void LoadSave(const u8* savedata, u32 savelen) override; int ROMCommandStart(u8* cmd, u8* data, u32 len) override; void ROMCommandFinish(u8* cmd, u8* data, u32 len) override; @@ -139,6 +142,8 @@ public: CartRetailIR(u8* rom, u32 len, u32 chipid, u32 irversion); ~CartRetailIR() override; + virtual u32 Type() override { return 0x103; } + void Reset() override; void DoSavestate(Savestate* file) override; @@ -157,6 +162,8 @@ public: CartRetailBT(u8* rom, u32 len, u32 chipid); ~CartRetailBT() override; + virtual u32 Type() override { return 0x104; } + void Reset() override; void DoSavestate(Savestate* file) override; @@ -171,8 +178,10 @@ public: CartHomebrew(u8* rom, u32 len, u32 chipid); ~CartHomebrew() override; + virtual u32 Type() override { return 0x201; } + void Reset() override; - void SetupDirectBoot() override; + void SetupDirectBoot(std::string romname) override; void DoSavestate(Savestate* file) override; @@ -180,6 +189,7 @@ public: void ROMCommandFinish(u8* cmd, u8* data, u32 len) override; private: + void ApplyDLDIPatchAt(u8* binary, u32 dldioffset, const u8* patch, u32 patchlen, bool readonly); void ApplyDLDIPatch(const u8* patch, u32 patchlen, bool readonly); void ReadROM_B7(u32 addr, u32 len, u8* data, u32 offset); @@ -192,6 +202,7 @@ extern u32 ROMCnt; extern u8 ROMCommand[8]; +extern bool CartInserted; extern u8* CartROM; extern u32 CartROMSize; @@ -207,14 +218,12 @@ void Reset(); void DoSavestate(Savestate* file); void DecryptSecureArea(u8* out); -bool LoadROM(const char* path, const char* sram, bool direct); -bool LoadROM(const u8* romdata, u32 filelength, const char *sram, bool direct); - -void FlushSRAMFile(); -void RelocateSave(const char* path, bool write); +bool LoadROM(const u8* romdata, u32 romlen); +void LoadSave(const u8* savedata, u32 savelen); +void SetupDirectBoot(std::string romname); -int ImportSRAM(const u8* data, u32 length); +void EjectCart(); void ResetCart(); |