主题:经典的打字游戏,功能较为强大,有动画等完美功能!(2)
此为程序下半部分:
dazi: PUSH CX ;利用时间计数器产生随机数
PUSH DX
PUSH AX
MOV AH,0
INT 1AH
MOV AX,DX
AND AH,3
MOV DL,75
DIV DL
MOV BL,AH ;随机数在BL中
INC COUNT4
POP AX
POP DX
POP CX
YIDONG: MOV AH,0FH ;使字符移动,掉落
INT 10H
MOV DH,10 ;清除Continue or Retry?(C/R)字符
MOV DL,25
MOV AH,02H
INT 10H
MOV AL,0
MOV CX,27
MOV AH,10
INT 10H
MOV AH,0FH
INT 10H
MOV DH,02H ;置掉落字符的光标位置
MOV DL,BL
ADD BL,30H ;要显示的字符的ASC码
REPT1: MOV AH,02H
INT 10H
MOV CX,1
MOV AL,BL ;输出显示字符
MOV AH,10
INT 10H
CALL DELAY ;调用延时子程序
SUB AL,AL ;清除原图形
MOV AH,10
INT 10H
PUSH DX
MOV DL,0FFH ;不等待用户输入,否则输出
MOV AH,06H
INT 21H
POP DX
INC DH
CMP AL,BL ;输入与输出相同,则为打中
JE jizhong2
CMP AL,1BH ;若输入为ESC,则退出
JE QUIT
CMP AL,20H ;若输入为SPACE,则暂停
JE PAUSE
PAUSE1: CMP DH,24 ;若没有输入且没有掉到最后一行,则继续下落
JNE REPT1
JMP BUZHONG ;无输入且掉到最后一行,则为不中
OVER3: JMP OVER2
START1: JMP START2
JILU: PUSH DX ;输出纪录且结束
MOV DH,10
MOV DL,20
MOV AH,02H
INT 10H
POP DX
MOV DX,OFFSET RECORD1
MOV AH,09H
INT 21H
CALL DELAY1
JMP OVER4
YIDONG1:JMP YIDONG
OVER4: JMP OVER2
JIZHONG2:JMP JIZHONG1
PAUSE2: PUSH DX ;清除PAUSE字符
MOV DH,11
MOV DL,37
MOV AH,02H
INT 10H
MOV AL,0
MOV CX,6
MOV AH,10
INT 10H
POP DX
JMP PAUSE1
PAUSE: MOV DH,11 ;输出暂停
MOV DL,37
MOV AH,02H
INT 10H
MOV DX,OFFSET DA11
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,20H ;若再次输入SPACE,则继续游戏,否则继续暂停
JE PAUSE2
JMP PAUSE
OVER2: JMP OVER
YIDONG2:JMP YIDONG1
QUIT: MOV DH,10 ;输出退出
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA5
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,59H ;若输入Y则退出
JE OVER
CMP AL,4EH ;若输入N则判断是否继续
JE PANDUAN
JMP QUIT
START3: JMP START1
JIZHONG1:JMP JIZHONG
PANDUAN:MOV AH,0FH ;首先清除原字符
INT 10H
MOV DH,10
MOV DL,25
MOV AH,02H
INT 10H
MOV AL,0
MOV CX,27
MOV AH,10
INT 10H
MOV DH,10
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA6
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,'R' ;若输入R则重新开始
JE START3
CMP AL,'C' ;若输入C则继续刚才的游戏
JE YIDONG2
JMP PANDUAN
OVER: MOV AL,2 ;结束游戏并输出你的分数值
MOV AH,0
INT 10H
MOV DH,10
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA10
MOV AH,09H
INT 21H
MOV DH,10
MOV DL,44
MOV AH,02H
INT 10H
MOV AX,SCORE1 ;输出分数值
MOV BL,10
DIV BL
MOV CH,BYTE PTR SCORE1
OR AH,30H
OR AL,30H
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
CALL DELAY1
MOV AH,15
INT 10H
MOV AL,2 ;输出正确率
MOV AH,0
INT 10H
MOV DH,10
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA16
MOV AH,09H
INT 21H
MOV AL,CH
MOV BL,100
MUL BL
MOV BL,COUNT4
DIV BL ;余数在AH中,商在AL中
MOV SI,OFFSET COUNT5
MOV CX,0
LL: PUSH CX
MOV AH,0
MOV CL,10
DIV CL
XCHG AH,AL
ADD AL,30H
MOV [SI],AL
INC SI
POP CX
INC CX
MOV AL,AH
CMP AH,0
JNZ LL
DEC2: DEC SI
MOV AL,[SI]
MOV DL,AL
MOV AH,2
INT 21H
LOOP DEC2
MOV DL,25H
MOV AH,02H
INT 21H
CALL DELAY1
MOV AH,15
INT 10H
MOV AL,2
MOV AH,0
INT 10H
MOV DH,10
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA4 ;输出GAME OVER,然后结束
MOV AH,09H
INT 21H
CALL DELAY1
OVER1: MOV AH,4CH
INT 21H
JIZHONG:INC SCORE1
JMP FENSHU
BUZHONG:INC COUNT2
DEC COUNT1
JMP SHENGMING
DELAY PROC ;字符掉落速度的延时子程序
PUSH CX
PUSH DX
MOV DX,01111h
DL500: MOV CX,BP
DL10MS: LOOP DL10MS
DEC DX
JNZ DL500
POP DX
POP CX
RET
DELAY ENDP
DELAY1 PROC ;第二个延时子程序
PUSH CX
PUSH DX
MOV DX,08888h
DL400: MOV CX,0FFFFH
DL20MS: LOOP DL20MS
DEC DX
JNZ DL400
POP DX
POP CX
RET
DELAY1 ENDP
DELAY2 PROC ;第三个延时子程序
PUSH CX
PUSH DX
MOV DX,06666h
DL300: MOV CX,0AAAAH
DL30MS: LOOP DL30MS
DEC DX
JNZ DL300
POP DX
POP CX
RET
DELAY2 ENDP
CODE ENDS
END START
dazi: PUSH CX ;利用时间计数器产生随机数
PUSH DX
PUSH AX
MOV AH,0
INT 1AH
MOV AX,DX
AND AH,3
MOV DL,75
DIV DL
MOV BL,AH ;随机数在BL中
INC COUNT4
POP AX
POP DX
POP CX
YIDONG: MOV AH,0FH ;使字符移动,掉落
INT 10H
MOV DH,10 ;清除Continue or Retry?(C/R)字符
MOV DL,25
MOV AH,02H
INT 10H
MOV AL,0
MOV CX,27
MOV AH,10
INT 10H
MOV AH,0FH
INT 10H
MOV DH,02H ;置掉落字符的光标位置
MOV DL,BL
ADD BL,30H ;要显示的字符的ASC码
REPT1: MOV AH,02H
INT 10H
MOV CX,1
MOV AL,BL ;输出显示字符
MOV AH,10
INT 10H
CALL DELAY ;调用延时子程序
SUB AL,AL ;清除原图形
MOV AH,10
INT 10H
PUSH DX
MOV DL,0FFH ;不等待用户输入,否则输出
MOV AH,06H
INT 21H
POP DX
INC DH
CMP AL,BL ;输入与输出相同,则为打中
JE jizhong2
CMP AL,1BH ;若输入为ESC,则退出
JE QUIT
CMP AL,20H ;若输入为SPACE,则暂停
JE PAUSE
PAUSE1: CMP DH,24 ;若没有输入且没有掉到最后一行,则继续下落
JNE REPT1
JMP BUZHONG ;无输入且掉到最后一行,则为不中
OVER3: JMP OVER2
START1: JMP START2
JILU: PUSH DX ;输出纪录且结束
MOV DH,10
MOV DL,20
MOV AH,02H
INT 10H
POP DX
MOV DX,OFFSET RECORD1
MOV AH,09H
INT 21H
CALL DELAY1
JMP OVER4
YIDONG1:JMP YIDONG
OVER4: JMP OVER2
JIZHONG2:JMP JIZHONG1
PAUSE2: PUSH DX ;清除PAUSE字符
MOV DH,11
MOV DL,37
MOV AH,02H
INT 10H
MOV AL,0
MOV CX,6
MOV AH,10
INT 10H
POP DX
JMP PAUSE1
PAUSE: MOV DH,11 ;输出暂停
MOV DL,37
MOV AH,02H
INT 10H
MOV DX,OFFSET DA11
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,20H ;若再次输入SPACE,则继续游戏,否则继续暂停
JE PAUSE2
JMP PAUSE
OVER2: JMP OVER
YIDONG2:JMP YIDONG1
QUIT: MOV DH,10 ;输出退出
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA5
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,59H ;若输入Y则退出
JE OVER
CMP AL,4EH ;若输入N则判断是否继续
JE PANDUAN
JMP QUIT
START3: JMP START1
JIZHONG1:JMP JIZHONG
PANDUAN:MOV AH,0FH ;首先清除原字符
INT 10H
MOV DH,10
MOV DL,25
MOV AH,02H
INT 10H
MOV AL,0
MOV CX,27
MOV AH,10
INT 10H
MOV DH,10
MOV DL,25
MOV AH,02H
INT 10H
MOV DX,OFFSET DA6
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
CMP AL,'R' ;若输入R则重新开始
JE START3
CMP AL,'C' ;若输入C则继续刚才的游戏
JE YIDONG2
JMP PANDUAN
OVER: MOV AL,2 ;结束游戏并输出你的分数值
MOV AH,0
INT 10H
MOV DH,10
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA10
MOV AH,09H
INT 21H
MOV DH,10
MOV DL,44
MOV AH,02H
INT 10H
MOV AX,SCORE1 ;输出分数值
MOV BL,10
DIV BL
MOV CH,BYTE PTR SCORE1
OR AH,30H
OR AL,30H
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
CALL DELAY1
MOV AH,15
INT 10H
MOV AL,2 ;输出正确率
MOV AH,0
INT 10H
MOV DH,10
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA16
MOV AH,09H
INT 21H
MOV AL,CH
MOV BL,100
MUL BL
MOV BL,COUNT4
DIV BL ;余数在AH中,商在AL中
MOV SI,OFFSET COUNT5
MOV CX,0
LL: PUSH CX
MOV AH,0
MOV CL,10
DIV CL
XCHG AH,AL
ADD AL,30H
MOV [SI],AL
INC SI
POP CX
INC CX
MOV AL,AH
CMP AH,0
JNZ LL
DEC2: DEC SI
MOV AL,[SI]
MOV DL,AL
MOV AH,2
INT 21H
LOOP DEC2
MOV DL,25H
MOV AH,02H
INT 21H
CALL DELAY1
MOV AH,15
INT 10H
MOV AL,2
MOV AH,0
INT 10H
MOV DH,10
MOV DL,33
MOV AH,02H
INT 10H
MOV DX,OFFSET DA4 ;输出GAME OVER,然后结束
MOV AH,09H
INT 21H
CALL DELAY1
OVER1: MOV AH,4CH
INT 21H
JIZHONG:INC SCORE1
JMP FENSHU
BUZHONG:INC COUNT2
DEC COUNT1
JMP SHENGMING
DELAY PROC ;字符掉落速度的延时子程序
PUSH CX
PUSH DX
MOV DX,01111h
DL500: MOV CX,BP
DL10MS: LOOP DL10MS
DEC DX
JNZ DL500
POP DX
POP CX
RET
DELAY ENDP
DELAY1 PROC ;第二个延时子程序
PUSH CX
PUSH DX
MOV DX,08888h
DL400: MOV CX,0FFFFH
DL20MS: LOOP DL20MS
DEC DX
JNZ DL400
POP DX
POP CX
RET
DELAY1 ENDP
DELAY2 PROC ;第三个延时子程序
PUSH CX
PUSH DX
MOV DX,06666h
DL300: MOV CX,0AAAAH
DL30MS: LOOP DL30MS
DEC DX
JNZ DL300
POP DX
POP CX
RET
DELAY2 ENDP
CODE ENDS
END START