Working on audio tests

This commit is contained in:
Samuel Walker 2025-02-13 14:16:37 -07:00
parent fc67151bfa
commit 8fc7992ca5
3 changed files with 13 additions and 8 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@ compile_commands.json
CTestTestfile.cmake
_deps
build/
.cache/
# ---> C++
# Prerequisites

View File

@ -279,8 +279,8 @@ void sq1_sweep() {
//overflow check
if(ctx.sq1_calc_period > 0x7FF) {
ctx.sq1_enable = false;
}
}
}
}
static int change = 1;
static u32 ticks = 0;
@ -373,9 +373,13 @@ void audio_tick(){
}
if((prev_ticks & (1 << 1)) && !(ticks & (1 << 1)) && ctx.sq1_sweep_enabled) {
ctx.sq1_sweep_timer++;
if((ctx.sq1_sweep_timer >= ctx.sq1_sweep_pace && ctx.sq1_sweep_pace > 0) || (ctx.sq1_sweep_timer >= 8 && ctx.sq1_sweep_pace == 0)) {
ctx.sq1_sweep_timer = 0;
ctx.sq1_sweep_timer--;
if(ctx.sq1_sweep_pace == 0) {
printf("sweep enabled without sweep pace\n");
}
if(ctx.sq1_sweep_timer <= 0){//(ctx.sq1_sweep_timer >= ctx.sq1_sweep_pace && ctx.sq1_sweep_pace > 0) || (ctx.sq1_sweep_timer >= 8 && ctx.sq1_sweep_pace == 0)) {
printf("sweep trigger Period: %d, Timer: %d\n", ctx.sq1_sweep_pace, ctx.sq1_sweep_timer);
ctx.sq1_sweep_timer = ctx.sq1_sweep_pace != 0 ? ctx.sq1_sweep_pace : 8;
if(ctx.sq1_enable && ctx.sq1_sweep_pace > 0 && ctx.sq1_sweep_enabled){
sq1_sweep();
if(ctx.sq1_calc_period <= 0x7FF && ctx.sq1_sweep_step != 0) {
@ -395,10 +399,9 @@ void enable_square1() {
ctx.sq1_volume = ctx.sq1_initial_volume;
ctx.sq1_env_timer = 0;
ctx.sq1_sweep_period = ctx.sq1_period_reset;
ctx.sq1_sweep_timer = 0;
ctx.sq1_sweep_timer = ctx.sq1_sweep_pace != 0 ? ctx.sq1_sweep_pace : 8;
ctx.sq1_env_direction = ctx.sq1_env_direction_buffer;
ctx.sq1_env_pace = ctx.sq1_env_pace_buffer;
ctx.sq1_sweep_enabled = ((ctx.sq1_sweep_pace != 0) || (ctx.sq1_sweep_step != 0));
if(ctx.sq1_sweep_step != 0) {
sq1_sweep();
}
@ -681,6 +684,7 @@ void audio_write(u16 address, u8 value){
ctx.sq1_sweep_pace = (value >> 4) & 0b111;
ctx.sq1_sweep_direction = value & 0x08;
ctx.sq1_sweep_step = value & 0b111;
ctx.sq1_sweep_enabled = ((ctx.sq1_sweep_pace != 0) || (ctx.sq1_sweep_step != 0));
}
if(address == 0xFF11) {
ctx.sq1_duty = value >> 6;

View File

@ -119,4 +119,4 @@ void cpu_set_ie_register(u8 ie){
void cpu_request_interrupt(interrupt_type t) {
ctx.int_flags |= t;
}
}