mirror of https://github.com/bsnes-emu/bsnes.git
Compensate for prefetch in DIV’s initial value
This commit is contained in:
parent
629550c30b
commit
dbc338a887
|
@ -553,6 +553,9 @@ void GB_reset(GB_gameboy_t *gb)
|
|||
gb->io_registers[GB_IO_DMA] = gb->io_registers[GB_IO_OBP0] = gb->io_registers[GB_IO_OBP1] = GB_is_cgb(gb)? 0x00 : 0xFF;
|
||||
|
||||
gb->accessed_oam_row = -1;
|
||||
|
||||
/* Todo: Ugly, fixme, see comment in the timer state machine */
|
||||
gb->div_state = 3;
|
||||
|
||||
gb->magic = (uintptr_t)'SAME';
|
||||
}
|
||||
|
|
|
@ -144,9 +144,11 @@ static void GB_timers_run(GB_gameboy_t *gb, uint8_t cycles)
|
|||
GB_STATE_MACHINE(gb, div, cycles, 1) {
|
||||
GB_STATE(gb, div, 1);
|
||||
GB_STATE(gb, div, 2);
|
||||
GB_STATE(gb, div, 3);
|
||||
}
|
||||
|
||||
GB_set_internal_div_counter(gb, 0);
|
||||
main:
|
||||
GB_SLEEP(gb, div, 1, 3);
|
||||
while (true) {
|
||||
advance_tima_state_machine(gb);
|
||||
|
@ -154,6 +156,14 @@ static void GB_timers_run(GB_gameboy_t *gb, uint8_t cycles)
|
|||
gb->apu.apu_cycles += 4 << !gb->cgb_double_speed;
|
||||
GB_SLEEP(gb, div, 2, 4);
|
||||
}
|
||||
|
||||
/* Todo: This is ugly to allow compatibility with 0.11 save states. Fix me when breaking save compatibility */
|
||||
{
|
||||
div3:
|
||||
/* Compensate for lack of prefetch emulation, as well as DIV's internal initial value */
|
||||
GB_set_internal_div_counter(gb, 8);
|
||||
goto main;
|
||||
}
|
||||
}
|
||||
|
||||
void GB_advance_cycles(GB_gameboy_t *gb, uint8_t cycles)
|
||||
|
|
Loading…
Reference in New Issue