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 CDRAW
- jsr CSHOW
-
-@Ret: plp ; Restore interrupt flag
+ plp ; Restore interrupt flag
rts
;----------------------------------------------------------------------------
IRQ:
+; Turn mouse polling IRQ back on in case it disabled itself due to CRITIC
+; flag being set.
+
+ lda POKMSK
+ ora #%00000001 ; timer 1 enable
+ sta POKMSK
+ sta IRQEN
+
; Check for a pressed button and place the result into Buttons
ldx #0
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
;
-T1Han: tya
+T1Han: lda CRITIC ; if CRITIC flag is set, disable the
+ bne disable_me ; high frequency polling IRQ, in order
+ ; not to interfere with SIO I/O (e.g.
+ ; floppy access)
+
+ tya
pha
txa
pha
pla
rti
.endif
+
+
+; Disable the interrupt source which caused us to be called.
+; The interrupt will be enabled again by the "IRQ" routine.
+; The "IRQ" routine, despite its name, is called from the
+; vertical blank NMI interrupt *only* if the CRITIC flag has
+; been cleared.
+
+disable_me:
+ lda POKMSK
+ and #%11111110 ; timer 1 disable
+ sta IRQEN
+ sta POKMSK
+.ifdef __ATARIXL__
+ rts
+.else
+ pla
+ rti
+.endif