Routines
| Prev: C996 | Up: Map | Next: CA60 |
C9BF: Run an action record (HL = the record)
|
Action records are a small data format that every verb's behaviour is written in. Byte 0 is a flags byte, byte 1 holds a value whose high nibble is stored at $A01F.
The executable body starts after the header: record + 2, + 2 more if bit 6, + 5 more if bit 4. CA64 runs the body through the dispatcher at CB2C.
SIT IN's $78 header puts the body at record + 9, E413).
The clock does move by 5 for one WAIT (value 5) and 2 for GET OUT (value 2), but another WAIT moved it by 1 and SIT IN (value 2) by 1.
WAIT (WAIT HERE, byte 1 $50) moves it on by 5, TAKE LAMP (DCC1, $10) and EXAMINE LAMP (DF40, $10) by 1 each.
How it works:
1. Refuse if it is too dark (D078) and the record cares about that.
3. If bit 6 of the record is set, run its pre-check routine; if that refuses, stop.
4. Otherwise take the high nibble of byte 1 as the action's length ($A01F) and run the body, narrating the action first and describing any change.
|
||||||||||||
| C9BF | PUSH HL | IY = the action record | ||||||||||
| C9C0 | POP IY | Restore IY from the stack | ||||||||||
| C9C2 | CALL $D078 | Is the action ruled out by D078? | ||||||||||
| C9C5 | JR NC,$C9D3 | No: carry on | ||||||||||
| C9C7 | LD A,(IY+$00) | Yes - but only refuse if this record says that matters | ||||||||||
| C9CA | AND $20 | Isolate bit 5 of A (mask $20) | ||||||||||
| C9CC | JR Z,$C9D3 | If bit 5 of A was clear, skip ahead to C9D3 | ||||||||||
| C9CE | LD HL,$CBBB | HL = the refusal handler | ||||||||||
| C9D1 | XOR A | Refuse (Z) | ||||||||||
| C9D2 | RET | Return to the caller | ||||||||||
| C9D3 | CALL $C628 | Check the direct object against the record (C628); refuse if it fails | ||||||||||
| C9D6 | JR Z,$C9D1 | If the zero flag is set, go back to C9D1 | ||||||||||
| C9D8 | CALL $C6BE | Check the indirect object (C6BE); refuse if it fails | ||||||||||
| C9DB | JR Z,$C9D1 | If the zero flag is set, go back to C9D1 | ||||||||||
| C9DD | BIT 6,(IY+$00) | Does the record have a pre-check routine? | ||||||||||
| C9E1 | JR Z,$C9F2 | If bit 6 of the first byte of the record at IY is clear, skip ahead to C9F2 | ||||||||||
| C9E3 | LD L,(IY+$02) | Yes: HL = its address... | ||||||||||
| C9E6 | LD H,(IY+$03) | Read byte +3 of the record at IY into H | ||||||||||
| C9E9 | PUSH IY | Save IY on the stack | ||||||||||
| C9EB | CALL $CB34 | ...run it with the current IX/IY | ||||||||||
| C9EE | POP IY | Restore IY from the stack | ||||||||||
| C9F0 | JR Z,$C9D1 | Refused? Then stop | ||||||||||
| C9F2 | LD A,($A00B) | |||||||||||
| C9F5 | AND A | A zero: return NZ (nothing to do) | ||||||||||
| C9F6 | JR NZ,$C9FB | If A is not zero, skip ahead to C9FB | ||||||||||
| C9F8 | OR $01 | Make A non-zero, which clears the zero flag, and hand that back to the caller | ||||||||||
| C9FA | RET | Return to the caller | ||||||||||
| C9FB | PUSH IY | Store the high nibble of byte 1 at $A01F | ||||||||||
| C9FD | LD A,(IY+$01) | The record's high nibble of byte 1... | ||||||||||
| CA00 | RRCA | ...rotated down four places (4 RRCAs) | ||||||||||
| CA01 | RRCA | Rotate A right one place (bit 0 goes to carry and bit 7) | ||||||||||
| CA02 | RRCA | Rotate A right one place (bit 0 goes to carry and bit 7) | ||||||||||
| CA03 | RRCA | Rotate A right one place (bit 0 goes to carry and bit 7) | ||||||||||
| CA04 | AND $0F | Low nibble only | ||||||||||
| CA06 | LD L,A | Copy A into L | ||||||||||
| CA07 | LD H,$00 | Load H with $00 | ||||||||||
| CA09 | LD ($A01F),HL | Stored in $A01F as a word | ||||||||||
| CA0C | POP HL | HL = the record again; skip the two fixed bytes | ||||||||||
| CA0D | LD DE,$0002 | Load DE with $0002, the amount that is added next | ||||||||||
| CA10 | ADD HL,DE | Add DE to HL | ||||||||||
| CA11 | BIT 6,(IY+$00) | Skip the pre-check address if there is one | ||||||||||
| CA15 | JR Z,$CA18 | If bit 6 of the first byte of the record at IY is clear, skip ahead to CA18 | ||||||||||
| CA17 | ADD HL,DE | Add DE to HL | ||||||||||
| CA18 | LD DE,$0005 | Skip the five extra bytes if there are any | ||||||||||
| CA1B | BIT 4,(IY+$00) | Test bit 4 of the first byte of the record at IY | ||||||||||
| CA1F | JR Z,$CA22 | If bit 4 of the first byte of the record at IY is clear, skip ahead to CA22 | ||||||||||
| CA21 | ADD HL,DE | Add DE to HL | ||||||||||
| CA22 | LD A,($A00A) | Remember the player's and the target's rooms | ||||||||||
| CA25 | LD ($C491),A | Save the actor's room as it was before the action (C491) | ||||||||||
| CA28 | LD IX,($A013) | IX = the direct object's record ($A013) | ||||||||||
| CA2C | LD A,(IX+$0F) | Save its room (C492) | ||||||||||
| CA2F | LD ($C492),A | Store A in C492 in "Rooms saved before an action" | ||||||||||
| CA32 | PUSH HL | Save HL on the stack | ||||||||||
| CA33 | PUSH IY | Save IY on the stack | ||||||||||
| CA35 | LD A,$01 | $A00C = 1 while the action is narrated | ||||||||||
| CA37 | LD ($A00C),A | Store A in $A00C in "Game variables" | ||||||||||
| CA3A | CALL $CA76 | Narrate it (CA76) | ||||||||||
| CA3D | POP IY | Restore IY from the stack | ||||||||||
| CA3F | POP HL | Restore HL from the stack | ||||||||||
| CA40 | BIT 7,(IY+$00) | Record flag bit 7 set: return carry | ||||||||||
| CA44 | JR Z,$CA48 | If bit 7 of the first byte of the record at IY is clear, skip ahead to CA48 | ||||||||||
| CA46 | SCF | Yes: report success without running the body | ||||||||||
| CA47 | RET | Return to the caller | ||||||||||
| CA48 | LD A,($9FD7) | Read the plan's direct object (9FD7) into A - A plan's direct object slot (9FD7) still $FF: take this action's ($A034) | ||||||||||
| CA4B | INC A | Add one to A | ||||||||||
| CA4C | JR NZ,$CA54 | If A is not zero, skip ahead to CA54 | ||||||||||
| CA4E | LD A,($A034) | Read $A034 in "Game variables" into A | ||||||||||
| CA51 | LD ($9FD7),A | Store A in the plan's direct object (9FD7) | ||||||||||
| CA54 | LD A,($9FD8) | Read the plan's indirect (9FD8) into A - Same for the indirect object (9FD8, $A035) | ||||||||||
| CA57 | INC A | Add one to A | ||||||||||
| CA58 | JR NZ,$CA60 | If A is not zero, skip ahead to the routine "Run the action body, then report what the player..." (CA60) | ||||||||||
| CA5A | LD A,($A035) | Read $A035 in "Game variables" into A | ||||||||||
| CA5D | LD ($9FD8),A | Store A in the plan's indirect (9FD8) | ||||||||||
| Prev: C996 | Up: Map | Next: CA60 |