一个需要用汇编语言编写的小游戏程序
假设CS:Code,DS:Code
Org 100h
开始:按0b800h
流行元素
推送cs
流行数码相机
mov cx,0fffh= = = = = =清空屏幕
代表stosw
德鲁芬:;= = = = = =分数标签
丽丝,芬
mov di,160+10
呼叫打印
子di,4
mov [fi],di;标签光标
画外音:;= = = = = =放置食物。
mov di,160+40
mov ax,0a05h
mov cl,8
drf:添加di,160*2+90
stosw
环路drf
draw Qian:;= = = = = =画一面墙
异或di,di
mov cl,80
mov ax,0C1Fh
repnz stosw
mov di,160*24
mov cl,80
mov ax,0C1Eh
repnz stosw
异或di,di
mov cl,24
mov ax,0C10h
Q1: mov es:[di],ax
地址di,160
环路Q1
mov di,158
mov cl,24
mov ax,0C11h
Q2:电影:[迪],斧头
地址di,160
环路Q2
;= = = = = = = = = = = = = = = = = = = = = = = = = = = =初始化蛇的数据。
InitS: mov bp,0;Bp=方向,ch=节点数,[Snake+_newxy]=XY坐标。
移动通道,3
mov word ptr[Snake+_newxy],_center
MainL:;游戏开始
呼叫movSnake
调用操作键
jmp短维护
出口:丽丝,完毕
中心移动
呼叫打印
int 20h结束
;= = = = = = = = = = = = = = = = =移动头部。
丽丝,蛇
mov bx,word ptr[si+_ new xy];获取当前值
推送bx
加bx,word ptr[dir+BP];添加偏移量x
mov ax,es:[bx]
cmp al,01h;击中某人的身体
Je出口
cmp al,10h;突然跑不动了
Je出口
cmp al,11h;突然跑不动了
Je出口
cmp al,1Eh;突然跑不动了
Je出口
cmp al,1Fh;突然跑不动了
Je出口
cmp al,05h吃食物
Jne氧化镁
打电话吃饭
氧化镁:
mov字ptr[si+_newxy],bx;更新
mov字ptr es:[bx],0e02h拉头(' _ ')
pop bx
mov字ptr[si+_oldxy],bx;保存旧xy
添加si,_ len= = = = = = = = =移动并绘制身体。
电影cl,ch
十二月cl
Jz mb
mlin:
推送字ptr[si+_ new xy];保存当前值
mov di,word ptr[si-_ len+_ old xy];获取prev.oldxy
mov字ptr[si+_newxy],di;更新当前值
mov ax,1e 01h;绘制正文
stosw
pop word ptr[si+_ old xy];保存旧XY
添加si,_ len下一个
十二月cl
Jnz mlin
mov di,word ptr[si-_ len+_ old xy];擦掉最后一个!
异或ax,ax
stosw
mb: ret
;= = = = = = = = = = =吃菜。
eat:Inc ch;
Jns v0
Jmp出口
v0: mov字ptr es:[bx],0;抹掉它
mov di,bx
添加di,90
cmp di,0f00h
Jb v2
mov di,dx
还有di,0f00h
v2:mov字ptr es:[di],0a05h
mov di,word ptr[fi];只能显示99个。
cmp字节指针:[di],' 9 '
JB v1
移动字节指针:[di],' 0 '
子di,2
v1: inc字节指针es:[di]
浸水使柔软
;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
打印:mov ah,0dh
山:洛德士
stosw
cmp al,0
jnz sa
浸水使柔软
;= = = = = = = = = = =键盘控制区
操作键:;游戏的操作键
推bx cx
mov ah,0
int 1ah
添加dx,4
mov bx,dx
重量:int 1ah
cmp dx,bx
jb wt
pop cx bx
在铝,60h
k0: cmp al,左侧
Jne k1
运动血压,0
k1: cmp al,右侧
Jne k2
运动血压,2
k2: cmp al,向上
Jne k3
运动血压,4
k3: cmp al,向下
Jne k4
运动血压,6
k4: cmp al,退出
Jne retk
Jmp出口
返回:返回
;= = = = = = = = = = = = =数据区
超过db '游戏结束',0
分数据库'分数=000 ',0
fi dw?
方向图-2,+2,-160,+160
_ center equ 160 * 12+60
_newxy equ 0
_oldxy equ 2
_len equ 4
离开EQU 75
右EQU 77
向上EQU 72
沿着EQU 80号公路
逃离EQU 1
蛇:
代码结束
结束开始