2 ; Ullrich von Bassewitz, 2009-11-02
4 ; void __fastcall__ tgi_vectorchar (const unsigned char* Ops);
5 ; /* Draw one character of the vector font at the current graphics cursor
6 ; ** position using the current font magnification.
10 .import imul16x16r32, umul16x16r32, negax, negeax
12 .include "tgi-kernel.inc"
13 .include "tgi-vectorfont.inc"
14 .include "zeropage.inc"
18 ;----------------------------------------------------------------------------
30 ;----------------------------------------------------------------------------
31 ; Get the next operation from the Ops pointer, remove the flag bit and sign
32 ; extend the 8 bit value to 16 bits.
45 ; Move bit 7 into Flag, then sign extend the value in A and extend the sign
48 : asl a ; Flag into carry
51 cmp #$80 ; Sign bit into carry
52 ror a ; Sign extend the value
54 dex ; Value is negative
63 ;----------------------------------------------------------------------------
64 ; Get and process one coordinate value. The scale factor is passed in a/x
73 ; Save scale factor as left operand for multiplication
78 ; Load next operation value.
82 ; Multiplicate with the scale factor.
84 jmp tgi_imulround ; Multiplicate, round and scale
86 ;----------------------------------------------------------------------------
87 ; Add the base coordinate with offset in Y to the value in A/X
103 ;----------------------------------------------------------------------------
104 ; Subtract the value in a/x from the base coordinate with offset in Y
107 ; ax = _tgi_cur[xy] - ax
109 ; which can be transformed to
111 ; ax = _tgi_cur[xy] + (~ax + 1);
130 ;----------------------------------------------------------------------------
134 .proc _tgi_vectorchar
136 ; Multiplicate the char value by two and save into Y
141 ; Since we will call tgi_lineto, which uses the zero page, and we do also
142 ; need the zero page, make room in the register bank.
151 ; Calculate a pointer to the vector ops for the given char (now in Y). We
152 ; definitely expect a font here, that has to be checked by the caller.
156 adc #<(TGI_VECTORFONT::CHARS - 2*TGI_VF_FIRSTCHAR)
158 lda _tgi_vectorfont+1
159 adc #>(TGI_VECTORFONT::CHARS - 2*TGI_VF_FIRSTCHAR)
170 ; Main loop executing vector operations
172 Loop: lda _tgi_textscalew+0
173 ldx _tgi_textscalew+1
174 jsr GetProcessedCoord ; Get X vector
176 ; Depending on the text direction, the X vector is either applied to X as
178 ; X2 = _tgi_curx + XMag * XDelta
182 ; Y2 = _tgi_cury - XMag * XDelta
184 ; which can be transformed to
186 ; Y2 = _tgi_cury + (~(XMag * XDelta) + 1);
189 ; For the Y component we have
191 ; Y2 = _tgi_cury - YMag * YDelta
193 ; which can be transformed to
195 ; Y2 = _tgi_cury + (~(YMag * YDelta) + 1);
199 ; X2 = _tgi_curx - YMag * YDelta
201 ; which can be transformed to
203 ; X2 = _tgi_curx + (~(YMag * YDelta) + 1);
206 ldy _tgi_textdir ; Horizontal or vertical text?
207 bne @Vertical ; Jump if vertical
209 ; Process horizontal text
218 jsr GetProcessedYCoord
228 ; Process vertical text
238 jsr GetProcessedYCoord
247 ; Draw, then move - or just move
251 bpl @Move ; Jump if move only
254 ldy #7 ; Copy start coords into zp
260 jsr tgi_line ; Call the driver
262 ldy #7 ; Copy start coords
268 jsr tgi_clippedline ; Call line clipper
271 ; Move the start position
284 ; Done. Restore zp and return.