.include "atari.inc"
.macpack generic
+ .macpack module
; ------------------------------------------------------------------------
; Header. Includes jump table
-.segment "JUMPTABLE"
+.ifdef __ATARIXL__
+ module_header _atrxjoy_mou
+.else
+ module_header _atrjoy_mou
+.endif
HEADER:
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
.rodata
+; (We use ".proc" because we want to define both a label and a scope.)
+
.proc DefVars
.word SCREEN_HEIGHT/2 ; YPos
.word SCREEN_WIDTH/2 ; XPos
dex
bpl @L1
-; Be sure the mouse cursor is invisible and at the default location. We
-; need to do that here, because our mouse interrupt handler doesn't set the
-; mouse position if it hasn't changed.
+; Make sure the mouse cursor is at the default location.
- sei
- jsr CHIDE
lda XPos
ldx XPos+1
jsr CMOVEX
lda YPos
ldx YPos+1
jsr CMOVEY
- cli
; Done, return zero (= MOUSE_ERR_OK)
; no special action is required besides hiding the mouse cursor.
; No return code required.
-HIDE: dec visible
+HIDE: php
sei
jsr CHIDE
- cli
+ plp
rts
;----------------------------------------------------------------------------
; no special action is required besides enabling the mouse cursor.
; No return code required.
-SHOW: inc visible
+SHOW: php
sei
jsr CSHOW
- cli
+ plp
rts
;----------------------------------------------------------------------------
stx ptr1+1 ; Save data pointer
ldy #.sizeof (MOUSE_BOX)-1
+ php
sei
@L1: lda (ptr1),y
dey
bpl @L1
- cli
+ plp
rts
;----------------------------------------------------------------------------
stx ptr1+1 ; Save data pointer
ldy #.sizeof (MOUSE_BOX)-1
+ php
sei
@L1: lda XMin,y
dey
bpl @L1
- cli
+ plp
rts
;----------------------------------------------------------------------------
; the screen). No return code required.
;
-MOVE: sei ; No interrupts
+MOVE: php
+ sei ; No interrupts
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: cli ; Allow interrupts
+ plp ; Restore interrupt flag
rts
;----------------------------------------------------------------------------
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
+ php
sei ; Disable interrupts
lda XPos ; Transfer the position
sta (ptr1),y
iny
sta (ptr1),y
lda YPos+1
- cli ; Enable interrupts
+ plp ; Restore interrupt flag
iny
sta (ptr1),y ; Store last byte
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>MOUSE_ERR_INV_IOCTL
-hlprts: rts
+ rts
;----------------------------------------------------------------------------
; IRQ: Irq handler entry point. Called as a subroutine but in IRQ context
and #15 ; clear joystick #1 bits
eor #15
sta Temp
- clc
- beq hlprts ; no movement, do nothing
- 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