Routines
| Prev: AE6A | Up: Map | Next: AEA9 |
AE7F: Read the next token of the typed line
|
The word list built by D715 ($5B81 on) is a run of tokens: a class byte, then - for classes below $80 and for $90, $E0 and $F0 - a 2-byte word reference (high byte first) or value. Returns the class in A and D and the reference in BC, keeps the previous class at $A02D and the token's address at $A029.
'TAKE THE LAMP, EXAMINE IT. PAY 2/6 TO WATSON' becomes $30 TAKE, $80 (THE, no reference), $50 LAMP, $A0 (comma), $30 EXAMINE, $90 IT, $B0 (full stop), $30 PAY, $F0 $809E (2/6, 30 pence), $70 TO, $50 WATSON, $B0, $C0 (end). So $30 is a verb, $50 a noun, $70 a preposition, $80 a word with no meaning to the parser, $90 a special word (the table at AF6B: IT, HE, QUIT, a quote mark...), $F0 a number or money, $A0 a comma, $B0 a full stop, $C0 the end.
How it works:
2. The class is the first byte. Classes $E0, $F0, $90 and those below $80 have a two-byte word after them, which is returned in BC.
3. Save the position after the token and return the class in A.
|
||||||||||||||||||
| AE7F | LD HL,($A02B) | Read $A02B in "Game variables" into HL - Where this token starts | ||||||||||||||||
| AE82 | LD ($A029),HL | Store HL in $A029 in "Game variables" | ||||||||||||||||
| AE85 | LD A,D | Copy D into A - Remember the previous class | ||||||||||||||||
| AE86 | LD ($A02D),A | Store A in $A02D in "Game variables" | ||||||||||||||||
| AE89 | LD A,(HL) | Read the byte HL points at into A - The class | ||||||||||||||||
| AE8A | LD D,A | Copy A into D | ||||||||||||||||
| AE8B | LD BC,$0000 | Load BC with $0000 | ||||||||||||||||
| AE8E | INC HL | Step HL on to the next byte | ||||||||||||||||
| AE8F | CP $E0 | Compare A with $E0 - Classes with a word after them... | ||||||||||||||||
| AE91 | JR Z,$AE9F | If A equals $E0, skip ahead to AE9F | ||||||||||||||||
| AE93 | CP $F0 | Compare A with $F0 | ||||||||||||||||
| AE95 | JR Z,$AE9F | If A equals $F0, skip ahead to AE9F | ||||||||||||||||
| AE97 | CP $90 | Compare A with $90 | ||||||||||||||||
| AE99 | JR Z,$AE9F | If A equals $90, skip ahead to AE9F | ||||||||||||||||
| AE9B | CP $80 | Compare A with $80 | ||||||||||||||||
| AE9D | JR NC,$AEA4 | If A is $80 or more, skip ahead to AEA4 | ||||||||||||||||
| AE9F | LD A,(HL) | Read the byte HL points at into A - ...BC = the word | ||||||||||||||||
| AEA0 | LD B,A | Copy A into B | ||||||||||||||||
| AEA1 | INC HL | Step HL on to the next byte | ||||||||||||||||
| AEA2 | LD C,(HL) | Read the byte HL points at into C | ||||||||||||||||
| AEA3 | INC HL | Step HL on to the next byte | ||||||||||||||||
| AEA4 | LD ($A02B),HL | Store HL in $A02B in "Game variables" - Step past the token | ||||||||||||||||
| AEA7 | LD A,D | Copy D into A | ||||||||||||||||
| AEA8 | RET | Return to the caller | ||||||||||||||||
| Prev: AE6A | Up: Map | Next: AEA9 |