]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm510/mcbdefault.s
Merge pull request #283 from polluks/sp65
[cc65] / libsrc / cbm510 / mcbdefault.s
index b156fdf2f359c6a7efc53906b979c0203ec998a8..700dcebb11de6c138669603c7e9b02b858095953 100644 (file)
@@ -8,7 +8,10 @@
 ; be called from an interrupt handler.
 ;
 
+        .constructor    initmcb
         .export         _mouse_def_callbacks
+        .import         _mouse_def_pointershape
+        .import         _mouse_def_pointercolor
         .import         vic:zp
 
         .include        "mouse-kernel.inc"
 ; Sprite definitions. The first value can be changed to adjust the number
 ; of the sprite used for the mouse. All others depend on that value.
 MOUSE_SPR       = 0                             ; Sprite used for the mouse
+MOUSE_SPR_MEM   = $F400                         ; Memory location
 MOUSE_SPR_MASK  = $01 .shl MOUSE_SPR            ; Positive mask
 MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK)  ; Negative mask
 VIC_SPR_X       = (VIC_SPR0_X + 2*MOUSE_SPR)    ; Sprite X register
 VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
 
+; --------------------------------------------------------------------------
+; Initialize the mouse sprite.
+
+.segment        "ONCE"
+
+initmcb:
+
+; Copy the mouse sprite data
+
+        ldx     #64 - 1
+@L0:    lda     _mouse_def_pointershape,x
+        sta     MOUSE_SPR_MEM,x
+        dex
+        bpl     @L0
+
+; Set the mouse sprite pointer
+
+        lda     #<(MOUSE_SPR_MEM / 64)
+        sta     $F3F8 + MOUSE_SPR
+
+; Set the mouse sprite color
+
+        ldx     IndReg
+        lda     #15
+        sta     IndReg
+
+        lda     _mouse_def_pointercolor
+        ldy     #VIC_SPR0_COLOR + MOUSE_SPR
+        sta     (vic),y
+
+        stx     IndReg
+        rts
+
 ; --------------------------------------------------------------------------
 ; Hide the mouse pointer. Always called with interrupts disabled.
 
-.proc   hide
+.code
 
+hide:
         ldy     #15
         sty     IndReg
 
@@ -41,13 +79,10 @@ VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
         sty     IndReg
         rts
 
-.endproc
-
 ; --------------------------------------------------------------------------
 ; Show the mouse pointer. Always called with interrupts disabled.
 
-.proc   show
-
+show:
         ldy     #15
         sty     IndReg
 
@@ -58,34 +93,25 @@ VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
 
         ldy     ExecReg
         sty     IndReg
-        rts
-
-.endproc
+        ; Fall through
 
 ; --------------------------------------------------------------------------
-; Draw the mouse pointer. Always called with interrupts disabled.
-
-.proc   draw
-
-        rts
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
 
-.endproc
+prep:
+        ; Fall through
 
 ; --------------------------------------------------------------------------
-; Prepare to move the mouse pointer. Always called with interrupts disabled.
-
-.proc   move
+; Draw the mouse pointer. Always called with interrupts disabled.
 
+draw:
         rts
 
-.endproc
-
 ; --------------------------------------------------------------------------
 ; Move the mouse pointer x position to the value in .XA. Always called with
 ; interrupts disabled.
 
-.proc   movex
-
+movex:
         ldy     #15
         sty     IndReg
 
@@ -112,16 +138,13 @@ VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
 @L1:    lda     (vic),y                 ; Get high x bits of all sprites
         ora     #MOUSE_SPR_MASK         ; Set high bit for sprite
         sta     (vic),y
-        bnz     @L0                     ; branch always
-
-.endproc
+        bnz     @L0                     ; Branch always
 
 ; --------------------------------------------------------------------------
 ; Move the mouse pointer y position to the value in .XA. Always called with
 ; interrupts disabled.
 
-.proc   movey
-
+movey:
         ldy     #15
         sty     IndReg
 
@@ -133,8 +156,6 @@ VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
         sty     IndReg
         rts
 
-.endproc
-
 ; --------------------------------------------------------------------------
 ; Callback structure
 
@@ -143,7 +164,7 @@ VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
 _mouse_def_callbacks:
         .addr   hide
         .addr   show
+        .addr   prep
         .addr   draw
-        .addr   move
         .addr   movex
         .addr   movey