Prev: 47316 Up: Map Next: 47336
47322: Play Square Wave
Plays one cycle of a square wave through the speaker, with C setting the length of each half of the cycle.
Input
C Pitch (length of each half of the wave)
PlaySquareWave 47322 LD B,C Copy the pitch into B, then decrease it by one and jump back to Silence_Loop until it is zero.
Silence_Loop 47323 DJNZ Silence_Loop
47325 LD A,16 Write 16 to port 254 to turn the speaker on (bit 4).
47327 OUT (254),A
47329 LD B,C Copy the pitch into B, then decrease it by one and jump back to PlaySquareWave_Loop until it is zero.
PlaySquareWave_Loop 47330 DJNZ PlaySquareWave_Loop
47332 XOR A Write 0 to port 254 to turn the speaker off.
47333 OUT (254),A
47335 RET Return.
View the equivalent code in;
Prev: 47316 Up: Map Next: 47336