]> git.sur5r.net Git - cc65/blobdiff - libsrc/c128/mou/c128-joy.s
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / libsrc / c128 / mou / c128-joy.s
index 8c3bd779d53412c95660b8d7adb9a0fcc2408487..be0cf227beb989530f396261762a37b74bacb9e6 100644 (file)
@@ -1,7 +1,8 @@
 ;
 ; Driver for a "joystick mouse".
 ;
-; Ullrich von Bassewitz, 2004-04-05, 2009-09-26
+; 2009-09-26, Ullrich von Bassewitz
+; 2014-03-17, Greg King
 ;
 
         .include        "zeropage.inc"
@@ -49,6 +50,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
 
@@ -83,21 +86,24 @@ XMax:           .res    2               ; X2 value of bounding box
 YMax:           .res    2               ; Y2 value of bounding box
 Buttons:        .res    1               ; Button mask
 
+INIT_save:      .res    1
+
 ; Temporary value used in the int handler
 
 Temp:           .res    1
 
-; Default values for above variables
-
 .rodata
 
+; Default values for above variables
+; (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
         .word   0                       ; XMin
         .word   0                       ; YMin
-        .word   SCREEN_WIDTH            ; XMax
-        .word   SCREEN_HEIGHT           ; YMax
+        .word   SCREEN_WIDTH - 1        ; XMax
+        .word   SCREEN_HEIGHT - 1       ; YMax
         .byte   0                       ; Buttons
 .endproc
 
@@ -110,6 +116,14 @@ Temp:           .res    1
 
 INSTALL:
 
+; Disable the BASIC interpreter's interrupt-driven sprite-motion code.
+; That allows direct access to the VIC-IIe's sprite registers.
+
+        lda     INIT_STATUS
+        sta     INIT_save
+        lda     #%11000000
+        sta     INIT_STATUS
+
 ; Initialize variables. Just copy the default stuff over
 
         ldx     #.sizeof(DefVars)-1
@@ -142,7 +156,11 @@ INSTALL:
 ; UNINSTALL routine. Is called before the driver is removed from memory.
 ; No return code required (the driver is removed from memory on return).
 
-UNINSTALL       = HIDE                  ; Hide cursor on exit
+UNINSTALL:
+        jsr     HIDE                    ; Hide cursor on exit
+        lda     INIT_save
+        sta     INIT_STATUS
+        rts
 
 ;----------------------------------------------------------------------------
 ; HIDE routine. Is called to hide the mouse pointer. The mouse kernel manages
@@ -301,7 +319,8 @@ IOCTL:  lda     #<MOUSE_ERR_INV_IOCTL     ; We don't support ioclts for now
 ; MUST return carry clear.
 ;
 
-IRQ:    lda     #$7F
+IRQ:    jsr     CPREP
+        lda     #$7F
         sta     CIA1_PRA
         lda     CIA1_PRB                ; Read joystick #0
         and     #$1F
@@ -414,6 +433,6 @@ IRQ:    lda     #$7F
 
 ; Done
 
-@SkipY: clc                             ; Interrupt not "handled"
+@SkipY: jsr     CDRAW
+        clc                             ; Interrupt not "handled"
         rts
-