maybe fix issue 375. GB text savestates are bumped (binary savestates are ok).

This commit is contained in:
goyuken 2015-01-20 22:18:38 +00:00
parent 85d6e985a0
commit d211bbd222
3 changed files with 15 additions and 15 deletions

View File

@ -23,15 +23,15 @@
namespace gambatte { namespace gambatte {
CPU::CPU() CPU::CPU()
: memory(Interrupter(SP, PC_)), : memory(Interrupter(SP, PC)),
cycleCounter_(0), cycleCounter_(0),
PC_(0x100), PC(0x100),
SP(0xFFFE), SP(0xFFFE),
HF1(0xF), HF1(0xF),
HF2(0xF), HF2(0xF),
ZF(0), ZF(0),
CF(0x100), CF(0x100),
A_(0x01), A(0x01),
B(0x00), B(0x00),
C(0x13), C(0x13),
D(0x00), D(0x00),
@ -93,9 +93,9 @@ void CPU::loadState(const SaveState &state) {
memory.loadState(state/*, cycleCounter_*/); memory.loadState(state/*, cycleCounter_*/);
cycleCounter_ = state.cpu.cycleCounter; cycleCounter_ = state.cpu.cycleCounter;
PC_ = state.cpu.PC & 0xFFFF; PC = state.cpu.PC & 0xFFFF;
SP = state.cpu.SP & 0xFFFF; SP = state.cpu.SP & 0xFFFF;
A_ = state.cpu.A & 0xFF; A = state.cpu.A & 0xFF;
B = state.cpu.B & 0xFF; B = state.cpu.B & 0xFF;
C = state.cpu.C & 0xFF; C = state.cpu.C & 0xFF;
D = state.cpu.D & 0xFF; D = state.cpu.D & 0xFF;
@ -488,11 +488,11 @@ void CPU::loadState(const SaveState &state) {
void CPU::process(const unsigned long cycles) { void CPU::process(const unsigned long cycles) {
memory.setEndtime(cycleCounter_, cycles); memory.setEndtime(cycleCounter_, cycles);
unsigned char A = A_; //unsigned char A = A_;
unsigned long cycleCounter = cycleCounter_; unsigned long cycleCounter = cycleCounter_;
while (memory.isActive()) { while (memory.isActive()) {
unsigned short PC = PC_; //unsigned short PC = PC_;
if (memory.halted()) { if (memory.halted()) {
if (cycleCounter < memory.nextEventTime()) { if (cycleCounter < memory.nextEventTime()) {
@ -2831,19 +2831,19 @@ void CPU::process(const unsigned long cycles) {
} }
} }
PC_ = PC; //PC_ = PC;
cycleCounter = memory.event(cycleCounter); cycleCounter = memory.event(cycleCounter);
} }
A_ = A; //A_ = A;
cycleCounter_ = cycleCounter; cycleCounter_ = cycleCounter;
} }
void CPU::GetRegs(int *dest) void CPU::GetRegs(int *dest)
{ {
dest[0] = PC_; dest[0] = PC;
dest[1] = SP; dest[1] = SP;
dest[2] = A_; dest[2] = A;
dest[3] = B; dest[3] = B;
dest[4] = C; dest[4] = C;
dest[5] = D; dest[5] = D;
@ -2857,13 +2857,13 @@ SYNCFUNC(CPU)
{ {
SSS(memory); SSS(memory);
NSS(cycleCounter_); NSS(cycleCounter_);
NSS(PC_); NSS(PC);
NSS(SP); NSS(SP);
NSS(HF1); NSS(HF1);
NSS(HF2); NSS(HF2);
NSS(ZF); NSS(ZF);
NSS(CF); NSS(CF);
NSS(A_); NSS(A);
NSS(B); NSS(B);
NSS(C); NSS(C);
NSS(D); NSS(D);

View File

@ -29,12 +29,12 @@ class CPU {
unsigned long cycleCounter_; unsigned long cycleCounter_;
unsigned short PC_; unsigned short PC;
unsigned short SP; unsigned short SP;
unsigned HF1, HF2, ZF, CF; unsigned HF1, HF2, ZF, CF;
unsigned char A_, B, C, D, E, /*F,*/ H, L; unsigned char A, B, C, D, E, /*F,*/ H, L;
bool skip; bool skip;

Binary file not shown.