Improved emulation of channel 3 wave RAM read glitch
This commit is contained in:
parent
e9629407a5
commit
f866441481
22
Core/apu.c
22
Core/apu.c
@ -598,10 +598,19 @@ void GB_apu_run(GB_gameboy_t *gb)
|
|||||||
gb->apu.apu_cycles = 0;
|
gb->apu.apu_cycles = 0;
|
||||||
if (!cycles) return;
|
if (!cycles) return;
|
||||||
|
|
||||||
if (unlikely(gb->apu.wave_channel.delayed_bugged_read)) {
|
if (unlikely(gb->apu.wave_channel.bugged_read_countdown)) {
|
||||||
gb->apu.wave_channel.delayed_bugged_read = false;
|
uint8_t cycles_left = cycles;
|
||||||
gb->apu.wave_channel.current_sample_byte =
|
while (cycles_left) {
|
||||||
gb->io_registers[GB_IO_WAV_START + (gb->address_bus & 0xF)];
|
cycles_left--;
|
||||||
|
if (--gb->apu.wave_channel.bugged_read_countdown == 0) {
|
||||||
|
gb->apu.wave_channel.current_sample_byte =
|
||||||
|
gb->io_registers[GB_IO_WAV_START + (gb->address_bus & 0xF)];
|
||||||
|
if (gb->apu.is_active[GB_WAVE]) {
|
||||||
|
update_wave_sample(gb, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool start_ch4 = false;
|
bool start_ch4 = false;
|
||||||
@ -707,12 +716,15 @@ void GB_apu_run(GB_gameboy_t *gb)
|
|||||||
gb->io_registers[GB_IO_WAV_START + (gb->address_bus & 0xF)];
|
gb->io_registers[GB_IO_WAV_START + (gb->address_bus & 0xF)];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gb->apu.wave_channel.delayed_bugged_read = true;
|
gb->apu.wave_channel.bugged_read_countdown = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cycles_left) {
|
if (cycles_left) {
|
||||||
gb->apu.wave_channel.sample_countdown -= cycles_left;
|
gb->apu.wave_channel.sample_countdown -= cycles_left;
|
||||||
}
|
}
|
||||||
|
if (gb->apu.wave_channel.sample_countdown == 0) {
|
||||||
|
gb->apu.wave_channel.bugged_read_countdown = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The noise channel can step even if inactive on the DMG
|
// The noise channel can step even if inactive on the DMG
|
||||||
|
@ -102,7 +102,7 @@ typedef struct
|
|||||||
uint8_t current_sample_byte; // Current sample byte.
|
uint8_t current_sample_byte; // Current sample byte.
|
||||||
bool wave_form_just_read;
|
bool wave_form_just_read;
|
||||||
bool pulsed;
|
bool pulsed;
|
||||||
bool delayed_bugged_read;
|
uint8_t bugged_read_countdown;
|
||||||
} wave_channel;
|
} wave_channel;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user