all repos — mgba @ b9e6ac954d606130f968878138163e304fdaa4c4

mGBA Game Boy Advance Emulator

LR35902: Fix RST timing
Jeffrey Pfau jeffrey@endrift.com
Wed, 27 Jan 2016 21:44:23 -0800
commit

b9e6ac954d606130f968878138163e304fdaa4c4

parent

da62e772a423de9e1b04a309047cc202058de7f7

1 files changed, 8 insertions(+), 6 deletions(-)

jump to
M src/lr35902/isa-lr35902.csrc/lr35902/isa-lr35902.c

@@ -741,18 +741,20 @@ DEFINE_INSTRUCTION_LR35902(HALT, cpu->irqh.halt(cpu));

#define DEFINE_RST_INSTRUCTION_LR35902(VEC) \ DEFINE_INSTRUCTION_LR35902(RST ## VEC ## UpdateSPL, \ + --cpu->sp; \ + cpu->index = cpu->sp; \ + cpu->bus = cpu->pc; \ cpu->pc = 0x ## VEC; \ - cpu->executionState = LR35902_CORE_STALL;) \ + cpu->executionState = LR35902_CORE_MEMORY_STORE; \ + cpu->instruction = _LR35902InstructionNOP;) \ DEFINE_INSTRUCTION_LR35902(RST ## VEC ## UpdateSPH, \ - cpu->index = cpu->sp + 1; \ + --cpu->sp;\ + cpu->index = cpu->sp; \ cpu->bus = cpu->pc >> 8; \ cpu->executionState = LR35902_CORE_MEMORY_STORE; \ cpu->instruction = _LR35902InstructionRST ## VEC ## UpdateSPL;) \ DEFINE_INSTRUCTION_LR35902(RST ## VEC, \ - cpu->sp -= 2; /* TODO: Atomic incrementing? */ \ - cpu->index = cpu->sp; \ - cpu->bus = cpu->pc; \ - cpu->executionState = LR35902_CORE_MEMORY_STORE; \ + cpu->executionState = LR35902_CORE_OP2; \ cpu->instruction = _LR35902InstructionRST ## VEC ## UpdateSPH;) DEFINE_RST_INSTRUCTION_LR35902(00);