.bss
_tgi_drv: .res 2 ; Pointer to driver
+; From here on, variables get cleared when a new driver is loaded
+cstart:
_tgi_error: .res 1 ; Last error code
_tgi_gmode: .res 1 ; Flag: Graphics mode active
_tgi_curx: .res 2 ; Current drawing cursor X
_tgi_cury: .res 2 ; Current drawing cursor Y
_tgi_color: .res 1 ; Current drawing color
+_tgi_font: .res 1 ; Which font to use
_tgi_textdir: .res 1 ; Current text direction
-_tgi_textmagx: .res 1 ; Text magnification in X dir
-_tgi_textmagy: .res 1 ; Text magnification in Y dir
+_tgi_vectorfont: .res 2 ; Pointer to vector font
+; The following two store an 8.8 fixed point value in the first two bytes,
+; 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_textscalew: .res 3 ; Text scale for the width
+_tgi_textscaleh: .res 3 ; Text scale for the height
+
+; The following two must also be in exactly this order
+_tgi_charwidth: .res 1 ; Char width of system font
+_tgi_charheight: .res 1 ; Char height of system font
+
+; End of section that gets cleared when a new driver is loaded
+csize = * - cstart
+
+; Maximum X and Y coordinate (that is, xres-1 and yres-1)
+_tgi_xmax: .res 2
+_tgi_ymax: .res 2
; 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_xres: .res 2 ; X resolution of the current mode
_tgi_yres: .res 2 ; Y resolution of the current mode
_tgi_colorcount: .res 1 ; Number of available colors
_tgi_pagecount: .res 1 ; Number of available screen pages
-_tgi_fontsizex: .res 1 ; System font X size
-_tgi_fontsizey: .res 1 ; System font Y size
+_tgi_fontwidth: .res 1 ; System font width in pixels
+_tgi_fontheight: .res 1 ; System font height in pixels
+_tgi_aspectratio: .res 2 ; Aspect ratio in 8.8 fixed point
.data
; Jump table for the driver functions.
+jumpvectors:
tgi_install: jmp $0000
tgi_uninstall: jmp $0000
tgi_init: jmp $0000
tgi_getpixel: jmp $0000
tgi_line: jmp $0000
tgi_bar: jmp $0000
-tgi_circle: jmp $0000
tgi_textstyle: jmp $0000
tgi_outtext: jmp $0000
tgi_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes
tgi_sig: .byte $74, $67, $69, TGI_API_VERSION ; "tgi", version
+.code
;----------------------------------------------------------------------------
; void __fastcall__ tgi_install (void* driver);
; /* Install an already loaded driver. */
; Initialize some other variables
lda #$00
-@L4: ldx #8-1
-@L5: sta _tgi_error,x ; Clear error/mode/curx/cury/textdir
+@L4: ldx #csize-1
+@L5: sta cstart,x ; Clear error/mode/curx/cury/...
dex
bpl @L5
rts
-; Copy one byte from the jump vectors
+; Copy one byte to the jump vectors
copy: lda (ptr1),y
- sta tgi_install,x
+ sta jumpvectors,x
iny
inx
rts
rts
+