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 .export _tgi_vectorchar
12 .import imul16x16r32, umul16x16r32, negax, negeax
14 .include "tgi-kernel.inc"
15 .include "zeropage.inc"
18 ;----------------------------------------------------------------------------
32 ;----------------------------------------------------------------------------
38 ; Since we will call tgi_lineto, which uses the zero page, and we do also
39 ; need the zero page, make room in the register bank.
54 ; Main loop executing vector operations
56 Loop: lda _tgi_textscalew+0
60 ; X2 = tgi_curx + XMag * XDelta.
75 ; Y2 = tgi_cury - YMag * YDelta;
76 ; Y2 = tgi_cury + (~(YMag * YDelta) + 1);
87 ; Draw, then move - or just move
90 bpl @Move ; Jump if move only
92 ldy #7 ; Copy start coords into zp
98 jsr tgi_line ; Call the driver
100 ; Move the start position
113 ; Done. Restore zp and return.
125 ;----------------------------------------------------------------------------
126 ; Get and process one coordinate value. The scale factor is passed in a/x
128 .proc GetProcessedCoord
130 ; Save scale factor as left operand for multiplication
143 ; Move bit 7 into Flag
145 : asl a ; Flag into carry
148 ; Since we know that the scale factor is always positive, we will remember
149 ; the sign of the coordinate offset, make it positive, do an unsigned mul
150 ; and negate the result if the vector was negative. This is faster than
151 ; relying on the signed multiplication, which will do the same, but for
154 sta tmp1 ; Remember sign of vector offset
155 cmp #$80 ; Sign bit into carry
156 ror a ; Sign extend the value
161 : ldx #$00 ; High byte is always zero
163 ; Multiplicate with the scale factor.
165 jsr umul16x16r32 ; Multiplicate
167 ; The result is a 16.8 fixed point value. Round it.
169 cmp #$80 ; frac(val) >= 0.5?
177 bit tmp1 ; Check sign
179 jmp negax ; Negate result if necessary