Skip to content

Commit

Permalink
Add sound effects for heavy objects hitting the floor
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Nov 4, 2024
1 parent 1711d6e commit f0c4cf8
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/rooms/boss_city.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/rooms/city_building3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/rooms/lava_center.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/rooms/mine_west.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
83 changes: 83 additions & 0 deletions src/sounds/thud.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
;;;=========================================================================;;;
;;; Copyright 2022 Matthew D. Steele <[email protected]> ;;;
;;; ;;;
;;; 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 <http://www.gnu.org/licenses/>. ;;;
;;;=========================================================================;;;

.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

;;;=========================================================================;;;

0 comments on commit f0c4cf8

Please sign in to comment.