It was my project to create a duck hunt game in masm615 8086 assembly and in that I have implemented a crosshair that moves with cursor using the INT 33 and I have added a check where on left click of my mouse it checks if the center coordinates of crosshair is in range of any of spirtes coordinates if yes the exit the procedure else continue the loop now the problem in my program is that whenever
I click it it call the checkduckinrange procedure but for some reason that program never returns true (AX=1) even if I click on duck it always returns false (AX=0) I don’t know whats happening need help. Pleaseeee
draw proc
mov ah,0ch
mov dx, yi ; y coordinate initial( up down)
y:
mov cx, xi ;x coordinate initial (left right)
x:
mov al,[si] ; start array
int 10h
inc si ; increment full row (x axis)
inc cx
cmp cx, xf ; x coordinate final( left right)
jb x
inc dx ; jump to next row
cmp dx, yf ; y coordinate final( up down)
jb y
ret
draw endp
Game1 proc
mov bp,sp
mov bullet_count, 0
mov al, 13h
mov ah, 00h
int 10H
call setScene
mov si, offset crosshair ;draw
mov yi, 80
mov yf, 94
mov xi, 140
mov xf, 170
call draw
mov yi, 80
mov yf, 97
mov xi, 150
mov xf, 184
mov bx,0
mov bx,xi
mov temp_xi,bx
mov bx,xf
mov temp_xf, bx
MOV AX,0
INT 33H
mov cx, 0
mov dx, 290
mov ax,7
int 33h
mov cx,0
mov dx, 186
mov ax,8
int 33h
mov cx,8*4
mov dx,16*4
mov ax,0Fh
int 33h
check_time:
cmp duck_xi, 0
JL neg_vel
cmp duck_xf, 140H
JG neg_vel
jmp moveit
neg_vel:
neg velocity_x
moveit:
MOV AX, velocity_x
mov bx,temp_xi
mov xi,bx
mov bx,temp_xf
mov xf, bx
ADD xi,AX
ADD xf,AX
mov yi, 80
mov yf, 97
mov bx,xi
mov temp_xi,bx
mov bx,xf
mov temp_xf, bx
mov bx,0
call backg
mov si, offset duck1
MOV bx, xi
mov duck_xi ,bx
MOV bx, yi
mov duck_yi, bx
MOV bx, xf
mov duck_xf ,bx
MOV bx, yf
mov duck_yf, bx
call draw
MOV AX,3
INT 33H
mov si, offset crosshair ;draw
CMP CX, 140H
JG Nosub
SUB CX, 140H
nosub:
mov yi, DX
mov yf, DX
ADD yf, 14
mov xi, CX
mov xf, CX
ADD xf, 30
mov ax, yf
mov cross_yf, ax
sub cross_yf, 9
mov ax, xf
mov cross_xf, ax
sub cross_xf, 17
call draw
cmp BL, 1
je check_duck
jmp draw_cont
check_duck:
call checkDuckInRange
CMP AX, 1
JE next_round
draw_cont:
call setScene
jmp check_time
next_round:
mov sp,bp
RET
Game1 ENDP
checkDuckInRange proc
mov bp,sp
MOV AX, duck_xi
CMP AX, cross_xf
JG notInRange
MOV AX, cross_xf
CMP AX, duck_xf
JG notInRange
MOV AX, duck_yi
CMP AX, cross_yf
JL notInRange
MOV AX, cross_yf
CMP AX, duck_yf
JG notInRange
MOV AX, 1
RET
notInRange:
MOV AX, 0
mov sp,bp
RET
checkDuckInRange endp
I tried doing different stuff but I don’t know why the program never returns true my program have never once return true (AX=1)
Hassan Ali Shoro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.