【精品】推箱子游戏汇编源程序18_第1页
【精品】推箱子游戏汇编源程序18_第2页
【精品】推箱子游戏汇编源程序18_第3页
【精品】推箱子游戏汇编源程序18_第4页
【精品】推箱子游戏汇编源程序18_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、; 推箱子游戏汇编源程序; ;-up equ 48h ;定义扫描码down equ 50hleft equ 4bhright equ 4dhf1 equ 3bhf2 equ 3chf3 equ 3dhf4 equ 3ehf5 equ 3fhf8 equ 42h;-;宏定义;- setpos macro x0,y0;设置光标位置 mov bh,0 mov dh,x0 mov dl,y0 mov ah,2 int 10h endm;-show_char macro x,y,attr,cha,no ;显示字符,x,y为坐标,attr为属性, push cx;cha为字符ascii码,no为重复次数

2、setpos x,y mov al,cha mov bl,attr mov cx,no mov ah,09h int 10h pop cx endm;- initchar macro cno,pno ;初始化字符,cno为字符串,pno为行数 lea bp,cno mov cx,15 mov dh,pno mov dl,51 mov bl,00000010b mov al,1 mov ah,13h int 10h endm;- initstor macro cno,pno;初始化仓库,cno为字符串,pno为行数 lea bp,cno mov cx,20 mov dh,pno mov dl,2

3、0 mov bl,00001011b mov al,1 mov ah,13h int 10h endm;-displaymsg macro msg push ax push bx push cx push dx push di mov ah,13h mov al,0 mov bl,00000100b mov bp,offset msg mov cx,51 mov bh,0 mov dh,23 mov dl,3 int 10h pop di pop dx pop cx pop bx pop ax endm;- setcolor macro no mov ah,0bh mov bh,00 mov

4、bl,no int 10hendm;*;* 堆栈段 ;*stack_seg segment stack;= stack_buf dw 120 dup(?) top equ $-stack_bufstack_seg ends;= ;*data_seg segment para;=s1 db 201,9,40 dup(205,9),203,9,19 dup(205,9),187,9;s1-s3为画边框s2 db 186,9,40 dup( ,9),186,9,19 dup( ,9),186,9s3 db 200,9,40 dup(205,9),202,9,19 dup(205,9),188,9s4

5、 db f1:, ,start game;s4-s12为功能说明s5 db f2:, ,save s6 db f3:, ,load s7 db f4:, ,select s8 db f5:, ,option s9 db f8:, ,quit s10 db no.:, s11 db game, ,time:, s12 db current, ,time:, gamename db hammal game;游戏名ying db 11 dup(223) ;阴影 g1 db 20 dup(177);g1-g8为仓库ascii码定义g2 db 2 dup(177),4 dup( ),4 dup(177)

6、,4 dup( ),6 dup(177)g3 db 2 dup(177),16 dup( ),2 dup(177)g4 db 2 dup(177),4 dup(176),4 dup(177),2 dup(234),2 dup(219),4 dup( ),2 dup(177)g5 db 2 dup(177),4 dup(176),4 dup(177),2 dup( ),2 dup(219),4 dup( ),2 dup(177)g6 db 2 dup(177),16 dup( ),2 dup(177)g7 db 2 dup(177),4 dup( ),4 dup(177),4 dup( ),6

7、dup(177)g8 db 20 dup(177)manx db ?;小人的坐标many db ?welcommsg db welcome to hammal game! selectmsg db press f1 to case1,f2 to case2 optionmsg db press 0.9 to set color errormsg db it is error! ;错误提示temp db ?,?,?,?;临时变量iswin db 0;标志youwin db clever! you win! press any key to continue. err1 db creat file

8、 error! err2 db open file error! err3 db read file error! err4 db write file error! err5 db close file error! correct db it is ok! flag db 0caseno db ?;=data_seg ends;*;时间数据段 ;*tdata_seg segment para;=count dw 0sec dw 0min dw 0hours dw 0 ran db 0rbn db 0rcn db 0rdn dw 0ren dw 0fla dw 0 ;=tdata_seg e

9、nds ;*;音乐数据段;*mdata_seg segment para;=mus_freq dw 330,392,330,294,330,392,330,294,330 dw 330,392,330,294,262,294,330,392,294 dw 262,262,220,196,196,220,262,294,330,262 dw -1mus_time dw 3 dup(500),250,250,500,250,250,1000 dw 2 dup(500,500,250,250),1000 dw 3 dup(500,250,250),1000;=mdata_seg ends;*;文件数

10、据段;*fdata_seg segment para;=fhle dw ? ;文件句柄 fname db ./data.dat,0 ;asciiz串下段数据存入文件list.dat,(一共39字节)relist label byte ;将relist为标志的数据段存入指定文件x db ?y db ?;=fdata_seg ends;* ;* 代码段 ;*code_seg segment para;=main proc far;主过程开始 assume cs:code_seg,es:data_seg assume ss:stack_segstart: mov ax,stack_seg mov s

11、s,ax mov sp,top mov ax,data_seg mov es,ax;- mov ah,0 mov al,3 int 10h call init call storage call music get_key:;接受键入键 mov ah,7 int 21h cmp al,0 je get_ec jmp get_keyget_ec: mov ah,7 int 21h cmp al,f1;根据扫描码转入相应处理过程 je start_g cmp al,f4 je select_g cmp al,f8 je exit jmp get_keyselect_g: call selectca

12、se start_g: ;游戏开始; call gametime call startgame;-exit: mov ax,4c00h int 21hmain endp ;主程序结束;+ selectcase proc near;选择子程序displaymsg selectmsgsel_key: ;接受键入键 mov ah,7 int 21h cmp al,0 je sel_ec jmp sel_keysel_ec: mov ah,7 int 21h cmp al,f8 je exit11 cmp al,f2 je sel2 cmp al,f1 je sel1 jmp sel_keyexit1

13、1: retsel1: jmp far ptr start_g sel2: mov caseno,32h show_char 13,58,00000011b,caseno,1 show_char 12,32,00001101b, ,2 show_char 13,24,00001101b,219,2 show_char 11,30,10001110b, ,2 show_char 10,34,10001110b,234,2 mov manx,10 mov many,34 jmp far ptr start_gselectcase endp;+init proc near;初始化子过程 mov ah

14、,0bh mov bh,00 mov bl,9 int 10h mov bp,offset s1 mov cx,62 mov bh,0 mov dh,4 mov dl,9 mov al,3 mov ah,13h int 10h mov cx,17 mov ax,5down_loop: mov bp,offset s2 push cx mov cx,62 mov bh,0 mov dh,al mov dl,9 push ax mov al,3 mov ah,13h int 10h pop ax pop cx inc ax loop down_loop mov bp,offset s3 mov c

15、x,62 mov bh,0 mov dh,22 mov dl,9 mov al,3 mov ah,13h int 10h show_char 1,32,00000001b,222,1 mov bp,offset gamename mov cx,12 mov bh,0 mov bl,00011110b mov dh,1 mov dl,33 mov al,0 mov ah,13h int 10h show_char 1,44,00000111b,220,1 mov bp,offset ying mov cx,11 mov bh,0 mov bl,00000111b mov dh,2 mov dl,

16、34 mov al,0 mov ah,13h int 10h initchar s4,5 initchar s5,6 initchar s6,7 initchar s7,8 initchar s8,9 initchar s9,11 initchar s10,13 initchar s11,15 initchar s12,18 displaymsg welcommsg mov flag,0 mov iswin,0 retinit endp;+ storage proc near;初始化仓库子过程 initstor g1,8 initstor g2,9 initstor g3,10 initsto

17、r g4,11 initstor g5,12 initstor g6,13 initstor g7,14 initstor g8,15 show_char 11,22,00000111b,176,2 show_char 11,24,00000111b,176,2 show_char 12,22,00000111b,176,2 show_char 12,24,00000111b,176,2 show_char 10,32,00001101b,219,2 show_char 11,32,00001101b,219,2 show_char 12,32,00001101b,219,2 show_cha

18、r 13,32,00001101b,219,2 mov caseno,31h show_char 13,58,00000011b,caseno,1 mov ah,2 mov bh,0 mov dh,11 mov dl,30 int 10h mov ah,09h mov al,234 mov bh,0 mov bl,10001110b mov cx,2 int 10h mov manx,11 mov many,30 mov ah,1 mov ch,4 mov cl,0 int 10h retstorage endp;+startgame proc near ;游戏子过程 push ax push

19、 bx push cx push dx push di mov ch,manx mov cl,manyget_key2: mov dx,cx mov ah,0 int 16h mov temp,-1 mov temp+1,-1 cmp ah,up jnz not_up dec ch jmp movemannot_up: cmp ah,down jnz not_down inc chnot_down: cmp ah,right jnz not_right inc clnot_right: cmp ah,left jnz moveman dec clmoveman: cmp ch,dh jl is

20、up jnle isdown cmp cl,dl jl isleft jnle isright jmp errorisup: mov temp+1,1isdown: setpos ch,cl mov bh,0 mov ah,8 int 10h cmp al,177 setpos manx,many jnz nextjmp call beepit add ch,temp+1 jmp get_key2nextjmp: cmp al,219 je nextjmp2 mov di,1 jmp nextisleft: mov temp,1 setpos ch,cl mov bh,0 mov ah,8 i

21、nt 10h cmp al,177 setpos manx,many jnz nextjmp2 call beepit add cl,temp jmp get_key2 isright: inc cl setpos ch,cl dec cl mov bh,0 mov ah,8 int 10h cmp al,177 setpos manx,many jnz nextjmp2 call beepit add cl,temp jmp get_key2nextjmp2: cmp al,219 je cagemov mov di,2 next: call sureit mov manx,ch mov many,cl show_char 23,3,00000000b, ,51 jmp get_key2exit2: pop di pop dx pop cx pop bx pop ax ret;cagemov: call movcase jmp next restart: jmp far ptr startsave_g: call sav

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论