Prev: 49005 Up: Map Next: 49028
49012: 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 49012 LD A,16 A=16 (bit 4 turns the speaker on).
49014 OUT (254),A Write A to port 254 (border black, speaker on).
49016 LD A,B Stash the duration in A.
PlaySquareWave_Loop 49017 DJNZ PlaySquareWave_Loop Decrease duration by one and loop back to PlaySquareWave_Loop until it is zero.
49019 LD B,A Restore the duration to B.
49020 XOR A A=0.
49021 OUT (254),A Write A to port 254 (border black, speaker off).
49023 LD A,B Stash the duration in A.
Silence_Loop 49024 DJNZ Silence_Loop Decrease duration by one and loop back to Silence_Loop until it is zero.
49026 LD B,A Restore the duration to B.
49027 RET Return.
View the equivalent code in;
Prev: 49005 Up: Map Next: 49028