;;;;任意掉落字符,按空格和ESC暂停并再ESC结束,空格继续;;
.model small
clear_screen macro op1,op2,op3,op4 ;清屏宏定义
push ax
push bx
push cx
push dx
mov ah,06h
mov al,00h
mov bh,06h
mov ch,op1
mov cl,op2
mov dh,op3
mov dl,op4
int
10h
mov ah,02h
mov bh,0h
mov dh,00h
mov dl,00h
int
10h
pop dx
pop cx
pop bx
pop ax
endm
set
macro p1,p2,p3 ;;;设置光标并显示p1
push cx
mov ah,02h
mov bh,0h
mov dx,p3
mov dh,p2
int
10h
mov ah,0ah
mov al,p1
mov cx,
1
mov bl,
12
int
10h
pop cx
endm
delay macro;;;拖延时间
local sg1,sg2,nextdelay,nextdelay1
push cx
push dx
push ax
mov dx,speed
mov cx,
1000
sg1 :
sg2 :
loop sg2
dec dx
jnz sg2
mov ah,0bh
int
21h
cmp al,0h;;无字符可以读取
je nextdelay
mov ah,
7
int
21h
cmp al,
'
'
je calll
cmp al,1bh
jne nextdelay1
calll :
call justment
jmp nextdelay
nextdelay1:
cmp al,letters[si]
jne nextdelay
call disp
nextdelay:
pop ax
pop dx
pop cx
endm
menu macro op1,op2,op3 ;菜单显示宏定义
mov ah,02h
mov bh,00h
mov dh,op1
mov dl,op2
int
10h
mov ah,09h
lea dx,op3
int
21h
endm
.model
.stack
256
.data
letters db
"
jwmilzoeucgpravskntxhdyqfb
"
db
'
iytpkwnxlsvxrmofzhgaebudjq
'
db
'
nwimzoexrphysfqtvdcgljukdas
'
count equ $
-
letters ;;
79
menu0 db
"
Welcome to play !$
"
menu1 db
'
input enter to game!
'
,0dh,0ah,
'
$
'
menu2 db
'
input space to halt!
'
,0dh,0ah,
'
$
'
menu3 db
'
input esc to exit!
'
,0dh,0ah,
'
$
'
menu40 db
'
this is agame which pritise keyin,
'
,0dh,0ah,
'
$
'
menu41 db
'
when you are exit from the
'
db
'
game ,you will
'
,0dh,0ah,
'
$
'
menu42 db
'
kown how much you can hit
'
,0dh,0ah,
'
$
'
msg db
'
choise speed:f--fast;s--slow;other character--orditional !
'
msg0 db
'
you hit:$
'
msg1 db
'
Help : space--- halt Esc---home$
'
speed dw
800
h dw
?
l db
?
gs db
0
.code
mov ax,@data
mov ds,ax
menulist :
clear_screen 0d,00d,25d,79d ;;
24
*
80
(0开始)
menu
07
,
20
,menu0 ;菜单信息的宏调用
menu
09
,
20
,menu1
menu
11
,
20
,menu2
menu
13
,
20
,menu3
menu
15
,
20
,menu40
menu
17
,
22
,menu41
menu
19
,
22
,menu42
again:
mov ah,
0
int
16h
cmp al,1bh
jne nextmain1
jmp overmain
nextmain1 :
cmp al,0dh
jne again
clear_screen 0d,00d,25d,79d ;;
24
*
80
(0开始)
call setspeed
clear_screen 0d,00d,25d,79d ;;
24
*
80
(0开始)
menu
0
,
5
,msg1;;help menu
mov dx,
0
ag0:
call outdb
call rand
mov di,si
call rand
add di,si
shr di,
1
;;;列坐标
mov cx,
1
call rand
push ax
mov ax,si
call rand
add si,ax
shr si,
1
;;;产生字符去两次的平均值
pop ax
ag :
mov h,di
mov l,cl
mov al,letters[si]
set
al,cl,di
delay
dispag :
set
'
'
,cl,di
inc cx
cmp cx,
23
je next
jmp ag
next :
inc dx
cmp dx,
5
je overmain
jmp ag0
overmain:
call outdb
mov ah,4ch
int
21h
;;;;;;
rand proc
push ax
push bx
push cx
push dx
sti;允许中断1ah:
0
mov ah,
0
int
1ah
mov ax,dx
and ah,
0
;;清除高6位
mov bl,count
div bl
mov al,ah
mov ah,
0
mov si,ax
pop dx
pop cx
pop bx
pop ax
ret
rand endp
;;;;;;;;
justment proc
cmp al,
'
'
call stop;;暂停
ret
justment endp
;;;;;;;;;;;;;;;
stop proc
;;;;;;;;;;;;;;local agstop
agstop :
mov ah,0bh
int
21h
cmp al,
0
je agstop
mov ah,
7
int
21h
cmp al,
'
'
je overstop
cmp al,1bh
jne nextagstop1
jmp menulist
nextagstop1:
jmp agstop
overstop:
ret
stop endp
;;;;
disp proc
set
'
'
,l,h
inc gs
call ring
call outdb
jmp ag0
ret
disp endp
;;;;;;;;;;
outdb proc
push ax
push bx
push cx
push dx
mov ah,02h
mov bh,0h
mov dh,
0
mov dl,
60
int
10h
mov ah,
9
mov dx,offset msg0
int
21h
mov al,gs
mov ch,
10
mov cl,
0
;记数
mov bh,
0
;;bh
=
0
agodb :
mov ah,
0
div ch
mov bl,ah;;存余数入栈
add bl,
'
0
'
push bx
inc cl
cmp al,
0
jg agodb
mov ch,
0
agodb1 :
pop bx
mov dx,bx
mov ah,
2
int
21h
loop agodb1
;;mov dl,0dh
;; mov ah,
2
;;
int
21h
;; mov dl,0ah
;; mov ah,
2
;;
int
21h
pop dx
pop cx
pop bx
pop ax
ret
outdb endp
;;;;;;;;;;;;;;
setspeed proc
push ax
menu
15
,
5
,msg
mov ah,1h
int
21h
cmp al,
'
f
'
je nextspeed1
cmp al,
'
s
'
jne nextspeed2
mov speed,
1000
jmp nextspeed2
nextspeed1 :
mov speed,
500
nextspeed2:
pop ax
ret
setspeed endp
;;;;;;;;;;;;;
ring proc
push ax
push cx
push dx
mov cx,
3
ringed :
mov ah,02h
mov dl,07h
int
21h
clear_screen 1d,00d,25d,79d ;;
24
*
80
(0开始)
loop ringed
pop dx
pop cx
pop ax
ret
ring endp
end