]> git.sur5r.net Git - cc65/blobdiff - libsrc/lynx/lynx-160-102-16.s
Lynx TGI driver update by Karri Kaksonen. Adds collision detection.
[cc65] / libsrc / lynx / lynx-160-102-16.s
index 864ab554fd6310574538abb9521f5396c0e08b4c..83e0c10afd8d8a8f1e99cc154554223e3b19c7a1 100644 (file)
@@ -199,6 +199,16 @@ INIT:
 ; Enable interrupts for VBL
        lda     #$80
        tsb     VTIMCTLA
+; Set up collision buffer to $A058
+       lda     #$58
+       sta     COLLBASL
+       lda     #$A0
+       sta     COLLBASH
+; Put collision index before sprite data
+       lda     #$FE
+       sta     COLLOFFL
+       lda     #$FF
+       sta     COLLOFFH
 ; Done, reset the error code
         lda     #TGI_ERR_OK
         sta     ERROR
@@ -245,6 +255,8 @@ GETERROR:
 ;
 ; To update displays you can call tgi_ioctl(4, 1) it will wait for the
 ; next VBL interrupt and swap draw and view buffers.
+;
+; Activate or deactivate collision detection by calling tgi_ioctl(5, 0/1).
 
 CONTROL:
         pha                    ; Almost all control routines succeed
@@ -252,6 +264,20 @@ CONTROL:
        sta     ERROR
        pla
 
+       cmp     #5
+       bne     ControlSwap
+       lda     ptr1
+       bne     @L0
+       lda     __sprsys
+       ora     #$20
+       bra     @L1
+@L0:   lda     __sprsys
+       and     #$df
+@L1:   sta     __sprsys
+       sta     SPRSYS
+       rts
+
+ControlSwap:
        cmp     #4
        bne     ControlFramerate