无法让 mov ax,3 int 33h 在图形模式下工作

问题描述

我正在尝试在图形模式 (13h) 中绘制一个矩形并检查它是否在任何时候被点击过,如果它被点击过,我想转到 "rectangleWasClicked:" ,这是我的方法但这似乎不起作用(就点击绘制的矩形而言)。

getAction:
                      
    mov  ax,0001h  
    int  33h ;Show Mouse

    checkMousePointer ; This simply does: mov ax,3 int 33h

     drawPlatform  65,85,15,10,240 ;This draws a rectangle,it takes x,y,color,height,width

     cmp bx,1 ;The user clicked,we need to check if that was on the rectangle
     ;shr cx
     jnz getAction ;It's not,so we keep checking

    ;Checking if the click was on the rectangle

     cmp cx,65
     jb done

     cmp cx,305
     ja done

     cmp dx,85
     jb done

     cmp dx,95
     ja done

     JMP rectangleWasClicked

     done:
    jmp getAction

我什至尝试使用 shr cx,1 来适应宏可能使用 640x200 分辨率的事实,但这似乎不起作用。 我还尝试将 bx 与 0 而不是 1 进行比较,这样每当鼠标悬停在我指定的区域时,它就会转到标签,但是无论我将鼠标悬停在整个屏幕的哪个位置,它都不会执行任何操作。 有什么想法吗?

这是 drawPlatform 宏:

    drawPlatform macro x,width ;x,y are the starting position (top left corner)
       local whilePlatformBeingDrawn
        mov cx,x                        
        mov dx,y                                
        whilePlatformBeingDrawn:
            drawPixel_implicit color
            inc cx ;the x-coordinate
            checkDifference cx,x,width ;Keep adding Pixels till Cx-P_x=widthPlatform
         JNG whilePlatformBeingDrawn 
            mov cx,x
            inc dx
            checkDifference dx,height
        JNG whilePlatformBeingDrawn
    endm drawPlatform

解决方法

在我看来,drawPlatform 在将 cxdx 与鼠标坐标进行比较之前正在破坏它们。如果您在调用 drawPlatform 之前 push cx push dx 然后调用 pop dx pop cx 之后,它应该可以工作。
TASM 不是带有 Turbo Debugger 的吗?或者至少如果您有一些打印例程,您可以在代码中的重要位置放置一些屏幕消息以查看事件流。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...