2002-06-21 12:46:52 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 21.06.2002
|
|
|
|
;
|
|
|
|
; Common functions of the tgi graphics kernel.
|
|
|
|
;
|
|
|
|
|
2013-06-01 10:42:00 +00:00
|
|
|
.import tgi_libref
|
2002-06-21 13:28:51 +00:00
|
|
|
.importzp ptr1
|
|
|
|
|
2013-06-01 10:42:00 +00:00
|
|
|
.include "tgi-kernel.inc"
|
|
|
|
.include "tgi-error.inc"
|
|
|
|
|
2002-06-21 13:28:51 +00:00
|
|
|
|
2002-06-21 12:46:52 +00:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Variables
|
|
|
|
|
|
|
|
.bss
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
_tgi_drv: .res 2 ; Pointer to driver
|
2009-11-06 12:02:52 +00:00
|
|
|
; From here on, variables get cleared when a new driver is loaded
|
|
|
|
cstart:
|
2013-05-09 11:56:54 +00:00
|
|
|
_tgi_error: .res 1 ; Last error code
|
2002-12-29 20:57:57 +00:00
|
|
|
_tgi_gmode: .res 1 ; Flag: Graphics mode active
|
2002-07-07 10:30:31 +00:00
|
|
|
_tgi_curx: .res 2 ; Current drawing cursor X
|
|
|
|
_tgi_cury: .res 2 ; Current drawing cursor Y
|
|
|
|
_tgi_color: .res 1 ; Current drawing color
|
2009-11-02 22:29:49 +00:00
|
|
|
_tgi_font: .res 1 ; Which font to use
|
2002-10-03 11:18:23 +00:00
|
|
|
_tgi_textdir: .res 1 ; Current text direction
|
2009-11-06 16:18:13 +00:00
|
|
|
_tgi_vectorfont: .res 2 ; Pointer to vector font
|
2011-07-17 18:27:01 +00:00
|
|
|
; The following are character scale/size variables in 8.8 fixed point
|
|
|
|
; format. They are required to be in this order and adjacent.
|
|
|
|
_tgi_textscalew: .res 2 ; Vector font width scale
|
|
|
|
.res 2 ; Bitmap font width scale
|
|
|
|
_tgi_charwidth: .res 2 ; Full width of one bitmap char
|
|
|
|
_tgi_textscaleh: .res 2 ; Vector font height scale
|
|
|
|
.res 2 ; Bitmap font height scale
|
|
|
|
_tgi_charheight: .res 2 ; Full height of one bitmap char
|
2002-10-03 11:18:23 +00:00
|
|
|
|
2009-11-06 12:02:52 +00:00
|
|
|
; 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
|
|
|
|
|
2011-07-17 18:27:01 +00:00
|
|
|
; The following variables are copied from the driver header for faster access.
|
2009-10-30 21:26:35 +00:00
|
|
|
; fontwidth and fontheight are expected to be in order and adjacent.
|
2002-10-03 11:18:23 +00:00
|
|
|
tgi_driver_vars:
|
2002-07-07 10:30:31 +00:00
|
|
|
_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
|
2009-10-30 21:26:35 +00:00
|
|
|
_tgi_fontwidth: .res 1 ; System font width in pixels
|
|
|
|
_tgi_fontheight: .res 1 ; System font height in pixels
|
2009-10-29 20:13:56 +00:00
|
|
|
_tgi_aspectratio: .res 2 ; Aspect ratio in 8.8 fixed point
|
2011-07-17 11:23:27 +00:00
|
|
|
_tgi_flags: .res 1 ; TGI driver flags
|
2002-06-22 13:10:02 +00:00
|
|
|
|
2002-06-21 12:46:52 +00:00
|
|
|
|
|
|
|
.data
|
2002-06-21 16:25:56 +00:00
|
|
|
|
2002-06-21 12:46:52 +00:00
|
|
|
; Jump table for the driver functions.
|
|
|
|
|
2009-11-06 12:02:52 +00:00
|
|
|
jumpvectors:
|
2013-05-09 11:56:54 +00:00
|
|
|
tgi_install: jmp $0000
|
|
|
|
tgi_uninstall: jmp $0000
|
2002-07-07 10:30:31 +00:00
|
|
|
tgi_init: jmp $0000
|
|
|
|
tgi_done: jmp $0000
|
2013-05-09 11:56:54 +00:00
|
|
|
tgi_geterror: jmp $0000
|
2002-07-07 10:30:31 +00:00
|
|
|
tgi_control: jmp $0000
|
|
|
|
tgi_clear: jmp $0000
|
|
|
|
tgi_setviewpage: jmp $0000
|
|
|
|
tgi_setdrawpage: jmp $0000
|
|
|
|
tgi_setcolor: jmp $0000
|
|
|
|
tgi_setpalette: jmp $0000
|
|
|
|
tgi_getpalette: jmp $0000
|
|
|
|
tgi_getdefpalette: jmp $0000
|
|
|
|
tgi_setpixel: jmp $0000
|
|
|
|
tgi_getpixel: jmp $0000
|
|
|
|
tgi_line: jmp $0000
|
|
|
|
tgi_bar: jmp $0000
|
2002-10-03 11:18:23 +00:00
|
|
|
tgi_textstyle: jmp $0000
|
|
|
|
tgi_outtext: jmp $0000
|
2002-06-21 12:46:52 +00:00
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
; Driver header signature
|
|
|
|
.rodata
|
2003-10-23 09:05:50 +00:00
|
|
|
tgi_sig: .byte $74, $67, $69, TGI_API_VERSION ; "tgi", version
|
2003-02-11 12:37:46 +00:00
|
|
|
|
2002-06-21 12:46:52 +00:00
|
|
|
|
2006-03-31 20:07:43 +00:00
|
|
|
.code
|
2002-06-21 12:46:52 +00:00
|
|
|
;----------------------------------------------------------------------------
|
2021-05-16 20:57:28 +00:00
|
|
|
; void __fastcall__ tgi_install (const void* driver);
|
2003-02-11 12:37:46 +00:00
|
|
|
; /* Install an already loaded driver. */
|
2002-06-21 12:46:52 +00:00
|
|
|
|
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
_tgi_install:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta _tgi_drv
|
|
|
|
sta ptr1
|
|
|
|
stx _tgi_drv+1
|
|
|
|
stx ptr1+1
|
2002-06-21 16:25:56 +00:00
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
; Check the driver signature
|
2002-06-21 16:25:56 +00:00
|
|
|
|
2004-11-07 11:30:26 +00:00
|
|
|
ldy #.sizeof(tgi_sig)-1
|
2003-02-11 12:37:46 +00:00
|
|
|
@L0: lda (ptr1),y
|
|
|
|
cmp tgi_sig,y
|
|
|
|
bne tgi_inv_drv
|
|
|
|
dey
|
|
|
|
bpl @L0
|
2002-06-21 21:15:46 +00:00
|
|
|
|
2013-06-01 10:42:00 +00:00
|
|
|
; Set the library reference
|
|
|
|
|
|
|
|
ldy #TGI_HDR::LIBREF
|
|
|
|
lda #<tgi_libref
|
|
|
|
sta (ptr1),y
|
|
|
|
iny
|
|
|
|
lda #>tgi_libref
|
|
|
|
sta (ptr1),y
|
|
|
|
|
2002-06-21 21:15:46 +00:00
|
|
|
; Copy the jump vectors
|
2002-06-21 16:25:56 +00:00
|
|
|
|
2004-11-07 11:30:26 +00:00
|
|
|
ldy #TGI_HDR::JUMPTAB
|
2002-06-21 16:25:56 +00:00
|
|
|
ldx #0
|
|
|
|
@L1: inx ; Skip JMP opcode
|
|
|
|
jsr copy ; Copy one byte
|
|
|
|
jsr copy ; Copy one byte
|
2004-11-25 13:18:20 +00:00
|
|
|
cpy #(TGI_HDR::JUMPTAB + .sizeof(TGI_HDR::JUMPTAB))
|
2002-06-21 12:46:52 +00:00
|
|
|
bne @L1
|
2002-06-21 16:25:56 +00:00
|
|
|
|
2004-11-07 11:30:26 +00:00
|
|
|
; Call the driver install routine. It may update header variables, so we copy
|
|
|
|
; them after this call.
|
2002-06-21 21:15:46 +00:00
|
|
|
|
2004-11-07 11:30:26 +00:00
|
|
|
jsr tgi_install
|
2002-12-22 22:50:17 +00:00
|
|
|
|
2004-11-07 11:30:26 +00:00
|
|
|
; Copy variables from the driver header for faster access.
|
2002-06-22 13:10:02 +00:00
|
|
|
|
2004-11-07 11:30:26 +00:00
|
|
|
jsr tgi_set_ptr ; Set ptr1 to tgi_drv
|
|
|
|
ldy #(TGI_HDR::VARS + .sizeof(TGI_HDR::VARS) - 1)
|
|
|
|
ldx #.sizeof(TGI_HDR::VARS)-1
|
2002-06-22 13:10:02 +00:00
|
|
|
@L3: lda (ptr1),y
|
2002-10-03 11:18:23 +00:00
|
|
|
sta tgi_driver_vars,x
|
2004-11-07 11:30:26 +00:00
|
|
|
dey
|
|
|
|
dex
|
|
|
|
bpl @L3
|
|
|
|
|
|
|
|
; Initialize some other variables
|
2002-06-21 12:46:52 +00:00
|
|
|
|
|
|
|
lda #$00
|
2018-02-02 17:15:45 +00:00
|
|
|
ldx #csize-1
|
|
|
|
@L4: sta cstart,x ; Clear error/mode/curx/cury/...
|
2002-06-22 21:40:24 +00:00
|
|
|
dex
|
2018-02-02 17:15:45 +00:00
|
|
|
bpl @L4
|
2002-06-21 12:46:52 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
rts
|
2002-06-21 12:46:52 +00:00
|
|
|
|
2009-11-06 12:02:52 +00:00
|
|
|
; Copy one byte to the jump vectors
|
2002-06-21 12:46:52 +00:00
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
copy: lda (ptr1),y
|
2009-11-06 12:02:52 +00:00
|
|
|
sta jumpvectors,x
|
2003-02-11 12:37:46 +00:00
|
|
|
iny
|
|
|
|
inx
|
2002-06-21 12:46:52 +00:00
|
|
|
rts
|
|
|
|
|
2002-06-22 13:10:02 +00:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Set an invalid argument error
|
|
|
|
|
|
|
|
tgi_inv_arg:
|
|
|
|
lda #TGI_ERR_INV_ARG
|
|
|
|
sta _tgi_error
|
|
|
|
rts
|
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Set an invalid driver error
|
|
|
|
|
|
|
|
tgi_inv_drv:
|
|
|
|
lda #TGI_ERR_INV_DRIVER
|
|
|
|
sta _tgi_error
|
|
|
|
rts
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Load the pointer to the tgi driver into ptr1.
|
|
|
|
|
|
|
|
tgi_set_ptr:
|
2013-05-09 11:56:54 +00:00
|
|
|
lda _tgi_drv
|
|
|
|
sta ptr1
|
|
|
|
lda _tgi_drv+1
|
|
|
|
sta ptr1+1
|
2003-02-11 12:37:46 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
2012-03-04 13:08:54 +00:00
|
|
|
; void tgi_uninstall (void);
|
2003-02-11 12:37:46 +00:00
|
|
|
; /* Uninstall the currently loaded driver but do not unload it. Will call
|
2014-06-30 09:10:35 +00:00
|
|
|
; ** tgi_done if necessary.
|
|
|
|
; */
|
2003-02-11 12:37:46 +00:00
|
|
|
|
|
|
|
_tgi_uninstall:
|
|
|
|
jsr _tgi_done ; Switch off graphics
|
2004-11-07 11:30:26 +00:00
|
|
|
|
2003-02-11 12:37:46 +00:00
|
|
|
jsr tgi_uninstall ; Allow the driver to clean up
|
|
|
|
|
|
|
|
; Clear driver pointer and error code
|
|
|
|
|
2012-07-22 11:07:46 +00:00
|
|
|
tgi_clear_ptr:
|
2003-02-11 12:37:46 +00:00
|
|
|
lda #$00
|
|
|
|
sta _tgi_drv
|
|
|
|
sta _tgi_drv+1
|
|
|
|
sta _tgi_error
|
|
|
|
|
|
|
|
rts
|