Prevent starting HDMA in the middle of an instruction, making both the CPU and DMA access memory at the same time. Closes #47
This commit is contained in:
parent
80b1275e07
commit
b50c97f4a7
@ -528,8 +528,7 @@ static void update_display_state(GB_gameboy_t *gb, uint8_t cycles)
|
|||||||
}
|
}
|
||||||
else if (position_in_line == MODE2_LENGTH + MODE3_LENGTH + stat_delay + scx_delay + 16) {
|
else if (position_in_line == MODE2_LENGTH + MODE3_LENGTH + stat_delay + scx_delay + 16) {
|
||||||
if (gb->hdma_on_hblank) {
|
if (gb->hdma_on_hblank) {
|
||||||
gb->hdma_on = true;
|
gb->hdma_starting = true;
|
||||||
gb->hdma_cycles = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,6 +276,7 @@ struct GB_gameboy_internal_s {
|
|||||||
int16_t dma_cycles;
|
int16_t dma_cycles;
|
||||||
bool is_dma_restarting;
|
bool is_dma_restarting;
|
||||||
uint8_t last_opcode_read; /* Required to emulte HDMA reads from Exxx */
|
uint8_t last_opcode_read; /* Required to emulte HDMA reads from Exxx */
|
||||||
|
bool hdma_starting;
|
||||||
);
|
);
|
||||||
|
|
||||||
/* MBC */
|
/* MBC */
|
||||||
|
@ -1402,4 +1402,10 @@ void GB_cpu_run(GB_gameboy_t *gb)
|
|||||||
else {
|
else {
|
||||||
GB_advance_cycles(gb, 4);
|
GB_advance_cycles(gb, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gb->hdma_starting) {
|
||||||
|
gb->hdma_starting = false;
|
||||||
|
gb->hdma_on = true;
|
||||||
|
gb->hdma_cycles = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user