|   
 UID1 威望1240 点 金钱24019 金币 点卡317 点 
 | 
1#
 发表于 2003-10-16 20:02 
 | 只看该作者 
 [分享]一个有趣的打字游戏
| 复制代码;--------------------------------------------------------------------------------;此模板是纯DOS程序代码,需要MASM5.0,编译时请使用"编译 -> DOS"方式。;--------------------------------------------------------------------------------Init_game macro op1,op2,op3,op4,op5,op6 mov cx,00h mov dh,op1 mov dl,op2op6: mov ah,02hmov bh,00h int 10hpush cxmov ah,0ahmov al,op3mov bh,00hmov cx,01hint 10hpop cxinc cxinc op4cmp cx,op5jne op6 endmclear_screen macro op1,op2,op3,op4 mov ah,06h mov al,00hmov bh,07hmov ch,op1mov cl,op2mov dh,op3mov dl,op4int 10hmov ah,02hmov bh,00hmov dh,00hmov dl,00hint 10hendmmenu macro op1,op2,op3 mov ah,02hmov bh,00hmov dh,op1mov dl,op2int 10hmov ah,09hlea dx,op3int 21hendmdata segment linjiang db "Made by lin jiang$" no db "NO.:021411$"meg db "Let us have a game!!Come on!!$"meg1 db "**Select Menu**$"meg2 db "Please select the game speed,ESC to quit.$"meg3 db "1.Very slow Too easy,speed up!$"meg4 db "2.Slow Everybody can deal.$"meg5 db "3.Nomal I think you can deal!$"meg6 db "4.Fast A challenge.Pay attention!$"meg7 db "5.Very Fast Too hard,Have a try?$"meg8 db "6.Fastest Are you crazy??$"meg9 db "*Select the number among 1-6 and press ENTER to start!*$"meg10 db "Game Speed Select:$"hotkey db "When you are playing games:$" hotkey1 db "ESC to return to menu$"hotkey2 db "SPACE to pause the game$"hotkey3 db "Press any key to play games......$"hotkey4 db "Are you ready??$"failmeg db "The letter is arrive the bottom, You are lost ! :($" failmeg0 db "Press ENTER to go on......$"failmeg1 db "Game is over!$"failmeg2 db "Press ENTER to return menu and press ESC to exit!$"failmeg3 db "Bye-Bye!Thank for your playing!!$"failmeg4 db "Press any key to quit......$"speed dw 00d,1200d,800d,600d,400d,200d,100d letters db "jwmilzoeucgpravskntxhdyqfb" db "iytpkwnxlsvxrmofzhgaebudjq"db "nwimzoexrphysfqtvdcgljukda"letters_bak db "jwmilzoeucgpravskntxhdyqfb" db "iytpkwnxlsvxrmofzhgaebudjq" db "nwimzoexrphysfqtvdcgljukda"letter_counter db 0 life_flag db 78 dup(0)position_flag db 78 dup(0) present_position db 1 data endsstack segment para stack 'stack'db 64 dup(0)stack endscode segmentmain proc farassume cs:code,ds:data,ss:stackstart:mov ax,datamov ds,axmov letter_counter,00h mov present_position,1 lea si,position_flag mov ah,00hmov cx,00hinit_postion_flag: mov [si],ahinc siinc cxcmp cx,78djne init_postion_flaglea di,letters lea si,letters_bakmov cx,00hinit_letters:mov ah,[si]mov [di],ahinc siinc diinc cxcmp cx,78djne init_lettersmov ah,00hlea si,life_flagmov cx,00hinit_life_flag:mov [si],ahinc siinc cxcmp cx,78djne init_life_flagmov cx,00h mov ah,01h or ch,00010000bint 10hclear_screen 00d,00d,24d,79d Init_game 00d,00d,0ah,dl,80d,nextsign1 Init_game 24d,00d,0ah,dl,80d,nextsign2Init_game 00d,00d,0ah,dh,25d,nextsign3Init_game 00d,79d,0ah,dh,25d,nextsign4menu 01d,15d,meg ;菜单信息的宏展开menu 01h,61d,linjiang menu 03d,20d,meg1menu 03d,68d,nomenu 05d,15d,meg2menu 07d,15d,meg3menu 09d,15d,meg4menu 11d,15d,meg5menu 13d,15d,meg6menu 15d,15d,meg7menu 17d,15d,meg8menu 19d,15d,meg9menu 22d,15d,meg10input: mov ah,02h mov bh,00hmov dh,22dmov dl,33dint 10hmov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hmov ah,01hint 21hretry: cmp al,"1"je speed1cmp al,"2"je speed2cmp al,"3"je speed3cmp al,"4"je speed4cmp al,"5"je speed5cmp al,"6"je speed6cmp al,1bhje to_over0jmp inputto_over0:jmp over speed1: mov ah,01h int 21hcmp al,0dhjne otherkeymov ax,speed+2mov speed,axjmp begin speed2: mov ah,01h int 21hcmp al,0dhjne otherkeymov ax,speed+4mov speed,axjmp beginspeed3: mov ah,01h int 21hcmp al,0dhjne otherkeymov ax,speed+6mov speed,axjmp beginspeed4: mov ah,01h int 21hcmp al,0dhjne otherkeymov ax,speed+8mov speed,axjmp beginspeed5: mov ah,01h int 21hcmp al,0dhjne otherkeymov ax,speed+10mov speed,axjmp beginspeed6: mov ah,01h int 21hcmp al,0dhjne otherkeymov ax,speed+12mov speed,axjmp begin otherkey: ; 处理重复输入的代码段push axmov ah,02hmov bh,00hmov dh,22dmov dl,34dint 10hmov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hmov ah,02hmov bh,00hmov dh,22dmov dl,33dint 10hpop axmov dx,axmov ah,02hint 21hjmp retry begin: clear_screen 01d,01d,23d,78d menu 08d,20d,hotkey menu 10d,20d,hotkey1menu 12d,20d,hotkey2menu 14d,20d,hotkey4menu 16d,20d,hotkey3mov ah,07hint 21hclear_screen 01d,01d,23d,78d Init_game 23d,01d,01h,dl,78d,nextsign5mov ah,02h ;光标初始化mov bh,00hmov dh,01hmov dl,01hint 10hmov cx,00h lea si,lettersnextletter: ; 初始化屏幕上方的字母mov ah,02hmov dl,[si]int 21hinc siinc cxcmp cx,78dje nextcyclejmp nextletterfrom_front: ; 相关循环的算法sub present_position,78d jmp gobackto_sifind_zero:cmp letter_counter,78d je recyclecmp present_position,78dje from_onemov ah,00hnextsi: add present_position,01hinc sicmp [si],ahje gobackto_dicmp present_position,78dje from_onejmp nextsifrom_one:mov present_position,01h jmp gobackto_sirecycle:mov letter_counter,00hmov present_position,01dlea si,position_flagmov cx,00hmov ah,00hclearsi: mov [si],ahinc cxcmp cx,78dje nextcycleinc sijmp clearsinextcycle: lea di,letterslea si,position_flagadd present_position,31dcmp present_position,78ja from_frontgobackto_si:add si,word ptr present_positiondec simov ah,[si]cmp ah,01hje find_zerogobackto_di:mov ah,01hmov [si],ahadd di,word ptr present_positiondec dimov dl,present_positionmov ah,02h ; 字母下落的代码段部分mov bh,00h mov dh,01hint 10hmov cx,00hnextrow:push cx ; 新的一行mov cx,00hout_cycle: ; 延迟push cxmov cx,00hin_cycle:add cx,01hcmp cx,50000djne in_cycle push dxmov ah,06hmov dl,0ffhint 21hpop dxjz pass ; 如果键盘缓冲区部分为空,则跳转cmp al,1bh ; 如果键入ESC,则返回主菜单je to_start1cmp al," " ;如果键入SPACE,则游戏暂停je pausecmp al,[di] ;输入字母正确!跳转!je disappearpass:pop cxinc cxcmp cx,speedje printjmp out_cyclepause: push dx ;暂停处理mov ah,06hmov dl,0ffhint 21hpop dxcmp al," "jne pausejmp passto_start1: ;返回主菜单jmp start print: mov ah,0ah mov al," "mov bh,00hmov cx,01hint 10hinc dhmov ah,02hmov bh,00hint 10hmov ah,0ahmov al,[di]mov bh,00hmov cx,01hint 10hpop cxinc cxcmp cx,21dje print_next_letterjmp nextrow ; 下一行disappear: ; 击中字母后的相关处理pop cxpop cxmov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hjmp hit print_next_letter: ; 处理原位置的空缺lea si,life_flagadd si,word ptr present_positiondec simov ah,[si]cmp ah,1je failmov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hinc dh mov ah,02hmov bh,00hint 10hmov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hmov ah,1mov [si],ahhit: mov ah,02hmov bh,00hmov dh,01hmov dl,present_positionint 10hmov al,[di] ; 出现下一个新字母的数法add al,7cmp al,7ahja convey_lettermov ah,0ahmov bh,00hmov cx,01hint 10hmov [di],aladd letter_counter,01hjmp nextcycleconvey_letter: sub al,7ahadd al,61hmov ah,0ahmov bh,00hmov cx,01hint 10hmov [di],aladd letter_counter,01hjmp nextcycle fail: mov ah,0ah ;游戏失败后的相关处理mov al," "mov cx,01hint 10hinc dhmov ah,02hmov bh,00hint 10hmov ah,0ahmov al,[di]mov bh,00hmov cx,01hint 10hmov ah,02hmov bh,00hmov dh,12dmov dl,17dint 10hpush dxmov ah,09hlea dx,failmegint 21hpop dxadd dh,2mov ah,02hmov bh,00h int 10hmov ah,09hlea dx,failmeg0int 21hre: mov ah,07hint 21hcmp al,0dhjne reclear_screen 01,01,23,78mov ah,02hmov bh,00hmov dh,11dmov dl,20dint 10hpush dxmov ah,09hlea dx,failmeg1int 21hpop dxinc dhinc dhmov ah,02hmov bh,00hint 10hmov ah,09hlea dx,failmeg2int 21hnotkey: mov ah,07hint 21hcmp al,0dhje to_startcmp al,1bhje overjmp notkeyto_start: clear_screen 00,00,24,79jmp startover: clear_screen 01,01,23,78 mov ah,02hmov bh,00hmov dh,11dmov dl,15hint 10hmov ah,09hlea dx,failmeg3int 21hmov ah,02hmov bh,00hmov dh,13dmov dl,15hint 10hmov ah,09hlea dx,failmeg4int 21hmov ah,07hint 21hmov ah,07hint 21hclear_screen 00,00,24,79 mov ax,4c00hint 21hmain endpcode endsend start 
 | 
 
| 我是一个呼吸着现在的空气而生活在过去的人
 这样的注定孤独,孤独的身处闹市却犹如置身于荒漠
 我已习惯了孤独,爱上孤独
 他让我看清了自我,还原了自我
 让我再静静的沉思中得到快乐和满足
 再孤独的世界里我一遍又一遍
 不厌其烦的改写着自己的过去
 延伸到现在与未来
 然而那只是泡沫般的美梦
 产生的时刻又伴随着破灭的到来
 在灰飞烟灭的瞬间我看到的是过程的美丽
 而不是结果的悲哀。。。
 
 |  |