More accurate audio mixing in AGB mode, fixes #555

This commit is contained in:
Lior Halphon
2023-12-15 20:38:19 +02:00
parent fcf31be735
commit c7c2d08dc5

View File

@@ -89,19 +89,11 @@ static void update_sample(GB_gameboy_t *gb, GB_channel_t index, int8_t value, un
GB_sample_t output; GB_sample_t output;
uint8_t bias = agb_bias_for_channel(gb, index); uint8_t bias = agb_bias_for_channel(gb, index);
if (gb->io_registers[GB_IO_NR51] & (1 << index)) { bool right = gb->io_registers[GB_IO_NR51] & (1 << index);
output.right = (0xF - value * 2 + bias) * right_volume; bool left = gb->io_registers[GB_IO_NR51] & (0x10 << index);
}
else {
output.right = 0xF * right_volume;
}
if (gb->io_registers[GB_IO_NR51] & (0x10 << index)) { output.right = (0xF - (right? value : 7) * 2 + bias) * right_volume;
output.left = (0xF - value * 2 + bias) * left_volume; output.left = (0xF - (left? value : 7) * 2 + bias) * left_volume;
}
else {
output.left = 0xF * left_volume;
}
if (unlikely(gb->apu_output.channel_muted[index])) { if (unlikely(gb->apu_output.channel_muted[index])) {
output.left = output.right = 0; output.left = output.right = 0;