QBasic in Dosbox : MS-DOS interrupt says there's no mouse

52 views Asked by At

I'm using QBASIC version QB45

I'm using the classic code snippet to get the state of the mouse, through a system interrupt :

 STATIC Regs as RegType
 Regs.ax = &H0
 CALL INTERRUPT(&H33, Regs, Regs)

IF Regs.ax = &HFFFF THEN
    PRINT "ooops! No Mouse!"
    SYSTEM
ENDIF

When I run the program, it does fail with "oooops! No mouse!"

I know that there is a mouse and that MS-DOS is not bothered by DosBox, as the mouse does work in the QBASIC graphical interface and I'm using it. It's only inside my program that it doesn't work.

Any idea?

1

There are 1 answers

0
jeancallisti On

There were two distinct issues:

  1. There was an issue with the STATIC . I thought it meant "local variable2 in QBASIC. So I removed it.

  2. despite Reg.ax being negative, the mouse still works. I can read CX, DX to get the mouse position and BX to get the buttons status.

Which leads to the core issue : Why does Dosbox say that there's no mouse available when I can display it and show it?

Maybe I simply misunderstand the meaning of "negative AX"; maybe it just means "no driver" but the mouse still works magically. For example, this page does not mention a possible negative result : https://www.equestionanswers.com/c/c-int33-mouse-service.php

Dosbox has an int33=false setting, maybe it has something to do with it. See https://github.com/joncampbell123/dosbox-x/issues/1315

I've updated my code to use INTERRUPTX instead of INTERRUPT:

 STATIC Regs as RegTypeX
 Regs.ax = &H0
 CALL INTERRUPTX(&H33, Regs, Regs)

'IF Regs.ax = &HFFFF THEN
'    PRINT "ooops! No Mouse!"
'    SYSTEM
'ENDIF

VAR SHARED MOUSEX = Regs.CX
VAR SHARED MOUSEY = regs.DX