]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/mou/atrjoy.s
Reduced clutter in root dir.
[cc65] / libsrc / atari / mou / atrjoy.s
index 1a5afa71a6d2ae3f19ea4d94840149a5ddc18842..7f1085fb87bdbf140f8808f6269fa35ec95306f4 100644 (file)
         .include        "atari.inc"
 
         .macpack        generic
+        .macpack        module
 
 ; ------------------------------------------------------------------------
 ; Header. Includes jump table
 
-.segment        "JUMPTABLE"
+.ifdef __ATARIXL__
+        module_header   _atrxjoy_mou
+.else
+        module_header   _atrjoy_mou
+.endif
 
 HEADER:
 
@@ -50,6 +55,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
 
@@ -85,12 +92,13 @@ Buttons:        .res    1               ; Button mask
 
 
 Temp:           .res    1               ; Temporary value used in the int handler
-visible:        .res    1
 
 ; Default values for above variables
 
 .rodata
 
+; (We use ".proc" because we want to define both a label and a scope.)
+
 .proc   DefVars
         .word   SCREEN_HEIGHT/2         ; YPos
         .word   SCREEN_WIDTH/2          ; XPos
@@ -118,19 +126,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.
 
-        sei
-        jsr     CHIDE
         lda     XPos
         ldx     XPos+1
         jsr     CMOVEX
         lda     YPos
         ldx     YPos+1
         jsr     CMOVEY
-        cli
 
 ; Done, return zero (= MOUSE_ERR_OK)
 
@@ -151,10 +154,10 @@ UNINSTALL       = HIDE                  ; Hide cursor on exit
 ; no special action is required besides hiding the mouse cursor.
 ; No return code required.
 
-HIDE:   dec     visible
+HIDE:   php
         sei
         jsr     CHIDE
-        cli
+        plp
         rts
 
 ;----------------------------------------------------------------------------
@@ -164,10 +167,10 @@ HIDE:   dec     visible
 ; no special action is required besides enabling the mouse cursor.
 ; No return code required.
 
-SHOW:   inc     visible
+SHOW:   php
         sei
         jsr     CSHOW
-        cli
+        plp
         rts
 
 ;----------------------------------------------------------------------------
@@ -181,6 +184,7 @@ SETBOX: sta     ptr1
         stx     ptr1+1                  ; Save data pointer
 
         ldy     #.sizeof (MOUSE_BOX)-1
+        php
         sei
 
 @L1:    lda     (ptr1),y
@@ -188,7 +192,7 @@ SETBOX: sta     ptr1
         dey
         bpl     @L1
 
-        cli
+        plp
         rts
 
 ;----------------------------------------------------------------------------
@@ -199,6 +203,7 @@ GETBOX: sta     ptr1
         stx     ptr1+1                  ; Save data pointer
 
         ldy     #.sizeof (MOUSE_BOX)-1
+        php
         sei
 
 @L1:    lda     XMin,y
@@ -206,7 +211,7 @@ GETBOX: sta     ptr1
         dey
         bpl     @L1
 
-        cli
+        plp
         rts
 
 ;----------------------------------------------------------------------------
@@ -217,12 +222,13 @@ GETBOX: sta     ptr1
 ; the screen). No return code required.
 ;
 
-MOVE:   sei                             ; No interrupts
+MOVE:   php
+        sei                             ; No interrupts
 
         pha
         txa
         pha
-        jsr     CHIDE
+        jsr     CPREP
         pla
         tax
         pla
@@ -238,15 +244,11 @@ MOVE:   sei                             ; No interrupts
         dey
         lda     (sp),y
         sta     XPos                    ; New X position
-
         jsr     CMOVEX                  ; Move the cursor
 
-        lda     visible
-        beq     @Ret
-        
-        jsr     CSHOW
+        jsr     CDRAW
 
-@Ret:   cli                             ; Allow interrupts
+        plp                             ; Restore interrupt flag
         rts
 
 ;----------------------------------------------------------------------------
@@ -263,6 +265,7 @@ BUTTONS:
 
 POS:    ldy     #MOUSE_POS::XCOORD      ; Structure offset
 
+        php
         sei                             ; Disable interrupts
         lda     XPos                    ; Transfer the position
         sta     (ptr1),y
@@ -273,7 +276,7 @@ POS:    ldy     #MOUSE_POS::XCOORD      ; Structure offset
         iny
         sta     (ptr1),y
         lda     YPos+1
-        cli                             ; Enable interrupts
+        plp                             ; Restore interrupt flag
 
         iny
         sta     (ptr1),y                ; Store last byte
@@ -307,7 +310,7 @@ INFO:   jsr     POS
 
 IOCTL:  lda     #<MOUSE_ERR_INV_IOCTL     ; We don't support ioclts for now
         ldx     #>MOUSE_ERR_INV_IOCTL
-hlprts: rts
+        rts
 
 ;----------------------------------------------------------------------------
 ; IRQ: Irq handler entry point. Called as a subroutine but in IRQ context
@@ -330,10 +333,8 @@ IRQ:
         and     #15                     ; clear joystick #1 bits
         eor     #15
         sta     Temp
-        clc
-        beq     hlprts                  ; no movement, do nothing
 
-        jsr     CHIDE
+        jsr     CPREP
 
 ; Check left/right
 
@@ -433,11 +434,7 @@ IRQ:
 
 ; Done
 
-@SkipY: lda     visible
-        beq     @Done
-
-        jsr     CSHOW
-
-@Done:  clc                             ; Interrupt not "handled"
+@SkipY: jsr     CDRAW
+        clc                             ; Interrupt not "handled"
         rts