2 ; Default mouse callbacks for the C64
4 ; Ullrich von Bassewitz, 2004-03-20
6 ; All functions in this module should be interrupt safe, because they may
7 ; be called from an interrupt handler
11 .export _mouse_def_callbacks
12 .import _mouse_def_pointershape
13 .import _mouse_def_pointercolor
14 .import mcb_spritememory
15 .import mcb_spritepointer
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 this value.
24 MOUSE_SPR = 0 ; Sprite used for the mouse
25 MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
26 MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
27 VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
28 VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
30 ; --------------------------------------------------------------------------
31 ; Initialize the mouse sprite.
37 ; Make all RAM accessible
44 ; Copy the mouse sprite data
47 @L0: lda _mouse_def_pointershape,x
48 sta mcb_spritememory,x
52 ; Set the mouse sprite pointer
54 lda #<(mcb_spritememory / 64)
55 sta mcb_spritepointer + MOUSE_SPR
57 ; Restore memory configuration
62 ; Set the mouse sprite color
64 lda _mouse_def_pointercolor
65 sta VIC_SPR0_COLOR + MOUSE_SPR
68 ; --------------------------------------------------------------------------
69 ; Hide the mouse pointer. Always called with interrupts disabled.
79 ; --------------------------------------------------------------------------
80 ; Show the mouse pointer. Always called with interrupts disabled.
88 ; --------------------------------------------------------------------------
89 ; Prepare to move the mouse pointer. Always called with interrupts disabled.
94 ; --------------------------------------------------------------------------
95 ; Draw the mouse pointer. Always called with interrupts disabled.
100 ; --------------------------------------------------------------------------
101 ; Move the mouse pointer X position to the value in a/x. Always called with
102 ; interrupts disabled.
106 ; Add the X correction and set the low byte. This frees A.
108 add #24 ; X correction
115 bne @L1 ; Branch if high byte not zero
116 lda VIC_SPR_HI_X ; Get high X bits of all sprites
117 and #MOUSE_SPR_NMASK ; Clear high bit for sprite
121 @L1: lda VIC_SPR_HI_X ; Get high X bits of all sprites
122 ora #MOUSE_SPR_MASK ; Set high bit for sprite
126 ; --------------------------------------------------------------------------
127 ; Move the mouse pointer Y position to the value in a/x. Always called with
128 ; interrupts disabled.
131 add #50 ; Y correction (first visible line)
132 sta VIC_SPR_Y ; Set Y position
135 ; --------------------------------------------------------------------------
140 _mouse_def_callbacks: