首页 > 解决方案 > 无法让 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, y, color, height, 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, y, height
        JNG whilePlatformBeingDrawn
    endm drawPlatform

标签: assemblyx86-16tasmdosbox

解决方案


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


推荐阅读