Prev: 48862 Up: Map Next: 48904
48878: Play Explosion Sound
Used by the routine at BlowUpActor.
Plays sixteen short tones to make a burst of noise. The half-period of each tone is the low seven bits of a byte of the ROM, which is read from an address made from the low five bits of the frame counter (the high byte) and the random seed (the low byte).
PlayExplosionSound 48878 LD A,(38549) Fetch the random seed from RandomNumber into L.
48881 LD L,A
48882 LD A,(38547) Fetch the low byte of the game timer from GameTimer.
48885 AND %00011111 Keep only bits 0-4.
48887 LD H,A Store the result in H, so HL points to a byte of the ROM.
48888 LD E,16 Set the number of tones in E to 16.
PlayExplosionSound_Loop 48890 LD A,(HL) Fetch a byte of the ROM, to use as noise.
48891 INC HL Move on to the next byte of the ROM.
48892 AND %01111111 Keep only bits 0-6.
48894 LD B,A Store the result in B (the half-period).
48895 LD C,2 Set the number of cycles of each tone in C to 2.
48897 CALL PlayWaveSequence Play the tone.
48900 DEC E Decrease the tone counter by one and loop back to PlayExplosionSound_Loop until all of the tones have been played.
48901 JR NZ,PlayExplosionSound_Loop
48903 RET Return.
View the equivalent code in;
Prev: 48862 Up: Map Next: 48904