I'm using QBASIC version QB45
我正在使用QBasic版本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.
我知道有一个鼠标,而且MS-DOS不受DOSBOX的影响,因为鼠标在QBasic图形界面中可以工作,我正在使用它。只有在我的程序中,它才不起作用。
Any idea?
有什么主意吗?
更多回答
优秀答案推荐
There were two distinct issues:
有两个截然不同的问题:
There was an issue with the STATIC
. I thought it meant "local variable2 in QBASIC. So I removed it.
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?
这就引出了核心问题:为什么DOSBOX说没有鼠标可用,而我可以显示它和显示它?
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
也许我只是误解了“负斧头”的意思;也许它只是意味着“没有司机”,但鼠标仍然可以神奇地工作。例如,该页面没有提到可能的负面结果: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
DOSBOX有一个int33=False设置,可能与此有关。请参阅https://github.com/joncampbell123/dosbox-x/issues/1315
I've updated my code to use INTERRUPTX instead of INTERRUPT:
我已经更新了我的代码,使用INTERRUPTX而不是中断:
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
更多回答
我是一名优秀的程序员,十分优秀!