From 0000e8b9c3eb0424457d1b143bbbe147f523efa1 Mon Sep 17 00:00:00 2001 From: tomcw Date: Thu, 17 Nov 2022 22:23:20 +0000 Subject: [PATCH] Mouse: support VBL even when in 'mouse off' mode. (Fixes #1138) --- source/MouseInterface.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/source/MouseInterface.cpp b/source/MouseInterface.cpp index 4e7c6eba..f0915840 100644 --- a/source/MouseInterface.cpp +++ b/source/MouseInterface.cpp @@ -111,7 +111,7 @@ Etc. #define MODE_MOUSE_ON (1<<0) // | | | | | | | \--- Mouse off (0) or on (1) #define MODE_INT_MOVEMENT (1<<1) // | | | | | | \----- Interrupt if mouse is moved #define MODE_INT_BUTTON (1<<2) // | | | | | \------- Interrupt if button is pressed -#define MODE_INT_VBL (1<<3) // | | | | \--------- Interrupt on VBL +#define MODE_INT_VBL (1<<3) // | | | | \--------- Interrupt on VBL [*1] #define MODE_RESERVED4 (1<<4) // | | | \----------- Reserved #define MODE_RESERVED5 (1<<5) // | | \------------- Reserved #define MODE_RESERVED6 (1<<6) // | \--------------- Reserved @@ -119,6 +119,9 @@ Etc. #define MODE_INT_ALL STAT_INT_ALL +// [*1] "A mode byte of $08 (mouse off but VBL interrupt on) will generate VBL interrupts." +// Ref. Apple II Technical Notes - Mouse #3: "Mode Byte of the SetMouse Routine" + //=========================================================================== void M6821_Listener_B( void* objTo, BYTE byData ) @@ -449,22 +452,26 @@ void CMouseInterface::OnMouseEvent(bool bEventVBL) { int byState = 0; - if ( !( m_byMode & MODE_MOUSE_ON ) ) // Mouse Off - return; - - if ( m_nX != m_iX || m_nY != m_iY ) - { - byState |= STAT_INT_MOVEMENT|STAT_MOVEMENT_SINCE_READMOUSE; // X/Y moved since last READMOUSE | Movement interrupt - m_byState |= STAT_MOVEMENT_SINCE_READMOUSE; // [TC] Used by CopyII+9.1 and ProTERM3.1 - } - - if ( m_bBtn0 != m_bButtons[0] || m_bBtn1 != m_bButtons[1] ) - byState |= STAT_INT_BUTTON; // Button 0/1 interrupt - if ( bEventVBL ) + if ((m_byMode & MODE_INT_VBL) && bEventVBL) byState |= STAT_INT_VBL; - //byState &= m_byMode & 0x2E; - byState &= ((m_byMode & MODE_INT_ALL) | STAT_MOVEMENT_SINCE_READMOUSE); // [TC] Keep "X/Y moved since last READMOUSE" for next MOUSE_READ (Contiki v1.3 uses this) + if (m_byMode & MODE_MOUSE_ON) + { + if (m_nX != m_iX || m_nY != m_iY) + { + byState |= STAT_INT_MOVEMENT | STAT_MOVEMENT_SINCE_READMOUSE; // X/Y moved since last READMOUSE | Movement interrupt + m_byState |= STAT_MOVEMENT_SINCE_READMOUSE; // [TC] Used by CopyII+9.1 and ProTERM3.1 + } + + if (m_bBtn0 != m_bButtons[0] || m_bBtn1 != m_bButtons[1]) + byState |= STAT_INT_BUTTON; // Button 0/1 interrupt + + byState &= ((m_byMode & MODE_INT_ALL) | STAT_MOVEMENT_SINCE_READMOUSE); // [TC] Keep "X/Y moved since last READMOUSE" for next MOUSE_READ (Contiki v1.3 uses this) + } + else // if MOUSE OFF then only consider VBL (GH#1138) + { + byState &= STAT_INT_VBL; + } if ( byState & STAT_INT_ALL ) {