2002-06-21 12:46:52 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 21.06.2002
|
|
|
|
;
|
|
|
|
; Common functions of the tgi graphics kernel.
|
|
|
|
;
|
|
|
|
|
|
|
|
.include "tgi-kernel.inc"
|
2002-06-22 13:10:02 +00:00
|
|
|
.include "tgi-error.inc"
|
2002-06-21 12:46:52 +00:00
|
|
|
|
2002-06-21 16:25:56 +00:00
|
|
|
.export _tgi_setup
|
2002-06-21 13:28:51 +00:00
|
|
|
.importzp ptr1
|
|
|
|
|
|
|
|
|
2002-06-21 12:46:52 +00:00
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Variables
|
|
|
|
|
|
|
|
.bss
|
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
_tgi_drv: .res 2 ; Pointer to driver
|
|
|
|
_tgi_error: .res 1 ; Last error code
|
|
|
|
_tgi_mode: .res 1 ; Graphics mode or zero
|
|
|
|
_tgi_curx: .res 2 ; Current drawing cursor X
|
|
|
|
_tgi_cury: .res 2 ; Current drawing cursor Y
|
|
|
|
_tgi_color: .res 1 ; Current drawing color
|
2002-10-03 11:18:23 +00:00
|
|
|
_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
|
|
|
|
|
|
|
|
; The following variables are copied from the driver header for faster access
|
|
|
|
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
|
2002-10-03 11:18:23 +00:00
|
|
|
_tgi_fontsizex: .res 1 ; System font X size
|
|
|
|
_tgi_fontsizey: .res 1 ; System font Y size
|
|
|
|
tgi_driver_var_size = * - tgi_driver_vars
|
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.
|
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
tgi_install: jmp $0000
|
|
|
|
tgi_deinstall: jmp $0000
|
|
|
|
tgi_init: jmp $0000
|
|
|
|
tgi_done: jmp $0000
|
|
|
|
tgi_geterror: jmp $0000
|
|
|
|
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
|
2002-07-07 11:12:41 +00:00
|
|
|
tgi_horline: jmp $0000
|
2002-07-07 10:30:31 +00:00
|
|
|
tgi_line: jmp $0000
|
|
|
|
tgi_bar: jmp $0000
|
|
|
|
tgi_circle: 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
|
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
2002-06-21 16:25:56 +00:00
|
|
|
; void __fastcall__ tgi_setup (void);
|
|
|
|
; /* Setup the driver and graphics kernel once the driver is loaded */
|
2002-06-21 12:46:52 +00:00
|
|
|
|
|
|
|
|
2002-06-21 16:25:56 +00:00
|
|
|
copy: lda (ptr1),y
|
2002-06-21 12:46:52 +00:00
|
|
|
sta tgi_install,x
|
|
|
|
iny
|
|
|
|
inx
|
2002-06-21 16:25:56 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
_tgi_setup:
|
2002-06-21 21:15:46 +00:00
|
|
|
jsr tgi_set_ptr ; load _tgi_drv into ptr1
|
|
|
|
|
|
|
|
; Copy the jump vectors
|
2002-06-21 16:25:56 +00:00
|
|
|
|
|
|
|
ldy #TGI_HDR_JUMPTAB
|
|
|
|
ldx #0
|
|
|
|
@L1: inx ; Skip JMP opcode
|
|
|
|
jsr copy ; Copy one byte
|
|
|
|
jsr copy ; Copy one byte
|
2002-06-21 13:28:51 +00:00
|
|
|
cpx #(TGI_HDR_JUMPCOUNT*3)
|
2002-06-21 12:46:52 +00:00
|
|
|
bne @L1
|
2002-06-21 16:25:56 +00:00
|
|
|
|
2002-06-22 13:10:02 +00:00
|
|
|
; Check for emulation vectors needed
|
2002-06-21 21:15:46 +00:00
|
|
|
|
2002-06-22 13:10:02 +00:00
|
|
|
lda tgi_bar+1
|
|
|
|
ora tgi_bar+2 ; Do we have a BAR vector?
|
|
|
|
bne @L2 ; Jump if yes
|
|
|
|
lda #<tgi_emu_bar ; Use emulation if no
|
|
|
|
sta tgi_bar+1
|
|
|
|
lda #>tgi_emu_bar
|
|
|
|
sta tgi_bar+2
|
|
|
|
|
|
|
|
; Copy variables. Beware: We are using internal knowledge about variable
|
|
|
|
; layout here!
|
|
|
|
|
|
|
|
@L2: ldy #TGI_HDR_XRES
|
|
|
|
ldx #0
|
|
|
|
@L3: lda (ptr1),y
|
2002-10-03 11:18:23 +00:00
|
|
|
sta tgi_driver_vars,x
|
2002-06-21 21:15:46 +00:00
|
|
|
iny
|
2002-06-22 13:10:02 +00:00
|
|
|
inx
|
2002-10-03 11:18:23 +00:00
|
|
|
cpx #tgi_driver_var_size
|
2002-06-22 13:10:02 +00:00
|
|
|
bne @L3
|
2002-06-21 21:15:46 +00:00
|
|
|
|
2002-06-21 13:28:51 +00:00
|
|
|
; Initialize variables
|
2002-06-21 12:46:52 +00:00
|
|
|
|
|
|
|
lda #$00
|
2002-10-03 11:18:23 +00:00
|
|
|
ldx #7-1
|
|
|
|
@L4: sta _tgi_error,x ; Clear error/mode/curx/cury/textdir
|
2002-06-22 21:40:24 +00:00
|
|
|
dex
|
|
|
|
bpl @L4
|
2002-06-21 12:46:52 +00:00
|
|
|
|
2002-07-07 10:30:31 +00:00
|
|
|
jmp tgi_install ; Call driver install routine
|
2002-06-21 12:46:52 +00:00
|
|
|
|
|
|
|
;----------------------------------------------------------------------------
|
|
|
|
; Load the pointer to the tgi driver into ptr1.
|
|
|
|
|
|
|
|
tgi_set_ptr:
|
2002-07-07 10:30:31 +00:00
|
|
|
lda _tgi_drv
|
2002-06-21 12:46:52 +00:00
|
|
|
sta ptr1
|
|
|
|
lda _tgi_drv+1
|
|
|
|
sta ptr1+1
|
|
|
|
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
|
|
|
|
|