From f0c4cf88261b4eaf14aab6b1c07bc9cf22caa9e4 Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Mon, 4 Nov 2024 08:28:00 -0500 Subject: [PATCH] Add sound effects for heavy objects hitting the floor --- src/rooms/boss_city.asm | 4 +- src/rooms/city_building3.asm | 7 +-- src/rooms/lava_center.asm | 3 +- src/rooms/mine_west.asm | 3 +- src/sounds/thud.asm | 83 ++++++++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 src/sounds/thud.asm diff --git a/src/rooms/boss_city.asm b/src/rooms/boss_city.asm index 5ff55739..42155bc0 100644 --- a/src/rooms/boss_city.asm +++ b/src/rooms/boss_city.asm @@ -1127,7 +1127,7 @@ _TryDropOffAmmo: ;; Error if the launcher machine already has a rocket loaded. lda Ram_MachineState1_byte_arr + kLauncherMachineIndex ; ammo count bne _Error - ;; TODO: play a sound + ;; TODO: play a sound for a rocket being transferred dec Ram_MachineState1_byte_arr + kReloaderMachineIndex ; ammo count inc Ram_MachineState1_byte_arr + kLauncherMachineIndex ; ammo count bne _StartWaiting ; unconditional @@ -1141,7 +1141,7 @@ _TryPickUpAmmo: and Ram_MachineState1_byte_arr + kAmmoRackMachineIndex ; ammo slot bits sta Ram_MachineState1_byte_arr + kAmmoRackMachineIndex ; ammo slot bits inc Ram_MachineState1_byte_arr + kReloaderMachineIndex ; ammo count - ;; TODO: play a sound + ;; TODO: play a sound for a rocket being transferred _StartWaiting: lda #kReloaderActCountdown ; param: num frames jmp FuncA_Machine_StartWaiting diff --git a/src/rooms/city_building3.asm b/src/rooms/city_building3.asm index 93324963..a1533608 100644 --- a/src/rooms/city_building3.asm +++ b/src/rooms/city_building3.asm @@ -50,6 +50,7 @@ .IMPORT FuncA_Objects_DrawCratePlatform .IMPORT FuncA_Objects_DrawLauncherMachineHorz .IMPORT FuncA_Objects_DrawReloaderMachine +.IMPORT FuncA_Room_PlaySfxThudSmall .IMPORT FuncA_Room_ResetLever .IMPORT Func_FindActorWithType .IMPORT Func_FindEmptyActorSlot @@ -455,7 +456,7 @@ _MakeCrate3Fall: ;; crate #1, then crate #3 is hitting crate #1 this frame. cmp T0 ; crate #3 dist above crate #1 blt @noHit - ;; TODO: play a sound for the crate landing + jsr FuncA_Room_PlaySfxThudSmall ; preserves T0+ ;; Zero crate #3's velocity, and move it to exactly hit crate #1. lda #0 sta Zp_RoomState + sState::Crate3SubY_u8 @@ -585,7 +586,7 @@ _TryDropOffAmmo: ;; Error if the launcher machine already has a rocket loaded. lda Ram_MachineState1_byte_arr + kLauncherMachineIndex ; ammo count bne _Error - ;; TODO: play a sound + ;; TODO: play a sound for a rocket being transferred dec Ram_MachineState1_byte_arr + kReloaderMachineIndex ; ammo count inc Ram_MachineState1_byte_arr + kLauncherMachineIndex ; ammo count bne _StartWaiting ; unconditional @@ -599,7 +600,7 @@ _TryPickUpAmmo: and Ram_MachineState1_byte_arr + kAmmoRackMachineIndex ; ammo slot bits sta Ram_MachineState1_byte_arr + kAmmoRackMachineIndex ; ammo slot bits inc Ram_MachineState1_byte_arr + kReloaderMachineIndex ; ammo count - ;; TODO: play a sound + ;; TODO: play a sound for a rocket being transferred _StartWaiting: lda #kReloaderActCountdown ; param: num frames jmp FuncA_Machine_StartWaiting diff --git a/src/rooms/lava_center.asm b/src/rooms/lava_center.asm index 4ca0cac2..3bb02b00 100644 --- a/src/rooms/lava_center.asm +++ b/src/rooms/lava_center.asm @@ -47,6 +47,7 @@ .IMPORT FuncA_Objects_DrawCratePlatform .IMPORT FuncA_Objects_MoveShapeDownOneTile .IMPORT FuncA_Objects_SetShapePosToPlatformTopLeft +.IMPORT FuncA_Room_PlaySfxThudSmall .IMPORT FuncA_Room_ReflectFireblastsOffMirror .IMPORT FuncA_Room_ResetLever .IMPORT FuncA_Room_TurnProjectilesToSmokeIfConsoleOpen @@ -648,7 +649,7 @@ _MaybeHitFloor: ;; floor, then the crate is hitting the floor this frame. cmp T0 ; crate dist above floor blt @noHit - ;; TODO: play a sound for the crate hitting the floor + jsr FuncA_Room_PlaySfxThudSmall ; preserves X and T0+ ;; Zero the crate's velocity, and move it to exactly hit the floor. lda #0 sta Zp_RoomState + sState::CrateSubY_u8_arr, x diff --git a/src/rooms/mine_west.asm b/src/rooms/mine_west.asm index dad256f1..27b8f69d 100644 --- a/src/rooms/mine_west.asm +++ b/src/rooms/mine_west.asm @@ -36,6 +36,7 @@ .IMPORT DataA_Room_Mine_sTileset .IMPORT FuncA_Machine_CraneMoveTowardGoal .IMPORT FuncA_Machine_GenericTryMoveZ +.IMPORT FuncA_Machine_PlaySfxThudBig .IMPORT FuncA_Machine_ReachedGoal .IMPORT FuncA_Machine_StartWaiting .IMPORT FuncA_Objects_Draw1x1Shape @@ -399,7 +400,7 @@ _MaybeHitFloor: ;; floor, then the cage is hitting the floor this frame. cmp T0 ; cage dist above floor blt @done - ;; TODO: play a sound for the cage hitting the floor + jsr FuncA_Machine_PlaySfxThudBig ; preserves T0+ lda #kCageShakeFrames ; param: shake frames jsr Func_ShakeRoom ; preserves T0+ ;; Zero the cage's velocity, and move it to exactly hit the floor. diff --git a/src/sounds/thud.asm b/src/sounds/thud.asm new file mode 100644 index 00000000..9a18d723 --- /dev/null +++ b/src/sounds/thud.asm @@ -0,0 +1,83 @@ +;;;=========================================================================;;; +;;; Copyright 2022 Matthew D. Steele ;;; +;;; ;;; +;;; This file is part of Annalog. ;;; +;;; ;;; +;;; Annalog is free software: you can redistribute it and/or modify it ;;; +;;; under the terms of the GNU General Public License as published by the ;;; +;;; Free Software Foundation, either version 3 of the License, or (at your ;;; +;;; option) any later version. ;;; +;;; ;;; +;;; Annalog is distributed in the hope that it will be useful, but WITHOUT ;;; +;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ;;; +;;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ;;; +;;; for more details. ;;; +;;; ;;; +;;; You should have received a copy of the GNU General Public License along ;;; +;;; with Annalog. If not, see . ;;; +;;;=========================================================================;;; + +.INCLUDE "../apu.inc" +.INCLUDE "../audio.inc" +.INCLUDE "../macros.inc" +.INCLUDE "../sound.inc" + +.IMPORT Func_PlaySfxSequenceNoise + +;;;=========================================================================;;; + +.SEGMENT "PRG8" + +;;; SFX sequence data for the "small thud" sound effect. +.PROC Data_ThudSmall_sSfxSeq_arr + D_STRUCT sSfxSeq + d_byte Duration_u8, 6 + d_byte Env_bEnvelope, bEnvelope::NoLength | 1 + d_byte Sweep_byte, 0 + d_word Timer_u16, $000c + D_END + .byte 0 +.ENDPROC + +;;; SFX sequence data for the "big thud" sound effect. +.PROC Data_ThudBig_sSfxSeq_arr + D_STRUCT sSfxSeq + d_byte Duration_u8, 24 + d_byte Env_bEnvelope, bEnvelope::NoLength | 5 + d_byte Sweep_byte, 0 + d_word Timer_u16, $000d + D_END + .byte 0 +.ENDPROC + +;;;=========================================================================;;; + +.SEGMENT "PRGA_Room" + +;;; Starts playing the sound for when smaller heavy object (like a crate) falls +;;; on the floor. +;;; @preserve X, T0+ +.EXPORT FuncA_Room_PlaySfxThudSmall +.PROC FuncA_Room_PlaySfxThudSmall + txa + pha + ldya #Data_ThudSmall_sSfxSeq_arr + jsr Func_PlaySfxSequenceNoise ; preserves T0+ + pla + tax + rts +.ENDPROC + +;;;=========================================================================;;; + +.SEGMENT "PRGA_Machine" + +;;; Starts playing the sound for when bigger heavy object falls on the floor. +;;; @preserve T0+ +.EXPORT FuncA_Machine_PlaySfxThudBig +.PROC FuncA_Machine_PlaySfxThudBig + ldya #Data_ThudBig_sSfxSeq_arr + jmp Func_PlaySfxSequenceNoise ; preserves T0+ +.ENDPROC + +;;;=========================================================================;;;