![]() |
Routines |
| Prev: EA60 | Up: Map | Next: EB3E |
|
Plots one character glyph into the display file. Callers set up PrintState first.
|
||||
| PrintCharacter | EA8D | PUSH AF | Stash the flags, counters, screen pointer and glyph pointer on the stack. | |
| EA8E | PUSH BC | |||
| EA8F | PUSH DE | |||
| EA90 | PUSH HL | |||
| EA91 | LD A,($5BF6) | Fetch *PrintState_Flags and test bit 2. | ||
| EA94 | BIT 2,A | |||
| EA96 | LD A,$AE | Prefer AE (XOR) unless bit 2 was set. | ||
| EA98 | JR Z,PrintCharacter_SetPlotOpcode | |||
| EA9A | LD A,$B6 | A=B6 (OR). | ||
| PrintCharacter_SetPlotOpcode | EA9C | LD ($EAF1),A | Patch that opcode into PrintCharacter_PlotOpcode. | |
|
Point HL at the 8-byte glyph. Codes below 8F use CHARS; 90 and above were meant to index UDG, but the unconditional jump at PrintCharacter_ForceChars always takes the CHARS path.
|
||||
| EA9F | LD A,($5BF9) | Fetch *PrintState_Character and compare it with 8F. | ||
| EAA2 | CP $8F | |||
| PrintCharacter_ForceChars | EAA4 | JR PrintCharacter_CharsGlyph | Always take the CHARS path at PrintCharacter_CharsGlyph. | |
|
Unreachable UDG path (left in the binary after PrintCharacter_ForceChars).
|
||||
| EAA6 | JR C,PrintCharacter_CharsGlyph | Scale the UDG index and point HL at UDG. | ||
| EAA8 | SUB $90 | |||
| EAAA | ADD A,A | |||
| EAAB | ADD A,A | |||
| EAAC | ADD A,A | |||
| EAAD | LD E,A | |||
| EAAE | LD D,$00 | |||
| EAB0 | LD HL,($5C7B) | |||
| EAB3 | ADD HL,DE | |||
| EAB4 | JR PrintCharacter_ScreenAddress | Jump to PrintCharacter_ScreenAddress. | ||
| PrintCharacter_CharsGlyph | EAB6 | LD DE,($5C36) | Point HL at glyph *PrintState_Character in CHARS. | |
| EABA | LD L,A | |||
| EABB | LD H,$00 | |||
| EABD | ADD HL,HL | |||
| EABE | ADD HL,HL | |||
| EABF | ADD HL,HL | |||
| EAC0 | ADD HL,DE | |||
|
Convert row/column at PrintState_Column into a display-file address in DE.
|
||||
| PrintCharacter_ScreenAddress | EAC1 | LD DE,$4000 | DE=4000. | |
| EAC4 | LD BC,($5BF7) | BC=*PrintState_Column. | ||
| EAC8 | LD A,C | Jump to PrintCharacter_Exit if the column is out of range. | ||
| EAC9 | CP $20 | |||
| EACB | JR NC,PrintCharacter_Exit | |||
| EACD | LD A,B | Jump to PrintCharacter_Exit if the row is out of range. | ||
| EACE | CP $18 | |||
| EAD0 | JR NC,PrintCharacter_Exit | |||
| PrintCharacter_RowThirds | EAD2 | CP $08 | Jump to PrintCharacter_ColumnOffset if this row is already in the current third. | |
| EAD4 | JR C,PrintCharacter_ColumnOffset | |||
| EAD6 | SUB $08 | Move D down one screen third and try again. | ||
| EAD8 | PUSH AF | |||
| EAD9 | LD A,D | |||
| EADA | ADD A,$08 | |||
| EADC | LD D,A | |||
| EADD | POP AF | |||
| EADE | JR PrintCharacter_RowThirds | |||
| PrintCharacter_ColumnOffset | EAE0 | ADD A,A | Fold the row remainder and column into E. | |
| EAE1 | ADD A,A | |||
| EAE2 | ADD A,A | |||
| EAE3 | ADD A,A | |||
| EAE4 | ADD A,A | |||
| EAE5 | ADD A,C | |||
| EAE6 | LD E,A | |||
|
Copy or XOR the 8 glyph rows into the display file.
|
||||
| EAE7 | LD A,($5BF6) | Jump to PrintCharacter_CopyLoop if bit 0 of *PrintState_Flags clears XOR mode. | ||
| EAEA | AND $01 | |||
| EAEC | JR Z,PrintCharacter_CopyLoop | |||
| EAEE | LD B,$08 | B=08. | ||
| PrintCharacter_XorLoop | EAF0 | LD A,(DE) | Plot one glyph row with the patched XOR/OR at PrintCharacter_PlotOpcode and move down a pixel line. | |
| PrintCharacter_PlotOpcode | EAF1 | XOR (HL) | ||
| EAF2 | LD (DE),A | |||
| EAF3 | INC HL | |||
| EAF4 | INC D | |||
| EAF5 | DJNZ PrintCharacter_XorLoop | |||
| EAF7 | JR PrintCharacter_Attributes | Jump to PrintCharacter_Attributes. | ||
| PrintCharacter_CopyLoop | EAF9 | LD B,$08 | B=08. | |
| PrintCharacter_CopyLoop_Body | EAFB | LD A,(HL) | Copy one glyph row into the display file and move down a pixel line. | |
| EAFC | LD (DE),A | |||
| EAFD | INC HL | |||
| EAFE | INC D | |||
| EAFF | 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 | EB01 | LD A,($5BF6) | Jump to PrintCharacter_AdvanceCursor if bit 1 of *PrintState_Flags skips attributes. | |
| EB04 | AND $02 | |||
| EB06 | JR NZ,PrintCharacter_AdvanceCursor | |||
| EB08 | LD A,($5BF5) | Point HL at the attribute-file cell for *PrintState_Column. | ||
| EB0B | LD C,A | |||
| EB0C | LD DE,($5BF7) | |||
| EB10 | LD H,$58 | |||
| EB12 | LD A,D | |||
| PrintCharacter_AttrRow | EB13 | SUB $08 | Jump to PrintCharacter_AttrNextThird if another attribute third remains. | |
| EB15 | JR NC,PrintCharacter_AttrNextThird | |||
| EB17 | JR PrintCharacter_AttrColumn | Jump to PrintCharacter_AttrColumn. | ||
| PrintCharacter_AttrNextThird | EB19 | INC H | Step H to the next attribute third and retry. | |
| EB1A | JR PrintCharacter_AttrRow | |||
| PrintCharacter_AttrColumn | EB1C | ADD A,$08 | Restore the row remainder and load the column. | |
| EB1E | LD B,A | |||
| EB1F | LD A,E | |||
| EB20 | JR Z,PrintCharacter_WriteAttr | |||
| PrintCharacter_0 | EB22 | ADD A,$20 | Add 20 per remaining row to reach the cell. | |
| EB24 | DJNZ PrintCharacter_0 | |||
| PrintCharacter_WriteAttr | EB26 | LD L,A | Write *PrintState into that attribute-file cell. | |
| EB27 | LD (HL),C | |||
|
Advance the cursor: move to the next column, or wrap to the next row.
|
||||
| PrintCharacter_AdvanceCursor | EB28 | LD DE,($5BF7) | Advance the column; jump to PrintCharacter_StoreCursor if still on this row. | |
| EB2C | INC E | |||
| EB2D | LD A,E | |||
| EB2E | CP $20 | |||
| EB30 | JR NZ,PrintCharacter_StoreCursor | |||
| EB32 | LD E,$00 | Wrap to column 00 on the next row. | ||
| EB34 | INC D | |||
| PrintCharacter_StoreCursor | EB35 | LD ($5BF7),DE | Store the updated cursor back in *PrintState_Column. | |
| PrintCharacter_Exit | EB39 | POP HL | Restore the glyph pointer, screen pointer, counters and flags from the stack. | |
| EB3A | POP DE | |||
| EB3B | POP BC | |||
| EB3C | POP AF | |||
| EB3D | RET | Return. | ||
| Prev: EA60 | Up: Map | Next: EB3E |
XOR (HL)) or B6 (OR (HL)) from bit 2 of the flags.