libgambatte: avoid bools in save state struct.

ensure boolean conversion on assignment.
master
sinamas 2015-03-22 17:26:20 +01:00
parent e8292b7bed
commit 5695cd55f2
2 changed files with 15 additions and 23 deletions

View File

@ -54,7 +54,7 @@ struct SaveState {
unsigned char f;
unsigned char h;
unsigned char l;
bool skip;
unsigned char /*bool*/ skip;
} cpu;
struct Mem {
@ -74,11 +74,11 @@ struct SaveState {
unsigned short dmaDestination;
unsigned char rambank;
unsigned char oamDmaPos;
bool IME;
bool halted;
bool enableRam;
bool rambankMode;
bool hdmaTransfer;
unsigned char /*bool*/ IME;
unsigned char /*bool*/ halted;
unsigned char /*bool*/ enableRam;
unsigned char /*bool*/ rambankMode;
unsigned char /*bool*/ hdmaTransfer;
} mem;
struct PPU {
@ -112,8 +112,8 @@ struct SaveState {
unsigned char oldWy;
unsigned char winDrawState;
unsigned char wscx;
bool weMaster;
bool pendingLcdstatIrq;
unsigned char /*bool*/ weMaster;
unsigned char /*bool*/ pendingLcdstatIrq;
} ppu;
struct SPU {
@ -121,7 +121,7 @@ struct SaveState {
unsigned long nextPosUpdate;
unsigned char nr3;
unsigned char pos;
bool high;
unsigned char /*bool*/ high;
};
struct Env {
@ -139,13 +139,13 @@ struct SaveState {
unsigned long counter;
unsigned short shadow;
unsigned char nr0;
bool negging;
unsigned char /*bool*/ negging;
} sweep;
Duty duty;
Env env;
LCounter lcounter;
unsigned char nr4;
bool master;
unsigned char /*bool*/ master;
} ch1;
struct {
@ -153,7 +153,7 @@ struct SaveState {
Env env;
LCounter lcounter;
unsigned char nr4;
bool master;
unsigned char /*bool*/ master;
} ch2;
struct {
@ -165,7 +165,7 @@ struct SaveState {
unsigned char nr4;
unsigned char wavePos;
unsigned char sampleBuf;
bool master;
unsigned char /*bool*/ master;
} ch3;
struct {
@ -176,7 +176,7 @@ struct SaveState {
Env env;
LCounter lcounter;
unsigned char nr4;
bool master;
unsigned char /*bool*/ master;
} ch4;
unsigned long cycleCounter;
@ -190,7 +190,7 @@ struct SaveState {
unsigned char dataH;
unsigned char dataM;
unsigned char dataS;
bool lastLatchData;
unsigned char /*bool*/ lastLatchData;
} rtc;
};

View File

@ -83,10 +83,6 @@ static void write(std::ofstream &file, unsigned long data) {
put32(file, data);
}
static inline void write(std::ofstream &file, bool data) {
write(file, static_cast<unsigned char>(data));
}
static void write(std::ofstream &file, unsigned char const *data, std::size_t size) {
put24(file, size);
file.write(reinterpret_cast<char const *>(data), size);
@ -134,10 +130,6 @@ static inline void read(std::ifstream &file, unsigned long &data) {
data = read(file);
}
static inline void read(std::ifstream &file, bool &data) {
data = read(file);
}
static void read(std::ifstream &file, unsigned char *buf, std::size_t bufsize) {
std::size_t const size = get24(file);
std::size_t const minsize = std::min(size, bufsize);