Why can't i get different mouse clicks coordinates twice? assembly

℡╲_俬逩灬. 提交于 2019-12-25 01:24:38

问题


I have a small procedure that is supposed to check if there was a click and get the click's coordinates. In the first time, it works but when I call it at the second time it doesn't even let me click again... why? what is wrong?

I tried everything, put the mouse setting outside the procedure-didn't do any differences. Also, I tried to create some kind of small thing where you click once, put the cx in si and call sam click check again and comparing si and the new cx and it is different (si is 0 at the start so no garbage) but at the real screen i can only click once before it jumps to the comparing part.

IDEAL
MODEL small
STACK 100h
DATASEG
a11 db ?
a12 db ?
b1 db ?
a21 db ?
a22 db ?
b2 db ?
CODESEG
;---------------------------------------------------------
;find color from click of mouse
;---------------------------------------------------------
proc line ;vertical line 
mov si,5d
mov bh,0h
startagain: ;;print another pixel
mov ah,0ch
int 10h
inc dx
dec si
cmp si,0
jnz startagain

ret
endp line
;---------------------------------------------------------
proc box1 ; make box 1/7-number 0
mov cx,8
mov dx,8
mov al,4
call line

mov di,10d
here:
;make a box
mov cx,8
mov dx,8
inc cx
call line
dec di
cmp di,0

jnz here

ret
endp box1
;---------------------------------------------------------
proc box2 ; make box 1/7-number 0
mov cx,20
mov dx,20
mov al,8
call line

mov di,10d
here1:
;make a box
mov cx,8
mov dx,8
inc cx
call line
dec di
cmp di,0

jnz here1

ret
endp box2
;---------------------------------------------------------

PROC LeftButtonClick
    mov  ax, 0000h  ; reset mouse
    int  33h        
    cmp  ax,0FFFFh
    jne  NoMouse
    mov  ax, 0001h  ; show mouse
    int  33h
    MouseLP: ; till cx= x of click & dx= y
    mov  ax, 0003h  ; get mouse position and buttonstatus
    int  33h       
    cmp bx, 1      ; check left mouse click
    jne   MouseLP    ; Loop until mouse click
    shr cx,1
    dec dx 

    call findcolor

NoMouse:    
    ret
ENDP LeftButtonClick 
;---------------------------------------------------------
proc findcolor
    add dl,'0'
    mov ah,02
    int 21
    ret
endp findcolor
;---------------------------------------------------------
start:
    mov ax, @data
    mov ds, ax
    ; Graphic mode
    mov ax, 13h
    int 10h

    call box1
    call box2
    call LeftButtonClick
    xor bx,bx
    call LeftButtonClick

    ; Wait for key press
    mov ah,00h 
    int 16h

; Return to text mode
    mov ah, 0
    mov al, 2
    int 10h 

exit:
    mov ax, 4c00h
    int 21h
END start

At the main program, I need to recive 6 different clicks on boxes that displayed on the screen and from each click's coordinates I find the color of the box. Why can I only click once on the screen???

来源:https://stackoverflow.com/questions/55870777/why-cant-i-get-different-mouse-clicks-coordinates-twice-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!