?? game.txt
字號:
mov dh,01h
mov dl,01h
int 10h
;初始化屏幕上方的字母
mov cx,00h
lea si,letters
nextletter:
mov ah,02h
mov dl,[si]
int 21h
inc si
inc cx
cmp cx,78d
je nextcycle
jmp nextletter
;相關循環的算法
from_front:
sub present_position,78d
jmp gobackto_si
find_zero:cmp letter_counter,78d
je recycle
cmp present_position,78d
je from_one
mov ah,00h
nextsi: add present_position,01h
inc si
cmp [si],ah
je gobackto_di
cmp present_position,78d
je from_one
jmp nextsi
from_one:
mov present_position,01h
jmp gobackto_si
recycle:
mov letter_counter,00h
mov present_position,01d
lea si,position_flag
mov cx,00h
mov ah,00h
clearsi:
mov [si],ah
inc cx
cmp cx,78d
je nextcycle
inc si
jmp clearsi
;主循環部分
nextcycle:
lea di,letters
lea si,position_flag
add present_position,31d
cmp present_position,78
ja from_front
gobackto_si:
add si,word ptr present_position
dec si
mov ah,[si]
cmp ah,01h
je find_zero
gobackto_di:
mov ah,01h
mov [si],ah
add di,word ptr present_position
dec di
mov dl,present_position
;字母下落的代碼段部分
mov ah,02h
mov bh,00h
mov dh,01h
int 10h
mov cx,00h
nextrow:push cx
mov cx,00h
out_cycle: ;延遲
push cx
mov cx,00h
in_cycle:
add cx,01h
cmp cx,50000d
jne in_cycle
push dx
mov ah,06h
mov dl,0ffh
int 21h
pop dx
;如果鍵盤緩沖區部分為空,則跳轉
jz pass
;如果鍵入ESC,則返回主菜單
cmp al,1bh
je to_start1
;如果鍵入SPACE,則游戲暫停
cmp al," "
je pause
;輸入字母正確!跳轉!
cmp al,[di]
je disappear
pass:
pop cx
inc cx
cmp cx,speed
je print
jmp out_cycle
;暫停處理
pause: push dx
mov ah,06h
mov dl,0ffh
int 21h
pop dx
cmp al," "
jne pause
jmp pass
;返回主菜單
to_start1:
jmp start
print: ;當前行輸入空格,下移一行,打印字母
mov ah,0ah
mov al," "
mov bh,00h
mov cx,01h
int 10h
inc dh
mov ah,02h
mov bh,00h
int 10h
mov ah,0ah
mov al,[di]
mov bh,00h
mov cx,01h
int 10h
pop cx
inc cx
cmp cx,21d
je print_next_letter
jmp nextrow
;擊中字母后的相關處理
disappear:
pop cx
pop cx
mov ah,0ah
mov al," "
mov bh,00h
mov cx,01h
int 10h
jmp hit
;處理原位置的空缺
print_next_letter:
lea si,life_flag
add si,word ptr present_position
dec si
mov ah,[si]
cmp ah,1
je fail
mov ah,0ah
mov al," "
mov bh,00h
mov cx,01h
int 10h
inc dh
mov ah,02h
mov bh,00h
int 10h
mov ah,0ah
mov al," "
mov bh,00h
mov cx,01h
int 10h
mov ah,1
mov [si],ah
hit:
mov ah,02h
mov bh,00h
mov dh,01h
mov dl,present_position
int 10h
;出現下一個新字母的數法
mov al,[di]
add al,7
cmp al,7ah
ja convey_letter
mov ah,0ah
mov bh,00h
mov cx,01h
int 10h
mov [di],al
add letter_counter,01h
jmp nextcycle
convey_letter:
sub al,7ah
add al,61h
mov ah,0ah
mov bh,00h
mov cx,01h
int 10h
mov [di],al
add letter_counter,01h
jmp nextcycle
;游戲失敗后的相關處理
fail:
mov ah,0ah
mov al," "
mov cx,01h
int 10h
inc dh
mov ah,02h
mov bh,00h
int 10h
mov ah,0ah
mov al,[di]
mov bh,00h
mov cx,01h
int 10h
mov ah,02h
mov bh,00h
mov dh,12d
mov dl,17d
int 10h
push dx
mov ah,09h
lea dx,failmeg
int 21h
pop dx
add dh,2
mov ah,02h
mov bh,00h
int 10h
mov ah,09h
lea dx,failmeg0
int 21h
re:
mov ah,07h
int 21h
cmp al,0dh
jne re
clear_screen 01,01,23,78
mov ah,02h
mov bh,00h
mov dh,11d
mov dl,20d
int 10h
push dx
mov ah,09h
lea dx,failmeg1
int 21h
pop dx
inc dh
inc dh
mov ah,02h
mov bh,00h
int 10h
mov ah,09h
lea dx,failmeg2
int 21h
notkey:
mov ah,07h
int 21h
cmp al,0dh
je to_start
cmp al,1bh
je over
jmp notkey
to_start:
clear_screen 00,00,24,79
jmp start
;結束游戲
over:
clear_screen 01,01,23,78
mov ah,02h
mov bh,00h
mov dh,11d
mov dl,15h
int 10h
mov ah,09h
lea dx,failmeg3
int 21h
mov ah,02h
mov bh,00h
mov dh,13d
mov dl,15h
int 10h
mov ah,09h
lea dx,failmeg4
int 21h
mov ah,07h
int 21h
;清屏,退出
clear_screen 00,00,24,79
mov ax,4c00h
int 21h
main endp
code ends
end start
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -