aboutsummaryrefslogtreecommitdiff
path: root/dostsr.c
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2022-04-03 00:03:15 +0200
committerJavier <dev.git@javispedro.com>2022-04-03 00:03:15 +0200
commit7d93442564b57c2d292df7f823c2115d3e0b8c12 (patch)
tree6a7e31e172ced11dde78f1b0a1f38fa2ab252697 /dostsr.c
parent3ca7b6c9cc23e118968b49a79f2b64fe4a3b73b3 (diff)
downloadvbados-7d93442564b57c2d292df7f823c2115d3e0b8c12.tar.gz
vbados-7d93442564b57c2d292df7f823c2115d3e0b8c12.zip
complete wheel support
Diffstat (limited to 'dostsr.c')
-rw-r--r--dostsr.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/dostsr.c b/dostsr.c
index 57ec089..7d881e2 100644
--- a/dostsr.c
+++ b/dostsr.c
@@ -384,7 +384,6 @@ static void load_cursor(void)
/** Refreshes the information about the current video mode. */
static void refresh_video_info(void)
{
- uint8_t screen_columns = bda_get_num_columns();
uint8_t mode = bda_get_video_mode() & ~0x80;
bool mode_change = mode != data.screen_mode;
@@ -396,7 +395,9 @@ static void refresh_video_info(void)
dlog_print("Current video mode=");
dlog_printx(mode);
dlog_print(" with cols=");
- dlog_printd(screen_columns);
+ dlog_printd(bda_get_num_columns());
+ dlog_print(" lastrow=");
+ dlog_printd(bda_get_last_row());
dlog_endline();
data.screen_mode = mode;
@@ -412,8 +413,8 @@ static void refresh_video_info(void)
case 2:
case 3: // CGA text modes with 25 rows and variable columns
case 7: // MDA Mono text mode
- data.screen_max.x = (screen_columns * 8) - 1;
- data.screen_max.y = (25 * 8) - 1;
+ data.screen_max.x = (bda_get_num_columns() * 8) - 1;
+ data.screen_max.y = ( 25 * 8) - 1;
break;
case 4:
@@ -736,6 +737,7 @@ static void reset_mouse_state()
data.button[i].released.last.x = 0;
data.button[i].released.last.y = 0;
}
+ data.wheel_delta = 0;
data.cursor_visible = false;
data.cursor_pos.x = 0;
data.cursor_pos.y = 0;
@@ -743,6 +745,16 @@ static void reset_mouse_state()
bzero(data.cursor_prev_graphic, sizeof(data.cursor_prev_graphic));
}
+static void return_clear_wheel_counter(union INTPACK __far *r)
+{
+ r->x.cx = data.wheel_last.x;
+ r->x.dx = data.wheel_last.y;
+ r->x.bx = data.wheel_delta;
+ data.wheel_last.x = 0;
+ data.wheel_last.y = 0;
+ data.wheel_delta = 0;
+}
+
static void return_clear_button_counter(union INTPACK __far *r, struct buttoncounter *c)
{
r->x.cx = c->last.x;
@@ -778,6 +790,10 @@ static void int33_handler(union INTPACK r)
r.x.cx = data.pos.x;
r.x.dx = data.pos.y;
r.x.bx = data.buttons;
+ if (data.haswheel) {
+ r.h.bh = data.wheel_delta;
+ data.wheel_delta = 0;
+ }
break;
case INT33_SET_MOUSE_POSITION:
data.pos.x = r.x.cx;
@@ -792,11 +808,30 @@ static void int33_handler(union INTPACK r)
break;
case INT33_GET_BUTTON_PRESSED_COUNTER:
r.x.ax = data.buttons;
- return_clear_button_counter(&r, &data.button[MIN(r.x.bx, NUM_BUTTONS - 1)].pressed);
+ if (data.haswheel) {
+ r.h.bh = data.wheel_delta;
+ }
+ if (data.haswheel && r.x.bx == -1) {
+ // Wheel information
+ return_clear_wheel_counter(&r);
+ } else {
+ // Regular button information
+ int btn = MIN(r.x.bx, NUM_BUTTONS - 1);
+ return_clear_button_counter(&r, &data.button[btn].pressed);
+ }
break;
case INT33_GET_BUTTON_RELEASED_COUNTER:
r.x.ax = data.buttons;
- return_clear_button_counter(&r, &data.button[MIN(r.x.bx, NUM_BUTTONS - 1)].released);
+ if (data.haswheel) {
+ r.h.bh = data.wheel_delta;
+ }
+ if (data.haswheel && r.x.bx == -1) {
+ // Wheel information
+ return_clear_wheel_counter(&r);
+ } else {
+ int btn = MIN(r.x.bx, NUM_BUTTONS - 1);
+ return_clear_button_counter(&r, &data.button[btn].released);
+ }
break;
case INT33_SET_HORIZONTAL_WINDOW:
dlog_print("Mouse set horizontal window [");
@@ -937,6 +972,11 @@ static void int33_handler(union INTPACK r)
r.x.cx = data.max.x;
r.x.dx = data.max.y;
break;
+ case INT33_GET_CAPABILITIES:
+ r.x.ax = INT33_WHEEL_API_MAGIC; // Driver supports wheel API
+ r.x.bx = 0;
+ r.x.cx = data.haswheel ? INT33_CAPABILITY_MOUSE_API : 0;
+ break;
case INT33_GET_TSR_DATA:
dlog_puts("Get TSR data");
r.x.es = FP_SEG(&data);