Routines
| Prev: AAB2 | Up: Map | Next: AC24 |
AB91: Read a sentence's verb words into the node at IY
|
Tokens (AE7F) of class $30 (a verb, see AE7F) go to IY+0/+1, class $00 to IY+2/+3, $40 and $20 to one or the other by the flags in E; $E0 tokens are skipped; anything else ends the verb (carry when a slot was wanted twice). In statement mode ($A024 = 2, while a case statement is being said) the verb must instead be one of the eleven relation words at 994D - KILLED, HAD, ... - and NZ means it is not.
How it works:
1. In statement mode ($A024 = 2) the words are matched against the relation words at 994D instead (ABF3).
2. Otherwise take tokens (AE7F). A class $30 token goes in the verb slot (IY+0/+1), a class $00 token in the second word slot (IY+2/+3).
3. A class $40 token clears E bit 0 and is treated as a verb; a class $20 token goes to whichever slot is free.
4. A word for a slot already taken returns carry set. Any other class ends the verb: return Z if the verb slot has been filled.
|
||||||||||||||||
| AB91 | LD A,($A024) | Read $A024 in "Game variables" into A - Statement mode ($A024 = 2)? | ||||||||||||||
| AB94 | CP $02 | Compare A with $02 | ||||||||||||||
| AB96 | JR Z,$ABF3 | Yes: the relation-word check at ABF3 | ||||||||||||||
| AB98 | LD A,E | Copy E into A - E bits 0-2 set: ready for a verb slot (bit 1), an object-word slot (bit 2), and the direct-or-indirect choice (bit 0) | ||||||||||||||
| AB99 | OR $07 | Set bits 0, 1, 2 of A (mask $07) | ||||||||||||||
| AB9B | LD E,A | Copy A into E | ||||||||||||||
| AB9C | CALL $AE7F | Next token (AE7F): class in A, word reference in BC | ||||||||||||||
| AB9F | CP $E0 | Compare A with $E0 - Class $E0: skipped | ||||||||||||||
| ABA1 | JR Z,$AB9C | If A equals $E0, go back to AB9C | ||||||||||||||
| ABA3 | CP $30 | Compare A with $30 - Class $30 (verb word)? | ||||||||||||||
| ABA5 | JR NZ,$ABB7 | If A differs from $30, skip ahead to ABB7 | ||||||||||||||
| ABA7 | BIT 1,E | Verb slot still free (E bit 1)? | ||||||||||||||
| ABA9 | JR Z,$ABB5 | No: wanted twice, carry (ABB5) | ||||||||||||||
| ABAB | RES 1,E | Fill the verb slot: mark it taken... | ||||||||||||||
| ABAD | LD (IY+$00),C | Store C in the first byte of the record at IY - ...and store the word reference at IY+0/+1 | ||||||||||||||
| ABB0 | LD (IY+$01),B | Store B in byte +1 of the record at IY | ||||||||||||||
| ABB3 | JR $AB9C | Go back to AB9C | ||||||||||||||
| ABB5 | SCF | Set the carry flag for the caller - Carry: a second word for a slot already taken | ||||||||||||||
| ABB6 | RET | Return to the caller | ||||||||||||||
| ABB7 | CP $00 | Compare A with $00 - Class $00 (second word)? | ||||||||||||||
| ABB9 | JR NZ,$ABC9 | If A differs from $00, skip ahead to ABC9 | ||||||||||||||
| ABBB | BIT 2,E | Test bit 2 of E - Its slot (E bit 2) free? | ||||||||||||||
| ABBD | JR Z,$ABB5 | If bit 2 of E is clear, go back to ABB5 | ||||||||||||||
| ABBF | RES 2,E | Clear bit 2 of E - Mark taken and store at IY+2/+3 | ||||||||||||||
| ABC1 | LD (IY+$02),C | Store C in byte +2 of the record at IY | ||||||||||||||
| ABC4 | LD (IY+$03),B | Store B in byte +3 of the record at IY | ||||||||||||||
| ABC7 | JR $AB9C | Go back to AB9C | ||||||||||||||
| ABC9 | CP $40 | Compare A with $40 - Class $40: clear E bit 0, then treat as a verb word | ||||||||||||||
| ABCB | JR NZ,$ABD1 | If A differs from $40, skip ahead to ABD1 | ||||||||||||||
| ABCD | RES 0,E | Clear bit 0 of E | ||||||||||||||
| ABCF | JR $ABA7 | Go back to ABA7 | ||||||||||||||
| ABD1 | CP $20 | Compare A with $20 - Class $20: goes to whichever slot is free: | ||||||||||||||
| ABD3 | JR NZ,$ABEF | If A differs from $20, skip ahead to ABEF | ||||||||||||||
| ABD5 | BIT 1,E | Test bit 1 of E - verb slot free: use it | ||||||||||||||
| ABD7 | JR NZ,$ABA7 | If bit 1 of E is set, go back to ABA7 | ||||||||||||||
| ABD9 | BIT 0,E | Test bit 0 of E - bit 0 still set: use the second slot | ||||||||||||||
| ABDB | JR NZ,$ABBB | If bit 0 of E is set, go back to ABBB | ||||||||||||||
| ABDD | RES 2,E | Clear bit 2 of E - else copy the verb word into the second slot and take the verb slot | ||||||||||||||
| ABDF | SET 0,E | Set bit 0 of E | ||||||||||||||
| ABE1 | LD A,(IY+$00) | Read the first byte of the record at IY into A | ||||||||||||||
| ABE4 | LD (IY+$02),A | Store A in byte +2 of the record at IY | ||||||||||||||
| ABE7 | LD A,(IY+$01) | Read byte +1 of the record at IY into A | ||||||||||||||
| ABEA | LD (IY+$03),A | Store A in byte +3 of the record at IY | ||||||||||||||
| ABED | JR $ABAB | Go back to ABAB | ||||||||||||||
| ABEF | OR A | Test A for zero (this leaves A as it was and clears carry) - Any other class ends the verb: Z if the verb slot has been filled (E bit 1 clear), NZ if not | ||||||||||||||
| ABF0 | BIT 1,E | Test bit 1 of E | ||||||||||||||
| ABF2 | RET | Return to the caller | ||||||||||||||
|
This entry point is used by the routine at AAB2.
|
||||||||||||||||
| ABF3 | CALL $AE7F | Statement mode: next token... | ||||||||||||||
| ABF6 | CP $80 | Compare A with $80 - ...skipping a class $80 one | ||||||||||||||
| ABF8 | CALL Z,$AE7F | If A equals $80, call the routine "Read the next token of the typed line" (AE7F) | ||||||||||||||
| ABFB | LD A,B | Copy B into A - Keep the dictionary offset's high nibble out of the way | ||||||||||||||
| ABFC | AND $0F | Keep only bits 0, 1, 2, 3 of A (mask $0F) | ||||||||||||||
| ABFE | LD B,A | Copy A into B | ||||||||||||||
| ABFF | LD HL,$994D | Point HL at "The case's relation words" (994D) - Search the relation words at 994D (2 bytes each, 0 ends) | ||||||||||||||
| AC02 | LD A,(HL) | Read the byte HL points at into A | ||||||||||||||
| AC03 | INC HL | Step HL on to the next byte | ||||||||||||||
| AC04 | OR (HL) | Set in A the bits that are set in the byte HL points at | ||||||||||||||
| AC05 | JR Z,$AC14 | If the result is zero, skip ahead to AC14 | ||||||||||||||
| AC07 | LD A,B | Copy B into A | ||||||||||||||
| AC08 | CP (HL) | Compare A with the byte HL points at | ||||||||||||||
| AC09 | JR NZ,$AC11 | If A differs from the byte HL points at, skip ahead to AC11 | ||||||||||||||
| AC0B | DEC HL | Step HL back one byte | ||||||||||||||
| AC0C | LD A,C | Copy C into A | ||||||||||||||
| AC0D | CP (HL) | Compare A with the byte HL points at | ||||||||||||||
| AC0E | JR Z,$AC17 | If A equals the byte HL points at, skip ahead to AC17 | ||||||||||||||
| AC10 | INC HL | Step HL on to the next byte | ||||||||||||||
| AC11 | INC HL | Step HL on to the next byte | ||||||||||||||
| AC12 | JR $AC02 | Go back to AC02 | ||||||||||||||
| AC14 | OR $01 | Make A non-zero, which clears the zero flag, and hand that back to the caller - Not one of them: NZ | ||||||||||||||
| AC16 | RET | Return to the caller | ||||||||||||||
| AC17 | LD (IY+$00),C | Store C in the first byte of the record at IY - Found: store its reference as the verb, take the slot, read on, return Z | ||||||||||||||
| AC1A | LD (IY+$01),B | Store B in byte +1 of the record at IY | ||||||||||||||
| AC1D | RES 1,E | Clear bit 1 of E | ||||||||||||||
| AC1F | CALL $AE7F | Call the routine "Read the next token of the typed line" (AE7F) | ||||||||||||||
| AC22 | XOR A | Set A to zero, which sets the zero flag for the caller | ||||||||||||||
| AC23 | RET | Return to the caller | ||||||||||||||
| Prev: AAB2 | Up: Map | Next: AC24 |