Prev: 41205 Up: Map Next: 41250
41223: Sounds: Weapon Pop
Used by the routine at Destroy_Creature.
Handler for the object type 139 which is also called directly to make a sound. It plays a run of tones of one cycle each, and the pitch of each one is made from a counter that falls by two each time.
The counter starts at the low byte of the frame counter plus one with its nibbles swapped, with the low four bits set and bit 7 cleared, so the sound is not always the same length. The half period is the counter exclusive ORed with 32 and rotated left.
Input
IX Object record
SoundsWeaponPop 41223 LD A,(23672) Fetch the low byte of the frame counter.
41226 INC A Add one.
41227 RLCA Rotate the result left four times, which swaps the nibbles.
41228 RLCA
41229 RLCA
41230 RLCA
41231 OR %00001111 Set the low four bits.
41233 AND %01111111 Clear bit 7.
41235 LD D,A Store the result as the tone counter.
SoundsWeaponPop_Loop 41236 LD A,D Fetch the tone counter.
41237 XOR %00100000 Flip bit 5.
41239 RLCA Rotate the result left to make the half period.
41240 LD B,A Store the half period in B.
41241 CALL SoundsClick Play the tone.
41244 DEC D Decrease the tone counter and return if all of the tones have been played.
41245 RET Z
41246 DEC D Decrease the tone counter again and return if all of the tones have been played.
41247 RET Z
41248 JR SoundsWeaponPop_Loop Jump back to play the next tone.
View the equivalent code in;
Prev: 41205 Up: Map Next: 41250