Prev: 63FC Up: Map Next: 654B
6483: Plot Glyph
Used by the routine at PlotCharacter.
Draws character A at the print position, using the ROM font. The eight bytes are shifted into whichever pixel column the cursor occupies inside its display byte, then ORed into the screen.
The ROM character set lives at CHARSET. Subtracting 0100 makes the character code times 8 land on its glyph.
PlotGlyph 6483 LD DE,($5B87) Keep the screen address.
6487 LD BC,$3C00 The font is CHARSET minus 0100.
648A LD H,$00 Character A, widened.
648C LD L,A
648D ADD HL,HL Times eight.
648E ADD HL,HL
648F ADD HL,HL
6490 ADD HL,BC Add the font base.
6491 PUSH DE Stash the screen address and the glyph address on the stack.
6492 PUSH HL
6493 LD DE,$6B23 Point DE at GlyphBuffer.
6496 LD BC,$0800 Eight bytes, with C clear.
Copy the glyph into the buffer.
PlotGlyph_Copy 6499 LD A,(HL) Copy one byte of the glyph.
649A LD (DE),A
649B INC HL Step both pointers.
649C INC DE
649D BIT 1,A Jump to PlotGlyph_Copied if bit 1 is clear.
649F JR Z,PlotGlyph_Copied
64A1 LD C,$FF Mark a descender.
The next glyph byte.
PlotGlyph_Copied 64A3 DJNZ PlotGlyph_Copy The next byte.
Tip the glyph so it sits in the right-hand pixels of its byte. A descender in the source sets the marker in C.
PlotGlyph_Align 64A5 LD DE,$6B23 Point DE at GlyphBuffer.
64A8 LD B,$08 Eight glyph bytes.
Shift one glyph row.
PlotGlyph_Row 64AA LD A,(DE) Fetch the glyph byte.
64AB RLA Rotate it left.
64AC JR NC,PlotGlyph_Nibble Jump to PlotGlyph_Nibble if there is no carry.
64AE OR %10000000 Set bit 7.
Merge the shifted nibbles.
PlotGlyph_Nibble 64B0 BIT 0,C The descender marker shifts the glyph one place further.
64B2 JR Z,PlotGlyph_Mask
64B4 LD H,A Copy the byte.
64B5 AND %00001111 Keep only bits 0-3.
64B7 LD L,A Store the low nibble.
64B8 LD A,H Fetch the saved byte.
64B9 AND %11110000 Keep only bits 4-7.
64BB RL L Merge in the shifted low nibble.
64BD OR L
Store the aligned byte.
PlotGlyph_Mask 64BE AND %11111100 Keep only bits 2-7.
64C0 LD (DE),A Store the aligned byte.
64C1 INC DE Step on.
64C2 DJNZ PlotGlyph_Row Jump to PlotGlyph_Row until eight rows are done.
64C4 POP HL Restore the glyph address and the screen address from the stack.
64C5 POP DE
64C6 LD HL,$6B23 Point HL at GlyphBuffer.
64C9 EX DE,HL Swap the buffer into DE.
64CA PUSH HL Stash the screen address on the stack.
The column within the byte chooses how the shifted glyph is merged with the pixels already there.
PlotGlyph_Column 64CB LD A,($5B8A) Fetch PrintColumn.
64CE AND %00000011 Keep only bits 0-1.
64D0 DEC A Column 1 uses the two-pixel shift.
64D1 JR Z,PlotGlyph_Byte1
64D3 DEC A Column 2 uses the four-pixel shift.
64D4 JR Z,PlotGlyph_Byte2
64D6 DEC A Column 3 keeps the top two pixels.
64D7 JR Z,PlotGlyph_Byte3
64D9 LD B,$08 Column 0 copies eight fresh bytes.
Copy eight unshifted bytes.
PlotGlyph_Byte0 64DB LD A,(DE) Copy one glyph byte.
64DC LD (HL),A
64DD INC DE Step to the next pixel row.
64DE INC H
64DF DJNZ PlotGlyph_Byte0 All eight bytes.
Advance the print address.
PlotGlyph_Stored 64E1 POP HL Restore the screen address from the stack.
64E2 INC HL Move the print address on one byte.
64E3 LD ($5B87),HL
64E6 JR PlotGlyph_Advance Jump to PlotGlyph_Advance to advance the column.
Shift two pixels.
PlotGlyph_Byte1 64E8 LD B,$08 Count the 08 pixel rows of this glyph.
Merge a two-pixel shift.
PlotGlyph_Shift2 64EA LD A,(DE) Fetch the glyph byte.
64EB DEC HL Step back to the previous screen byte.
64EC SRL (HL) Make room for two pixels.
64EE SRL (HL)
64F0 SLA A Shift two pixels of the glyph in.
64F2 RL (HL)
64F4 SLA A
64F6 RL (HL)
64F8 INC HL Store the shifted byte.
64F9 LD (HL),A
64FA INC H The next pixel row.
64FB INC DE
64FC DJNZ PlotGlyph_Shift2 All eight.
64FE JR PlotGlyph_Stored Jump to PlotGlyph_Stored.
Shift four pixels.
PlotGlyph_Byte2 6500 LD B,$08 Count the 08 pixel rows of this glyph.
Merge a four-pixel shift.
PlotGlyph_Shift4 6502 LD A,(DE) Fetch the glyph byte.
6503 DEC HL Step back to the previous screen byte.
6504 SRL (HL) Make room for four pixels.
6506 SRL (HL)
6508 SRL (HL)
650A SRL (HL)
650C SLA A Shift the first two pixels in.
650E RL (HL)
6510 SLA A
6512 RL (HL)
6514 SLA A Shift the other two pixels in.
6516 RL (HL)
6518 SLA A
651A RL (HL)
651C INC HL Store the shifted byte on this pixel row.
651D LD (HL),A
651E INC H The next pixel row.
651F INC DE
6520 DJNZ PlotGlyph_Shift4 All eight.
6522 POP HL Restore the screen address from the stack.
6523 JR PlotGlyph_Advance Jump to PlotGlyph_Advance.
Keep the top two pixels.
PlotGlyph_Byte3 6525 LD B,$08 Count the 08 pixel rows of this glyph.
Merge a six-pixel shift.
PlotGlyph_Top 6527 LD A,$C0 Keep the top two pixels already on screen.
6529 AND (HL)
652A LD (HL),A
652B LD A,(DE) Fetch the glyph byte.
652C SRL A Shift it right by two.
652E SRL A
6530 OR (HL) Merge the shifted glyph into the screen byte with OR.
6531 LD (HL),A
6532 INC H Step both pointers.
6533 INC DE
6534 DJNZ PlotGlyph_Top Jump to PlotGlyph_Top until eight pixel rows are done.
6536 JR PlotGlyph_Stored Jump to PlotGlyph_Stored.
The next character moves one column right. Column 29 is the margin, so the cursor wraps.
PlotGlyph_Advance 6538 POP AF Keep the character on the stack.
6539 PUSH AF
653A LD A,($5B8A) Fetch PrintColumn.
653D CP $29 Column 29 wraps to the next row.
653F JP Z,PlotCharacter_Newline
6542 INC A Otherwise the cursor moves one column right.
6543 LD ($5B8A),A
This entry point is used by the routine at PlotCharacter.
Restore the registers.
PlotGlyph_Done 6546 POP AF Restore the registers saved around the glyph from the stack.
6547 POP DE
6548 POP BC
6549 POP HL
654A RET Return.
Prev: 63FC Up: Map Next: 654B