Prev: 46676 Up: Map Next: 46710
46687: 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 46687 LD A,(IX+0) Fetch the sprite number.
46690 RLCA Rotate it three times.
46691 RLCA
46692 RLCA
46693 AND %00011000 Keep only bits 3 and 4.
46695 ADD A,16 Add 16.
46697 LD C,A Keep the number of beeps in C.
Play a beep of a pitch made from the remaining count.
PlaySoundFromObjectNumber_NextBeep 46698 LD A,C Copy the number of beeps to A.
46699 XOR %01010101 Flip every other bit.
46701 ADD A,C Add the number of beeps.
46702 LD B,A Keep the pitch in B.
46703 CALL PlaySquareWave Call PlaySquareWave.
46706 DEC C Count down the beeps.
46707 JR NZ,PlaySoundFromObjectNumber_NextBeep Jump to PlaySoundFromObjectNumber_NextBeep until all of them have been played.
46709 RET Return.
View the equivalent code in;
Prev: 46676 Up: Map Next: 46710