Prev: BEDE Up: Map Next: BF08
BEEE: 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 BEEE LD A,($9695) Fetch the random seed from RandomNumber into L.
BEF1 LD L,A
BEF2 LD A,($9693) Fetch the low byte of the game timer from GameTimer.
BEF5 AND %00011111 Keep only bits 0-4.
BEF7 LD H,A Store the result in H, so HL points to a byte of the ROM.
BEF8 LD E,$10 Set the number of tones in E to 10.
PlayExplosionSound_Loop BEFA LD A,(HL) Fetch a byte of the ROM, to use as noise.
BEFB INC HL Move on to the next byte of the ROM.
BEFC AND %01111111 Keep only bits 0-6.
BEFE LD B,A Store the result in B (the half-period).
BEFF LD C,$02 Set the number of cycles of each tone in C to 02.
BF01 CALL PlayWaveSequence Play the tone.
BF04 DEC E Decrease the tone counter by one and loop back to PlayExplosionSound_Loop until all of the tones have been played.
BF05 JR NZ,PlayExplosionSound_Loop
BF07 RET Return.
View the equivalent code in;
Prev: BEDE Up: Map Next: BF08