From b477023783bcb779131a07710833a503b123b354 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 14 Feb 2014 01:40:21 +0100 Subject: [PATCH] Turn off mouse polling interrupt if the mouse hasn't been moved for some time. Turn it back on when the mouse is moved again. Since the polling interrupt runs at a rather high frequency (1kHz), this saves many processor cycles when the mouse is inactive. --- libsrc/atari/mou/atrst.s | 105 ++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 18 deletions(-) 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 #