[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4149: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3027) [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result Reading mouse ports - Pete's QBASIC Site
I realized it was probably possible to create an ASM-less method of accessing the mouse by polling it directly. This is theoretically straight forward, but it seems like something's in the way. The port (0x60) is always reading either 21 or 28.
Running under WinXP SP3 32-bit. (Dosbox doesn't do real mouse simulation).
DIM mouseBytes(2) AS INTEGER
byteCount% = 0
WAIT &H64, 2
OUT &H64, &HD4
OUT &H60, &HF4
DO UNTIL INKEY$ = "Q"
PRINT INP(&H64)
WAIT &H64, 2
OUT &H64, &HD4
OUT &H60, &HF5
IF INP(&H64) AND &H20 THEN
PRINT "Mouse active..."
mouseBytes(byteCount%) = INP(&H60)
byteCount% = byteCount% + 1
IF byteCount% = 3 THEN
IF mouseBytes(0) = &H80 OR mouseBytes(0) = &H40 THEN
ELSE
'PRINT "Byte 3"
'xDifference = (mouseBytes(0) AND 3) * 64 + mouseBytes%(1)
'yDifference = (mouseBytes(0) AND 12) * 16 + mouseBytes%(2)
'IF xDifference% >= 128 THEN :xDifference% = xDifference% - 256
'IF yDifference% >= 128 THEN :yDifference% = yDifference% - 256
'_MOUSEX% = _MOUSEX% + xDifference
'mouseY% = mouseY% + yDifference
mouseBtn1% = mouseBytes%(0) AND 32
mouseBtn2% = mouseBytes%(0) AND 16
PRINT "Byte: ", mouseBytes%(0), ", Status 1:", mouseBtn1%, ", Status 2:", mouseBtn2%
SLEEP 1
END IF
byteCount% = 0
END IF
END IF
LOOP
I looked into it some more... the problems are intractible in the modern age. Neither Dosbox or NTVDM accurately simulate the PS/2 mouse port, nor do they map USB mice to that port. The only way to access the mouse, now, is by calling the IRQ.
Here's the corrected code. It is correct, based on the DOS port docs I've found, but it doesn't work because NTVDM doesn't accept the write to get the mouse status (0xE5 at 0x60). That port 0x64, the status read port, doesn't set the mouse read flag at all is further evidence NTVDM doesn't accurately manage the mouse.
mouseStatus% = 0
DO
sleep 1
WAIT &H64, 0 'wait for port clear
OUT &H60, &HE9 'request mouse status
WAIT &H64, 1 'wait for port ready
mouseStatus% = INP(&H60) AND 1 ' get mouse status bytes
mouseStatus2% = INP(&H60)
LOOP UNTIL mouseStatus% > 0 OR INKEY$ = "Q"
PRINT mouseStatus%
END
mouseStatus% = 0
DO
SLEEP 1
WAIT &H64, 0 'wait for port clear
OUT &H60, &HE9 'request mouse status
WAIT &H64, 1 'wait for port ready
mouseStatus% = INP(&H60) AND 1 ' get mouse status bytes
mouseStatus2% = INP(&H60)
PRINT mouseStatus%; mouseStatus2%;
LOOP UNTIL INKEY$ = "q"
END