2 ; Default mouse callbacks for the CBM510 (P128)
4 ; 2004-03-20, Ullrich von Bassewitz2
5 ; 2013-06-25, Greg King
7 ; All functions in this module should be interrupt-safe because they might
8 ; be called from an interrupt handler.
12 .export _mouse_def_callbacks
13 .import _mouse_def_pointershape
14 .import _mouse_def_pointercolor
17 .include "mouse-kernel.inc"
22 ; Sprite definitions. The first value can be changed to adjust the number
23 ; of the sprite used for the mouse. All others depend on that value.
24 MOUSE_SPR = 0 ; Sprite used for the mouse
25 MOUSE_SPR_MEM = $F400 ; Memory location
26 MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
27 MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
28 VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
29 VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
31 ; --------------------------------------------------------------------------
32 ; Initialize the mouse sprite.
38 ; Copy the mouse sprite data
41 @L0: lda _mouse_def_pointershape,x
46 ; Set the mouse sprite pointer
48 lda #<(MOUSE_SPR_MEM / 64)
51 ; Set the mouse sprite color
57 lda _mouse_def_pointercolor
58 ldy #VIC_SPR0_COLOR + MOUSE_SPR
64 ; --------------------------------------------------------------------------
65 ; Hide the mouse pointer. Always called with interrupts disabled.
82 ; --------------------------------------------------------------------------
83 ; Show the mouse pointer. Always called with interrupts disabled.
98 ; --------------------------------------------------------------------------
99 ; Prepare to move the mouse pointer. Always called with interrupts disabled.
104 ; --------------------------------------------------------------------------
105 ; Draw the mouse pointer. Always called with interrupts disabled.
110 ; --------------------------------------------------------------------------
111 ; Move the mouse pointer x position to the value in .XA. Always called with
112 ; interrupts disabled.
118 ; Add the x correction; and, set the low byte. That frees .A.
120 add #<24 ; x correction
129 bnz @L1 ; Branch if high byte not zero
130 lda (vic),y ; Get high x bits of all sprites
131 and #MOUSE_SPR_NMASK ; Clear high bit for sprite
138 @L1: lda (vic),y ; Get high x bits of all sprites
139 ora #MOUSE_SPR_MASK ; Set high bit for sprite
141 bnz @L0 ; Branch always
143 ; --------------------------------------------------------------------------
144 ; Move the mouse pointer y position to the value in .XA. Always called with
145 ; interrupts disabled.
151 add #50 ; y correction (first visible line)
153 sta (vic),y ; Set y position
159 ; --------------------------------------------------------------------------
164 _mouse_def_callbacks: