Pushr macro x,y,z,w
Push x
Push y
Push z
Push w
Endm
Popr macro x,y,z,w
Pop w
Pop z
Pop y
Pop x
Endm
Stacks segment
Dw 256 dup(?)
Stacks ends
Data segment
Plane db 17 ;飞机由17和符号组成
Db 3eh,06h,0,0 ;机尾,字符属性,行偏移,列偏移
Db 3dh,20h,0,2 ;机身
Db 3dh,20h,0,1 ;机身
Db 3dh,20h,0,1 ;机身
Db 10h,06h,0,2 ;机头
Db 2fh,06h,1,-2 ;右翼
Db 2fh,06h,1,-1 ;右翼
Db 5ch,06h,-3,1 ;左翼
Db 5ch,06h,-1,-1 ;左翼
Db 3eh,06h,-1,-9 ;机尾
Db 3dh,20h,0,2 ;机身
Db 3dh,20h,0,1 ;机身
Db 10h,06h,0,2 ;机头
Db 2fh,06h,1,-2 ;右翼
Db 2fh,06h,1,-1 ;右翼
Db 5ch,06h,-3,1 ;左翼
Db 5ch,06h,-1,-1 ;左翼
Bomb db 2 ;炸弹
Db 59h,04h,0,0
Db 59h,04h,-2,-8
Tree db 21 ;树林
db 124,06h,0,0
db 124,06h,0,1
db 124,06h,-1,0
db 124,06h,0,-1
db 124,06h,-1,0
db 124,06h,0,1
db 124,06h,-1,0
db 124,06h,0,-1
db 123,02h,-1,-1
db 125,02h,0,3
db 125,02h,-1,1
db 123,02h,0,-3
db 123,02h,0,-2
db 123,02h,-1,-1
db 123,02h,0,2
db 125,02h,0,5
db 125,02h,-1,0
db 123,02h,0,-6
db 123,02h,-1,1
db 125,02h,0,4
db 123,02h,-1,-1
Fire db 22 ;爆炸硝烟
db 57h,04h,0,0
db 57h,04h,0,4
db 57h,04h,0,4
db 57h,04h,-1,1
db 57h,04h,0,-2
db 57h,04h,0,-3
db 57h,04h,0,-4
db 57h,04h,0,-2
db 57h,04h,-1,-1
db 57h,04h,0,4
db 57h,04h,0,3
db 57h,04h,0,2
db 57h,04h,0,4
db 57h,04h,-1,1
db 57h,04h,0,-3
db 57h,04h,0,-3
db 57h,04h,0,-3
db 57h,04h,0,-3
db 57h,04h,0,-3
db 57h,04h,-1,6
db 57h,04h,0,4
db 57h,04h,0,3
Tank db 16 ;坦克
db 40,06h,0,0
db 15,03h,0,1
db 15,03h,0,1
db 15,03h,0,1
db 15,03h,0,1
db 41,06h,0,1
db 61,03h,-1,-1
db 61,03h,0,-1
db 61,03h,0,-1
db 61,03h,0,-1
db 61,06h,-1,-2
db 61,06h,0,1
db 61,06h,0,1
db 123,06h,0,1
db 66,06h,0,1
db 125,06h,0,1
Count dw 0 ;保存字符个数
Pointer dw 0 ;保存字符首地址
Line db 0 ;保存行号
Column db 0 ;保存列号
X db 06h
Y db 07h
Z db 06h
I db 23h
R db 23h
Time db 0
Data ends
Codes segment
Assume cs:codes,ds:data,es:data,ss:stacks
Start: mov ax,data
Mov ds,ax
Mov es,ax
mov ah,0
mov al,3
int 10h
Call clear
Lea di,plane
Mov dx,0506h
Mov bh,0
Call moves
Call clear
Mov ah,4ch
Int 21h
Moves proc ;移动子程序
Pushr ax,bx,cx,dx
Push di
Xor ch,ch
Mov cl,[di]
Inc di
Mov count,cx
Mov pointer,di
Mov line,dh
Mov column,dl
Next: add dh,[di+2]
Add dl,[di+3]
Cmp dl,80
Jb write
Pop di
Popr ax,bx,cx,dx
Ret
Write: mov ah,2
Int 10h
Mov al,[di]
Mov bl,[di+1]
Push cx
mov ah,9
mov cx,1
int 10h
Pop cx
Add di,4
Loop next
Call delay
Inc Time
Cmp Time,19
Jb U
Call Up
U: Add X,1
Add Y,2
Call delay
Call clear
call Down
Call BJ
Cmp Time,19
Jae Q
Call Tk
Q: Call Erase
Jmp short next
Moves endp
TK proc ;坦克子程序
Pushr ax,bx,cx,dx
Push di
F: Lea di,Tank
Mov dh,18h
Mov dl,I
Add I,8
Mov bh,0
Xor ch,ch
Mov cl,[di]
Inc di
K: add dh,[di+2]
Add dl,[di+3]
mov ah,2
Int 10h
Mov al,[di]
Mov bl,[di+1]
Push cx
mov ah,9
mov cx,1
int 10h
Pop cx
Add di,4
Loop K
Cmp I,36h
Jb F
Mov I,23h
pop di
popr ax,bx,cx,dx
ret
TK endp
Up proc ;硝烟子程序
Pushr ax,bx,cx,dx
Push di
G: Lea di,Fire
Mov dh,18h
Mov dl,R
Add R,8
Mov bh,0
Xor ch,ch
Mov cl,[di]
Inc di
J: add dh,[di+2]
Add dl,[di+3]
mov ah,2
Int 10h
Mov al,[di]
Mov bl,[di+1]
Push cx
mov ah,9
mov cx,1
int 10h
Pop cx
Add di,4
Loop J
Cmp R,32h
Jb G
Mov R,23h
pop di
popr ax,bx,cx,dx
ret
Up endp
Down proc ;炸弹下落子程序
Pushr ax,bx,cx,dx
Push di
Lea di,Bomb
Mov dh,X
Mov dl,Y
Mov bh,0
Xor ch,ch
Mov cl,[di]
Inc di
M: add dh,[di+2]
Add dl,[di+3]
mov ah,2
Int 10h
Mov al,[di]
Mov bl,[di+1]
Push cx
mov ah,9
mov cx,1
int 10h
Pop cx
Add di,4
Loop M
pop di
popr ax,bx,cx,dx
ret
Down endp
BJ proc ;树林子程序
Pushr ax,bx,cx,dx
Push di
O: Lea di,Tree
Mov dh,18h
Mov dl,Z
Add Z,6
Mov bh,0
Xor ch,ch
Mov cl,[di]
Inc di
N: add dh,[di+2]
Add dl,[di+3]
mov ah,2
Int 10h
Mov al,[di]
Mov bl,[di+1]
Push cx
mov ah,9
mov cx,1
int 10h
Pop cx
Add di,4
Loop N
Cmp Z,80
jb O
Mov Z,06
pop di
popr ax,bx,cx,dx
ret
BJ endp
Erase proc ;擦除轨迹子程序
Mov cx,count
Mov di,pointer
Mov dh,line
Mov dl,column
l: add dh,[di+2]
mov ah,2
add dl,[di+3]
int 10h
mov al,[di]
mov bl,0
push cx
mov ah,9
mov cx,1
int 10h
pop cx
Add di,4
loop l
mov cx,count
mov di,pointer
mov dh,line
Add column,2
mov dl,column
ret
erase endp
delay proc ;延时子程序
pushr ax,bx,cx,dx
mov dx,2000h
go: mov cx,5000h
repeat: loop repeat
dec dx
jne go
popr ax,bx,cx,dx
ret
delay endp
clear proc ;清屏幕