Reputation: 17
On my code I have to check if the mouse press is on my image. When I am debugging the code I see the the interrupt returns the same information over and over again mikoon is the starting point of the printing of the picture (16*16)
proc checker
xor bx, bx
mov ax,05h ; Return button press data
int 33h
shr cx, 1
mov ax, 0A000h
sub [mikoom], ax
shr [mikoom], 2
jmp cont
check:
mov ax,05h ; Return button press data
int 33h
shr cx, 1
cont:
cmp cx, [mikoom]
jae odchaecker
jmp check
odchaecker:
mov ax, 16h
add [mikoom], ax
cmp cx, [mikoom]
jbe caller
mov ax, 16h
sub [mikoom], ax
jmp check
caller:
call CleanScreen
ret
endp
proc CleanScreen
mov ah, 0
int 10h
ret
endp
Upvotes: 1
Views: 189
Reputation: 9899
Whenever your CleanScreen procedure sets the video mode AL
contains the (leftover) value 16h which is 22 in decimal. There's no such video mode available!
You don't mention it but I'm kind of assuming that you're using video mode 13h (320x200).
xor bx, bx mov ax,05h ; Return button press data int 33h shr cx, 1
This mouse function returns x,y-coordinates in CX
and DX
.
Your program does not even use the y-coordinate!
Also what's with this subtraction of 0A000h? The video memory is at segment address 0A000h but that is of no concern in this program.
What you need to do is compare CX
with the left side and right side coordinates of your picture and compare DX
with the top side and bottom side coordinates of your picture.
cmp cx, [LeftX]
jb outside
cmp cx, [RightX] ; RightX == LeftX + Width - 1
ja outside
cmp dx, [TopY]
jb outside
cmp dx, [BottomY] ; BottomY == TopY + Height - 1
ja outside
;
; Here you're inside the picture
;
outside:
;
; Here you're outside the picture
;
Upvotes: 1