aboutsummaryrefslogtreecommitdiff
path: root/mousetsr.c
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 /mousetsr.c
parentf71b20f8fb12f28fc2c05f9f14e14fba5daa521c (diff)
downloadvbados-802e8f3d32a4a497538431863a3ab178543815b6.tar.gz
vbados-802e8f3d32a4a497538431863a3ab178543815b6.zip
don't clobber si on int33/3 calls, this breaks qbasic.com
Diffstat (limited to 'mousetsr.c')
-rw-r--r--mousetsr.c21
1 files changed, 14 insertions, 7 deletions
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;