.global _tgi_fontwidth ; System font width
.global _tgi_fontheight ; System font height
.global _tgi_aspectratio ; Aspect ratio, fixed point 8.8
+ .global _tgi_flags ; TGI driver flags
;------------------------------------------------------------------------------
; ASM accessible variables
.global _tgi_getpagecount
.global _tgi_getpalette
.global _tgi_getpixel
+ .global _tgi_gettextheight
+ .global _tgi_gettextwidth
.global _tgi_getxres
.global _tgi_getyres
.global _tgi_gotoxy
.global _tgi_setdrawpage
.global _tgi_setpalette
.global _tgi_setpixel
+ .global _tgi_settextscale
+ .global _tgi_settextstyle
.global _tgi_setviewpage
- .global _tgi_textheight
- .global _tgi_textscale
- .global _tgi_textstyle
- .global _tgi_textwidth
.global _tgi_uninstall
.global _tgi_unload
void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
/* Draw a bar (a filled rectangle) using the current color. */
-void __fastcall__ tgi_textscale (unsigned width, unsigned height);
+void __fastcall__ tgi_settextscale (unsigned width, unsigned height);
/* Set the scaling for text output. The scaling factors for width and height
* are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
*/
-void __fastcall__ tgi_textstyle (unsigned width, unsigned height,
- unsigned char dir, unsigned char font);
+void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
+ unsigned char dir, unsigned char font);
/* Set the style for text output. The scaling factors for width and height
* are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
* dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
* constants.
*/
-unsigned __fastcall__ tgi_textwidth (const char* s);
+unsigned __fastcall__ tgi_gettextwidth (const char* s);
/* Calculate the width of the text in pixels according to the current text
* style.
*/
-unsigned __fastcall__ tgi_textheight (const char* s);
+unsigned __fastcall__ tgi_gettextheight (const char* s);
/* Calculate the height of the text in pixels according to the current text
* style.
*/
tgi_getpalette.o \
tgi_getpixel.o \
tgi_getset.o \
+ tgi_gettextheight.o \
+ tgi_gettextwidth.o \
tgi_getxres.o \
tgi_getyres.o \
tgi_gotoxy.o \
tgi_setdrawpage.o \
tgi_setpalette.o \
tgi_setpixel.o \
+ tgi_settextstyle.o \
tgi_setviewpage.o \
- tgi_textheight.o \
- tgi_textwidth.o \
- tgi_textstyle.o \
tgi_unload.o \
tgi_vectorchar.o
--- /dev/null
+;
+; Ullrich von Bassewitz, 2009-10-30
+;
+
+
+ .include "tgi-kernel.inc"
+ .include "tgi-vectorfont.inc"
+ .include "zeropage.inc"
+
+
+;-----------------------------------------------------------------------------
+; unsigned __fastcall__ tgi_gettextheight (const char* s);
+; /* Calculate the height of the text in pixels according to the current text
+; * style.
+; */
+;
+
+.proc _tgi_gettextheight
+
+ ldy _tgi_font
+ bne @L2 ; Jump if vector font
+
+; Return the height for the bitmap font
+
+ lda _tgi_charheight
+ ldx #0
+@L1: rts
+
+; Return the height for the vector font
+
+@L2: lda _tgi_vectorfont
+ tax
+ ora _tgi_vectorfont+1
+ beq @L1 ; Return zero if no font
+
+ stx ptr1
+ lda _tgi_vectorfont+1
+ sta ptr1+1
+ ldy #TGI_VECTORFONT::HEIGHT
+ lda (ptr1),y ; Get height of font
+
+ sta ptr1
+ lda #0
+ sta ptr1+1 ; Save base height in ptr1
+
+ lda _tgi_textscaleh
+ ldx _tgi_textscaleh+1 ; Get scale factor ...
+ jmp tgi_imulround ; ... and return scaled result
+
+.endproc
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 2009-10-30
+;
+
+
+ .include "tgi-kernel.inc"
+ .include "tgi-vectorfont.inc"
+ .include "zeropage.inc"
+
+ .import _strlen, _toascii
+ .import umul8x16r16
+
+;-----------------------------------------------------------------------------
+; Aliases for zero page locations
+
+Width := ptr1
+WTab := ptr2
+Text := ptr3
+
+
+
+;-----------------------------------------------------------------------------
+; unsigned __fastcall__ tgi_gettextwidth (const char* s);
+; /* Calculate the width of the text in pixels according to the current text
+; * style.
+; */
+;
+; Result is strlen (s) * tgi_textmagw * tgi_fontsizex
+;
+
+.code
+.proc _tgi_gettextwidth
+
+ ldy _tgi_font
+ bne @L1 ; Jump if vector font
+
+; Return the width of the string for the bitmap font
+
+ ldy _tgi_charwidth
+ sta ptr1
+ jsr _strlen
+ jsr umul8x16r16
+ ldy _tgi_textscalew+2 ; Get rounded scale factor
+ sty ptr1
+ jmp umul8x16r16
+
+; Return the width of the string for the vector font. To save some code, we
+; will add up all the character widths and then multiply by the scale factor.
+; Since the output routine will scale each single character, the result may
+; be slightly different.
+
+@L1: sta Text
+ stx Text+1 ; Save pointer to string
+
+ lda _tgi_vectorfont+1
+ tax
+ ora _tgi_vectorfont
+ beq @L9 ; Return zero if no font
+
+ lda _tgi_vectorfont
+ clc
+ adc #<(TGI_VECTORFONT::WIDTHS - TGI_VF_FIRSTCHAR)
+ sta WTab
+ txa
+ adc #>(TGI_VECTORFONT::WIDTHS - TGI_VF_FIRSTCHAR)
+ sta WTab+1
+
+ ldy #0
+ sty Width
+ sty Width+1 ; Zero the total width
+
+; Sum up the widths of the single characters
+
+@L2: ldy #0
+ lda (Text),y ; Get next char
+ beq @L4 ; Bail out if end of text reached
+ jsr _toascii ; Convert to ascii
+ tay
+ lda (WTab),y ; Get width of this char
+ clc
+ adc Width
+ sta Width
+ bcc @L3
+ inc Width+1
+@L3: inc Text
+ bne @L2
+ inc Text+1
+ bne @L2
+
+; We have the total width now, scale and return it
+
+@L4: lda _tgi_textscalew
+ ldx _tgi_textscalew+1
+ jmp tgi_imulround
+
+; Exit point if no font installed
+
+@L9: rts
+
+.endproc
+
+
+
jsr pushax ; Width scale = 1.0
jsr pushax ; Heigh scale = 1.0
jsr pusha ; Text direction = TGI_TEXT_HORIZONTAL
- jmp _tgi_textstyle ; A = Font = TGI_FONT_BITMAP
+ jmp _tgi_settextstyle ; A = Font = TGI_FONT_BITMAP
; Error exit
.proc _tgi_outtext
- ldy _tgi_font ; Bit or vectorfont?
+ ldy _tgi_font ; Bit or vectorfont?
bne VectorFont
; Handle bitmapped font output
sta ptr3
- stx ptr3+1 ; Pass s in ptr3 to driver
+ stx ptr3+1 ; Pass s in ptr3 to driver
pha
txa
- pha ; Save s on stack for later
+ pha ; Save s on stack for later
- jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2
- jsr tgi_outtext ; Call the driver
+ jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2
+ jsr tgi_outtext ; Call the driver
pla
tax
- pla ; Restore s
- jsr _tgi_textwidth ; Get width of text string
+ pla ; Restore s
+ jsr _tgi_gettextwidth ; Get width of text string
; Move the graphics cursor by the amount in a/x
MoveCursor:
- ldy _tgi_textdir ; Horizontal or vertical text?
- beq @L1 ; Jump if horizontal
+ ldy _tgi_textdir ; Horizontal or vertical text?
+ beq @L1 ; Jump if horizontal
; Move graphics cursor for vertical text
jsr negax
- ldy #2 ; Point to _tgi_cury
+ ldy #2 ; Point to _tgi_cury
; Move graphics cursor for horizontal text
jsr MoveCursor ; Move the graphics cursor
; Next char in string
-
+
inc text
bne @L1
inc text+1
--- /dev/null
+;
+; Ullrich von Bassewitz, 2009-10-30
+;
+
+
+ .include "zeropage.inc"
+ .include "tgi-kernel.inc"
+
+ .import umul8x16r24
+ .import popa, popax
+
+ .macpack cpu
+
+;-----------------------------------------------------------------------------
+; void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
+; unsigned char dir, unsigned char font);
+; /* Set the style for text output. The scaling factors for width and height
+; * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
+; * dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
+; * constants.
+; */
+;
+
+.proc _tgi_settextstyle
+
+ sta _tgi_font ; Remember the font to use
+ jsr popa
+ sta _tgi_textdir ; Remember the direction
+
+; Pop the height and run directly into tgi_textscale
+
+ jsr popax
+
+.endproc
+
+;-----------------------------------------------------------------------------
+; void __fastcall__ tgi_settextscale (unsigned width, unsigned height);
+; /* Set the scaling for text output. The scaling factors for width and height
+; * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
+; */
+
+.proc _tgi_settextscale
+
+; Setup the height
+
+ ldy _tgi_fontheight ; Get height of bitmap font in pixels
+ sty ptr1 ; Save for later
+ ldy #6 ; Address the height
+ jsr process_onedim ; Process height
+
+; Setup the width
+
+ jsr popax ; Get width scale into a/x
+ ldy _tgi_fontwidth ; Get width of bitmap font in pixels
+ sty ptr1 ; Save for later
+ ldy #0 ; Address the width
+
+; Process one character dimension. That means:
+;
+; - Store the vector font dimension in 8.8 format
+; - If necessary, round up/down to next integer
+; - Store the bitmap font dimension in 8.8 format
+; - Multiply by size of bitmap char in pixels
+; - Store the bitmap font size in 8.8 format
+;
+
+process_onedim:
+
+ jsr store ; Store vector font scale factor
+ bit _tgi_flags ; Fine grained scaling support avail?
+ bmi @L2 ; Jump if yes
+
+ asl a ; Round to nearest full integer
+ bcc @L1
+ inx
+@L1: lda #0
+
+@L2: jsr store ; Store bitmap font scale factor
+
+; The size of the font in pixels in the selected dimension is already in ptr1
+; So if we call umul8x16r24 we get the size in pixels in 16.8 fixed point.
+; Disallowing characters larger than 256 pixels, we just drop the high byte
+; and remember the low 16 bit as size in 8.8 format.
+
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+ phy ; Save Y
+ jsr umul8x16r24
+ ply ; Restore Y
+.else
+ sty tmp1 ; Save Y
+ jsr umul8x16r24
+ ldy tmp1 ; Restore Y
+.endif
+
+store: sta _tgi_textscalew,y
+ iny
+ pha
+ txa
+ sta _tgi_textscalew,y
+ iny
+ pla
+ rts
+
+.endproc
+
+
+++ /dev/null
-;
-; Ullrich von Bassewitz, 2009-10-30
-;
-
-
- .include "tgi-kernel.inc"
- .include "tgi-vectorfont.inc"
- .include "zeropage.inc"
-
-
-;-----------------------------------------------------------------------------
-; unsigned __fastcall__ tgi_textheight (const char* s);
-; /* Calculate the height of the text in pixels according to the current text
-; * style.
-; */
-;
-
-.proc _tgi_textheight
-
- ldy _tgi_font
- bne @L2 ; Jump if vector font
-
-; Return the height for the bitmap font
-
- lda _tgi_charheight
- ldx #0
-@L1: rts
-
-; Return the height for the vector font
-
-@L2: lda _tgi_vectorfont
- tax
- ora _tgi_vectorfont+1
- beq @L1 ; Return zero if no font
-
- stx ptr1
- lda _tgi_vectorfont+1
- sta ptr1+1
- ldy #TGI_VECTORFONT::HEIGHT
- lda (ptr1),y ; Get height of font
-
- sta ptr1
- lda #0
- sta ptr1+1 ; Save base height in ptr1
-
- lda _tgi_textscaleh
- ldx _tgi_textscaleh+1 ; Get scale factor ...
- jmp tgi_imulround ; ... and return scaled result
-
-.endproc
-
-
+++ /dev/null
-;
-; Ullrich von Bassewitz, 2009-10-30
-;
-
-
- .include "zeropage.inc"
- .include "tgi-kernel.inc"
-
- .import umul8x16r24
- .import popa, popax
-
- .macpack cpu
-
-;-----------------------------------------------------------------------------
-; void __fastcall__ tgi_textstyle (unsigned width, unsigned height,
-; unsigned char dir, unsigned char font);
-; /* Set the style for text output. The scaling factors for width and height
-; * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
-; * dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
-; * constants.
-; */
-;
-
-.proc _tgi_textstyle
-
- sta _tgi_font ; Remember the font to use
- jsr popa
- sta _tgi_textdir ; Remember the direction
-
-; Pop the height and run directly into tgi_textscale
-
- jsr popax
-
-.endproc
-
-;-----------------------------------------------------------------------------
-; void __fastcall__ tgi_textscale (unsigned width, unsigned height);
-; /* Set the scaling for text output. The scaling factors for width and height
-; * are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
-; */
-
-.proc _tgi_textscale
-
-; Setup the height
-
- ldy _tgi_fontheight ; Get height of bitmap font in pixels
- sty ptr1 ; Save for later
- ldy #6 ; Address the height
- jsr process_onedim ; Process height
-
-; Setup the width
-
- jsr popax ; Get width scale into a/x
- ldy _tgi_fontwidth ; Get width of bitmap font in pixels
- sty ptr1 ; Save for later
- ldy #0 ; Address the width
-
-; Process one character dimension. That means:
-;
-; - Store the vector font dimension in 8.8 format
-; - If necessary, round up/down to next integer
-; - Store the bitmap font dimension in 8.8 format
-; - Multiply by size of bitmap char in pixels
-; - Store the bitmap font size in 8.8 format
-;
-
-process_onedim:
-
- jsr store ; Store vector font scale factor
- bit _tgi_flags ; Fine grained scaling support avail?
- bmi @L2 ; Jump if yes
-
- asl a ; Round to nearest full integer
- bcc @L1
- inx
-@L1: lda #0
-
-@L2: jsr store ; Store bitmap font scale factor
-
-; The size of the font in pixels in the selected dimension is already in ptr1
-; So if we call umul8x16r24 we get the size in pixels in 16.8 fixed point.
-; Disallowing characters larger than 256 pixels, we just drop the high byte
-; and remember the low 16 bit as size in 8.8 format.
-
-.if (.cpu .bitand ::CPU_ISET_65SC02)
- phy ; Save Y
- jsr umul8x16r24
- ply ; Restore Y
-.else
- sty tmp1 ; Save Y
- jsr umul8x16r24
- ldy tmp1 ; Restore Y
-.endif
-
-store: sta _tgi_textscalew,y
- iny
- pha
- txa
- sta _tgi_textscalew,y
- iny
- pla
- rts
-
-.endproc
-
-
+++ /dev/null
-;
-; Ullrich von Bassewitz, 2009-10-30
-;
-
-
- .include "tgi-kernel.inc"
- .include "tgi-vectorfont.inc"
- .include "zeropage.inc"
-
- .import _strlen, _toascii
- .import umul8x16r16
-
-;-----------------------------------------------------------------------------
-; Aliases for zero page locations
-
-Width := ptr1
-WTab := ptr2
-Text := ptr3
-
-
-
-;-----------------------------------------------------------------------------
-; unsigned __fastcall__ tgi_textwidth (const char* s);
-; /* Calculate the width of the text in pixels according to the current text
-; * style.
-; */
-;
-; Result is strlen (s) * tgi_textmagw * tgi_fontsizex
-;
-
-.code
-.proc _tgi_textwidth
-
- ldy _tgi_font
- bne @L1 ; Jump if vector font
-
-; Return the width of the string for the bitmap font
-
- ldy _tgi_charwidth
- sta ptr1
- jsr _strlen
- jsr umul8x16r16
- ldy _tgi_textscalew+2 ; Get rounded scale factor
- sty ptr1
- jmp umul8x16r16
-
-; Return the width of the string for the vector font. To save some code, we
-; will add up all the character widths and then multiply by the scale factor.
-; Since the output routine will scale each single character, the result may
-; be slightly different.
-
-@L1: sta Text
- stx Text+1 ; Save pointer to string
-
- lda _tgi_vectorfont+1
- tax
- ora _tgi_vectorfont
- beq @L9 ; Return zero if no font
-
- lda _tgi_vectorfont
- clc
- adc #<(TGI_VECTORFONT::WIDTHS - TGI_VF_FIRSTCHAR)
- sta WTab
- txa
- adc #>(TGI_VECTORFONT::WIDTHS - TGI_VF_FIRSTCHAR)
- sta WTab+1
-
- ldy #0
- sty Width
- sty Width+1 ; Zero the total width
-
-; Sum up the widths of the single characters
-
-@L2: ldy #0
- lda (Text),y ; Get next char
- beq @L4 ; Bail out if end of text reached
- jsr _toascii ; Convert to ascii
- tay
- lda (WTab),y ; Get width of this char
- clc
- adc Width
- sta Width
- bcc @L3
- inc Width+1
-@L3: inc Text
- bne @L2
- inc Text+1
- bne @L2
-
-; We have the total width now, scale and return it
-
-@L4: lda _tgi_textscalew
- ldx _tgi_textscalew+1
- jmp tgi_imulround
-
-; Exit point if no font installed
-
-@L9: rts
-
-.endproc
-
-
-