Prev: A39E Up: Map Next: A3BD
A3A8: Square wave on the beeper
Toggles bit 4 of port $FE with a busy-wait either side, which is the only way a 48K makes a sound. Every sound effect in the game is a call here, or a short sequence of them with different pitches.
Input
B Half-period: the delay between edges, so smaller is higher pitched
C Number of complete cycles, i.e. how long the note lasts
BEEP A3A8 LD C,$01 The plain entry point plays exactly one cycle; callers wanting a longer note enter below with C already set.
BEEP_BC A3AA LD A,$10 Speaker bit high.
A3AC OUT ($FE),A
A3AE PUSH BC
BEEP_0 A3AF DJNZ BEEP_0 The pitch: burn B iterations doing nothing.
A3B1 POP BC
A3B2 PUSH BC
A3B3 XOR A Speaker bit low again. This also writes 0 to the border bits, which is why the border stays black through every effect.
A3B4 OUT ($FE),A
BEEP_1 A3B6 DJNZ BEEP_1
A3B8 POP BC
A3B9 DEC C Repeat for C cycles.
A3BA JR NZ,BEEP_BC
A3BC RET
Prev: A39E Up: Map Next: A3BD