Prev: 46310 Up: Map Next: 46333
46317: Play Square Wave
Plays a single beep by switching the speaker on, waiting, switching it off and waiting again. The bigger the pitch, the longer the beep.
Input
B Pitch of the tone (smaller values are higher)
Hold the speaker on, then off.
PlaySquareWave 46317 LD A,16 Set the speaker output high.
46319 OUT (254),A
46321 LD A,B Keep the pitch in A.
PlaySquareWave_FirstDelay 46322 DJNZ PlaySquareWave_FirstDelay Wait for the high part of the cycle.
46324 LD B,A Restore the pitch.
46325 XOR A Set the speaker output low.
46326 OUT (254),A
46328 LD A,B Keep the pitch in A.
PlaySquareWave_SecondDelay 46329 DJNZ PlaySquareWave_SecondDelay Wait for the low part of the cycle.
46331 LD B,A Restore the pitch.
46332 RET Return.
View the equivalent code in;
Prev: 46310 Up: Map Next: 46333