Prev: 6473 Up: Map Next: 649E
6485: Play Explosion Sound
Used by the routine at ExplodeBug.
Plays 20 square waves of falling pitch. A random value from RandomNumber is written over the operand of the instruction at 6494, which changes the durations, so this isn't the same twice.
PlayExplosionSound 6485 LD A,($5E19) Fetch the random value from RandomNumber.
6488 AND %01111111 Keep only bits 0-6.
648A OR %00110000 Set bits 4-5.
648C LD ($6495),A Write this over the operand of the instruction at 6494.
648F LD C,$20 Set the wave counter in C to 20.
PlayExplosionSound_Loop 6491 LD A,C Fetch the wave counter.
6492 XOR %00001111 Flip bits 0-3.
6494 AND %00011111 Keep only the bits set in the operand written at 648C.
6496 LD D,A Set the duration of the wave in D.
6497 CALL PlaySquareWave Call PlaySquareWave.
649A DEC C Decrease the wave counter by one.
649B JR NZ,PlayExplosionSound_Loop Loop back to PlayExplosionSound_Loop until all of the waves have been played.
649D RET Return.
Prev: 6473 Up: Map Next: 649E