Prev: 59634 Up: Map Next: 59821
59722: Set sound of index A as pending if appropriate, then play and clear pending sound
The sound with index A will become the pending sound if the currently pending sound index is either zero, or of higher index than A (i.e. lower priority).
On entering this routine, register L will have a pseudo-random (undefined) value due to the register's use in other routines.
Used by the routines at 34438, 41424, 47043 and 47955.
Input
A Sound index
L Undefined, pseudo-random value
59722 CALL 59613 Set pending sound index to A if it is currently zero, or lower priority
This entry point is used by the routine at 34438.
59725 LD A,(34273) Load A with index of pending sound and if this is zero then return
59728 OR A
59729 RET Z
59730 DEC A Decrease A to give zero-based sound index
59731 PUSH IX Store IX
59733 LD IX,59635 Point IX at second byte of first entry in sound parameters table
59737 ADD A,A Load BC with eight times pending sound index
59738 ADD A,A
59739 ADD A,A
59740 LD C,A
59741 LD B,0
59743 ADD IX,BC Add BC to IX as offset to point to sound data for pending sound
59745 LD A,B Set index of pending sound to zero
59746 LD (34273),A
59749 LD C,(IX+0) Load C with outer repeat count
59752 LD B,(IX+1) Load B with inner repeat count
59755 LD E,(IX+2) Load E with delay constant E
59758 LD D,(IX+3) Load D with delay constant D
59761 LD H,(IX+6) Load H with most significant byte of pseudo-random address
59764 PUSH BC Store BC (B = inner repeat count, C = outer repeat count)
59765 LD A,(34217) Set speaker state and border colour
59768 SET 4,A
59770 OUT (254),A
59772 LD B,D Pause for period D
59773 NOP
59774 DJNZ 59773
59776 BIT 7,H If no-pause flag is set then skip ahead to 59794
59778 JR NZ,59794
59780 LD B,(HL) Load B with value from pseudo-random address
59781 INC HL Advance HL
59782 BIT 0,(IX+0) Pause for period B
59786 NOP
59787 NOP
59788 NOP
59789 NOP
59790 NOP
59791 NOP
59792 DJNZ 59782
59794 RES 4,A Reset speaker state and set border colour
59796 OUT (254),A
59798 LD B,E Pause for period E
59799 NOP
59800 DJNZ 59799
59802 LD A,(IX+4) Adjust value of delay constant D
59805 ADD A,D
59806 LD D,A
59807 LD A,(IX+5) Adjust value of delay constant E
59810 ADD A,E
59811 LD E,A
59812 POP BC Restore BC (B = inner repeat count, C = outer repeat count)
59813 DJNZ 59764 Decrease repeat count and loop back to 59764
59815 DEC C Decrease outer repeat count
59816 JR NZ,59752 If non-zero (i.e. more repeats to process) then loop back to 59752
59818 POP IX Restore IX
59820 RET Return
Prev: 59634 Up: Map Next: 59821