2 ; Default mouse callbacks for the C128
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
15 .include "mouse-kernel.inc"
20 ; Sprite definitions. The first value can be changed to adjust the number
21 ; of the sprite used for the mouse. All others depend on this value.
22 MOUSE_SPR = 0 ; Sprite used for the mouse
23 MOUSE_SPR_MEM = $0E00 ; Memory location
24 MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
25 MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
26 VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
27 VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
29 ; --------------------------------------------------------------------------
30 ; Initialize the mouse sprite.
36 ; Copy the mouse sprite data
39 @L0: lda _mouse_def_pointershape,x
44 ; Set the mouse sprite pointer
46 lda #<(MOUSE_SPR_MEM / 64)
49 ; Set the mouse sprite color
51 lda _mouse_def_pointercolor
52 sta VIC_SPR0_COLOR + MOUSE_SPR
55 ; --------------------------------------------------------------------------
56 ; Hide the mouse pointer. Always called with interrupts disabled.
66 ; --------------------------------------------------------------------------
67 ; Show the mouse pointer. Always called with interrupts disabled.
75 ; --------------------------------------------------------------------------
76 ; Prepare to move the mouse pointer. Always called with interrupts disabled.
81 ; --------------------------------------------------------------------------
82 ; Draw the mouse pointer. Always called with interrupts disabled.
87 ; --------------------------------------------------------------------------
88 ; Move the mouse pointer X position to the value in a/x. Always called with
89 ; interrupts disabled.
93 ; Add the X correction and set the low byte. This frees A.
95 add #24 ; X correction
102 bne @L1 ; Branch if high byte not zero
103 lda VIC_SPR_HI_X ; Get high X bits of all sprites
104 and #MOUSE_SPR_NMASK ; Clear high bit for sprite
108 @L1: lda VIC_SPR_HI_X ; Get high X bits of all sprites
109 ora #MOUSE_SPR_MASK ; Set high bit for sprite
113 ; --------------------------------------------------------------------------
114 ; Move the mouse pointer Y position to the value in a/x. Always called with
115 ; interrupts disabled.
121 adc #50 ; FIXME: Should be NTSC, is PAL value
122 sta VIC_SPR_Y ; Set Y position
125 @L2: adc #50 ; Add PAL correction
126 sta VIC_SPR_Y ; Set Y position
129 ; --------------------------------------------------------------------------
134 _mouse_def_callbacks: