From: Svjatoslav Agejenko Date: Tue, 29 Jul 2025 14:16:29 +0000 (+0300) Subject: Better documentation for mouse driver X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=52ded7f048fbe99e3731bce11987c345a5172425;p=qbasicapps.git Better documentation for mouse driver --- 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 0000000..dc8e0a0 Binary files /dev/null and b/Miscellaneous/Mouse driver/screenshot.png differ