Prev: 24838 Up: Map Next: 24907
24859: Sounds: Cup/ Refuel
Used by the routine at 27291.
SoundsCupRefuel 24859 LD A,(24105) A=GameTimer.
24862 AND %00000001 Keep only bit 0.
24864 RET NZ Return every other frame.
24865 LD HL,24134 HL=SoundCounter.
24868 LD A,(HL) A=item ID.
24869 BIT 7,A Jump to SoundsCup if bit 7 is not set.
24871 JR NZ,SoundsCup
24873 AND A Return if item ID is zero.
24874 RET Z
24875 DEC A Decrease A/ item ID by one.
24876 LD (HL),A Store A at SoundCounter.
24877 RET Z Return if the new item ID is zero.
SoundsRefuel 24878 RLCA A=A * 4.
24879 RLCA
24880 AND %00011100 Keep only bits 2-4.
24882 OR %00100000 Set bit 5.
24884 LD D,A Store the result in D.
24885 LD C,32 C=32.
SoundsCupRefuel_Loop 24887 CALL PlaySquareWave Call PlaySquareWave.
24890 DEC C Decrease C by one.
24891 JR NZ,SoundsCupRefuel_Loop Jump back to SoundsCupRefuel_Loop until C is zero.
24893 RET Return.
SoundsCup 24894 AND %01111111 Keep only bits 0-6.
24896 RET Z Return if A is now zero.
24897 DEC A Decrease A by one.
24898 OR %10000000 Set bit 7.
24900 LD (HL),A Store A at SoundCounter.
24901 AND %01111111 Keep only bits 0-6.
24903 RET Z Return if A is now zero.
24904 CPL Flip the bits.
24905 JR SoundsRefuel Jump to SoundsRefuel.
Prev: 24838 Up: Map Next: 24907