![]() |
Routines |
| Prev: 43136 | Up: Map | Next: 43311 |
|
Used by the routines at ProcessObjectDisplay, ProcessObject_Display, MarkSuccessScript, PrintCharacterWithTimePeriod, PrintTokenBasedOnParameters, 43029, ProcessObjectOrPrintToken, ProcessTextTokenEntry, GetDisplayAddressBasedOnFlag, DescribeCurrentRoom, PrintFormattedObjectList, PrintObjectAttributeDescription, PrintLocationExits and PrintLocationExitsWithFormatting.
Prints a space and the dictionary word when the dictionary flag is set, and returns at once when that flag is clear.
|
||||
| PrintTextToken | 43143 | LD A,(23612) | Return if *TV_FLAG is not set. | |
| 43146 | AND A | |||
| 43147 | RET Z | |||
| 43148 | LD (40994),DE | Write DE (the token value) to *TokenValueBuffer. | ||
| 43152 | LD A,D | Read the high byte of the token. | ||
| 43153 | AND %00001111 | Keep only bits 0-3 (ensure we have just the low nibble). | ||
| 43155 | OR E | Set the bits from E (merge with the first byte). | ||
| 43156 | RET Z | Return if both token digits are zero. | ||
| 43157 | PUSH IX | Save the character record, the pointer, the count and the source. | ||
| 43159 | PUSH HL | |||
| 43160 | PUSH BC | |||
| 43161 | PUSH DE | |||
|
Process the token format and prepare for dictionary lookup.
|
||||
| 43162 | LD A,32 | Use 32 for the character code. | ||
| 43164 | CALL Print_Character | Print the character in A through Print_Character. | ||
| 43167 | LD A,D | Read the high byte of the token. | ||
| 43168 | AND %11110000 | Keep only bits 4-7 (extract the high nibble). | ||
| 43170 | LD C,A | Store the result in the low byte of the count. | ||
| 43171 | CP 112 | See whether this byte is a dictionary word. | ||
|
Prepare to set a flag if the token format is 112.
|
||||
| 43173 | LD A,1 | Load 1 and jump ahead to PrintTextToken_ProcessToken unless the high nibble is 112. | ||
| 43175 | JR NZ,PrintTextToken_ProcessToken | |||
| 43177 | LD (40998),A | Record the token format flag. | ||
| PrintTextToken_ProcessToken | 43180 | LD A,D | Read the high byte of the token. | |
| 43181 | AND %00001111 | Keep only bits 0-3 (extract the low nibble). | ||
| 43183 | LD D,A | Store the result in the high byte of the source. | ||
| 43184 | EX DE,HL | Move the token into HL so its high byte can be merged with the format bits. | ||
| 43185 | PUSH HL | Read the high byte of the pointer, saving pointer. | ||
| 43186 | LD A,H | |||
| 43187 | OR C | Set the bits from C (merge with the format bits). | ||
| 43188 | LD H,A | Keep the high byte of this token. | ||
| 43189 | LD (40994),HL | Write HL (the modified token) to *TokenValueBuffer. | ||
| 43192 | POP HL | Restore the saved pointer from the stack. | ||
| 43193 | PUSH BC | Use the dictionary index at Table_WordIndex, saving count and. | ||
|
Search the dictionary index table for the token value.
|
||||
| 43194 | LD IX,23936 | |||
| 43198 | LD B,95 | |||
| PrintTextToken_SearchLoop | 43200 | INC B | Count this dictionary entry and keep searching when it is still below the token. | |
| 43201 | LD A,(IX+1) | |||
| 43204 | CP H | |||
| 43205 | JR C,PrintTextToken_ContinueSearch | |||
| 43207 | JR NZ,PrintTextToken_FoundEntry | Jump to PrintTextToken_FoundEntry when this entry is past the token. | ||
| 43209 | LD A,(IX+0) | Compare the low byte and jump to PrintTextToken_FoundEntry when the entry has reached the token. | ||
| 43212 | CP L | |||
| 43213 | JR NC,PrintTextToken_FoundEntry | |||
| PrintTextToken_ContinueSearch | 43215 | INC IX | Step to the next dictionary entry and keep searching until 123 entries have been tried. | |
| 43217 | INC IX | |||
| 43219 | LD A,B | |||
| 43220 | CP 123 | |||
| 43222 | JR NZ,PrintTextToken_SearchLoop | |||
| 43224 | INC B | Count another dictionary entry. | ||
| PrintTextToken_FoundEntry | 43225 | JR Z,PrintTextToken_GetWordAddress | Go to PrintTextToken_GetWordAddress if the count wrapped to zero. | |
| PrintTextToken_BackupEntry | 43227 | DEC IX | Step back one dictionary entry. | |
| 43229 | DEC IX | |||
| 43231 | DEC B | |||
| PrintTextToken_GetWordAddress | 43232 | LD E,(IX+0) | Read the word address at the start of the record. | |
| 43235 | LD D,(IX+1) | |||
| 43238 | LD A,D | Jump back to PrintTextToken_BackupEntry when the word address is still zero. | ||
| 43239 | OR E | |||
| 43240 | JR Z,PrintTextToken_BackupEntry | |||
|
Print the next letter of this dictionary word.
|
||||
| 43242 | LD A,B | Take the count. | ||
| 43243 | CALL Print_Character | Print the character in A through Print_Character. | ||
| 43246 | LD BC,23999 | Take the dictionary index and swap the two pointers. | ||
| 43249 | ADD HL,BC | |||
| 43250 | PUSH HL | |||
| 43251 | EX DE,HL | |||
| 43252 | ADD HL,BC | |||
| PrintTextToken_PrintWordContinue | 43253 | PUSH HL | Compare HL with DE, keeping HL, and save the result flags. | |
| PrintTextToken_PrintWordLoop | 43254 | AND A | ||
| 43255 | SBC HL,DE | |||
| 43257 | POP HL | |||
| 43258 | PUSH AF | |||
| 43259 | CALL ProcessFormatDataByte | Call ProcessFormatDataByte to read the next format byte. | ||
| 43262 | POP AF | Restore the comparison flags from the stack. | ||
| 43263 | JR NZ,PrintTextToken_PrintWordContinue | . Jump back to PrintTextToken_PrintWordContinue while the two pointers differ, and drop the saved pointers when they match. | ||
| 43265 | POP HL | |||
| 43266 | POP BC | |||
|
Handle special token format cases.
|
||||
| 43267 | LD A,C | Jump to PrintTextToken_PrintRemainingText when the format byte is 80. | ||
| 43268 | CP 80 | |||
| 43270 | JR Z,PrintTextToken_PrintRemainingText | |||
| 43272 | CP 64 | Jump to PrintTextToken_ProcessFormat when the format byte is 64. | ||
| 43274 | JR Z,PrintTextToken_ProcessFormat | |||
| 43276 | CP 16 | Load the room display parameter and jump ahead to PrintTextToken_Format_TestCharacterBeingProcessed if the format byte is 16. | ||
| 43278 | LD A,(41012) | |||
| 43281 | JR Z,PrintTextToken_Format_TestCharacterBeingProcessed | |||
| 43283 | LD A,(41014) | Load A with *CurrentCharacter_ID. | ||
| PrintTextToken_Format_TestCharacterBeingProcessed | 43286 | AND A | Jump ahead to PrintTextToken_PrintRemainingText if the character being processed is zero. | |
| 43287 | JR Z,PrintTextToken_PrintRemainingText | |||
| PrintTextToken_ProcessFormat | 43289 | CALL ProcessTextTokenFormat | Call ProcessTextTokenFormat to handle the token format. | |
| PrintTextToken_PrintRemainingText | 43292 | LD HL,23618 | HL=NEWPPC. | |
| PrintTextToken_PrintLoop | 43295 | LD A,(HL) | Load a byte from *NEWPPC. | |
| 43296 | AND A | Jump ahead to PrintTextToken_End if this byte is zero. | ||
| 43297 | JR Z,PrintTextToken_End | |||
| 43299 | CALL Print_Character | Print the character in A through Print_Character. | ||
| 43302 | INC HL | Step to the next letter and go back to PrintTextToken_PrintLoop. | ||
| 43303 | JR PrintTextToken_PrintLoop | |||
|
Return.
All text printed - restore registers and return.
|
||||
| PrintTextToken_End | 43305 | POP DE | Restore the saved source, the saved count, the saved pointer and the saved character record from the stack. | |
| 43306 | POP BC | |||
| 43307 | POP HL | |||
| 43308 | POP IX | |||
| 43310 | RET | Return. | ||
| Prev: 43136 | Up: Map | Next: 43311 |