project64/Source/nragev20/GBCart.h

80 lines
2.1 KiB
C
Raw Normal View History

2016-01-27 09:11:59 +00:00
#ifndef _GBCART_H_
#define _GBCART_H_
#include <time.h>
#include <windows.h>
2016-01-27 09:11:59 +00:00
typedef struct _gbCartRTC {
UINT mapperSeconds;
UINT mapperMinutes;
UINT mapperHours;
UINT mapperDays;
UINT mapperControl;
UINT mapperLSeconds;
UINT mapperLMinutes;
UINT mapperLHours;
UINT mapperLDays;
UINT mapperLControl;
time_t mapperLastTime;
} gbCartRTC, *lpgbCartRTC;
typedef struct _GBCART
{
2020-02-09 11:36:49 +00:00
unsigned int iCurrentRomBankNo;
unsigned int iCurrentRamBankNo;
int iCartType;
bool bHasRam;
bool bHasBattery;
bool bHasTimer;
bool bHasRumble;
bool bRamEnableState;
bool bMBC1RAMbanking; // If false, use 2 magic bits for most significant bits of ROM banking (default); if true, use the 2 magic bits for RAM banking
2020-02-09 11:36:49 +00:00
unsigned int iNumRomBanks;
unsigned int iNumRamBanks;
BYTE TimerData[5];
BYTE LatchedTimerData[5];
time_t timerLastUpdate;
bool TimerDataLatched;
HANDLE hRomFile; // A file mapping handle
HANDLE hRamFile; // A file mapping handle, must be NULL if malloc'd RAM is being used instead of a valid memory mapped file
2020-02-09 11:36:49 +00:00
const unsigned char * RomData; // max [0x200 * 0x4000];
LPBYTE RamData; // max [0x10 * 0x2000];
bool (*ptrfnReadCart)(_GBCART * Cart, WORD dwAddress, BYTE *Data); // ReadCart handler
bool (*ptrfnWriteCart)(_GBCART * Cart, WORD dwAddress, BYTE *Data); // WriteCart handler
2016-01-27 09:11:59 +00:00
} GBCART, *LPGBCART;
bool LoadCart(LPGBCART Cart, LPCTSTR RomFile, LPCTSTR RamFile, LPCTSTR TdfFile);
// bool ReadCart(LPGBCART Cart, WORD dwAddress, BYTE *Data);
// bool WriteCart(LPGBCART Cart, WORD dwAddress, BYTE *Data);
bool SaveCart(LPGBCART Cart, LPTSTR SaveFile, LPTSTR TimeFile);
bool UnloadCart(LPGBCART Cart);
/*
iCartType values:
0 = no MBC
1 = MBC1
2 = MBC2
3 = MMMO1
4 = MBC3
5 = MBC5
6 = Pocket Camera
7 = TAMA 5
8 = HuC 3
9 = HuC 1
Note, that 7 and up are not implemented yet.
*/
2020-02-09 11:36:49 +00:00
#define GB_NORM 0x00
#define GB_MBC1 0x01
#define GB_MBC2 0x02
#define GB_MMMO1 0x03
#define GB_MBC3 0x04
#define GB_MBC5 0x05
#define GB_CAMERA 0x06
#define GB_TAMA5 0x07
#define GB_HUC3 0x08
#define GB_HUC1 0x09
2016-01-27 09:11:59 +00:00
#endif // #ifndef _GBCART_H_