我的代码中有很多我不知道如何解决的问题: 1.当我单击正方形时,如果不单击它至少8次,则无法单击另一个。 2.当玩家完成其第一回合时,他无法单击另一对方格。 3.我试图解决单击现有正方形的问题,但没有成功。 非常感谢您,如果您能为我提供帮助,对于英语不好,我深表歉意。
游戏的工作方式如下:玩家一点击一个正方形。 findColor proc通过坐标并检查单击了哪个正方形以及该正方形是什么颜色。接下来是showColor颜料的立方体。现在,我将inTurn(内部转弯)与1进行比较-我想检查玩家单击的方块数。如果玩家仅单击1个正方形,则我跳至waitMS绘制另一个。当玩家绘制两个正方形时,我将第一个正方形的颜色与第二个颜色进行比较。如果它们与isSame proc颜色不同,我将删除该正方形。最后,我检查是否已发现所有8对([转])。如果所有8个都被发现,我将比较两个分数以检查谁赢了。如果不是所有的8对都被发现,我会跳回前卫再转一圈。 如果您愿意帮助我,再次感谢您。 Status window if two square's are not the same color and need to be deleted screen after one click screen at start of the game
IDEAL
MODEL small
STACK 0f500h
MAX_BMP_WIDTH = 320
MAX_BMP_HEIGHT = 200
SMALL_BMP_HEIGHT = 40
SMALL_BMP_WIDTH = 40
DATASEG
first_s db 'first_screen.bmp', 0
teco_s db 'teco.bmp', 0
win_1 db 'win_screen_1.bmp', 0
win_2 db 'win_screen_2.bmp', 0
sizeX dw 80d
sizeY dw 50d
x1 dw 3d ; temp x
y1 dw 3d
x dw 3d
y dw 3d
x2 dw ?
y2 dw ?
x3 dw ?
x4 dw ?
turn dw 0 ; number of pairs found
Score1 dw 0
Score2 dw 2
inTurn db 0
outTurn dw 0
tempX dw ?
tempY dw ?
board db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
num dw 49
color db 4
color2 db 8
OneBmpLine db MAX_BMP_WIDTH dup (0) ; One Color line read
buffer
ScreenLineMax db MAX_BMP_WIDTH dup (0) ; One Color line read
buffer
;BMP File data
FileHandle dw ?
Header db 54 dup(0)
Palette db 400h dup (0)
SmallPicName db 'zicaron.bmp',0
BmpFileErrorMsg db 'Error At Opening Bmp File .', 0dh,
0ah,'$'
ErrorFile db 0
BB db "BB..",'$'
BmpLeft dw ?
BmpTop dw ?
two db 2
BmpColSize dw ?
BmpRowSize dw ?
location db 0
location2 db 0
CODESEG
start:
mov ax, @data
mov ds, ax
mov ax,13h
int 10h
mov [BmpLeft],0
mov [BmpTop],0
mov [BmpColSize], 320
mov [BmpRowSize] ,200
mov dx,offset SmallPicName
call OpenShowBmp
prog:
mov [inTurn], 0
inc [outTurn]
mov ax, 0h
int 33h
mov ax, 1h
int 33h
waitMS:
mov ax, 1h
int 33h
mov ax, 3h
int 33h
cmp bx, 01h ; בדיקה אם כפתור שמאלי של העכבר הוקלק
jne waitMS
shr cx, 1 ; X ערך
sub dx, 1 ; Y ערך
call findColor ; find the box to draw
call showColor ; call to paint the box
;-----------------------
cmp [inTurn], 1
jne check
mov ah, [location]
mov [location2], ah
jmp waitMS
check:
call isSame
cmp [turn], 8
jge finalWinner
jmp prog
finalWinner:
push [Score1]
pop bx
cmp [Score2], bx
jg Screen_Win_2
cmp [Score2], bx
jl Screen_Win_1
tie:
mov dx, offset teco_s
call OpenShowBmp
mov ah,00h
int 16h
jmp exit
Screen_Win_1:
mov dx, offset win_1
call OpenShowBmp
mov ah,00h
int 16h
jmp exit
Screen_Win_2:
mov dx, offset win_2
call OpenShowBmp
mov ah,00h
int 16h
jmp exit
exit:
mov dx, offset BB
mov ah,9
;int 21h
mov ah,0
int 16h
mov ax,2
int 10h
mov ax, 4c00h
int 21h
proc showColor near
mov ax,2h
int 33h
push [x]
pop [tempX]
mov cx, 46
raw:
push cx
mov cx, 75
doit:
push cx
; Print one dot
mov bh,0h
mov cx, [x]
mov dx, [y]
mov al, [color]
mov ah,0ch
int 10h
inc [x]
pop cx
loop doit ;;;;;;;;;;;;;;;;;;;;
pop cx
inc [y]
push [tempX]
pop [x]
loop raw ;;;;;;;;;;;;;;;;;;;;
ret
endp showColor
proc timeDelay near
mov cx, 0Fh
mov dx, 4240h
mov ah, 86h
int 15h
ret
endp timeDelay
proc findColor near
mov bx, offset board
cmp cx, 80
jl firstC
cmp cx, 160
jl secondC
cmp cx, 240
jl thirdC
mov [x], 243
call fourthCP
jmp ext
thirdC:
mov [x], 163
call thirdCP
jmp ext
secondC:
mov [x], 83
call secondCP
jmp ext
firstC:
mov [x], 3
call firstCP
ext:
cmp [byte ptr bx + location], 0
je nxt
call callWaitMS
nxt:
mov [bx + location], 1
inc [inTurn]
cmp [inTurn], 1
jne timeToLeave
mov ah, [color]
mov [color2], ah
push [x]
pop [x1]
push [y]
pop [y1]
mov ah, [location]
mov [location2], ah
jmp plsExt
timeToLeave:
push [x]
pop [x2]
push [y]
pop [y2]
plsExt:
ret
endp findColor
proc callWaitMS near
jmp waitMS
ret
endp callWaitMS
proc fourthCP near
cmp dx, 50
jl oneL
cmp dx, 100
jl twoL
cmp dx, 150
jle thirdL
fourthL:
mov [location], 15
mov [y], 154
mov [color], 5h
jmp extD
thirdL:
mov [location], 14
mov [y], 104
mov [color], 3h
jmp extD
twoL:
mov [location], 13
mov [y], 54
mov [color], 2h
jmp extD
oneL:
mov [location], 12
mov[y], 4
mov [color], 9h
jmp extD
extD:
ret
endp fourthCP
proc thirdCP near
cmp dx, 50
jl oneLS
cmp dx, 100
jl twoLS
cmp dx, 150
jle thirdLS
fourthLS:
mov [location], 11
mov [y], 154
mov [color], 15h
jmp extT
thirdLS:
mov [location], 10
mov [y], 104
mov [color], 6h
jmp extT
twoLS:
mov [location], 9
mov [y], 54
mov [color], 14h
jmp extT
oneLS:
mov [location], 8
mov [y], 4
mov [color], 3h
jmp extT
extT:
ret
endp thirdCP
proc secondCP near
cmp dx, 50
jl oneLT
cmp dx, 100
jl twoLT
cmp dx, 150
jl thirdLT
fourthLT:
mov [location], 7
mov [y], 154
mov [color], 2h
jmp extS
thirdLT:
mov [location], 6
mov [y], 104
mov [color], 9h
jmp extS
twoLT:
mov [location], 5
mov [y], 54
mov [color], 14h
jmp extS
oneLT:
mov [location], 4
mov [y], 4
mov [color], 5h
jmp extS
extS:
ret
endp secondCP
proc firstCP near
cmp dx, 50
jl oneLA
cmp dx, 100
jl twoLA
cmp dx, 150
jl thirdLA
fourthLA:
mov [location], 3
mov [y], 154
mov [color], 12h
jmp extF
thirdLA:
mov [location], 2
mov [y], 104
mov [color], 15h
jmp extF
twoLA:
mov [location], 1
mov [y], 54
mov [color], 12h
jmp extF
oneLA:
mov [location], 0
mov [y], 4
mov [color], 6h
jmp extF
extF:
ret
endp firstCP
proc isSame near
mov bx, offset board
mov ah, [color2]
cmp [color], ah
jne calc
inc [turn]
push [outTurn]
pop ax
div [two]
cmp ah , 0
jne playerOne
cmp ah, 1
jne playerTwo
playerOne:
inc [turn]
inc [Score1]
jmp prog
playerTwo:
inc [turn]
inc [Score2]
jmp prog
calc:
call timeDelay
call timeDelay
mov [bx + location], 0
mov [bx + location2], 0
mov [color], 0
push [x2]
pop [x]
push [y2]
pop [y]
push [x2]
pop [tempX]
call showColor
push [x1]
pop [x]
push [y1]
pop [y]
push [x1]
pop [tempX]
call showColor
jmp prog
ret
endp isSame
;========================
;==========================
;===== Procedures Area ===
;==========================
;==========================
; input :
; 1.BmpLeft offset from left (where to start draw the picture)
; 2. BmpTop offset from top
; 3. BmpColSize picture width ,
; 4. BmpRowSize bmp height
; 5. dx offset to file name with zero at the end
proc OpenShowBmp near
push cx
push bx
call OpenBmpFile
cmp [ErrorFile],1
je @@ExitProc
call ReadBmpHeader
; from here assume bx is global param with file handle.
call ReadBmpPalette
call CopyBmpPalette
call ShowBMP
call CloseBmpFile
@@ExitProc:
pop bx
pop cx
ret
endp OpenShowBmp
; input dx filename to open
proc OpenBmpFile near
mov ah, 3Dh
xor al, al
int 21h
jc @@ErrorAtOpen
mov [FileHandle], ax
jmp @@ExitProc
@@ErrorAtOpen:
mov [ErrorFile],1
@@ExitProc:
ret
endp OpenBmpFile
proc CloseBmpFile near
mov ah,3Eh
mov bx, [FileHandle]
int 21h
ret
endp CloseBmpFile
; Read 54 bytes the Header
proc ReadBmpHeader near
push cx
push dx
mov ah,3fh
mov bx, [FileHandle]
mov cx,54
mov dx,offset Header
int 21h
pop dx
pop cx
ret
endp ReadBmpHeader
proc ReadBmpPalette near
; 4 bytes for each color BGR + null)
push cx
push dx
mov ah,3fh
mov cx,400h
mov dx,offset Palette
int 21h
pop dx
pop cx
ret
endp ReadBmpPalette
; Will move out to screen memory the colors
; video ports are 3C8h for number of first color
; and 3C9h for all rest
proc CopyBmpPalette near
push cx
push dx
mov si,offset Palette
mov cx,256
mov dx,3C8h
mov al,0 ; black first
out dx,al ;3C8h
inc dx ;3C9h
CopyNextColor:
mov al,[si+2] ; Red
shr al,2
out dx,al
mov al,[si+1] ; Green.
shr al,2
out dx,al
mov al,[si] ; Blue.
shr al,2
out dx,al
add si,4
loop CopyNextColor
pop dx
pop cx
ret
endp CopyBmpPalette
proc ShowBMP
; BMP graphics are saved upside-down.
; Read the graphic line by line (BmpRowSize lines in VGA format),
; displaying the lines from bottom to top.
push cx
mov ax, 0A000h
mov es, ax
mov cx,[BmpRowSize]
mov ax,[BmpColSize] ;
xor dx,dx
mov si,4
div si
mov bp,dx
mov dx,[BmpLeft]
@@NextLine:
push cx
push dx
mov di,cx ; Current Row at the small bmp (each time -1)
add di,[BmpTop] ; add the Y on entire screen
mov cx,di
shl cx,6
shl di,8
add di,cx
add di,dx
; small Read one line
mov ah,3fh
mov cx,[BmpColSize]
add cx,bp ; extra bytes to each row must be divided by 4
mov dx,offset ScreenLineMax
int 21h
; Copy one line into video memory
cld ; Clear direction flag, for movsb
mov cx,[BmpColSize]
mov si,offset ScreenLineMax
rep movsb ; Copy line to the screen
pop dx
pop cx
loop @@NextLine
pop cx
ret
endp ShowBMP
proc SetGraphic
mov ax,13h ; 320 X 200
int 10h
ret
endp SetGraphic
END start