mgba/src/gba/gba-savedata.h

53 lines
1.1 KiB
C
Raw Normal View History

2013-04-28 02:59:41 +00:00
#ifndef GBA_SAVEDATA_H
#define GBA_SAVEDATA_H
#include <stdint.h>
enum SavedataType {
SAVEDATA_NONE = 0,
SAVEDATA_SRAM,
SAVEDATA_FLASH512,
SAVEDATA_FLASH1M,
SAVEDATA_EEPROM
};
2013-04-28 04:51:58 +00:00
enum SavedataCommand {
EEPROM_COMMAND_NULL = 0,
EEPROM_COMMAND_PENDING = 1,
EEPROM_COMMAND_WRITE = 2,
EEPROM_COMMAND_READ_PENDING = 3,
EEPROM_COMMAND_READ = 4
};
2013-04-28 02:59:41 +00:00
enum {
SAVEDATA_FLASH_BASE = 0x0E005555
};
struct GBASavedata {
enum SavedataType type;
uint8_t* data;
const char* filename;
2013-04-28 04:51:58 +00:00
enum SavedataCommand command;
2013-04-28 02:59:41 +00:00
int fd;
2013-04-28 04:51:58 +00:00
int readBitsRemaining;
int readAddress;
int writeAddress;
int writePending;
int addressBits;
2013-04-28 02:59:41 +00:00
};
void GBASavedataInit(struct GBASavedata* savedata, const char* filename);
void GBASavedataDeinit(struct GBASavedata* savedata);
void GBASavedataInitFlash(struct GBASavedata* savedata);
2013-04-28 03:25:31 +00:00
void GBASavedataInitEEPROM(struct GBASavedata* savedata);
2013-04-28 02:59:41 +00:00
void GBASavedataInitSRAM(struct GBASavedata* savedata);
void GBASavedataWriteFlash(struct GBASavedata* savedata, uint8_t value);
2013-04-28 03:25:31 +00:00
uint16_t GBASavedataReadEEPROM(struct GBASavedata* savedata);
2013-04-28 04:51:58 +00:00
void GBASavedataWriteEEPROM(struct GBASavedata* savedata, uint16_t value, uint32_t writeSize);
2013-04-28 03:25:31 +00:00
2013-04-28 02:59:41 +00:00
#endif