Prev: B4AD Up: Map Next: B4E6
B4BB: Play Footsteps Sound
Used by the routine at HandleWalking.
Plays the footsteps of the player walking, but only on every other frame of the walking animation. The number of cycles comes from the position of the player on the screen. The entry point at PlayFootstepsSound_EveryFrame plays them on every frame.
Input
IX Address of the object
Play on even frames of the walking animation.
PlayFootstepsSound B4BB LD A,(IX+$00) Fetch the graphic number of the object.
B4BE AND %00000001 Test whether it is an odd frame of the animation.
B4C0 RET NZ Return if it is.
This entry point is used by the routine at HandleTurning.
PlayFootstepsSound_EveryFrame B4C1 LD B,$60 Set the pitch.
B4C3 LD A,($5BA2) Fetch the frame counter from FrameCounter.
This entry point is used by the routine at PlayGuardFootstepsSound.
One time in two the pitch is made from the height of the object instead.
PlayFootstepsSound_Position B4C6 BIT 1,A Jump to PlayFootstepsSound_Cycles if a random bit of the seed is not set.
B4C8 JR Z,PlayFootstepsSound_Cycles
B4CA LD A,(IX+$03) Fetch the Z coordinate of the object.
B4CD CPL Invert it.
B4CE SRL A Halve it.
B4D0 LD B,A Use it as the pitch.
The number of cycles is the high nibble of half of the X coordinate added to half of the negated Y coordinate, which is the horizontal position on the screen.
PlayFootstepsSound_Cycles B4D1 LD A,(IX+$01) Fetch the X coordinate of the object.
B4D4 SRL A Halve it.
B4D6 LD C,A Stash it in C.
B4D7 LD A,(IX+$02) Fetch the Y coordinate of the object.
B4DA NEG Negate it.
B4DC SRL A Halve it.
B4DE ADD A,C Add the halved X coordinate.
B4DF RRCA Move the high nibble into the low nibble.
B4E0 RRCA
B4E1 RRCA
B4E2 RRCA
B4E3 AND %00001111 Keep the low nibble.
B4E5 LD C,A Use it as the number of cycles.
View the equivalent code in;
Prev: B4AD Up: Map Next: B4E6