mirror of
https://github.com/cc65/cc65.git
synced 2024-09-29 02:55:20 +00:00
Start of TGI changes. Untested, may not work.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4404 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
7b8fbb31da
commit
763fe0b802
@ -6,10 +6,10 @@
|
|||||||
;* */
|
;* */
|
||||||
;* */
|
;* */
|
||||||
;* */
|
;* */
|
||||||
;* (C) 2002-2004 Ullrich von Bassewitz */
|
;* (C) 2002-2009, Ullrich von Bassewitz */
|
||||||
;* Römerstraße 52 */
|
;* Roemerstrasse 52 */
|
||||||
;* D-70794 Filderstadt */
|
;* D-70794 Filderstadt */
|
||||||
;* EMail: uz@cc65.org */
|
;* EMail: uz@cc65.org */
|
||||||
;* */
|
;* */
|
||||||
;* */
|
;* */
|
||||||
;* This software is provided 'as-is', without any expressed or implied */
|
;* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -44,8 +44,8 @@
|
|||||||
YRES .word 1 ; Y resolution
|
YRES .word 1 ; Y resolution
|
||||||
COLORCOUNT .byte 1 ; Number of available colors
|
COLORCOUNT .byte 1 ; Number of available colors
|
||||||
PAGECOUNT .byte 1 ; Number of screens available
|
PAGECOUNT .byte 1 ; Number of screens available
|
||||||
FONTSIZE_X .byte 1 ; System font size in X direction
|
FONTWIDTH .byte 1 ; System font width
|
||||||
FONTSIZE_Y .byte 1 ; System font size in Y direction
|
FONTHEIGHT .byte 1 ; System font height
|
||||||
ASPECTRATIO .word 1 ; Fixed point 8.8 format
|
ASPECTRATIO .word 1 ; Fixed point 8.8 format
|
||||||
.endstruct
|
.endstruct
|
||||||
JUMPTAB .struct
|
JUMPTAB .struct
|
||||||
@ -93,14 +93,16 @@ TGI_TEXT_VERTICAL = 1
|
|||||||
.global _tgi_cury ; Current drawing cursor Y
|
.global _tgi_cury ; Current drawing cursor Y
|
||||||
.global _tgi_color ; Current drawing color
|
.global _tgi_color ; Current drawing color
|
||||||
.global _tgi_textdir ; Current text direction
|
.global _tgi_textdir ; Current text direction
|
||||||
.global _tgi_textmagx ; Text magnification in X dir
|
.global _tgi_textmagw ; Text magnification for the width
|
||||||
.global _tgi_textmagy ; Text magnification in Y dir
|
.global _tgi_textmagh ; Text magnification for the height
|
||||||
|
.global _tgi_charwidth ; Width of scaled system font char
|
||||||
|
.global _tgi_charheight ; Height of scaled system font char
|
||||||
.global _tgi_xres ; X resolution of the current mode
|
.global _tgi_xres ; X resolution of the current mode
|
||||||
.global _tgi_yres ; Y resolution of the current mode
|
.global _tgi_yres ; Y resolution of the current mode
|
||||||
.global _tgi_colorcount ; Number of available colors
|
.global _tgi_colorcount ; Number of available colors
|
||||||
.global _tgi_pagecount ; Number of available screen pages
|
.global _tgi_pagecount ; Number of available screen pages
|
||||||
.global _tgi_fontsizex ; System font X size
|
.global _tgi_fontwidth ; System font width
|
||||||
.global _tgi_fontsizey ; System font Y size
|
.global _tgi_fontheight ; System font height
|
||||||
.global _tgi_aspectratio ; Aspect ratio, fixed point 8.8
|
.global _tgi_aspectratio ; Aspect ratio, fixed point 8.8
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
@ -190,9 +190,11 @@ void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
|
|||||||
void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
|
void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
|
||||||
/* Draw a bar (a filled rectangle) using the current color. */
|
/* Draw a bar (a filled rectangle) using the current color. */
|
||||||
|
|
||||||
void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy,
|
void __fastcall__ tgi_textstyle (unsigned magwidth, unsigned magheight,
|
||||||
unsigned char dir);
|
unsigned char dir);
|
||||||
/* Set the style for text output. */
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
unsigned __fastcall__ tgi_textwidth (const char* s);
|
unsigned __fastcall__ tgi_textwidth (const char* s);
|
||||||
/* Calculate the width of the text in pixels according to the current text
|
/* Calculate the width of the text in pixels according to the current text
|
||||||
|
@ -71,7 +71,8 @@ S_OBJS = tgi-kernel.o \
|
|||||||
tgi_setviewpage.o \
|
tgi_setviewpage.o \
|
||||||
tgi_stddrv.o \
|
tgi_stddrv.o \
|
||||||
tgi_stdmode.o \
|
tgi_stdmode.o \
|
||||||
tgi_textsize.o \
|
tgi_textheight.o \
|
||||||
|
tgi_textwidth.o \
|
||||||
tgi_textstyle.o \
|
tgi_textstyle.o \
|
||||||
tgi_unload.o
|
tgi_unload.o
|
||||||
|
|
||||||
|
@ -23,17 +23,26 @@ _tgi_curx: .res 2 ; Current drawing cursor X
|
|||||||
_tgi_cury: .res 2 ; Current drawing cursor Y
|
_tgi_cury: .res 2 ; Current drawing cursor Y
|
||||||
_tgi_color: .res 1 ; Current drawing color
|
_tgi_color: .res 1 ; Current drawing color
|
||||||
_tgi_textdir: .res 1 ; Current text direction
|
_tgi_textdir: .res 1 ; Current text direction
|
||||||
_tgi_textmagx: .res 1 ; Text magnification in X dir
|
; The following two store an 8.8 fixed point value in the first two bytes,
|
||||||
_tgi_textmagy: .res 1 ; Text magnification in Y dir
|
; and a rounded integer value in the third byte. The latter is passed to the
|
||||||
|
; driver to scale the bitmap font. The variables are expected to be in
|
||||||
|
; this order and adjacent.
|
||||||
|
_tgi_textmagw: .res 3 ; Text magnification for the width
|
||||||
|
_tgi_textmagh: .res 3 ; Text magnification for the height
|
||||||
|
|
||||||
|
; The following two must also be in exactly this order
|
||||||
|
_tgi_charheight: .res 1 ; Char height of system font
|
||||||
|
_tgi_charwidth: .res 1 ; Char width of system font
|
||||||
|
|
||||||
; The following variables are copied from the driver header for faster access
|
; The following variables are copied from the driver header for faster access
|
||||||
|
; fontwidth and fontheight are expected to be in order and adjacent.
|
||||||
tgi_driver_vars:
|
tgi_driver_vars:
|
||||||
_tgi_xres: .res 2 ; X resolution of the current mode
|
_tgi_xres: .res 2 ; X resolution of the current mode
|
||||||
_tgi_yres: .res 2 ; Y resolution of the current mode
|
_tgi_yres: .res 2 ; Y resolution of the current mode
|
||||||
_tgi_colorcount: .res 1 ; Number of available colors
|
_tgi_colorcount: .res 1 ; Number of available colors
|
||||||
_tgi_pagecount: .res 1 ; Number of available screen pages
|
_tgi_pagecount: .res 1 ; Number of available screen pages
|
||||||
_tgi_fontsizex: .res 1 ; System font X size
|
_tgi_fontwidth: .res 1 ; System font width in pixels
|
||||||
_tgi_fontsizey: .res 1 ; System font Y size
|
_tgi_fontheight: .res 1 ; System font height in pixels
|
||||||
_tgi_aspectratio: .res 2 ; Aspect ratio in 8.8 fixed point
|
_tgi_aspectratio: .res 2 ; Aspect ratio in 8.8 fixed point
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
.include "tgi-kernel.inc"
|
.include "tgi-kernel.inc"
|
||||||
.include "tgi-error.inc"
|
.include "tgi-error.inc"
|
||||||
|
|
||||||
|
.import pushax
|
||||||
.importzp ptr1
|
.importzp ptr1
|
||||||
|
|
||||||
.proc _tgi_init
|
.proc _tgi_init
|
||||||
@ -45,13 +46,11 @@
|
|||||||
|
|
||||||
; Set the text style
|
; Set the text style
|
||||||
|
|
||||||
lda #TGI_TEXT_HORIZONTAL
|
lda #<$100
|
||||||
sta _tgi_textdir
|
ldx #>$100
|
||||||
ldx #1
|
jsr pushax ; Width scale
|
||||||
stx _tgi_textmagx
|
jsr pushax ; Heigh scale
|
||||||
ldy #1
|
jsr _tgi_textstyle ; A = Direction = TEXT_VERTICAL
|
||||||
sty _tgi_textmagy
|
|
||||||
jsr tgi_textstyle ; Tell the driver about the text style
|
|
||||||
|
|
||||||
; Clear the screen
|
; Clear the screen
|
||||||
|
|
||||||
|
@ -7,15 +7,41 @@
|
|||||||
|
|
||||||
.include "tgi-kernel.inc"
|
.include "tgi-kernel.inc"
|
||||||
|
|
||||||
.import popax
|
.import popax, negax
|
||||||
.importzp ptr3
|
.importzp ptr3
|
||||||
|
|
||||||
.proc _tgi_outtext
|
.proc _tgi_outtext
|
||||||
|
|
||||||
sta ptr3
|
sta ptr3
|
||||||
stx ptr3+1 ; Save s
|
stx ptr3+1 ; Pass s in ptr3 to driver
|
||||||
|
pha
|
||||||
|
txa
|
||||||
|
pha ; Save s on stack for later
|
||||||
|
|
||||||
jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2
|
jsr tgi_curtoxy ; Copy curx/cury into ptr1/ptr2
|
||||||
jmp tgi_outtext ; Call the driver
|
jsr tgi_outtext ; Call the driver
|
||||||
|
|
||||||
|
pla
|
||||||
|
tax
|
||||||
|
pla ; Restore s
|
||||||
|
jsr _tgi_textwidth ; Get width of text string
|
||||||
|
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
|
||||||
|
|
||||||
|
; 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
|
||||||
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
24
libsrc/tgi/tgi_textheight.s
Normal file
24
libsrc/tgi/tgi_textheight.s
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 2009-10-30
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
.include "tgi-kernel.inc"
|
||||||
|
|
||||||
|
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
; unsigned __fastcall__ tgi_textheight (const char* s);
|
||||||
|
; /* Calculate the width of the text in pixels according to the current text
|
||||||
|
; * style.
|
||||||
|
; */
|
||||||
|
;
|
||||||
|
|
||||||
|
.proc _tgi_textheight
|
||||||
|
|
||||||
|
lda _tgi_charheight
|
||||||
|
ldx #0
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
|||||||
;
|
|
||||||
; Ullrich von Bassewitz, 22.06.2002
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
.include "tgi-kernel.inc"
|
|
||||||
|
|
||||||
.import _strlen, pushax, tosumulax
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
|
||||||
; unsigned __fastcall__ tgi_textwidth (const char* s);
|
|
||||||
; /* Calculate the width of the text in pixels according to the current text
|
|
||||||
; * style.
|
|
||||||
; */
|
|
||||||
|
|
||||||
|
|
||||||
_tgi_textwidth:
|
|
||||||
|
|
||||||
ldy _tgi_textdir ; Get text direction
|
|
||||||
bne height
|
|
||||||
|
|
||||||
; Result is
|
|
||||||
;
|
|
||||||
; strlen (s) * tgi_textmagx * tgi_fontsizex
|
|
||||||
;
|
|
||||||
; Since we don't expect textmagx to have large values, we do the multiplication
|
|
||||||
; by looping.
|
|
||||||
|
|
||||||
width: jsr _strlen
|
|
||||||
jsr pushax
|
|
||||||
|
|
||||||
lda #0
|
|
||||||
tax
|
|
||||||
ldy _tgi_textmagx
|
|
||||||
@L1: clc
|
|
||||||
adc _tgi_fontsizex
|
|
||||||
bcc @L2
|
|
||||||
inx
|
|
||||||
@L2: dey
|
|
||||||
bne @L1
|
|
||||||
|
|
||||||
jmp tosumulax ; Result * strlen (s)
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
|
||||||
; unsigned __fastcall__ tgi_textheight (const char* s);
|
|
||||||
; /* Calculate the height of the text in pixels according to the current text
|
|
||||||
; * style.
|
|
||||||
; */
|
|
||||||
|
|
||||||
_tgi_textheight:
|
|
||||||
ldy _tgi_textdir ; Get text direction
|
|
||||||
bne width ; Jump if vertical
|
|
||||||
|
|
||||||
; Result is
|
|
||||||
;
|
|
||||||
; tgi_textmagy * tgi_fontsizey
|
|
||||||
;
|
|
||||||
; Since we don't expect textmagx to have large values, we do the multiplication
|
|
||||||
; by looping.
|
|
||||||
|
|
||||||
height: lda #0
|
|
||||||
tax
|
|
||||||
ldy _tgi_textmagy
|
|
||||||
@L1: clc
|
|
||||||
adc _tgi_fontsizey
|
|
||||||
bcc @L2
|
|
||||||
inx
|
|
||||||
@L2: dey
|
|
||||||
bne @L1
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|
@ -1,42 +1,82 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 22.06.2002
|
; Ullrich von Bassewitz, 2009-20-30
|
||||||
;
|
;
|
||||||
; void __fastcall__ tgi_textstyle (unsigned char magx, unsigned char magy,
|
; void __fastcall__ tgi_textstyle (unsigned magwidth, unsigned magheight,
|
||||||
; unsigned char dir);
|
; unsigned char dir);
|
||||||
; /* Set the style for text output. */
|
; /* 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.
|
||||||
|
; */
|
||||||
|
|
||||||
|
|
||||||
.include "tgi-kernel.inc"
|
.include "tgi-kernel.inc"
|
||||||
|
|
||||||
.import popax, incsp2
|
.import popax
|
||||||
|
|
||||||
|
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
; Calculate either the total height or the total width of a bitmapped
|
||||||
|
; character, depending on the value in Y. On entry, X contains the scaling
|
||||||
|
; factor. Since it is usually small, we multiplicate by doing repeated adds.
|
||||||
|
; The function returns zero in X and the calculated value in A.
|
||||||
|
|
||||||
|
.proc charsize_helper
|
||||||
|
|
||||||
|
lda _tgi_fontwidth,y
|
||||||
|
jmp @L2
|
||||||
|
@L1: clc
|
||||||
|
adc _tgi_fontwidth,y
|
||||||
|
@L2: dex
|
||||||
|
bne @L1
|
||||||
|
sta _tgi_charwidth,y
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
;
|
||||||
|
|
||||||
.proc _tgi_textstyle
|
.proc _tgi_textstyle
|
||||||
|
|
||||||
pha
|
sta _tgi_textdir ; Remember the direction
|
||||||
jsr popax ; Get magx/magy in one call
|
|
||||||
tay
|
|
||||||
pla
|
|
||||||
|
|
||||||
; A = textdir, X = textmagx, Y = textmagy
|
; The magheight value is in 8.8 fixed point. Store it and calculate a rounded
|
||||||
|
; value for scaling the bitmapped system font in the driver.
|
||||||
|
|
||||||
cmp #TGI_TEXT_HORIZONTAL
|
jsr popax ; magheight
|
||||||
beq DirOk
|
sta _tgi_textmagh+0
|
||||||
cmp #TGI_TEXT_VERTICAL
|
stx _tgi_textmagh+1
|
||||||
beq DirOk
|
asl a ; Check value behind comma
|
||||||
Fail: jmp tgi_inv_arg ; Invalid argument
|
bcc @L1
|
||||||
DirOk: cpy #$00
|
inx ; Round
|
||||||
beq Fail ; Cannot have magnification of zero
|
@L1: stx _tgi_textmagh+2 ; Store rounded value
|
||||||
cpx #$00
|
|
||||||
beq Fail ; Cannot have magnification of zero
|
|
||||||
|
|
||||||
; Parameter check ok, store them
|
; Calculate the total height of the bitmapped font and remember it.
|
||||||
|
|
||||||
stx _tgi_textmagx
|
ldy #1
|
||||||
sty _tgi_textmagy
|
jsr charsize_helper
|
||||||
sta _tgi_textdir
|
|
||||||
|
|
||||||
; Call the driver, parameters are passed in registers
|
; The magwidth value is in 8.8 fixed point. Store it and calculate a rounded
|
||||||
|
; value for scaling the bitmapped system font in the driver.
|
||||||
|
|
||||||
|
jsr popax ; magheight
|
||||||
|
sta _tgi_textmagw+0
|
||||||
|
stx _tgi_textmagw+1
|
||||||
|
asl a ; Check value behind comma
|
||||||
|
bcc @L2
|
||||||
|
inx ; Round
|
||||||
|
@L2: stx _tgi_textmagw+2 ; Store rounded value
|
||||||
|
|
||||||
|
; Calculate the total width of the bitmapped font and remember it.
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
jsr charsize_helper
|
||||||
|
|
||||||
|
; Load values and call the driver, parameters are passed in registers
|
||||||
|
|
||||||
|
ldx _tgi_textmagw+2
|
||||||
|
ldy _tgi_textmagh+2
|
||||||
|
lda _tgi_textdir
|
||||||
jmp tgi_textstyle
|
jmp tgi_textstyle
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
27
libsrc/tgi/tgi_textwidth.s
Normal file
27
libsrc/tgi/tgi_textwidth.s
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 2009-10-30
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
.include "tgi-kernel.inc"
|
||||||
|
|
||||||
|
.import _strlen, pushax, tosumula0
|
||||||
|
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
; 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
|
||||||
|
;
|
||||||
|
|
||||||
|
.proc _tgi_textwidth
|
||||||
|
|
||||||
|
jsr _strlen
|
||||||
|
jsr pushax
|
||||||
|
lda _tgi_charwidth
|
||||||
|
jmp tosumula0
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
Loading…
Reference in New Issue
Block a user