![]() |
Routines |
| Prev: 29882 | Up: Map | Next: 30068 |
|
Used by the routines at Inglish_DescribeTheAction, PrintMessage, PrintMessage_TokenByNibble, Message_ChooseAClassToken, Message_PrintTheClassToken, Message_PrintTheFallbackToken, Action_Look, Message_ChooseTheNounByte, MessageListTheObjects, DisplayExits and ActionGoblinCapture.
Prints a dictionary token, expanding letters until the dictionary word ends.
|
||||||||
| PrintToken | 29889 | LD A,D | Take the token's high byte. | |||||
| 29890 | AND %00001111 | Keep its low nibble (bits 8-11 of the token). | ||||||
| 29892 | OR E | Merge in the low byte. | ||||||
| 29893 | RET Z | Return if bits 0-11 of the token are all zero. | ||||||
| 29894 | PUSH HL | Save the text pointer, BC and the token, and keep the class in C. | ||||||
| 29895 | PUSH BC | |||||||
| 29896 | PUSH DE | |||||||
| 29897 | LD C,D | |||||||
| 29898 | LD A,D | Take the token's high byte again. | ||||||
| 29899 | AND 15 | Keep bits 8-11 of the token in D. | ||||||
| 29901 | LD D,A | |||||||
| 29902 | LD HL,24576 | Add the token index to the pointer. | ||||||
| 29905 | ADD HL,DE | |||||||
| 29906 | LD DE,29862 | Point DE at output buffer. | ||||||
| 29909 | PUSH HL | Save the dictionary address and start the letter count at zero. | ||||||
| 29910 | LD B,0 | |||||||
| PrintToken_Loop | 29912 | LD A,(HL) | Read the next byte of the dictionary word. | |||||
| 29913 | AND 31 | Jump to PrintToken_ChooseTheSubject if the low five bits of this dictionary byte are zero. | ||||||
| 29915 | JR Z,PrintToken_ChooseTheSubject | |||||||
| 29917 | INC B | Count one more character of the message. | ||||||
| 29918 | ADD A,96 | Add 96 to A to convert to ASCII. | ||||||
| 29920 | LD (DE),A | Store the result in the output buffer. | ||||||
| 29921 | INC DE | Increase the output buffer pointer by one. | ||||||
| 29922 | BIT 7,(HL) | Check if this is the last character in it. | ||||||
| 29924 | INC HL | Increase the character pointer reference by one. | ||||||
| 29925 | JR Z,PrintToken_Loop | If this is not the last character in it, loop back to PrintToken_Loop to continue processing. | ||||||
|
Check minimum length.
|
||||||||
| 29927 | LD A,B | Copy the count in B into A. | ||||||
| 29928 | CP 2 | If the number of characters is only 2 then jump back to PrintToken_Loop to continue processing. | ||||||
| 29930 | JR Z,PrintToken_Loop | |||||||
| 29932 | CP 3 | If it is not 3, then jump to PrintToken_ChooseTheSubject. | ||||||
| 29934 | JR NZ,PrintToken_ChooseTheSubject | |||||||
| 29936 | DEC HL | Otherwise fetch the second character again and test its bit 7. | ||||||
| 29937 | DEC HL | |||||||
| 29938 | LD A,(HL) | |||||||
| 29939 | INC HL | |||||||
| 29940 | INC HL | |||||||
| 29941 | BIT 7,A | |||||||
| 29943 | JR NZ,PrintToken_Loop | Loop back to PrintToken_Loop to continue processing if bit 7 of the second character is set. | ||||||
| PrintToken_ChooseTheSubject | 29945 | POP HL | Jump to PrintToken_MeasureTheOutput if the high nibble of the result is 80. | |||||
| 29946 | LD A,C | |||||||
| 29947 | AND 240 | |||||||
| 29949 | CP 80 | |||||||
| 29951 | JR Z,PrintToken_MeasureTheOutput | |||||||
| 29953 | CP 64 | Jump to PrintToken_ExpandTheVerbEnding if the high nibble of the result is 64. | ||||||
| 29955 | JR Z,PrintToken_ExpandTheVerbEnding | |||||||
| 29957 | CP 16 | Take the current object, and jump to PrintToken_TestForThePlayer if the high nibble of the result is 16. | ||||||
| 29959 | LD A,(46824) | |||||||
| 29962 | JR Z,PrintToken_TestForThePlayer | |||||||
| 29964 | LD A,(46826) | Read *CurrentCharacter. | ||||||
| PrintToken_TestForThePlayer | 29967 | AND A | Jump to PrintToken_MeasureTheOutput if the subject in A is the player (id 0). | |||||
| 29968 | JR Z,PrintToken_MeasureTheOutput | |||||||
| PrintToken_ExpandTheVerbEnding | 29970 | INC HL | Jump to PrintToken_MeasureTheOutput if the token index is not a class token. | |||||
| 29971 | BIT 7,(HL) | |||||||
| 29973 | JR Z,PrintToken_MeasureTheOutput | |||||||
| 29975 | INC HL | Step to the next byte of the token index. | ||||||
| 29976 | LD A,(HL) | Read the token index. | ||||||
| 29977 | AND 224 | Shift the top three bits down by three places. That index, times four, selects an ending in 46879. | ||||||
| 29979 | RRCA | |||||||
| 29980 | RRCA | |||||||
| 29981 | RRCA | |||||||
| 29982 | LD L,A | The shifted index is the low byte of the pointer. | ||||||
| 29983 | LD H,0 | The pointer's high byte is zero. | ||||||
| 29985 | LD BC,46879 | Add the verb-ending table at 46879. | ||||||
| 29988 | ADD HL,BC | |||||||
| 29989 | LD B,4 | Copy at most 4 bytes of the ending. | ||||||
| PrintToken_CopyTheEnding | 29991 | LD A,(HL) | Jump to PrintToken_MeasureTheOutput if the token index is zero. | |||||
| 29992 | AND A | |||||||
| 29993 | JR Z,PrintToken_MeasureTheOutput | |||||||
| 29995 | INC HL | Step to the next byte of the token index. | ||||||
| 29996 | LD (DE),A | Store it at OutputBuffer and step on. | ||||||
| 29997 | INC DE | |||||||
| 29998 | DJNZ PrintToken_CopyTheEnding | Loop back to PrintToken_CopyTheEnding until 4 runs out. | ||||||
| PrintToken_MeasureTheOutput | 30000 | LD HL,29862 | Point HL at output buffer. | |||||
| 30003 | EX DE,HL | Swap the print pointer with the start of the output buffer. | ||||||
| 30004 | AND A | Clear carry before measuring how far the print pointer has moved. | ||||||
| 30005 | SBC HL,DE | See how far the pointer is past OutputBuffer. | ||||||
| 30007 | LD B,L | Keep the length just measured, and read the action countdown. | ||||||
| 30008 | LD A,(46849) | |||||||
| 30011 | AND A | See whether the action countdown is zero. | ||||||
| 30012 | PUSH AF | Jump to PrintToken_PrintASpace if the action countdown is not zero. | ||||||
| 30013 | JR NZ,PrintToken_PrintASpace | |||||||
| 30015 | LD A,(34464) | Read the character flag. | ||||||
| 30018 | AND A | See whether the character flag is zero. | ||||||
| PrintToken_PrintASpace | 30019 | LD A,32 | Take 32, and call Print_Character to print it if the action countdown or the character flag is not zero. | |||||
| 30021 | CALL NZ,Print_Character | |||||||
| 30024 | POP AF | Take the characters left on the line from 34227, and jump to PrintToken_FitOnTheLine if the action countdown is not zero. | ||||||
| 30025 | LD A,(34227) | |||||||
| 30028 | JR NZ,PrintToken_FitOnTheLine | |||||||
| 30030 | LD A,(34459) | Read the room left on the line at PrintWriteACharacterToTheScreen. | ||||||
| PrintToken_FitOnTheLine | 30033 | LD HL,46852 | Jump to PrintToken_TestTheClassNibble if A is not below the character count. A is *34227 when the action countdown is not zero, and the room left on the line otherwise. | |||||
| 30036 | CP B | |||||||
| 30037 | JR NC,PrintToken_TestTheClassNibble | |||||||
| 30039 | LD A,(HL) | Save the capitalise-the-next-letter flag. | ||||||
|
Print a newline.
|
||||||||
| 30040 | CALL Print_LineBreak | Call Print_LineBreak to print a newline. | ||||||
| 30043 | LD (HL),A | Put the capitalise-the-next-letter flag back as it was before the newline. | ||||||
| PrintToken_TestTheClassNibble | 30044 | POP DE | Take 1 and jump to PrintToken_Print unless the high nibble of D is 112. | |||||
| 30045 | LD A,D | |||||||
| 30046 | AND 240 | |||||||
| 30048 | CP 112 | |||||||
| 30050 | LD A,1 | |||||||
| 30052 | JR NZ,PrintToken_Print | |||||||
| 30054 | LD (HL),A | Set the capitalise-the-next-letter flag. | ||||||
| PrintToken_Print | 30055 | LD HL,29862 | Point HL at output buffer. | |||||
| PrintToken_Print_Loop | 30058 | LD A,(HL) | Fetch the next character from the output buffer. | |||||
| 30059 | CALL Print_Character | Call Print_Character to print one character. | ||||||
| 30062 | INC HL | Increase the output buffer pointer by one. | ||||||
| 30063 | DJNZ PrintToken_Print_Loop | Decrease counter by one and loop back to PrintToken_Print_Loop until counter is zero. | ||||||
| 30065 | POP BC | Restore BC and HL from the stack. | ||||||
| 30066 | POP HL | |||||||
| 30067 | RET | Return. | ||||||
| Prev: 29882 | Up: Map | Next: 30068 |