2004-03-29 17:27:48 +00:00
|
|
|
;
|
2014-01-15 21:47:59 +00:00
|
|
|
; Default mouse callbacks for the C128
|
2004-03-29 17:27:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2004-03-20
|
|
|
|
;
|
|
|
|
; All functions in this module should be interrupt safe, because they may
|
|
|
|
; be called from an interrupt handler
|
|
|
|
;
|
|
|
|
|
2015-10-09 16:33:35 +00:00
|
|
|
.constructor initmcb
|
2004-03-29 17:27:48 +00:00
|
|
|
.export _mouse_def_callbacks
|
2015-10-09 16:33:35 +00:00
|
|
|
.import _mouse_def_pointershape
|
|
|
|
.import _mouse_def_pointercolor
|
2004-03-29 17:27:48 +00:00
|
|
|
|
|
|
|
.include "mouse-kernel.inc"
|
|
|
|
.include "c128.inc"
|
|
|
|
|
|
|
|
.macpack generic
|
|
|
|
|
|
|
|
; Sprite definitions. The first value can be changed to adjust the number
|
2015-10-09 16:33:35 +00:00
|
|
|
; of the sprite used for the mouse. All others depend on this value.
|
2004-03-29 17:27:48 +00:00
|
|
|
MOUSE_SPR = 0 ; Sprite used for the mouse
|
2015-10-09 16:33:35 +00:00
|
|
|
MOUSE_SPR_MEM = $0E00 ; Memory location
|
2004-03-29 17:27:48 +00:00
|
|
|
MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
|
|
|
|
MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
|
|
|
|
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
|
|
|
|
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
|
|
|
|
|
2015-10-09 16:33:35 +00:00
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Initialize the mouse sprite.
|
|
|
|
|
2016-03-06 20:26:22 +00:00
|
|
|
.segment "ONCE"
|
2015-10-09 16:33:35 +00:00
|
|
|
|
|
|
|
initmcb:
|
|
|
|
|
|
|
|
; Copy the mouse sprite data
|
|
|
|
|
|
|
|
ldx #64 - 1
|
|
|
|
@L0: lda _mouse_def_pointershape,x
|
|
|
|
sta MOUSE_SPR_MEM,x
|
|
|
|
dex
|
|
|
|
bpl @L0
|
|
|
|
|
|
|
|
; Set the mouse sprite pointer
|
|
|
|
|
|
|
|
lda #<(MOUSE_SPR_MEM / 64)
|
|
|
|
sta $07F8 + MOUSE_SPR
|
|
|
|
|
|
|
|
; Set the mouse sprite color
|
|
|
|
|
|
|
|
lda _mouse_def_pointercolor
|
|
|
|
sta VIC_SPR0_COLOR + MOUSE_SPR
|
|
|
|
rts
|
|
|
|
|
2004-03-29 17:27:48 +00:00
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Hide the mouse pointer. Always called with interrupts disabled.
|
|
|
|
|
2015-10-09 16:33:35 +00:00
|
|
|
.code
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
hide:
|
2004-03-29 17:27:48 +00:00
|
|
|
lda #MOUSE_SPR_NMASK
|
|
|
|
and VIC_SPR_ENA
|
|
|
|
sta VIC_SPR_ENA
|
|
|
|
rts
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Show the mouse pointer. Always called with interrupts disabled.
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
show:
|
2004-03-29 17:27:48 +00:00
|
|
|
lda #MOUSE_SPR_MASK
|
|
|
|
ora VIC_SPR_ENA
|
|
|
|
sta VIC_SPR_ENA
|
2014-01-17 20:09:15 +00:00
|
|
|
; Fall through
|
2004-03-29 17:27:48 +00:00
|
|
|
|
2014-01-15 21:47:59 +00:00
|
|
|
; --------------------------------------------------------------------------
|
2014-01-17 20:09:15 +00:00
|
|
|
; Prepare to move the mouse pointer. Always called with interrupts disabled.
|
2014-01-15 21:47:59 +00:00
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
prep:
|
|
|
|
; Fall through
|
2014-01-15 21:47:59 +00:00
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
2014-01-17 20:09:15 +00:00
|
|
|
; Draw the mouse pointer. Always called with interrupts disabled.
|
2014-01-15 21:47:59 +00:00
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
draw:
|
2014-01-15 21:47:59 +00:00
|
|
|
rts
|
|
|
|
|
2004-03-29 17:27:48 +00:00
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Move the mouse pointer X position to the value in a/x. Always called with
|
|
|
|
; interrupts disabled.
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
movex:
|
2004-03-29 17:27:48 +00:00
|
|
|
|
|
|
|
; Add the X correction and set the low byte. This frees A.
|
|
|
|
|
|
|
|
add #24 ; X correction
|
|
|
|
sta VIC_SPR_X
|
|
|
|
|
|
|
|
; Set the high byte
|
|
|
|
|
|
|
|
txa
|
|
|
|
adc #0
|
|
|
|
bne @L1 ; Branch if high byte not zero
|
2013-05-09 11:56:54 +00:00
|
|
|
lda VIC_SPR_HI_X ; Get high X bits of all sprites
|
|
|
|
and #MOUSE_SPR_NMASK ; Clear high bit for sprite
|
2004-03-29 17:27:48 +00:00
|
|
|
sta VIC_SPR_HI_X
|
|
|
|
rts
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
@L1: lda VIC_SPR_HI_X ; Get high X bits of all sprites
|
|
|
|
ora #MOUSE_SPR_MASK ; Set high bit for sprite
|
2004-03-29 17:27:48 +00:00
|
|
|
sta VIC_SPR_HI_X
|
|
|
|
rts
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Move the mouse pointer Y position to the value in a/x. Always called with
|
|
|
|
; interrupts disabled.
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
movey:
|
2004-03-29 17:27:48 +00:00
|
|
|
clc
|
|
|
|
ldx PALFLAG
|
2014-01-17 20:09:15 +00:00
|
|
|
bne @L2
|
2004-03-29 17:27:48 +00:00
|
|
|
adc #50 ; FIXME: Should be NTSC, is PAL value
|
2013-05-09 11:56:54 +00:00
|
|
|
sta VIC_SPR_Y ; Set Y position
|
2004-03-29 17:27:48 +00:00
|
|
|
rts
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
@L2: adc #50 ; Add PAL correction
|
2013-05-09 11:56:54 +00:00
|
|
|
sta VIC_SPR_Y ; Set Y position
|
2004-03-29 17:27:48 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Callback structure
|
|
|
|
|
|
|
|
.rodata
|
|
|
|
|
|
|
|
_mouse_def_callbacks:
|
|
|
|
.addr hide
|
|
|
|
.addr show
|
2014-01-17 20:09:15 +00:00
|
|
|
.addr prep
|
2014-01-15 21:47:59 +00:00
|
|
|
.addr draw
|
2004-03-29 17:27:48 +00:00
|
|
|
.addr movex
|
|
|
|
.addr movey
|