Adapt to new mouse driver interface ('prep' and 'draw')

This commit is contained in:
Christian Groessler
2014-01-18 00:02:29 +01:00
parent f5e7e92a35
commit 012268b8e8
3 changed files with 36 additions and 51 deletions

View File

@@ -21,6 +21,7 @@
.bss .bss
backup: .res 1 backup: .res 1
visible:.res 1
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@@ -36,6 +37,8 @@ scrptr: .res 2
_mouse_def_callbacks: _mouse_def_callbacks:
.addr hide .addr hide
.addr show .addr show
.addr prep
.addr draw
.addr movex .addr movex
.addr movey .addr movey
@@ -66,6 +69,9 @@ done:
; Hide the mouse cursor. ; Hide the mouse cursor.
hide: hide:
dec visible
prep:
jsr getcursor ; Get character at cursor position jsr getcursor ; Get character at cursor position
cmp #cursor ; "mouse" character cmp #cursor ; "mouse" character
bne overwr ; no, probably program has overwritten it bne overwr ; no, probably program has overwritten it
@@ -76,6 +82,11 @@ overwr: sta backup
; Show the mouse cursor. ; Show the mouse cursor.
show: show:
inc visible
draw:
lda visible
beq done
jsr getcursor ; Cursor visible at current position? jsr getcursor ; Cursor visible at current position?
sta backup ; Save character at cursor position sta backup ; Save character at cursor position
lda #cursor lda #cursor

View File

@@ -50,6 +50,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -85,7 +87,6 @@ Buttons: .res 1 ; Button mask
Temp: .res 1 ; Temporary value used in the int handler Temp: .res 1 ; Temporary value used in the int handler
visible: .res 1
; Default values for above variables ; Default values for above variables
@@ -120,9 +121,8 @@ INSTALL:
dex dex
bpl @L1 bpl @L1
; Be sure the mouse cursor is invisible and at the default location. ; Make sure the mouse cursor is at the default location.
jsr CHIDE
lda XPos lda XPos
ldx XPos+1 ldx XPos+1
jsr CMOVEX jsr CMOVEX
@@ -149,8 +149,7 @@ UNINSTALL = HIDE ; Hide cursor on exit
; no special action is required besides hiding the mouse cursor. ; no special action is required besides hiding the mouse cursor.
; No return code required. ; No return code required.
HIDE: dec visible HIDE: php
php
sei sei
jsr CHIDE jsr CHIDE
plp plp
@@ -163,8 +162,7 @@ HIDE: dec visible
; no special action is required besides enabling the mouse cursor. ; no special action is required besides enabling the mouse cursor.
; No return code required. ; No return code required.
SHOW: inc visible SHOW: php
php
sei sei
jsr CSHOW jsr CSHOW
plp plp
@@ -225,7 +223,7 @@ MOVE: php
pha pha
txa txa
pha pha
jsr CHIDE jsr CPREP
pla pla
tax tax
pla pla
@@ -241,15 +239,11 @@ MOVE: php
dey dey
lda (sp),y lda (sp),y
sta XPos ; New X position sta XPos ; New X position
jsr CMOVEX ; Move the cursor jsr CMOVEX ; Move the cursor
lda visible jsr CDRAW
beq @Ret
jsr CSHOW
@Ret: plp ; Restore interrupt flag plp ; Restore interrupt flag
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -335,7 +329,7 @@ IRQ:
eor #15 eor #15
sta Temp sta Temp
jsr CHIDE jsr CPREP
; Check left/right ; Check left/right
@@ -435,11 +429,7 @@ IRQ:
; Done ; Done
@SkipY: lda visible @SkipY: jsr CDRAW
beq @Done clc ; Interrupt not "handled"
jsr CSHOW
@Done: clc ; Interrupt not "handled"
rts rts

View File

@@ -60,6 +60,8 @@ libref: .addr $0000
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CPREP: jmp $0000 ; Prepare to move the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -96,8 +98,6 @@ Buttons: .res 1 ; Button mask
XPosWrk: .res 2 XPosWrk: .res 2
YPosWrk: .res 2 YPosWrk: .res 2
visible: .res 1
.if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE) .if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE)
dumx: .res 1 dumx: .res 1
dumy: .res 1 dumy: .res 1
@@ -170,9 +170,8 @@ INSTALL:
dex dex
bpl @L1 bpl @L1
; Be sure the mouse cursor is invisible and at the default location. ; Make sure the mouse cursor is at the default location.
jsr CHIDE
lda XPos lda XPos
sta XPosWrk sta XPosWrk
ldx XPos+1 ldx XPos+1
@@ -276,8 +275,7 @@ UNINSTALL:
; no special action is required besides hiding the mouse cursor. ; no special action is required besides hiding the mouse cursor.
; No return code required. ; No return code required.
HIDE: dec visible HIDE: php
php
sei sei
jsr CHIDE jsr CHIDE
plp plp
@@ -290,8 +288,7 @@ HIDE: dec visible
; no special action is required besides enabling the mouse cursor. ; no special action is required besides enabling the mouse cursor.
; No return code required. ; No return code required.
SHOW: inc visible SHOW: php
php
sei sei
jsr CSHOW jsr CSHOW
plp plp
@@ -352,13 +349,8 @@ MOVE: php
pha pha
txa txa
pha pha
jsr CPREP
lda visible pla
beq @L01
jsr CHIDE
@L01: pla
tax tax
pla pla
@@ -377,15 +369,11 @@ MOVE: php
lda (sp),y lda (sp),y
sta XPos ; New X position sta XPos ; New X position
sta XPosWrk sta XPosWrk
jsr CMOVEX ; Move the cursor jsr CMOVEX ; Move the cursor
lda visible jsr CDRAW
beq @Ret
jsr CSHOW plp ; Restore interrupt flag
@Ret: plp ; Restore interrupt flag
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
@@ -466,13 +454,11 @@ IRQ:
ldx #MOUSE_BTN_LEFT ldx #MOUSE_BTN_LEFT
@L0: stx Buttons @L0: stx Buttons
ldx visible jsr CPREP
beq @L1
jsr CHIDE
; Limit the X coordinate to the bounding box ; Limit the X coordinate to the bounding box
@L1: lda XPosWrk+1 lda XPosWrk+1
ldy XPosWrk ldy XPosWrk
tax tax
cpy XMin cpy XMin
@@ -518,14 +504,12 @@ IRQ:
tya tya
jsr CMOVEY jsr CMOVEY
ldx visible jsr CDRAW
beq @Done
jsr CSHOW clc
@Done: clc
rts rts
;---------------------------------------------------------------------------- ;----------------------------------------------------------------------------
; T1Han: Local IRQ routine to poll mouse ; T1Han: Local IRQ routine to poll mouse
; ;