1

My program just can't get the mouse position correctly. I have tried two cases, the first: - No mouse reset - Code:

WAIT_FOR_CLICK:
    ; CHECK IF THE MOUSE IS CLICKED
    MOV AX,3H
    MOV BX, 0
    INT 33H
    CMP BX, 0
JZ WAIT_FOR_CLICK
; DISPLAY CLICK POSITION
MOV AL, 5
MOV AH, 0CH
INT 10H

This case always produces the same coordinate no matter where I click.

Second case, with mouse reset:

; RESET THE MOUSE
MOV AX, 0
INT 33H
; SHOW THE MOUSE POINTER
MOV AX, 1
INT 33H

WAIT_FOR_CLICK:
    ; CHECK IF THE MOUSE IS CLICKED
    MOV AX,3H
    MOV BX, 0
    INT 33H
    CMP BX, 0
JZ WAIT_FOR_CLICK
MOV AL, 5
MOV AH, 0CH
INT 10H

In this case, the mouse position varies. It isn't accurate at all (probably because I am using a super VGA video mode with 800x600 resolution) but I think it can be fixed with some scaling. The problem is, whenever I click the mouse, the pointer disappears and the mouse click isn't recorded. However, the second click is recorded. The mouse pointer stays hidden no matter what I do ( I put the call to INT 33H, 1 literally everywhere in the code and it still gets hidden once I click ). I am using Turbo GUI Assembler, any help please?

p.s I tried running the executable file using dosbox instead of inside the GUI Assembler, same results. I also tried a different assembler, same.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Yosry
  • 147
  • 2
  • 9
  • 1
    You should reset the mouse at the beginning of your code. The show/hide cursor are affecting counter starting at -1 (hidden), show will increment, and cursor is displayed when counter is zero, so multiple show calls may not help, or may actually hide the cursor, if the BIOS/mouse-driver really does hide cursor at counter==1, you should call show/hide just once and track the current state precisely. Also IIRC the DOS age correctly, the show cursor was always PITA for me and I never really figured how to use it correctly, so I always ended drawing my own cursor instead. – Ped7g Dec 04 '18 at 09:17
  • And `int 10h,C` takes "page number" in `bx`, which is button status after `int 33h` (btw, you don't need to set `mov bx,0` before `int 33h`, the mouse driver will overwrite it with button status any way). So put `mov bx,0` rather ahead of "draw pixel" `int 10h`. Your posted code doesn't show how it would handle "second" click, etc... [MCVE] please, if you want somebody else debugging it, who knows what else is happening in your real code in the parts you don't show, which SVGA mode you are using, etc... – Ped7g Dec 04 '18 at 09:19

0 Answers0