From: Oliver Schmidt
Date: Wed, 15 Jan 2014 21:47:59 +0000 (+0100)
Subject: Harmonized interface between mouse drivers and callbacks.
X-Git-Tag: V2.15~200
X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4065cb198395d25845bfe07f1303c9e2a2f2fdc5;p=cc65
Harmonized interface between mouse drivers and callbacks.
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.
---
diff --git a/asminc/mouse-kernel.inc b/asminc/mouse-kernel.inc
index d3ec9b30f..4ad9a733e 100644
--- a/asminc/mouse-kernel.inc
+++ b/asminc/mouse-kernel.inc
@@ -78,6 +78,10 @@
.byte
CSHOW .addr
.byte
+ CDRAW .addr
+ .byte
+ CMOVE .addr
+ .byte
CMOVEX .addr
.byte
CMOVEY .addr
@@ -90,14 +94,16 @@
.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.
@@ -169,12 +175,10 @@ MOUSE_BTN_RIGHT = $01
.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
-
-
diff --git a/libsrc/apple2/mcbdefault.s b/libsrc/apple2/mcbdefault.s
index 2ade00aef..892e387e0 100644
--- a/libsrc/apple2/mcbdefault.s
+++ b/libsrc/apple2/mcbdefault.s
@@ -16,6 +16,7 @@
.bss
backup: .res 1
+visible:.res 1
; ------------------------------------------------------------------------
@@ -25,6 +26,8 @@ backup: .res 1
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr draw
+ .addr move
.addr movex
.addr movey
@@ -65,10 +68,15 @@ done:
.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
@@ -76,6 +84,13 @@ hide:
; 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
diff --git a/libsrc/apple2/mou/a2.stdmou.s b/libsrc/apple2/mou/a2.stdmou.s
index 8414cde36..ecfb7da58 100644
--- a/libsrc/apple2/mou/a2.stdmou.s
+++ b/libsrc/apple2/mou/a2.stdmou.s
@@ -57,6 +57,8 @@ status := $0778
; 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
@@ -67,7 +69,6 @@ CMOVEY: jmp $0000 ; Move the cursor to Y coord
box: .tag MOUSE_BOX
info: .tag MOUSE_INFO
slot: .res 1
-visible:.res 1
; ------------------------------------------------------------------------
@@ -321,7 +322,6 @@ MOVE:
; no special action is required besides hiding the mouse cursor.
; No return code required.
HIDE:
- dec visible
sei
jsr CHIDE
cli
@@ -333,7 +333,9 @@ HIDE:
; 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.
@@ -409,7 +411,7 @@ done: rts
beq :+
; Remove the cursor at the old position
-update: jsr CHIDE
+update: jsr CMOVE
; Get and set the new X position
ldy slot
@@ -427,11 +429,7 @@ update: jsr CHIDE
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
diff --git a/libsrc/c128/mcbdefault.s b/libsrc/c128/mcbdefault.s
index cdedf4904..fcf742d14 100644
--- a/libsrc/c128/mcbdefault.s
+++ b/libsrc/c128/mcbdefault.s
@@ -1,5 +1,5 @@
;
-; Default mouse callbacks for the C64
+; Default mouse callbacks for the C128
;
; Ullrich von Bassewitz, 2004-03-20
;
@@ -48,6 +48,24 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
.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.
@@ -103,7 +121,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr draw
+ .addr move
.addr movex
.addr movey
-
-
diff --git a/libsrc/c128/mou/c128-1351.s b/libsrc/c128/mou/c128-1351.s
index ca165f5c3..881605d2d 100644
--- a/libsrc/c128/mou/c128-1351.s
+++ b/libsrc/c128/mou/c128-1351.s
@@ -50,6 +50,8 @@ HEADER:
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
@@ -302,7 +304,8 @@ IOCTL: lda #