⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 game.txt

📁 用汇编编的一个游戏
💻 TXT
📖 第 1 页 / 共 2 页
字号:
        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 + -