Prev: 24907 Up: Map Next: 24949
24920: Sounds: Engine
Used by the routine at NextEntity.
Plays the engine sound: four square waves using PlaySquareWave. The period of the waves is 63 minus the speed divided by 4 so the faster the car is going, the higher the pitch. There is no sound when the car is stationary.
SoundsEngine 24920 LD A,(24077) Fetch the speed of the car from Speed.
24923 AND A Return if the car is stationary.
24924 RET Z
24925 RRCA Divide the speed by 4 by rotating it right twice.
24926 RRCA
24927 CPL Flip the bits, so the faster the car the shorter the period.
24928 AND %00111111 Keep only bits 0-5.
24930 LD D,A Set the period of the waves.
24931 LD C,4 Set the wave counter to 4.
24933 LD A,(24192) If Entity_Player is 3 then jump to SoundsEngine_Loop.
24936 CP 3
24938 JR Z,SoundsEngine_Loop
24940 LD B,12 Set the delay counter to 12 (this has no effect, as it is overwritten).
SoundsEngine_Loop 24942 CALL PlaySquareWave Play a square wave using PlaySquareWave.
24945 DEC C Decrease the wave counter by one and loop back to SoundsEngine_Loop until all 4 waves have been played.
24946 JR NZ,SoundsEngine_Loop
24948 RET Return.
Prev: 24907 Up: Map Next: 24949