2009-11-02 22:29:49 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2009-11-02
|
|
|
|
;
|
|
|
|
; void __fastcall__ tgi_vectorchar (const unsigned char* Ops);
|
|
|
|
; /* Draw one character of the vector font at the current graphics cursor
|
|
|
|
; * position using the current font magnification.
|
|
|
|
; */
|
|
|
|
;
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
.import imul16x16r32, umul16x16r32, negax, negeax
|
2009-11-02 22:29:49 +00:00
|
|
|
|
|
|
|
.include "tgi-kernel.inc"
|
2009-11-06 16:18:13 +00:00
|
|
|
.include "tgi-vectorfont.inc"
|
2009-11-02 22:29:49 +00:00
|
|
|
.include "zeropage.inc"
|
2009-11-10 18:50:33 +00:00
|
|
|
|
2009-11-06 16:18:13 +00:00
|
|
|
.macpack longbranch
|
2009-11-02 22:29:49 +00:00
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Data
|
|
|
|
|
|
|
|
Ops = regbank
|
|
|
|
Flag = regbank+2
|
|
|
|
|
|
|
|
.bss
|
|
|
|
X1: .res 2
|
|
|
|
Y1: .res 2
|
|
|
|
X2: .res 2
|
|
|
|
Y2: .res 2
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Get the next operation from the Ops pointer, remove the flag bit and sign
|
2009-11-12 18:00:17 +00:00
|
|
|
; extend the 8 bit value to 16 bits.
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
.code
|
|
|
|
.proc GetOp
|
|
|
|
|
|
|
|
; Load delta value
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
lda (Ops),y
|
|
|
|
inc Ops
|
|
|
|
bne :+
|
|
|
|
inc Ops+1
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Move bit 7 into Flag, then sign extend the value in A and extend the sign
|
|
|
|
; into X.
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
: asl a ; Flag into carry
|
|
|
|
ror Flag
|
2009-11-12 18:00:17 +00:00
|
|
|
ldx #0
|
2009-11-10 18:50:33 +00:00
|
|
|
cmp #$80 ; Sign bit into carry
|
|
|
|
ror a ; Sign extend the value
|
2009-11-12 18:00:17 +00:00
|
|
|
bpl :+
|
|
|
|
dex ; Value is negative
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
; Done
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
: rts
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Get and process one coordinate value. The scale factor is passed in a/x
|
|
|
|
|
|
|
|
.code
|
2009-11-12 18:00:17 +00:00
|
|
|
GetProcessedYCoord:
|
|
|
|
lda _tgi_textscaleh+0
|
|
|
|
ldx _tgi_textscaleh+1
|
|
|
|
|
|
|
|
GetProcessedCoord:
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
; Save scale factor as left operand for multiplication
|
|
|
|
|
|
|
|
sta ptr1
|
|
|
|
stx ptr1+1
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Load next operation value.
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
jsr GetOp
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Multiplicate with the scale factor.
|
2009-11-10 18:50:33 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
jmp tgi_imulround ; Multiplicate, round and scale
|
2009-11-10 18:50:33 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Add the base coordinate with offset in Y to the value in A/X
|
|
|
|
|
|
|
|
.code
|
|
|
|
.proc AddBaseCoord
|
|
|
|
|
|
|
|
clc
|
|
|
|
adc _tgi_curx+0,y
|
|
|
|
pha
|
|
|
|
txa
|
|
|
|
adc _tgi_curx+1,y
|
|
|
|
tax
|
|
|
|
pla
|
|
|
|
rts
|
2009-11-10 18:50:33 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
.endproc
|
2009-11-10 18:50:33 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Subtract the value in a/x from the base coordinate with offset in Y
|
|
|
|
; This is
|
|
|
|
;
|
|
|
|
; ax = _tgi_cur[xy] - ax
|
|
|
|
;
|
|
|
|
; which can be transformed to
|
|
|
|
;
|
|
|
|
; ax = _tgi_cur[xy] + (~ax + 1);
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
.code
|
|
|
|
.proc SubBaseCoord
|
2009-11-10 18:50:33 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
eor #$FF
|
|
|
|
sec ; + 1
|
|
|
|
adc _tgi_curx+0,y
|
|
|
|
pha
|
|
|
|
txa
|
|
|
|
eor #$FF
|
|
|
|
adc _tgi_curx+1,y
|
|
|
|
tax
|
|
|
|
pla
|
|
|
|
rts
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
.endproc
|
2009-11-02 22:29:49 +00:00
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
|
|
|
|
.code
|
|
|
|
.proc _tgi_vectorchar
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Multiplicate the char value by two and save into Y
|
2009-11-06 16:18:13 +00:00
|
|
|
|
|
|
|
asl a
|
|
|
|
tay
|
|
|
|
|
2009-11-02 22:29:49 +00:00
|
|
|
; Since we will call tgi_lineto, which uses the zero page, and we do also
|
|
|
|
; need the zero page, make room in the register bank.
|
|
|
|
|
|
|
|
lda Ops
|
|
|
|
pha
|
|
|
|
lda Ops+1
|
|
|
|
pha
|
|
|
|
lda Flag
|
|
|
|
pha
|
|
|
|
|
2009-11-10 18:50:33 +00:00
|
|
|
; Calculate a pointer to the vector ops for the given char (now in Y). We
|
|
|
|
; definitely expect a font here, that has to be checked by the caller.
|
|
|
|
|
2009-11-06 16:18:13 +00:00
|
|
|
lda _tgi_vectorfont
|
|
|
|
clc
|
|
|
|
adc #<(TGI_VECTORFONT::CHARS - 2*TGI_VF_FIRSTCHAR)
|
|
|
|
sta Ops
|
|
|
|
lda _tgi_vectorfont+1
|
|
|
|
adc #>(TGI_VECTORFONT::CHARS - 2*TGI_VF_FIRSTCHAR)
|
|
|
|
sta Ops+1
|
|
|
|
|
|
|
|
iny
|
|
|
|
lda (Ops),y
|
|
|
|
tax
|
|
|
|
dey
|
|
|
|
lda (Ops),y
|
|
|
|
sta Ops
|
2009-11-02 22:29:49 +00:00
|
|
|
stx Ops+1
|
|
|
|
|
|
|
|
; Main loop executing vector operations
|
|
|
|
|
|
|
|
Loop: lda _tgi_textscalew+0
|
|
|
|
ldx _tgi_textscalew+1
|
2009-11-10 18:50:33 +00:00
|
|
|
jsr GetProcessedCoord ; Get X vector
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Depending on the text direction, the X vector is either applied to X as
|
|
|
|
;
|
|
|
|
; X2 = _tgi_curx + XMag * XDelta
|
|
|
|
;
|
|
|
|
; or applied to Y as
|
|
|
|
;
|
|
|
|
; Y2 = _tgi_cury - XMag * XDelta
|
|
|
|
;
|
|
|
|
; which can be transformed to
|
|
|
|
;
|
|
|
|
; Y2 = _tgi_cury + (~(XMag * XDelta) + 1);
|
|
|
|
;
|
|
|
|
;
|
|
|
|
; For the Y component we have
|
|
|
|
;
|
|
|
|
; Y2 = _tgi_cury - YMag * YDelta
|
|
|
|
;
|
|
|
|
; which can be transformed to
|
|
|
|
;
|
|
|
|
; Y2 = _tgi_cury + (~(YMag * YDelta) + 1);
|
|
|
|
;
|
|
|
|
; or applied to X as
|
|
|
|
;
|
|
|
|
; X2 = _tgi_curx - YMag * YDelta
|
|
|
|
;
|
|
|
|
; which can be transformed to
|
|
|
|
;
|
|
|
|
; X2 = _tgi_curx + (~(YMag * YDelta) + 1);
|
|
|
|
;
|
|
|
|
|
|
|
|
ldy _tgi_textdir ; Horizontal or vertical text?
|
|
|
|
bne @Vertical ; Jump if vertical
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Process horizontal text
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
ldy #0
|
|
|
|
jsr AddBaseCoord
|
|
|
|
sta X2
|
|
|
|
stx X2+1
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Get Y vector
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
jsr GetProcessedYCoord
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Apply to Y
|
|
|
|
|
|
|
|
ldy #2
|
|
|
|
jsr SubBaseCoord
|
|
|
|
sta Y2
|
|
|
|
stx Y2+1
|
|
|
|
jmp @DrawMove
|
|
|
|
|
|
|
|
; Process vertical text
|
|
|
|
|
|
|
|
@Vertical:
|
|
|
|
ldy #2
|
|
|
|
jsr SubBaseCoord
|
|
|
|
sta Y2
|
|
|
|
stx Y2+1
|
|
|
|
|
|
|
|
; Get Y vector
|
|
|
|
|
|
|
|
jsr GetProcessedYCoord
|
|
|
|
|
|
|
|
; Apply to X
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
jsr SubBaseCoord
|
|
|
|
sta X2
|
|
|
|
stx X2+1
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-06 12:08:25 +00:00
|
|
|
; Draw, then move - or just move
|
2009-11-02 22:29:49 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
@DrawMove:
|
2009-11-02 22:29:49 +00:00
|
|
|
bit Flag
|
|
|
|
bpl @Move ; Jump if move only
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
.if 0
|
2009-11-02 22:29:49 +00:00
|
|
|
ldy #7 ; Copy start coords into zp
|
|
|
|
: lda X1,y
|
|
|
|
sta ptr1,y
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
jsr tgi_line ; Call the driver
|
2009-11-12 18:00:17 +00:00
|
|
|
.else
|
|
|
|
ldy #7 ; Copy start coords
|
|
|
|
: lda X1,y
|
|
|
|
sta tgi_clip_x1,y
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
jsr tgi_clippedline ; Call line clipper
|
|
|
|
.endif
|
2009-11-02 22:29:49 +00:00
|
|
|
|
|
|
|
; Move the start position
|
|
|
|
|
|
|
|
@Move: ldy #3
|
|
|
|
: lda X2,y
|
|
|
|
sta X1,y
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
|
|
|
|
; Loop if not done
|
|
|
|
|
|
|
|
bit Flag
|
|
|
|
bvc Loop
|
|
|
|
|
|
|
|
; Done. Restore zp and return.
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
pla
|
2009-11-02 22:29:49 +00:00
|
|
|
sta Flag
|
|
|
|
pla
|
|
|
|
sta Ops+1
|
|
|
|
pla
|
|
|
|
sta Ops
|
|
|
|
rts
|
|
|
|
|
|
|
|
.endproc
|
|
|
|
|