The Apple2 doesn't have sprites so the Apple2 mouse callbacks place a special character on the text screen to indicate the mouse position. In order to support the necessary character removing and redrawing the Apple2 mouse driver called the Apple2 mouse callbacks in an "unusual way". So far so (sort of) good.
However the upcoming Atari mouse driver aims to support both "sprite-type" mouse callbacks as well as "text-char-type" mouse callbacks. Therefore the interface between mouse drivers and callbacks needs to be extended to allow the mouse callbacks to hide their different types from the mouse driver.
The nature of this change can be seen best by looking at the Apple2 file modifications. The CBM drivers and callbacks (at least the current ones) don't benefit from this change.
.byte
CSHOW .addr
.byte
+ CDRAW .addr
+ .byte
+ CMOVE .addr
+ .byte
CMOVEX .addr
.byte
CMOVEY .addr
.struct MOUSE_CALLBACKS
HIDE .addr ; Hide the mouse cursor
SHOW .addr ; Show the mouse cursor
- MOVEX .addr ; Move the mouse cursor
- MOVEY .addr ; Dito for Y
+ 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
;------------------------------------------------------------------------------
; The mouse API version, stored in MOUSE_HDR::VERSION
-MOUSE_API_VERSION = $04
+MOUSE_API_VERSION = $05
;------------------------------------------------------------------------------
; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS.
.global mouse_uninstall
.global mouse_hide
.global mouse_show
- .global mouse_setbox
+ .global mouse_setbox
.global mouse_getbox
.global mouse_move
.global mouse_buttons
.global mouse_pos
.global mouse_info
.global mouse_ioctl
-
-
.bss
backup: .res 1
+visible:.res 1
; ------------------------------------------------------------------------
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr draw
+ .addr move
.addr movex
.addr movey
.ifdef __APPLE2ENH__
bit LOWSCR ; Doesn't hurt in 40 column mode
.endif
- rts
+return: rts
; Hide the mouse cursor.
hide:
+ dec visible
+ ; Fall through
+
+; Prepare to move the mouse cursor.
+move:
jsr getcursor ; Cursor visible at current position?
bne done ; No, we're done
lda backup ; Get character at cursor position
; Show the mouse cursor.
show:
+ inc visible
+ ; Fall through
+
+; Draw the mouse cursor.
+draw:
+ lda visible
+ beq return
jsr getcursor ; Cursor visible at current position?
beq done ; Yes, we're done
sta backup ; Save 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
+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
box: .tag MOUSE_BOX
info: .tag MOUSE_INFO
slot: .res 1
-visible:.res 1
; ------------------------------------------------------------------------
; no special action is required besides hiding the mouse cursor.
; No return code required.
HIDE:
- dec visible
sei
jsr CHIDE
cli
; no special action is required besides enabling the mouse cursor.
; No return code required.
SHOW:
- inc visible
+ sei
+ jsr CSHOW
+ cli
rts
; BUTTONS: Return the button mask in A/X.
beq :+
; Remove the cursor at the old position
-update: jsr CHIDE
+update: jsr CMOVE
; Get and set the new X position
ldy slot
stx info + MOUSE_POS::YCOORD+1
jsr CMOVEY
- ; Check for visibility
-: lda visible
- beq :+
-
; Draw the cursor at the new position
- jsr CSHOW
-: sec ; Interrupt handled
+: jsr CDRAW
+ sec ; Interrupt handled
rts
;
-; Default mouse callbacks for the C64
+; Default mouse callbacks for the C128
;
; Ullrich von Bassewitz, 2004-03-20
;
.endproc
+; --------------------------------------------------------------------------
+; Draw the mouse pointer. Always called with interrupts disabled.
+
+.proc draw
+
+ rts
+
+.endproc
+
+; --------------------------------------------------------------------------
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
+
+.proc move
+
+ rts
+
+.endproc
+
; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in a/x. Always called with
; interrupts disabled.
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr draw
+ .addr move
.addr movex
.addr movey
-
-
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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: lda SID_ADConv1 ; Get mouse X movement
+IRQ: jsr CMOVE
+ lda SID_ADConv1 ; Get mouse X movement
ldy OldPotX
jsr MoveCheck ; Calculate movement vector
sty OldPotX
; Done
- clc ; Interrupt not "handled"
-@SkipY: rts
+@SkipY: jsr CDRAW
+ clc ; Interrupt not "handled"
+ rts
; --------------------------------------------------------------------------
;
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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:
+IRQ: jsr CMOVE
; Record the state of the buttons.
; Try to avoid crosstalk between the keyboard and the lightpen.
; Done
-@SkipX: clc ; Interrupt not "handled"
+@SkipX: jsr CDRAW
+ clc ; Interrupt not "handled"
rts
; Move the lightpen pointer to the new Y pos.
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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: lda #$7F
+IRQ: jsr CMOVE
+ lda #$7F
sta CIA1_PRA
lda CIA1_PRB ; Read joystick #0
and #$1F
; Done
-@SkipY: clc ; Interrupt not "handled"
+@SkipY: jsr CDRAW
+ clc ; Interrupt not "handled"
rts
-
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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: lda #$7F
+IRQ: jsr CMOVE
+ lda #$7F
sta CIA1_PRA
lda CIA1_PRB ; Read port #1
and #%00001100
; Move the mouse pointer to the new X pos
tya
- jmp CMOVEY
+ jsr CMOVEY
+ jsr CDRAW
+ clc ; Interrupt not "handled"
+ rts
.endproc
+; --------------------------------------------------------------------------
+; Draw the mouse pointer. Always called with interrupts disabled.
+
+.proc draw
+
+ rts
+
+.endproc
+
+; --------------------------------------------------------------------------
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
+
+.proc move
+
+ rts
+
+.endproc
+
; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in a/x. Always called with
; interrupts disabled.
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr draw
+ .addr move
.addr movex
.addr movey
-
-
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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:
+IRQ: jsr CMOVE
; Record the state of the buttons.
; Avoid crosstalk between the keyboard and the mouse.
; Done
+@SkipY: jsr CDRAW
clc ; Interrupt not "handled"
-@SkipY: rts
+ rts
; --------------------------------------------------------------------------
;
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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:
+IRQ: jsr CMOVE
; Record the state of the buttons.
; Try to avoid crosstalk between the keyboard and the lightpen.
; Done
-@SkipX: clc ; Interrupt not "handled"
+@SkipX: jsr CDRAW
+ clc ; Interrupt not "handled"
rts
; Move the lightpen pointer to the new Y pos.
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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
+
; Avoid crosstalk between the keyboard and a joystick.
-IRQ: ldy #%00000000 ; Set ports A and B to input
+ ldy #%00000000 ; Set ports A and B to input
sty CIA1_DDRB
sty CIA1_DDRA ; Keyboard won't look like joystick
lda CIA1_PRB ; Read Control-Port 1
; Done
-@SkipY: clc ; Interrupt not handled
+@SkipY: jsr CDRAW
+ clc ; Interrupt not "handled"
rts
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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: lda #$7F
+IRQ: jsr CMOVE
+ lda #$7F
sta CIA1_PRA
lda CIA1_PRB ; Read port #1
and #%00001100
; Move the mouse pointer to the new X pos
tya
- jmp CMOVEY
+ jsr CMOVEY
+ jsr CDRAW
+ clc ; Interrupt not "handled"
+ rts
.endproc
+; --------------------------------------------------------------------------
+; Draw the mouse pointer. Always called with interrupts disabled.
+
+.proc draw
+
+ rts
+
+.endproc
+
+; --------------------------------------------------------------------------
+; Prepare to move the mouse pointer. Always called with interrupts disabled.
+
+.proc move
+
+ rts
+
+.endproc
+
; --------------------------------------------------------------------------
; Move the mouse pointer x position to the value in .XA. Always called with
; interrupts disabled.
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr draw
+ .addr move
.addr movex
.addr movey
-
-
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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: ldx #15 ; To system bank
+IRQ: jsr CMOVE
+ ldx #15 ; To system bank
stx IndReg
; Read the VIC-II lightpen registers.
; Done
-@SkipX: clc ; Interrupt not "handled"
+@SkipX: jsr CDRAW
+ clc ; Interrupt not "handled"
rts
; Move the lightpen pointer to the new Y pos.
CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show 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: ldy #15 ; Switch to the system bank
+IRQ: jsr CMOVE
+ ldy #15 ; Switch to the system bank
sty IndReg
; Get the direction bits.
; Done
-@SkipY: clc ; Interrupt not handled
+@SkipY: jsr CDRAW
+ clc ; Interrupt not "handled"
rts
; Move the mouse pointer to the new x pos.