From 6078257f9806ba45af17d89731ba4031ba0cafb0 Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Wed, 20 Nov 2024 21:16:49 -0500 Subject: [PATCH] Rename/refactor some audio variables --- src/audio.asm | 92 +++++++++++++++++++++--------------------- src/audio.inc | 17 ++++---- src/inst.asm | 76 +++++++++++++++++----------------- src/sample.asm | 16 ++++---- src/sound.asm | 27 ++++++------- src/sounds/beep.asm | 14 +++---- src/sounds/dialog.asm | 14 +++---- src/sounds/explode.asm | 18 ++++----- 8 files changed, 136 insertions(+), 138 deletions(-) diff --git a/src/audio.asm b/src/audio.asm index 273aeb8d..b7c640bb 100644 --- a/src/audio.asm +++ b/src/audio.asm @@ -56,7 +56,7 @@ ;;; Assert that all the channel structs we use are exactly four bytes. This ;;; allows us to use four times the channel number as a byte index into any the ;;; struct arrays. -.ASSERT .sizeof(sChanInst) = 4, error +.ASSERT .sizeof(sChanCtrl) = 4, error .ASSERT .sizeof(sChanNext) = 4, error .ASSERT .sizeof(sChanNote) = 4, error .ASSERT .sizeof(sChanRegs) = 4, error @@ -125,15 +125,13 @@ Zp_AudioTmp_ptr: .res kSizeofAddr .SEGMENT "RAM_Audio" -;;; Music channel state for all the different APU channels. -.EXPORT Ram_Music_sChanInst_arr -Ram_Music_sChanInst_arr: .res .sizeof(sChanInst) * kNumApuChannels -.EXPORT Ram_Music_sChanNote_arr -Ram_Music_sChanNote_arr: .res .sizeof(sChanNote) * kNumApuChannels - -;;; SFX channel state for all the different APU channels. -.EXPORT Ram_Sound_sChanSfx_arr -Ram_Sound_sChanSfx_arr: .res .sizeof(sChanSfx) * kNumApuChannels +;;; Music/SFX channel state for all the different APU channels. +.EXPORT Ram_Audio_sChanCtrl_arr +Ram_Audio_sChanCtrl_arr: .res .sizeof(sChanCtrl) * kNumApuChannels +.EXPORT Ram_Audio_sChanNote_arr +Ram_Audio_sChanNote_arr: .res .sizeof(sChanNote) * kNumApuChannels +.EXPORT Ram_Audio_sChanSfx_arr +Ram_Audio_sChanSfx_arr: .res .sizeof(sChanSfx) * kNumApuChannels ;;;=========================================================================;;; @@ -169,7 +167,7 @@ _HaltSfx: lda #0 ldx #.sizeof(sChanSfx) * kNumApuChannels - 1 @loop: - sta Ram_Sound_sChanSfx_arr, x + sta Ram_Audio_sChanSfx_arr, x dex .assert .sizeof(sChanSfx) * kNumApuChannels <= $80, error bpl @loop @@ -216,17 +214,19 @@ _StartSfx: ;; If not, continue to the next channel. .assert eSound::None = 0, error beq @continue - ;; Otherwise, copy this sChanSfx struct into Ram_Sound_sChanSfx_arr. - sta Ram_Sound_sChanSfx_arr + sChanSfx::Sfx_eSound, x - lda Zp_Next_sChanSfx_arr + sChanSfx::Timer_u8, x - sta Ram_Sound_sChanSfx_arr + sChanSfx::Timer_u8, x + ;; Otherwise, copy this sChanSfx struct into Ram_Audio_sChanSfx_arr. + sta Ram_Audio_sChanSfx_arr + sChanSfx::Sfx_eSound, x lda Zp_Next_sChanSfx_arr + sChanSfx::Param1_byte, x - sta Ram_Sound_sChanSfx_arr + sChanSfx::Param1_byte, x + sta Ram_Audio_sChanSfx_arr + sChanSfx::Param1_byte, x lda Zp_Next_sChanSfx_arr + sChanSfx::Param2_byte, x - sta Ram_Sound_sChanSfx_arr + sChanSfx::Param2_byte, x + sta Ram_Audio_sChanSfx_arr + sChanSfx::Param2_byte, x + lda Zp_Next_sChanSfx_arr + sChanSfx::Param3_byte, x + sta Ram_Audio_sChanSfx_arr + sChanSfx::Param3_byte, x + lda #0 + sta Ram_Audio_sChanCtrl_arr + sChanCtrl::SfxRepeat_u8, x ;; Null out the Sfx_eSound field in Zp_Next_sAudioCtrl, so we don't restart ;; this SFX again next frame. - lda #eSound::None + .assert eSound::None = 0, error sta Zp_Next_sChanSfx_arr + sChanSfx::Sfx_eSound, x ;; Disable the channel that the sound is about to play on, so as to reset ;; its state (it'll get enabled again when we call the SFX function). @@ -264,13 +264,13 @@ _ResetChannels: tax ; now X is zero @loop: ;; At this point, A is still zero. - sta Ram_Music_sChanNote_arr + sChanNote::ElapsedFrames_u8, x - sta Ram_Music_sChanNote_arr + sChanNote::DurationFrames_u8, x - sta Ram_Music_sChanNote_arr + sChanNote::TimerLo_byte, x - sta Ram_Music_sChanNote_arr + sChanNote::TimerHi_byte, x - sta Ram_Music_sChanInst_arr + sChanInst::Instrument_eInst, x - sta Ram_Music_sChanInst_arr + sChanInst::Param_byte, x - sta Ram_Music_sChanInst_arr + sChanInst::RepeatCount_u8, x + sta Ram_Audio_sChanNote_arr + sChanNote::ElapsedFrames_u8, x + sta Ram_Audio_sChanNote_arr + sChanNote::DurationFrames_u8, x + sta Ram_Audio_sChanNote_arr + sChanNote::TimerLo_byte, x + sta Ram_Audio_sChanNote_arr + sChanNote::TimerHi_byte, x + sta Ram_Audio_sChanCtrl_arr + sChanCtrl::Instrument_eInst, x + sta Ram_Audio_sChanCtrl_arr + sChanCtrl::InstParam_byte, x + sta Ram_Audio_sChanCtrl_arr + sChanCtrl::ChainRepeat_u8, x .assert Data_Empty_bChain_arr = Data_Empty_sPhrase, error ldy #