微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决无法让 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 的吗?或者至少如果您有一些打印例程,您可以在代码中的重要位置放置一些屏幕消息以查看事件流。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。