Prev: 25596 Up: Map Next: 25931
25731: 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 256 makes the character code times 8 land on its glyph.
PlotGlyph 25731 LD DE,(23431) Keep the screen address.
25735 LD BC,15360 The font is CHARSET minus 256.
25738 LD H,0 Character A, widened.
25740 LD L,A
25741 ADD HL,HL Times eight.
25742 ADD HL,HL
25743 ADD HL,HL
25744 ADD HL,BC Add the font base.
25745 PUSH DE Stash the screen address and the glyph address on the stack.
25746 PUSH HL
25747 LD DE,27427 Point DE at GlyphBuffer.
25750 LD BC,2048 Eight bytes, with C clear.
Copy the glyph into the buffer.
PlotGlyph_Copy 25753 LD A,(HL) Copy one byte of the glyph.
25754 LD (DE),A
25755 INC HL Step both pointers.
25756 INC DE
25757 BIT 1,A Jump to PlotGlyph_Copied if bit 1 is clear.
25759 JR Z,PlotGlyph_Copied
25761 LD C,255 Mark a descender.
The next glyph byte.
PlotGlyph_Copied 25763 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 25765 LD DE,27427 Point DE at GlyphBuffer.
25768 LD B,8 Eight glyph bytes.
Shift one glyph row.
PlotGlyph_Row 25770 LD A,(DE) Fetch the glyph byte.
25771 RLA Rotate it left.
25772 JR NC,PlotGlyph_Nibble Jump to PlotGlyph_Nibble if there is no carry.
25774 OR %10000000 Set bit 7.
Merge the shifted nibbles.
PlotGlyph_Nibble 25776 BIT 0,C The descender marker shifts the glyph one place further.
25778 JR Z,PlotGlyph_Mask
25780 LD H,A Copy the byte.
25781 AND %00001111 Keep only bits 0-3.
25783 LD L,A Store the low nibble.
25784 LD A,H Fetch the saved byte.
25785 AND %11110000 Keep only bits 4-7.
25787 RL L Merge in the shifted low nibble.
25789 OR L
Store the aligned byte.
PlotGlyph_Mask 25790 AND %11111100 Keep only bits 2-7.
25792 LD (DE),A Store the aligned byte.
25793 INC DE Step on.
25794 DJNZ PlotGlyph_Row Jump to PlotGlyph_Row until eight rows are done.
25796 POP HL Restore the glyph address and the screen address from the stack.
25797 POP DE
25798 LD HL,27427 Point HL at GlyphBuffer.
25801 EX DE,HL Swap the buffer into DE.
25802 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 25803 LD A,(23434) Fetch PrintColumn.
25806 AND %00000011 Keep only bits 0-1.
25808 DEC A Column 1 uses the two-pixel shift.
25809 JR Z,PlotGlyph_Byte1
25811 DEC A Column 2 uses the four-pixel shift.
25812 JR Z,PlotGlyph_Byte2
25814 DEC A Column 3 keeps the top two pixels.
25815 JR Z,PlotGlyph_Byte3
25817 LD B,8 Column 0 copies eight fresh bytes.
Copy eight unshifted bytes.
PlotGlyph_Byte0 25819 LD A,(DE) Copy one glyph byte.
25820 LD (HL),A
25821 INC DE Step to the next pixel row.
25822 INC H
25823 DJNZ PlotGlyph_Byte0 All eight bytes.
Advance the print address.
PlotGlyph_Stored 25825 POP HL Restore the screen address from the stack.
25826 INC HL Move the print address on one byte.
25827 LD (23431),HL
25830 JR PlotGlyph_Advance Jump to PlotGlyph_Advance to advance the column.
Shift two pixels.
PlotGlyph_Byte1 25832 LD B,8 Count the 8 pixel rows of this glyph.
Merge a two-pixel shift.
PlotGlyph_Shift2 25834 LD A,(DE) Fetch the glyph byte.
25835 DEC HL Step back to the previous screen byte.
25836 SRL (HL) Make room for two pixels.
25838 SRL (HL)
25840 SLA A Shift two pixels of the glyph in.
25842 RL (HL)
25844 SLA A
25846 RL (HL)
25848 INC HL Store the shifted byte.
25849 LD (HL),A
25850 INC H The next pixel row.
25851 INC DE
25852 DJNZ PlotGlyph_Shift2 All eight.
25854 JR PlotGlyph_Stored Jump to PlotGlyph_Stored.
Shift four pixels.
PlotGlyph_Byte2 25856 LD B,8 Count the 8 pixel rows of this glyph.
Merge a four-pixel shift.
PlotGlyph_Shift4 25858 LD A,(DE) Fetch the glyph byte.
25859 DEC HL Step back to the previous screen byte.
25860 SRL (HL) Make room for four pixels.
25862 SRL (HL)
25864 SRL (HL)
25866 SRL (HL)
25868 SLA A Shift the first two pixels in.
25870 RL (HL)
25872 SLA A
25874 RL (HL)
25876 SLA A Shift the other two pixels in.
25878 RL (HL)
25880 SLA A
25882 RL (HL)
25884 INC HL Store the shifted byte on this pixel row.
25885 LD (HL),A
25886 INC H The next pixel row.
25887 INC DE
25888 DJNZ PlotGlyph_Shift4 All eight.
25890 POP HL Restore the screen address from the stack.
25891 JR PlotGlyph_Advance Jump to PlotGlyph_Advance.
Keep the top two pixels.
PlotGlyph_Byte3 25893 LD B,8 Count the 8 pixel rows of this glyph.
Merge a six-pixel shift.
PlotGlyph_Top 25895 LD A,192 Keep the top two pixels already on screen.
25897 AND (HL)
25898 LD (HL),A
25899 LD A,(DE) Fetch the glyph byte.
25900 SRL A Shift it right by two.
25902 SRL A
25904 OR (HL) Merge the shifted glyph into the screen byte with OR.
25905 LD (HL),A
25906 INC H Step both pointers.
25907 INC DE
25908 DJNZ PlotGlyph_Top Jump to PlotGlyph_Top until eight pixel rows are done.
25910 JR PlotGlyph_Stored Jump to PlotGlyph_Stored.
The next character moves one column right. Column 41 is the margin, so the cursor wraps.
PlotGlyph_Advance 25912 POP AF Keep the character on the stack.
25913 PUSH AF
25914 LD A,(23434) Fetch PrintColumn.
25917 CP 41 Column 41 wraps to the next row.
25919 JP Z,PlotCharacter_Newline
25922 INC A Otherwise the cursor moves one column right.
25923 LD (23434),A
This entry point is used by the routine at PlotCharacter.
Restore the registers.
PlotGlyph_Done 25926 POP AF Restore the registers saved around the glyph from the stack.
25927 POP DE
25928 POP BC
25929 POP HL
25930 RET Return.
Prev: 25596 Up: Map Next: 25931