diff --git a/Core/apu.c b/Core/apu.c index c74bb6d..4e417d7 100755 --- a/Core/apu.c +++ b/Core/apu.c @@ -27,11 +27,11 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, uint8_t value, unsig if (gb->apu_output.sample_rate) { unsigned left_volume = 0; if (gb->io_registers[GB_IO_NR51] & (1 << index)) { - left_volume = gb->io_registers[GB_IO_NR50] & 7; + left_volume = (gb->io_registers[GB_IO_NR50] & 7) + 1; } unsigned right_volume = 0; 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) + 1; } GB_sample_t output = {(0xf - value) * left_volume, (0xf - value) * right_volume}; if (*(uint32_t *)&(gb->apu_output.current_sample[index]) != *(uint32_t *)&output) { diff --git a/Core/apu.h b/Core/apu.h index bace09a..44b3d45 100644 --- a/Core/apu.h +++ b/Core/apu.h @@ -6,9 +6,9 @@ #ifdef GB_INTERNAL -/* Divides nicely and never overflows with 4 channels and 8 volume levels */ -#define MAX_CH_AMP 0x1FFE -#define CH_STEP (MAX_CH_AMP/0xF/7) +/* Divides nicely and never overflows with 4 channels and 8 (1-8) volume levels */ +#define MAX_CH_AMP 0x1FE0 +#define CH_STEP (MAX_CH_AMP/0xF/8) #endif /* APU ticks are 2MHz, triggered by an internal APU clock. */