Routines
| Prev: E518 | Up: Map | Next: E57A |
E52F: Script helper: start a countdown for the actor
|
||||||||||||||
| E52F | DEFB $07,$07 | Action record header: flags $07; byte 1 $07 | ||||||||||||
| E531 | LD A,$02 | Load A with $02 - A 2-byte node | ||||||||||||
| E533 | CALL $A11C | Call the routine "Allocate A + 3 bytes from the free list, cleared" (A11C) | ||||||||||||
| E536 | LD HL,($9FE5) | Read countdowns (9FE5) into HL - Link it in at the head of the countdown list | ||||||||||||
| E539 | LD ($9FE5),IX | Store IX in countdowns (9FE5) | ||||||||||||
| E53D | LD (IX-$02),L | Store L in byte -2 of the record at IX | ||||||||||||
| E540 | LD (IX-$01),H | Store H in byte -1 of the record at IX | ||||||||||||
| E543 | LD A,($A036) | Read $A036 in "Game variables" into A - +0: whose countdown | ||||||||||||
| E546 | LD (IX+$00),A | Store A in the first byte of the record at IX | ||||||||||||
| E549 | LD A,($A035) | Read $A035 in "Game variables" into A - The random part, if any... | ||||||||||||
| E54C | LD B,$00 | Load B with $00 | ||||||||||||
| E54E | CP $FF | Compare A with $FF | ||||||||||||
| E550 | JR Z,$E556 | If A equals $FF, skip ahead to E556 | ||||||||||||
| E552 | CALL $D2A4 | Call the routine "A random number from 0 to A" (D2A4) - ...a random number from 0 to it | ||||||||||||
| E555 | LD B,A | Copy A into B | ||||||||||||
| E556 | LD A,($A034) | Read $A034 in "Game variables" into A - Plus the fixed part | ||||||||||||
| E559 | ADD A,B | Add B to A | ||||||||||||
| E55A | LD (IX+$01),A | +1: the count | ||||||||||||
| E55D | OR $01 | Make A non-zero, which clears the zero flag, and hand that back to the caller - Done | ||||||||||||
| E55F | RET | Return to the caller | ||||||||||||
| E560 | LD IX,$9FE7 | Point IX at SIGNAL tokens (9FE7) - Find the actor's countdown: Z if none | ||||||||||||
| E564 | CALL $A0F7 | Call the routine "Move IX to the next node of a list" (A0F7) | ||||||||||||
| E567 | RET Z | If the zero flag is set, return | ||||||||||||
| E568 | LD A,($A036) | Read $A036 in "Game variables" into A | ||||||||||||
| E56B | CP (IX+$00) | Compare A with the first byte of the record at IX | ||||||||||||
| E56E | JR NZ,$E564 | If A differs from the first byte of the record at IX, go back to E564 | ||||||||||||
| E570 | OR $01 | Make A non-zero, which clears the zero flag, and hand that back to the caller | ||||||||||||
| E572 | RET | Return to the caller | ||||||||||||
| E573 | CALL $E560 | Call E560 (inside "Script helper: start a countdown for the...") - Refuse if there is none | ||||||||||||
| E576 | JP Z,$DC15 | If the zero flag is set, go back to the routine "Fail: A = 0, HL = 0, Z set" (DC15) | ||||||||||||
| E579 | RET | Return to the caller | ||||||||||||
| Prev: E518 | Up: Map | Next: E57A |