【问题标题】:Unable to get mov ax,3 int 33h to work in graphics mode无法让 mov ax,3 int 33h 在图形模式下工作
【发布时间】:2020-12-31 20:40:20
【问题描述】:

我正在尝试在图形模式 (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

【问题讨论】:

    标签: assembly x86-16 tasm dosbox


    【解决方案1】:

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

    【讨论】:

    • 他们不应该更好地保留那些CXDX 寄存器宏代码;所以不是“在调用 *drawPlatform 之前”。如果他们把所有东西都很好地放在一起,就不会那么大惊小怪了。
    • 在我看来 mov ax,3 int 33h 应该在 drawPlatform 之后来完全避免这个问题。一开始我没有注意到,所以我只是在上面进行了快速修复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多