_tgi_drv: .res 2 ; Pointer to driver
_tgi_error: .res 1 ; Last error code
-_tgi_mode: .res 1 ; Graphics mode or zero
+_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
.export _tgi_done
_tgi_done:
- lda _tgi_mode ; Is a graphics mode active?
+ lda _tgi_gmode ; Is a graphics mode active?
beq @L1 ; Jump if not
jsr tgi_done ; Call the driver routine
jsr tgi_geterror ; Get the error code
sta _tgi_error ; Save it for reference
cmp #TGI_ERR_OK
bne @L1 ; Jump if we had an error
- sta _tgi_mode ; Reset the current mode (A = 0)
+ sta _tgi_gmode ; Reset the graph mode flag (A = 0)
@L1: rts
;
; Ullrich von Bassewitz, 21.06.2002
;
-; void __fastcall__ tgi_init (unsigned char mode);
-; /* Initialize the given graphics mode. */
+; void __fastcall__ tgi_init (void);
+; /* Initialize the already loaded graphics driver */
.include "tgi-kernel.inc"
.export _tgi_init
_tgi_init:
- pha ; Save mode
jsr _tgi_done ; Switch off graphics if needed
- pla
- sta _tgi_mode ; Remember the mode
jsr tgi_init ; Go into graphics mode
jsr tgi_geterror ; Get the error code
sta _tgi_error ; Save for later reference
cmp #TGI_ERR_OK
bne @L9 ; Jump on error
+ inc _tgi_gmode ; Remember that graph mode is active
+
; Do driver initialization. First set the default palette.
jsr tgi_getdefpalette ; Get the default palette into A/X
; Error exit
-@L9: lda #$00
- sta _tgi_mode ; Clear the mode if init was not successful
- rts
+@L9: rts