SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit c36bdc22f66fbc58c82d4e3812e0110e50ece208 parent 60b89787622840b2f5cf1490d401a82fa0257a5d Author: Lior Halphon <LIJI32@gmail.com> Date: Sat, 14 Nov 2020 13:55:39 +0200 More accurate interrupt emulation Diffstat:
| M | Core/sm83_cpu.c | 18 | ++++++++++++++++-- |
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/Core/sm83_cpu.c b/Core/sm83_cpu.c @@ -261,7 +261,20 @@ static void cycle_oam_bug(GB_gameboy_t *gb, uint8_t register_id) } GB_trigger_oam_bug(gb, gb->registers[register_id]); /* Todo: test T-cycle timing */ gb->pending_cycles = 4; +} +static void cycle_oam_bug_pc(GB_gameboy_t *gb) +{ + if (GB_is_cgb(gb)) { + /* Slight optimization */ + gb->pending_cycles += 4; + return; + } + if (gb->pending_cycles) { + GB_advance_cycles(gb, gb->pending_cycles); + } + GB_trigger_oam_bug(gb, gb->pc); /* Todo: test T-cycle timing */ + gb->pending_cycles = 4; } static void flush_pending_cycles(GB_gameboy_t *gb) @@ -1538,8 +1551,9 @@ void GB_cpu_run(GB_gameboy_t *gb) gb->halted = false; uint16_t call_addr = gb->pc; - cycle_no_access(gb); - cycle_no_access(gb); + gb->last_opcode_read = cycle_read_inc_oam_bug(gb, gb->pc++); + cycle_oam_bug_pc(gb); + gb->pc--; GB_trigger_oam_bug(gb, gb->registers[GB_REGISTER_SP]); /* Todo: test T-cycle timing */ cycle_no_access(gb);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.