主题:[原创]经典的打字游戏,功能较为强大,有动画等完美功能!
;打字游戏源程序
DATA SEGMENT
DA1 DB 'SCORE:','$'
DA2 DB 'LIFE:','$'
DA3 DB ' ','$' ;引号内共40个空格
DA4 DB 'GAME OVER','$'
DA5 DB 'Are you sure to quit?(Y/N)','$'
DA6 DB 'Continue or Retry?(C/R)','$'
DA7 DB 'Welcome to the word game!','$'
DA8 DB 'Maker:ZhangKuoda','$'
DA9 DB 'Class:computer 031 Number:032261','$'
DA10 DB 'YOUR SCORE:','$'
DA11 DB 'PAUSE','$'
DA12 DB 'Please choose level(1-5):','$'
DA13 DB 'WORD GAME','$'
DA14 DB 'QUIT:Esc PAUSE:Space LEVEL:','$'
DA15 DW 3
DB 01H,0,0
DB 04H,1,0
DB 13H,1,0
DA16 DB 'Right Rate:','$'
SCORE1 DW 0
SCORE2 DB '0'
RECORD1 DB 'You have make the record!Congratulation!','$'
COUNT1 DW 15
COUNT2 DW 0
COUNT3 DB 1 DUP(0)
COUNT4 DB 0
COUNT5 DB 3 DUP(0)
DATA ENDS
STACK SEGMENT PARA STACK
DW 30H DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
WELCOME:MOV AL,2 ;输出WELCOME等
MOV AH,0
INT 10H
MOV AH,15
INT 10H
MOV DI,OFFSET DA15
ADD DI,2
MOV CX,11
LOP1: PUSH CX
SUB DI,2
MOV CX,[DI]
MOV DX,0
ADD DI,2
NEXT1: ADD DH,[DI+1] ;置小人的位置
ADD DL,[DI+2]
MOV AH,2
INT 10H
MOV AL,[DI] ;显示小人图形
PUSH CX
MOV BL,00000010B
MOV CX,1
MOV AH,9
INT 10H
POP CX
ADD DI,3
LOOP NEXT1
CALL DELAY2 ;调用延时
MOV CX,3
N1: SUB DI,3 ;清除图形
MOV AH,2
INT 10H
PUSH CX
MOV AL,0
MOV CX,1
MOV AH,10
INT 10H
SUB DH,[DI+1]
SUB DL,[DI+2]
POP CX
LOOP N1
Y1: PUSH DX
MOV DH,[DI+1] ;改变光标位置,使小人移动
MOV DL,[DI+2]
INC DH
ADD DL,3
MOV [DI+1],DH
MOV [DI+2],DL
POP DX
POP CX
LOOP LOP1
MOV DH,9
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA13 ;输出WORD GAME
MOV AH,09H
INT 21H
CALL DELAY1
MOV AL,2
MOV AH,0
INT 10H
MOV DH,9 ;置光标位置
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA7
MOV AH,09H
INT 21H
CALL DELAY1 ;调用延时程序
MOV DH,10
MOV DL,29
MOV AH,02H
INT 10H
CALL DELAY1
MOV DX,OFFSET DA8
MOV AH,09H
INT 21H
CALL DELAY1
MOV DH,11
MOV DL,21
MOV AH,02H
INT 10H
MOV DX,OFFSET DA9
MOV AH,09H
INT 21H
CALL DELAY1
LEVEL: MOV AL,2 ;输出选择速度
MOV AH,0
INT 10H
MOV DH,10
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA12
MOV AH,09H
INT 21H
MOV AH,01H ;若为1,则BP赋值0CCCCH,决定下落速度
INT 21H
MOV COUNT3,AL
CMP AL,31H ;等待用户输入
JE L1
CMP AL,32H
JE L2
CMP AL,33H
JE L3
CMP AL,34H
JE L4
CMP AL,35H
JE L5
JMP LEVEL ;使得游戏开始前按任何键都不起作用
START2: mov al,2
mov ah,0
int 10h
MOV DX,0 ;输出第一行的字符
MOV AH,02H
INT 10H
MOV AL,14H
MOV CX,34
MOV BL,10010100B
MOV AH,9
INT 10H
MOV DH,0
MOV DL,35
MOV AH,02H
INT 10H
MOV DX,OFFSET DA13
MOV AH,09H
INT 21H
MOV DH,0
MOV DL,45
MOV AH,02H
INT 10H
MOV AL,14H
MOV CX,35
MOV BL,10001010B
MOV AH,9
INT 10H
MOV DH,1
MOV DL,0
MOV AH,02H
INT 10H
MOV DX,OFFSET DA1 ;输出SCORE
MOV AH,09H
INT 21H
MOV SCORE1,0
MOV COUNT1,15
MOV COUNT2,0
JMP FENSHU
L1: MOV BP,0CCCCH
JMP START2
L2: MOV BP,0AAAAH
JMP START2
L3: MOV BP,7777H
JMP START2
L4: MOV BP,5555H
JMP START2
L5: MOV BP,3333H
JMP START2
fenshu: mov dh,1
mov dl,7
mov ah,02h
int 10h
MOV AX,SCORE1 ;输出分数值
MOV BL,10 ;16进制转换成非压缩BCD码输出
DIV BL
OR AH,30H
OR AL,30H
MOV CL,AL ;CL存放商
MOV DH,AH
MOV DL,AL
MOV AH,02H
INT 21H
MOV DL,DH
MOV AH,02H
INT 21H
MOV DI,OFFSET SCORE2
MOV DL,[DI]
MOV AH,02H
INT 21H
CMP CL,33H ;大于300则成为纪录
JAE JILU1
CMP CL,30H
JA DAZI
MOV DX,OFFSET DA3 ;输出空格
MOV AH,09H
INT 21H
MOV DX,OFFSET DA2 ;输出LIFE
MOV AH,09H
INT 21H
SHENGMING:mov dh,1
mov dl,55
mov ah,02h
int 10h
MOV AH,09H ;输出生命值(红色条形)
MOV AL,20H
MOV BH,0
MOV BL,01000100B
MOV CX,COUNT1 ;红色条减少
INT 10H
MOV BH,55
MOV BL,BYTE PTR COUNT1
ADD BH,BL
MOV DH,0
MOV DL,BH
MOV AH,02H
INT 10H
MOV AH,09H
MOV AL,20H
MOV BH,0
MOV BL,00000000B ;在要消去的生命条上输出黑色
MOV CX,COUNT2
INT 10H
CMP CX,15
JE OVER5
MOV DH,24
MOV DL,40
MOV AH,02H
INT 10H
MOV DX,OFFSET DA14 ;输出提示
MOV AH,09H
INT 21H
MOV DH,24
MOV DL,75
MOV AH,02H
INT 10H
MOV BL,COUNT3
OR BL,30H
MOV AL,BL
MOV CX,1
MOV AH,10
INT 10H
JMP DAZI
OVER5: JMP OVER3
JILU1: JMP JILU
此为前半部分,后半部分请看下帖...
DATA SEGMENT
DA1 DB 'SCORE:','$'
DA2 DB 'LIFE:','$'
DA3 DB ' ','$' ;引号内共40个空格
DA4 DB 'GAME OVER','$'
DA5 DB 'Are you sure to quit?(Y/N)','$'
DA6 DB 'Continue or Retry?(C/R)','$'
DA7 DB 'Welcome to the word game!','$'
DA8 DB 'Maker:ZhangKuoda','$'
DA9 DB 'Class:computer 031 Number:032261','$'
DA10 DB 'YOUR SCORE:','$'
DA11 DB 'PAUSE','$'
DA12 DB 'Please choose level(1-5):','$'
DA13 DB 'WORD GAME','$'
DA14 DB 'QUIT:Esc PAUSE:Space LEVEL:','$'
DA15 DW 3
DB 01H,0,0
DB 04H,1,0
DB 13H,1,0
DA16 DB 'Right Rate:','$'
SCORE1 DW 0
SCORE2 DB '0'
RECORD1 DB 'You have make the record!Congratulation!','$'
COUNT1 DW 15
COUNT2 DW 0
COUNT3 DB 1 DUP(0)
COUNT4 DB 0
COUNT5 DB 3 DUP(0)
DATA ENDS
STACK SEGMENT PARA STACK
DW 30H DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
WELCOME:MOV AL,2 ;输出WELCOME等
MOV AH,0
INT 10H
MOV AH,15
INT 10H
MOV DI,OFFSET DA15
ADD DI,2
MOV CX,11
LOP1: PUSH CX
SUB DI,2
MOV CX,[DI]
MOV DX,0
ADD DI,2
NEXT1: ADD DH,[DI+1] ;置小人的位置
ADD DL,[DI+2]
MOV AH,2
INT 10H
MOV AL,[DI] ;显示小人图形
PUSH CX
MOV BL,00000010B
MOV CX,1
MOV AH,9
INT 10H
POP CX
ADD DI,3
LOOP NEXT1
CALL DELAY2 ;调用延时
MOV CX,3
N1: SUB DI,3 ;清除图形
MOV AH,2
INT 10H
PUSH CX
MOV AL,0
MOV CX,1
MOV AH,10
INT 10H
SUB DH,[DI+1]
SUB DL,[DI+2]
POP CX
LOOP N1
Y1: PUSH DX
MOV DH,[DI+1] ;改变光标位置,使小人移动
MOV DL,[DI+2]
INC DH
ADD DL,3
MOV [DI+1],DH
MOV [DI+2],DL
POP DX
POP CX
LOOP LOP1
MOV DH,9
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA13 ;输出WORD GAME
MOV AH,09H
INT 21H
CALL DELAY1
MOV AL,2
MOV AH,0
INT 10H
MOV DH,9 ;置光标位置
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA7
MOV AH,09H
INT 21H
CALL DELAY1 ;调用延时程序
MOV DH,10
MOV DL,29
MOV AH,02H
INT 10H
CALL DELAY1
MOV DX,OFFSET DA8
MOV AH,09H
INT 21H
CALL DELAY1
MOV DH,11
MOV DL,21
MOV AH,02H
INT 10H
MOV DX,OFFSET DA9
MOV AH,09H
INT 21H
CALL DELAY1
LEVEL: MOV AL,2 ;输出选择速度
MOV AH,0
INT 10H
MOV DH,10
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA12
MOV AH,09H
INT 21H
MOV AH,01H ;若为1,则BP赋值0CCCCH,决定下落速度
INT 21H
MOV COUNT3,AL
CMP AL,31H ;等待用户输入
JE L1
CMP AL,32H
JE L2
CMP AL,33H
JE L3
CMP AL,34H
JE L4
CMP AL,35H
JE L5
JMP LEVEL ;使得游戏开始前按任何键都不起作用
START2: mov al,2
mov ah,0
int 10h
MOV DX,0 ;输出第一行的字符
MOV AH,02H
INT 10H
MOV AL,14H
MOV CX,34
MOV BL,10010100B
MOV AH,9
INT 10H
MOV DH,0
MOV DL,35
MOV AH,02H
INT 10H
MOV DX,OFFSET DA13
MOV AH,09H
INT 21H
MOV DH,0
MOV DL,45
MOV AH,02H
INT 10H
MOV AL,14H
MOV CX,35
MOV BL,10001010B
MOV AH,9
INT 10H
MOV DH,1
MOV DL,0
MOV AH,02H
INT 10H
MOV DX,OFFSET DA1 ;输出SCORE
MOV AH,09H
INT 21H
MOV SCORE1,0
MOV COUNT1,15
MOV COUNT2,0
JMP FENSHU
L1: MOV BP,0CCCCH
JMP START2
L2: MOV BP,0AAAAH
JMP START2
L3: MOV BP,7777H
JMP START2
L4: MOV BP,5555H
JMP START2
L5: MOV BP,3333H
JMP START2
fenshu: mov dh,1
mov dl,7
mov ah,02h
int 10h
MOV AX,SCORE1 ;输出分数值
MOV BL,10 ;16进制转换成非压缩BCD码输出
DIV BL
OR AH,30H
OR AL,30H
MOV CL,AL ;CL存放商
MOV DH,AH
MOV DL,AL
MOV AH,02H
INT 21H
MOV DL,DH
MOV AH,02H
INT 21H
MOV DI,OFFSET SCORE2
MOV DL,[DI]
MOV AH,02H
INT 21H
CMP CL,33H ;大于300则成为纪录
JAE JILU1
CMP CL,30H
JA DAZI
MOV DX,OFFSET DA3 ;输出空格
MOV AH,09H
INT 21H
MOV DX,OFFSET DA2 ;输出LIFE
MOV AH,09H
INT 21H
SHENGMING:mov dh,1
mov dl,55
mov ah,02h
int 10h
MOV AH,09H ;输出生命值(红色条形)
MOV AL,20H
MOV BH,0
MOV BL,01000100B
MOV CX,COUNT1 ;红色条减少
INT 10H
MOV BH,55
MOV BL,BYTE PTR COUNT1
ADD BH,BL
MOV DH,0
MOV DL,BH
MOV AH,02H
INT 10H
MOV AH,09H
MOV AL,20H
MOV BH,0
MOV BL,00000000B ;在要消去的生命条上输出黑色
MOV CX,COUNT2
INT 10H
CMP CX,15
JE OVER5
MOV DH,24
MOV DL,40
MOV AH,02H
INT 10H
MOV DX,OFFSET DA14 ;输出提示
MOV AH,09H
INT 21H
MOV DH,24
MOV DL,75
MOV AH,02H
INT 10H
MOV BL,COUNT3
OR BL,30H
MOV AL,BL
MOV CX,1
MOV AH,10
INT 10H
JMP DAZI
OVER5: JMP OVER3
JILU1: JMP JILU
此为前半部分,后半部分请看下帖...