Prev: F9C2 Up: Map Next: F9F0
F9C4: Asteroids : Generate a "hit lightning" sound
Used by the routine at F9F5.
The routine takes random bytes from 8000 - 9BFF and uses them as pairs of lengths to keep the speaker on or off, effectively determine the frequency and wave type.
F9C4 PUSH AF Store AF, BC and HL.
F9C5 PUSH BC
F9C6 PUSH HL
F9C7 LD HL,($F9C2) Get the current pointer to sound data.
F9CA LD B,$19 Loop 19 times.
F9CC PUSH BC Remember the count in BC.
F9CD LD B,(HL) Get the current frequency.
F9CE INC HL Move to the next position in the buffer.
F9CF LD A,$10 Turn the speaker on.
F9D1 OUT ($FE),A
F9D3 PUSH BC Remember the frequency count.
F9D4 DJNZ $F9D4 Loop to keep the speaker on for this time.
F9D6 POP BC Restore the count.
F9D7 LD B,(HL) Get the next frequency count.
F9D8 INC HL Move to the next place in the buffer.
F9D9 LD A,$00 Turn the speaker off.
F9DB OUT ($FE),A
F9DD DJNZ $F9DD Loop to keep the speaker off for this time.
F9DF POP BC Restore the count in BC.
F9E0 DJNZ $F9CC Loop while there is more to do.
F9E2 LD A,H If HL reaches 9C set it back to 80.
F9E3 CP $9C
F9E5 JR NZ,$F9E9
F9E7 LD H,$80
F9E9 LD ($F9C2),HL
F9EC POP HL Restore registers pushed earlier and return.
F9ED POP BC
F9EE POP AF
F9EF RET
Prev: F9C2 Up: Map Next: F9F0