From: cuz Date: Fri, 21 Jun 2002 13:28:51 +0000 (+0000) Subject: TGI Implementation X-Git-Tag: V2.12.0~2312 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f82ac8a91cdb71a17fd830745eb0ce2669afa6c8;p=cc65 TGI Implementation git-svn-id: svn://svn.cc65.org/cc65/trunk@1312 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/tgi/Makefile b/libsrc/tgi/Makefile index 4e2168cd4..1371089d0 100644 --- a/libsrc/tgi/Makefile +++ b/libsrc/tgi/Makefile @@ -14,12 +14,15 @@ 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) diff --git a/libsrc/tgi/tgi-kernel.s b/libsrc/tgi/tgi-kernel.s index c15737e79..5f968f860 100644 --- a/libsrc/tgi/tgi-kernel.s +++ b/libsrc/tgi/tgi-kernel.s @@ -6,6 +6,9 @@ .include "tgi-kernel.inc" + .importzp ptr1 + + ;---------------------------------------------------------------------------- ; Variables @@ -13,10 +16,11 @@ _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 @@ -52,11 +56,14 @@ tgi_setup: 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 diff --git a/libsrc/tgi/tgi_done.s b/libsrc/tgi/tgi_done.s new file mode 100644 index 000000000..83a70b580 --- /dev/null +++ b/libsrc/tgi/tgi_done.s @@ -0,0 +1,22 @@ +; +; 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 + + + diff --git a/libsrc/tgi/tgi_geterror.s b/libsrc/tgi/tgi_geterror.s index b55957094..4b74f561a 100644 --- a/libsrc/tgi/tgi_geterror.s +++ b/libsrc/tgi/tgi_geterror.s @@ -2,12 +2,16 @@ ; 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 diff --git a/libsrc/tgi/tgi_getmaxy.s b/libsrc/tgi/tgi_getmaxy.s index 23e55ba62..56e186b18 100644 --- a/libsrc/tgi/tgi_getmaxy.s +++ b/libsrc/tgi/tgi_getmaxy.s @@ -9,7 +9,7 @@ .include "tgi-kernel.inc" .export _tgi_getmaxy .import _tgi_getyres - .import decax + .import decax1 _tgi_getmaxy: diff --git a/libsrc/tgi/tgi_init.s b/libsrc/tgi/tgi_init.s new file mode 100644 index 000000000..a43bf9d04 --- /dev/null +++ b/libsrc/tgi/tgi_init.s @@ -0,0 +1,24 @@ +; +; 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 + diff --git a/libsrc/tgi/tgi_unload.s b/libsrc/tgi/tgi_unload.s new file mode 100644 index 000000000..fba835ed1 --- /dev/null +++ b/libsrc/tgi/tgi_unload.s @@ -0,0 +1,32 @@ +; +; 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 + +