From 86aa9bdd85243207bbd7e888d73c2b865d805265 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 19 Jun 2023 05:10:20 +0300 Subject: [PATCH] add relative mouse handling in mouse.asm --- src/dos/mouse.asm | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/dos/mouse.h | 2 ++ 2 files changed, 52 insertions(+) diff --git a/src/dos/mouse.asm b/src/dos/mouse.asm index 92b4f49..3a68966 100644 --- a/src/dos/mouse.asm +++ b/src/dos/mouse.asm @@ -9,6 +9,7 @@ WRITE equ 4 PIXRATE equ 15 XLIM equ 7 YLIM equ 8 +READREL equ 0xb PUSHA_EAX_OFFS equ 28 PUSHA_ECX_OFFS equ 24 @@ -61,6 +62,19 @@ _show_mouse: pop ebp ret +; int read_mouse_bn(void) + global read_mouse_bn_ + global _read_mouse_bn +read_mouse_bn_: +_read_mouse_bn: + pusha + mov ax, READ + int 0x33 + xor eax, eax + mov ax, bx + popa + ret + ; int read_mouse(int *xp, int *yp) global read_mouse_ read_mouse_: @@ -102,6 +116,42 @@ _read_mouse: pop ebp ret +; void read_mouse_rel(int *xp, int *yp) + global read_mouse_rel_ +read_mouse_rel_: + pusha + mov esi, eax ; xp + mov edi, edx ; yp + mov ax, READREL + int 0x33 + movsx eax, cx + mov [esi], eax + movsx eax, dx + mov [edi], eax + popa + ret + + global _read_mouse_rel +_read_mouse_rel: + push ebp + mov ebp, esp + push ebx + push esi + push edi + mov ax, READREL + int 0x33 + mov ebx, [ebp + 8] + movsx eax, cx + mov [ebx], eax + mov ebx, [ebp + 12] + movsx eax, dx + mov [ebx], eax + pop edi + pop esi + pop ebx + pop ebp + ret + ; void set_mouse(int x, int y) global set_mouse_ set_mouse_: diff --git a/src/dos/mouse.h b/src/dos/mouse.h index b54f6a9..aa46df3 100644 --- a/src/dos/mouse.h +++ b/src/dos/mouse.h @@ -13,7 +13,9 @@ extern "C" { int have_mouse(void); void show_mouse(int show); +int read_mouse_bn(void); int read_mouse(int *xp, int *yp); +void read_mouse_rel(int *xp, int *yp); void set_mouse(int x, int y); void set_mouse_limits(int xmin, int ymin, int xmax, int ymax); void set_mouse_rate(int xrate, int yrate); -- 1.7.10.4