| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1528 人关注过本帖
标题:关于汇编小游戏高射炮打飞机的小问题
取消只看楼主 加入收藏
l1142778722
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-1-3
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
关于汇编小游戏高射炮打飞机的小问题
最近在学汇编语言,在网上看了份游戏代码,试了下不能运行。新手水平有限,改了几天没改好,不知道pao.asm程序到底是什么内容。把“INCLUDE J:\1.52\PAO.asm
INCLUDE J:\1.52\FEIJI.ASM”注释掉后,提示找不到pao..程序里有这个,就是不能调用,是距离太远了,所以调用不到吗?请大神帮帮忙,看看怎么改才能正常运行~~~万分感激
       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
              ASSUME    CS:CODE,DS:DATA,SS:STACKS

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  PROC      NEAR
              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
       DELAY  ENDP

    PAOSHENG  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      SI
              PUSH      DI

              MOV       DX,43H      ;初始化8254工作方式
              MOV       AL,0B6H     ;定时器3、方式3
              OUT       DX,AL

              MOV       SI,OFFSET FREQ_LIST     ;装入频率表起始地址
              MOV       DI,OFFSET TIME_LIST     ;装入时间表起始地址
              MOV       BX,0
              MOV       BL,F_NUM
              ADD       SI,BX
              MOV       BL,T_NUM
              ADD       DI,BX

              MOV       DX,61H
              IN        AL,DX
              PUSH      AX
              OR        AL,03H
              OUT       DX,AL
      

              MOV       DX,0FH      ;输入时钟为1.0416667MHz,1.0416667M = 0FE502H
              MOV       AX,0E502H
              DIV       WORD PTR [SI]           ;取出频率值计算计数初值,0F4240H / 输出频率
              MOV       DX,42H
              OUT       DX,AL       ;装入计数初值
              MOV       AL,AH
              OUT       DX,AL

              MOV       DL,[DI]     ;取出演奏相对时间,调用延时子程序
              CALL      DALLY1

              ADD       SI,2
              INC       DI

              ADD       F_NUM,2
              INC       T_NUM
      
              POP       AX
              MOV       DX,61H
              OUT       DX,AL

              POP       DI
              POP       SI
              POP       DX
              POP       CX
              POP       BX
              POP       AX

              RET
    PAOSHENG  ENDP

      DALLY1  PROC                  ;延时子程序
         D0:  MOV       CX,200H
         D1:  MOV       AX,0FFFFH
         D2:  DEC       AX
              JNZ       D2
              LOOP      D1
              DEC       DL
              JNZ       D0
              RET
      DALLY1  ENDP

        CODE  ENDS
              END       START



;飞机程序
        HANG  PROC      NEAR        ;飞机飞行路线
              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
        HANG  ENDP
       FEIJI  PROC      NEAR
              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
       FEIJI  ENDP
        RAND  PROC                  ;产生随机数
              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
        RAND  ENDP


     BAOZHA1  PROC      NEAR
              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
     BAOZHA1  ENDP

     BAOZHA2  PROC      NEAR
              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
     BAOZHA2  ENDP

     PUTDOT1  PROC      NEAR

              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
     PUTDOT1  ENDP



       HANG1  PROC      NEAR        ;飞机飞行规划
              PUSH      CX
              PUSH      DX
              PUSH      BX
              PUSH      AX
      
              CMP       F_BOOR,0    ;飞机击中标志,0未击中;
              JNE       HANG_1
              CALL      HANG
              JMP       HANG_2
     HANG_1:                        ;击中
      
              CMP       F_BOOR,5    ;大烟雾5帧
              JBE       HANG_6
      
              CALL      PAOSHENG
              CALL      BAOZHA2
              DEC       F_BOOR
              JMP       HANG_5
      
     HANG_6:
              CALL      PAOSHENG
              CALL      BAOZHA1
              DEC       F_BOOR
              JNZ       HANG_5
              MOV       AX,0
              MOV       C_X0,AX
              MOV       AX,5
              MOV       C_Y0,AX
              JMP       HANG_5
     HANG_2:
              MOV       CX,12
              MOV       BX,OFFSET PD1_X
     HANG_3:
              CMP       [BX+4],0
              JZ        HANG_4
      
              MOV       AX,[BX+2]
              CMP       AX,C_LY
              JG        HANG_4
              ADD       AX,15
              CMP       AX,C_LY
              JB        HANG_4
      
              MOV       AX,[BX]
              CMP       AX,C_LX
              JB        HANG_4
              SUB       AX,54
              CMP       AX,C_LX
              JG        HANG_4
      
              MOV       F_NUM,0
              MOV       T_NUM,0
      
              MOV       AX,6        ;击中画面时长6帧
              MOV       F_BOOR,AL
      
              MOV       AX,0        ;击中,炮弹消失
              MOV       [BX+4],AX
              JMP       HANG_5
     HANG_4:
              ADD       BX,6
              DEC       CX
              CMP       CX,0
              JNZ       HANG_3
      
     HANG_5:
     
              POP       AX
              POP       BX
              POP       DX
              POP       CX
      

              RET
       HANG1  ENDP

;大炮程序
         PAO  PROC
              PUSH      AX
              PUSH      CX
              PUSH      DX
              PUSH      SI
              PUSH      DI
              MOV       AH,0CH      ;写入点像
              MOV       AL,P_PIX    ;装入颜色
              MOV       DI,5        ;底座高度
              MOV       DX,P_Y
     DISP_2:  MOV       SI,30       ;底座宽度
              MOV       CX,P_X
     DISP_1:  INT       10H
              INC       CX
              DEC       SI
              JNZ       DISP_1
              DEC       DX
              DEC       DI
              JNZ       DISP_2
                   ;底座完成
              MOV       DI,10       ;炮筒高度
              MOV       DX,P_Y
              SUB       DX,5H
     DISP_4:  MOV       SI,10       ;炮筒宽
              MOV       CX,P_X
              ADD       CX,10
     DISP_3:  INT       10H
              INC       CX
              DEC       SI
              JNZ       DISP_3
              DEC       DX
              DEC       DI
              JNZ       DISP_4

              POP       DI
              POP       SI
              POP       DX
              POP       CX
              POP       AX
              RET
         PAO  ENDP


      PAODAN  PROC      NEAR        ;画炮弹 CX,横坐标.DX,纵坐标
              PUSH      AX
              PUSH      BX
              PUSH      DX
              PUSH      CX
            
              MOV       AH,0CH      ;写入点像
              MOV       AL,PD_PIX   ;装入颜色
              MOV       DI,3        ;炮弹高
  PD_DISP_2:  MOV       SI,3        ;炮弹宽
  PD_DISP_1:  INT       10H
              INC       CX
              DEC       SI
              JNZ       PD_DISP_1
              INC       DX
              POP       CX
              PUSH      CX
              DEC       DI
              JNZ       PD_DISP_2
      
              POP       CX
              POP       DX
              POP       BX
              POP       AX

              RET
      PAODAN  ENDP


     DAOHANG  PROC      NEAR        ;导航
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      SI

              MOV       AX,12
              MOV       BX,OFFSET PD1_X
      PD_L1:
              CMP       [BX+4],0    ;炮弹1标志为0,不画炮弹
              JZ        PD_NO

              MOV       CX,[BX]
              MOV       DX,[BX+2]
              CALL      PAODAN
              SUB       [BX+2],9    ;炮弹上移
   
              MOV       DX,[BX+2]   ;判断炮弹是否移出屏幕
              CMP       DX,0000H
              JG        PD_NO
              MOV       DX,0
              MOV       [BX],DX
              MOV       [BX+2],DX
              MOV       [BX+4],DX   ;炮弹1消失,标志置0
      PD_NO:
              ADD       BX,6        ;指向下一发炮弹

              DEC       AX
              JNZ       PD_L1

              POP       SI
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
     DAOHANG  ENDP

;声音程序
    PAOSHENG  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSH      SI
              PUSH      DI



              MOV       DX,43H      ;初始化8254工作方式
              MOV       AL,B7H      ;定时器3、方式3
              OUT       DX,AL

              MOV       SI,OFFSET FREQ_LIST     ;装入频率表起始地址
              MOV       DI,OFFSET TIME_LIST     ;装入时间表起始地址

              MOV       DX,61H
              IN        DX,AL
      ;PUSH AX
              OR        AL,03
              OUT       DX,AL
      
              MOV       DX,0FH      ;输入时钟为1.0416667MHz,1.0416667M = 0FE502H
              MOV       AX,0E502H
              DIV       WORD PTR [SI]           ;取出频率值计算计数初值,0F4240H / 输出频率
              MOV       DX,42H
              OUT       DX,AL       ;装入计数初值
              MOV       AL,AH
              OUT       DX,AL

              MOV       DL,[DI]     ;取出演奏相对时间,调用延时子程序
              CALL      DALLY1

              ADD       SI,2
              INC       DI

              CMP       WORD PTR [SI],0         ;判断是否到曲末?
              JE        OUT1
              JMP       PLAY
       OUT1:
      ;POP AX
              MOV       DX,61H
              OUT       DX,AL

              POP       DI
              POP       SI
              POP       DX
              POP       CX
              POP       BX
              POP       AX

              RET
    PAOSHENG  ENDP


      DALLY1  PROC                  ;延时子程序
         D0:  MOV       CX,200H
         D1:  MOV       AX,0FFFFH
         D2:  DEC       AX
              JNZ       D2
              LOOP      D1
              DEC       DL
              JNZ       D0
              RET
      DALLY1  ENDP


搜索更多相关主题的帖子: 高射炮 
2013-01-06 13:22
l1142778722
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-1-3
收藏
得分:0 
自己先顶下,求不沉
2013-01-06 13:23
l1142778722
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-1-3
收藏
得分:0 
求大神~~~
2013-01-06 13:28
快速回复:关于汇编小游戏高射炮打飞机的小问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043559 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved