VOGONS


First post, by Peter Swinkels

User metadata
Rank Oldbie
Rank
Oldbie

A mouse interrupt caller for QBasic:

; Mouse interrupt call procedure for QBasic.
push bp ; Save previous bp.
mov bp,sp ; Set new bp.
push si ; Save si.
mov si,[bp+6] ; Load registers structure offset.
mov ax,[si] ; Load values into CPU registers.
mov cx,[si+2] ;
mov dx,[si+4] ;
mov bx,[si+6] ;
int 0x33 ; Call mouse interrupt.
mov [si],ax ; Save CPU registers to structure.
mov [si+2],cx ;
mov [si+4],dx ;
mov [si+6],bx ;
pop si ; Restore si.
pop bp ; Restore bp.
retf 2 ; Return and remove arguments from stack.

Just assemble it with Nasm or similar.

A QBasic example:

DEFINT A-Z

TYPE RegistersStr
ax AS INTEGER
cx AS INTEGER
dx AS INTEGER
bx AS INTEGER
END TYPE

DECLARE FUNCTION LoadWrapper$ ()
DECLARE SUB CallInt33h ()

DIM SHARED Int33h AS STRING
DIM SHARED Registers AS RegistersStr

CLS
Int33h = LoadWrapper$

Registers.ax = &H1
Registers.cx = &H0
Registers.dx = &H0
Registers.bx = &H0
CallInt33h

DO
Registers.ax = &H3
Registers.cx = &H0
Registers.dx = &H0
Registers.bx = &H0
CallInt33h
LOCATE 1, 1: PRINT Registers.cx, Registers.dx, " ";
LOOP WHILE INKEY$ = ""

END

SUB CallInt33h
DEF SEG = VARSEG(Int33h)
CALL ABSOLUTE(Registers, SADD(Int33h))
END SUB

FUNCTION LoadWrapper$
DIM FileH AS INTEGER

FileH = FREEFILE
OPEN "Int33h.BIN" FOR INPUT LOCK READ WRITE AS FileH
CLOSE FileH

FileH = FREEFILE
OPEN "Int33h.BIN" FOR BINARY LOCK READ WRITE AS FileH
Int33h = INPUT$(LOF(FileH), FileH)
CLOSE FileH

LoadWrapper$ = Int33h
END FUNCTION

Tested with QBasic 1.1 and QuickBASIC 4.5. Probably works with QuickBASIC 7.1 and VBDos too.

Changing it to handle other registers and interrupts should be simple. 😀

New versions of programs originally for qb45 changed to work with QBasic will likely be released in the near future! 😀

My GitHub:
https://github.com/peterswinkels

Reply 1 of 2, by Peter Swinkels

User metadata
Rank Oldbie
Rank
Oldbie

Okay, I tested it with VBDOS, to make it work with there VARSEG needs to be changed to SSEG. Furthermore, the code works fine in the example I provided but it refuses to cooperate in when I try to integrate into my other programs. As near as I can tell the interrupt caller fails to read the parameters properly.

My GitHub:
https://github.com/peterswinkels

Reply 2 of 2, by Peter Swinkels

User metadata
Rank Oldbie
Rank
Oldbie

Okay, here is a fully working program demonstrating how to use the mouse in QBasic:

https://github.com/PeterSwinkels/QBDraw/

As to updating my other projects to work with QBasic, I was a bit too optimistic about what was possible and am not going through with that.

My GitHub:
https://github.com/peterswinkels