Routines
| Prev: C57A | Up: Map | Next: C5FC |
C583: Pick one of the 13 numbered action records
|
A = a record number with bit 7 set (a verb of 128 or more, from a DO in a plan script). Looks the record up in the table at 9FAB, then copies the low nibble of its byte 0 to $A00F and of its byte 1 to $A010 (via C571 and C57A), and clears $A00B.
CB41 is taken to be the "return Z" stub; the guessing loops only try candidates until the record runs, as the helpers at C463/C60D/C613 describe.
How it works:
1. The record number (bit 7 dropped) indexes the 13 record addresses at 9FAB.
3. If the record takes no objects, run it at once (C5F4). If the direct object must be a number, $A034 must be $FE or the command is refused.
4.
|
||||||||||||
| C583 | AND $7F | Record number (bit 7 dropped) into DE | ||||||||||
| C585 | LD E,A | Copy A into E | ||||||||||
| C586 | LD D,$00 | Load D with $00 | ||||||||||
| C588 | LD HL,$9FAB | Look it up in the table of 13 record addresses at 9FAB (2 bytes each)... | ||||||||||
| C58B | ADD HL,DE | Add DE to HL | ||||||||||
| C58C | ADD HL,DE | Add DE to HL | ||||||||||
| C58D | LD E,(HL) | ... | ||||||||||
| C58E | INC HL | Step HL on to the next byte | ||||||||||
| C58F | LD D,(HL) | Read the byte HL points at into D | ||||||||||
| C590 | EX DE,HL | IX = HL = the record | ||||||||||
|
This entry point is used by the routine at CE18.
|
||||||||||||
| C591 | PUSH HL | Save HL on the stack | ||||||||||
| C592 | POP IX | Restore IX from the stack | ||||||||||
| C594 | CALL $C571 | $A00F = requirement code of the direct object from the record's header (C571) | ||||||||||
| C597 | CALL $C57A | $A010 = the indirect object's (C57A) | ||||||||||
| C59A | XOR A | $A00B = 0 | ||||||||||
| C59B | LD ($A00B),A | Store A in $A00B in "Game variables" | ||||||||||
| C59E | LD A,($A00F) | Read $A00F in "Game variables" into A - Both requirement codes zero (the record takes no objects)? | ||||||||||
| C5A1 | LD HL,$A010 | Point HL at $A010 in "Game variables" | ||||||||||
| C5A4 | OR (HL) | Set in A the bits that are set in the byte at $A010 in "Game variables" | ||||||||||
| C5A5 | JR Z,$C5F4 | Yes: run the record at once (C5F4) | ||||||||||
| C5A7 | LD A,($A00F) | Read $A00F in "Game variables" into A - Direct object a number (code 5 or 6)? | ||||||||||
| C5AA | CP $05 | Compare A with $05 | ||||||||||
| C5AC | JR Z,$C5B2 | If A equals $05, skip ahead to C5B2 | ||||||||||
| C5AE | CP $06 | Compare A with $06 | ||||||||||
| C5B0 | JR NZ,$C5BA | If A differs from $06, skip ahead to C5BA | ||||||||||
| C5B2 | LD A,($A034) | Read $A034 in "Game variables" into A - Then $A034 must already hold $FE ('a number was given')... | ||||||||||
| C5B5 | CP $FE | Compare A with $FE | ||||||||||
| C5B7 | JP NZ,$CB41 | ...if not, give up: Z (CB41) | ||||||||||
| C5BA | LD A,($A010) | Read $A010 in "Game variables" into A - Same test for the indirect object and $A035 | ||||||||||
| C5BD | CP $05 | Compare A with $05 | ||||||||||
| C5BF | JR Z,$C5C5 | If A equals $05, skip ahead to C5C5 | ||||||||||
| C5C1 | CP $06 | Compare A with $06 | ||||||||||
| C5C3 | JR NZ,$C5CD | If A differs from $06, skip ahead to C5CD | ||||||||||
| C5C5 | LD A,($A035) | Read $A035 in "Game variables" into A | ||||||||||
| C5C8 | CP $FE | Compare A with $FE | ||||||||||
| C5CA | JP NZ,$CB41 | If A differs from $FE, jump on to the routine "Return Z (does nothing)" (CB41) | ||||||||||
| C5CD | LD A,($A00F) | Read $A00F in "Game variables" into A - Does the record want a direct object, and is $A034 still $FF (none named)? | ||||||||||
| C5D0 | AND A | Test A for zero (this leaves A as it was and clears carry) | ||||||||||
| C5D1 | JR Z,$C5EB | If A is zero, skip ahead to C5EB | ||||||||||
| C5D3 | LD A,($A034) | Read $A034 in "Game variables" into A | ||||||||||
| C5D6 | CP $FF | Compare A with $FF | ||||||||||
| C5D8 | JR NZ,$C5EB | If A differs from $FF, skip ahead to C5EB | ||||||||||
| C5DA | LD B,$00 | (C463 says when B has run out) | ||||||||||
| C5DC | CALL $C463 | Next candidate into A | ||||||||||
| C5DF | RET Z | Candidates exhausted: return Z | ||||||||||
| C5E0 | LD ($A034),A | Make it the direct object | ||||||||||
| C5E3 | CALL $C60D | |||||||||||
| C5E6 | JR NZ,$C5F4 | |||||||||||
| C5E8 | INC B | Add one to B - Else try the next candidate | ||||||||||
| C5E9 | JR $C5DC | Go back to C5DC | ||||||||||
| C5EB | CALL $C5FC | |||||||||||
| C5EE | JR Z,$C5F4 | No: run the record as it is | ||||||||||
| C5F0 | CALL $C613 | |||||||||||
| C5F3 | RET Z | Return its Z/NZ | ||||||||||
| C5F4 | LD A,$01 | Load A with $01 - Run the record: $A00B = 1... | ||||||||||
| C5F6 | LD ($A00B),A | Store A in $A00B in "Game variables" | ||||||||||
| C5F9 | JP $C989 | ...and go to C989 | ||||||||||
| Prev: C57A | Up: Map | Next: C5FC |