From 52ded7f048fbe99e3731bce11987c345a5172425 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Tue, 29 Jul 2025 17:16:29 +0300 Subject: [PATCH] Better documentation for mouse driver --- Miscellaneous/Mouse driver/index.html | 80 ++++++++++++++++++++-- Miscellaneous/Mouse driver/index.org | 39 +++++++++-- Miscellaneous/Mouse driver/mousedrv.bas | 11 ++- Miscellaneous/Mouse driver/screenshot.png | Bin 0 -> 7323 bytes 4 files changed, 114 insertions(+), 16 deletions(-) create mode 100644 Miscellaneous/Mouse driver/screenshot.png diff --git a/Miscellaneous/Mouse driver/index.html b/Miscellaneous/Mouse driver/index.html index 36675a3..6c458ba 100644 --- a/Miscellaneous/Mouse driver/index.html +++ b/Miscellaneous/Mouse driver/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Mouse driver for QBasic programs @@ -206,15 +206,83 @@

Mouse driver for QBasic programs

+ + +
+

1. Overview

+
+

+QBasic, a popular programming language in the DOS era, lacks native +mouse support. This limitation can be a hurdle for developers looking +to create interactive applications. To bridge this gap, I developed a +solution that involves a Terminate and Stay Resident (TSR) program +written in x86 assembly and a QBasic demonstration program. +

+ + +

+The solution comprises two main components: +

+
+ + +
+

1.1. Terminate and Stay Resident module

+
+

+A DOS TSR program that hooks into the system's interrupt mechanism to +regularly read mouse input and store it in a dedicated memory +location. +

+ +

+Files: +

+ +
+
+ + +
+

1.2. QBasic demonstration program

+
+

+A QBasic program that reads mouse data from the memory location +populated by the TSR and demonstrates mouse movement and button +clicks. +

+ + + +
+

screenshot.png +

+
+

-This TSR written in x86 assembler, allows QBasic programs to use -mouse, by writing mouse movement and button press info to memory, -referenced by INT 79h. Afterwards QBasic programs can read mouse -cursor position directly from RAM by using PEEK command. +mousedrv.bas - source code

+
+
+
-

Created: 2025-07-29 ti 16:07

+

Created: 2025-07-29 ti 17:15

Validate

diff --git a/Miscellaneous/Mouse driver/index.org b/Miscellaneous/Mouse driver/index.org index ba2c76a..0cddd4f 100644 --- a/Miscellaneous/Mouse driver/index.org +++ b/Miscellaneous/Mouse driver/index.org @@ -7,7 +7,38 @@ #+OPTIONS: H:20 num:20 #+OPTIONS: author:nil -This TSR written in x86 assembler, allows QBasic programs to use -mouse, by writing mouse movement and button press info to memory, -referenced by INT 79h. Afterwards QBasic programs can read mouse -cursor position directly from RAM by using PEEK command. +* Overview + +QBasic, a popular programming language in the DOS era, lacks native +mouse support. This limitation can be a hurdle for developers looking +to create interactive applications. To bridge this gap, I developed a +solution that involves a Terminate and Stay Resident (TSR) program +written in x86 assembly and a QBasic demonstration program. + + +The solution comprises two main components: + + +** Terminate and Stay Resident module + +A DOS TSR program that hooks into the system's interrupt mechanism to +regularly read mouse input and store it in a dedicated memory +location. + +Files: +- [[file:qbext.asm][qbext.asm - x86 Assembly source code]] +- [[file:qbext.com][qbext.com - binary COM executable for DOS]] + + +** QBasic demonstration program + +A QBasic program that reads mouse data from the memory location +populated by the TSR and demonstrates mouse movement and button +clicks. + + +#+attr_html: :class responsive-img +#+attr_latex: :width 1000px +[[file:mousedrv.bas][file:screenshot.png]] + +[[file:mousedrv.bas][mousedrv.bas - source code]] diff --git a/Miscellaneous/Mouse driver/mousedrv.bas b/Miscellaneous/Mouse driver/mousedrv.bas index e4e62ad..c0353da 100755 --- a/Miscellaneous/Mouse driver/mousedrv.bas +++ b/Miscellaneous/Mouse driver/mousedrv.bas @@ -45,15 +45,15 @@ SUB mousedemo cy = 100 ' Initial y-coordinate maxmove = 50 ' Maximum movement in one step frm = 0 ' Frame counter - 1 +1 frm = frm + 1 ' Increment frame counter ' Check for user input on keyboard and exit if any key is pressed IF INKEY$ <> "" THEN SYSTEM ' Print the current coordinates and frame number. LOCATE 1, 1 - PRINT cx, cy ' Print current x and y coordinates - PRINT frm ' Print current frame number + PRINT "X: " + STR$(cx) + " Y:" + STR$(cy) + " " ' Print current x and y coordinates + PRINT "Frame #" + STR$(frm) ' Print current frame number ' Erase circle at the old mouse position by drawing black circle CIRCLE (cx, cy), 10, 0 @@ -98,7 +98,7 @@ SUB putword (addr, dat) ' This subroutine stores a word (2 bytes) at the specified address in RAM. b$ = HEX$(dat) ' Convert data to hexadecimal - 2 +2 IF LEN(b$) < 4 THEN b$ = "0" + b$: GOTO 2 ' Ensure four digits ' Split the word into two bytes. @@ -118,12 +118,10 @@ SUB start ' Retrieve mouse data table address within TSR as pointed by interrupt 79h extSEG = PEEK(&H79 * 4 + 3) * 256 extSEG = extSEG + PEEK(&H79 * 4 + 2) - PRINT "Segment is: " + HEX$(extSEG) ' Print segment address ' Retrieve the offset address of the mouse driver. extADDR = PEEK(&H79 * 4 + 1) * 256 extADDR = extADDR + PEEK(&H79 * 4 + 0) - PRINT "relative address is:"; extADDR ' Print offset address DEF SEG = extSEG ' Set segment for memory access ' Check if the mouse driver is loaded by verifying the magic number (1983). @@ -133,3 +131,4 @@ SUB start SYSTEM ' Exit program if mouse driver is not loaded END IF END SUB + diff --git a/Miscellaneous/Mouse driver/screenshot.png b/Miscellaneous/Mouse driver/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..dc8e0a02a2a7b72de24d23a32a79d133f11ece1c GIT binary patch literal 7323 zcmeHsXHZjH+jbNVpdv+zRN){AJz#*)L8M9V-Ka?DM5=&Pk)||{2}QbqG-(<@x(JAz z&|>Hv=`HjQ33;QBXXcrCXTF(lzWHX}cjozX?U`%tweNLb>$=xkv-e9Q1Ffr8 z;{~@TPkiloArcU2-di%@TasYOTf&Ma0px+~KL?t6IQshAc{>1{9(y1h#C+_%9ULC} zID7bRQM4$NQ`s5mnQ4%N+1S{)xVSPiGtEin1Og!-Ab><7QBl!czs{eRmuG5fIx;eH zbad3y(?d&3>*M2d_wHRvN=g_EW@Tl?#KfepuixL_FDWUBL?S^TP;G7P^z^ilkPsCU zm9w*RWo6~%%a>DAQ?*94`1tsWii(~;e-3#AK_C!xbaZGmdSPKfR#ujmm$$pSTS7tt zgTa)RmR`JgabshHhKA-M^+hlk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