]> git.sur5r.net Git - cc65/blobdiff - libsrc/lynx/lynx-160-102-16.s
Clear __oserror on success.
[cc65] / libsrc / lynx / lynx-160-102-16.s
index f37723df9e1aaa1ca2178876a406e6f1efcb2fa6..83e0c10afd8d8a8f1e99cc154554223e3b19c7a1 100644 (file)
@@ -107,7 +107,6 @@ BGINDEX:        .res    1   ; Pen to use for text background
 ; Double buffer IRQ stuff
 DRAWPAGE:      .res    1
 SWAPREQUEST:   .res    1
-VBLHOOK:       .res    3
 
 text_bitmap:    .res   8*(1+20+1)+1
 ; 8 rows with (one offset-byte plus 20 character bytes plus one fill-byte) plus one 0-offset-byte
@@ -168,8 +167,6 @@ INSTALL:
        stz     BGINDEX
        stz     DRAWPAGE
        stz     SWAPREQUEST
-       lda     #$60            ; rts op-code
-       sta     VBLHOOK
         rts
 
 
@@ -199,6 +196,19 @@ UNINSTALL:
 ;
 
 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
@@ -246,26 +256,28 @@ 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.
 ;
-; Set an address for a subroutine you want to call at every VBL
-; tgi_ioctl(5, hook)
+; Activate or deactivate collision detection by calling tgi_ioctl(5, 0/1).
 
 CONTROL:
         pha                    ; Almost all control routines succeed
         lda     #TGI_ERR_OK
        sta     ERROR
        pla
+
        cmp     #5
-       bne ControlSwapRequest
-
-       lda     ptr1            ; Set IRQ routine to be called at VBL
-       sta     VBLHOOK+1
-       lda     ptr1+1
-       sta     VBLHOOK+2
-       lda     #$43            ; jmp op-code
-       sta     VBLHOOK
+       bne     ControlSwap
+       lda     ptr1
+       bne     @L0
+       lda     __sprsys
+       ora     #$20
+       bra     @L1
+@L0:   lda     __sprsys
+       and     #$df
+@L1:   sta     __sprsys
+       sta     SPRSYS
        rts
 
-ControlSwapRequest:
+ControlSwap:
        cmp     #4
        bne     ControlFramerate
 
@@ -280,6 +292,7 @@ ControlFramerate:
        cmp     #3
        bne     ControlTextBG
 
+       lda     ptr1
                cmp     #75             ; Set framerate
                beq     rate75
                cmp     #60
@@ -400,12 +413,12 @@ CLEAR:  lda     #<cls_sprite
 SETVIEWPAGE:
        cmp     #1
                beq     @L1             ; page == maxpages-1
-               ldy     #<$de20         ; page 0
-               ldx     #>$de20
+               ldy     #<$e018         ; page 0
+               ldx     #>$e018
                bra     @L2
 @L1:
-       ldy     #<$be40         ; page 1
-               ldx     #>$be40
+       ldy     #<$c038         ; page 1
+               ldx     #>$c038
 @L2:
                sty     VIEWPAGEL       ; Save viewpage for getpixel
                stx     VIEWPAGEH
@@ -433,14 +446,14 @@ SETVIEWPAGE:
 ;
 
 SETDRAWPAGE:
-       cmp     #1
+               cmp     #1
                beq     @L1                 ; page == maxpages-1
-               lda     #<$de20             ; page 0
-               ldx     #>$de20
+               lda     #<$e018             ; page 0
+               ldx     #>$e018
                bra     @L2
 @L1:
-        lda     #<$be40             ; page 1
-               ldx     #>$be40
+        lda     #<$c038             ; page 1
+               ldx     #>$c038
 @L2:
         sta     DRAWPAGEL
                stx     DRAWPAGEH
@@ -450,39 +463,24 @@ SETDRAWPAGE:
 ; IRQ: VBL interrupt handler
 ;
 
-TIMER0_INTERRUPT = $01
-TIMER1_INTERRUPT = $02
-TIMER2_INTERRUPT = $04
-TIMER3_INTERRUPT = $08
-TIMER4_INTERRUPT = $10
-TIMER5_INTERRUPT = $20
-TIMER6_INTERRUPT = $40
-TIMER7_INTERRUPT = $80
-
-HBL_INTERRUPT = TIMER0_INTERRUPT
-VBL_INTERRUPT = TIMER2_INTERRUPT
-SERIAL_INTERRUPT = TIMER4_INTERRUPT
-
 IRQ:
-       lda     INTSET          ; Poll all pending interrupts
-       and     #VBL_INTERRUPT
-        bne    IRQVBL
-       clc                     ; Not a VBL interrupt - exit
-       rts
-IRQVBL: 
-       lda     SWAPREQUEST
-       beq     @L0
-       lda     DRAWPAGE
-       jsr     SETVIEWPAGE
-       lda     DRAWPAGE
-       eor     #1
-       sta     DRAWPAGE
-       jsr     SETDRAWPAGE
-       stz     SWAPREQUEST
+               lda     INTSET          ; Poll all pending interrupts
+               and     #VBL_INTERRUPT
+        beq            IRQEND          ; Exit if not a VBL interrupt
+
+               lda     SWAPREQUEST
+               beq     @L0
+               lda     DRAWPAGE
+               jsr     SETVIEWPAGE
+               lda     DRAWPAGE
+               eor     #1
+               sta     DRAWPAGE
+               jsr     SETDRAWPAGE
+               stz     SWAPREQUEST
 @L0:
-       jsr     VBLHOOK
-       clc
-       rts
+IRQEND:
+               clc
+               rts
 
 ; ------------------------------------------------------------------------
 ; SETCOLOR: Set the drawing color (in A). The new color is already checked
@@ -1003,7 +1001,7 @@ text_c:
 ; The Font
 ; 96 characters from ASCII 32 to 127
 ; 8 pixels wide, 8 pixels high
-; bit value 0 = foreground, bit value 1 = background / transparent 
+; bit value 0 = foreground, bit value 1 = background / transparent
 font:
 ; VERSAIL
        .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF  ;32