|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
ASSUME CS:CODE,DS:DATA,SS:STACKS
DATA SEGMENT
P_X DW 145 ;高射炮起始左下角横坐标150
P_Y DW 195 ;高射炮起始左下角纵坐标195
P_PIX DB 1 ;高射炮颜色
PD_PIX DB 2 ;炮弹颜色
PD1_X DW 0 ;炮弹1起始横坐标
PD1_Y DW 0 ;炮弹1起始纵坐标
PD1_BOOR DW 0 ;炮弹1标志,1:画炮弹,0:不画炮弹
PD2 DW 0,0,0 ;炮弹2起始坐标,标志
PD3 DW 0,0,0 ;炮弹3起始坐标,标志
PD4 DW 0,0,0 ;炮弹4起始坐标,标志
PD5 DW 0,0,0 ;炮弹5起始坐标,标志
PD6 DW 0,0,0 ;炮弹6起始坐标,标志
PD7 DW 0,0,0 ;炮弹7起始坐标,标志
PD8 DW 0,0,0 ;炮弹8起始坐标,标志
PD9 DW 0,0,0 ;炮弹9起始坐标,标志
PDA DW 0,0,0 ;炮弹A起始坐标,标志
PDB DW 0,0,0 ;炮弹B起始坐标,标志
PDC DW 0,0,0 ;炮弹C起始坐标,标志
C_X DW 0
C_Y DW 0
C_X0 DW 0 ;飞机中心坐标
C_Y0 DW 75
C_R DB 37 ;半径
C_PIX DB 3 ;飞机颜色
C_D DB 0
C_LX DW 0 ;飞机左下角坐标
C_LY DW 75
C_BOOR DB 10 ;飞机运行标志,大于10上升,小于10下降
F_BOOR DB 0 ;飞机击中标志
FREQ_LIST DW 371,495,495,495,624,556,0 ;频率表
TIME_LIST DB 4, 6, 2, 4, 4, 6 ;时间表
F_NUM DB 0
T_NUM DB 0
DATA ENDS
STACKS SEGMENT
DB 128 DUP (?)
STACKS ENDS
CODE SEGMENT
; INCLUDE J:\1.52\PAO.asm
; INCLUDE J:\1.52\FEIJI.ASM
START: MOV AX,DATA
MOV DS,AX
MOV AH,0
MOV AL,5 ;320*200 4色方式
INT 10H
LOOP1:
MOV AX,0600H ;清屏
MOV BH,00
MOV CX,0000H
MOV DX,184FH
INT 10H
MOV AH,0BH ;选择调色盘
MOV BH,01
MOV BL,0 ;绿、红、黄调色盘
INT 10H
CALL PAO
CALL DAOHANG
CALL HANG1
CALL DELAY
MOV AH,01H
INT 16H
JZ LOOP1
LOOP2: MOV AH,00H ;按键判断左右控制大炮,空格发射炮弹,esc退出
INT 16H
CMP AX,4B00H
JE PR1
CMP AX,4D00H
JE PR2
CMP AL,20H
JE PR3
CMP AL,1BH
JE QUIT
JMP LOOP1 ;左移
PR1:
SUB P_X,9
CMP P_X,5
JG PR11
MOV P_X,5
PR11:
JMP LOOP1 ;右移
PR2:
ADD P_X,9
CMP P_X,285
JB PR21
MOV P_X,285
PR21:
JMP LOOP1 ;发射
PR3:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV CX,12
MOV BX,OFFSET PD1_X
L1:
CMP BYTE PTR[BX+4],0
JZ L2
ADD BX,6
LOOP L1
L2:
MOV AX,P_X ;炮弹初始坐标
ADD AX,14
MOV [BX],AX
MOV AX,P_Y
SUB AX,15
MOV [BX+2],AX
MOV DX,1
MOV BYTE PTR[BX+4],1 ;允许画炮弹
POP DX
POP CX
POP BX
POP AX
JMP LOOP1
QUIT: MOV AH,4CH
INT 21H
DELAY : PUSH CX
PUSH DX
PUSH BX
PUSH AX
MOV DX,5000
DL1: MOV CX,5500
DL2: MOV AH,01H
LOOP DL2
DEC DX
JNZ DL1
POP AX
POP BX
POP DX
POP CX
RET
;飞机程序
HANG: ;飞机飞行路线
PUSH AX
PUSH BX
PUSH CX
PUSH DX
CALL FEIJI
MOV AX,C_Y0
CMP C_BOOR,10
JNE H_L3
CALL RAND ;产生飞机飞行参数,0-20的随机数
MOV C_BOOR,BL
H_L3:
CMP C_BOOR,10
JL H_L4
MOV BL,C_BOOR ;大于10飞机上升,单步上升2格,上升c_boor-10次
DEC BL
MOV C_BOOR,BL
SUB AX,2
JMP H_L5
H_L4:
MOV BL,C_BOOR ;大于10飞机上升,单步上升2格,下降10-c_boor次
INC BL
MOV C_BOOR,BL
ADD AX,2
H_L5:
CMP AX,100 ;飞机飞行下限
JB H_L1
MOV AX,100
H_L1:
CMP AX,50 ;飞机飞行上限
JA H_L2
MOV AX,50
H_L2:
MOV C_Y0,AX
MOV AX,C_X0 ;横向飞行
ADD AX,5
MOV C_X0,AX
CMP C_X0,310 ;右边界
JB H_L6
MOV AX,0
MOV C_X0,AX
MOV AX,75
MOV C_Y0,AX
MOV AL,10
MOV C_BOOR,AL
H_L6:
POP DX
POP CX
POP BX
POP AX
RET
FEIJI :
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
MOV BX,C_X0 ;
ADD BX,5
MOV C_LX,BX
MOV AH,0CH
MOV AL,3
MOV DI,5H
MOV DX,C_Y0
F_2: MOV SI,50
MOV CX,C_X0
F_1: INT 10H
INC CX
DEC SI
JNZ F_1
DEC DX
DEC DI
JNZ F_2
MOV AL,1H
MOV DI,10
MOV DX,C_Y0
SUB DX,5H
F_4: MOV SI,5H
MOV CX,C_X0
F_3: INT 10H
INC CX
DEC SI
JNZ F_3
DEC DX
DEC DI
JNZ F_4
MOV AL,1H
MOV DI,5
MOV DX,C_Y0
SUB DX,5H
F_6: MOV SI,5H
MOV CX,C_X0
ADD CX,35
F_5: INT 10H
INC CX
DEC SI
JNZ F_5
DEC DX
DEC DI
JNZ F_6
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
RET
RAND : ;产生随机数
PUSH CX
PUSH DX
PUSH AX
STI
MOV AH,0 ;读时钟计数器值
INT 1AH
MOV AX,DX ;清高6位
AND AH,3
MOV DL,21 ;除101,产生0~100余数
DIV DL
MOV BL,AH ;余数存BX,作随机数
POP AX
POP DX
POP CX
RET
BAOZHA1 :
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AX,0
MOV C_X,AX
MOV AL,20 ;半径
MOV C_Y,AX
MOV AX,1
SBB AL,20
MOV C_D,AL
B_LOOP1:
CALL PUTDOT1
MOV BL,C_D
CMP BL,0
JG B_L1
MOV AX,C_X
MOV CX,2
IMUL CX
ADC AX,3
ADC AL,C_D
MOV C_D,AL
JMP B_L2
B_L1:
MOV AX,C_X
MOV DX,C_Y
ADC AX,DX
MOV CX,2
IMUL CX
ADC AX,5
ADC AL,C_D
MOV C_D,AL
MOV AX,C_Y
DEC AX
MOV C_Y,AX
B_L2:
MOV AX,C_X
INC AX
MOV C_X,AX
MOV CX,C_X
MOV DX,C_Y
CMP CX,DX
JLE B_LOOP1
POP DX
POP CX
POP BX
POP AX
RET
BAOZHA2 :
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AX,0
MOV C_X,AX
MOV AL,10 ;半径
MOV C_Y,AX
MOV AX,1
SBB AL,10
MOV C_D,AL
B_LOOP2:
CALL PUTDOT1
MOV BL,C_D
CMP BL,0
JG B_L3
MOV AX,C_X
MOV CX,2
IMUL CX
ADC AX,3
ADC AL,C_D
MOV C_D,AL
JMP B_L4
B_L3:
MOV AX,C_X
MOV DX,C_Y
ADC AX,DX
MOV CX,2
IMUL CX
ADC AX,5
ADC AL,C_D
MOV C_D,AL
MOV AX,C_Y
DEC AX
MOV C_Y,AX
B_L4:
MOV AX,C_X
INC AX
MOV C_X,AX
MOV CX,C_X
MOV DX,C_Y
CMP CX,DX
JLE B_LOOP2
POP DX
POP CX
POP BX
POP AX
RET
PUTDOT1 :
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AX,C_X0 ;X0+X,Y0+Y
ADD AX,C_X
MOV CX,AX
MOV AX,C_Y0
ADD AX,C_Y
MOV DX,AX
SUB DX,20
MOV BX,C_X0 ;X0-X
SBB BX,C_X
O1_LOOP1:
MOV AH,0CH ;写入点像
MOV AL,1 ;装入颜色
INT 10H
DEC CX
CMP CX,BX
JG O1_LOOP1
MOV AX,C_X0 ;X0+X,Y0-Y
ADD AX,C_X
MOV CX,AX
MOV AX,C_Y0
SBB AX,C_Y
MOV DX,AX
SUB DX,20
MOV BX,C_X0 ;X0-X
SBB BX,C_X
O1_LOOP2:
MOV AH,0CH ;写入点像
MOV AL,1 ;装入颜色
INT 10H
DEC CX
CMP CX,BX
JG O1_LOOP2
MOV AX,C_X0 ;X0+Y,Y0+X
ADD AX,C_Y
MOV CX,AX
MOV AX,C_Y0
ADD AX,C_X
MOV DX,AX
SUB DX,20
MOV BX,C_X0 ;X0-Y
SBB BX,C_Y
O1_LOOP3:
MOV AH,0CH ;写入点像
MOV AL,1 ;装入颜色
INT 10H
DEC CX
CMP CX,BX
JG O1_LOOP3
MOV AX,C_X0 ;X0+Y,Y0-X
ADD AX,C_Y
MOV CX,AX
MOV AX,C_Y0
SBB AX,C_X
MOV DX,AX
SUB DX,20
MOV BX,C_X0 ;X0-Y
SBB BX,C_Y
O1_LOOP4:
MOV AH,0CH ;写入点像
MOV AL,1 ;装入颜色
INT 10H
DEC CX
CMP CX,BX
JG O1_LOOP4
POP DX
POP CX
POP BX
POP AX
RET |
|