Prev: EEE7 Up: Map Next: EF82
EEF1: 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 20 are control codes:
Code Action
00-17 Set row, then column (also PrintLeftMarginColumn)
18 Set attribute at PrintState
19 Set flags at PrintState_Flags
1A End of script (return)
1B Repeat current character
1C Fill a box of spaces
1D New line from PrintLeftMarginColumn
1E Add to column; advance row
1F Call sub-script via CallSubMessage
Dispatch the next script byte to a control handler, or print it as a literal character.
PrintMessage EEF1 LD A,(HL) Fetch the next script byte.
EEF2 INC HL
Codes 00-17 set the print row and column.
EEF3 CP $18 Jump to PrintMessage_SetPosition if A is less than 18.
EEF5 JR C,PrintMessage_SetPosition
Code 18 sets the print attribute.
EEF7 JR Z,PrintMessage_SetAttribute Jump to PrintMessage_SetAttribute if A is 18.
Code 1A ends the script.
EEF9 CP $1A Compare A with 1A.
EEFB RET Z Return if this is the end-of-script code.
Code 19 sets the print flags.
EEFC JR C,PrintMessage_SetFlags Jump to PrintMessage_SetFlags if A is less than 1A.
Code 1B repeats the current character.
EEFE CP $1C Jump to PrintMessage_Repeat if A is less than 1C.
EF00 JR C,PrintMessage_Repeat
Code 1C fills a box of spaces.
EF02 JR Z,PrintMessage_FillBox Jump to PrintMessage_FillBox if A is 1C.
Code 1D starts a new line from the left margin.
EF04 CP $1E Jump to PrintMessage_NewLine if A is less than 1E.
EF06 JR C,PrintMessage_NewLine
Code 1E adds to the column, then advances the row.
EF08 JR Z,PrintMessage_AddColumn Jump to PrintMessage_AddColumn if A is 1E.
Code 1F calls a location-art sub-script.
EF0A CP $1F Jump to CallSubMessage if A is 1F.
EF0C JP Z,CallSubMessage
Literal character: store it and print via ClipAndPrintCharacter.
EF0F LD ($5BF9),A Store the character in *PrintState_Character and print it.
EF12 CALL ClipAndPrintCharacter
EF15 JR PrintMessage Jump to PrintMessage.
PrintMessage_SetPosition EF17 LD ($5BF8),A Store the new row and column in the print state.
EF1A LD A,(HL)
EF1B LD ($5BF7),A
EF1E LD ($5B00),A Remember the left margin at PrintLeftMarginColumn and continue.
EF21 INC HL
EF22 JR PrintMessage
PrintMessage_SetAttribute EF24 LD A,(HL) Store the next script byte as the print attribute.
EF25 LD ($5BF5),A
EF28 INC HL
EF29 JR PrintMessage
PrintMessage_SetFlags EF2B LD A,(HL) Store the next script byte as the print flags.
EF2C LD ($5BF6),A
EF2F INC HL
EF30 JR PrintMessage
PrintMessage_Repeat EF32 LD A,(HL) Load the repeat count from the script.
EF33 LD B,A
PrintMessage_Repeat_Loop EF34 CALL ClipAndPrintCharacter Print the current character that many times.
EF37 DJNZ PrintMessage_Repeat_Loop
EF39 INC HL Advance the script and continue.
EF3A JR PrintMessage
PrintMessage_FillBox EF3C LD B,(HL) Set the fill character to a space and load the row count.
EF3D LD A,$20
EF3F LD ($5BF9),A
EF42 INC HL
EF43 LD A,(HL) Store the fill attribute and start row from the script.
EF44 LD ($5BF5),A
EF47 INC HL
EF48 LD A,(HL)
EF49 LD ($5BF8),A
PrintMessage_FillBox_Row EF4C PUSH BC Begin a row of 14 spaces from column 06.
EF4D LD B,$14
EF4F LD A,$06
EF51 LD ($5BF7),A
PrintMessage_FillBox_Column EF54 CALL ClipAndPrintCharacter Print one row of spaces.
EF57 DJNZ PrintMessage_FillBox_Column
EF59 LD A,($5BF8) Advance the print row and loop until the box is filled.
EF5C INC A
EF5D LD ($5BF8),A
EF60 POP BC
EF61 DJNZ PrintMessage_FillBox_Row
EF63 INC HL Advance the script and continue.
EF64 JP PrintMessage
PrintMessage_NewLine EF67 LD A,($5B00) Restore the column from the left-margin copy at PrintLeftMarginColumn.
EF6A LD ($5BF7),A
PrintMessage_AdvanceRow EF6D LD A,($5BF8) Advance the print row.
EF70 INC A
EF71 LD ($5BF8),A
EF74 JP PrintMessage Jump to PrintMessage.
PrintMessage_AddColumn EF77 LD B,(HL) Add the next script byte to the left-margin column.
EF78 LD A,($5B00)
EF7B ADD A,B
EF7C LD ($5BF7),A
EF7F INC HL
EF80 JR PrintMessage_AdvanceRow Jump to PrintMessage_AdvanceRow to advance the row.
Prev: EEE7 Up: Map Next: EF82