mirror of https://github.com/bsnes-emu/bsnes.git
Fix CGB timings
This commit is contained in:
parent
3e5e17d1a3
commit
c11af7ea26
|
@ -434,7 +434,9 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
|
|||
return;
|
||||
}
|
||||
|
||||
GB_SLEEP(gb, display, 23, 1);
|
||||
if (!gb->is_cgb) {
|
||||
GB_SLEEP(gb, display, 23, 1);
|
||||
}
|
||||
|
||||
/* Handle the very first line 0 */
|
||||
gb->current_line = 0;
|
||||
|
@ -464,8 +466,6 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
|
|||
gb->cycles_for_line += MODE3_LENGTH + (gb->io_registers[GB_IO_SCX] & 7) - 2;
|
||||
GB_SLEEP(gb, display, 3, MODE3_LENGTH + (gb->io_registers[GB_IO_SCX] & 7) - 2);
|
||||
|
||||
|
||||
|
||||
if (!gb->cgb_double_speed) {
|
||||
gb->io_registers[GB_IO_STAT] &= ~3;
|
||||
gb->oam_read_blocked = false;
|
||||
|
@ -676,14 +676,22 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
|
|||
gb->cycles_for_line++;
|
||||
GB_SLEEP(gb, display, 21, 1);
|
||||
}
|
||||
if (!gb->cgb_double_speed) {
|
||||
gb->io_registers[GB_IO_STAT] &= ~3;
|
||||
gb->oam_read_blocked = false;
|
||||
gb->vram_read_blocked = false;
|
||||
gb->oam_write_blocked = false;
|
||||
gb->vram_write_blocked = false;
|
||||
}
|
||||
|
||||
gb->cycles_for_line++;
|
||||
GB_SLEEP(gb, display, 22, 1);
|
||||
|
||||
gb->io_registers[GB_IO_STAT] &= ~3;
|
||||
gb->oam_read_blocked = false;
|
||||
gb->vram_read_blocked = false;
|
||||
gb->oam_write_blocked = false;
|
||||
gb->vram_write_blocked = false;
|
||||
|
||||
gb->cycles_for_line++;
|
||||
GB_SLEEP(gb, display, 22, 1);
|
||||
GB_STAT_update(gb);
|
||||
|
||||
/* Todo: Measure this value */
|
||||
|
|
|
@ -153,6 +153,13 @@ static void GB_timers_run(GB_gameboy_t *gb, uint8_t cycles)
|
|||
|
||||
void GB_advance_cycles(GB_gameboy_t *gb, uint8_t cycles)
|
||||
{
|
||||
/* It appears that on the CGB, write timing is a bit different then on the DMG, effectively
|
||||
making writes 1 T-cycle late when compared to the DMG. */
|
||||
if (gb->is_cgb) {
|
||||
cycles = (cycles + 1) & ~3;
|
||||
if (cycles == 0) return;
|
||||
}
|
||||
|
||||
// Affected by speed boost
|
||||
gb->dma_cycles += cycles;
|
||||
|
||||
|
@ -180,12 +187,6 @@ void GB_advance_cycles(GB_gameboy_t *gb, uint8_t cycles)
|
|||
|
||||
if (!gb->cgb_double_speed) {
|
||||
cycles <<= 1;
|
||||
if ((cycles & 6) == 2) {
|
||||
cycles--;
|
||||
}
|
||||
else if ((cycles & 6) == 6) {
|
||||
cycles++;
|
||||
}
|
||||
}
|
||||
|
||||
// Not affected by speed boost
|
||||
|
|
Loading…
Reference in New Issue