📄 adasdasda.asm
字号:
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
show_letter macro op4 ;字符个数显示宏定义
mov ax,op4
aam
or ah,30h
or al,30h
mov dh,al
mov dl,ah
mov ah,02h
int 21h
mov dl,dh
mov ah,02h
int 21h
endm
delay macro op5,op6,op7 ;时间延迟宏
mov bx,op5
op6:dec bx
op7:loop op7
jne op6
endm
data segment
menu0 db "ESC to End$"
menu1 db "When you are playing games:$"
menu2 db "1.Press ESC to end the game$"
menu3 db "2.There are 99 letters drop from the top$"
menu4 db "3.When all letters drop the game over$"
menu5 db "Now press any other key to play games......$"
menu6 db "Game Over$"
menu7 db "1.Press ESC to end the game$"
menu8 db "2.Press any other key to return to the menu$"
loading db "Loading . . .$"
loading0 db " . $"
total_show db "Total letters : $"
lost_show db "Lost letters : $"
total_letter dw ?
lost_letter dw ?
num_div db 26
num_mul db 7
character db 0
line db ?
data ends
stack segment para stack
dw 80h dup(0)
stack ends
code segment
assume ds:data,cs:code,ss:stack
start:
mov ax,data
mov ds,ax
mov ah,00h
mov al,02h
int 10h
mov total_letter,0
mov lost_letter,0
menu 03d,33d,menu0 ;菜单信息的宏展开
menu 06d,22d,menu1
menu 8d,22d,menu2
menu 10d,22d,menu3
menu 12d,22d,menu4
menu 15d,22d,menu5
mov ah,07h
int 21h
cmp al,1bh
je to_exit
jne load_game
to_exit:jmp exit
load_game: ;loading延迟
mov ah,00h
mov al,02h
int 10h
menu 12d,28d,loading
delay 0fffh,a0,b1
menu 12d,41d,loading0
delay 0effh,a2,b2
menu 12d,43,loading0
delay 0dffh,a3,b3
menu 12d,45d,loading0
delay 0cffh,a4,b4
begin:
mov ah,00h
mov al,02h
int 10h
stochastic_variable:
menu 0d,30d,total_show ;显示下落的字符总数
show_letter total_letter
menu 0d,60d,lost_show ;显示未被击中的字符个数
show_letter lost_letter
mov ah,2ch ;产生随机下落的字符
int 21h
mov al,dh
mul num_mul
mov ah,0
div num_div
add ah,61h
mov character,ah
mov line,1 ;开始下落行数的初始化
auto_over: ;自动结束游戏
cmp total_letter,99d
je game_over
inc total_letter
show_character:
mov ah,02h
mov dh,line
int 10h
mov ah,09h ;显示字符
mov al,character
mov cx,1
mov ah,0ah
int 10h
delay 03ffh,a5,b5
character_disappear: ;使字符消失
mov al,' '
mov cx,1
mov ah,0ah
int 10h
to_judge:
push dx ;保护dh值
mov dl,0ffh
mov ah,06h
int 21h
cmp al,1bh
je exit
cmp al,character ;判断是否击中下落字符
je stochastic_variable0
pop dx
inc line
cmp line,24 ;判断下落行数并中转
je to_stochastic_variable
jne show_character
stochastic_variable0:jmp stochastic_variable
to_stochastic_variable:
inc lost_letter
jmp stochastic_variable
game_over: ;游戏结束
menu 06d,32d,menu6
menu 10d,22d,menu7
menu 12d,22d,menu8
mov ah,07h
int 21h
cmp al,1bh
je exit
jmp start
exit: ;退出游戏
mov ah,4ch
int 21h
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -