1

I'm using TASM in DOSBox, Windows. I'm learning about the int 33h interrupt. In normal text mode, I am able to get the mouse position correctly.

But when I enter the graphics mode

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

the mouse position is fixed at the center, which is at (320,100) since the mouse resolution is 640x200. When I enter the graphics mode, the mouse cursor position in the cx and dx registers doesn't change, even though the mouse is moving.

[EDIT]:
I think this is a problem on the VESA modes.
How do I get a mouse cursor in VESA mode?

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
  • i don't think the mouse cursor works on this mode. i've also tried using the cursor mask, in mode 13h, it works, but in this mode it doesnt work also. help please – Jhon Paul Jaspe Sep 01 '17 at 09:50
  • 1
    The function [Int 33h/AX=0001](http://www.ctyme.com/intr/rb-5957.htm) [SHOW MOUSE CURSOR] doesn't work in 800x600 mode with the firmware provided by DOSBox but the [Int 33h/AX=0003](http://www.ctyme.com/intr/rb-5959.htm) [RETURN POSITION AND BUTTON STATUS] does. What is your goal? Showing a cursor? – Margaret Bloom Sep 01 '17 at 10:14
  • I created a whack-a-mole game, and all the graphics are created, the only problem left is the clicking of the moles. what I would like to do is, when a click happened, i get the position of the click and do some computation to know what i clicked. The clicks are working, not just in the right positions. I would like to show also the cursor – Jhon Paul Jaspe Sep 01 '17 at 10:17
  • Update: I've done some tests, using the left and right click. When a left click happens on the right side of the screen, (x >= 320 in mouse resolution), it says "left clicked", but when on the left side of the screen (x < 320 in mouse resolution), it wont print anything. It doesn't show the cursor, but when i move the mouse and click, it is printing "left clicked". So, i know i can get the mouse position, but how do i show the cursor? Is there a way to show the cursor? please help – Jhon Paul Jaspe Sep 01 '17 at 10:53
  • 1
    The functions Int33h/AX=0008 and Int33h/AX=0009 let you set the range of the mouse. Setting it to 800x600 will greatly simplify the logic. You have to draw the cursor manually, save the area under the cursor and draw on top of it. When the mouse moves, restore the area and repeat. Some tricks may be needed in order to keep it smooth. – Margaret Bloom Sep 01 '17 at 11:13
  • Won't that make the game laggy? or be less responsive in other tasks? for example, i make a 16x16 size cursor? i would have to read 16x16 pixel graphic data and redraw 16x16 pixel graphic data everytime the cursor moves. Will that make the game very very slow, and unresponsive? Or it can handle it? – Jhon Paul Jaspe Sep 01 '17 at 12:11
  • It will slow it down, the magnitude I cannot tell. Being forced to use the BIOS services to read/write pixel will have some impact on performance. That's why I mentioned "tricks". You have to try, I'm afraid. If I have some time I will make a demo to see how it performs. – Margaret Bloom Sep 01 '17 at 12:48
  • I've done it but only 1 pixel, lol. still working on how to read multiple pixels – Jhon Paul Jaspe Sep 01 '17 at 15:37
  • tried using 2x2 pixel, its super slow already – Jhon Paul Jaspe Sep 01 '17 at 15:55
  • Are you using the [Int 44h/AX=000Ch [DEFINE INTERRUPT SUBROUTINE PARAMETERS]](http://www.ctyme.com/intr/rb-5968.htm) service to catch the mouse movements? I tried drawing a 4x4 and it was smooth. – Margaret Bloom Sep 02 '17 at 07:08
  • No, i don't know what that is. I'm using [Int 33h/AX=0003h] to get the mouse position, then i'm using [Int 10h/AH=0Dh] to read the pixel at a position, and [Int 10h/AH=0Ch] to write a pixel at a position. – Jhon Paul Jaspe Sep 02 '17 at 09:02
  • I'm having trouble in reading and drawing, but im getting the right mouse position. When reading and drawing 1x1 pixel, it works. but i tried reading and drawing multiple pixels, and maybe theres something wrong with my code for reading and drawing multiple pixels – Jhon Paul Jaspe Sep 02 '17 at 09:04
  • hope you do use pages ... if not see this [#1 VESA C++ example](https://stackoverflow.com/a/21699076/2521214) and [800x600x8bpp PCX view TASM](https://stackoverflow.com/a/45780565/2521214). Simply each time you got CY or Z flag after address increment for next pixel increase page ... (heh the 2nd link is your question :)) – Spektre Sep 04 '17 at 07:49

1 Answers1

-1

This is a separated part from the "cutemouse-driver", but only for PS2 or USB(legacy enable) mouse without serial ports and without to draw the mousepointer:

      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
  • 1
    this does not answer the question. The OPs problem lies in rendering the cursor not in obtaining its position. – Spektre Sep 04 '17 at 07:45