all repos — mgba @ 67050e44dd98b358655e5813a54b4b40a6a81893

mGBA Game Boy Advance Emulator

LR35902: Implement HALT, RETI and CPL
Jeffrey Pfau jeffrey@endrift.com
Sun, 17 Jan 2016 03:35:16 -0800
commit

67050e44dd98b358655e5813a54b4b40a6a81893

parent

7a91b4a98aef707d996f559c8427974a74585695

2 files changed, 16 insertions(+), 3 deletions(-)

jump to
M src/lr35902/emitter-lr35902.hsrc/lr35902/emitter-lr35902.h

@@ -57,7 +57,7 @@ DECLARE_INSTRUCTION_LR35902(EMITTER, DECHL), \

DECLARE_INSTRUCTION_LR35902(EMITTER, INCL), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECL), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDL_), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, CPL_), \ DECLARE_INSTRUCTION_LR35902(EMITTER, JRNC), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDSP), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDDHLA), \

@@ -128,7 +128,7 @@ DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_D), \

DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_E), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_H), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_L), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, HALT), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_A), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_B), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_C), \

@@ -227,7 +227,7 @@ DECLARE_INSTRUCTION_LR35902(EMITTER, PUSHDE), \

DECLARE_INSTRUCTION_LR35902(EMITTER, SUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, RETC), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, RETI), \ DECLARE_INSTRUCTION_LR35902(EMITTER, JPC), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, CALLC), \
M src/lr35902/isa-lr35902.csrc/lr35902/isa-lr35902.c

@@ -121,6 +121,13 @@ cpu->index = cpu->sp; \

cpu->executionState = LR35902_CORE_MEMORY_LOAD; \ cpu->instruction = _LR35902InstructionRETUpdateSPH;) +DEFINE_INSTRUCTION_LR35902(RETI, + cpu->condition = true; + cpu->index = cpu->sp; + cpu->executionState = LR35902_CORE_MEMORY_LOAD; + cpu->irqh.setInterrupts(cpu, true); + cpu->instruction = _LR35902InstructionRETUpdateSPH;) + DEFINE_CONDITIONAL_INSTRUCTION_LR35902(RET) #define DEFINE_AND_INSTRUCTION_LR35902(NAME, OPERAND) \

@@ -520,6 +527,11 @@ cpu->f.c ^= 1;

cpu->f.h = 0; cpu->f.n = 0;) +DEFINE_INSTRUCTION_LR35902(CPL_, + cpu->a ^= 0xFF; + cpu->f.h = 1; + cpu->f.n = 1;) + #define DEFINE_POPPUSH_INSTRUCTION_LR35902(REG, HH, H, L) \ DEFINE_INSTRUCTION_LR35902(POP ## REG ## Delay, \ cpu-> L = cpu->bus; \

@@ -554,6 +566,7 @@ DEFINE_POPPUSH_INSTRUCTION_LR35902(AF, A, a, f.packed);

DEFINE_INSTRUCTION_LR35902(DI, cpu->irqh.setInterrupts(cpu, false)); DEFINE_INSTRUCTION_LR35902(EI, cpu->irqh.setInterrupts(cpu, true)); +DEFINE_INSTRUCTION_LR35902(HALT, cpu->cycles = cpu->nextEvent); DEFINE_INSTRUCTION_LR35902(STUB, cpu->irqh.hitStub(cpu));