Prev: DA9E Up: Map Next: DAC8
DAB2: Beep
Used by the routines at DAE5 and DDE0.
Input
B Length
DE Frequency
DAB2 LD A,($E800) Get the last read state of port FE. (E800)
DAB5 PUSH DE Remember DE.
First, toggle the bit on the speaker to start a square wave
DAB6 XOR $10 Toggle the speaker bit on the port.
DAB8 OUT ($FE),A
DABA LD C,A Remember this in C.
Now, wait a while, leaving the speaker in this state, then loop back, toggling the bit again to start a new wave.
DABB DEC DE Decrease the length.
DABC LD A,D Is it now zero?
DABD OR E
DABE JR NZ,$DABB Jump back if it isn't.
DAC0 POP DE Restore the wave length.
DAC1 LD A,C Restore the speaker state.
DAC2 DJNZ $DAB5 Loop back and toggle it again.
DAC4 LD ($E800),A Store the most recent state and return.
DAC7 RET
Prev: DA9E Up: Map Next: DAC8