; TSR hack that allows QBasic programs to use mouse. ; Made by Svjatoslav Agejenko ; in 2004.01 ; Homepage: http://svjatoslav.eu org 100h myint = 79h ; interrupt to hook, becomes pointer to data table mov dx, msg mov ah, 9 int 21h mov ax, 0 ; Saves old interrupt vector mov es, ax mov eax, [es:32] mov [oldVector], eax cli mov ax, cs ; Set new interrupt vector for IRQ 0 shl eax, 16 mov ax, custom mov [es:32], eax mov ax, dataTable ; Set interrupt vector for INT 79 (default) mov [es:4 * myint], eax sti mov ax, endPointer ; Calculate needed memory size, become TSR add ax, 32 mov dx, 0 mov bx, 16 div bx mov dx, ax mov ax, 3100h int 21h custom: pushf ; Execute default code in old int vector call dword [cs:oldVector] cmp [cs:isRunning], 0 ; Check if custom routine is already active jne EndOfRoutine mov [cs:isRunning], 1 ; Set active flag pusha push ds push es cli mov ax, 0bh ; Read Mouse Motion Counters int 33h add [CS:mouseHorisontal], cx add [CS:mouseVertical], dx mov ax, 3 ; read mouse buttons int 33h or [CS:mouseButtons], bx inc byte [CS:updated] sti pop es pop ds popa mov [cs:isRunning], 0 ; Terminate active flag EndOfRoutine: iret oldVector dd 0 isRunning db 0 dataTable: dw 1983 ; check number, indicates that module is loaded mouseHorisontal dw 0 mouseVertical dw 0 mouseButtons dw 0 updated db 0 endPointer: msg: file 'readme.txt' db '$'