diff --git a/Core/display.c b/Core/display.c index dca6498..901bf03 100755 --- a/Core/display.c +++ b/Core/display.c @@ -680,8 +680,7 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) gb->oam_write_blocked = false; gb->vram_write_blocked = false; if (gb->hdma_on_hblank) { - gb->hdma_on = true; - gb->hdma_cycles = 0; + gb->hdma_starting = true; } gb->cycles_for_line++; GB_SLEEP(gb, display, 22, 1); diff --git a/Core/gb.h b/Core/gb.h index 8702629..2e646e1 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -289,6 +289,7 @@ struct GB_gameboy_internal_s { int16_t dma_cycles; bool is_dma_restarting; uint8_t last_opcode_read; /* Required to emulte HDMA reads from Exxx */ + bool hdma_starting; ); /* MBC */ diff --git a/Core/z80_cpu.c b/Core/z80_cpu.c index dc93ffa..28ceae6 100644 --- a/Core/z80_cpu.c +++ b/Core/z80_cpu.c @@ -1424,4 +1424,10 @@ void GB_cpu_run(GB_gameboy_t *gb) } opcodes[gb->last_opcode_read](gb, gb->last_opcode_read); } + + if (gb->hdma_starting) { + gb->hdma_starting = false; + gb->hdma_on = true; + gb->hdma_cycles = 0; + } }