Prev: BF6D Up: Map Next: BF84
BF74: Play Square Wave
Used by the routines at PlayWarbleSound, PlayNoiseSound and PlayWaveSequence.
Plays a single cycle of a square wave: the speaker is turned on for the duration and then off for the same duration.
Input
B Duration of wave
PlaySquareWave BF74 LD A,$10 A=10 (bit 4 turns the speaker on).
BF76 OUT ($FE),A Write A to port FE (border black, speaker on).
BF78 LD A,B Stash the duration in A.
PlaySquareWave_Loop BF79 DJNZ PlaySquareWave_Loop Decrease duration by one and loop back to PlaySquareWave_Loop until it is zero.
BF7B LD B,A Restore the duration to B.
BF7C XOR A A=00.
BF7D OUT ($FE),A Write A to port FE (border black, speaker off).
BF7F LD A,B Stash the duration in A.
Silence_Loop BF80 DJNZ Silence_Loop Decrease duration by one and loop back to Silence_Loop until it is zero.
BF82 LD B,A Restore the duration to B.
BF83 RET Return.
View the equivalent code in;
Prev: BF6D Up: Map Next: BF84