]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/mou/atrtt.s
Merge pull request #122 from groessler/a5200
[cc65] / libsrc / atari / mou / atrtt.s
index 9d2dac1c971f201f9ca911acb71859deb7f28719..56f62636c4a154cd63f4e107b436736066837106 100644 (file)
@@ -13,7 +13,7 @@
 ; ------------------------------------------------------------------------
 ; Header. Includes jump table
 
-.segment        "JUMPTABLE"
+.segment        "HEADER"
 
 HEADER:
 
@@ -49,6 +49,8 @@ HEADER:
 
 CHIDE:  jmp     $0000                   ; Hide the cursor
 CSHOW:  jmp     $0000                   ; Show the cursor
+CPREP:  jmp     $0000                   ; Prepare to move the cursor
+CDRAW:  jmp     $0000                   ; Draw the cursor
 CMOVEX: jmp     $0000                   ; Move the cursor to X coord
 CMOVEY: jmp     $0000                   ; Move the cursor to Y coord
 
@@ -82,9 +84,6 @@ XMax:           .res    2               ; X2 value of bounding box
 YMax:           .res    2               ; Y2 value of bounding box
 Buttons:        .res    1               ; Button mask
 
-
-visible:        .res    1
-
 ; Default values for above variables
 
 .rodata
@@ -118,20 +117,14 @@ INSTALL:
         dex
         bpl     @L1
 
-; Be sure the mouse cursor is invisible and at the default location. We
-; need to do that here, because our mouse interrupt handler doesn't set the
-; mouse position if it hasn't changed.
+; Make sure the mouse cursor is at the default location.
 
-        php
-        sei
-        jsr     CHIDE
         lda     XPos
         ldx     XPos+1
         jsr     CMOVEX
         lda     YPos
         ldx     YPos+1
         jsr     CMOVEY
-        plp
 
 ; Done, return zero (= MOUSE_ERR_OK)
 
@@ -152,8 +145,7 @@ UNINSTALL       = HIDE                  ; Hide cursor on exit
 ; no special action is required besides hiding the mouse cursor.
 ; No return code required.
 
-HIDE:   dec     visible
-        php
+HIDE:   php
         sei
         jsr     CHIDE
         plp
@@ -166,8 +158,7 @@ HIDE:   dec     visible
 ; no special action is required besides enabling the mouse cursor.
 ; No return code required.
 
-SHOW:   inc     visible
-        php
+SHOW:   php
         sei
         jsr     CSHOW
         plp
@@ -226,14 +217,12 @@ MOVE:   php
         sei                             ; No interrupts
 
         pha
-        lda     visible
-        beq     @nohide
         txa
         pha
-        jsr     CHIDE
+        jsr     CPREP
         pla
         tax
-@nohide:pla
+        pla
 
         sta     YPos
         stx     YPos+1                  ; New Y position
@@ -246,15 +235,11 @@ MOVE:   php
         dey
         lda     (sp),y
         sta     XPos                    ; New X position
-
         jsr     CMOVEX                  ; Move the cursor
 
-        lda     visible
-        beq     @Ret
-        
         jsr     CSHOW
 
-@Ret:   plp                             ; Restore interrupt flag
+        plp                             ; Restore interrupt flag
         rts
 
 ;----------------------------------------------------------------------------
@@ -352,15 +337,16 @@ IRQ:
 
 @L02:   lda     PADDL0
         cmp     #228
-        beq     @Dont
+        beq     @Cont                   ; CF set if equal
         lda     PADDL1
-        cmp     #228
-        bne     @Do
-@Dont:  jmp     @Done
+        cmp     #228                    ; CF set if equal
 
-@Do:    lda     visible
-        beq     @L03
-        jsr     CHIDE
+@Cont:  php                             ; remember CF
+        jsr     CPREP
+        plp                             ; restore CF
+
+        bcc     @L03
+        jmp     @Show
 
 @L03:   ldx     #0
         stx     XPos+1
@@ -484,10 +470,8 @@ IRQ:
         tya
         jsr     CMOVEY
 
-        lda     visible
-        beq     @Done
-        jsr     CSHOW
+@Show:  jsr     CDRAW
 
-@Done:  clc                             ; Interrupt not "handled"
+        clc                             ; Interrupt not "handled"
         rts