Prev: A045 Up: Map Next: A07D
A068: Sounds: Click
Used by the routines at SoundsSword, Play_Position_Sound and SoundsWeaponPop.
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.
The entry at SoundsBeep plays the number of cycles that is in C. The code that follows plays other tones by loading BC and jumping to that entry.
Writing 10 to port FE sets the speaker bit and leaves the border black.
Input
B Half period of the tone
SoundsClick A068 LD C,$01 C=01 (one cycle).
This entry point is used by the routines at Play_Low_Tone, Play_Alternating_Tone, SoundEffect, SoundEffectNext and SoundsBounce.
Play C cycles of the tone.
SoundsBeep A06A LD A,$10 Switch the speaker on.
A06C OUT ($FE),A
A06E PUSH BC Stash the half period on the stack, as the wait counts B down to zero.
SoundsBeep_Speaker_On_Wait A06F DJNZ SoundsBeep_Speaker_On_Wait Wait for the half period of the tone by counting down to zero.
A071 POP BC Restore the half period from the stack.
A072 PUSH BC Stash the half period on the stack again.
A073 XOR A Switch the speaker off.
A074 OUT ($FE),A
SoundsBeep_Speaker_Off_Wait A076 DJNZ SoundsBeep_Speaker_Off_Wait Wait for the other half of the period by counting down to zero.
A078 POP BC Restore the half period from the stack.
A079 DEC C Decrease the cycle counter and loop back until all of the cycles have been played.
A07A JR NZ,SoundsBeep
A07C RET Return.
View the equivalent code in;
Prev: A045 Up: Map Next: A07D