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 Character set. Subtracting 256 makes the character code times 8 land on its glyph.
PlotGlyph 25731 LD DE,(23431) Keep the screen address. The font is the ROM character set minus 256.
25735 LD BC,15360
25738 LD H,0 Character A, widened.
25740 LD L,A
25741 ADD HL,HL Times eight, plus the font base.
25742 ADD HL,HL
25743 ADD HL,HL
25744 ADD HL,BC
25745 PUSH DE The screen address and the glyph address are restored after the copy.
25746 PUSH HL
25747 LD DE,27427 The eight glyph bytes are copied into GlyphBuffer. C starts clear.
25750 LD BC,2048
PlotGlyph_Copy 25753 LD A,(HL) Copy one byte of the glyph.
25754 LD (DE),A
25755 INC HL
25756 INC DE
25757 BIT 1,A Bit 1 of a byte marks a descender.
25759 JR Z,PlotGlyph_Copied
25761 LD C,255
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 Eight glyph bytes are shifted in GlyphBuffer.
25768 LD B,8
PlotGlyph_Row 25770 LD A,(DE) A source bit carried out sets the top bit.
25771 RLA
25772 JR NC,PlotGlyph_Nibble
25774 OR 128
PlotGlyph_Nibble 25776 BIT 0,C The descender marker shifts the glyph one place further.
25778 JR Z,PlotGlyph_Mask
25780 LD H,A Split the byte into nibbles.
25781 AND 15
25783 LD L,A
25784 LD A,H The low nibble moves into the neighbouring byte.
25785 AND 240
25787 RL L
25789 OR L
PlotGlyph_Mask 25790 AND 252 Store the aligned byte and do the next row.
25792 LD (DE),A
25793 INC DE
25794 DJNZ PlotGlyph_Row
25796 POP HL Restore the glyph address and the screen address from the stack.
25797 POP DE
25798 LD HL,27427 Point DE at the buffer and HL at the screen byte.
25801 EX DE,HL
25802 PUSH HL
The column within the byte chooses how the shifted glyph is merged with the pixels already there.
PlotGlyph_Column 25803 LD A,(23434) The column within the byte is 0, 1, 2 or 3.
25806 AND 3
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.
PlotGlyph_Byte0 25819 LD A,(DE) Copy one glyph byte and step to the next pixel row.
25820 LD (HL),A
25821 INC DE
25822 INC H
25823 DJNZ PlotGlyph_Byte0 All eight bytes.
PlotGlyph_Stored 25825 POP HL The print address moves on one byte.
25826 INC HL
25827 LD (23431),HL
25830 JR PlotGlyph_Advance Join PlotGlyph_Advance to advance the column.
PlotGlyph_Byte1 25832 LD B,8 Eight pixel rows.
PlotGlyph_Shift2 25834 LD A,(DE) Take the glyph byte and the previous screen byte.
25835 DEC HL
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 Join the shared advance at PlotGlyph_Stored.
PlotGlyph_Byte2 25856 LD B,8 Eight pixel rows.
PlotGlyph_Shift4 25858 LD A,(DE) Take one glyph byte and the previous screen byte.
25859 DEC HL
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 This column restores the screen address itself and advances.
25891 JR PlotGlyph_Advance
PlotGlyph_Byte3 25893 LD B,8 Eight pixel rows.
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) Shift the glyph right by two.
25900 SRL A
25902 SRL A
25904 OR (HL) OR it into the screen byte.
25905 LD (HL),A
25906 INC H The next pixel row, then the shared advance.
25907 INC DE
25908 DJNZ PlotGlyph_Top
25910 JR 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 and read the column.
25913 PUSH AF
25914 LD A,(23434)
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.
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