Fix a sweep regression in DMG/SGB mode and CGB-C mode
@@ -454,7 +454,7 @@ static void trigger_sweep_calculation(GB_gameboy_t *gb)
/* Recalculation and overflow check only occurs after a delay */
gb->apu.square_sweep_calculate_countdown = (gb->io_registers[GB_IO_NR10] & 0x7) * 2 + 5 - gb->apu.lf_div;
if (gb->model <= GB_MODEL_CGB_C && gb->apu.lf_div) {
- gb->apu.square_sweep_calculate_countdown += 2;
+ // gb->apu.square_sweep_calculate_countdown += 2;
}
gb->apu.enable_zombie_calculate_stepping = false;
gb->apu.unshifted_sweep = !(gb->io_registers[GB_IO_NR10] & 0x7);
@@ -1102,7 +1102,10 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value)
/* APU bug: if shift is nonzero, overflow check also occurs on trigger */
gb->apu.square_sweep_calculate_countdown = (gb->io_registers[GB_IO_NR10] & 0x7) * 2 + 5 - gb->apu.lf_div;
if (gb->model <= GB_MODEL_CGB_C && gb->apu.lf_div) {
- gb->apu.square_sweep_calculate_countdown += 2;
+ /* TODO: I used to think this is correct, but it caused several regressions.
+ More research is needed to figure how calculation time is different
+ in models prior to CGB-D */
+ // gb->apu.square_sweep_calculate_countdown += 2;
}
gb->apu.enable_zombie_calculate_stepping = false;
gb->apu.unshifted_sweep = false;
