Prev: 49297 Up: Map Next: 49390
49316: 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 49316 CALL SkipToBreak Call SkipToBreak to skip to a space, a comma or ENTER.
49319 CP 13 Jump to ParseWord_NotEnter if the character is not ENTER.
49321 JR NZ,ParseWord_NotEnter
49323 JP FinishParse Jump to FinishParse to finish the command.
A comma keeps the rest of the line.
ParseWord_NotEnter 49326 CP 44 Jump to ParseWord_Comma to keep the rest of the line.
49328 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 49330 LD B,4 Count four letters and point DE at WordToken.
49332 LD DE,23419
Write those spaces.
ParseWord_Pad 49335 LD A,32 Fill WordToken with four spaces.
49337 LD (DE),A
49338 INC DE
49339 DJNZ ParseWord_Pad
49341 LD DE,23419 The copy starts at the first character of WordToken.
49344 LD B,0
A comma after copied letters looks the word up. An empty comma keeps scanning.
ParseWord_Letter 49346 LD A,(HL) Jump to ParseWord_Break if this character is not a comma.
49347 CP 44
49349 JR NZ,ParseWord_Break
49351 XOR A Jump to LookupWord if a letter has already been stored.
49352 CP B
49353 JR NZ,LookupWord
49355 LD A,(23435) Jump to ParseWord if no word has been recognised yet.
49358 OR A
49359 JR Z,ParseWord
Save the rest of the line for the next turn.
ParseWord_Comma 49361 LD A,1 Write 1 to *Continuation and store the pointer in *InputPointer.
49363 LD (23429),A
49366 LD (23436),HL
49369 RET Return.
A space or ENTER ends the word; anything else is another letter.
ParseWord_Break 49370 CP 32 Jump to LookupWord when a space or ENTER ends the word.
49372 JR Z,LookupWord
49374 CP 13
49376 JR Z,LookupWord
49378 LD A,4 Jump to LookupWord if a fifth character is not stored.
49380 CP B
49381 JR Z,LookupWord
49383 LD A,(HL) Store one character in WordToken.
49384 LD (DE),A
49385 INC HL Advance the line pointer.
49386 INC DE Advance the token pointer.
49387 INC B Count this letter.
49388 JR ParseWord_Letter Jump to ParseWord_Letter.
Prev: 49297 Up: Map Next: 49390