![]() |
Routines |
| Prev: 41453 | Up: Map | Next: 41564 |
|
Used by the routines at PrintCompressedStringAndNewline, Handler_RoomExits, Parser_ValidateItem, Action_PrintMessage and Print_Scoring.
Prints a compressed text string using a dictionary lookup.
|
||||||||
|
Resolve the messaging string ID into a pointer at Data_Strings.
|
||||||||
| PrintCompressedString | 41460 | PUSH IX | Stash IX, HL, DE, BC and AF on the stack. | |||||
| 41462 | PUSH HL | |||||||
| 41463 | PUSH DE | |||||||
| 41464 | PUSH BC | |||||||
| 41465 | PUSH AF | |||||||
| 41466 | ADD HL,HL | Double the messaging string ID held in HL. | ||||||
| 41467 | EX DE,HL | Add the result to Table_MessagingOffsets. | ||||||
| 41468 | LD IX,51755 | |||||||
| 41472 | ADD IX,DE | |||||||
| 41474 | LD L,(IX+0) | Fetch the address from the string pointer table and store it in HL. | ||||||
| 41477 | LD H,(IX+1) | |||||||
| 41480 | LD DE,51433 | HL+=Data_Strings. | ||||||
| 41483 | ADD HL,DE | |||||||
| 41484 | JR PrintCompressedString_Loop | Jump to PrintCompressedString_Loop. | ||||||
|
Codes below 96 are literal characters. Codes from 96 upwards index the dictionary at 51435.
|
||||||||
| PrintCompressedString_Process | 41486 | CP 96 | Jump to PrintCompressedString_Literal if A is less than 96. | |||||
| 41488 | JR C,PrintCompressedString_Literal | |||||||
| 41490 | CALL PrintCompressedString_Dictionary | Call PrintCompressedString_Dictionary. | ||||||
| 41493 | JR PrintCompressedString_Next | Jump to PrintCompressedString_Next. | ||||||
|
Bias the literal into the printable range. 126 becomes a newline.
|
||||||||
| PrintCompressedString_Literal | 41495 | ADD A,32 | A+=32. | |||||
| 41497 | CP 126 | Jump to PrintCompressedString_PrintChar if A is not equal to 126. | ||||||
| 41499 | JR NZ,PrintCompressedString_PrintChar | |||||||
| 41501 | LD A,13 | A=13. | ||||||
| PrintCompressedString_PrintChar | 41503 | CALL PrintCharacter | Call PrintCharacter. | |||||
| PrintCompressedString_Next | 41506 | INC HL | Move HL on to the next compressed character. | |||||
|
Fetch the next compressed byte. 95 ends the string.
|
||||||||
| PrintCompressedString_Loop | 41507 | LD A,(HL) | A=*HL. | |||||
| 41508 | CP 95 | Jump to PrintCompressedString_Process if A is not equal to 95. | ||||||
| 41510 | JR NZ,PrintCompressedString_Process | |||||||
| 41512 | POP AF | Restore AF, BC, DE, HL and IX from the stack. | ||||||
| 41513 | POP BC | |||||||
| 41514 | POP DE | |||||||
| 41515 | POP HL | |||||||
| 41516 | POP IX | |||||||
| 41518 | RET | Return. | ||||||
|
Look up a two-byte dictionary entry and print both characters.
|
||||||||
| PrintCompressedString_Dictionary | 41519 | PUSH HL | Stash HL, DE and BC on the stack. | |||||
| 41520 | PUSH DE | |||||||
| 41521 | PUSH BC | |||||||
| 41522 | SUB 96 | A-=96. | ||||||
| 41524 | LD L,A | Create an offset in HL using A. | ||||||
| 41525 | LD H,0 | |||||||
| 41527 | ADD HL,HL | Double the offset held in HL. | ||||||
| 41528 | LD DE,51435 | HL+=51435. | ||||||
| 41531 | ADD HL,DE | |||||||
| 41532 | LD B,2 | Count two dictionary bytes. | ||||||
| 41534 | JR PrintCompressedString_DictFetch | Jump to PrintCompressedString_DictFetch. | ||||||
| PrintCompressedString_DictNext | 41536 | INC HL | Move HL on to the next dictionary character. | |||||
|
Dictionary bytes use the same literal-or-dictionary split as the main string.
|
||||||||
| PrintCompressedString_DictFetch | 41537 | LD A,(HL) | A=*HL. | |||||
| 41538 | CP 96 | Jump to PrintCompressedString_DictLiteral if A is less than 96. | ||||||
| 41540 | JR C,PrintCompressedString_DictLiteral | |||||||
| 41542 | CALL PrintCompressedString_Dictionary | Call PrintCompressedString_Dictionary. | ||||||
| 41545 | JR PrintCompressedString_DictDone | Jump to PrintCompressedString_DictDone. | ||||||
| PrintCompressedString_DictLiteral | 41547 | ADD A,32 | A+=32. | |||||
| 41549 | CP 126 | Jump to PrintCompressedString_DictPrint if A is not equal to 126. | ||||||
| 41551 | JR NZ,PrintCompressedString_DictPrint | |||||||
| 41553 | LD A,13 | A=13. | ||||||
| PrintCompressedString_DictPrint | 41555 | CALL PrintCharacter | Call PrintCharacter. | |||||
| PrintCompressedString_DictDone | 41558 | DJNZ PrintCompressedString_DictNext | Decrease the dictionary-character counter and loop back to PrintCompressedString_DictNext until both bytes are done. | |||||
| 41560 | POP BC | Restore BC, DE and HL from the stack. | ||||||
| 41561 | POP DE | |||||||
| 41562 | POP HL | |||||||
| 41563 | RET | Return. | ||||||
| Prev: 41453 | Up: Map | Next: 41564 |