.bss
backup: .res 1
+visible:.res 1
; ------------------------------------------------------------------------
_mouse_def_callbacks:
.addr hide
.addr show
+ .addr prep
+ .addr draw
.addr movex
.addr movey
; Hide the mouse cursor.
hide:
+ dec visible
+
+prep:
jsr getcursor ; Get character at cursor position
cmp #cursor ; "mouse" character
bne overwr ; no, probably program has overwritten it
; Show the mouse cursor.
show:
+ inc visible
+
+draw:
+ lda visible
+ beq done
jsr getcursor ; Cursor visible at current position?
sta backup ; Save character at cursor position
lda #cursor
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
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
Temp: .res 1 ; Temporary value used in the int handler
-visible: .res 1
; Default values for above variables
dex
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
ldx XPos+1
jsr CMOVEX
; no special action is required besides hiding the mouse cursor.
; No return code required.
-HIDE: dec visible
- php
+HIDE: php
sei
jsr CHIDE
plp
; no special action is required besides enabling the mouse cursor.
; No return code required.
-SHOW: inc visible
- php
+SHOW: php
sei
jsr CSHOW
plp
pha
txa
pha
- jsr CHIDE
+ jsr CPREP
pla
tax
pla
dey
lda (sp),y
sta XPos ; New X position
-
jsr CMOVEX ; Move the cursor
- lda visible
- beq @Ret
-
- jsr CSHOW
+ jsr CDRAW
-@Ret: plp ; Restore interrupt flag
+ plp ; Restore interrupt flag
rts
;----------------------------------------------------------------------------
eor #15
sta Temp
- jsr CHIDE
+ jsr CPREP
; Check left/right
; Done
-@SkipY: lda visible
- beq @Done
-
- jsr CSHOW
-
-@Done: clc ; Interrupt not "handled"
+@SkipY: jsr CDRAW
+ clc ; Interrupt not "handled"
rts
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
CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord
XPosWrk: .res 2
YPosWrk: .res 2
-visible: .res 1
-
.if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE)
dumx: .res 1
dumy: .res 1
dex
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
sta XPosWrk
ldx XPos+1
; no special action is required besides hiding the mouse cursor.
; No return code required.
-HIDE: dec visible
- php
+HIDE: php
sei
jsr CHIDE
plp
; no special action is required besides enabling the mouse cursor.
; No return code required.
-SHOW: inc visible
- php
+SHOW: php
sei
jsr CSHOW
plp
pha
txa
pha
-
- lda visible
- beq @L01
-
- jsr CHIDE
-
-@L01: pla
+ jsr CPREP
+ pla
tax
pla
lda (sp),y
sta XPos ; New X position
sta XPosWrk
-
jsr CMOVEX ; Move the cursor
- lda visible
- beq @Ret
-
- jsr CSHOW
+ jsr CDRAW
-@Ret: plp ; Restore interrupt flag
+ plp ; Restore interrupt flag
rts
;----------------------------------------------------------------------------
ldx #MOUSE_BTN_LEFT
@L0: stx Buttons
- ldx visible
- beq @L1
- jsr CHIDE
+ jsr CPREP
; Limit the X coordinate to the bounding box
-@L1: lda XPosWrk+1
+ lda XPosWrk+1
ldy XPosWrk
tax
cpy XMin
tya
jsr CMOVEY
- ldx visible
- beq @Done
+ jsr CDRAW
- jsr CSHOW
-
-@Done: clc
+ clc
rts
+
;----------------------------------------------------------------------------
; T1Han: Local IRQ routine to poll mouse
;