Prev: A39E Up: Map Next: A3BD
A3A8: Sounds: Click
Plays a tone on the speaker by switching it on and off. Each cycle is a wait of the half period with the speaker on and the same wait with the speaker off.
This entry plays one cycle (a click). The entry at SoundsBeep plays the number of cycles that is in C, and the routines which follow play other tones by loading BC and jumping to it.
Writing 10 to port FE sets the speaker bit and leaves the border black.
A single click is too short to be heard on its own, so there is no sample for it here. It is heard in the run of clicks played by SoundsWeaponPop (which has a sample), and in those played by SoundsAxeThrow, SoundsSword and SoundsFireball, and when the player falls through a trapdoor in FallThroughTrapdoor.
Input
B The half period of the tone (00 is 0100)
SoundsClick A3A8 LD C,$01 C=01 (one cycle).
Play C cycles of the tone.
SoundsBeep A3AA LD A,$10 A=10 (the speaker bit).
A3AC OUT ($FE),A Switch the speaker on.
A3AE PUSH BC Stash the cycle counter and the half period on the stack, as the wait counts B down to zero.
SoundsClick_OnDelay A3AF DJNZ SoundsClick_OnDelay Wait for the half period.
A3B1 POP BC Restore the cycle counter and the half period from the stack.
A3B2 PUSH BC Stash them on the stack again.
A3B3 XOR A A=00 (clear the speaker bit).
A3B4 OUT ($FE),A Switch the speaker off.
SoundsClick_OffDelay A3B6 DJNZ SoundsClick_OffDelay Wait for the half period.
A3B8 POP BC Restore the cycle counter and the half period from the stack.
A3B9 DEC C Decrease the cycle counter by one.
A3BA JR NZ,SoundsBeep Jump back to SoundsBeep until all of the cycles have been played.
A3BC RET Return.
View the equivalent code in;
Prev: A39E Up: Map Next: A3BD