From 645ae2f7d3743aa9d9bd0d9b38b6a510c73a7129 Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Tue, 4 Feb 2025 11:45:09 -0700 Subject: [PATCH] stuff --- lib/audio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/audio.c b/lib/audio.c index 619127d..20ec596 100644 --- a/lib/audio.c +++ b/lib/audio.c @@ -95,7 +95,7 @@ static int audio_callback(const void* input_uffer, void *output_buffer, if(ctx.ch3_period_timer >= 0x800) { ctx.ch3_period_timer = ctx.ch3_period_reset; ctx.ch3_sample = (ctx.ch3_sample + 1) % 32; - if(ctx.ch3_sample & 0b1) { + if((ctx.ch3_sample & 0b1) == 0b1) { ctx.ch3_last_sample = ctx.wave_ram[ctx.ch3_sample >> 1] & 0xF; } else { ctx.ch3_last_sample = ctx.wave_ram[ctx.ch3_sample >> 1] >> 4; @@ -291,10 +291,10 @@ void audio_tick(){ } if(ctx.ch3_len_enable) { - ctx.ch3_len++; - if(ctx.ch3_len >= 256) { + if(ctx.ch3_len >= 255) { ctx.ch3_enable = false; } + ctx.ch3_len++; } if(ctx.ch4_len_enable) { @@ -409,12 +409,13 @@ void enable_wave() { return; } ctx.ch3_enable = true; - if(ctx.ch3_len >= 256) { + if(ctx.ch3_len == 255) { ctx.ch3_len = 0; } ctx.ch3_sample = 0; ctx.ch3_volume = ctx.ch3_initial_volume; ctx.ch3_period_timer = ctx.ch3_period_reset; + printf("channel 3 enabled\n"); } void enable_noise() { @@ -433,7 +434,7 @@ void enable_noise() { } u8 audio_read(u16 address) { - printf("read at %02X\n", address); + //printf("read at %02X\n", address); if(address == 0xFF26) { u8 value = (ctx.audio_enabled << 7) | (ctx.ch4_enable << 3) | (ctx.ch3_enable << 2) | (ctx.sq2_enable << 1) | (ctx.sq1_enable); return value | 0b01110000;