تقریبا همه این بازی جالب انجام دادن کد این بازی با زبان اسمبلی امیدوارم لذت ببرید . البته یک اعتراف کنم من این برنامه رو خودم اجرا نکردم البته امیدوارم خطا نداشته باشه .
;@ SNAKE, Assembly Project
;@ 8:07 PM 6/30/2004
;===================================Stack Segment
stksg segment stack
db 32 dup('Stck')
stksg ends
;===================================Data Segment
datsg segment 'data'
CR equ 0dh ;Carriage Return (CR = 13)
LF equ 0ah ;Next row (LF = 10)
;===================================Construct status panel
pane1_1 db 32 dup(' '),0dah,5 dup(0c4h),0bfh,CR,LF,"$"
pane1_2 db 32 dup(' '),0b3h,5 dup(' '),0b3h,CR,LF
db 32 dup(' '),0b3h,'SCORE',0b3h,CR,LF
db 32 dup(' '),0b3h,4 dup(' '),'0',0b3h,CR,LF
db 32 dup(' '),0b3h,5 dup(' '),0b3h,CR,LF
db 32 dup(' '),0b3h,'LEVEL',0b3h,CR,LF
db 32 dup(' '),0b3h,'1 : 9',0b3h,CR,LF
db 32 dup(' '),0b3h,5 dup(' '),0b3h,CR,LF
db 32 dup(' '),0b3h,'SNAKE',0b3h,CR,LF
db 32 dup(' '),0b3h,2,' ',2,' ',1,0b3h,CR,LF
db 32 dup(' '),0b3h,5 dup(' '),0b3h,CR,LF
db 32 dup(' '),0b3h,'SPEED',0b3h,CR,LF
db 32 dup(' '),0b3h,5 dup(' '),0b3h,CR,LF
db 32 dup(' '),0b3h,5 dup(' '),0b3h,CR,LF,"$"
pane1_3 db 32 dup(' '),0c0h,5 dup(0c4h),0d9h,CR,"$"
;===================================Construct main panel
pane2_1 db ' ',219,25 dup(0dfh),219,CR,LF,"$"
pane2_2 db ' ',0ddh,25 dup(' '),0deh,CR,LF,"$"
pane2_3 db ' ',219,25 dup(0dch),219,CR,"$"
;===================================Construct speed menu
SPane_1 db ' ',0ddh,8 dup(' '),'S P E E D',8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),8 dup(' '),177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),6 dup(' '),177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),4 dup(' '),177,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),2 dup(' '),177,' ',177,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),219,' ',177,' ',177,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),'1 ','2 ','3 ','4 ','5',8 dup(' '),0deh,CR,LF,"$"
SPane_2 db ' ',0ddh,8 dup(' '),'S P E E D',8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),8 dup(' '),177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),6 dup(' '),177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),4 dup(' '),177,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),2 dup(' '),219,' ',177,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),177,' ',219,' ',177,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),'1 ','2 ','3 ','4 ','5',8 dup(' '),0deh,CR,LF,"$"
SPane_3 db ' ',0ddh,8 dup(' '),'S P E E D',8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),8 dup(' '),177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),6 dup(' '),177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),4 dup(' '),219,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),2 dup(' '),177,' ',219,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),177,' ',177,' ',219,' ',177,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),'1 ','2 ','3 ','4 ','5',8 dup(' '),0deh,CR,LF,"$"
SPane_4 db ' ',0ddh,8 dup(' '),'S P E E D',8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),8 dup(' '),177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),6 dup(' '),219,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),4 dup(' '),177,' ',219,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),2 dup(' '),177,' ',177,' ',219,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),177,' ',177,' ',177,' ',219,' ',177,8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),'1 ','2 ','3 ','4 ','5',8 dup(' '),0deh,CR,LF,"$"
SPane_5 db ' ',0ddh,8 dup(' '),'S P E E D',8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),8 dup(' '),219,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),6 dup(' '),177,' ',219,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),4 dup(' '),177,' ',177,' ',219,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),2 dup(' '),177,' ',177,' ',177,' ',219,8 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),177,' ',177,' ',177,' ',177,' ',219,8 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,8 dup(' '),'1 ','2 ','3 ','4 ','5',8 dup(' '),0deh,CR,LF,"$"
;===================================Construct speed bar
SSP_1 db 219,4 dup(177),"$"
SSP_2 db 219,219,3 dup(177),"$"
SSP_3 db 3 dup(219),177,177,"$"
SSP_4 db 4 dup(219),177,"$"
SSP_5 db 5 dup(219),"$"
;===================================Construct empty area
clear db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF
db ' ',0ddh,25 dup(' '),0deh,CR,LF,"$"
;===================================Random numbers for row
XBox db 1,4,15,6,14,19,15,10,13,14,2,2,14,5,3,11,17,6,9,0,11,18,9,8,5
db 1,17,2,3,10,3,8,8,10,3,16,3,8,18,1,13,19,15,6,16,10,5,2,17,18
db 10,10,4,7,15,0,0,14,0,7,0,2,6,17,7,4,18,11,1,16,10,0,15,14,7
db 3,12,19,16,4,19,16,10,1,16,8,5,12,7,6,18,6,5,1,15,2,14,14,1,11
db 9,0,18,0,14,17,7,9,16,7,1,10,18,3,17,12,5,18,18,17,0,4,4,7,6
db 9,13,6,7,11,18,15,9,12,15,6,17,8,17,9,9,10,6,8,7,19,15,15,14,12
db 16,13,2,11,19,3,11,6,3,6,10,19,3,16,8,14,3,2,16,18,7,10,1,11,15
db 2,5,5,18,7,11,3,11,13,15,6,15,8,16,9,9,7,3,15,10,4,4,1,7,2
db 5,5,14,18,13,10,3,1,14,13,10,0,17,16,1,17,15,7,3,14,13,16,19,12,19
db 7,12,4,14,10,12,2,0,16,19,12,15,7,13,6,6,13,13,9,16,16,14,18,6,14
db 12,3,2,5,15,1,3,6,19,8,9,8,11,0,0,1,12,17,14,13,13,10,5,19,4
db 14,12,19,13,5,1,8,13,18,1,0,1,0,9,11,6,11,4,5,6,18,2,8,5,2
db 6,19,2,13,0,6,9,14,7,10,7,16,12,13,5,4,2,12,8,0,8,3,4,8,14
db 17,19,1,4,17,18,14,3,0,3,12,9,9,18,19,11,8,18,9,17,4,15,11,9,11
db 5,19,9,0,5,12,12,5,5,18,17,7,18,0,2,10,14,6,15,12,2,8,8,2,17
db 17,16,8,9,12,12,19,19,7,10,6,10,0,11,5,9,7,12,7,1,11,2,19,11,8
db 2,4,15,19,11,15,13,4,13,1,16,2,1,4,9,19,16,13,2,8,12,10,8,16,14
db 16,5,9,0,19,15,3,4,8,2,4,0,9,2,17,10,4,3,11,3,18,17,4,11,15
db 8,5,11,16,13,9,1,12,13,7,17,17,0,16,14,19,18,18,13,13,17,6,12,19,11
db 14,0,11,4,4,12,17,7,4,6,3,15,5,15,10,3,17,16,18,1,10,1,5,13,1
;====================================Random numbers for column
YBox db 23,9,11,17,17,17,9,14,6,0,0,9,19,8,22,24,24,2,10,24,6,18,4,10,21
db 4,7,19,12,19,13,4,1,4,15,18,7,0,1,24,5,13,1,8,11,10,17,2,1,7
db 21,9,18,18,10,23,10,1,2,7,8,3,13,20,5,7,6,20,22,12,17,1,15,7,22
db 8,16,7,0,16,1,19,18,17,10,23,22,2,12,14,2,12,20,0,12,11,18,22,6,19
db 5,12,15,15,3,4,3,16,20,20,3,23,23,18,16,14,2,5,11,6,3,24,19,23,0
db 14,16,7,17,3,9,2,23,15,19,15,3,20,21,15,8,20,3,6,15,9,13,0,20,21
db 17,15,24,21,10,4,23,19,20,16,7,11,0,7,17,4,23,20,22,4,16,0,13,1,4
db 1,14,4,17,24,9,5,14,13,23,9,7,9,6,6,7,2,21,21,3,12,5,20,19,4
db 18,23,10,22,3,11,3,11,15,22,6,11,14,16,14,12,24,8,1,16,14,23,21,4,2
db 11,9,14,9,8,10,14,13,5,0,1,20,14,21,10,20,10,7,2,2,24,2,12,22,11
db 20,9,6,5,3,19,10,5,12,16,3,18,17,9,5,21,7,9,8,12,19,5,12,16,11
db 13,11,22,9,19,10,7,8,19,18,0,1,6,22,7,4,13,13,15,21,16,12,22,13,22
db 23,15,13,18,22,6,18,5,9,2,1,8,0,2,6,21,21,12,24,16,12,14,0,15,14
db 0,18,2,4,8,13,21,24,7,19,22,20,12,10,24,18,14,20,17,18,17,22,12,1,15
db 11,5,13,14,0,5,24,10,24,14,19,4,24,4,16,13,23,24,8,8,8,2,3,5,13
db 23,4,11,24,18,17,19,20,10,1,11,24,17,4,7,11,0,23,13,8,10,17,23,0,13
db 15,20,16,4,16,18,4,1,0,7,21,18,9,2,0,3,15,17,23,8,3,12,19,14,12
db 9,9,9,18,6,6,6,10,21,10,3,19,19,7,11,16,22,17,8,2,3,2,23,5,14
db 5,16,11,13,20,21,16,6,24,6,10,17,20,1,24,14,8,21,23,11,22,1,19,8,22
db 6,21,2,15,8,13,15,21,6,18,11,17,3,5,22,16,5,3,0,12,15,15,1,1,5
;===================================Variables
SXBox db 500 dup('0')
SYBox db 500 dup('0')
row db ?
col db ?
rowxy db ?
colxy db ?
X db ? ;Random point
Y db ?
SX db 21 ;Snake point
SY db 1
Alt_X equ 2dh
Esc equ 1bh
Up equ 48h
Left equ 4bh
Right equ 4dh
Down equ 50h
UMotion db 0
LMotion db 0
RMotion db 1
DMotion db 0
choose db 3
length dw 5 ;Snake length in begin
threshold dw 0
prnPoint dw ?
delPoint dw ?
scoreMS db 5 dup(' '),'$'
printSQR db 219,'$' ;Print top of snake
clearSQR db ' $' ;Clear end of snake
printTRI db ' ',16,'$' ;Triangle
clearTRI db ' $'
current db 0 ;Current time
last db -1 ;Last time
temp db 0
iteration dw ?
failed db 0
score dw 0
speed db 3
datsg ends
;===================================Code Segment
codsg segment 'code'
main proc far
assume ss:stksg, ds:datsg, cs:codsg
mov ax,datsg
mov ds,ax
call Graphic
call init
call Choice
call Random
mov al,X
mov row,al
mov ah,Y
mov col,ah
call gotoXY
mov dl,2
mov ah,02h
int 21h
MAINLOOP:
call Delay
call Draw
call check
cmp failed,1
jne Continue
Wait:
mov ah,11h
int 16h
je Wait
mov ah,10h
int 16h
cmp ah,Alt_X ;Press Alt+X
je HelpExit
cmp al,Esc ;Press Esc Key
jne Wait
call init
call Choice
call Random
mov al,X
mov row,al
mov ah,Y
mov col,ah
call gotoXY
mov dl,2
mov ah,02h
int 21h
jmp MAINLOOP
Continue:
mov ah,11h
int 16h
je MAINLOOP
mov ah,10h
int 16h
cmp ah,Alt_X ;Press Alt+X
jne CASE_1
HelpExit:
jmp EXIT
HelpMain:
jmp MAINLOOP
CASE_1:
cmp al,Esc ;Press Esc Key
jne CASE_2
call init
call Choice
jmp MAINLOOP
CASE_2:
cmp ah,Up ;Press Up Arrow
jne CASE_3
cmp DMotion,1
je MAINLOOP
mov choose,1
call arrow
jmp MAINLOOP
CASE_3:
cmp ah,Left ;Press Left Arrow
jne CASE_4
cmp RMotion,1
je HelpMain
mov choose,2
call arrow
jmp MAINLOOP
CASE_4:
cmp ah,Right ;Press Right Arrow
jne CASE_5
cmp LMotion,1
je HelpMain
mov choose,3
call arrow
jmp HelpMain
CASE_5:
cmp ah,Down ;Press Down Arrow
jne HelpMain
cmp UMotion,1
je HelpMain
mov choose,4
call arrow
jmp HelpMain
EXIT:
mov ah,00h
mov al,03h
int 10h
mov ax,4c00h
int 21h
main endp
;===================================Graphic routine [01]
Graphic proc near
mov ah,00h ;Set VGA graphic mode
mov al,0dh ;320x200
int 10h ;Call interrupt service
mov ah,0bh ;Request color palette
mov bh,00h ;Background
mov bl,01h ;Black
int 10h ;Call interrupt service
ret
Graphic endp
;===================================Cursor Move routine [02]
gotoXY proc near
push ax
push bx
push dx
mov ah,02h ;Request set cursor
mov bh,0 ;Page number = 0
mov dh,row ;Row
mov dl,col ;Column
int 10h ;Call interrupt service
pop dx
pop bx
pop ax
ret
gotoXY endp
;===================================Initialization routine [03]
init proc near
push dx
push cx
push ax
mov SX,21
mov SY,1
mov UMotion,0
mov LMotion,0
mov RMotion,1
mov DMotion,0
mov length,5
mov threshold,0
mov prnPoint,0
mov delPoint,0
mov score,0
mov failed,0
mov row,9
mov col,0
call gotoXY
lea dx,pane1_1
mov ah,09h
int 21h
inc row
call gotoXY
lea dx,pane1_2
mov ah,09h
int 21h
mov row,23
call gotoXY
lea dx,pane1_3
mov ah,09h
int 21h
mov row,2
call gotoXY
lea dx,pane2_1
mov ah,09h
int 21h
inc row
mov cx,20
L_03_01:
call gotoXY
lea dx,pane2_2
mov ah,09h
int 21h
inc row
loop L_03_01
call gotoXY
lea dx,pane2_3
mov ah,09h
int 21h
pop ax
pop cx
pop dx
ret
init endp
;===================================Delay routine [04]
Delay proc near
push cx
cmp speed,1
jne L_04_01
mov iteration,70
jmp L_04_05
L_04_01:
cmp speed,2
jne L_04_02
mov iteration,55
jmp L_04_05
L_04_02:
cmp speed,3
jne L_04_03
mov iteration,40
jmp L_04_05
L_04_03:
cmp speed,4
jne L_04_04
mov iteration,25
jmp L_04_05
L_04_04:
mov iteration,10
mov cx,0ffffh
L_04_05:
push cx
mov cx,iteration
L_04_06:
inc temp
dec temp
loop L_04_06
pop cx
loop L_04_05
pop cx
ret
Delay endp
;===================================Random routine [05]
random proc near
push ax
push bx
push cx
mov ah,2ch ;Clock interrupte
int 21h
mov current,dl ;dl = S/100
mov al,last
cmp current,al
je L_05_01
sub ax,ax ;IF body
mov al,current
mov cl,5
div cl
mov rowxy,al ;rowxy = 0..19
sub ax,ax
mov al,current
mov cl,4
div cl
mov colxy,al ;colxy = 0..24
sub ax,ax
sub bx,bx
mov al,rowxy
mov bl,25
mul bl
sub bx,bx
mov bl,colxy
add ax,bx
mov bx,ax
sub ax,ax
mov al,XBox [bx]
mov X,al
mov rowxy,al
sub ax,ax
mov al,YBox [bx]
mov Y,al
mov colxy,al
L_05_01:
sub ax,ax ;Else body
sub bx,bx
mov al,rowxy
mov bl,25
mul bl
sub bx,bx
mov bl,colxy
add ax,bx
mov bx,ax
sub ax,ax
mov al,XBox [bx]
mov X,al
mov rowxy,al
sub ax,ax
mov al,YBox [bx]
mov Y,al
mov colxy,al
mov al,current
mov last,al
add X,3
add Y,2
pop cx
pop bx
pop ax
ret
random endp
;===================================Print Score routine [06]
printS proc near
push ax
push bx
push cx
push dx
mov ax,score
lea bx,scoreMS
mov byte ptr [bx],' '
mov byte ptr [bx+1],' '
mov byte ptr [bx+2],' '
mov byte ptr [bx+3],' '
mov byte ptr [bx+4],' '
add bx,4
mov cx,10
L_06_01:
mov dx,0
div cx
add dl,30h
mov [bx],dl
dec bx
cmp ax,0
jne L_06_01
mov ah,02h
mov bh,0
mov dh,12
mov dl,33
int 10h
lea dx,scoreMS
mov ah,09h
int 21h
pop dx
pop cx
pop bx
pop ax
ret
printS endp
;===================================Choice routine [07]
Choice proc near
push ax
push bx
push cx
push dx
cmp speed,1
jne L_07_01
lea dx,SPane_1
lea bx,SSP_1
jmp L_07_05
L_07_01:
cmp speed,2
jne L_07_02
lea dx,SPane_2
lea bx,SSP_2
jmp L_07_05
L_07_02:
cmp speed,3
jne L_07_03
lea dx,SPane_3
lea bx,SSP_3
jmp L_07_05
L_07_03:
cmp speed,4
jne L_07_04
lea dx,SPane_4
lea bx,SSP_4
jmp L_07_05
L_07_04:
lea dx,SPane_5
lea bx,SSP_5
L_07_05:
mov row,9
call gotoXY
mov ah,09h
int 21h
mov dx,bx
mov row,21
mov col,33
call gotoXY
mov ah,09h
int 21h
L_07_06:
mov ah,11h ;Readkey interrupte
int 16h
je L_07_06
mov ah,10h
int 16h
cmp al,Esc ;Press Esc
jne L_07_07
jmp L_07_12
L_07_07:
cmp ah,78h ;Press Alt+1
jne L_07_08
mov speed,1
lea dx,SSP_1
jmp L_07_12
L_07_08:
cmp ah,79h ;Press Alt+2
jne L_07_09
mov speed,2
lea dx,SSP_2
jmp L_07_12
L_07_09:
cmp ah,7ah ;Press Alt+3
jne L_07_10
mov speed,3
lea dx,SSP_3
jmp L_07_12
L_07_10:
cmp ah,7bh ;Press Alt+4
jne L_07_11
mov speed,4
lea dx,SSP_4
jmp L_07_12
L_07_11:
cmp ah,7ch ;Press Alt+5
jne L_07_06
mov speed,5
lea dx,SSP_5
L_07_12:
mov row,21
mov col,33
call gotoXY
mov ah,09h
int 21h
mov row,9
mov col,0
call gotoXY
lea dx,clear
mov ah,09h
int 21h
L_07_13:
mov row,21
mov col,3
call gotoXY
lea dx,printTRI
mov ah,09h
int 21h
mov iteration,250
mov cx,0ffffh
L_07_14:
push cx
mov cx,iteration
L_07_15:
inc temp
dec temp
loop L_07_15
pop cx
loop L_07_14
mov row,21
mov col,3
call gotoXY
lea dx,clearTRI
mov ah,09h
int 21h
mov iteration,100
mov cx,0ffffh
L_07_16:
push cx
mov cx,iteration
L_07_17:
inc temp
dec temp
loop L_07_17
pop cx
loop L_07_16
mov ah,11h
int 16h
je L_07_13
pop dx
pop cx
pop bx
pop ax
ret
Choice endp
;===================================Arrow routine [08]
arrow proc near
cmp choose,1
jne L_08_01
mov UMotion,1
mov LMotion,0
mov RMotion,0
mov DMotion,0
jmp L_08_04
L_08_01:
cmp choose,2
jne L_08_02
mov UMotion,0
mov LMotion,1
mov RMotion,0
mov DMotion,0
jmp L_08_04
L_08_02:
cmp choose,3
jne L_08_03
mov UMotion,0
mov LMotion,0
mov RMotion,1
mov DMotion,0
jmp L_08_04
L_08_03:
mov UMotion,0
mov LMotion,0
mov RMotion,0
mov DMotion,1
L_08_04:
ret
arrow endp
;===================================Draw routine [09]
Draw proc near
push ax
push bx
sub bx,bx
cmp UMotion,1
jne L_09_01
dec SX
jmp L_09_04
L_09_01:
cmp LMotion,1
jne L_09_02
dec SY
jmp L_09_04
L_09_02:
cmp RMotion,1
jne L_09_03
inc SY
jmp L_09_04
L_09_03:
cmp DMotion,1
jne L_09_04
inc SX
L_09_04:
mov al,SX
mov row,al
mov ah,SY
mov col,ah
call gotoXY
lea dx,printSQR
mov ah,09h
int 21h
mov bx,prnPoint ;Failed Check
cmp bx,length
jb L_09_07
sub bx,length
mov cx,length
L_09_05:
mov al,byte ptr SXBox [bx]
cmp al,SX
jne L_09_06
mov al,byte ptr SYBox [bx]
cmp al,SY
jne L_09_06
mov failed,1
call Beep
jmp L_09_07
L_09_06:
inc bx
loop L_09_05 ;Failed Check
L_09_07:
mov bx,prnPoint ;Store SX in SXBox
mov al,SX
mov SXBox [bx],al
mov ah,SY ;Store SY in SYBox
mov SYBox [bx],ah
inc prnPoint
cmp prnPoint,500
jne L_09_08
mov prnPoint,0
L_09_08:
mov ax,length ;Clear Check
cmp ax,threshold
je L_09_09
inc threshold
jmp L_09_11
L_09_09:
mov bx,prnPoint
sub bx,length
dec bx
cmp bx,0
jge L_09_10
add bx,500
L_09_10:
mov al,byte ptr SXBox [bx]
mov row,al
mov ah,byte ptr SYBox [bx]
mov col,ah
call gotoXY
lea dx,clearSQR
mov ah,09h
int 21h
L_09_11:
call printS
mov al,X ;Print Small Face
mov row,al
mov ah,Y
mov col,ah
call gotoXY
mov dl,2
mov ah,02h
int 21h
pop bx
pop ax
ret
Draw endp
;===================================Check routine [10]
Check proc near
cmp SY,2
jb L_10_01
cmp SY,26
ja L_10_01
cmp SX,3
jb L_10_01
cmp SX,22
ja L_10_01
jmp L_10_02
L_10_01:
mov failed,1
call Beep
L_10_02:
mov al,SX
cmp al,X
jne L_10_06
mov al,SY
cmp al,Y
jne L_10_06
add score,10
call Beep
inc length
mov al,X
mov row,al
mov ah,Y
mov col,ah
call gotoXY
mov dl,219
mov ah,02h
int 21h
L_10_03:
call Random ;Small Face Check
mov bx,prnPoint
cmp bx,length
jb L_10_06
sub bx,length
mov cx,length
L_10_04:
mov al,byte ptr SXBox [bx]
cmp al,X
jne L_10_05
mov al,byte ptr SYBox [bx]
cmp al,Y
jne L_10_05
jmp L_10_03
L_10_05:
inc bx
loop L_10_04
mov al,X
mov row,al
mov ah,Y
mov col,ah
call gotoXY
mov dl,2 ;Print Small Face
mov ah,02h
int 21h
L_10_06:
ret
Check endp
;===================================Beep routine [11]
Beep proc near
push ax
push cx
mov al,0b6h
out 43h,al
mov ax,1000
out 42h,al
mov al,ah
out 42h,al
in al,61h
mov ah,al
or al,03
out 61h,al
mov cx,0ffffh
L_11_01:
push cx
mov cx,70
L_11_02:
inc temp
dec temp
loop L_11_02
pop cx
loop L_11_01
mov al,ah
out 61h,al
pop cx
pop ax
ret
Beep endp
codsg ends
end main
;===================================End of program, have a fun!
با سلام و خسته نباشید.تدریس خصوصی و انجام پروژه پذیرفته میشود.
تشکر خوب بود .به ما هم سر بزنید