TASM显示鼠标光标

时间:2017-09-01 08:22:00

标签: assembly graphics mouse tasm dosbox

我在DOSBox,Windows中使用TASM。我正在学习int 33h中断。在普通文本模式下,我能够正确地获得鼠标位置。

但是当我进入图形模式时

; 800x600 - 256 colors
mov ax, 04F02h
mov bx, 0103h
int 10h

鼠标位置固定在中心位置,因为鼠标分辨率为640x200,所以位于(320,100)。当我进入图形模式时,即使鼠标移动,cxdx寄存器中的鼠标光标位置也不会改变。

[编辑]:
我认为这是VESA模式的一个问题 如何在VESA模式下获得鼠标光标?

1 个答案:

答案 0 :(得分:-1)

这是" cutemouse-driver"的分离部分,但仅适用于没有串行端口的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