Prev: 7DF9 Up: Map Next: 7E5A
7DFB: Parser: a verb
The entry at 7DFB (from 7DB6) supplies the verb GO ($30 class) for a bare direction; the entry at 7DFD handles verbs typed by the player.
If a verb arrives when a command has already been started and there has been no AND, the parser backtracks: the state saved by the last AND (7DD5) is restored and the AND is reinterpreted as THEN, splitting the line into two commands.
Otherwise the verb must be allowed here (bit 1 of E). It is stored at offset 0 of the frame (7FDE). GO and RUN look ahead (from 7E31) past any adverbs: if the next word is a direction, the verb is dropped and the direction stored as the particle, so that 'go north' and 'north' produce the same frame.
7DFB LD D,$30 Class of GO (for a bare direction)
7DFD BIT 3,E VERB: has there just been an AND?
7DFF JR NZ,$7E1F Yes: a new command after AND is fine
7E01 CALL $7CBB Inside a quotation?
7E04 JR NZ,$7E1F Yes: accept it
7E06 LD HL,($7C3E) A second verb without AND: backtrack to the last AND...
7E09 LD ($B5CD),HL
7E0C LD D,$B0 ...and treat it as THEN
7E0E LD A,($7C40) Restore the state saved at the AND
7E11 LD E,A
7E12 LD A,($7C43)
7E15 LD ($B5F7),A
7E18 LD IY,($7C41)
7E1C JP $7CC4 Close the frame and start a new one
7E1F CALL $7F29 A verb cancels ALL
7E22 BIT 1,E Is a verb allowed here?
7E24 JP Z,$7FF3 No: syntax error
7E27 BIT 0,E Is this a GO followed by a direction?
7E29 JR Z,$7E31 No: look ahead
7E2B CALL $7FDE Store the verb in the frame
7E2E JP $7C7E Next noun phrase
7E31 PUSH DE Look ahead past any adverbs...
7E32 PUSH BC
7E33 LD HL,($B5CD)
7E36 PUSH HL
7E37 CALL $7F3D
7E3A CP $00
7E3C JR Z,$7E37
7E3E SET 0,E
7E40 CP $20 ...is the next word a direction?
7E42 JR Z,$7E4C Yes
7E44 POP HL No: rewind and store the verb normally
7E45 LD ($B5CD),HL
7E48 POP BC
7E49 POP DE
7E4A JR $7E2B
7E4C CALL $7FDE Store GO as the verb...
7E4F POP HL
7E50 POP BC
7E51 POP HL
7E52 LD L,$02 ...and the direction at offset 2
7E54 CALL $7FE2
7E57 JP $7C7E Next noun phrase
Prev: 7DF9 Up: Map Next: 7E5A