Prev: 63296 Up: Map Next: 63759
63737: Queue Sound
Queue a sound index in PendingSoundIndex for Play_QueuedSound. If bit 7 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 63751 plus index×8. That base address 63751 is the operand byte of the busy-check JR NZ, and it is never read as a sound parameter because indexes start at 1 (so the first block is at Table_SoundParameters).
Input
A Sound index (1–20), optionally with bit 7 set to force
Queue_Sound 63737 BIT 7,A Is bit 7 set (force-queue)? If not, jump to Queue_Sound_UnlessBusy to queue only when idle.
63739 JR Z,Queue_Sound_UnlessBusy
63741 LD (29449),A Write the sound index to PendingSoundIndex.
63744 RET Return.
Queue the sound index into PendingSoundIndex only when the queue is idle.
Queue_Sound_UnlessBusy 63745 PUSH AF Stash AF on the stack.
63746 LD A,(29449) Fetch the pending sound index from PendingSoundIndex.
63749 OR A Is a sound already waiting? If so, jump to Queue_Sound_Busy.
63750 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 63752 POP AF Restore the new index from the stack.
63753 LD (29449),A Write it to PendingSoundIndex.
63756 RET Return.
Leave the pending sound in PendingSoundIndex unchanged when the queue is busy.
Queue_Sound_Busy 63757 POP AF Restore AF from the stack (discard the new index).
63758 RET Return.
Prev: 63296 Up: Map Next: 63759