我在DOSBox,Windows中使用TASM。我正在了解中断int 33h
。在普通文本模式下,我能够正确获取鼠标位置。
但是当我进入图形模式时
; 800x600 - 256 colors
mov ax, 04F02h
mov bx, 0103h
int 10h
鼠标位置固定在中心,即 (320,100),因为鼠标分辨率为 640x200。当我进入图形模式时,即使鼠标在移动,cx
和dx
寄存器中的鼠标光标位置也不会改变。
[编辑]:
我认为这是VESA模式的问题。
如何在 VESA 模式下获取鼠标光标?
这是与"可爱鼠标驱动程序"分开的部分,但仅适用于没有串行端口且没有绘制鼠标指针的 PS2 或 USB(传统启用)鼠标:
call CHECKPS2
jc short ERROR
call PS2ON
jc short ERROR
mov bx, [X]
mov cx, [Y]
mov dx, [S]
;-------------------------------
ERROR: call PS2OFF
;---------------------------------------------------------------
; Sub-Routine
;---------------------------------------------------------------
CHECKPS2: int 11h ; get equipment list
test al, 3
jz short NOPS2 ; jump if PS/2-Mouse not indicated
mov bh, 3
mov ax, 0C205h
int 15h ; initialize mouse, bh=datasize
jc short NOPS2
mov bh, 3
mov ax, 0C203h
int 15h ; set mouse resolution bh
jc short NOPS2
mov ax, cs
mov es, ax
mov bx, OFFSET PS2TEST
mov ax, 0C207h
int 15h ; mouse, es:bx=ptr to handler
jc short NOPS2
xor bx, bx
mov es, bx ; mouse, es:bx=ptr to handler
mov ax, 0C207h
int 15h
ret
NOPS2: stc
ret
;---------------------------------------------------------
PS2ON: call PS2OFF
mov ax, cs
mov es, ax
mov bx, OFFSET PS2IRQ
mov ax, 0C207h ; es:bx=ptr to handler
int 15h
jc short NOPS2
mov bh, 1 ; set mouse on
mov ax, 0C200h
int 15h
ret
;-------------------------------
PS2OFF: xor bx, bx ; set mouse off
mov ax, 0C200h
int 15h
xor bx, bx
mov es, bx
mov ax, 0C207h ; es:bx=ptr to handler
int 15h
ret
;---------------------------------------------------------------------------
; PS2-Mousehandler
;---------------------------------------------------------------------------
PS2IRQ: cld
push ds
pusha
mov ax, @DATA
mov ds, ax
mov bp, sp
mov ax, [bp+22+6] ; buttons
mov bx, [bp+22+4] ; X movement
mov cx, [bp+22+2] ; Y movement
mov [S], ax
mov [X], bx
mov [Y], cx
popa
pop ds
PS2TEST: retf
;----------------------------------------------
.DATA
S DW 0 ;Bitfields for pointing device status:
;Bit(s) Description (Table 00525)
; 15-8 reserved (0)
; 7 Y data overflowed
; 6 X data overflowed
; 5 Y data is negative
; 4 X data is negative
; 3 reserved (1)
; 2 middle button pressed
; 1 right button pressed
; 0 left button pressed
X DW 0
Y DW 0