]> git.sur5r.net Git - cc65/blobdiff - libsrc/c128/mcbdefault.s
add support for detecting 45GS02
[cc65] / libsrc / c128 / mcbdefault.s
index fcf742d14cb4dc044d816ef4bf57e8312c950216..eb521eb3abe53aefd63ff6305c2e6ad4548ec92b 100644 (file)
@@ -7,7 +7,10 @@
 ; be called from an interrupt handler
 ;
 
+        .constructor    initmcb
         .export         _mouse_def_callbacks
+        .import         _mouse_def_pointershape
+        .import         _mouse_def_pointercolor
 
         .include        "mouse-kernel.inc"
         .include        "c128.inc"
         .macpack        generic
 
 ; Sprite definitions. The first value can be changed to adjust the number
-; of the sprite used for the mouse.
+; of the sprite used for the mouse. All others depend on this value.
 MOUSE_SPR       = 0                             ; Sprite used for the mouse
+MOUSE_SPR_MEM   = $0E00                         ; 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
 
-.code
+; --------------------------------------------------------------------------
+; 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     $07F8 + MOUSE_SPR
+
+; Set the mouse sprite color
+
+        lda     _mouse_def_pointercolor
+        sta     VIC_SPR0_COLOR + MOUSE_SPR
+        rts
 
 ; --------------------------------------------------------------------------
 ; Hide the mouse pointer. Always called with interrupts disabled.
 
-.proc   hide
+.code
 
+hide:
         lda     #MOUSE_SPR_NMASK
         and     VIC_SPR_ENA
         sta     VIC_SPR_ENA
         rts
 
-.endproc
-
 ; --------------------------------------------------------------------------
 ; Show the mouse pointer. Always called with interrupts disabled.
 
-.proc   show
-
+show:
         lda     #MOUSE_SPR_MASK
         ora     VIC_SPR_ENA
         sta     VIC_SPR_ENA
-        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 a/x. Always called with
 ; interrupts disabled.
 
-.proc   movex
+movex:
 
 ; Add the X correction and set the low byte. This frees A.
 
@@ -92,27 +110,22 @@ VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
         sta     VIC_SPR_HI_X
         rts
 
-.endproc
-
 ; --------------------------------------------------------------------------
 ; Move the mouse pointer Y position to the value in a/x. Always called with
 ; interrupts disabled.
 
-.proc   movey
-
+movey:
         clc
         ldx     PALFLAG
-        bne     @L1
+        bne     @L2
         adc     #50                     ; FIXME: Should be NTSC, is PAL value
         sta     VIC_SPR_Y               ; Set Y position
         rts
 
-@L1:    adc     #50                     ; Add PAL correction
+@L2:    adc     #50                     ; Add PAL correction
         sta     VIC_SPR_Y               ; Set Y position
         rts
 
-.endproc
-
 ; --------------------------------------------------------------------------
 ; Callback structure
 
@@ -121,7 +134,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