![]() |
Routines |
| Prev: A85C | Up: Map | Next: A92F |
|
Used by the routines at ProcessObject_Display and PrintObjectAttributeDescription.
|
||||||||||||||
|
Read the token value from the text data.
|
||||||||||||||
| ExtractTokenFromText | A880 | LD E,(HL) | E=*HL (load the first byte of the token into E). | |||||||||||
| A881 | INC HL | Increment HL by one (move to the second byte). | ||||||||||||
| A882 | LD A,(HL) | A=*HL (load the second byte of the token into A). | ||||||||||||
| A883 | INC HL | Increment HL by one (advance the text pointer past the token). | ||||||||||||
| A884 | AND %00001111 | Keep only bits 0-3 (extract the low nibble from the second byte). | ||||||||||||
| A886 | LD D,A | D=A (store the low nibble in D). | ||||||||||||
|
This entry point is used by the routines at ProcessObjectDisplay, ProcessObject_Display, ProcessTextCommand, PrintCharacterWithTimePeriod, PrintTokenBasedOnParameters, ProcessTextTokenWithAttributes, ProcessObjectOrPrintToken, ProcessTextTokenEntry, GetDisplayAddressBasedOnFlag, ProcessLocationTokenDisplay, PrintFormattedObjectList, PrintObjectAttributeDescription, PrintLocationExits and PrintLocationExitsWithFormatting.
|
||||||||||||||
| PrintTextToken | A887 | LD A,($5C3C) | Return if *TV-FLAG is not set. | |||||||||||
| A88A | AND A | |||||||||||||
| A88B | RET Z | |||||||||||||
| A88C | LD ($A022),DE | Write DE (the token value) to *TokenValueBuffer. | ||||||||||||
|
Check if this is a simple token that doesn't need further processing.
|
||||||||||||||
| A890 | LD A,D | A=D (load the low nibble into A). | ||||||||||||
| A891 | AND %00001111 | Keep only bits 0-3 (ensure we have just the low nibble). | ||||||||||||
| A893 | OR E | Set the bits from E (merge with the first byte). | ||||||||||||
| A894 | RET Z | Return if this is a simple token (HL equals E). | ||||||||||||
| A895 | PUSH IX | Stash IX, HL, BC and DE on the stack. | ||||||||||||
| A897 | PUSH HL | |||||||||||||
| A898 | PUSH BC | |||||||||||||
| A899 | PUSH DE | |||||||||||||
|
Process the token format and prepare for dictionary lookup.
|
||||||||||||||
| A89A | LD A,$20 | A=20 (load space character code). | ||||||||||||
| A89C | CALL Print_Character | Call Print_Character to print the space character. | ||||||||||||
| A89F | LD A,D | A=D (load the token byte). | ||||||||||||
| A8A0 | AND %11110000 | Keep only bits 4-7 (extract the high nibble). | ||||||||||||
| A8A2 | LD C,A | Compare C (the high nibble) with 70. | ||||||||||||
| A8A3 | CP $70 | |||||||||||||
|
Prepare to set a flag if the token format is 70.
|
||||||||||||||
| A8A5 | LD A,$01 | A=01. | ||||||||||||
| A8A7 | JR NZ,ExtractTokenFromText_ProcessToken | Jump to ExtractTokenFromText_ProcessToken if the token format is not 70. | ||||||||||||
| A8A9 | LD ($A026),A | Write A to *TokenFormatFlag (set a flag for this token format). | ||||||||||||
| ExtractTokenFromText_ProcessToken | A8AC | LD A,D | A=D (restore the token byte). | |||||||||||
| A8AD | AND %00001111 | Keep only bits 0-3 (extract the low nibble). | ||||||||||||
| A8AF | LD D,A | D=A (store the low nibble in D). | ||||||||||||
| A8B0 | EX DE,HL | Exchange the DE and HL registers (swap token and text pointer). | ||||||||||||
| A8B1 | PUSH HL | Stash HL (the text pointer) on the stack. | ||||||||||||
| A8B2 | LD A,H | A=H (load the high byte of the token). | ||||||||||||
| A8B3 | OR C | Set the bits from C (merge with the format bits). | ||||||||||||
| A8B4 | LD H,A | H=A (store the modified high byte). | ||||||||||||
| A8B5 | LD ($A022),HL | Write HL (the modified token) to *TokenValueBuffer. | ||||||||||||
| A8B8 | POP HL | Restore HL (the text pointer) from the stack. | ||||||||||||
| A8B9 | PUSH BC | Stash BC on the stack. | ||||||||||||
|
Search the word index table for the token value.
|
||||||||||||||
| A8BA | LD IX,$5D80 | IX=Table_WordIndex (load the address of the word index table). | ||||||||||||
| A8BE | LD B,$5F | B=5F (initialise the search index). | ||||||||||||
| ExtractTokenFromText_SearchLoop | A8C0 | INC B | Increment B by one (move to the next entry). | |||||||||||
| A8C1 | LD A,(IX+$01) | Jump to ExtractTokenFromText_ContinueSearch if the high byte of the table entry is less than H (token high byte). | ||||||||||||
| A8C4 | CP H | |||||||||||||
| A8C5 | JR C,ExtractTokenFromText_ContinueSearch | |||||||||||||
| A8C7 | JR NZ,ExtractTokenFromText_FoundEntry | Jump to ExtractTokenFromText_FoundEntry if the high byte doesn't match (IX+01 is not equal to H). | ||||||||||||
| A8C9 | LD A,(IX+$00) | Jump to ExtractTokenFromText_FoundEntry if the low byte is too high (IX+00 is greater than or equal to L). | ||||||||||||
| A8CC | CP L | |||||||||||||
| A8CD | JR NC,ExtractTokenFromText_FoundEntry | |||||||||||||
| ExtractTokenFromText_ContinueSearch | A8CF | INC IX | Increment IX by two (move to the next table entry). | |||||||||||
| A8D1 | INC IX | |||||||||||||
| A8D3 | LD A,B | Jump to ExtractTokenFromText_SearchLoop if we haven't reached the end of the table (B is not equal to 7B). | ||||||||||||
| A8D4 | CP $7B | |||||||||||||
| A8D6 | JR NZ,ExtractTokenFromText_SearchLoop | |||||||||||||
| A8D8 | INC B | Increment B by one (adjust for end of table). | ||||||||||||
| ExtractTokenFromText_FoundEntry | A8D9 | JR Z,ExtractTokenFromText_GetWordAddress | Jump to ExtractTokenFromText_GetWordAddress if no matching entry was found (B is zero). | |||||||||||
| ExtractTokenFromText_BackupEntry | A8DB | DEC IX | Decrease IX by two (back up to the matching entry). | |||||||||||
| A8DD | DEC IX | |||||||||||||
| A8DF | DEC B | Decrease B by one (adjust the index). | ||||||||||||
| ExtractTokenFromText_GetWordAddress | A8E0 | LD E,(IX+$00) | Load the word address from the table entry into DE. | |||||||||||
| A8E3 | LD D,(IX+$01) | |||||||||||||
| A8E6 | LD A,D | Jump to ExtractTokenFromText_BackupEntry until we find a non-zero word address (DE is zero). | ||||||||||||
| A8E7 | OR E | |||||||||||||
| A8E8 | JR Z,ExtractTokenFromText_BackupEntry | |||||||||||||
|
Print the word from the dictionary.
|
||||||||||||||
| A8EA | LD A,B | A=B (load the word index). | ||||||||||||
| A8EB | CALL Print_Character | Call Print_Character to print the word character. | ||||||||||||
| A8EE | LD BC,$5DBF | HL+=5DBF (add the dictionary base address to get the word data pointer). | ||||||||||||
| A8F1 | ADD HL,BC | |||||||||||||
| A8F2 | PUSH HL | Stash HL (the word data pointer) on the stack. | ||||||||||||
| A8F3 | EX DE,HL | Exchange the DE and HL registers (swap word address and word data pointer). | ||||||||||||
| A8F4 | ADD HL,BC | HL+=BC (add the offset to the word data). | ||||||||||||
| ExtractTokenFromText_PrintWordContinue | A8F5 | PUSH HL | Stash HL (the calculated word data address) on the stack. | |||||||||||
| ExtractTokenFromText_PrintWordLoop | A8F6 | AND A | HL-=DE (with carry) (calculate the remaining length). | |||||||||||
| A8F7 | SBC HL,DE | |||||||||||||
| A8F9 | POP HL | Restore HL (the word data address) from the stack. | ||||||||||||
| A8FA | PUSH AF | Stash AF (the length comparison result) on the stack. | ||||||||||||
| A8FB | CALL ProcessFormatDataByte | Call ProcessFormatDataByte to print characters from the word. | ||||||||||||
| A8FE | POP AF | Restore AF (the length comparison result) from the stack. | ||||||||||||
| A8FF | JR NZ,ExtractTokenFromText_PrintWordContinue | Jump to ExtractTokenFromText_PrintWordContinue if there are more characters to print (B is not equal to A). | ||||||||||||
| A901 | POP HL | Restore HL and BC from the stack. | ||||||||||||
| A902 | POP BC | |||||||||||||
|
Handle special token format cases.
|
||||||||||||||
| A903 | LD A,C | Jump to ExtractTokenFromText_PrintRemainingText if the token format is 50. | ||||||||||||
| A904 | CP $50 | |||||||||||||
| A906 | JR Z,ExtractTokenFromText_PrintRemainingText | |||||||||||||
| A908 | CP $40 | Jump to ExtractTokenFromText_ProcessFormat if the token format is 40. | ||||||||||||
| A90A | JR Z,ExtractTokenFromText_ProcessFormat | |||||||||||||
|
Check if the token format is 10 (requires special handling).
|
||||||||||||||
| A90C | CP $10 | Compare C (the token format) with 10. | ||||||||||||
| A90E | LD A,($A034) | A=*RoomDisplayParameter (load the room display parameter). | ||||||||||||
| A911 | JR Z,ExtractTokenFromText_Format10 | Jump to ExtractTokenFromText_Format10 if the token format is 10. | ||||||||||||
| A913 | LD A,($A036) | Load A with *CurrentCharacter_ID. | ||||||||||||
| ExtractTokenFromText_Format10 | A916 | AND A | Jump to ExtractTokenFromText_PrintRemainingText (skip format processing for format 10). | |||||||||||
| A917 | JR Z,ExtractTokenFromText_PrintRemainingText | |||||||||||||
| ExtractTokenFromText_ProcessFormat | A919 | CALL ProcessTextTokenFormat | Call ProcessTextTokenFormat to process the text token format. | |||||||||||
| ExtractTokenFromText_PrintRemainingText | A91C | LD HL,$5C42 | HL=NEWPPC. | |||||||||||
| ExtractTokenFromText_PrintLoop | A91F | LD A,(HL) | Load a byte from *NEWPPC. | |||||||||||
| A920 | AND A | Jump to ExtractTokenFromText_End if we've reached the end of the text (A is zero). | ||||||||||||
| A921 | JR Z,ExtractTokenFromText_End | |||||||||||||
| A923 | CALL Print_Character | Call Print_Character to print the character. | ||||||||||||
| A926 | INC HL | Increment HL by one (move to the next character). | ||||||||||||
| A927 | JR ExtractTokenFromText_PrintLoop | Jump to ExtractTokenFromText_PrintLoop to continue printing. | ||||||||||||
|
All text printed - restore registers and return.
|
||||||||||||||
| ExtractTokenFromText_End | A929 | POP DE | Restore DE, BC, HL and IX from the stack. | |||||||||||
| A92A | POP BC | |||||||||||||
| A92B | POP HL | |||||||||||||
| A92C | POP IX | |||||||||||||
| A92E | RET | Return. | ||||||||||||
| Prev: A85C | Up: Map | Next: A92F |