; ; P/M mouse callbacks for the Ataris ; ; Christian Groessler, 11.04.2014 ; ; All functions in this module should be interrupt safe, because they may ; be called from an interrupt handler ; .include "atari.inc" .importzp sp .export _mouse_pm_callbacks .constructor pm_init,27 .destructor pm_down,7 ; get mouse shape data .import mouse_pm_bits .import mouse_pm_height .import mouse_pm_hotspot_x .import mouse_pm_hotspot_y ; P/M definitions. The first value can be changed to adjust the number ; of the P/M used for the mouse. All others depend on this value. ; Valid P/M numbers are 0 to 4. When 4 is used, the missiles are used ; as a player. MOUSE_PM_NUM = 2 ; P/M used for the mouse MOUSE_PM_BASE = pm_base ; ZP location pointing to the hw area used by the selected P/M .if MOUSE_PM_NUM = 4 MOUSE_PM_RAW = 0 ; MOUSE_PM_RAW is the hardware P/M number for MOUSE_PM_NUM .macro set_mouse_x ; assume CF = 0 sta HPOSM3 adc #2 sta HPOSM2 adc #2 sta HPOSM1 adc #2 sta HPOSM0 .endmacro .else MOUSE_PM_RAW = MOUSE_PM_NUM + 1 .macro set_mouse_x sta HPOSP0 + MOUSE_PM_NUM .endmacro .endif ; ------------------------------------------------------------------------ .rodata ; Callback structure _mouse_pm_callbacks: .addr hide .addr show .addr prep .addr draw .addr movex .addr movey ; ------------------------------------------------------------------------ .bss omy: .res 1 ; old Mouse Y position colhlp: .res 1 ; helper variable to set P/M color ; ------------------------------------------------------------------------ .segment "EXTZP" : zeropage pm_base:.res 2 ; ------------------------------------------------------------------------ .code ; Hide the mouse cursor. hide: lda #0 sta GRACTL rts ; Show the mouse cursor. show: .if MOUSE_PM_NUM < 4 lda #2 .else lda #1 .endif sta GRACTL ;rts ; optimized out prep: draw: rts ; Move the mouse cursor x position to the value in A/X. movex: cpx #1 ror a clc adc #48 sbc #<(mouse_pm_hotspot_x - 1) set_mouse_x jmp update_colors ; Move the mouse cursor y position to the value in A/X. movey: clc adc #32 sbc #<(mouse_pm_hotspot_y - 1) pha lda omy jsr clr_pm ; remove player at old position jsr update_colors pla sta omy ;jmp set_pm ; put player to new position ; fall thru ; Set P/M data from 'mouse_pm_bits' set_pm: tay ldx #0 set_l: lda mouse_pm_bits,x sta (MOUSE_PM_BASE),y inx iny beq set_end cpx #