Prev: 63759 Up: Map Next: 64014
63919: Play Queued Sound
Play the sound queued at PendingSoundIndex using the parameter block selected from base 63751 (sound 1 starts at Table_SoundParameters), then clear the queue. The base 63751 is the operand byte of JR NZ in Queue_Sound; it is never read as a parameter because indexes start at 1.
Fetch the pending sound and return if the queue is empty.
Play_QueuedSound 63919 LD A,(29449) Fetch the pending sound index from PendingSoundIndex.
63922 AND %01111111 Keep only bits 0–6 (mask 127).
63924 RET Z Return if the queue was empty.
63925 PUSH IX Stash IX on the stack.
Point IX at this sound's parameter block and clear the queue.
63927 ADD A,A Multiply the index by 8.
63928 ADD A,A
63929 ADD A,A
63930 LD C,A Keep the table offset in C.
63931 XOR A Clear PendingSoundIndex.
63932 LD (29449),A
63935 LD B,A Clear B (high byte of the offset).
63936 LD IX,63751 Point IX at 63751 (operand of 63750) plus the offset.
63940 ADD IX,BC
Load the tone parameters and play.
63942 LD C,(IX+0) Load the outer repeat count from IX+0 into C.
Outer repeat: reload pulse count and on/off delays from the parameter block.
Play_QueuedSound_RepeatLoop 63945 LD B,(IX+1) Load the pulse count from IX+1 into B.
63948 LD E,(IX+2) Load the speaker-off delay from IX+2 into E.
63951 LD D,(IX+3) Load the speaker-on delay from IX+3 into D.
63954 LD H,(IX+6) Load the flags / waveform high byte from IX+6 into H.
One speaker pulse: turn EAR on, delay, optional waveform, then EAR off.
Play_QueuedSound_PulseLoop 63957 PUSH BC Stash BC on the stack.
63958 LD A,(60012) Fetch the border / speaker state from BorderSpeakerState.
63961 SET 4,A Set bit 4 (speaker on).
63963 OUT (254),A Send it to the speaker (port 254).
63965 LD B,D Keep the on-delay in B.
Hold the speaker on for the on-delay in D.
Play_QueuedSound_OnDelay 63966 NOP Hold for the on-delay. jump to Play_QueuedSound_OnDelay while it remains.
63967 DJNZ Play_QueuedSound_OnDelay
63969 BIT 7,H Is the square-wave-only flag set? If so, jump to Play_QueuedSound_SpeakerOff.
63971 JR NZ,Play_QueuedSound_SpeakerOff
63973 LD B,(HL) Fetch the next waveform delay into B.
63974 INC HL Advance the waveform pointer in HL.
Pad the non-square waveform delay from the stream at HL.
Play_QueuedSound_WaveDelay 63975 BIT 0,(IX+0) Timing pad for the waveform delay.
63979 NOP
63980 NOP
63981 NOP
63982 NOP
63983 NOP
63984 NOP
63985 DJNZ Play_QueuedSound_WaveDelay Decrease the waveform delay and jump to Play_QueuedSound_WaveDelay while it remains.
Turn the speaker off and hold for the off-delay in E.
Play_QueuedSound_SpeakerOff 63987 RES 4,A Clear bit 4 (speaker off).
63989 OUT (254),A Send it to the speaker (port 254).
63991 LD B,E Keep the off-delay in B.
Hold the speaker off for the off-delay, then apply the per-pulse deltas.
Play_QueuedSound_OffDelay 63992 NOP Hold for the off-delay. jump to Play_QueuedSound_OffDelay while it remains.
63993 DJNZ Play_QueuedSound_OffDelay
63995 LD A,(IX+4) Add the on-delay delta from IX+4 to D.
63998 ADD A,D
63999 LD D,A
64000 LD A,(IX+5) Add the off-delay delta from IX+5 to E.
64003 ADD A,E
64004 LD E,A
64005 POP BC Restore BC from the stack.
64006 DJNZ Play_QueuedSound_PulseLoop Decrease the pulse counter and jump to Play_QueuedSound_PulseLoop while pulses remain.
64008 DEC C Decrease the repeat counter.
64009 JR NZ,Play_QueuedSound_RepeatLoop Jump to Play_QueuedSound_RepeatLoop while repeats remain.
Housekeeping; restore the registers stashed at the start of the routine.
64011 POP IX Restore IX from the stack.
64013 RET Return.
Prev: 63759 Up: Map Next: 64014