Prev: C091 Up: Map Next: C0EE
C0A4: Parse Word
Used by the routines at LookupWord, KeepToken and StoreExtra.
Skips to the next word and copies up to four letters. A comma after a word saves the rest of the line.
Input
HL Line pointer
Move to the next word. A comma after a word saves the rest of the line.
ParseWord C0A4 CALL SkipToBreak Call SkipToBreak to skip to a space, a comma or ENTER.
C0A7 CP $0D Jump to FinishParse to finish the command.
C0A9 JR NZ,ParseWord_NotEnter
C0AB JP FinishParse
ParseWord_NotEnter C0AE CP $2C Jump to ParseWord_Comma to keep the rest of the line.
C0B0 JR Z,ParseWord_Comma
This entry point is used by the routines at ReadCommand and ParseLine.
Copy up to four characters, padding with spaces, then look the word up.
ParseWord_Copy C0B2 LD B,$04 Fill WordToken with four spaces.
C0B4 LD DE,$5B7B
ParseWord_Pad C0B7 LD A,$20
C0B9 LD (DE),A
C0BA INC DE
C0BB DJNZ ParseWord_Pad
C0BD LD DE,$5B7B The copy starts at the first character of WordToken.
C0C0 LD B,$00
ParseWord_Letter C0C2 LD A,(HL) Jump to ParseWord_Break to test for a space or ENTER.
C0C3 CP $2C
C0C5 JR NZ,ParseWord_Break
C0C7 XOR A Jump to LookupWord to look the word up.
C0C8 CP B
C0C9 JR NZ,LookupWord
C0CB LD A,($5B8B) Jump to ParseWord to keep scanning.
C0CE OR A
C0CF JR Z,ParseWord
Save the rest of the line for the next turn.
ParseWord_Comma C0D1 LD A,$01 Write 01 to *Continuation and store the pointer in *InputPointer.
C0D3 LD ($5B85),A
C0D6 LD ($5B8C),HL
C0D9 RET Return.
A space or ENTER ends the word; anything else is another letter.
ParseWord_Break C0DA CP $20 Jump to LookupWord when a space or ENTER ends the word.
C0DC JR Z,LookupWord
C0DE CP $0D
C0E0 JR Z,LookupWord
C0E2 LD A,$04 Jump to LookupWord if a fifth character is not stored.
C0E4 CP B
C0E5 JR Z,LookupWord
C0E7 LD A,(HL) Store one character in WordToken.
C0E8 LD (DE),A
C0E9 INC HL Advance both pointers and jump to ParseWord_Letter.
C0EA INC DE
C0EB INC B
C0EC JR ParseWord_Letter
Prev: C091 Up: Map Next: C0EE