![]() |
Routines |
| Prev: F90F | Up: Map | Next: FA0E |
|
Used by the routines at GameStart, Update_Berk_State, Handle_Berk_Action, Print_EncodedMessage and Clear_AttributeFile.
Play the sound queued at PendingSoundIndex using the parameter block selected from base F907 (sound 01 starts at Table_SoundParameters), then clear the queue. The base F907 is the operand byte of JR NZ in Queue_Sound; it is never read as a parameter because indexes start at 01.
|
||||
|
Fetch the pending sound and return if the queue is empty.
|
||||
| Play_QueuedSound | F9AF | LD A,($7309) | Fetch the pending sound index from PendingSoundIndex. | |
| F9B2 | AND %01111111 | Keep only bits 00–06 (mask 7F). | ||
| F9B4 | RET Z | Return if the queue was empty. | ||
| F9B5 | PUSH IX | Stash IX on the stack. | ||
|
Point IX at this sound's parameter block and clear the queue.
|
||||
| F9B7 | ADD A,A | Multiply the index by 08. | ||
| F9B8 | ADD A,A | |||
| F9B9 | ADD A,A | |||
| F9BA | LD C,A | Keep the table offset in C. | ||
| F9BB | XOR A | Clear PendingSoundIndex. | ||
| F9BC | LD ($7309),A | |||
| F9BF | LD B,A | Clear B (high byte of the offset). | ||
| F9C0 | LD IX,$F907 | Point IX at F907 (operand of F906) plus the offset. | ||
| F9C4 | ADD IX,BC | |||
|
Load the tone parameters and play.
|
||||
| F9C6 | LD C,(IX+$00) | Load the outer repeat count from IX+00 into C. | ||
|
Outer repeat: reload pulse count and on/off delays from the parameter block.
|
||||
| Play_QueuedSound_RepeatLoop | F9C9 | LD B,(IX+$01) | Load the pulse count from IX+01 into B. | |
| F9CC | LD E,(IX+$02) | Load the speaker-off delay from IX+02 into E. | ||
| F9CF | LD D,(IX+$03) | Load the speaker-on delay from IX+03 into D. | ||
| F9D2 | LD H,(IX+$06) | Load the flags / waveform high byte from IX+06 into H. | ||
|
One speaker pulse: turn EAR on, delay, optional waveform, then EAR off.
|
||||
| Play_QueuedSound_PulseLoop | F9D5 | PUSH BC | Stash BC on the stack. | |
| F9D6 | LD A,($EA6C) | Fetch the border / speaker state from BorderSpeakerState. | ||
| F9D9 | SET 4,A | Set bit 04 (speaker on). | ||
| F9DB | OUT ($FE),A | Send it to the speaker (port FE). | ||
| F9DD | LD B,D | Keep the on-delay in B. | ||
|
Hold the speaker on for the on-delay in D.
|
||||
| Play_QueuedSound_OnDelay | F9DE | NOP | Hold for the on-delay. jump to Play_QueuedSound_OnDelay while it remains. | |
| F9DF | DJNZ Play_QueuedSound_OnDelay | |||
| F9E1 | BIT 7,H | Is the square-wave-only flag set? If so, jump to Play_QueuedSound_SpeakerOff. | ||
| F9E3 | JR NZ,Play_QueuedSound_SpeakerOff | |||
| F9E5 | LD B,(HL) | Fetch the next waveform delay into B. | ||
| F9E6 | INC HL | Advance the waveform pointer in HL. | ||
|
Pad the non-square waveform delay from the stream at HL.
|
||||
| Play_QueuedSound_WaveDelay | F9E7 | BIT 0,(IX+$00) | Timing pad for the waveform delay. | |
| F9EB | NOP | |||
| F9EC | NOP | |||
| F9ED | NOP | |||
| F9EE | NOP | |||
| F9EF | NOP | |||
| F9F0 | NOP | |||
| F9F1 | 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 | F9F3 | RES 4,A | Clear bit 04 (speaker off). | |
| F9F5 | OUT ($FE),A | Send it to the speaker (port FE). | ||
| F9F7 | 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 | F9F8 | NOP | Hold for the off-delay. jump to Play_QueuedSound_OffDelay while it remains. | |
| F9F9 | DJNZ Play_QueuedSound_OffDelay | |||
| F9FB | LD A,(IX+$04) | Add the on-delay delta from IX+04 to D. | ||
| F9FE | ADD A,D | |||
| F9FF | LD D,A | |||
| FA00 | LD A,(IX+$05) | Add the off-delay delta from IX+05 to E. | ||
| FA03 | ADD A,E | |||
| FA04 | LD E,A | |||
| FA05 | POP BC | Restore BC from the stack. | ||
| FA06 | DJNZ Play_QueuedSound_PulseLoop | Decrease the pulse counter and jump to Play_QueuedSound_PulseLoop while pulses remain. | ||
| FA08 | DEC C | Decrease the repeat counter. | ||
| FA09 | JR NZ,Play_QueuedSound_RepeatLoop | Jump to Play_QueuedSound_RepeatLoop while repeats remain. | ||
|
Housekeeping; restore the registers stashed at the start of the routine.
|
||||
| FA0B | POP IX | Restore IX from the stack. | ||
| FA0D | RET | Return. | ||
| Prev: F90F | Up: Map | Next: FA0E |