Prev: B654 Up: Map Next: B676
B65F: Play Sound From Object Number
Plays a sound whose length and pitches depend on the sprite number of the object. Nothing in the game uses this routine.
Input
IX The address of the object
Work out the number of beeps from the sprite number.
PlaySoundFromObjectNumber B65F LD A,(IX+$00) Fetch the sprite number.
B662 RLCA Rotate it three times.
B663 RLCA
B664 RLCA
B665 AND %00011000 Keep only bits 3 and 4.
B667 ADD A,$10 Add 10.
B669 LD C,A Keep the number of beeps in C.
Play a beep of a pitch made from the remaining count.
PlaySoundFromObjectNumber_NextBeep B66A LD A,C Copy the number of beeps to A.
B66B XOR %01010101 Flip every other bit.
B66D ADD A,C Add the number of beeps.
B66E LD B,A Keep the pitch in B.
B66F CALL PlaySquareWave Call PlaySquareWave.
B672 DEC C Count down the beeps.
B673 JR NZ,PlaySoundFromObjectNumber_NextBeep Jump to PlaySoundFromObjectNumber_NextBeep until all of them have been played.
B675 RET Return.
View the equivalent code in;
Prev: B654 Up: Map Next: B676