Prev: 41029 Up: Map Next: 41085
41064: 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 16 to port 254 sets the speaker bit and leaves the border black.
Input
B Half period of the tone
SoundsClick 41064 LD C,1 C=1 (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 41066 LD A,16 Switch the speaker on.
41068 OUT (254),A
41070 PUSH BC Stash the half period on the stack, as the wait counts B down to zero.
SoundsBeep_Speaker_On_Wait 41071 DJNZ SoundsBeep_Speaker_On_Wait Wait for the half period of the tone by counting down to zero.
41073 POP BC Restore the half period from the stack.
41074 PUSH BC Stash the half period on the stack again.
41075 XOR A Switch the speaker off.
41076 OUT (254),A
SoundsBeep_Speaker_Off_Wait 41078 DJNZ SoundsBeep_Speaker_Off_Wait Wait for the other half of the period by counting down to zero.
41080 POP BC Restore the half period from the stack.
41081 DEC C Decrease the cycle counter and loop back until all of the cycles have been played.
41082 JR NZ,SoundsBeep
41084 RET Return.
View the equivalent code in;
Prev: 41029 Up: Map Next: 41085