First post, by Peter Swinkels
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-ZTYPE RegistersStrax AS INTEGERcx AS INTEGERdx AS INTEGERbx AS INTEGEREND TYPEDECLARE FUNCTION LoadWrapper$ ()DECLARE SUB CallInt33h ()DIM SHARED Int33h AS STRINGDIM SHARED Registers AS RegistersStrCLSInt33h = LoadWrapper$Registers.ax = &H1Registers.cx = &H0Registers.dx = &H0Registers.bx = &H0CallInt33hDORegisters.ax = &H3Registers.cx = &H0Registers.dx = &H0Registers.bx = &H0CallInt33hLOCATE 1, 1: PRINT Registers.cx, Registers.dx, " ";LOOP WHILE INKEY$ = ""ENDSUB CallInt33hDEF SEG = VARSEG(Int33h)CALL ABSOLUTE(Registers, SADD(Int33h))END SUBFUNCTION LoadWrapper$DIM FileH AS INTEGERFileH = FREEFILEOPEN "Int33h.BIN" FOR INPUT LOCK READ WRITE AS FileHCLOSE FileHFileH = FREEFILEOPEN "Int33h.BIN" FOR BINARY LOCK READ WRITE AS FileHInt33h = INPUT$(LOF(FileH), FileH)CLOSE FileHLoadWrapper$ = Int33hEND 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