为什么我的代码不检查第二个按钮按下情况?

问题描述 投票:0回答:1

这是我检查两台印刷机的代码。我不明白为什么第二个按钮不起作用

proc whatPress
pusha
    call setUpMagicNumbers
    call startscreen
    mov ax,00
        int 33h
        mov ax,01
        int 33h
waitforpress:
;call Esc_end
        mov ax, 3
        int 33h
        
 cmp cx, 112
        jb waitforpress
        cmp cx, 452
        ja waitforpress
        cmp dx, 81
        jb waitforpress
        cmp dx, 153
        ja waitforpress
        cmp bx, 1h
        je startt
        ;-----------
        check_second_button:; Check for the second button press
    cmp cx, 336
    jb waitforpress
    cmp cx, 624
    ja waitforpress
    cmp dx, 157
    jb waitforpress
    cmp dx, 198
    ja waitforpress
    cmp bx, 1h
    je Rulejump
    jmp waitforpress
        startt:
        mov ax,02
        int 33h
        call clean
      call GamePlay
        popa
        ret
        Rulejump:
        call RuleWaitPress
        popa
        ret
endp whatPress
assembly mouse x86-16
1个回答
0
投票

我不明白为什么第二个按钮不起作用

先了解一下吧

这是两个按钮在屏幕上的近似位置:

    
    
    
       **********************
       *                    *
       *      button 1      *
       *                    *
       **********************

                    *******************
                    *     button 2    *
                    *******************

为了让你的程序执行到达

check_second_button:
,需要满足5个条件。 CX和DX中的坐标必须落在第一个按钮内,并且不能有鼠标左键单击。
因此,如果坐标已经指向第一个按钮,并且观察到按钮之间没有重叠,我们就不能希望注册第二个按钮上的点击(因为我们显然在第二个按钮之外)!
即使存在一些重叠,它仍然不起作用,因为 BX 仍然持有与 1h 不同的数字,因此会跳转到 waitforpress

那就解决吧

waitforpress:
  mov  ax, 0003h
  int  33h            ; -> BX CX DX
  test bx, 1
  jnz  waitforpress   ; Wait for left mouse button to be pressed

check_first_button:
  cmp  cx, 112
  jb   check_second_button
  cmp  cx, 452
  ja   check_second_button
  cmp  dx, 81
  jb   check_second_button
  cmp  dx, 153
  ja   check_second_button

  ; startt:
  mov  ax, 0002h
  int  33h
  call clean
  call GamePlay
  popa
  ret

check_second_button:
  cmp  cx, 336
  jb   waitforpress
  cmp  cx, 624
  ja   waitforpress
  cmp  dx, 157
  jb   waitforpress
  cmp  dx, 198
  ja   waitforpress
  ; Rulejump:
  call RuleWaitPress
  popa
  ret
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.