2002-10-03 11:18:23 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 21.06.2002
|
|
|
|
;
|
|
|
|
; void __fastcall__ tgi_outtext (const char* s);
|
|
|
|
; /* Output text at the current graphics cursor position. */
|
|
|
|
|
|
|
|
|
|
|
|
.include "tgi-kernel.inc"
|
2009-11-10 18:50:33 +00:00
|
|
|
.include "tgi-vectorfont.inc"
|
|
|
|
.include "zeropage.inc"
|
2002-10-03 11:18:23 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
.import _toascii
|
2009-10-30 21:26:35 +00:00
|
|
|
.import popax, negax
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Data
|
|
|
|
|
|
|
|
text := regbank
|
2009-11-12 18:00:17 +00:00
|
|
|
font := regbank ; Same as text
|
|
|
|
widths := regbank+2
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
;
|
2002-10-03 11:18:23 +00:00
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
.proc _tgi_outtext
|
|
|
|
|
2011-07-17 18:36:12 +00:00
|
|
|
ldy _tgi_font ; Bit or vectorfont?
|
2009-11-10 18:50:33 +00:00
|
|
|
bne VectorFont
|
|
|
|
|
|
|
|
; Handle bitmapped font output
|
|
|
|
|
2002-10-03 11:18:23 +00:00
|
|
|
sta ptr3
|
2011-07-17 18:36:12 +00:00
|
|
|
stx ptr3+1 ; Pass s in ptr3 to driver
|
2009-10-30 21:26:35 +00:00
|
|
|
pha
|
|
|
|
txa
|
2011-07-17 18:36:12 +00:00
|
|
|
pha ; Save s on stack for later
|
2009-10-30 21:26:35 +00:00
|
|
|
|
2011-07-17 18:36:12 +00:00
|
|
|
jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2
|
|
|
|
jsr tgi_outtext ; Call the driver
|
2009-10-30 21:26:35 +00:00
|
|
|
|
|
|
|
pla
|
|
|
|
tax
|
2011-07-17 18:36:12 +00:00
|
|
|
pla ; Restore s
|
|
|
|
jsr _tgi_gettextwidth ; Get width of text string
|
2009-11-12 18:00:17 +00:00
|
|
|
|
|
|
|
; Move the graphics cursor by the amount in a/x
|
|
|
|
|
|
|
|
MoveCursor:
|
2011-07-17 18:36:12 +00:00
|
|
|
ldy _tgi_textdir ; Horizontal or vertical text?
|
|
|
|
beq @L1 ; Jump if horizontal
|
2009-10-30 21:26:35 +00:00
|
|
|
|
|
|
|
; Move graphics cursor for vertical text
|
|
|
|
|
|
|
|
jsr negax
|
2011-07-17 18:36:12 +00:00
|
|
|
ldy #2 ; Point to _tgi_cury
|
2009-10-30 21:26:35 +00:00
|
|
|
|
|
|
|
; Move graphics cursor for horizontal text
|
|
|
|
|
|
|
|
@L1: clc
|
|
|
|
adc _tgi_curx,y
|
|
|
|
sta _tgi_curx,y
|
|
|
|
txa
|
|
|
|
adc _tgi_curx+1,y
|
|
|
|
sta _tgi_curx+1,y
|
2009-11-12 18:00:17 +00:00
|
|
|
Done: rts
|
2002-10-03 11:18:23 +00:00
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Handle vector font output. First, check if we really have a registered
|
|
|
|
; vector font. Bail out if this is not the case.
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
VectorFont:
|
|
|
|
tay
|
|
|
|
lda _tgi_vectorfont ; Do we have a vector font?
|
|
|
|
ora _tgi_vectorfont+1
|
|
|
|
beq Done ; Bail out if not
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
; Check if the font in the given size is partially out of the screen. We
|
|
|
|
; do this in vertical direction here, and in horizontal direction before
|
|
|
|
; outputting a character.
|
|
|
|
|
|
|
|
; (todo)
|
|
|
|
|
|
|
|
; Save zero page variable on stack and save
|
|
|
|
|
|
|
|
lda text
|
2009-11-10 18:50:33 +00:00
|
|
|
pha
|
|
|
|
lda text+1
|
|
|
|
pha
|
2009-11-12 18:00:17 +00:00
|
|
|
lda widths
|
|
|
|
pha
|
|
|
|
lda widths+1
|
|
|
|
pha
|
2009-11-10 18:50:33 +00:00
|
|
|
|
|
|
|
sty text
|
|
|
|
stx text+1 ; Store pointer to string
|
|
|
|
|
2009-11-12 18:00:17 +00:00
|
|
|
lda _tgi_vectorfont
|
|
|
|
clc
|
|
|
|
adc #<(TGI_VECTORFONT::WIDTHS - TGI_VF_FIRSTCHAR)
|
|
|
|
sta widths
|
|
|
|
lda _tgi_vectorfont+1
|
|
|
|
adc #>(TGI_VECTORFONT::WIDTHS - TGI_VF_FIRSTCHAR)
|
|
|
|
sta widths+1
|
|
|
|
|
2009-11-10 18:50:33 +00:00
|
|
|
; Output the text string
|
|
|
|
|
|
|
|
@L1: ldy #0
|
|
|
|
lda (text),y ; Get next character from string
|
|
|
|
beq EndOfText
|
2009-11-12 18:00:17 +00:00
|
|
|
jsr _toascii ; Convert to ascii
|
|
|
|
pha ; Save char in A
|
2009-11-10 18:50:33 +00:00
|
|
|
jsr _tgi_vectorchar ; Output it
|
2009-11-12 18:00:17 +00:00
|
|
|
pla
|
|
|
|
|
|
|
|
; Move the graphics cursor by the width of the char
|
|
|
|
|
|
|
|
tay
|
|
|
|
lda (widths),y ; Get width of this char
|
|
|
|
sta ptr1
|
|
|
|
lda #0
|
|
|
|
sta ptr1+1
|
|
|
|
lda _tgi_textscalew
|
|
|
|
ldx _tgi_textscalew+1 ; Get scale factor
|
|
|
|
jsr tgi_imulround ; Multiplcate and round
|
|
|
|
jsr MoveCursor ; Move the graphics cursor
|
|
|
|
|
|
|
|
; Next char in string
|
2011-07-17 18:36:12 +00:00
|
|
|
|
2009-11-10 18:50:33 +00:00
|
|
|
inc text
|
|
|
|
bne @L1
|
|
|
|
inc text+1
|
|
|
|
bne @L1
|
|
|
|
|
|
|
|
; Done. Restore registers and return
|
|
|
|
|
|
|
|
EndOfText:
|
2009-11-12 18:00:17 +00:00
|
|
|
pla
|
|
|
|
sta widths+1
|
|
|
|
pla
|
|
|
|
sta widths
|
2009-11-10 18:50:33 +00:00
|
|
|
pla
|
|
|
|
sta text+1
|
|
|
|
pla
|
|
|
|
sta text
|
2009-11-12 18:00:17 +00:00
|
|
|
rts
|
2009-11-10 18:50:33 +00:00
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
.endproc
|
2002-10-03 11:18:23 +00:00
|
|
|
|