Turns out APU signal is inverted. This fixes Perfect Dark’s audio.

This commit is contained in:
Lior Halphon 2017-08-12 20:47:55 +03:00
parent 688991f57f
commit dba7370d6d

View File

@ -33,7 +33,7 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, uint8_t value, unsig
if (gb->io_registers[GB_IO_NR51] & (0x10 << index)) { if (gb->io_registers[GB_IO_NR51] & (0x10 << index)) {
right_volume = (gb->io_registers[GB_IO_NR50] >> 4) & 7;; right_volume = (gb->io_registers[GB_IO_NR50] >> 4) & 7;;
} }
GB_sample_t output = {value * left_volume, value * right_volume}; GB_sample_t output = {(0xf - value) * left_volume, (0xf - value) * right_volume};
if (*(uint32_t *)&(gb->apu_output.current_sample[index]) != *(uint32_t *)&output) { if (*(uint32_t *)&(gb->apu_output.current_sample[index]) != *(uint32_t *)&output) {
refresh_channel(gb, index, cycles_offset); refresh_channel(gb, index, cycles_offset);
gb->apu_output.current_sample[index] = output; gb->apu_output.current_sample[index] = output;