Prev: 60000 Up: Map Next: 60222
60045: Print Character
Plots one character glyph into the display file. Callers set up PrintState first.
PrintCharacter 60045 PUSH AF Stash the flags, counters, screen pointer and glyph pointer on the stack.
60046 PUSH BC
60047 PUSH DE
60048 PUSH HL
Pick the plot opcode written into PrintCharacter_PlotOpcode: 174 (XOR (HL)) or 182 (OR (HL)) from bit 2 of the flags.
60049 LD A,(23542) Fetch *PrintState_Flags and test bit 2.
60052 BIT 2,A
60054 LD A,174 Prefer 174 (XOR) unless bit 2 was set.
60056 JR Z,PrintCharacter_SetPlotOpcode
60058 LD A,182 A=182 (OR).
PrintCharacter_SetPlotOpcode 60060 LD (60145),A Patch that opcode into PrintCharacter_PlotOpcode.
Point HL at the 8-byte glyph. Codes below 143 use CHARS; 144 and above were meant to index UDG, but the unconditional jump at PrintCharacter_ForceChars always takes the CHARS path.
60063 LD A,(23545) Fetch *PrintState_Character and compare it with 143.
60066 CP 143
PrintCharacter_ForceChars 60068 JR PrintCharacter_CharsGlyph Always take the CHARS path at PrintCharacter_CharsGlyph.
Unreachable UDG path (left in the binary after PrintCharacter_ForceChars).
60070 JR C,PrintCharacter_CharsGlyph Scale the UDG index and point HL at UDG.
60072 SUB 144
60074 ADD A,A
60075 ADD A,A
60076 ADD A,A
60077 LD E,A
60078 LD D,0
60080 LD HL,(23675)
60083 ADD HL,DE
60084 JR PrintCharacter_ScreenAddress Jump to PrintCharacter_ScreenAddress.
PrintCharacter_CharsGlyph 60086 LD DE,(23606) Point HL at glyph *PrintState_Character in CHARS.
60090 LD L,A
60091 LD H,0
60093 ADD HL,HL
60094 ADD HL,HL
60095 ADD HL,HL
60096 ADD HL,DE
Convert row/column at PrintState_Column into a display-file address in DE.
PrintCharacter_ScreenAddress 60097 LD DE,16384 DE=16384.
60100 LD BC,(23543) BC=*PrintState_Column.
60104 LD A,C Jump to PrintCharacter_Exit if the column is out of range.
60105 CP 32
60107 JR NC,PrintCharacter_Exit
60109 LD A,B Jump to PrintCharacter_Exit if the row is out of range.
60110 CP 24
60112 JR NC,PrintCharacter_Exit
PrintCharacter_RowThirds 60114 CP 8 Jump to PrintCharacter_ColumnOffset if this row is already in the current third.
60116 JR C,PrintCharacter_ColumnOffset
60118 SUB 8 Move D down one screen third and try again.
60120 PUSH AF
60121 LD A,D
60122 ADD A,8
60124 LD D,A
60125 POP AF
60126 JR PrintCharacter_RowThirds
PrintCharacter_ColumnOffset 60128 ADD A,A Fold the row remainder and column into E.
60129 ADD A,A
60130 ADD A,A
60131 ADD A,A
60132 ADD A,A
60133 ADD A,C
60134 LD E,A
Copy or XOR the 8 glyph rows into the display file.
60135 LD A,(23542) Jump to PrintCharacter_CopyLoop if bit 0 of *PrintState_Flags clears XOR mode.
60138 AND 1
60140 JR Z,PrintCharacter_CopyLoop
60142 LD B,8 B=8.
PrintCharacter_XorLoop 60144 LD A,(DE) Plot one glyph row with the patched XOR/OR at PrintCharacter_PlotOpcode and move down a pixel line.
PrintCharacter_PlotOpcode 60145 XOR (HL)
60146 LD (DE),A
60147 INC HL
60148 INC D
60149 DJNZ PrintCharacter_XorLoop
60151 JR PrintCharacter_Attributes Jump to PrintCharacter_Attributes.
PrintCharacter_CopyLoop 60153 LD B,8 B=8.
PrintCharacter_CopyLoop_Body 60155 LD A,(HL) Copy one glyph row into the display file and move down a pixel line.
60156 LD (DE),A
60157 INC HL
60158 INC D
60159 DJNZ PrintCharacter_CopyLoop_Body
Unless bit 1 of the flags is set, write the attribute from PrintState into the matching attribute-file cell.
PrintCharacter_Attributes 60161 LD A,(23542) Jump to PrintCharacter_AdvanceCursor if bit 1 of *PrintState_Flags skips attributes.
60164 AND 2
60166 JR NZ,PrintCharacter_AdvanceCursor
60168 LD A,(23541) Point HL at the attribute-file cell for *PrintState_Column.
60171 LD C,A
60172 LD DE,(23543)
60176 LD H,88
60178 LD A,D
PrintCharacter_AttrRow 60179 SUB 8 Jump to PrintCharacter_AttrNextThird if another attribute third remains.
60181 JR NC,PrintCharacter_AttrNextThird
60183 JR PrintCharacter_AttrColumn Jump to PrintCharacter_AttrColumn.
PrintCharacter_AttrNextThird 60185 INC H Step H to the next attribute third and retry.
60186 JR PrintCharacter_AttrRow
PrintCharacter_AttrColumn 60188 ADD A,8 Restore the row remainder and load the column.
60190 LD B,A
60191 LD A,E
60192 JR Z,PrintCharacter_WriteAttr
PrintCharacter_0 60194 ADD A,32 Add 32 per remaining row to reach the cell.
60196 DJNZ PrintCharacter_0
PrintCharacter_WriteAttr 60198 LD L,A Write *PrintState into that attribute-file cell.
60199 LD (HL),C
Advance the cursor: move to the next column, or wrap to the next row.
PrintCharacter_AdvanceCursor 60200 LD DE,(23543) Advance the column; jump to PrintCharacter_StoreCursor if still on this row.
60204 INC E
60205 LD A,E
60206 CP 32
60208 JR NZ,PrintCharacter_StoreCursor
60210 LD E,0 Wrap to column 0 on the next row.
60212 INC D
PrintCharacter_StoreCursor 60213 LD (23543),DE Store the updated cursor back in *PrintState_Column.
PrintCharacter_Exit 60217 POP HL Restore the glyph pointer, screen pointer, counters and flags from the stack.
60218 POP DE
60219 POP BC
60220 POP AF
60221 RET Return.
Prev: 60000 Up: Map Next: 60222