2 ; P/M mouse callbacks for the Ataris
4 ; Christian Groessler, 11.04.2014
6 ; All functions in this module should be interrupt safe, because they may
7 ; be called from an interrupt handler
12 .export _mouse_pm_callbacks
13 .constructor pm_init,27
16 ; get mouse shape data
18 .importzp mouse_pm_height
19 .importzp mouse_pm_hotspot_x
20 .importzp mouse_pm_hotspot_y
23 ; P/M definitions. The MOUSE_PM_NUM value can be changed to adjust the
24 ; number of the P/M used for the mouse. All others depend on this value.
25 ; Valid P/M numbers are 0 to 4. When 4 is used, the missiles are used
28 MOUSE_PM_NUM = 2 ; P/M used for the mouse
29 ; This cannot be changed since only player #2 uses the memory at $600.
31 MOUSE_PM_NUM = 4 ; P/M used for the mouse
32 ; Using player #4 (missiles) wastes the least amount of memory on the
33 ; atari target, since top of memory is typically at $xC20, and the
34 ; missiles use the space at $xB00-$xBFF.
35 ; On the atarixl target this configuration (not using page 6) is not
36 ; really satisfying since the top of memory typically lies beneath
37 ; the ROM and there is flickering visible while the ROM is banked in.
39 MOUSE_PM_BASE = pm_base ; ZP location pointing to the hw area used by the selected P/M
42 MOUSE_PM_RAW = 0 ; MOUSE_PM_RAW is the hardware P/M number for MOUSE_PM_NUM
54 MOUSE_PM_RAW = MOUSE_PM_NUM + 1
56 sta HPOSP0 + MOUSE_PM_NUM
60 ; ------------------------------------------------------------------------
73 ; ------------------------------------------------------------------------
77 omy: .res 1 ; old Mouse Y position
78 colhlp: .res 1 ; helper variable to set P/M color
80 ; ------------------------------------------------------------------------
82 .segment "EXTZP" : zeropage
86 ; ------------------------------------------------------------------------
90 ; Hide the mouse cursor.
95 ; Show the mouse cursor.
109 ; Move the mouse cursor x position to the value in A/X.
114 sbc #(mouse_pm_hotspot_x - 1) & $FF
118 ; Move the mouse cursor y position to the value in A/X.
121 sbc #(mouse_pm_hotspot_y - 1) & $FF
124 jsr clr_pm ; remove player at old position
128 ;jmp set_pm ; put player to new position
131 ; Set P/M data from 'mouse_pm_bits'
134 set_l: lda mouse_pm_bits,x
135 sta (MOUSE_PM_BASE),y
143 ; Clear (zero) P/M data
144 clr_pm: ldx #mouse_pm_height
147 clr_l: sta (MOUSE_PM_BASE),y
158 ; this assumes a GRAPHICS 0 screen
160 lda COLOR2 ; get background color
175 sta PCOLR0 + MOUSE_PM_NUM
177 sta SIZEP0 + MOUSE_PM_NUM
181 ; ------------------------------------------------------------------------
196 ; use top of memory and lower sp accordingly
200 and #7 ; offset within 2K
201 cmp #3 + MOUSE_PM_RAW + 1 ; can we use it?
206 @set: adc #3 + MOUSE_PM_RAW - 1 ; CF is set, so adding MOUSE_PM_RAW + 3
209 bne @cont ; jump always
213 sbc #8 - 1 ; CF is clear, subtracts 8
214 bcs @set ; jump always
221 @iniloo:sta (MOUSE_PM_BASE),y