git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 76b881c2e153e164485814257fee472572dd8482
parent 967fdadd7cd6422ed4aaa853c8960c38b5bb28be
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Wed,  2 Feb 2022 23:01:38 +0200

More accurate HDMA during halt

Diffstat:
MCore/display.c2+-
MCore/sm83_cpu.c6++++++
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Core/display.c b/Core/display.c @@ -1773,7 +1773,7 @@ skip_slow_mode_3: GB_SLEEP(gb, display, 33, 2); gb->cgb_palettes_blocked = !gb->cgb_double_speed; - if (gb->hdma_on_hblank) { + if (gb->hdma_on_hblank && !gb->halted && !gb->stopped) { gb->hdma_on = true; } diff --git a/Core/sm83_cpu.c b/Core/sm83_cpu.c @@ -1617,6 +1617,9 @@ void GB_cpu_run(GB_gameboy_t *gb) /* Wake up from HALT mode without calling interrupt code. */ if (gb->halted && !effective_ime && interrupt_queue) { gb->halted = false; + if (gb->hdma_on_hblank && (gb->io_registers[GB_IO_STAT] & 3) == 0) { + gb->hdma_on = true; + } gb->dma_cycles = 4; GB_dma_run(gb); gb->speed_switch_halt_countdown = 0; @@ -1625,6 +1628,9 @@ void GB_cpu_run(GB_gameboy_t *gb) /* Call interrupt */ else if (effective_ime && interrupt_queue) { gb->halted = false; + if (gb->hdma_on_hblank && (gb->io_registers[GB_IO_STAT] & 3) == 0) { + gb->hdma_on = true; + } // TODO: verify the timing! gb->dma_cycles = 4; GB_dma_run(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.