2013-08-23 07:06:00 +00:00
|
|
|
;
|
|
|
|
; Default mouse callbacks for the CBM510 (P128)
|
|
|
|
;
|
|
|
|
; 2004-03-20, Ullrich von Bassewitz2
|
|
|
|
; 2013-06-25, Greg King
|
|
|
|
;
|
|
|
|
; All functions in this module should be interrupt-safe because they might
|
|
|
|
; be called from an interrupt handler.
|
|
|
|
;
|
|
|
|
|
2015-10-09 16:33:35 +00:00
|
|
|
.constructor initmcb
|
2013-08-23 07:06:00 +00:00
|
|
|
.export _mouse_def_callbacks
|
2015-10-09 16:33:35 +00:00
|
|
|
.import _mouse_def_pointershape
|
|
|
|
.import _mouse_def_pointercolor
|
2013-08-23 07:06:00 +00:00
|
|
|
.import vic:zp
|
|
|
|
|
|
|
|
.include "mouse-kernel.inc"
|
|
|
|
.include "cbm510.inc"
|
|
|
|
|
|
|
|
.macpack generic
|
|
|
|
|
|
|
|
; Sprite definitions. The first value can be changed to adjust the number
|
|
|
|
; of the sprite used for the mouse. All others depend on that value.
|
2020-11-28 02:19:49 +00:00
|
|
|
MOUSE_SPR = 0 ; Sprite used for the mouse
|
|
|
|
MOUSE_SPR_MEM = $F400 ; Memory location
|
|
|
|
MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
|
|
|
|
MOUSE_SPR_NMASK = .lobyte(.bitnot 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
|
2013-08-23 07:06:00 +00:00
|
|
|
|
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 $F3F8 + MOUSE_SPR
|
|
|
|
|
|
|
|
; Set the mouse sprite color
|
|
|
|
|
|
|
|
ldx IndReg
|
|
|
|
lda #15
|
|
|
|
sta IndReg
|
|
|
|
|
|
|
|
lda _mouse_def_pointercolor
|
2015-10-10 09:15:43 +00:00
|
|
|
ldy #VIC_SPR0_COLOR + MOUSE_SPR
|
2015-10-09 16:33:35 +00:00
|
|
|
sta (vic),y
|
|
|
|
|
|
|
|
stx IndReg
|
|
|
|
rts
|
|
|
|
|
2013-08-23 07:06:00 +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:
|
2013-08-23 07:06:00 +00:00
|
|
|
ldy #15
|
|
|
|
sty IndReg
|
|
|
|
|
|
|
|
ldy #VIC_SPR_ENA
|
|
|
|
lda (vic),y
|
|
|
|
and #MOUSE_SPR_NMASK
|
|
|
|
sta (vic),y
|
|
|
|
|
|
|
|
ldy ExecReg
|
|
|
|
sty IndReg
|
|
|
|
rts
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Show the mouse pointer. Always called with interrupts disabled.
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
show:
|
2013-08-23 07:06:00 +00:00
|
|
|
ldy #15
|
|
|
|
sty IndReg
|
|
|
|
|
|
|
|
ldy #VIC_SPR_ENA
|
|
|
|
lda (vic),y
|
|
|
|
ora #MOUSE_SPR_MASK
|
|
|
|
sta (vic),y
|
|
|
|
|
|
|
|
ldy ExecReg
|
|
|
|
sty IndReg
|
2014-01-17 20:09:15 +00:00
|
|
|
; Fall through
|
2013-08-23 07:06:00 +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
|
|
|
|
|
2013-08-23 07:06:00 +00:00
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Move the mouse pointer x position to the value in .XA. Always called with
|
|
|
|
; interrupts disabled.
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
movex:
|
2013-08-23 07:06:00 +00:00
|
|
|
ldy #15
|
|
|
|
sty IndReg
|
|
|
|
|
|
|
|
; Add the x correction; and, set the low byte. That frees .A.
|
|
|
|
|
|
|
|
add #<24 ; x correction
|
|
|
|
ldy #VIC_SPR_X
|
|
|
|
sta (vic),y
|
|
|
|
|
|
|
|
; Set the high byte
|
|
|
|
|
|
|
|
ldy #VIC_SPR_HI_X
|
|
|
|
txa
|
|
|
|
adc #>24
|
|
|
|
bnz @L1 ; Branch if high byte not zero
|
|
|
|
lda (vic),y ; Get high x bits of all sprites
|
|
|
|
and #MOUSE_SPR_NMASK ; Clear high bit for sprite
|
|
|
|
sta (vic),y
|
|
|
|
|
|
|
|
@L0: ldy ExecReg
|
|
|
|
sty IndReg
|
|
|
|
rts
|
|
|
|
|
|
|
|
@L1: lda (vic),y ; Get high x bits of all sprites
|
|
|
|
ora #MOUSE_SPR_MASK ; Set high bit for sprite
|
|
|
|
sta (vic),y
|
2014-01-17 20:09:15 +00:00
|
|
|
bnz @L0 ; Branch always
|
2013-08-23 07:06:00 +00:00
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
; Move the mouse pointer y position to the value in .XA. Always called with
|
|
|
|
; interrupts disabled.
|
|
|
|
|
2014-01-17 20:09:15 +00:00
|
|
|
movey:
|
2013-08-23 07:06:00 +00:00
|
|
|
ldy #15
|
|
|
|
sty IndReg
|
|
|
|
|
|
|
|
add #50 ; y correction (first visible line)
|
|
|
|
ldy #VIC_SPR_Y
|
|
|
|
sta (vic),y ; Set y position
|
|
|
|
|
|
|
|
ldy ExecReg
|
|
|
|
sty IndReg
|
|
|
|
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
|
2013-08-23 07:06:00 +00:00
|
|
|
.addr movex
|
|
|
|
.addr movey
|