![]() |
Routines |
| Prev: A880 | Up: Map | Next: A92F |
|
Used by the routines at ProcessObjectDisplay, ProcessObject_Display, MarkSuccessScript, PrintCharacterWithTimePeriod, PrintTokenBasedOnParameters, A815, 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 | 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. | ||
| A890 | LD A,D | Read the high byte of the token. | ||
| 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 both token digits are zero. | ||
| A895 | PUSH IX | Save the character record, the pointer, the count and the source. | ||
| A897 | PUSH HL | |||
| A898 | PUSH BC | |||
| A899 | PUSH DE | |||
|
Process the token format and prepare for dictionary lookup.
|
||||
| A89A | LD A,$20 | Use 20 for the character code. | ||
| A89C | CALL Print_Character | Print the character in A through Print_Character. | ||
| A89F | LD A,D | Read the high byte of the token. | ||
| A8A0 | AND %11110000 | Keep only bits 4-7 (extract the high nibble). | ||
| A8A2 | LD C,A | Store the result in the low byte of the count. | ||
| A8A3 | CP $70 | See whether this byte is a dictionary word. | ||
|
Prepare to set a flag if the token format is 70.
|
||||
| A8A5 | LD A,$01 | Load 01 and jump ahead to PrintTextToken_ProcessToken unless the high nibble is 70. | ||
| A8A7 | JR NZ,PrintTextToken_ProcessToken | |||
| A8A9 | LD ($A026),A | Record the token format flag. | ||
| PrintTextToken_ProcessToken | A8AC | LD A,D | Read the high byte of the token. | |
| A8AD | AND %00001111 | Keep only bits 0-3 (extract the low nibble). | ||
| A8AF | LD D,A | Store the result in the high byte of the source. | ||
| A8B0 | EX DE,HL | Move the token into HL so its high byte can be merged with the format bits. | ||
| A8B1 | PUSH HL | Read the high byte of the pointer, saving pointer. | ||
| A8B2 | LD A,H | |||
| A8B3 | OR C | Set the bits from C (merge with the format bits). | ||
| A8B4 | LD H,A | Keep the high byte of this token. | ||
| A8B5 | LD ($A022),HL | Write HL (the modified token) to *TokenValueBuffer. | ||
| A8B8 | POP HL | Restore the saved pointer from the stack. | ||
| A8B9 | PUSH BC | Use the dictionary index at Table_WordIndex, saving count and. | ||
|
Search the dictionary index table for the token value.
|
||||
| A8BA | LD IX,$5D80 | |||
| A8BE | LD B,$5F | |||
| PrintTextToken_SearchLoop | A8C0 | INC B | Count this dictionary entry and keep searching when it is still below the token. | |
| A8C1 | LD A,(IX+$01) | |||
| A8C4 | CP H | |||
| A8C5 | JR C,PrintTextToken_ContinueSearch | |||
| A8C7 | JR NZ,PrintTextToken_FoundEntry | Jump to PrintTextToken_FoundEntry when this entry is past the token. | ||
| A8C9 | LD A,(IX+$00) | Compare the low byte and jump to PrintTextToken_FoundEntry when the entry has reached the token. | ||
| A8CC | CP L | |||
| A8CD | JR NC,PrintTextToken_FoundEntry | |||
| PrintTextToken_ContinueSearch | A8CF | INC IX | Step to the next dictionary entry and keep searching until 7B entries have been tried. | |
| A8D1 | INC IX | |||
| A8D3 | LD A,B | |||
| A8D4 | CP $7B | |||
| A8D6 | JR NZ,PrintTextToken_SearchLoop | |||
| A8D8 | INC B | Count another dictionary entry. | ||
| PrintTextToken_FoundEntry | A8D9 | JR Z,PrintTextToken_GetWordAddress | Go to PrintTextToken_GetWordAddress if the count wrapped to zero. | |
| PrintTextToken_BackupEntry | A8DB | DEC IX | Step back one dictionary entry. | |
| A8DD | DEC IX | |||
| A8DF | DEC B | |||
| PrintTextToken_GetWordAddress | A8E0 | LD E,(IX+$00) | Read the word address at the start of the record. | |
| A8E3 | LD D,(IX+$01) | |||
| A8E6 | LD A,D | Jump back to PrintTextToken_BackupEntry when the word address is still zero. | ||
| A8E7 | OR E | |||
| A8E8 | JR Z,PrintTextToken_BackupEntry | |||
|
Print the next letter of this dictionary word.
|
||||
| A8EA | LD A,B | Take the count. | ||
| A8EB | CALL Print_Character | Print the character in A through Print_Character. | ||
| A8EE | LD BC,$5DBF | Take the dictionary index and swap the two pointers. | ||
| A8F1 | ADD HL,BC | |||
| A8F2 | PUSH HL | |||
| A8F3 | EX DE,HL | |||
| A8F4 | ADD HL,BC | |||
| PrintTextToken_PrintWordContinue | A8F5 | PUSH HL | Compare HL with DE, keeping HL, and save the result flags. | |
| PrintTextToken_PrintWordLoop | A8F6 | AND A | ||
| A8F7 | SBC HL,DE | |||
| A8F9 | POP HL | |||
| A8FA | PUSH AF | |||
| A8FB | CALL ProcessFormatDataByte | Call ProcessFormatDataByte to read the next format byte. | ||
| A8FE | POP AF | Restore the comparison flags from the stack. | ||
| A8FF | JR NZ,PrintTextToken_PrintWordContinue | . Jump back to PrintTextToken_PrintWordContinue while the two pointers differ, and drop the saved pointers when they match. | ||
| A901 | POP HL | |||
| A902 | POP BC | |||
|
Handle special token format cases.
|
||||
| A903 | LD A,C | Jump to PrintTextToken_PrintRemainingText when the format byte is 50. | ||
| A904 | CP $50 | |||
| A906 | JR Z,PrintTextToken_PrintRemainingText | |||
| A908 | CP $40 | Jump to PrintTextToken_ProcessFormat when the format byte is 40. | ||
| A90A | JR Z,PrintTextToken_ProcessFormat | |||
| A90C | CP $10 | Load the room display parameter and jump ahead to PrintTextToken_Format_TestCharacterBeingProcessed if the format byte is 10. | ||
| A90E | LD A,($A034) | |||
| A911 | JR Z,PrintTextToken_Format_TestCharacterBeingProcessed | |||
| A913 | LD A,($A036) | Load A with *CurrentCharacter_ID. | ||
| PrintTextToken_Format_TestCharacterBeingProcessed | A916 | AND A | Jump ahead to PrintTextToken_PrintRemainingText if the character being processed is zero. | |
| A917 | JR Z,PrintTextToken_PrintRemainingText | |||
| PrintTextToken_ProcessFormat | A919 | CALL ProcessTextTokenFormat | Call ProcessTextTokenFormat to handle the token format. | |
| PrintTextToken_PrintRemainingText | A91C | LD HL,$5C42 | HL=NEWPPC. | |
| PrintTextToken_PrintLoop | A91F | LD A,(HL) | Load a byte from *NEWPPC. | |
| A920 | AND A | Jump ahead to PrintTextToken_End if this byte is zero. | ||
| A921 | JR Z,PrintTextToken_End | |||
| A923 | CALL Print_Character | Print the character in A through Print_Character. | ||
| A926 | INC HL | Step to the next letter and go back to PrintTextToken_PrintLoop. | ||
| A927 | JR PrintTextToken_PrintLoop | |||
|
Return.
All text printed - restore registers and return.
|
||||
| PrintTextToken_End | A929 | POP DE | Restore the saved source, the saved count, the saved pointer and the saved character record from the stack. | |
| A92A | POP BC | |||
| A92B | POP HL | |||
| A92C | POP IX | |||
| A92E | RET | Return. | ||
| Prev: A880 | Up: Map | Next: A92F |