【发布时间】: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