.byte
CSHOW .addr
.byte
- CDRAW .addr
+ CPREP .addr
.byte
- CMOVE .addr
+ CDRAW .addr
.byte
CMOVEX .addr
.byte
.struct MOUSE_CALLBACKS
HIDE .addr ; Hide the mouse cursor
SHOW .addr ; Show the mouse cursor
+ PREP .addr ; Prepare to move the mouse cursor
DRAW .addr ; Draw the mouse cursor
- MOVE .addr ; Prepare to move the mouse cursor
MOVEX .addr ; Move the mouse cursor to X coord
MOVEY .addr ; Move the mouse cursor to Y coord
.endstruct
/* Hide the mouse cursor. */
void (*show) (void);
- /* Show the mouse cursor */
+ /* Show the mouse cursor. */
+
+ void (*prep) (void);
+ /* Prepare to move the mouse cursor. This function is called,
+ * even when the cursor is currently invisible.
+ */
+
+ void (*draw) (void);
+ /* Draw the mouse cursor. This function is called,
+ * even when the cursor is currently invisible.
+ */
void __fastcall__ (*movex) (int x);
/* Move the mouse cursor to the new X coordinate. This function is called,
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr prep
.addr draw
- .addr move
.addr movex
.addr movey
; Fall through
; Prepare to move the mouse cursor.
-move:
+prep:
jsr getcursor ; Cursor visible at current position?
bne done ; No, we're done
lda backup ; Get character at cursor position
; Callback table, set by the kernel before INSTALL is called
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
beq :+
; Remove the cursor at the old position
-update: jsr CMOVE
+update: jsr CPREP
; Get and set the new X position
ldy slot
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. Always called with interrupts disabled.
-.proc hide
-
+hide:
lda #MOUSE_SPR_NMASK
and VIC_SPR_ENA
sta VIC_SPR_ENA
rts
-.endproc
-
; --------------------------------------------------------------------------
; Show the mouse pointer. Always called with interrupts disabled.
-.proc show
-
+show:
lda #MOUSE_SPR_MASK
ora VIC_SPR_ENA
sta VIC_SPR_ENA
- rts
-
-.endproc
+ ; Fall through
; --------------------------------------------------------------------------
-; Draw the mouse pointer. Always called with interrupts disabled.
-
-.proc draw
-
- rts
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
-.endproc
+prep:
+ ; Fall through
; --------------------------------------------------------------------------
-; Prepare to move the mouse pointer. Always called with interrupts disabled.
-
-.proc move
+; Draw the mouse pointer. Always called with interrupts disabled.
+draw:
rts
-.endproc
-
; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in a/x. Always called with
; interrupts disabled.
-.proc movex
+movex:
; Add the X correction and set the low byte. This frees A.
sta VIC_SPR_HI_X
rts
-.endproc
-
; --------------------------------------------------------------------------
; Move the mouse pointer Y position to the value in a/x. Always called with
; interrupts disabled.
-.proc movey
-
+movey:
clc
ldx PALFLAG
- bne @L1
+ bne @L2
adc #50 ; FIXME: Should be NTSC, is PAL value
sta VIC_SPR_Y ; Set Y position
rts
-@L1: adc #50 ; Add PAL correction
+@L2: adc #50 ; Add PAL correction
sta VIC_SPR_Y ; Set Y position
rts
-.endproc
-
; --------------------------------------------------------------------------
; Callback structure
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr prep
.addr draw
- .addr move
.addr movex
.addr movey
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
; MUST return carry clear.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
lda SID_ADConv1 ; Get mouse X movement
ldy OldPotX
jsr MoveCheck ; Calculate movement vector
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X co-ord.
CMOVEY: jmp $0000 ; Move the cursor to Y co-ord.
; MUST return carry clear.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
; Record the state of the buttons.
; Try to avoid crosstalk between the keyboard and the lightpen.
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
; MUST return carry clear.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
lda #$7F
sta CIA1_PRA
lda CIA1_PRB ; Read joystick #0
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
; (so be careful).
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
lda #$7F
sta CIA1_PRA
lda CIA1_PRB ; Read port #1
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. Always called with interrupts disabled.
-.proc hide
-
+hide:
lda #MOUSE_SPR_NMASK
and VIC_SPR_ENA
sta VIC_SPR_ENA
rts
-.endproc
-
; --------------------------------------------------------------------------
; Show the mouse pointer. Always called with interrupts disabled.
-.proc show
-
+show:
lda #MOUSE_SPR_MASK
ora VIC_SPR_ENA
sta VIC_SPR_ENA
- rts
-
-.endproc
+ ; Fall through
; --------------------------------------------------------------------------
-; Draw the mouse pointer. Always called with interrupts disabled.
-
-.proc draw
-
- rts
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
-.endproc
+prep:
+ ; Fall through
; --------------------------------------------------------------------------
-; Prepare to move the mouse pointer. Always called with interrupts disabled.
-
-.proc move
+; Draw the mouse pointer. Always called with interrupts disabled.
+draw:
rts
-.endproc
-
; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in a/x. Always called with
; interrupts disabled.
-.proc movex
+movex:
; Add the X correction and set the low byte. This frees A.
sta VIC_SPR_HI_X
rts
-.endproc
-
; --------------------------------------------------------------------------
; Move the mouse pointer Y position to the value in a/x. Always called with
; interrupts disabled.
-.proc movey
-
+movey:
add #50 ; Y correction (first visible line)
sta VIC_SPR_Y ; Set Y position
rts
-.endproc
-
; --------------------------------------------------------------------------
; Callback structure
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr prep
.addr draw
- .addr move
.addr movex
.addr movey
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
; MUST return carry clear.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
; Record the state of the buttons.
; Avoid crosstalk between the keyboard and the mouse.
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X co-ord.
CMOVEY: jmp $0000 ; Move the cursor to Y co-ord.
; MUST return carry clear.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
; Record the state of the buttons.
; Try to avoid crosstalk between the keyboard and the lightpen.
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
; MUST return carry clear.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
; Avoid crosstalk between the keyboard and a joystick.
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
; (so be careful).
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
lda #$7F
sta CIA1_PRA
lda CIA1_PRB ; Read port #1
; --------------------------------------------------------------------------
; Hide the mouse pointer. Always called with interrupts disabled.
-.proc hide
-
+hide:
ldy #15
sty IndReg
sty IndReg
rts
-.endproc
-
; --------------------------------------------------------------------------
; Show the mouse pointer. Always called with interrupts disabled.
-.proc show
-
+show:
ldy #15
sty IndReg
ldy ExecReg
sty IndReg
- rts
-
-.endproc
+ ; Fall through
; --------------------------------------------------------------------------
-; Draw the mouse pointer. Always called with interrupts disabled.
-
-.proc draw
-
- rts
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
-.endproc
+prep:
+ ; Fall through
; --------------------------------------------------------------------------
-; Prepare to move the mouse pointer. Always called with interrupts disabled.
-
-.proc move
+; Draw the mouse pointer. Always called with interrupts disabled.
+draw:
rts
-.endproc
-
; --------------------------------------------------------------------------
; Move the mouse pointer x position to the value in .XA. Always called with
; interrupts disabled.
-.proc movex
-
+movex:
ldy #15
sty IndReg
@L1: lda (vic),y ; Get high x bits of all sprites
ora #MOUSE_SPR_MASK ; Set high bit for sprite
sta (vic),y
- bnz @L0 ; branch always
-
-.endproc
+ bnz @L0 ; Branch always
; --------------------------------------------------------------------------
; Move the mouse pointer y position to the value in .XA. Always called with
; interrupts disabled.
-.proc movey
-
+movey:
ldy #15
sty IndReg
sty IndReg
rts
-.endproc
-
; --------------------------------------------------------------------------
; Callback structure
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr prep
.addr draw
- .addr move
.addr movex
.addr movey
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X co-ord.
CMOVEY: jmp $0000 ; Move the cursor to Y co-ord.
; MUST return carry clear.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
ldx #15 ; To system bank
stx IndReg
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor
+CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
-CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to x co-ord.
CMOVEY: jmp $0000 ; Move the cursor to y co-ord.
; Reads joystick 2.
;
-IRQ: jsr CMOVE
+IRQ: jsr CPREP
ldy #15 ; Switch to the system bank
sty IndReg
show := MouseUp
; --------------------------------------------------------------------------
-; Move the mouse pointer X position to the value in .XA. Always called with
-; interrupts disabled.
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
-.proc movex
+prep:
+ ; Fall through
- rts
+; --------------------------------------------------------------------------
+; Draw the mouse pointer. Always called with interrupts disabled.
-.endproc
+draw:
+ ; Fall through
; --------------------------------------------------------------------------
-; Move the mouse pointer Y position to the value in .XA. Always called with
+; Move the mouse pointer X position to the value in .XA. Always called with
; interrupts disabled.
-.proc movey
+movex:
+ ; Fall through
- rts
+; --------------------------------------------------------------------------
+; Move the mouse pointer Y position to the value in .XA. Always called with
+; interrupts disabled.
-.endproc
+movey:
+ rts
; --------------------------------------------------------------------------
; Callback structure
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr prep
+ .addr draw
.addr movex
.addr movey
-
-