]> git.sur5r.net Git - cc65/commitdiff
Added emulation and more clipping for the BAR function.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 22 Jun 2002 13:10:02 +0000 (13:10 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 22 Jun 2002 13:10:02 +0000 (13:10 +0000)
Copy colors and page count into local storage from the driver.
Added more functions.

git-svn-id: svn://svn.cc65.org/cc65/trunk@1322 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/tgi/Makefile
libsrc/tgi/tgi-kernel.s
libsrc/tgi/tgi_bar.s
libsrc/tgi/tgi_emu_bar.s [new file with mode: 0644]
libsrc/tgi/tgi_getcolorcount.s [new file with mode: 0644]
libsrc/tgi/tgi_getmaxcolor.s [new file with mode: 0644]
libsrc/tgi/tgi_setcolor.s
libsrc/tgi/tgi_setdrawpage.s [new file with mode: 0644]
libsrc/tgi/tgi_setviewpage.s [new file with mode: 0644]

index 30c6fc90d8b22225c59815b01e15d3b19b401c25..85fdfa031cf53fb7c647cd306209035c72c2ab4b 100644 (file)
 
 C_OBJS =        tgi_load.o
 
-S_OBJS =       tgi-kernel.o    \
-                tgi_bar.o       \
-                tgi_circle.o    \
-                tgi_clear.o     \
-                tgi_done.o      \
-                tgi_geterror.o  \
-                tgi_getmaxx.o   \
-                tgi_getmaxy.o   \
-                tgi_getpixel.o  \
-                tgi_getxres.o   \
-                tgi_getyres.o   \
-                tgi_init.o      \
-                tgi_line.o      \
-               tgi_map_mode.o  \
-                tgi_setcolor.o  \
-                tgi_setpixel.o  \
+S_OBJS =               tgi-kernel.o            \
+                tgi_bar.o               \
+                tgi_circle.o            \
+                tgi_clear.o             \
+                tgi_done.o              \
+                tgi_emu_bar.o           \
+                tgi_getcolorcount.o     \
+                tgi_geterror.o          \
+                tgi_getmaxcolor.o       \
+                tgi_getmaxx.o           \
+                tgi_getmaxy.o           \
+                tgi_getpixel.o          \
+                tgi_getxres.o           \
+                tgi_getyres.o           \
+                tgi_init.o              \
+                tgi_line.o              \
+                       tgi_map_mode.o          \
+                tgi_setcolor.o          \
+                tgi_setdrawpage.o       \
+                tgi_setpixel.o          \
+                tgi_setdrawpage.o       \
                 tgi_unload.o
 
 
index 521ecb7417b91071c9a1d5508a9462b078696df0..af448398fe90ddd77c254861407f78551f8f6d6e 100644 (file)
@@ -5,6 +5,7 @@
 ;
 
         .include        "tgi-kernel.inc"
+        .include        "tgi-error.inc"
 
         .export         _tgi_setup
         .importzp       ptr1
@@ -20,7 +21,9 @@ _tgi_error:   .res    1               ; Last error code
 _tgi_mode:      .res    1               ; Graphics mode or zero
 _tgi_xres:      .res    2               ; X resolution of the current mode
 _tgi_yres:      .res    2               ; Y resolution of the current mode
-        
+_tgi_colors:    .res    1               ; Number of available colors
+_tgi_pagecount: .res    1               ; Number of available screen pages
+
 
 .data
 
@@ -32,6 +35,8 @@ tgi_init:       jmp   $0000
 tgi_done:       jmp    $0000
 tgi_control:    jmp    $0000
 tgi_clear:      jmp     $0000
+tgi_setviewpage:jmp     $0000
+tgi_setdrawpage:jmp     $0000
 tgi_setcolor:   jmp     $0000
 tgi_setpixel:   jmp     $0000
 tgi_getpixel:   jmp     $0000
@@ -65,20 +70,27 @@ _tgi_setup:
         cpx     #(TGI_HDR_JUMPCOUNT*3)
         bne     @L1
 
-; Copy the screen dimensions
+; Check for emulation vectors needed
 
-        ldy     #TGI_HDR_XRES
-        lda     (ptr1),y
-        sta     _tgi_xres
-        iny
-        lda     (ptr1),y
-        sta     _tgi_xres+1
-        ldy     #TGI_HDR_YRES
-        lda     (ptr1),y
-        sta     _tgi_yres
+        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
+        sta     _tgi_xres,x
         iny
-        lda     (ptr1),y
-        sta     _tgi_yres+1
+        inx
+        cpx     #6
+        bne     @L3
 
 ; Initialize variables
 
@@ -112,3 +124,11 @@ tgi_set_ptr:
        sta     ptr1+1
         rts
 
+;----------------------------------------------------------------------------
+; Set an invalid argument error
+
+tgi_inv_arg:
+        lda     #TGI_ERR_INV_ARG
+        sta     _tgi_error
+        rts
+
index 439aa9d6960c94f8a401c2f655f14ec2805d6cad..1b6ffb0e74a739c6084fee3849cf7e83f130474a 100644 (file)
@@ -68,44 +68,63 @@ _tgi_bar:
 
 ; Check if X1 is negative. If so, clip it to the left border (zero).
 
-        lda     #$00
         bit     ptr1+1
         bpl     @L3
+        lda     #$00
         sta     ptr1
         sta     ptr1+1
+        beq     @L4             ; Branch always, skip following test
+
+; Check if X1 is beyond the right border. If so, the bar is invisible.
+
+@L3:    lda     ptr1
+        cmp     _tgi_xres
+        lda     ptr1+1
+        sbc     _tgi_xres
+        bcs     @L9             ; Bail out if invisible
 
-; Dito for Y1
+; Check if Y1 is negative. If so, clip it to the top border (zero).
 
-@L3:    bit     ptr2+1
-        bpl     @L4
+@L4:    bit     ptr2+1
+        bpl     @L5
+        lda     #$00
         sta     ptr2
         sta     ptr2+1
+        beq     @L6             ; Branch always, skip following test
+
+; Check if Y1 is beyond the bottom border. If so, the bar is invisible.
+
+@L5:    lda     ptr2
+        cmp     _tgi_yres
+        lda     ptr2+1
+        sbc     _tgi_yres
+        bcs     @L9             ; Bail out if invisible
 
 ; Check if X2 is larger than the maximum x coord. If so, clip it.
 
-@L4:    lda     ptr3
+@L6:    lda     ptr3
         cmp     _tgi_xres
         lda     ptr3+1
         sbc     _tgi_xres+1
-        bcs     @L5
+        bcc     @L7
         jsr     _tgi_getmaxx
         sta     ptr3
         stx     ptr3+1
 
 ; Check if Y2 is larger than the maximum y coord. If so, clip it.
 
-@L5:    lda     ptr4
+@L7:    lda     ptr4
         cmp     _tgi_yres
         lda     ptr4+1
         sbc     _tgi_yres+1
-        bcs     @L6
+        bcc     @L8
         jsr     _tgi_getmaxy
         sta     ptr4
         stx     ptr4+1
 
 ; The coordinates are now valid. Call the driver.
 
-@L6:    jmp     tgi_bar
+@L8:    jmp     tgi_bar
 
 ; Error exit
 
diff --git a/libsrc/tgi/tgi_emu_bar.s b/libsrc/tgi/tgi_emu_bar.s
new file mode 100644 (file)
index 0000000..6af7cc3
--- /dev/null
@@ -0,0 +1,80 @@
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; Emulation for tgi_bar.
+;
+
+        .include        "tgi-kernel.inc"
+
+        .importzp       ptr1, ptr2, ptr3, ptr4
+        .export         tgi_emu_bar
+
+tgi_emu_bar:
+        lda     ptr4
+        sta     Y2
+        lda     ptr4+1
+        sta     Y2+1
+
+        lda     ptr3
+        sta     X2
+        lda     ptr3+1
+        sta     X2+1
+
+        lda     ptr2
+        sta     ptr4
+        sta     Y1
+        lda     ptr2+1
+        sta     ptr4+1
+        sta     Y1+1
+
+        lda     ptr1
+        sta     X1
+        lda     ptr1+1
+        sta     X1+1
+
+@L1:    jsr     tgi_line
+
+        lda     Y1
+        cmp     Y2
+        bne     @L2
+        lda     Y1
+        cmp     Y2
+        beq     @L4
+
+@L2:    inc     Y1
+        bne     @L3
+        inc     Y1+1
+
+@L3:    lda     Y1
+        sta     ptr2
+        sta     ptr4
+        lda     Y1+1
+        sta     ptr2+1
+        sta     ptr4+1
+
+        lda     X1
+        sta     ptr1
+        lda     X1+1
+        sta     ptr1+1
+
+        lda     X2
+        sta     ptr3
+        lda     X2+1
+        sta     ptr3+1
+        jmp     @L1
+
+@L4:    rts
+
+;-----------------------------------------------------------------------------
+; Data
+
+.bss
+
+DY:     .res    2
+X1:     .res    2
+X2:     .res    2
+Y1:     .res    2
+Y2:     .res    2
+
+
+
diff --git a/libsrc/tgi/tgi_getcolorcount.s b/libsrc/tgi/tgi_getcolorcount.s
new file mode 100644 (file)
index 0000000..8059e2d
--- /dev/null
@@ -0,0 +1,15 @@
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; unsigned char __fastcall__ tgi_getcolorcount (void);
+; /* Get the number of available colors */
+
+        .include        "tgi-kernel.inc"
+        .export         _tgi_getcolorcount
+
+
+_tgi_getcolorcount:
+        lda     _tgi_colors
+        ldx     #0
+        rts
+
diff --git a/libsrc/tgi/tgi_getmaxcolor.s b/libsrc/tgi/tgi_getmaxcolor.s
new file mode 100644 (file)
index 0000000..dda4fb2
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; unsigned char __fastcall__ tgi_getmaxcolor (void);
+; /* Return the maximum supported color number (the number of colors would
+;  * then be getmaxcolor()+1).
+;  */
+
+        .include        "tgi-kernel.inc"
+        .export         _tgi_getmaxcolor
+
+
+_tgi_getmaxcolor:
+        ldx     _tgi_colors
+        dex
+        txa
+        ldx     #0
+        rts
+
+
+
index abf054abcb97ebd1daff5b3cf88f6d1f45a49fb5..0d430f76a0fc255ce1678332c927f43fcbcb8d84 100644 (file)
@@ -6,9 +6,13 @@
 
 
         .include        "tgi-kernel.inc"
-
+        .include        "tgi-error.inc"
         .export         _tgi_setcolor
 
-_tgi_setcolor   = tgi_setcolor  ; Call the driver
-
+_tgi_setcolor:
+        cmp     _tgi_colors     ; Compare to available colors
+        bcs     @L1
+        jmp     tgi_setcolor    ; Call the driver
+@L1:    jmp     tgi_inv_arg     ; Invalid argument
+    
 
diff --git a/libsrc/tgi/tgi_setdrawpage.s b/libsrc/tgi/tgi_setdrawpage.s
new file mode 100644 (file)
index 0000000..9052258
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; void __fastcall__ tgi_setdrawpage (unsigned char page);
+; /* Set the drawable page */
+
+
+        .include        "tgi-kernel.inc"
+        .export         _tgi_setdrawpage
+
+_tgi_setdrawpage:
+        cmp     _tgi_pagecount  ; Compare to available pages
+        bcs     @L1
+        jmp     tgi_setdrawpage ; Call the driver
+@L1:    jmp     tgi_inv_arg     ; Invalid argument
+
+
+
diff --git a/libsrc/tgi/tgi_setviewpage.s b/libsrc/tgi/tgi_setviewpage.s
new file mode 100644 (file)
index 0000000..d8fdb54
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Ullrich von Bassewitz, 22.06.2002
+;
+; void __fastcall__ tgi_setviewpage (unsigned char page);
+; /* Set the visible page. */
+
+
+
+        .include        "tgi-kernel.inc"
+        .export         _tgi_setviewpage
+
+_tgi_setviewpage:
+        cmp     _tgi_pagecount  ; Compare to available pages
+        bcs     @L1
+        jmp     tgi_setviewpage ; Call the driver
+@L1:    jmp     tgi_inv_arg     ; Invalid argument
+
+