Mouse driver implementation

git-svn-id: svn://svn.cc65.org/cc65/trunk@2957 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2004-03-23 21:54:24 +00:00
parent 5f3ed8826f
commit 31595342d6
2 changed files with 105 additions and 67 deletions

View File

@@ -2,6 +2,9 @@
; Default mouse callbacks for the C64
;
; Ullrich von Bassewitz, 2004-03-20
;
; All functions in this module should be interrupt safe, because they may
; be called from an interrupt handler
;
.export _mouse_def_callbacks
@@ -9,6 +12,7 @@
.include "mouse-kernel.inc"
.include "c64.inc"
.macpack generic
; Sprite definitions. The first value can be changed to adjust the number
; of the sprite used for the mouse.
@@ -18,71 +22,74 @@ 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
.code
; --------------------------------------------------------------------------
; Hide the mouse pointer
; Hide the mouse pointer. Always called with interrupts disabled.
.proc hide
lda #MOUSE_SPR_NMASK
sei
and VIC_SPR_ENA
sta VIC_SPR_ENA
cli
rts
.endproc
; --------------------------------------------------------------------------
; Show the mouse pointer
; Show the mouse pointer. Always called with interrupts disabled.
.proc show
lda #MOUSE_SPR_MASK
sei
ora VIC_SPR_ENA
sta VIC_SPR_ENA
cli
rts
.endproc
; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in a/x
; Move the mouse pointer X position to the value in a/x. Always called with
; interrupts disabled.
.proc movex
; Set the low byte, this frees A
; 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 ; Test high byte of X coord
bne @L1
sei
txa
adc #0
bne @L1 ; Branch if high byte not zero
lda VIC_SPR_HI_X ; Get high X bits of all sprites
and #MOUSE_SPR_NMASK ; Clear high bit for sprite
sta VIC_SPR_HI_X
cli
rts
@L1: sei
lda VIC_SPR_HI_X ; Get high X bits of all sprites
ora #MOUSE_SPR_NMASK ; Set high bit for sprite
@L1: lda VIC_SPR_HI_X ; Get high X bits of all sprites
ora #MOUSE_SPR_MASK ; Set high bit for sprite
sta VIC_SPR_HI_X
cli
rts
.endproc
; --------------------------------------------------------------------------
; Move the mouse pointer Y position to the value in a/x
; Move the mouse pointer Y position to the value in a/x. Always called with
; interrupts disabled.
.proc movey
clc
ldx PALFLAG
bne @L1
adc #50 ; FIXME: Should be NTSC, is PAL value
sta VIC_SPR_Y ; Set Y position
rts
@L1: adc #50 ; Add PAL correction
sta VIC_SPR_Y ; Set Y position
rts
@@ -100,4 +107,3 @@ _mouse_def_callbacks:
.addr movey