Skip to content

Commit a28035a

Browse files
On mouse events, do not signal mouse IRQ unless: a) Guest enabled AUX mouse reporting b) INT 15h called to enable reporting c) INT 33h has visible cursor, interrupt handler, or guest is polling mouse info. Do not process mouse movement into mouse device input while debugger is active. This should fix the issue where IRQ12 is consistently seen active in the debugger, whether it is stuck or has the appearance of being stuck on.
1 parent 93eed65 commit a28035a

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/hardware/keyboard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ int KEYBOARD_AUX_Active() {
253253
return keyb.auxactive && !keyb.ps2mouse.int33_taken;
254254
}
255255

256+
int KEYBOARD_PS2REPORT_Active() {
257+
/* HACK: INT 15h really needs to issue Enable AUX, but for now, report if PS/2 mouse reporting active */
258+
return keyb.ps2mouse.reporting;
259+
}
260+
256261
static void KEYBOARD_SetPort60(uint16_t val) {
257262
keyb.auxchanged=(val&AUX)>0;
258263
keyb.p60changed=true;

src/ints/mouse.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ static struct {
251251
bool first_range_setx;
252252
bool first_range_sety;
253253
bool in_UIR;
254+
bool polled;
254255
uint8_t mode;
255256
int16_t gran_x,gran_y;
256257
int scrollwheel;
@@ -428,6 +429,23 @@ void ChangeMouseReportRate(unsigned int new_rate) {
428429
}
429430
}
430431

432+
int KEYBOARD_PS2REPORT_Active();
433+
434+
bool MouseInterruptEnabled(void) {
435+
if (!IS_PC98_ARCH && KEYBOARD_AUX_Active())
436+
return true;
437+
if (KEYBOARD_PS2REPORT_Active()) // FIXME: INT 15h needs to issue keyboard command "enable AUX"
438+
return true;
439+
if (mouse.polled)
440+
return true;
441+
if (mouse.sub_mask)
442+
return true;
443+
if (!mouse.hidden)
444+
return true;
445+
446+
return false;
447+
}
448+
431449
void MOUSE_Limit_Events(Bitu /*val*/) {
432450
mouse.timer_in_progress = false;
433451

@@ -442,7 +460,7 @@ void MOUSE_Limit_Events(Bitu /*val*/) {
442460
PIC_AddEvent(MOUSE_Limit_Events,MOUSE_DELAY);
443461

444462
if (MOUSE_IRQ != 0) {
445-
if (!IS_PC98_ARCH)
463+
if (!IS_PC98_ARCH && MouseInterruptEnabled())
446464
PIC_ActivateIRQ(MOUSE_IRQ);
447465
}
448466
}
@@ -468,7 +486,7 @@ INLINE void Mouse_AddEvent(uint8_t type) {
468486
PIC_AddEvent(MOUSE_Limit_Events,MOUSE_DELAY);
469487

470488
if (MOUSE_IRQ != 0) {
471-
if (!IS_PC98_ARCH)
489+
if (!IS_PC98_ARCH && MouseInterruptEnabled())
472490
PIC_ActivateIRQ(MOUSE_IRQ);
473491
}
474492
}
@@ -1567,6 +1585,7 @@ static Bitu INT33_Handler(void) {
15671585
switch (reg_ax) {
15681586
case 0x00: /* MS MOUSE - RESET DRIVER AND READ STATUS */
15691587
Mouse_ResetHardware();
1588+
mouse.polled = false;
15701589
goto software_reset;
15711590
case 0x01: /* MS MOUSE v1.0+ - SHOW MOUSE CURSOR */
15721591
if (mouse.hidden) mouse.hidden--;
@@ -1594,6 +1613,7 @@ static Bitu INT33_Handler(void) {
15941613
}
15951614
reg_cx=POS_X;
15961615
reg_dx=POS_Y;
1616+
mouse.polled = true;
15971617
mouse.first_range_setx = false;
15981618
mouse.first_range_sety = false;
15991619
if (en_int33_hide_if_polling) int33_last_poll = PIC_FullIndex();
@@ -1639,6 +1659,7 @@ static Bitu INT33_Handler(void) {
16391659
}
16401660
if (en_int33_hide_if_polling) int33_last_poll = PIC_FullIndex();
16411661
}
1662+
mouse.polled = true;
16421663
Mouse_Used();
16431664
break;
16441665
case 0x06: /* MS MOUSE v1.0+ - RETURN BUTTON RELEASE DATA */
@@ -1668,6 +1689,7 @@ static Bitu INT33_Handler(void) {
16681689
}
16691690
if (en_int33_hide_if_polling) int33_last_poll = PIC_FullIndex();
16701691
}
1692+
mouse.polled = true;
16711693
Mouse_Used();
16721694
break;
16731695
case 0x07: /* MS MOUSE v1.0+ - DEFINE HORIZONTAL CURSOR RANGE */
@@ -1839,6 +1861,7 @@ static Bitu INT33_Handler(void) {
18391861
DrawCursor();
18401862
break;
18411863
case 0x0b: /* MS MOUSE v1.0+ - READ MOTION COUNTERS */
1864+
mouse.polled = true;
18421865
Mouse_Read_Motion_Data();
18431866
break;
18441867
case 0x0c: /* MS MOUSE v1.0+ - DEFINE INTERRUPT SUBROUTINE PARAMETERS */
@@ -2042,6 +2065,7 @@ static Bitu INT33_Handler(void) {
20422065
reg_dx = (uint16_t)mouse.max_y;
20432066
break;
20442067
case 0x27: /* MS MOUSE v7.01+ - GET SCREEN/CURSOR MASKS AND MICKEY COUNTS */
2068+
mouse.polled = true;
20452069
reg_ax = mouse.textAndMask;
20462070
reg_bx = mouse.textXorMask;
20472071
Mouse_Read_Motion_Data();
@@ -2465,6 +2489,7 @@ void MOUSE_Startup(Section *sec) {
24652489
mouse.timer_in_progress = false;
24662490
mouse.mode = 0xFF; //Non existing mode
24672491
mouse.scrollwheel = 0;
2492+
mouse.polled = 0;
24682493

24692494
mouse.sub_mask=0;
24702495
mouse.sub_seg=0x6362; // magic value

0 commit comments

Comments
 (0)