Turns out the AGB inverts Channel 3’s output

This commit is contained in:
Lior Halphon 2019-06-01 18:22:58 +03:00
parent 6888047102
commit 4c34e0a6e0

View File

@ -59,6 +59,11 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsign
unsigned right_volume = (gb->io_registers[GB_IO_NR50] & 7) + 1; unsigned right_volume = (gb->io_registers[GB_IO_NR50] & 7) + 1;
unsigned left_volume = ((gb->io_registers[GB_IO_NR50] >> 4) & 7) + 1; unsigned left_volume = ((gb->io_registers[GB_IO_NR50] >> 4) & 7) + 1;
if (index == GB_WAVE) {
/* For some reason, channel 3 is inverted on the AGB */
value ^= 0xF;
}
GB_sample_t output; GB_sample_t output;
if (gb->io_registers[GB_IO_NR51] & (1 << index)) { if (gb->io_registers[GB_IO_NR51] & (1 << index)) {
output.right = (0xf - value * 2) * right_volume; output.right = (0xf - value * 2) * right_volume;