aboutsummaryrefslogtreecommitdiff
path: root/src/GBACart.h
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2022-01-07 14:00:43 +0100
committerGitHub <noreply@github.com>2022-01-07 14:00:43 +0100
commite665e25bd3ea4b9af932e182b1c93e77b762ccb0 (patch)
tree06b5ceb336e42868806113cbf1f45add2b56a3e8 /src/GBACart.h
parentc4cd9da674bcfb8dca89086ce3ffa2d3b03438eb (diff)
Custom path support (#1333)
also including: * getting rid of shitty strings * all new, cleaner ROM handling code * base for DSi savestates * GBA slot addons (for now, memory cart)
Diffstat (limited to 'src/GBACart.h')
-rw-r--r--src/GBACart.h62
1 files changed, 50 insertions, 12 deletions
diff --git a/src/GBACart.h b/src/GBACart.h
index 8698e25..13c6100 100644
--- a/src/GBACart.h
+++ b/src/GBACart.h
@@ -32,10 +32,15 @@ public:
CartCommon();
virtual ~CartCommon();
+ virtual u32 Type() { return 0x001; }
+ virtual u32 Checksum() { return 0; }
+
+ virtual void Reset();
+
virtual void DoSavestate(Savestate* file);
- virtual void LoadSave(const char* path, u32 type);
- virtual void RelocateSave(const char* path, bool write);
+ virtual void SetupSave(u32 type);
+ virtual void LoadSave(const u8* savedata, u32 savelen);
virtual int SetInput(int num, bool pressed);
@@ -53,10 +58,15 @@ public:
CartGame(u8* rom, u32 len);
virtual ~CartGame() override;
+ virtual u32 Type() override { return 0x101; }
+ virtual u32 Checksum() override;
+
+ 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 void SetupSave(u32 type) override;
+ virtual void LoadSave(const u8* savedata, u32 savelen) override;
virtual u16 ROMRead(u32 addr) override;
virtual void ROMWrite(u32 addr, u16 val) override;
@@ -107,11 +117,8 @@ protected:
} SRAMFlashState;
u8* SRAM;
- FILE* SRAMFile;
u32 SRAMLength;
SaveType SRAMType;
-
- char SRAMPath[1024];
};
// CartGameSolarSensor -- Boktai game cart
@@ -121,6 +128,10 @@ public:
CartGameSolarSensor(u8* rom, u32 len);
virtual ~CartGameSolarSensor() override;
+ virtual u32 Type() override { return 0x102; }
+
+ virtual void Reset() override;
+
virtual void DoSavestate(Savestate* file) override;
virtual int SetInput(int num, bool pressed) override;
@@ -136,6 +147,27 @@ private:
u8 LightLevel;
};
+// CartRAMExpansion -- RAM expansion cart (DS browser, ...)
+class CartRAMExpansion : public CartCommon
+{
+public:
+ CartRAMExpansion();
+ ~CartRAMExpansion() override;
+
+ virtual u32 Type() override { return 0x201; }
+
+ void Reset() override;
+
+ void DoSavestate(Savestate* file) override;
+
+ u16 ROMRead(u32 addr) override;
+ void ROMWrite(u32 addr, u16 val) override;
+
+private:
+ u8 RAM[0x800000];
+ u16 RAMEnable;
+};
+
// possible inputs for GBA carts that might accept user input
enum
{
@@ -146,17 +178,23 @@ enum
extern bool CartInserted;
extern u8* CartROM;
extern u32 CartROMSize;
-extern u32 CartCRC;
bool Init();
void DeInit();
void Reset();
-void Eject();
void DoSavestate(Savestate* file);
-bool LoadROM(const char* path, const char* sram);
-bool LoadROM(const u8* romdata, u32 filelength, const char *sram);
-void RelocateSave(const char* path, bool write);
+
+bool LoadROM(const u8* romdata, u32 romlen);
+void LoadSave(const u8* savedata, u32 savelen);
+
+void LoadAddon(int type);
+
+void EjectCart();
+
+//bool LoadROM(const char* path, const char* sram);
+//bool LoadROM(const u8* romdata, u32 filelength, const char *sram);
+//void RelocateSave(const char* path, bool write);
// TODO: make more flexible, support nonbinary inputs
int SetInput(int num, bool pressed);