Prev: 61159 Up: Map Next: 61314
61169: Print Message
Used by the routines at CallSubMessage and SubMessageSelect.
Walks a message script pointed to by HL. Most bytes are literal character codes passed to ClipAndPrintCharacter; values below 32 are control codes:
Code Action
0-23 Set row, then column (also PrintLeftMarginColumn)
24 Set attribute at PrintState
25 Set flags at PrintState_Flags
26 End of script (return)
27 Repeat current character
28 Fill a box of spaces
29 New line from PrintLeftMarginColumn
30 Add to column; advance row
31 Call sub-script via CallSubMessage
Dispatch the next script byte to a control handler, or print it as a literal character.
PrintMessage 61169 LD A,(HL) Fetch the next script byte.
61170 INC HL
Codes 0-23 set the print row and column.
61171 CP 24 Jump to PrintMessage_SetPosition if A is less than 24.
61173 JR C,PrintMessage_SetPosition
Code 24 sets the print attribute.
61175 JR Z,PrintMessage_SetAttribute Jump to PrintMessage_SetAttribute if A is 24.
Code 26 ends the script.
61177 CP 26 Compare A with 26.
61179 RET Z Return if this is the end-of-script code.
Code 25 sets the print flags.
61180 JR C,PrintMessage_SetFlags Jump to PrintMessage_SetFlags if A is less than 26.
Code 27 repeats the current character.
61182 CP 28 Jump to PrintMessage_Repeat if A is less than 28.
61184 JR C,PrintMessage_Repeat
Code 28 fills a box of spaces.
61186 JR Z,PrintMessage_FillBox Jump to PrintMessage_FillBox if A is 28.
Code 29 starts a new line from the left margin.
61188 CP 30 Jump to PrintMessage_NewLine if A is less than 30.
61190 JR C,PrintMessage_NewLine
Code 30 adds to the column, then advances the row.
61192 JR Z,PrintMessage_AddColumn Jump to PrintMessage_AddColumn if A is 30.
Code 31 calls a location-art sub-script.
61194 CP 31 Jump to CallSubMessage if A is 31.
61196 JP Z,CallSubMessage
Literal character: store it and print via ClipAndPrintCharacter.
61199 LD (23545),A Store the character in *PrintState_Character and print it.
61202 CALL ClipAndPrintCharacter
61205 JR PrintMessage Jump to PrintMessage.
PrintMessage_SetPosition 61207 LD (23544),A Store the new row and column in the print state.
61210 LD A,(HL)
61211 LD (23543),A
61214 LD (23296),A Remember the left margin at PrintLeftMarginColumn and continue.
61217 INC HL
61218 JR PrintMessage
PrintMessage_SetAttribute 61220 LD A,(HL) Store the next script byte as the print attribute.
61221 LD (23541),A
61224 INC HL
61225 JR PrintMessage
PrintMessage_SetFlags 61227 LD A,(HL) Store the next script byte as the print flags.
61228 LD (23542),A
61231 INC HL
61232 JR PrintMessage
PrintMessage_Repeat 61234 LD A,(HL) Load the repeat count from the script.
61235 LD B,A
PrintMessage_Repeat_Loop 61236 CALL ClipAndPrintCharacter Print the current character that many times.
61239 DJNZ PrintMessage_Repeat_Loop
61241 INC HL Advance the script and continue.
61242 JR PrintMessage
PrintMessage_FillBox 61244 LD B,(HL) Set the fill character to a space and load the row count.
61245 LD A,32
61247 LD (23545),A
61250 INC HL
61251 LD A,(HL) Store the fill attribute and start row from the script.
61252 LD (23541),A
61255 INC HL
61256 LD A,(HL)
61257 LD (23544),A
PrintMessage_FillBox_Row 61260 PUSH BC Begin a row of 20 spaces from column 6.
61261 LD B,20
61263 LD A,6
61265 LD (23543),A
PrintMessage_FillBox_Column 61268 CALL ClipAndPrintCharacter Print one row of spaces.
61271 DJNZ PrintMessage_FillBox_Column
61273 LD A,(23544) Advance the print row and loop until the box is filled.
61276 INC A
61277 LD (23544),A
61280 POP BC
61281 DJNZ PrintMessage_FillBox_Row
61283 INC HL Advance the script and continue.
61284 JP PrintMessage
PrintMessage_NewLine 61287 LD A,(23296) Restore the column from the left-margin copy at PrintLeftMarginColumn.
61290 LD (23543),A
PrintMessage_AdvanceRow 61293 LD A,(23544) Advance the print row.
61296 INC A
61297 LD (23544),A
61300 JP PrintMessage Jump to PrintMessage.
PrintMessage_AddColumn 61303 LD B,(HL) Add the next script byte to the left-margin column.
61304 LD A,(23296)
61307 ADD A,B
61308 LD (23543),A
61311 INC HL
61312 JR PrintMessage_AdvanceRow Jump to PrintMessage_AdvanceRow to advance the row.
Prev: 61159 Up: Map Next: 61314