![]() |
Routines |
| Prev: ACE6 | Up: Map | Next: AD32 |
|
Used by the routine at Handler_UserInput.
Match the four letters at FourLetterBuffer against the vocabulary. On success return the word's token number in A with the carry flag set; on failure return with the carry flag clear. A comma separates synonyms of the same token; FF ends the table.
|
||||||||||
| Handler_MatchItem | ACFB | PUSH HL | Stash HL, DE, BC and IX on the stack. | |||||||
| ACFC | PUSH DE | |||||||||
| ACFD | PUSH BC | |||||||||
| ACFE | PUSH IX | |||||||||
|
Search the vocabulary from the address held in *Pointer_Vocabulary.
|
||||||||||
| AD00 | LD HL,($A7C6) | HL=*Pointer_Vocabulary. | ||||||||
| AD03 | LD C,$00 | Set the token number in C to 00. | ||||||||
| AD05 | JR MatchItem_Word | Jump to MatchItem_Word. | ||||||||
|
This vocabulary word did not match. Step past the remaining letters. A comma keeps the same token for a synonym; anything else advances the token number for the next entry.
|
||||||||||
| MatchItem_NextWord | AD07 | LD E,B | Turn the remaining letter count into a 16-bit offset in DE. | |||||||
| AD08 | LD D,$00 | |||||||||
| AD0A | ADD HL,DE | Move HL past the unmatched letters. | ||||||||
| AD0B | LD A,(HL) | Fetch the next vocabulary byte into A. | ||||||||
| AD0C | CP $2C | Is this byte a comma (2C)? | ||||||||
| AD0E | JR Z,MatchItem_SkipComma | Jump to MatchItem_SkipComma if it is, so the token number stays the same. | ||||||||
| AD10 | INC C | Otherwise advance the token number for the next vocabulary entry. | ||||||||
| AD11 | JR MatchItem_Word | Jump to MatchItem_Word. | ||||||||
| MatchItem_SkipComma | AD13 | INC HL | Move past the comma. | |||||||
|
Test this vocabulary word against the four-letter buffer.
|
||||||||||
| MatchItem_Word | AD14 | LD A,(HL) | Jump to MatchItem_Return if the word is the FF terminator. | |||||||
| AD15 | CP $FF | |||||||||
| AD17 | JR Z,MatchItem_Return | |||||||||
|
Compare the four-letter buffer at FourLetterBuffer with this word.
|
||||||||||
| AD19 | LD IX,$A82F | IX=FourLetterBuffer. | ||||||||
| AD1D | LD B,$04 | Set a counter in B for the 04 letters. | ||||||||
| MatchItem_Letter | AD1F | LD A,(IX+$00) | Jump to MatchItem_NextWord if this letter does not match. | |||||||
| AD22 | CP (HL) | |||||||||
| AD23 | JR NZ,MatchItem_NextWord | |||||||||
| AD25 | INC HL | Move to the next vocabulary letter. | ||||||||
| AD26 | INC IX | Move to the next letter of the four-letter buffer. | ||||||||
| AD28 | DJNZ MatchItem_Letter | Decrease the letter counter by one and loop back to MatchItem_Letter until the counter is zero. | ||||||||
|
The word matched, so return its token with the carry set.
|
||||||||||
| AD2A | LD A,C | Copy the matched token number into A. | ||||||||
| AD2B | SCF | Set the carry flag to show the word was found. | ||||||||
|
Hand back the registers saved at the start of the search.
|
||||||||||
| MatchItem_Return | AD2C | POP IX | Restore IX, BC, DE and HL from the stack. | |||||||
| AD2E | POP BC | |||||||||
| AD2F | POP DE | |||||||||
| AD30 | POP HL | |||||||||
| AD31 | RET | Return. | ||||||||
|
View the equivalent code in;
|
||||||||||
| Prev: ACE6 | Up: Map | Next: AD32 |