]> git.sur5r.net Git - cc65/commitdiff
TGI Implementation
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 21 Jun 2002 13:28:51 +0000 (13:28 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 21 Jun 2002 13:28:51 +0000 (13:28 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1312 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/tgi/Makefile
libsrc/tgi/tgi-kernel.s
libsrc/tgi/tgi_done.s [new file with mode: 0644]
libsrc/tgi/tgi_geterror.s
libsrc/tgi/tgi_getmaxy.s
libsrc/tgi/tgi_init.s [new file with mode: 0644]
libsrc/tgi/tgi_unload.s [new file with mode: 0644]

index 4e2168cd4c6024cee0cf6b4f6e9ffebb11aad37c..1371089d07a8316d9302d26b2ec71a7d374474dd 100644 (file)
 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)
index c15737e79be7ba30d57e87e5a7bef7134fdba83a..5f968f86024812b3dc013b8fa7af461bd46e8b45 100644 (file)
@@ -6,6 +6,9 @@
 
         .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
@@ -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 (file)
index 0000000..83a70b5
--- /dev/null
@@ -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
+
+
+
index b5595709494ee8786bb224923f48003d15f8be86..4b74f561ab84fed1b0cf9b7543cc09c469850479 100644 (file)
@@ -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
 
index 23e55ba62ebdfa8eb1d1b224cbfac96cba73bb2a..56e186b18bb1451c48c92dbf090ba34198f44754 100644 (file)
@@ -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 (file)
index 0000000..a43bf9d
--- /dev/null
@@ -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 (file)
index 0000000..fba835e
--- /dev/null
@@ -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
+
+