Prev: F740 Up: Map Next: F90F
F8F9: Queue Sound
Queue a sound index in PendingSoundIndex for Play_QueuedSound. If bit 07 of A is set, force the queue (replace any pending sound). Otherwise keep the existing pending sound when one is already waiting Play_QueuedSound forms the parameter pointer as base F907 plus index×08. That base address F907 is the operand byte of the busy-check JR NZ, and it is never read as a sound parameter because indexes start at 01 (so the first block is at Table_SoundParameters).
Input
A Sound index (01–14), optionally with bit 07 set to force
Queue_Sound F8F9 BIT 7,A Is bit 07 set (force-queue)? If not, jump to Queue_Sound_UnlessBusy to queue only when idle.
F8FB JR Z,Queue_Sound_UnlessBusy
F8FD LD ($7309),A Write the sound index to PendingSoundIndex.
F900 RET Return.
Queue the sound index into PendingSoundIndex only when the queue is idle.
Queue_Sound_UnlessBusy F901 PUSH AF Stash AF on the stack.
F902 LD A,($7309) Fetch the pending sound index from PendingSoundIndex.
F905 OR A Is a sound already waiting? If so, jump to Queue_Sound_Busy.
F906 JR NZ,Queue_Sound_Busy
Finish Queue_Sound: write the new index when the queue was idle, or discard it when busy.
Queue_Sound_CommitOrDiscard F908 POP AF Restore the new index from the stack.
F909 LD ($7309),A Write it to PendingSoundIndex.
F90C RET Return.
Leave the pending sound in PendingSoundIndex unchanged when the queue is busy.
Queue_Sound_Busy F90D POP AF Restore AF from the stack (discard the new index).
F90E RET Return.
Prev: F740 Up: Map Next: F90F