Prev: C0EE Up: Map Next: C14C
C104: Keep Token
Used by the routine at LookupWord.
The first word below id 55 is the verb. IT and THEM substitute the previous noun. POLISH, SKIN and BRIDGE are rewritten to internal verbs 2C, 2B and 31. Later words are the noun, then extra words.
Input
A Token id
HL Line pointer
Count this word. A third word is stored as an extra, not as the noun.
KeepToken C104 PUSH AF Stash the id on the stack.
C105 LD A,($5B8B) Increment *WordCount.
C108 INC A
C109 LD ($5B8B),A
C10C CP $03 Jump to StoreExtra if this is a third word.
C10E JR NC,StoreExtra
C110 CP $20 Jump to StoreExtra_Overflow if *WordCount is 20.
C112 JR Z,StoreExtra_Overflow
C114 POP AF Restore the id from the stack.
C115 CP $55 An id below 55 is the verb.
C117 JR NC,KeepToken_It
KeepToken_Verb C119 LD ($5B7F),A Write the id to *Verb.
C11C JP ParseWord Jump to ParseWord to take the next word.
IT and THEM reuse the previous noun; other ids become the noun unless they rewrite to a verb.
KeepToken_It C11F CP $80 IT and THEM (80) reuse *PreviousNoun.
C121 JR NZ,KeepToken_Held
C123 LD A,($5B9D)
KeepToken_Held C126 LD B,A Jump to KeepToken_Noun if a verb is already stored.
C127 LD A,($5B7F)
C12A OR A
C12B LD A,B
C12C JR NZ,KeepToken_Noun
KeepToken_Rewrite C12E CP $AF Jump to KeepToken_Verb with 2C if the token is POLISH (AF).
C130 LD A,$2C
C132 JR Z,KeepToken_Verb
C134 LD A,B Jump to KeepToken_Verb with 2B if the token is SKIN (F9).
C135 CP $F9
C137 LD A,$2B
C139 JR Z,KeepToken_Verb
C13B LD A,B Jump to KeepToken_Verb with 31 if the token is BRIDGE (86).
C13C CP $86
C13E LD A,$31
C140 JR Z,KeepToken_Verb
C142 LD A,B Restore the id when none of those matched.
KeepToken_Noun C143 LD ($5B80),A Write the id to *Noun and *PreviousNoun.
C146 LD ($5B9D),A
C149 JP ParseWord Jump to ParseWord to take the next word.
Prev: C0EE Up: Map Next: C14C