aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2024-05-20 15:39:10 +0200
committerJavier <dev.git@javispedro.com>2024-05-20 15:39:10 +0200
commit802e8f3d32a4a497538431863a3ab178543815b6 (patch)
treecb0654c7232cfad6866b77db4fcb7a6337125f4c
parentf71b20f8fb12f28fc2c05f9f14e14fba5daa521c (diff)
downloadvbados-802e8f3d32a4a497538431863a3ab178543815b6.tar.gz
vbados-802e8f3d32a4a497538431863a3ab178543815b6.zip
don't clobber si on int33/3 calls, this breaks qbasic.com
-rw-r--r--doc/wheelapi2.txt6
-rw-r--r--mousetsr.c21
-rw-r--r--mousetsr.h6
3 files changed, 24 insertions, 9 deletions
diff --git a/doc/wheelapi2.txt b/doc/wheelapi2.txt
index d1f6fb3..c2b087f 100644
--- a/doc/wheelapi2.txt
+++ b/doc/wheelapi2.txt
@@ -24,21 +24,23 @@ INT 33/0003 - Get cursor position, buttons status and wheel counter
Return: BL = buttons status (bits 0-4)
CX = column
DX = row
- BH = 8-bit signed counter of wheel movement since last call
+ BH = 8-bit signed counter of wheel movement since last call.
positive value means downward wheel movement.
- SI = 16-bit signed counter of 2nd wheel movement since last call
+ AH = 8-bit signed counter of 2nd wheel movement since last call.
positive value means rightward wheel movement.
Note: calling this clears the wheel counter for ALL wheels.
INT 33/0005 - Get button press or wheel movement data
AX = 0005h
BX = button number, -1 for vertical wheel, -2 for 2nd/horizontal wheel
+ (return values remain the same)
Note: as in wheelapi v1, AH always contains (1st) wheel movement on return
independently of button number requested in BX.
INT 33/0006 - Get button release or wheel movement data
AX = 0006h
BX = button number, -1 for vertical wheel, -2 for 2nd/horizontal wheel
+ (return values remain the same)
INT 33/000C - Define User Interrupt Routine
INT 33/0014 - Exchange User Interrupt Routines
diff --git a/mousetsr.c b/mousetsr.c
index 2afc2b4..e571d51 100644
--- a/mousetsr.c
+++ b/mousetsr.c
@@ -989,7 +989,7 @@ static void reset_mouse_hardware()
data.packet_size = PS2M_PACKET_SIZE_STD;
data.cur_packet_bytes = 0;
data.cur_packet_ticks = 0;
- data.num_buttons = 3;
+ data.num_buttons = MIN(3, MAX_BUTTONS);
#if USE_WHEEL
data.num_wheels = 0;
data.usewheelapi = 0;
@@ -1037,7 +1037,7 @@ static void reset_mouse_hardware()
dputs("ImPS/2 detected");
data.packet_size = PS2M_PACKET_SIZE_EXT;
- data.num_wheels = 1;
+ data.num_wheels = MIN(1, MAX_WHEELS);
ps2m_get_device_id(&data.device_id);
#if USE_IMEX
@@ -1059,12 +1059,13 @@ static void reset_mouse_hardware()
if (data.device_id == PS2M_DEVICE_ID_IMEX
|| data.device_id == PS2M_DEVICE_ID_IMEX_HORZ) {
dputs("ImEx detected");
- data.num_wheels = 2;
- data.num_buttons = 5;
+ data.num_wheels = MIN(2, MAX_WHEELS);
+ data.num_buttons = MIN(5, MAX_BUTTONS);
}
#endif /* USE_IMEX */
- dprintf("found mouse device id = 0x%hx\n", data.device_id);
+ dprintf("found mouse device id = 0x%hx num buttons=%d num wheels=%d\n",
+ data.device_id, data.num_buttons, data.num_wheels);
} else {
if (data.usewheel) dputs("PS/2 wheel NOT detected");
}
@@ -1140,11 +1141,13 @@ static void reset_mouse_state()
data.button[i].released.last.x = 0;
data.button[i].released.last.y = 0;
}
+#if USE_WHEEL
for (i = 0; i < MAX_WHEELS; i++) {
data.wheel[i].delta = 0;
data.wheel[i].last.x = 0;
data.wheel[i].last.y = 0;
}
+#endif
data.cursor_visible = false;
data.cursor_pos.x = 0;
data.cursor_pos.y = 0;
@@ -1152,6 +1155,7 @@ static void reset_mouse_state()
memset(data.cursor_prev_graphic, 0, sizeof(data.cursor_prev_graphic));
}
+#if USE_WHEEL
/** Return (in the appropiate registers) the wheel movement counter and afterwards reset it. */
static void return_clear_wheel_counter(union INTPACK __far *r, struct wheelcounter *c)
{
@@ -1160,6 +1164,7 @@ static void return_clear_wheel_counter(union INTPACK __far *r, struct wheelcount
r->w.bx = c->delta;
c->delta = 0;
}
+#endif
/** Return (in the appropiate registers) the desired button press counter and afterwards reset it. */
static void return_clear_button_counter(union INTPACK __far *r, struct buttoncounter *c)
@@ -1223,8 +1228,10 @@ static void int33_handler(union INTPACK r)
if (data.num_wheels > 0) {
r.h.bh = data.wheel[0].delta;
data.wheel[0].delta = 0;
- r.x.si = data.wheel[1].delta;
- data.wheel[1].delta = 0;
+ if (data.num_wheels > 1) {
+ r.h.ah = data.wheel[1].delta;
+ data.wheel[1].delta = 0;
+ }
}
#endif
break;
diff --git a/mousetsr.h b/mousetsr.h
index 5f98333..5625ae1 100644
--- a/mousetsr.h
+++ b/mousetsr.h
@@ -63,7 +63,13 @@
#define MAX_BUTTONS 5
/** Maximum number of wheels supported. */
+#if USE_IMEX
#define MAX_WHEELS 2
+#elif USE_WHEEL
+#define MAX_WHEELS 1
+#else
+#define MAX_WHEELS 0
+#endif
/** Size of int33 graphic cursor shape definitions. */
#define GRAPHIC_CURSOR_WIDTH 16