C_OBJS =
S_OBJS = tgi-kernel.o \
+ tgi_done.o \
tgi_geterror.o \
tgi_getmaxx.o \
tgi_getmaxy.o \
tgi_getxres.o \
tgi_getyres.o \
- tgi_map_mode.o
+ tgi_init.o \
+ tgi_map_mode.o \
+ tgi_unload.o
all: $(C_OBJS) $(S_OBJS)
.include "tgi-kernel.inc"
+ .importzp ptr1
+
+
;----------------------------------------------------------------------------
; Variables
_tgi_drv: .res 2 ; Pointer to driver
_tgi_error: .res 1 ; Last error code
+_tgi_mode: .res 1 ; Graphics mode or zero
.data
-
+
; Jump table for the driver functions.
tgi_install: jmp $0000
lda (ptr1),y
sta tgi_install,x
inx
- cpx #(TGI_HDR_JMPCOUNT*3)
+ cpx #(TGI_HDR_JUMPCOUNT*3)
bne @L1
+
+; Initialize variables
lda #$00
sta _tgi_error
+ sta _tgi_mode
jsr tgi_install ; Call driver install routine
--- /dev/null
+;
+; Ullrich von Bassewitz, 21.06.2002
+;
+; void __fastcall__ tgi_done (void);
+; /* End graphics mode, switch back to text mode. Will NOT unload the driver! */
+
+ .include "tgi-kernel.inc"
+
+ .export _tgi_done
+
+_tgi_done:
+ lda _tgi_mode ; Is a graphics mode active?
+ beq @L1 ; Jump if not
+ jsr tgi_done ; Call the driver routine
+ jsr tgi_fetch_error ; Get the error code
+ lda _tgi_error ; Did we have an error?
+ bne @L1 ; Jump if yes
+ sta _tgi_mode ; Reset the current mode
+@L1: rts
+
+
+
; Ullrich von Bassewitz, 21.06.2002
;
; unsigned char __fastcall__ tgi_geterror (void);
-; /* Return the error code for the last operation. */
+; /* Return the error code for the last operation. This will also clear the
+; * error.
+; */
.include "tgi-kernel.inc"
_tgi_geterror:
+ ldx #0
lda _tgi_error
+ stx _tgi_error
rts
.include "tgi-kernel.inc"
.export _tgi_getmaxy
.import _tgi_getyres
- .import decax
+ .import decax1
_tgi_getmaxy:
--- /dev/null
+;
+; Ullrich von Bassewitz, 21.06.2002
+;
+; void __fastcall__ tgi_init (unsigned char mode);
+; /* Initialize the given graphics mode. */
+
+
+ .include "tgi-kernel.inc"
+ .include "tgi-error.inc"
+
+ .import _tgi_done
+ .export _tgi_init
+
+_tgi_init:
+ pha ; Save mode
+ jsr _tgi_done ; Switch off graphics if needed
+ jsr tgi_init ; Initialize the mode
+ jsr tgi_fetch_error ; Get the error code
+ pla ; Restore the mode
+ ldx _tgi_error ; Did we have an error before?
+ bne @L1 ; Jump if yes
+ sta _tgi_mode ; Set the current mode if not
+@L1: rts
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 21.06.2002
+;
+; void __fastcall__ tgi_unload (void);
+; /* Unload the currently loaded driver. */
+
+
+ .include "tgi-kernel.inc"
+ .include "modload.inc"
+
+ .import _tgi_done
+ .export _tgi_unload
+
+
+_tgi_unload:
+ jsr _tgi_done ; Switch off graphics
+ jsr tgi_deinstall ; Allow the driver to clean up
+
+ lda _tgi_drv
+ ldx _tgi_drv+1
+ jsr _mod_free ; Free the driver
+
+; Clear variables
+
+ lda #$00
+ sta _tgi_drv
+ sta _tgi_drv+1
+ sta _tgi_error
+
+ rts
+
+