diff --git a/libsrc/atari/mou/atrst.s b/libsrc/atari/mou/atrst.s index 773e171e1..35fd768f3 100644 --- a/libsrc/atari/mou/atrst.s +++ b/libsrc/atari/mou/atrst.s @@ -11,6 +11,13 @@ ; is being built. ; +;DEBUG = 1 + +DISABLE_TIMEOUT = 30 ; # of vertical blank interrupts after which, if + ; no mouse motion occurred, the polling IRQ gets + ; disabled. + ; VBI frequency is 50Hz for PAL and 60Hz for NTSC + .include "zeropage.inc" .include "mouse-kernel.inc" .include "atari.inc" @@ -98,6 +105,10 @@ Buttons: .res 1 ; Button mask XPosWrk: .res 2 YPosWrk: .res 2 +irq_enabled: .res 1 ; flag indicating that the high frequency polling interrupt is enabled +old_porta_vbi: .res 1 ; previous PORTA value of the VBI interrupt (IRQ) +how_long: .res 1 ; counter for how many VBI interrupts the mouse hasn't been moved + .if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE) dumx: .res 1 dumy: .res 1 @@ -226,10 +237,17 @@ INSTALL: sta AUDF1 sta STIMER +.if 0 ; the IRQ will now be dynamically enabled when the mouse is moved lda POKMSK ora #%00000001 ; timer 1 enable sta POKMSK sta IRQEN + sta irq_enabled +.endif + + lda PORTA + and #$0f + sta old_porta_vbi ; Done, return zero (= MOUSE_ERR_OK) @@ -444,23 +462,60 @@ IOCTL: lda #