mirror of https://github.com/mgba-emu/mgba.git
SM83: Emulate HALT bug
This commit is contained in:
parent
3ef59bd2c4
commit
90e932e12c
1
CHANGES
1
CHANGES
|
@ -27,6 +27,7 @@ Emulation fixes:
|
|||
- GBA Video: Fix disabling OBJWIN in GL renderer (fixes mgba.io/i/1759)
|
||||
- GBA Video: Add missing parts of 256-color mode 0 mosaic (fixes mgba.io/1701)
|
||||
- GBA Video: Fix double-size OBJ wrapping in GL renderer (fixes mgba.io/1712)
|
||||
- SM83: Emulate HALT bug
|
||||
Other fixes:
|
||||
- 3DS: Fix framelimiter on newer citro3d (fixes mgba.io/i/1771)
|
||||
- All: Improve export headers (fixes mgba.io/i/1738)
|
||||
|
|
|
@ -47,7 +47,8 @@ enum SM83ExecutionState {
|
|||
SM83_CORE_MEMORY_STORE = 11,
|
||||
SM83_CORE_READ_PC = 15,
|
||||
SM83_CORE_STALL = 19,
|
||||
SM83_CORE_OP2 = 23
|
||||
SM83_CORE_OP2 = 23,
|
||||
SM83_CORE_HALT_BUG = 27,
|
||||
};
|
||||
struct SM83Memory {
|
||||
uint8_t (*cpuLoad8)(struct SM83Core*, uint16_t address);
|
||||
|
|
|
@ -749,8 +749,9 @@ void GBHalt(struct SM83Core* cpu) {
|
|||
if (!(gb->memory.ie & gb->memory.io[REG_IF] & 0x1F)) {
|
||||
cpu->cycles = cpu->nextEvent;
|
||||
cpu->halted = true;
|
||||
} else if (gb->model < GB_MODEL_CGB) {
|
||||
mLOG(GB, STUB, "Unimplemented HALT bug");
|
||||
} else {
|
||||
mLOG(GB, GAME_ERROR, "HALT bug");
|
||||
cpu->executionState = SM83_CORE_HALT_BUG;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,17 @@ static void _SM83Step(struct SM83Core* cpu) {
|
|||
case SM83_CORE_STALL:
|
||||
cpu->instruction = _sm83InstructionTable[0]; // NOP
|
||||
break;
|
||||
case SM83_CORE_HALT_BUG:
|
||||
if (cpu->irqPending) {
|
||||
cpu->index = cpu->sp;
|
||||
cpu->irqPending = false;
|
||||
cpu->instruction = _SM83InstructionIRQ;
|
||||
cpu->irqh.setInterrupts(cpu, false);
|
||||
break;
|
||||
}
|
||||
cpu->bus = cpu->memory.cpuLoad8(cpu, cpu->pc);
|
||||
cpu->instruction = _sm83InstructionTable[cpu->bus];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue