Prev: A0F5 Up: Map Next: A122
A107: Sounds: Weapon Pop
Used by the routine at Destroy_Creature.
Handler for the object type 8B 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 20 and rotated left.
Input
IX Object record
SoundsWeaponPop A107 LD A,($5C78) Fetch the low byte of the frame counter.
A10A INC A Add one.
A10B RLCA Rotate the result left four times, which swaps the nibbles.
A10C RLCA
A10D RLCA
A10E RLCA
A10F OR %00001111 Set the low four bits.
A111 AND %01111111 Clear bit 7.
A113 LD D,A Store the result as the tone counter.
SoundsWeaponPop_Loop A114 LD A,D Fetch the tone counter.
A115 XOR %00100000 Flip bit 5.
A117 RLCA Rotate the result left to make the half period.
A118 LD B,A Store the half period in B.
A119 CALL SoundsClick Play the tone.
A11C DEC D Decrease the tone counter and return if all of the tones have been played.
A11D RET Z
A11E DEC D Decrease the tone counter again and return if all of the tones have been played.
A11F RET Z
A120 JR SoundsWeaponPop_Loop Jump back to play the next tone.
View the equivalent code in;
Prev: A0F5 Up: Map Next: A122