Prev: A1ED Up: Map Next: A25C
A1F4: Print Compressed String
Prints a compressed text string using a dictionary lookup.
Input
HL Messaging string ID
Resolve the messaging string ID into a pointer at Data_Strings.
PrintCompressedString A1F4 PUSH IX Stash IX, HL, DE, BC and AF on the stack.
A1F6 PUSH HL
A1F7 PUSH DE
A1F8 PUSH BC
A1F9 PUSH AF
A1FA ADD HL,HL Double the messaging string ID held in HL.
A1FB EX DE,HL Add the result to Table_MessagingOffsets.
A1FC LD IX,$CA2B
A200 ADD IX,DE
A202 LD L,(IX+$00) Fetch the address from the string pointer table and store it in HL.
A205 LD H,(IX+$01)
A208 LD DE,$C8E9 HL+=Data_Strings.
A20B ADD HL,DE
A20C JR PrintCompressedString_Loop Jump to PrintCompressedString_Loop.
Codes below 60 are literal characters. Codes from 60 upwards index the dictionary at C8EB.
PrintCompressedString_Process A20E CP $60 Jump to PrintCompressedString_Literal if A is less than 60.
A210 JR C,PrintCompressedString_Literal
A212 CALL PrintCompressedString_Dictionary Call PrintCompressedString_Dictionary.
A215 JR PrintCompressedString_Next Jump to PrintCompressedString_Next.
Bias the literal into the printable range. 7E becomes a newline.
PrintCompressedString_Literal A217 ADD A,$20 A+=20.
A219 CP $7E Jump to PrintCompressedString_PrintChar if A is not equal to 7E.
A21B JR NZ,PrintCompressedString_PrintChar
A21D LD A,$0D A=0D.
PrintCompressedString_PrintChar A21F CALL PrintCharacter Call PrintCharacter.
PrintCompressedString_Next A222 INC HL Move HL on to the next compressed character.
Fetch the next compressed byte. 5F ends the string.
PrintCompressedString_Loop A223 LD A,(HL) A=*HL.
A224 CP $5F Jump to PrintCompressedString_Process if A is not equal to 5F.
A226 JR NZ,PrintCompressedString_Process
A228 POP AF Restore AF, BC, DE, HL and IX from the stack.
A229 POP BC
A22A POP DE
A22B POP HL
A22C POP IX
A22E RET Return.
Look up a two-byte dictionary entry and print both characters.
PrintCompressedString_Dictionary A22F PUSH HL Stash HL, DE and BC on the stack.
A230 PUSH DE
A231 PUSH BC
A232 SUB $60 A-=60.
A234 LD L,A Create an offset in HL using A.
A235 LD H,$00
A237 ADD HL,HL Double the offset held in HL.
A238 LD DE,$C8EB HL+=C8EB.
A23B ADD HL,DE
A23C LD B,$02 Count two dictionary bytes.
A23E JR PrintCompressedString_DictFetch Jump to PrintCompressedString_DictFetch.
PrintCompressedString_DictNext A240 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 A241 LD A,(HL) A=*HL.
A242 CP $60 Jump to PrintCompressedString_DictLiteral if A is less than 60.
A244 JR C,PrintCompressedString_DictLiteral
A246 CALL PrintCompressedString_Dictionary Call PrintCompressedString_Dictionary.
A249 JR PrintCompressedString_DictDone Jump to PrintCompressedString_DictDone.
PrintCompressedString_DictLiteral A24B ADD A,$20 A+=20.
A24D CP $7E Jump to PrintCompressedString_DictPrint if A is not equal to 7E.
A24F JR NZ,PrintCompressedString_DictPrint
A251 LD A,$0D A=0D.
PrintCompressedString_DictPrint A253 CALL PrintCharacter Call PrintCharacter.
PrintCompressedString_DictDone A256 DJNZ PrintCompressedString_DictNext Decrease the dictionary-character counter and loop back to PrintCompressedString_DictNext until both bytes are done.
A258 POP BC Restore BC, DE and HL from the stack.
A259 POP DE
A25A POP HL
A25B RET Return.
Prev: A1ED Up: Map Next: A25C