Better documentation for mouse driver
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Tue, 29 Jul 2025 14:16:29 +0000 (17:16 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Tue, 29 Jul 2025 14:16:29 +0000 (17:16 +0300)
Miscellaneous/Mouse driver/index.html
Miscellaneous/Mouse driver/index.org
Miscellaneous/Mouse driver/mousedrv.bas
Miscellaneous/Mouse driver/screenshot.png [new file with mode: 0644]

index 36675a3..6c458ba 100644 (file)
@@ -3,7 +3,7 @@
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
-<!-- 2025-07-29 ti 16:07 -->
+<!-- 2025-07-29 ti 17:15 -->
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1" />
 <title>Mouse driver for QBasic programs</title>
 <body>
 <div id="content" class="content">
 <h1 class="title">Mouse driver for QBasic programs</h1>
+<div id="table-of-contents" role="doc-toc">
+<h2>Table of Contents</h2>
+<div id="text-table-of-contents" role="doc-toc">
+<ul>
+<li><a href="#org6da62e5">1. Overview</a>
+<ul>
+<li><a href="#orgf629f52">1.1. Terminate and Stay Resident module</a></li>
+<li><a href="#org75f72a4">1.2. QBasic demonstration program</a></li>
+</ul>
+</li>
+</ul>
+</div>
+</div>
+
+<div id="outline-container-org6da62e5" class="outline-2">
+<h2 id="org6da62e5"><span class="section-number-2">1.</span> Overview</h2>
+<div class="outline-text-2" id="text-1">
+<p>
+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.
+</p>
+
+
+<p>
+The solution comprises two main components:
+</p>
+</div>
+
+
+<div id="outline-container-orgf629f52" class="outline-3">
+<h3 id="orgf629f52"><span class="section-number-3">1.1.</span> Terminate and Stay Resident module</h3>
+<div class="outline-text-3" id="text-1-1">
+<p>
+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.
+</p>
+
+<p>
+Files:
+</p>
+<ul class="org-ul">
+<li><a href="qbext.asm">qbext.asm - x86 Assembly source code</a></li>
+<li><a href="qbext.com">qbext.com - binary COM executable for DOS</a></li>
+</ul>
+</div>
+</div>
+
+
+<div id="outline-container-org75f72a4" class="outline-3">
+<h3 id="org75f72a4"><span class="section-number-3">1.2.</span> QBasic demonstration program</h3>
+<div class="outline-text-3" id="text-1-2">
+<p>
+A QBasic program that reads mouse data from the memory location
+populated by the TSR and demonstrates mouse movement and button
+clicks.
+</p>
+
+
+
+<div id="orgbb53e8f" class="figure">
+<p><a href="mousedrv.bas" class="responsive-img"><img src="screenshot.png" alt="screenshot.png" class="responsive-img" /></a>
+</p>
+</div>
+
 <p>
-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.
+<a href="mousedrv.bas">mousedrv.bas - source code</a>
 </p>
 </div>
+</div>
+</div>
+</div>
 <div id="postamble" class="status">
-<p class="date">Created: 2025-07-29 ti 16:07</p>
+<p class="date">Created: 2025-07-29 ti 17:15</p>
 <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
 </div>
 </body>
index ba2c76a..0cddd4f 100644 (file)
@@ -7,7 +7,38 @@
 #+OPTIONS: H:20 num:20\r
 #+OPTIONS: author:nil\r
 \r
-This TSR written in x86 assembler, allows QBasic programs to use\r
-mouse, by writing mouse movement and button press info to memory,\r
-referenced by INT 79h.  Afterwards QBasic programs can read mouse\r
-cursor position directly from RAM by using PEEK command.\r
+* Overview\r
+\r
+QBasic, a popular programming language in the DOS era, lacks native\r
+mouse support. This limitation can be a hurdle for developers looking\r
+to create interactive applications. To bridge this gap, I developed a\r
+solution that involves a Terminate and Stay Resident (TSR) program\r
+written in x86 assembly and a QBasic demonstration program.\r
+\r
+\r
+The solution comprises two main components:\r
+\r
+\r
+** Terminate and Stay Resident module\r
+\r
+A DOS TSR program that hooks into the system's interrupt mechanism to\r
+regularly read mouse input and store it in a dedicated memory\r
+location.\r
+\r
+Files:\r
+- [[file:qbext.asm][qbext.asm - x86 Assembly source code]]\r
+- [[file:qbext.com][qbext.com - binary COM executable for DOS]]\r
+\r
+\r
+** QBasic demonstration program\r
+\r
+A QBasic program that reads mouse data from the memory location\r
+populated by the TSR and demonstrates mouse movement and button\r
+clicks.\r
+\r
+\r
+#+attr_html: :class responsive-img\r
+#+attr_latex: :width 1000px\r
+[[file:mousedrv.bas][file:screenshot.png]]\r
+\r
+[[file:mousedrv.bas][mousedrv.bas - source code]]\r
index e4e62ad..c0353da 100755 (executable)
@@ -45,15 +45,15 @@ SUB mousedemo
     cy = 100  ' Initial y-coordinate\r
     maxmove = 50  ' Maximum movement in one step\r
     frm = 0  ' Frame counter\r
-    1\r
+1\r
     frm = frm + 1  ' Increment frame counter\r
     ' Check for user input on keyboard and exit if any key is pressed\r
     IF INKEY$ <> "" THEN SYSTEM\r
 \r
     ' Print the current coordinates and frame number.\r
     LOCATE 1, 1\r
-    PRINT cx, cy  ' Print current x and y coordinates\r
-    PRINT frm     ' Print current frame number\r
+    PRINT "X: " + STR$(cx) + "  Y:" + STR$(cy) + "      " ' Print current x and y coordinates\r
+    PRINT "Frame #" + STR$(frm)     ' Print current frame number\r
 \r
     ' Erase circle at the old mouse position by drawing black circle\r
     CIRCLE (cx, cy), 10, 0\r
@@ -98,7 +98,7 @@ SUB putword (addr, dat)
     ' This subroutine stores a word (2 bytes) at the specified address in RAM.\r
     b$ = HEX$(dat)  ' Convert data to hexadecimal\r
 \r
-    2\r
+2\r
     IF LEN(b$) < 4 THEN b$ = "0" + b$: GOTO 2  ' Ensure four digits\r
 \r
     ' Split the word into two bytes.\r
@@ -118,12 +118,10 @@ SUB start
     ' Retrieve mouse data table address within TSR as pointed by interrupt 79h\r
     extSEG = PEEK(&H79 * 4 + 3) * 256\r
     extSEG = extSEG + PEEK(&H79 * 4 + 2)\r
-    PRINT "Segment is: " + HEX$(extSEG)  ' Print segment address\r
 \r
     ' Retrieve the offset address of the mouse driver.\r
     extADDR = PEEK(&H79 * 4 + 1) * 256\r
     extADDR = extADDR + PEEK(&H79 * 4 + 0)\r
-    PRINT "relative address is:"; extADDR  ' Print offset address\r
     DEF SEG = extSEG  ' Set segment for memory access\r
 \r
     ' Check if the mouse driver is loaded by verifying the magic number (1983).\r
@@ -133,3 +131,4 @@ SUB start
         SYSTEM  ' Exit program if mouse driver is not loaded\r
     END IF\r
 END SUB\r
+\r
diff --git a/Miscellaneous/Mouse driver/screenshot.png b/Miscellaneous/Mouse driver/screenshot.png
new file mode 100644 (file)
index 0000000..dc8e0a0
Binary files /dev/null and b/Miscellaneous/Mouse driver/screenshot.png differ