home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 13 / af013.adf / DaveJones / MENACE.S < prev    next >
Text File  |  1978-04-15  |  73KB  |  2,894 lines

  1. *****************************************************************************
  2. *                                            *
  3. *    Amiga system takeover framework                            *
  4. *    1988 Dave Jones, DMA Design                            *
  5. *                                            *
  6. * Allows killing of system, allowing changing of all display & blitter        *
  7. * hardware, restoring to normal after exiting.                        *
  8. * Memory must still be properly allocated/deallocated upon entry/exit       *
  9. * DOS routines for loading must be called BEFORE killing the system           *
  10. *                                            *
  11. * Written using Devpac2                                    *
  12. *                                            *
  13. *****************************************************************************
  14.  
  15.     section    Framework,code_c    
  16.  
  17.     incdir        "fast:devpac/include/"
  18.     include     libraries/dos_lib.i
  19.     include     exec/exec_lib.i
  20.     include     hardware/custom.i
  21.  
  22. Hardware        equ    $dff000
  23. SystemCopper1        equ    $26
  24. SystemCopper2        equ    $32
  25. PortA            equ    $bfe001
  26. ICRA            equ    $bfed01
  27. LeftMouse        equ    6
  28.  
  29. BackgroundWidth        equ    100    100 bytes wide
  30. ForegroundWidth        equ    92    92  bytes wide
  31. ScreenHeight        equ    192    playing area 192 lines high (12 blocks)
  32. NumberPlanes        equ    3    3 planes in each playfield
  33.  
  34. BytesPerBackPlane    equ    BackgroundWidth*ScreenHeight
  35. BytesPerForePlane    equ    ForegroundWidth*ScreenHeight
  36. BackgroundMemory    equ    2*NumberPlanes*BytesPerBackPlane
  37. ForegroundMemory    equ    NumberPlanes*BytesPerForePlane
  38. MemNeeded        equ    BackgroundMemory+ForegroundMemory
  39.  
  40. FullFirepower        equ    0
  41. aliensize        equ    24<<6!3
  42. firedelay        equ    3
  43.  
  44. *******************************************************************************
  45.  
  46. start    lea    GraphicsName(pc),a1    open the graphics library purely
  47.     move.l    _SysBase,a6        to find the system copper
  48.     clr.l    d0
  49.     jsr    _LVOOpenLibrary(a6)
  50.     move.l    d0,GraphicsBase
  51.     lea    DOSName(pc),a1        open the DOS library to allow
  52.     clr.l    d0            the loading of data before
  53.     jsr    _LVOOpenLibrary(a6)    killing the system
  54.     move.l    d0,DOSBase
  55.  
  56.     move.l    #MemNeeded,d0        properly allocate some chip
  57.     moveq.l    #2,d1            memory for screens etc.
  58.     jsr    _LVOAllocMem(a6)    d1 = 2, specifies chip memory
  59.     tst.l    d0            where screens,samples etc
  60.     beq    MemError        must be (bottom 512K)
  61.     move.l    d0,MemBase
  62.  
  63. *******************************************************************************
  64.  
  65.     lea    variables(pc),a5    a5 is the variables pointer
  66.     lea    rasters(a5),a0
  67.     lea    displayraster(a5),a1
  68.     move.l    d0,(a0)+        calculate the address of each plane
  69.     move.l    d0,(a1)+        store them in the variables area,
  70.     add.l    #BytesPerBackPlane,d0    twice for the background as it is
  71.     move.l    d0,(a0)+        double buffered            
  72.     move.l    d0,(a1)+
  73.     add.l    #BytesPerBackPlane,d0
  74.     move.l    d0,(a0)+            
  75.     move.l    d0,(a1)+
  76.     add.l    #BytesPerBackPlane,d0
  77.     move.l    d0,(a0)+            
  78.     add.l    #BytesPerForePlane,d0
  79.     move.l    d0,(a0)+            
  80.     add.l    #BytesPerForePlane,d0
  81.     move.l    d0,(a0)+            
  82.     add.l    #BytesPerForePlane,d0
  83.     move.l    d0,(a0)+            
  84.     move.l    d0,(a1)+
  85.     add.l    #BytesPerBackPlane,d0
  86.     move.l    d0,(a0)+            
  87.     move.l    d0,(a1)+
  88.     add.l    #BytesPerBackPlane,d0
  89.     move.l    d0,(a0)+            
  90.     move.l    d0,(a1)+
  91.  
  92.     move.l    #Hardware,a6
  93.     jsr    TakeSystem
  94.  
  95. *******************************************************************************
  96.  
  97.     move.l    #$dff000,a6        a6 ALWAYS point to base of
  98.     move.l    #-1,bltafwm(a6)        custom chips
  99.     bsr    GameInit
  100.     move.l    #clist,cop1lc(a6)
  101.     move.w    #$87e0,dmacon(a6)    enable copper,sprite,blitter
  102.     move.w    #$7fff,intreq(a6)    clear all int request flags
  103.     move.w    #$0c30,clxcon(a6)
  104.  
  105. *******************************************************************************
  106.  
  107. * Main game loop with the routines we are yet to cover commented out
  108.  
  109. *******************************************************************************
  110.  
  111. vloop    bsr    waitline223        interrupt set at vertical 
  112.     not.b    vcount(a5)        position 223 (panel start)
  113.     beq    twoblanks        alternate every frame
  114.  
  115.     lea    copperlist(pc),a1    set up registers for routine
  116.     move.w    pf2scroll(a5),d0    checkpf2
  117.     move.w    pf1scroll(a5),d1
  118.     bsr    checkpf2        and branch to it
  119.     bsr    moveship    
  120.     bsr    check.collision
  121.     bsr    erase.missiles
  122.     bsr    levels.code
  123.     bsr    update.missiles
  124.     bsr    drawfgnds
  125. *    bsr    print.score
  126. *    bsr    check.keys
  127.     bsr    check.path
  128.     bra    vloop
  129. twoblanks    
  130.     bsr    checkpf1        the following routines are only
  131.     bsr    flipbgnd        executed every second frame
  132.     bsr    moveship
  133.     bsr    restorebgnds        restore backgrounds behind aliens
  134.     bsr    process.aliens        
  135.     bsr    save.aliens        save the backgrounds behind aliens
  136.     bsr    draw.aliens        and then draw the aliens
  137.  
  138.     tst.b    kill.game(a5)    
  139.     beq    vloop
  140.     bra    alldone    
  141.  
  142. **************************************************************************
  143.  
  144. waitline223
  145.     btst    #4,intreqr+1(a6)    wait for vertical line 223
  146.     beq    waitline223        interrupt set by the
  147.     move.w    #$10,intreq(a6)        copperlist
  148. return    rts
  149.  
  150. **************************************************************************
  151.  
  152. checkpf1
  153.     cmp.w    #3,level.end(a5)    level.end = 3 means 
  154.     beq    return            guardian on, so no scroll
  155.     lea    copperlist(pc),a1
  156.     move.w    pf2scroll(a5),d0    d0 = pf2 scroll value (0-15)
  157.     move.w    pf1scroll(a5),d1    d1 = pf1 scroll value (0-15)
  158.     subq.w    #1,d1            scroll a pixel
  159.     bcs    resetpf1        reset back to 15
  160. checkpf2
  161.     cmp.w    #3,level.end(a5)    as above
  162.     beq    return
  163.     subq.w    #1,d0            scroll a pixel
  164.     bcs    resetpf2        reset to 15 and update pointers
  165. storescroll                    
  166.     move.w    d1,pf1scroll(a5)    resave the values
  167.     move.w    d0,pf2scroll(a5)
  168.     move.w    pf1count(a5),d2
  169.     subq.w    #1,d2            check if at the end of the two
  170.     or.w    d1,d2            screens and flag for the sprite
  171.     move.w    d2,screenend(a5)    routine if true    
  172.     lsl.w    #4,d0
  173.     or.w    d0,d1
  174.     move.w    d1,54(a1)        put the new scroll value into 
  175.     rts                the copper list
  176.  
  177. resetpf1
  178.     moveq    #$f,d1            reset scroll to 15
  179.     subq.w    #1,pf1count(a5)        decrement words scrolled
  180.     bne    storepf1        carry on if not zero
  181.     move.w    #23,pf1count(a5)    otherwise reset the number of
  182.     lea    rasters(a5),a4        words to scroll and reset the 
  183.     lea    displayraster(a5),a3    display planes back to the very
  184.     move.l    (a4)+,(a3)+        start.
  185.     move.l    (a4)+,(a3)+
  186.     move.l    (a4)+,(a3)+        six planes in all
  187.     add.w    #12,a4
  188.     move.l    (a4)+,(a3)+
  189.     move.l    (a4)+,(a3)+
  190.     move.l    (a4)+,(a3)+
  191.     bra    checkpf2        now check pf2
  192. storepf1
  193.     lea    displayraster(a5),a3    increment the plane pointers
  194.     addq.l    #2,(a3)            by a word each
  195.     addq.l    #2,4(a3)        these are background planes
  196.     addq.l    #2,8(a3)        and are therefore double
  197.     addq.l    #2,12(a3)        buffered
  198.     addq.l    #2,16(a3)
  199.     addq.l    #2,20(a3)
  200.     bra    checkpf2
  201.  
  202. resetpf2
  203.     lea    rasters(a5),a4
  204.     moveq    #$f,d0            reset scroll back to 15
  205.     subq.w    #1,pf2count(a5)        decrement the word scroll
  206.     bne    respf2            value and reset if zero
  207.     move.w    #23,pf2count(a5)
  208.     clr.w    pf2offset(a5)        offset is reverse of pf2count
  209.     cmp.w    #1,level.end(a5)    and is used for the copper
  210.     bne    respf2            level.end = 1 when map finished
  211.     addq.w    #1,level.end(a5)    so start to draw guardian
  212.     bsr    change.colours        setup the guardian colours
  213.     move.w    #6*72,guard.offset(a5)    changes the missiles
  214. respf2 
  215.     move.l    12(a4),d2        get the foreground plane 
  216.     move.l    16(a4),d3        pointers and add the offset to
  217.     move.l    20(a4),d4        them
  218.     addq.w    #2,pf2offset(a5)
  219.     add.w    pf2offset(a5),d2    store these in the copper list
  220.     add.w    pf2offset(a5),d3
  221.     add.w    pf2offset(a5),d4
  222. storepf2
  223.     move.w    d2,30(a1)
  224.     move.w    d3,38(a1)
  225.     move.w    d4,46(a1)
  226.     bra    storescroll
  227.  
  228. **************************************************************************
  229.  
  230. flipbgnd    
  231.     lea    copperlist(pc),a1    swap the background displays
  232.     lea    displayraster(a5),a3    every second frame
  233.     move.l    (a3),d4
  234.     move.l    4(a3),d5
  235.     move.l    8(a3),d6
  236.     move.l    12(a3),(a3)
  237.     move.l    16(a3),4(a3)
  238.     move.l    20(a3),8(a3)
  239.     move.l    d4,12(a3)
  240.     move.l    d5,16(a3)
  241.     move.l    d6,20(a3)
  242.     addq    #4,d4            add 4 bytes (32 pixels) to the
  243.     addq    #4,d5            pointers so that clipping can
  244.     addq    #4,d6            be carried out on the left
  245.     move.w    d4,6(a1)        hand side
  246.     swap    d4
  247.     move.w    d4,2(a1)        store the new ones in the copper
  248.     move.w    d5,14(a1)        list
  249.     swap    d5
  250.     move.w    d5,10(a1)
  251.     move.w    d6,22(a1)
  252.     swap    d6
  253.     move.w    d6,18(a1)
  254.     not.b    screen.num(a5)
  255.     rts
  256.  
  257. **************************************************************************
  258.  
  259. drawfgnds
  260.     cmp.w    #3,level.end(a5)    3 for guardian fully on
  261.     beq    return
  262.     cmp.w    #2,level.end(a5)    2 for drawing guardian
  263.     beq    draw.guardian
  264.     tst.w    pf2scroll(a5)        every 16 pixels a new strip
  265.     beq    drawbegin        of foreground graphics are
  266.     cmp.w    #$e,pf2scroll(a5)    drawn into a hidden part
  267.     beq    drawend            of the screen
  268.     rts
  269. drawbegin
  270.     bsr    setupblit
  271.     clr.l    d6            d6 = offset into the screen
  272.     move.l    fgndpointer(a5),a0    for the start of the screen
  273.     bsr    drawfgnd        this will be zero
  274.     subq    #1,a0
  275.     move.l    a0,fgndpointer(a5)
  276.     rts
  277.  
  278. drawend
  279.     bsr    setupblit
  280.     moveq    #46,d6            as the screen is 46 bytes
  281.     move.l    fgndpointer(a5),a0    wide, this is the offset
  282.     cmp.b    #$ff,(a0)        at which to draw the strip
  283.     bne    drawfgnd
  284.     sub.w    #12,a0            the end of map is flagged
  285.     move.l    a0,fgndpointer(a5)    by an FF block number
  286.     move.w    #1,level.end(a5)    flag the end of the map
  287.  
  288. drawfgnd
  289.     clr.l    d0
  290.     move.b    (a0)+,d0        d0 = block number (0-254)
  291.     lea    rasters(a5),a4        get the current foreground
  292.     move.l    12(a4),d1        plane pointers in d1,d2,d3
  293.     move.l    16(a4),d2
  294.     move.l    20(a4),d3
  295.     add.l    d6,d1            add the offset passed
  296.     add.l    d6,d2
  297.     add.l    d6,d3
  298.     add.w    pf2offset(a5),d1    add the scrolled words
  299.     add.w    pf2offset(a5),d2    offset to each plane
  300.     add.w    pf2offset(a5),d3
  301.     moveq    #11,d7            12 blocks in height
  302.     move.l    #graphics,a4        a4 = base address of the graphics
  303. fgndloop                    
  304.     move.l    a4,d4
  305.     mulu    #96,d0            96 bytes per graphic blocks
  306.     ext.l    d0            (2 bytes wide x 16 high
  307.     add.l    d0,d4             x 3 planes)
  308.     bsr    blitfgnd
  309.     add.l    #ForegroundWidth*16,d1    work out address of 16 scanlines
  310.     add.l    #ForegroundWidth*16,d2    down 
  311.     add.l    #ForegroundWidth*16,d3
  312.     clr.l    d0
  313.     move.b    (a0)+,d0        get next block number
  314.     dbf    d7,fgndloop        and repeat for all 12
  315.     rts
  316.  
  317. blitfgnd
  318.     move.l    d1,bltdpt(a6)        blit a 16x16 pixel block
  319.     move.l    d4,bltapt(a6)        into the foreground screen
  320.     move.w    #$0401,bltsize(a6)    unmasked with no shift
  321.     add.l    #32,d4
  322.     move.l    d2,bltdpt(a6)
  323.     move.l    d4,bltapt(a6)
  324.     move.w    #$0401,bltsize(a6)
  325.     add.l    #32,d4
  326.     move.l    d3,bltdpt(a6)
  327.     move.l    d4,bltapt(a6)
  328.     move.w    #$0401,bltsize(a6)
  329.     rts
  330.  
  331. setupblit
  332.     move.w    #$09f0,bltcon0(a6)        minterm for D = A
  333.     clr.w    bltcon1(a6)
  334.     clr.w    bltamod(a6)            data is stored sequentially
  335.     move.w    #ForegroundWidth-2,bltdmod(a6)
  336.     rts
  337.  
  338. **************************************************************************
  339.  
  340. buildbackgnd
  341.     lea    rasters(a5),a0
  342.     move.l    (a0),a1            get the background plane pointers
  343.     move.l    4(a0),a2        in a1-a4 (double buffered so 2 sets)
  344.     move.l    24(a0),a3        background graphics are only 4 colour
  345.     move.l    28(a0),a4        (2 planes) so third plane is ignored
  346.     addq    #4,a1            skip the hidden words used for
  347.     addq    #4,a2            clipping
  348.     addq    #4,a3
  349.     addq    #4,a4
  350.     move.l    #backgroundtable,a0    a0 = the background map
  351.     move.w    level.number(a5),d0
  352.     mulu    #144,d0            144 bytes per background map
  353.     add.w    d0,a0
  354.     moveq    #11,d0            12 blocks high
  355. build1    moveq    #11,d1            24 blocks across
  356.     movem.l    a1-a4,-(sp)
  357. build2    move.b    (a0),d2            this loop draws 2 across
  358.     lsr.b    #4,d2            block number stored in 4 bits
  359.     bsr    drawback
  360.     move.b    (a0)+,d2
  361.     and.b    #$f,d2
  362.     tst.w    d1
  363.     beq    skipit
  364.     bsr    drawback
  365. skipit    dbf    d1,build2        do all 24 across
  366.     movem.l    (sp)+,a1-a4
  367.     add.l    #BackgroundWidth*16,a1    next block down the way
  368.     add.l    #BackgroundWidth*16,a2
  369.     add.l    #BackgroundWidth*16,a3
  370.     add.l    #BackgroundWidth*16,a4
  371.     dbf    d0,build1        do all 12 high
  372.     move.l    #$dff000,a6
  373.     rts
  374.  
  375. drawback
  376.     lea    backgrounds,a6        a6 = the background graphics
  377.     move.w    level.number(a5),d3
  378.     mulu    #1024,d3        1024 bytes per level of background
  379.     add.w    d3,a6            graphics (16 blocks)
  380.     and.w    #$f,d2
  381.     mulu    #64,d2            64 bytes per block
  382.     add.l    d2,a6            (2 bytes x 16 high x 2 planes)
  383.     movem.l    a1-a4,-(sp)
  384.     moveq    #15,d3
  385. drawb1    move.w    (a6),(a1)        draw into both the screens
  386.     move.w    (a6),(a3)
  387.     move.w    (a6),46(a1)        
  388.     move.w    (a6),46(a3)
  389.     move.w    32(a6),(a2)
  390.     move.w    32(a6),(a4)
  391.     move.w    32(a6),46(a4)
  392.     move.w    32(a6),46(a2)
  393.     add.w    #BackgroundWidth,a1
  394.     add.w    #BackgroundWidth,a2
  395.     add.w    #BackgroundWidth,a3
  396.     add.w    #BackgroundWidth,a4
  397.     addq    #2,a6
  398.     dbf    d3,drawb1
  399.     movem.l    (sp)+,a1-a4
  400.     addq    #2,a1            next block along
  401.     addq    #2,a2
  402.     addq    #2,a3
  403.     addq    #2,a4
  404.     rts
  405.  
  406. **************************************************************************
  407.  
  408. GameInit
  409.     lea    map,a0
  410.     move.l    a0,fgndpointer(a5)    set up the map index
  411.     move.w    #23,pf1count(a5)    width of the foreground in words
  412.     move.w    #24,pf2count(a5)    width of the background in words
  413.     move.w    #15,pf1scroll(a5)    initial scroll value
  414.     move.w    #15,pf2scroll(a5)
  415.     move.w    #100,xpos(A5)        ships initial x,y & speed
  416.     move.w    #80,ypos(a5)
  417.     move.w    #2,ship.speed(a5)
  418.     move.w    #1,mult.number(a5)
  419.     move.l    #ship1.2,shipaddress(a5) setup address of initial ship
  420.     move.w    #10,path.delay(a5)
  421.     move.w    #5,bonus.count(a5)
  422.  
  423.     move.w    #128,ship.energy(a5)
  424.     move.w    #$ffff,ship.count(a5)
  425.     move.w    #324-12,d0
  426.     bsr    max.energy
  427.     move.l    #explosion.sequence,explosion.ptr(a5)
  428.     move.l    #guardian+384,guardian.data(a5)
  429.     move.w    #999,guardian.count(a5)
  430.     
  431.     lea    copperlist(pc),a1
  432.     lea    rasters(a5),a0
  433.     move.w    (a0),2(a1)        copy the plane adresses into the
  434.     move.w    2(a0),6(a1)        copperlist
  435.     move.w    4(a0),10(a1)
  436.     move.w    6(a0),14(a1)
  437.     move.w    8(a0),18(a1)
  438.     move.w    10(a0),22(a1)
  439.     move.w    12(a0),26(a1)
  440.     move.w    14(a0),30(a1)
  441.     move.w    16(a0),34(a1)
  442.     move.w    18(a0),38(a1)
  443.     move.w    20(a0),42(a1)
  444.     move.w    22(a0),46(a1)
  445.     addq.w    #4,6(a1)        skip the hidden words in the
  446.     addq.w    #4,14(a1)        background
  447.     addq.w    #4,22(a1)
  448.     lea    scroll.value(pc),a0
  449.     move.w    #$ff,2(a0)
  450.  
  451.     move.l    #panel+32,d0        put the address of the panel
  452.     lea    rastersplit2(pc),a1    graphics into the copper
  453.     moveq    #3,d1            the panel is 4 planes
  454. setup1    move.w    d0,6(a1)
  455.     swap    d0
  456.     move.w    d0,2(a1)
  457.     swap    d0
  458.     add.l    #1408,d0        panel size is 352x32 (1408 bytes
  459.     addq    #8,a1            per plane)
  460.     dbf    d1,setup1
  461.  
  462.     lea    level.colours(pc),a0    copy the level colours into the
  463.     lea    colours(pc),a1        copperlist
  464.     moveq    #31,d0
  465. .copy    move.w    (a0)+,2(a1)
  466.     addq    #4,a1
  467.     dbf    d0,.copy
  468.  
  469.     lea    panel.colours(pc),a0    copy the panel colours into the
  470.     lea    colours2(pc),a1        copperlist
  471.     moveq    #15,d0
  472. .copy2    move.w    (a0)+,2(a1)
  473.     addq    #4,a1
  474.     dbf    d0,.copy2
  475.  
  476.     bsr    ship.to.copper        setup the hardware sprite pointers
  477.  
  478.     bsr    clear.screen
  479.     bsr    buildbackgnd        and draw the background
  480.     bsr    setup.mouse
  481.  
  482.     IFNE    FullFirepower
  483.     st.b    mult1.on(a5)
  484.     st.b    mult2.on(a5)
  485.     st.b    canons.on(a5)
  486.     st.b    lasers.on(A5)
  487.     move.w    #2,ship.speed(A5)
  488.     move.b    #3,ship.status(a5)    
  489.     bsr    change.ship
  490.     ENDC
  491.     rts
  492.  
  493.  
  494. clear.screen
  495.     move.l    rasters(a5),a0        clear all the screen memory
  496.     move.w    #MemNeeded/4-1,d0
  497. clear.scr1
  498.     clr.l    (a0)+
  499.     dbf    d0,clear.scr1
  500.     rts
  501.  
  502. **************************************************************************
  503.  
  504. check.collision
  505.     tst.b    ship.dead(a5)            no action taken if he's dead
  506.     bne    return
  507.     move.w    clxdat(a6),d0            get collison value in d0
  508.     bsr    collect.bonus            check if bonus mode
  509.     and.w    #$46,d0
  510.     beq    return                no collision, so return
  511.     tst.w    field.count(a5)            is force field on
  512.     bne    return
  513.     cmp.b    #3,last.path(a5)        is guardian dead
  514.     beq    return
  515.     move.w    ship.count(a5),d2
  516.     and.w    #$6,d0                bits 1 & 2 of clxdat for background
  517.     beq    check3
  518.     tst.b    last.path(a5)
  519.     beq    normal.value            decrease by 8 if guardian path
  520. normal.value
  521.     lsr.w    #5,d2                
  522.     bcc    shield.decrease            
  523. no.decrease
  524.     move.w    d2,ship.count(a5)
  525.     rts
  526. check3
  527.     cmp.w    #2,level.end(a5)
  528.     bge    foreground.hit            guardian always deadly
  529.     tst.w    difficulty(a5)
  530.     beq    return                no effect on easy level
  531. foreground.hit
  532.     lsr.w    #3,d2                on level. This is less than for
  533.     bcs    no.decrease            alien collisons
  534. shield.decrease
  535.     subq.w    #2,ship.energy(a5)        bit 5 of clxdat for foreground
  536.     move.w    ship.energy(a5),d1
  537.     bmi    explode                if shield <0 start the explosion
  538.     move.w    #$ffff,ship.count(a5)        reset secondary count
  539.     move.w    #324-12,d0
  540.     bra    decrease.energy
  541.  
  542. explode
  543.     st    ship.dead(a5)            flag ship dead
  544.     move.w    xpos(a5),d4
  545.     move.w    ypos(a5),d5
  546.     clr.l    d0                return longword in do
  547.     add.w    #44,d5                hardware offset vertical
  548.     lsl.w    #8,d5                into bits 8-15
  549.     add.w    #128,d4                horizontal offset
  550.     lsr.w    #1,d4                /2 low bit into extend
  551.     or.w    d5,d4                X intact
  552.     move.w    d4,d0                X still intact
  553.     swap    d0                ditto
  554.     roxl.w    #1,d0                get low bit of hstart into bit 0
  555.     add.w    #$1800,d5            calcualate vstop (+24 lines)
  556.     or.w    d5,d0                low word set up
  557.     move.l    d0,d1
  558.     move.l    d0,d2
  559.     add.l    #$00080000,d1            3 sprites for the explosion
  560.     add.l    #$00100000,d2            so each is 16 pixels apart
  561.  
  562.     lea    ship.explosion,a1
  563.     moveq    #9,d7
  564. setup.sprite
  565.     move.l    d0,(a1)                store the new coords in the ten
  566.     move.l    d1,104(a1)            explosion animations
  567.     move.l    d2,208(a1)
  568.     add.l    #312,a1
  569.     dbf    d7,setup.sprite
  570.     lea    colours(pc),a0
  571.     move.w    #$fd0,70(a0)            copy the explosion colours into
  572.     move.w    #$fd0,86(a0)            the copper
  573.     move.w    #$f80,74(a0)
  574.     move.w    #$f80,90(a0)
  575.     move.w    #$c21,78(a0)
  576.     move.w    #$c21,94(a0)
  577.     
  578. explode.ship
  579.     addq.w    #1,explosion.delay(a5)
  580.     and.w    #%11,explosion.delay(a5)
  581.     bne    return
  582.     move.l    explosion.ptr(a5),a0        points to an animation sequence
  583.     clr.w    d0                ended by 255
  584.     move.b    (a0)+,d0
  585.     bmi    game.over
  586.     move.l    a0,explosion.ptr(a5)
  587.     move.l    #ship.explosion,d1
  588.     mulu    #312,d0                work out the next sprite address
  589.     add.l    d0,d1
  590.     lea    sprite(pc),a0
  591.     moveq    #2,d0
  592. explode1
  593.     move.w    d1,6(a0)            and put it in the copper
  594.     swap    d1
  595.     move.w    d1,2(a0)
  596.     swap    d1
  597.     add.w    #104,d1
  598.     addq.l    #8,a0
  599.     dbf    d0,explode1
  600.     clr.w    2(a0)                make sure outriders are not
  601.     clr.w    6(a0)                displayed
  602.     rts
  603.  
  604. game.over
  605.     st.b    kill.game(a5)
  606.     rts
  607.  
  608. collect.bonus
  609.     move.w    d0,d1
  610.     and.w    #$6,d1                was it a foreground hit
  611.     beq    return                if so no bonus
  612.     tst.b    bonus.mode(a5)
  613.     beq    return
  614.     move.w    bonus.num(a5),d1
  615.     beq    bonus.score
  616.     cmp.w    #1,d1
  617.     beq    max.canons
  618.     cmp.w    #2,d1
  619.     beq    max.lasers
  620.     cmp.w    #3,d1
  621.     beq    increase.speed
  622.     cmp.w    #4,d1
  623.     beq    attach.mult
  624.     cmp.w    #5,d1
  625.     beq    force.field
  626.  
  627.     addq.b    #1,num.shields(a5)
  628.     move.w    #324-12,d0            final one is full shields
  629.     move.w    #128,ship.energy(a5)
  630.     bsr    max.energy
  631.     bra    collect.end    
  632.  
  633. bonus.score
  634.     move.l    #$1000,score.add(a5)
  635.     bra    collect.end
  636.  
  637. max.canons
  638.     addq.b    #1,num.canons(a5)
  639.     tst.b    canons.on(a5)            attach canons or power them up
  640.     beq    attach1
  641.     move.w    #676-12,d0
  642.     move.w    #128,canon.energy(a5)
  643.     bsr    max.energy
  644.     bra    collect.end
  645. attach1
  646.     st    canons.on(a5)            activate canons
  647.     addq.b    #1,ship.status(a5)
  648.     bsr    change.ship
  649.     bra    collect.end
  650.  
  651. max.lasers
  652.     addq.b    #1,num.lasers(a5)
  653.     tst.b    lasers.on(a5)
  654.     beq    attach2
  655.     move.w    #1028-12,d0
  656.     move.w    #128,laser.energy(a5)
  657.     bsr    max.energy
  658.     bra    collect.end
  659. attach2
  660.     st    lasers.on(a5)
  661.     addq.b    #2,ship.status(a5)
  662.     bsr    change.ship
  663.     bra    collect.end
  664.  
  665. increase.speed
  666.     cmp.w    #8,ship.speed(a5)        
  667.     beq    collect.end
  668.     addq.b    #1,num.speedups(a5)
  669.     addq.w    #1,ship.speed(a5)        pixel speed between        
  670.     bra    collect.end            1 & 7 only
  671.  
  672. force.field
  673.     addq.b    #1,num.fields(a5)
  674.     move.w    #768,field.count(a5)        set up the force field count
  675.     move.w    #$f,colours+74            make ship outline blue
  676.     bra    collect.end
  677.  
  678. attach.mult
  679.     tst.b    mult1.on(a5)            attach outriders
  680.     bne    attach.mult2
  681.     st    mult1.on(a5)
  682.     addq.b    #1,num.outriders(a5)
  683.     bra    collect.end
  684. attach.mult2
  685.     addq.b    #1,num.outriders(a5)
  686.     st    mult2.on(a5)
  687.  
  688. collect.end
  689.     clr.w    d0                no collison
  690.     move.l    #path.buffer,a0
  691.     clr.w    x.pos(a0)            reset the bonus path
  692.     clr.b    bonus.mode(a5)
  693.     move.w    #$ffff,ship.count(a5)
  694.     rts
  695.  
  696.  
  697. max.energy
  698.     move.l    #panel,a0            d0 = offset
  699.     add.w    d0,a0
  700.     moveq    #7,d1
  701. max.loop
  702.     or.w    #$5555,(a0)            set all energy bits
  703.     or.w    #$5555,44(a0)
  704.     or.w    #$5555,88(a0)
  705.     addq    #2,a0
  706.     dbf    d1,max.loop
  707.     rts
  708.     
  709. moveship
  710.     tst.b    ship.dead(a5)
  711.     bne    explode.ship
  712.     tst.w    field.count(a5)
  713.     beq    no.field
  714.     move.w    #$f,colours+74
  715.     subq.w    #1,field.count(a5)        decrement the force field
  716.     bne    no.field
  717.     clr.w    colours+74            outline back to black
  718. no.field
  719.     btst    #1,field.count+1(a5)        check lsb
  720.     beq    no.field2
  721.     move.w    #$00c,colours+74
  722. no.field2
  723.     bsr    joy            read joystick & mouse
  724.     tst.w    ypos(a5)        upper y limit of 0
  725.     bge    up.ok
  726.     clr.w    d0            reset up flag if not allowed
  727.     clr.w    yvector(a5)        and no y movement
  728. up.ok    cmp.w    #150,ypos(a5)        maximum y value is 150
  729.     ble    down.ok
  730.     clr.w    d1            if at max signal down no more
  731.     clr.w    yvector(a5)
  732. down.ok    tst.w    xpos(a5)        minimum x position is 0
  733.     bge    left.ok
  734.     clr.w    d3
  735.     clr.w    xvector(a5)
  736. left.ok    cmp.w    #266,xpos(a5)        maximum x position is 266
  737.     ble    right.ok
  738.     clr.w    d2
  739.     clr.w    xvector(a5)
  740. right.ok
  741.  
  742.     move.w    ship.speed(a5),d4    d4 = ship speed
  743.     move.w    d4,d5            d5 = -ve ship speed
  744.     neg.w    d5                
  745.     clr.w    up.down(a5)        make ship untilt
  746.     move.w    yvector(a5),d7        change the y vector first
  747. up    tst.w    d0            are we going up?
  748.     beq    down            no, so check down    
  749.     move.w    #-560,up.down(a5)    yes, so tilt ship up (anims 560 bytes apart)
  750.     cmp.w    d7,d5            are we at max y speed
  751.     beq    right            yes, so go and check x movement
  752.     subq.w    #1,d7            no, so decrease the vector
  753.     bra    right
  754. down    tst.w    d1            are we going down?
  755.     beq    right            no, so check right
  756.     move.w    #560,up.down(a5)    yes, so tilt the ship down
  757.     cmp.w    d7,d4            are we at max y speed
  758.     beq    right            yes, so check x movement
  759.     addq.w    #1,d7            no, so increase the y vector
  760. right    move.w    d7,yvector(a5)        store the new y vector
  761.     move.w    xvector(a5),d7
  762.     clr.w    d6            now do the x vector which is
  763.     tst.w    d2            virtually identical to the y above
  764.     beq    left
  765.     moveq    #1,d6
  766.     cmp.w    d7,d4
  767.     beq    add.vectors
  768.     addq    #1,d7
  769.     bra    add.vectors
  770. left    tst.w    d3
  771.     beq    add.vectors
  772.     moveq    #-1,d6
  773.     cmp.w    d7,d5
  774.     beq    add.vectors
  775.     subq    #1,d7
  776. add.vectors
  777.     move.w    d7,xvector(a5)
  778.  
  779.     or.w    d2,d3            if we have moved left or right we
  780.     bne    checky            may have to alter the animation
  781.     move.w    #4,mult.delay(a5)    of the multiples
  782.  
  783.     moveq    #1,d7            if the ship is not being moved but
  784.     tst.w    xvector(a5)        still has some inertia then decrease
  785.     beq    checky            the x & y vectors until they hit 0
  786.     bmi    xto0
  787.     neg.w    d7
  788. xto0    add.w    d7,xvector(a5)
  789. checky    or.w    d0,d1
  790.     bne    add.vectors2
  791.     moveq    #1,d7
  792.     tst.w    yvector(a5)
  793.     beq    add.vectors2
  794.     bmi    yto0
  795.     neg.w    d7
  796. yto0    add.w    d7,yvector(a5)
  797.  
  798. add.vectors2
  799.     move.w    xpos(a5),d4        finally add the new vectors to
  800.     move.w    ypos(a5),d5        the x & y coordinates
  801.     add.w    xvector(a5),d4
  802.     add.w    yvector(a5),d5
  803.     move.w    d4,xpos(a5)
  804.     move.w    d5,ypos(a5)
  805.     bsr    xytosprite        convert the xy coords into
  806.     move.l    shipaddress(a5),a0    hardware sprite format
  807.     add.w    up.down(a5),a0        add the up/down offset
  808.  
  809.  
  810.     * now set up the four hardware sprite control words
  811.  
  812.     move.l    d0,(a0)            ship 1.1 (rear end)
  813.     bset    #7,d0
  814.     move.l    d0,184(a0)        ship 1.2 with attach bit set
  815.     add.l    #$0b080000,d0        add 11 to vstart & 16 to hstart
  816.     bclr    #7,d0            reset attach bit
  817.     sub.w    #$0b00,d0        vstop is 11 less
  818.     move.l    d0,2*184(a0)        ship 1.3 (front)
  819.     bset    #7,d0            set attach
  820.     move.l    d0,2*184+96(a0)        ship 1.4
  821.     bsr    ship.to.copper        put the address of the current
  822.     subq.w    #1,mult.delay(a5)    ship in the copper
  823.     bne    same.outrider        and finally work out which multiple 
  824.     move.w    #4,mult.delay(a5)    to display
  825.     add.w    d6,mult.number(a5)    outriders must be between
  826.     bne    max.mult        1 & 5
  827.     move.w    #1,mult.number(a5)
  828. max.mult
  829.     cmp.w    #6,mult.number(a5)
  830.     bne    same.outrider
  831.     move.w    #5,mult.number(a5)
  832. same.outrider
  833.     bsr    draw.outrider        draw the multiple into the sprite
  834.     bra    check.firekey
  835.  
  836. **************************************************************************
  837.  
  838. xytosprite
  839. *    d4 = x coordinate
  840. *    d5 = y coordinate
  841. *    returns d0.l as the control words
  842.  
  843.     clr.l    d0            return longword in do
  844.     add.w    #44-11,d5        hardware offset vertical
  845.     lsl.w    #8,d5            into bits 8-15
  846.     add.w    #128,d4            horizontal offset
  847.     lsr.w    #1,d4            /2 low bit into extend
  848.     or.w    d5,d4            X intact
  849.     move.w    d4,d0            X still intact
  850.     swap    d0            ditto
  851.     roxl.w    #1,d0            get low bit of hstart into bit 0
  852.     add.w    #$2c00,d5        calcualate vstop (+44 lines)
  853.     or.w    d5,d0            low word set up
  854.     rts
  855.  
  856. **************************************************************************
  857.  
  858. draw.outrider
  859.     move.w    mult.number(a5),d0    get the animation number
  860.     tst.b    mult1.on(a5)        for the multiple
  861.     bne    mult1ok
  862.     clr.w    d0
  863. mult1ok
  864.     lea    outriders,a0        base address of outriders
  865.     mulu    #44,d0            44 bytes per plane for pair
  866.     add.w    d0,a0
  867.     move.l    a0,a1            a0 = plane 1
  868.     add.w    #264,a1            a1 = plane 2
  869.     move.l    shipaddress(a5),a2    current ship address
  870.     add.w    up.down(a5),a2
  871.     addq    #4,a2            get past sprite header
  872.     movem.l    a0-a2,-(sp)
  873.     moveq    #10,d7            11 lines high
  874. out1    move.w    (a0)+,(a2)+
  875.     move.w    (a1)+,(a2)+
  876.     dbf    d7,out1
  877.     tst.b    mult2.on(a5)
  878.     bne    mult2ok
  879.     lea    outriders,a0        if mult 2 not on then
  880.     move.l    a0,a1            point the data to zeroes
  881. mult2ok
  882.     add.w    #22*2*2,a2        pass the ship graphics
  883.     moveq    #10,d7            and draw the bottom one
  884. out2    move.w    (a0)+,(a2)+
  885.     move.w    (a1)+,(a2)+
  886.     dbf    d7,out2            planes 1 & 2 done
  887.  
  888.     movem.l    (sp)+,a0-a2        get back pointers
  889.     add.w    #528,a0            a0 = plane 3
  890.     add.w    #528,a1            a1 = plane 4
  891.     add.w    #44*4+8,a2        next sprite
  892.     moveq    #10,d7            11 lines high
  893. out3    move.w    (a0)+,(a2)+
  894.     move.w    (a1)+,(a2)+
  895.     dbf    d7,out3
  896.     tst.b    mult2.on(a5)
  897.     bne    mult3ok
  898.     lea    outriders,a0        if mult 2 not on then
  899.     move.l    a0,a1            point the data to zeroes
  900. mult3ok
  901.     add.w    #22*2*2,a2        pass the ship graphics
  902.     moveq    #10,d7            and draw the bottom one
  903. out4    move.w    (a0)+,(a2)+
  904.     move.w    (a1)+,(a2)+
  905.     dbf    d7,out4            planes 3 & 4 done
  906.     rts
  907.  
  908.  
  909. **************************************************************************
  910.  
  911. check.firekey
  912.     bsr    get.firekey
  913.     bne    fire
  914.     clr.b    firekey(a5)
  915.     rts
  916. fire    tst.w    fire.delay(a5)
  917.     bne    fire.end
  918.     move.w    #firedelay,fire.delay(a5)
  919.     tst.b    firekey(a5)
  920.     beq    test.missiles
  921.     rts
  922. fire.end
  923.     move.w    #firedelay,fire.delay(a5)
  924.     rts
  925.     
  926. get.firekey
  927.     move.b    PortA,d0
  928.     not.b    d0
  929.     and.b    #$c0,d0
  930.     rts
  931.  
  932. shift.coords
  933.     lea    xpos(a5),a2
  934.     move.w    16(a2),20(a2)
  935.     move.w    18(a2),22(a2)
  936.     move.w    12(a2),16(a2)
  937.     move.w    14(a2),18(a2)
  938.     move.w    8(a2),12(a2)
  939.     move.w    10(a2),14(a2)
  940.     move.w    4(a2),8(a2)
  941.     move.w    6(a2),10(a2)
  942.     move.w    (a2),4(a2)
  943.     move.w    2(a2),6(a2)
  944.     rts
  945.  
  946. test.missiles
  947.     st    firekey(a5)
  948.     clr.w    d0                0 for missile sound only
  949.     tst.w    canon.energy(a5)
  950.     sne    d1
  951.     and.w    #1,d1                1 for canons only
  952.     tst.w    laser.energy(a5)
  953.     sne    d2
  954.     and.w    #2,d2                2 for lasers only
  955.     add.w    d1,d0
  956.     add.w    d2,d0                3 for all
  957. ;    lea    effects(pc),a0
  958. ;    move.b    0(a0,d0.w),d0
  959. ;    jsr    initfx
  960.  
  961.     moveq    #3,d7
  962. fire3    btst    d7,activemissiles(a5)
  963.     beq    initmissile
  964.     dbf    d7,fire3
  965.  
  966. test.canon
  967.     tst.b    canons.on(a5)
  968.     beq    test.lasers
  969.     tst.w    canon.energy(a5)
  970.     beq    test.lasers
  971.     moveq    #2,d7
  972. fire1    btst    d7,activecanons(a5)
  973.     beq    initcanon
  974.     dbf    d7,fire1
  975.  
  976. test.lasers
  977.     tst.b    lasers.on(a5)
  978.     beq    test.mult1
  979.     tst.w    laser.energy(a5)
  980.     beq    test.mult1
  981.     moveq    #2,d7
  982. fire4    btst    d7,activelasers(a5)
  983.     beq    initlaser
  984.     dbf    d7,fire4
  985.  
  986. test.mult1
  987.     tst.b    mult1.on(a5)
  988.     beq    test.mult2
  989.     moveq    #1,d7
  990. fire5    btst    d7,activemult1(a5)
  991.     beq    init.mult1
  992.     dbf    d7,fire5
  993.  
  994. test.mult2    
  995.     tst.b    mult2.on(a5)
  996.     beq    fire7
  997.     moveq    #1,d7
  998. fire6    btst    d7,activemult2(a5)
  999.     beq    init.mult2
  1000.     dbf    d7,fire6
  1001. fire7
  1002.     rts
  1003.  
  1004. init.mult1
  1005.     bset    d7,activemult1(a5)
  1006.     lea    mult1data(a5),a0
  1007.     lsl.w    #3,d7
  1008.     add.w    d7,a0
  1009.     move.w    xpos(a5),d0
  1010.     add.w    #38,d0
  1011.     move.w    d0,(a0)+
  1012.     move.w    ypos(a5),d0
  1013.     addq    #6,d0
  1014.     move.w    d0,(a0)+
  1015.     move.w    mult.number(a5),d0
  1016.     subq.w    #1,d0
  1017.     lsl.w    #1,d0
  1018.     lea    mult1offsets(pc),a1
  1019.     move.b    0(a1,d0.w),(a0)+    
  1020.     move.b    1(a1,d0.w),(a0)+
  1021.     move.w    #16,(a0)+
  1022.     bra    test.mult2    
  1023.  
  1024. init.mult2
  1025.     bset    d7,activemult2(a5)
  1026.     lea    mult2data(a5),a0
  1027.     lsl.w    #3,d7
  1028.     add.w    d7,a0
  1029.     move.w    xpos(a5),d0
  1030.     add.w    #38,d0
  1031.     move.w    d0,(a0)+
  1032.     move.w    ypos(a5),d0
  1033.     add.w    #40,d0
  1034.     move.w    d0,(a0)+
  1035.     move.w    mult.number(a5),d0
  1036.     subq.w    #1,d0
  1037.     lsl.w    #1,d0
  1038.     lea    mult2offsets(pc),a1
  1039.     move.b    0(a1,d0.w),(a0)+    
  1040.     move.b    1(a1,d0.w),(a0)+
  1041.     move.w    #16,(a0)+
  1042.     rts    
  1043.  
  1044. initmissile
  1045.     bset    d7,activemissiles(a5)
  1046.     lea    missiledata(a5),a0
  1047.     lsl.w    #3,d7
  1048.     add.w    d7,a0
  1049.     move.w    xpos(a5),d0
  1050.     add.w    #58,d0
  1051.     move.w    d0,(a0)+
  1052.     move.w    ypos(a5),d0
  1053.     add.w    #24,d0
  1054.     move.w    d0,(a0)+
  1055.     move.w    #16,(a0)+
  1056.     bra    test.canon
  1057.  
  1058. initcanon
  1059.     bset    d7,activecanons(a5)
  1060.     lea    canondata(a5),a0
  1061.     lsl.w    #3,d7
  1062.     add.w    d7,a0
  1063.     move.w    xpos(a5),d0
  1064.     add.w    #53,d0
  1065.     move.w    d0,(a0)+
  1066.     move.w    ypos(a5),d0
  1067.     add.w    #30,d0
  1068.     move.w    d0,(a0)+
  1069.     move.w    #12,(a0)+
  1070.     move.w    #676,d0
  1071.     subq.w    #2,canon.energy(a5)
  1072.     move.w    canon.energy(a5),d1
  1073.     bsr    decrease.energy
  1074.  
  1075.     bra    test.lasers
  1076.  
  1077. initlaser
  1078.     bset    d7,activelasers(a5)
  1079.     lea    laserdata(a5),a0
  1080.     lsl.w    #3,d7
  1081.     add.w    d7,a0
  1082.     move.w    xpos(a5),d0
  1083.     add.w    #42,d0
  1084.     move.w    d0,(a0)+
  1085.     move.w    ypos(a5),d0
  1086.     add.w    #14,d0
  1087.     move.w    d0,(a0)+
  1088.     move.w    #32,(a0)+
  1089.     move.w    #1028,d0
  1090.     subq.w    #2,laser.energy(a5)
  1091.     move.w    laser.energy(a5),d1
  1092.     bsr    decrease.energy
  1093.     bra    test.mult1
  1094.  
  1095. decrease.energy
  1096.     move.l    #panel,a1            d0 = offset
  1097.     add.w    d0,a1                d1 = energy value (0-128)
  1098. ;                        324 for ship energy
  1099. ;                        676 for canons
  1100.     lsr.w    #4,d1                1028 for lasers
  1101.     lsl.w    #1,d1                a1 = plane1
  1102.     add.w    d1,a1                
  1103.     move.w    (a1),d1
  1104.     move.w    d1,d2
  1105.     and.w    #$5555,d1            get energy bits only
  1106.     and.w    #$aaaa,d2            preserve panel bits
  1107.     lsl.w    #2,d1                shift into next space
  1108.     or.w    d1,d2
  1109.     move.w    d2,(a1)                
  1110.     add.w    #44,a1
  1111.     move.w    (a1),d2
  1112.     and.w    #$aaaa,d2
  1113.     or.w    d1,d2                new energy into panel
  1114.     move.w    d2,(a1)                
  1115.     add.w    #44,a1
  1116.     move.w    (a1),d2
  1117.     and.w    #$aaaa,d2
  1118.     or.w    d1,d2
  1119.     move.w    d2,(a1)                
  1120.     rts
  1121.  
  1122. **************************************************************************
  1123.  
  1124. setup.mouse
  1125.     move.w    joy0dat(a6),d4        read the mouse x,y position so
  1126.     move.w    d4,-(sp)
  1127.     and.w    #$ff,d4            the ship doesnt jump when we
  1128.     move.w    d4,oldmousex(a5)    start
  1129.     move.w    (sp)+,d4
  1130.     lsr.w    #8,d4
  1131.     move.w    d4,oldmousey(a5)
  1132.     rts
  1133.  
  1134. joy    move.w    #$0100,d0        setup the mask for each bit in
  1135.     move.w    #$0001,d1        the joystick register
  1136.     move.w    #$0002,d2        the routine returns left/right
  1137.     move.w    #$0200,d3        /up/down in d0..d3
  1138.     move.w    joy1dat(a6),d4        if the corresponding data register
  1139.     and.w    d4,d0            is not = 0 then the joystick
  1140.     and.w    d4,d1            had been pressed in that direction
  1141.     and.w    d4,d2
  1142.     and.w    d4,d3
  1143.     lsl.w    #1,d0
  1144.     lsl.w    #1,d1
  1145.     eor.w    d2,d1
  1146.     eor.w    d3,d0
  1147.  
  1148.     move.w    joy0dat(a6),d4        read the mouse counters, if a move
  1149.     move.w    d4,-(sp)        has been detected then set the
  1150.     and.w    #$ff,d4            appropiate joystick registers
  1151.     sub.w    oldmousex(a5),d4    to mimick a joystick move
  1152.     beq    noxmove
  1153.     bmi    leftmove        this is not a proper proportional
  1154.     moveq    #1,d2            read but a simple up/dowm/left/right
  1155.     bra    noxmove            check
  1156. leftmove
  1157.     moveq    #1,d3
  1158. noxmove    move.w    (sp),d4
  1159.     lsr.w    #8,d4
  1160.     sub.w    oldmousey(a5),d4
  1161.     beq    joyend
  1162.     bmi    upmove
  1163.     moveq    #1,d1
  1164.     bra    joyend
  1165. upmove    moveq    #1,d0
  1166. joyend    move.w    (sp),d4
  1167.     and.w    #$ff,d4
  1168.     move.w    d4,oldmousex(a5)    save the mouse values for comparison
  1169.     move.w    (sp)+,d4        next time around
  1170.     lsr.w    #8,d4
  1171.     move.w    d4,oldmousey(a5)
  1172.     rts
  1173.  
  1174. **************************************************************************
  1175.  
  1176. ship.to.copper
  1177.     move.l    shipaddress(a5),a1    get the current ship address
  1178.     add.w    up.down(a5),a1        and update the four sprite
  1179.     move.l    a1,d0            pointers in the copperlist
  1180.     move.l    a1,d1            
  1181.     move.l    a1,d2
  1182.     move.l    a1,d3    
  1183.     add.w    #184,d1            work out the address of each        
  1184.     add.w    #184*2,d2        hardware sprite
  1185.     add.w    #184*2+96,d3
  1186.     lea    sprite(pc),a0
  1187.     move.w    d0,6(a0)
  1188.     swap    d0
  1189.     move.w    d0,2(a0)
  1190.     move.w    d1,14(a0)
  1191.     swap    d1
  1192.     move.w    d1,10(a0)
  1193.     move.w    d2,22(a0)
  1194.     swap    d2
  1195.     move.w    d2,18(a0)
  1196.     move.w    d3,30(a0)
  1197.     swap    d3
  1198.     move.w    d3,26(a0)
  1199.     rts
  1200.  
  1201. **************************************************************************
  1202.  
  1203. change.ship
  1204.     clr.w    d0
  1205.     move.b    ship.status(a5),d0    1 = canons, 2 = lasers, 3 = both
  1206.     lea    ship1.2(pc),a0
  1207.     mulu    #1680,d0        968 bytes for the four sprites
  1208.     add.l    d0,a0            per ship
  1209.     move.l    a0,shipaddress(a5)    store the ship address
  1210.     rts
  1211.  
  1212. **************************************************************************
  1213.  
  1214. restorebgnds
  1215.     bsr    getscreeninfo
  1216.     clr.w    bltamod(a6)
  1217.     move.l    d0,bltapt(a6)        set blitter A channel to the saved
  1218.     clr.w    bltcon1(a6)        background data
  1219. restoreloop
  1220.     move.w    (a0)+,d1        fetch the blit size
  1221.     beq    return            once zero all have been replaced
  1222.     move.w    d1,d3
  1223.     addq    #2,a0
  1224.     and.w    #$3f,d1            work out the length in bytes
  1225.     lsl.w    #1,d1
  1226.     move.w    #100,d2            subtract from the screen width
  1227.     sub.w    d1,d2            to give the destination modulo
  1228.     move.w    d2,bltdmod(a6)
  1229.     move.w    #$09f0,bltcon0(a6)    use D = A for the blit
  1230.     move.l    (a0)+,bltdpt(a6)    and do all three planes.
  1231.     move.w    d3,bltsize(a6)
  1232.     move.l    (a0)+,bltdpt(a6)
  1233.     move.w    d3,bltsize(a6)
  1234.     move.l    (a0)+,bltdpt(a6)
  1235.     move.w    d3,bltsize(a6)
  1236.     bra    restoreloop
  1237.  
  1238. savebgnds
  1239.     bsr    check.end.screen    watch out for screen wraparound
  1240.     bsr    coords.to.pf1offsets    convert pixel coords to byte offsets
  1241.     move.w    #aliensize,d3
  1242.     move.w    #94,bltamod(a6)
  1243.     clr.w    bltdmod(a6)
  1244.     clr.w    bltcon1(a6)
  1245.     move.w    #$09f0,bltcon0(a6)    use D = A for the blit
  1246.     bsr    setup.addresses        save the blitsize and addresses
  1247.     bsr    blit.to.buffer        and save the background data
  1248.     rts
  1249.  
  1250. **************************************************************************
  1251.  
  1252. drawbobs
  1253.     move.w    #94,bltdmod(a6)        set up the destination modulos
  1254.     move.w    #94,bltcmod(a6)
  1255.     clr.l    d6            d6 will hold an offset if the
  1256.     tst.b    upsidedown(a5)        bob is drawn upside down
  1257.     beq    normal
  1258.     move.w    #-106,bltdmod(a6)    draw from the bottom up by using
  1259.     move.w    #-106,bltcmod(a6)    a negative modulo
  1260.     move.l    #23*100,d6
  1261. normal    move.w    (a0),d3            get the blitsize in d3
  1262.     move.w    2(a0),d1        the scroll value in d1 (0-15)
  1263.     ror.w    #4,d1
  1264.     move.w    d1,bltcon1(a6)        set up the B scroll value
  1265.     or.w    #$0fca,d1        set up the A scroll value and the
  1266.     move.w    d1,bltcon0(a6)        minterm for D = notA.C + B
  1267.     move.w    #-2,bltbmod(a6)
  1268.     move.w    #-2,bltamod(a6)
  1269.     move.l    a1,bltbpt(a6)
  1270.     bsr    blit.to.backgnd        draw to the screen
  1271.     rts
  1272.  
  1273. **************************************************************************
  1274.  
  1275. getscreeninfo
  1276. *    returns the address in a0 of the data listing the screeen locations
  1277. *    where the backgrounds have to be replaced
  1278. *    d0 points to the buffer containing the saved backgrounds
  1279.  
  1280.     tst.b    screen.num(a5)        double buffering means we have 
  1281.     bne    getscreen1        to have two lists running
  1282.     move.l    #buffer0,d0
  1283.     move.l    #screen0bgnds,a0
  1284.     rts
  1285. getscreen1
  1286.     move.l    #buffer1,d0
  1287.     move.l    #screen1bgnds,a0
  1288.     rts
  1289.  
  1290. **************************************************************************
  1291.  
  1292. process.aliens
  1293.     clr.w    all.coords(a5)
  1294.     move.l    #path.buffer,a0
  1295.     lea    alien.buffer(a5),a1        where to store the info
  1296.     moveq    #11,d7                12 aliens max
  1297. process.loop
  1298.     move.w    table.offset(a0),d0        get offset in d0
  1299.     move.b    mode(a0),d6            d6 contains the mode byte
  1300.     move.w    x.pos(a0),d1
  1301.     beq    finished            alien dead
  1302.     clr.w    last.x(a5)
  1303.     clr.w    last.y(a5)
  1304.     move.w    y.pos(a0),d2
  1305.     subq.b    #1,anim.delay(a0)
  1306.     bne    same.anim
  1307.  
  1308.     move.b    num.anims(a0),d3
  1309.     beq    same.anim
  1310.     btst    #3,d6
  1311.     beq    up.only
  1312.     btst    #4,d6
  1313.     bne    down.anim
  1314.     addq.b    #1,anim.num(a0)            increase anim num
  1315.     cmp.b    anim.num(a0),d3
  1316.     bne    process1
  1317.     bchg    #4,d6
  1318.     bra    process1
  1319. down.anim
  1320.     subq.b    #1,anim.num(a0)
  1321.     bpl    process1
  1322.     move.b    #1,anim.num(a0)
  1323.     bchg    #4,d6
  1324.     bra    process1
  1325. up.only
  1326.     addq.b    #1,anim.num(a0)            next animation
  1327.     addq.b    #1,d3
  1328.     cmp.b    anim.num(a0),d3            wrap around anims
  1329.     bne    process1
  1330.     clr.b    anim.num(a0)
  1331.     tst.b    sprite.num(a0)            was it an explosion
  1332.     bne    process1
  1333.     clr.w    x.pos(a0)            yes so
  1334.     move.w    d1,last.x(a5)            store its coords
  1335.     move.w    d2,last.y(a5)
  1336.     clr.w    d1                kill this alien
  1337.     bra    finished
  1338. process1
  1339.     move.b    anim.delay2(a0),anim.delay(a0)    restore the delay
  1340. same.anim
  1341.     tst.b    sprite.num(a0)        
  1342.     beq    finished            dont move explosions
  1343.     tst.b    pause.count(a0)
  1344.     beq    no.pause            no pause 
  1345.     cmp.b    #$ff,pause.count(a0)
  1346.     beq    finished            ff means pause forever...
  1347.     subq.b    #1,pause.count(a0)
  1348.     beq    update                if zero update the offset
  1349.     bra    finished            not zero so do nufink
  1350. no.pause
  1351.     clr.w    d3
  1352.     clr.w    d4
  1353.     clr.w    d5
  1354.     move.b    speed(a0),d5            speed in d5
  1355.     move.b    0(a0,d0.w),d3            d3 is the x coord to go to
  1356.     move.b    1(a0,d0.w),d4            d4 is the y coord to go to
  1357.     bsr    check.seek            check all seek bits
  1358.     tst.b    sprite.num(a0)
  1359.     beq    store.coords            a heat seeker may have exploded
  1360.     btst    #0,d6                test for offset mode
  1361.     bne    add.offsets
  1362.     tst.w    d3                if x goto is minus then
  1363.     bmi    check.y                leave x coord alone
  1364.     lsl.w    #1,d3                even coord only
  1365.     cmp.w    d3,d1                check difference between the 
  1366.     sne    x.equal(a5)            two x coords
  1367.     beq    check.y
  1368.     blt    increase.x            if d1<d3 then increase x
  1369.     sub.w    d5,d1                else decrease it
  1370.     cmp.w    d3,d1                has it now passed
  1371.     bgt    check.y                the x coord
  1372.     move.w    d3,d1                if so, make it equal to the x
  1373.     sf    x.equal(a5)
  1374.     bra    check.y
  1375. increase.x
  1376.     add.w    d5,d1
  1377.     cmp.w    d3,d1
  1378.     blt    check.y                is it still less than x
  1379.     move.w    d3,d1
  1380.     sf    x.equal(a5)
  1381. check.y    tst.w    d4
  1382.     bmi    store.coords            check wether to leave y alone
  1383.     lsl.w    #1,d4                
  1384.     cmp.w    d4,d2                compares d2 to d4
  1385.     sne    y.equal(a5)
  1386.     beq    store.coords
  1387.     blt    increase.y            if d2<d4 then increase y
  1388.     sub.w    d5,d2
  1389.     cmp.w    d4,d2
  1390.     bgt    store.coords
  1391.     move.w    d4,d2
  1392.     sf    y.equal(a5)
  1393.     bra    store.coords
  1394. increase.y
  1395.     add.w    d5,d2
  1396.     cmp.w    d4,d2
  1397.     blt    store.coords
  1398.     move.w    d4,d2
  1399.     sf    y.equal(a5)
  1400.     bra    store.coords
  1401.  
  1402. add.offsets
  1403.     ext.w    d3
  1404.     ext.w    d4
  1405.     add.w    d3,d1                add the offsets
  1406.     add.w    d4,d2
  1407.     clr.b    x.equal(a5)            signal to update table
  1408.     clr.b    y.equal(a5)
  1409.  
  1410. store.coords
  1411.     move.w    d1,x.pos(a0)            restore the new coords
  1412.     move.w    d2,y.pos(a0)
  1413.     move.b    x.equal(a5),d3
  1414.     or.b    d3,y.equal(a5)            is the alien there
  1415.     bne    finished            no, so dont update the table
  1416.     btst    #5,d6                heat seeker ?
  1417.     beq    update
  1418.     bsr    explode.alien            heat seekers explode when they
  1419.     bra    finished            hit their target
  1420. update
  1421.     btst    #1,d6                check for seek mode
  1422.     beq    new.offset
  1423.     bsr    copy.coords
  1424.     subq.b    #1,seek.count(a0)
  1425.     bne    finished
  1426.     bclr    #1,d6                reset seek mode
  1427. new.offset
  1428.     addq.w    #2,d0
  1429.     move.w    d0,table.offset(a0)        new offset
  1430.     tst.w    0(a0,d0.w)
  1431.     beq    path.finished            path finished, so branch
  1432.     move.b    0(a0,d0.w),d4            get code in d4 & d3
  1433.     move.w    d4,d3
  1434.     and.w    #$f0,d4                get upper 4 bits
  1435.     cmp.w    #$e0,d4                hex E for a code
  1436.     bne    finished            no code so carry on
  1437.     and.w    #$f,d3                otherwise get code number in d3
  1438.     lsl.w    #2,d3                x4
  1439.     lea    vector.table(pc),a2        get table base
  1440.     move.l    0(a2,d3.w),a2            get routine address in a2
  1441.     jmp    (a2)                and jump to it
  1442.  
  1443. vector.table
  1444.     dc.l    init.pause
  1445.     dc.l    loop.back
  1446.     dc.l    toggle.offset
  1447.     dc.l    change.speed
  1448.     dc.l    change.sprite
  1449.     dc.l    seek.mode
  1450.     dc.l    reload.coords
  1451.     dc.l    new.table
  1452.     dc.l    restore.offset
  1453.     dc.l    fire.heatseeker
  1454.     dc.l    change.anim
  1455.     dc.l    restart.table
  1456.     dc.l    start.xy
  1457.     dc.l    start.seekx
  1458.     dc.l    start.seeky
  1459.     dc.l    return                16 codes maximum
  1460.  
  1461. finished                    
  1462.     or.w    d1,all.coords(a5)
  1463.     move.w    d1,(a1)+            
  1464.     move.w    d2,(a1)+            store it all in the 
  1465.     move.b    sprite.num(a0),(a1)+        buffer
  1466.     move.b    anim.num(a0),(a1)+
  1467.     move.b    d6,mode(a0)            save the mode byte
  1468.     add.w    next.path(a0),a0
  1469.     dbf    d7,process.loop
  1470.     rts
  1471.  
  1472. path.finished
  1473.     clr.w    d1                make x = 0
  1474.     clr.w    x.pos(a0)
  1475.     btst    #2,d6
  1476.     seq     no.bonus(a5)
  1477.     bra    finished
  1478.  
  1479. check.seek
  1480.     btst    #6,d6                bit 6 for seek on ship x
  1481.     beq    check.seeky
  1482.     st    y.equal(a5)            make sure it never updates table
  1483.     move.w    xpos(a5),d3            get new x coord to goto
  1484.     moveq    #-1,d4                signal to leave y alone
  1485.     add.w    #54,d3                hardware sprite offset
  1486.     lsr.w    #1,d3                even coords only
  1487.     subq.b    #1,seek.count(a0)        check count
  1488.     bne    check.seeky
  1489.     bclr    #6,d6                reset if count zero
  1490. check.seeky
  1491.     btst    #7,d6                bit 7 for seek on ship y
  1492.     beq    check.heat
  1493.     st    x.equal(a5)            make sure it never updates table
  1494.     move.w    ypos(a5),d4            get new y coord to goto
  1495.     moveq    #-1,d3                signal to leave x alone
  1496.     add.w    #14,d4                hardware sprite offset
  1497.     lsr.w    #1,d4                even coords only
  1498.     subq.b    #1,seek.count(a0)        check count
  1499.     bne    check.heat
  1500.     bclr    #7,d6                reset if count zero
  1501. check.heat
  1502.     btst    #5,d6                bit 5 for a heat seeking mine
  1503.     beq    return                all finished
  1504.     move.w    xpos(a5),d3            get new x coord to goto
  1505.     move.w    ypos(a5),d4            get new y coord to goto
  1506.     add.w    #56,d3                hardware sprite offset
  1507.     add.w    #16,d4                hardware sprite offset
  1508.     lsr.w    #1,d3                even coords only
  1509.     lsr.w    #1,d4                even coords only
  1510.     subq.b    #1,seek.count(a0)        check count
  1511.     bne    return
  1512.     bsr    explode.alien            kill mine if count zero
  1513.     rts
  1514.  
  1515. init.pause
  1516.     move.b    1(a0,d0.w),pause.count(a0)    setup the pause
  1517.     bra    finished
  1518.  
  1519. loop.back
  1520.     clr.w    d3
  1521.     move.b    loop.offset(a0),d3        get the loop offset in words
  1522.     lsl.w    #1,d3                convert to bytes
  1523.     subq.b    #1,loop.count(a0)        reduce the loop counter
  1524.     beq    update
  1525.     sub.w    d3,table.offset(a0)        and work out the new path PC
  1526.     bra    finished
  1527.  
  1528. toggle.offset
  1529.     bchg    #0,d6                start or end offset mode
  1530.     bra    update                get the next path value
  1531.                 
  1532. seek.mode
  1533.     bset    #1,d6                set the seek mode bit
  1534.     move.b    1(a0,d0.w),seek.count(a0)    copy the count
  1535.     addq.w    #2,d0
  1536.     move.w    d0,table.offset(a0)
  1537.     bsr    copy.coords
  1538.     bra    finished
  1539.  
  1540. start.seekx
  1541.     bset    #6,d6                set the seek on X bit
  1542.     move.b    1(a0,d0.w),seek.count(a0)    copy the count
  1543.     addq.w    #2,d0
  1544.     move.w    d0,table.offset(a0)
  1545.     bra    finished
  1546.  
  1547. start.seeky
  1548.     bset    #7,d6                set the seek on Y bit
  1549.     move.b    1(a0,d0.w),seek.count(a0)    copy the count
  1550.     addq.w    #2,d0
  1551.     move.w    d0,table.offset(a0)
  1552.     bra    finished
  1553.  
  1554. copy.coords
  1555.     move.w    xpos(a5),d3            copy the ship coords
  1556.     move.w    ypos(a5),d4            for the seek functions
  1557.     add.w    #54,d3                into the path table
  1558.     add.w    #14,d4
  1559.     lsr.w    #1,d3
  1560.     lsr.w    #1,d4
  1561.     move.b    d3,0(a0,d0.w)
  1562.     move.b    d4,1(a0,d0.w)
  1563.     rts
  1564.  
  1565. change.speed
  1566.     move.b    1(a0,d0.w),speed(a0)        copy the new speed byte
  1567.     bra    update
  1568.  
  1569. change.sprite
  1570.     addq.w    #2,d0
  1571.     move.b    0(a0,d0.w),sprite.num(a0)    new sprite number
  1572.     move.b    1(a0,d0.w),num.anims(a0)    new max anims
  1573.     clr.b    anim.num(a0)            
  1574.     move.b    anim.delay2(a0),anim.delay(a0)    new anim delay
  1575.     bra    update
  1576.  
  1577. reload.coords
  1578.     addq    #2,d0
  1579.     clr.w    d1                copy a new x,y position
  1580.     clr.w    d2                into the sprite structure
  1581.     move.b    0(a0,d0.w),d1    
  1582.     move.b    1(a0,d0.w),d2
  1583.     lsl.w    #1,d1
  1584.     lsl.w    #1,d2
  1585.     move.w    d1,x.pos(a0)
  1586.     move.w    d2,y.pos(a0)
  1587.     bra    update    
  1588.  
  1589. new.table
  1590.     addq.w    #2,d0                setup a new path PC
  1591.     move.w    d0,d4                saving the old one in the
  1592.     move.b    d4,loop.offset+1(a0)        loop.offset word
  1593.     lsr.w    #8,d4
  1594.     move.b    d4,loop.offset(a0)
  1595.     move.w    0(a0,d0.w),d0
  1596.     subq.w    #2,d0
  1597.     bra    new.offset
  1598.  
  1599. restore.offset
  1600.     move.b    loop.offset(a0),d0        restore the old path PC
  1601.     lsl.w    #8,d0
  1602.     move.b    loop.offset+1(a0),d0
  1603.     bra    new.offset
  1604.  
  1605. fire.heatseeker
  1606.     move.l    #path.buffer,a2            start a new path at the
  1607.     moveq    #11,d5                present paths x,y coord
  1608.     addq    #2,d0
  1609. heat1    btst    #5,mode(a2)            only if a free path entry
  1610.     beq    heat2                can be found
  1611.     tst.w    x.pos(a2)
  1612.     bne    heat2
  1613.     move.w    d1,x.pos(a2)
  1614.     move.w    d2,y.pos(a2)
  1615.     move.b    0(a0,d0.w),seek.count(a2)
  1616.     move.b    1(a0,d0.w),hits.num(a2)
  1617.     move.b    #2,sprite.num(a2)
  1618.     move.b    #2,anim.delay(a2)
  1619.     clr.b    anim.num(a2)
  1620.     move.b    #3,num.anims(a2)
  1621.     bra    new.offset
  1622. heat2    add.w    (a2),a2
  1623.     dbf    d5,heat1
  1624.     bra    new.offset
  1625.  
  1626. change.anim
  1627.     move.b    1(a0,d0.w),anim.num(a0)        new animation number
  1628.     bra    new.offset
  1629.  
  1630. restart.table
  1631.     move.w    #table.size-2,d0        restart the path from the
  1632.     bra    update                beginning
  1633.  
  1634. start.xy
  1635.     move.b    1(a0,d0.w),d4            get path number to start
  1636.     subq.b    #2,d4                cant use path 0
  1637.     move.l    a0,-(sp)            save path pointer
  1638.     move.l    #path.buffer,a0
  1639. find.num
  1640.     add.w    next.path(a0),a0
  1641.     dbf    d4,find.num            get the path
  1642.     move.w    d1,x.pos(a0)            new one starts at present x & y
  1643.     move.w    d2,y.pos(a0)
  1644.     move.w    d1,d4
  1645.     lsr.w    #1,d4
  1646.     move.b    d4,table.size(a0)        set up the first xy coord to
  1647.     move.w    d2,d4                goto. Must be the same as
  1648.     lsr.w    #1,d4                the present xy
  1649.     move.b    d4,table.size+1(a0)
  1650.     move.w    #table.size,table.offset(a0)    start of path
  1651.     move.b    #128,hits.num(a0)        indistrutable
  1652.     move.b    #2,anim.delay(a0)
  1653.     clr.b    pause.count(a0)
  1654.     clr.b    anim.num(a0)            reset anim info
  1655.     move.l    (sp)+,a0
  1656.     bra    new.offset
  1657.  
  1658. **************************************************************************
  1659.  
  1660. save.aliens
  1661.     lea    alien.buffer+66(a5),a4        the buffer contains
  1662.     moveq    #11,d7                word x-cord
  1663.     bsr    getscreeninfo            word y-cord
  1664. save.alien1                    
  1665.     move.w    (a4),d1                byte sprite number
  1666.     beq    save.next            byte animation number
  1667.     move.w    2(a4),d2
  1668.     bsr    savebgnds
  1669. save.next
  1670.     subq    #6,a4
  1671.     dbf    d7,save.alien1
  1672.     rts
  1673.  
  1674. **************************************************************************
  1675.  
  1676. draw.aliens
  1677.     clr.w    bltalwm(a6)
  1678.     moveq    #11,d7
  1679.     bsr    getscreeninfo
  1680.     lea    alien.buffer+66(a5),a4        work DOWN through
  1681. draw.alien2
  1682.     tst.w    (a4)                the buffer so that the first
  1683.     beq    draw.next2            sprite is drawn first and
  1684.     clr.w    d1                therefore hit first.
  1685.     clr.w    d2
  1686.     move.b    4(a4),d1            d1 = sprite number
  1687.     bclr    #7,d1
  1688.     sne    upsidedown(a5)
  1689.     move.b    5(a4),d2            d2 = animation number
  1690.     move.l    #alien.pointers,a1
  1691.     move.w    level.number(a5),d3
  1692.     mulu    #24*4,d3
  1693.     ext.l    d3
  1694.     add.l    d3,a1
  1695.     lsl.w    #2,d1
  1696.     add.w    d1,a1
  1697.     move.l    (a1),a1                get the sprite pointer in a1
  1698.     mulu    #384,d2                from the lookup table
  1699.     ext.l    d2                and then work out the animation
  1700.     add.l    d2,a1                number address
  1701.     move.l    a1,a2
  1702.     add.w    #288,a2                a2 = mask address
  1703.     bsr    drawbobs
  1704. draw.next2
  1705.     subq    #6,a4
  1706.     dbf    d7,draw.alien2
  1707.     move.w    #$ffff,bltalwm(a6)
  1708.     rts    
  1709.     
  1710. **************************************************************************
  1711.  
  1712. blit.to.backgnd
  1713.     addq    #4,a0            skip the hidden words
  1714.     move.l    (a0)+,d5        get the screen offset
  1715.     add.l    d6,d5
  1716.     move.l    d5,bltcpt(a6)        setup the screen pointers
  1717.     move.l    d5,bltdpt(a6)
  1718.     move.l    a2,bltapt(a6)        setup the bob mask
  1719.     move.w    d3,bltsize(a6)        and blit the bob to the screen
  1720.     move.l    (a0)+,d5
  1721.     add.l    d6,d5
  1722.     move.l    d5,bltcpt(a6)
  1723.     move.l    d5,bltdpt(a6)
  1724.     move.l    a2,bltapt(a6)
  1725.     move.w    d3,bltsize(a6)        plane 2
  1726.     move.l    (a0)+,d5
  1727.     add.l    d6,d5
  1728.     move.l    d5,bltcpt(a6)
  1729.     move.l    d5,bltdpt(a6)
  1730.     move.l    a2,bltapt(a6)
  1731.     move.w    d3,bltsize(a6)        plane 3
  1732.     rts
  1733.  
  1734. **************************************************************************
  1735.  
  1736. blit.to.buffer
  1737.     tst.l    d6            copy the background where a 
  1738.     beq    no.blit            bob  is to be drawn into
  1739.     move.l    d0,bltdpt(a6)        the buffer
  1740.     addq    #4,a0
  1741.     move.l    (a0)+,bltapt(a6)
  1742.     move.w    d3,bltsize(a6)
  1743.     move.l    (a0)+,bltapt(a6)
  1744.     move.w    d3,bltsize(a6)
  1745.     addq    #4,a0
  1746. no.blit    clr.w    (a0)
  1747.     add.l    #3*6*24,d0
  1748.     rts
  1749.  
  1750. **************************************************************************
  1751.  
  1752. coords.to.pf1offsets    
  1753. *    convert the x,y coordinate in d1,d2 into a byte offset
  1754. *    in d1 and a scroll offset (0-15) in d2
  1755.             
  1756.     add.w    #16,d1
  1757.     sub.w    pf1scroll2(a5),d1        d2 = y coord
  1758.     mulu    #100,d2                d1 = x coord
  1759.     swap    d2
  1760.     move.w    d1,d2
  1761.     and.w    #$f,d2
  1762.     swap    d2
  1763.     lsr.w    #3,d1
  1764.     add.w    d2,d1
  1765.     swap    d2                d2 = scroll value
  1766.     ext.l    d1                d1 = offset
  1767.     rts
  1768.  
  1769. **************************************************************************
  1770.  
  1771. coords.to.pf2offsets
  1772. *    As the above routine but for the front playfield which is only
  1773. *    92 bytes wide
  1774.  
  1775.     sub.w    pf2scroll(a5),d1
  1776.     mulu    #92,d2
  1777.     swap    d2
  1778.     move.w    d1,d2
  1779.     and.w    #$f,d2
  1780.     swap    d2
  1781.     lsr.w    #3,d1
  1782.     add.w    d2,d1
  1783.     swap    d2
  1784.     ror.w    #4,d2
  1785.     add.w    pf2offset(a5),d1
  1786.     ext.l    d1
  1787.     rts
  1788.  
  1789. **************************************************************************
  1790.  
  1791. setup.addresses
  1792. *    setup the list of addresses to which bobs are to be blitted
  1793.  
  1794.     move.w    d3,(a0)                d3 = blitsize
  1795.     move.w    d2,2(a0)            d2 = scroll value
  1796.     move.l    (a2),d6                d1 = offset
  1797.     add.l    d1,d6                stores the addresses
  1798.     cmp.l    4(a0),d6
  1799.     beq    dont.save
  1800.     move.l    d6,4(a0)            without updating the
  1801.     move.l    4(a2),d6            pointer
  1802.     add.l    d1,d6
  1803.     move.l    d6,8(a0)
  1804.     move.l    8(a2),d6
  1805.     add.l    d1,d6
  1806.     move.l    d6,12(a0)
  1807.     rts
  1808. dont.save
  1809.     clr.l    d6
  1810.     add.w    #16,a0
  1811.     rts
  1812.  
  1813. **************************************************************************
  1814.  
  1815. check.end.screen
  1816.     tst.w    screenend(a5)
  1817.     bne    notend
  1818.     lea    rasters(a5),a2
  1819.     move.w    #16,pf1scroll2(a5)
  1820.     rts
  1821. notend    lea    displayraster(a5),a2
  1822.     move.w    pf1scroll(a5),pf1scroll2(a5)
  1823.     rts
  1824.  
  1825. **************************************************************************
  1826.  
  1827. check.path
  1828.     cmp.b    #1,last.path(a5)
  1829.     beq    decrement.counter
  1830.     tst.w    all.coords(a5)        wait until all the x coords are 0 
  1831.     bne    check.end        before a new path can start
  1832.     not.b    bonus.delay(a5)
  1833.     bne    check.end        a small delay before the bonus
  1834.     tst.b    last.path(a5)        path can start
  1835.     bne    start.path
  1836.     clr.b    bonus.mode(a5)
  1837.     move.w    last.x(a5),d1
  1838.     beq    start.path        if all the aliens had been killed
  1839.     tst.b    no.bonus(a5)        then we will start the bonus path
  1840.     bne    start.path
  1841.     move.w    #10,path.delay(a5)
  1842.     move.w    last.y(a5),d2
  1843.     move.l    paths,a0
  1844.     st    bonus.mode(a5)
  1845.     clr.w    bonus.num(a5)
  1846.     move.w    #5,bonus.count(a5)    setup the bonus path coordinates
  1847.     move.w    d1,x.pos+2(a0)
  1848.     move.w    d2,y.pos+2(a0)
  1849.     clr.b    anim.num+2(a0)
  1850.     lsr.w    #1,d2
  1851.     move.w    #$0200,d1
  1852.     or.w    d2,d1
  1853.     move.w    d1,table.size+2(a0)
  1854.     bra    copy.path    
  1855. check.end
  1856.     rts
  1857.  
  1858. start.path
  1859.     cmp.w    #1,level.end(a5)    start a new path, providing
  1860.     beq    return            the guardian is not scrolling on
  1861.     cmp.w    #2,level.end(a5)
  1862.     beq    return
  1863.     cmp.w    #3,level.end(a5)
  1864.     beq    check.all
  1865.     subq.w    #1,path.delay(a5)
  1866.     beq    start.path1
  1867.     rts
  1868. start.path1
  1869.     move.w    #10,path.delay(a5)    start a normal path
  1870.     move.w    path.number(a5),d0
  1871.     lea    paths,a0
  1872.     add.w    d0,a0
  1873.     move.l    (a0),d1
  1874.     bne    start1
  1875.     moveq    #4,d0
  1876.     lea    paths,a0
  1877.     move.l    4(a0),d1
  1878. start1
  1879.     addq    #4,d0
  1880.     move.w    d0,path.number(a5)
  1881.     move.l    d1,a0
  1882. copy.path
  1883.     clr.w    d0            copy the new path data
  1884.     lea    colours(pc),a2        and set up the new alien colours
  1885.     move.b    sprite.num+2(a0),d0        get sprite num
  1886.     and.b    #$7f,d0
  1887.     subq.w    #1,d0
  1888.     lea    alien.colours(pc),a1        get colour table
  1889.     move.w    level.number(a5),d3
  1890.     mulu    #384,d3    
  1891.     add.w    d3,a1
  1892.     lsl.w    #4,d0                16 bytes per alien
  1893.     add.w    d0,a1
  1894.     move.w    (a1)+,2(a2)            copy 8 colours
  1895.     move.w    (a1)+,6(a2)            
  1896.     move.w    (a1)+,10(a2)            
  1897.     move.w    (a1)+,14(a2)            
  1898.     move.w    (a1)+,18(a2)            
  1899.     move.w    (a1)+,22(a2)
  1900.     move.w    (a1)+,26(a2)
  1901.     move.w    (a1)+,30(a2)
  1902.     move.w    (a0)+,d0
  1903.     move.l    #path.buffer,a1
  1904.     lsr.w    #2,d0
  1905. copyloop
  1906.     move.l    (a0)+,(a1)+
  1907.     dbf    d0,copyloop
  1908.     clr.b    no.bonus(a5)
  1909.     rts
  1910.  
  1911. **************************************************************************
  1912.  
  1913. update.missiles
  1914.     tst.w    fire.delay(a5)
  1915.     beq    .skip
  1916.     subq.w    #1,fire.delay(a5)
  1917.  
  1918. .skip    move.l    #missiletable,a0        used for erasing 
  1919.     move.w    level.number(a5),d0
  1920.     mulu    #72,d0                72 bytes per missile graphics
  1921.     lea    missiles1(pc),a1        base address
  1922.     add.w    d0,a1                level missiles
  1923.     add.w    #32,a1                cannon offset
  1924.     add.w    guard.offset(a5),a1        different for guardian
  1925.     lea    missilemask+32(pc),a3
  1926.     lea    rasters(a5),a2
  1927.     lea    canondata+24(a5),a4
  1928.     move.l    #fgnd.buffer,d6
  1929.     move.w    #%101000010,d3            size for canon
  1930.     moveq    #3,d7
  1931. update1    btst    d7,activecanons(a5)        check canons first
  1932.     beq    update2
  1933.     move.w    (a4),d1                x coordinate in d1
  1934.     move.w    2(a4),d2            y coordinate in d2
  1935.     subq.w    #1,4(a4)            check range
  1936.     beq    killcanon            it's dead
  1937.     addq.w    #8,d1                move 8 pixels
  1938.     cmp.w    #360,d1
  1939.     bcc    killcanon            is it offscreen
  1940.     move.w    d1,(a4)                restore it
  1941.     bsr    draw.missile            and draw it
  1942.     bne    update2                
  1943.     move.w    (a4),d1
  1944.     move.w    2(a4),d2
  1945.     add.w    #12,d1                canon tip
  1946.     addq.w    #4,d2                middle of canon
  1947.     bsr    kill.alien
  1948.     beq    update2                zero, so it was'nt an alien
  1949.     bclr    d7,activecanons(a5)        canon hit alien, so kill it
  1950. update2    subq    #8,a4                work down thru buffer
  1951.     dbf    d7,update1            check for 4
  1952.  
  1953.     move.w    level.number(a5),d0
  1954.     mulu    #72,d0                72 bytes per missile graphics
  1955.     lea    missiles1(pc),a1        base address
  1956.     add.w    d0,a1                level missiles
  1957.     add.w    #16,a1                missile offset
  1958.     add.w    guard.offset(a5),a1        different for guardian
  1959.     lea    missilemask+16(pc),a3
  1960.     lea    missiledata+24(a5),a4
  1961.     move.w    #%10000010,d3            size for missiles
  1962.     moveq    #3,d7
  1963. update3    btst    d7,activemissiles(a5)
  1964.     beq    update4
  1965.     move.w    (a4),d1                x coordinate in d1
  1966.     move.w    2(a4),d2            y coordinate in d2
  1967.     subq.w    #1,4(a4)            check range
  1968.     beq    killmissile            it's dead
  1969.     add.w    #10,d1                move 10 pixels
  1970.     cmp.w    #360,d1
  1971.     bcc    killmissile            is it offscreen
  1972.     move.w    d1,(a4)                restore it
  1973.     bsr    draw.missile            and draw it
  1974.     bne    update4                
  1975.     move.w    (a4),d1
  1976.     move.w    2(a4),d2
  1977.     addq.w    #8,d1                missile tip
  1978.     addq.w    #2,d2                middle of missile
  1979.     bsr    kill.alien
  1980.     beq    update4                zero, so it was'nt an alien
  1981.     bclr    d7,activemissiles(a5)        missile hit alien, so kill it
  1982. update4    subq    #8,a4                work down thru buffer
  1983.     dbf    d7,update3            check for 4
  1984.  
  1985.     move.w    level.number(a5),d0
  1986.     mulu    #72,d0                72 bytes per missile graphics
  1987.     lea    missiles1(pc),a1        base address
  1988.     add.w    d0,a1                level missiles
  1989.     add.w    guard.offset(a5),a1        different for guardian
  1990.     lea    missilemask(pc),a3
  1991.     lea    laserdata+24(a5),a4
  1992.     move.w    #%10000010,d3            size for lasers
  1993.     moveq    #3,d7
  1994. update5    btst    d7,activelasers(a5)
  1995.     beq    update6
  1996.     move.w    (a4),d1                x coordinate in d1
  1997.     move.w    2(a4),d2            y coordinate in d2
  1998.     subq.w    #1,4(a4)            check range
  1999.     beq    killlaser            it's dead
  2000.     add.w    #16,d1                move 16 pixels!
  2001.     cmp.w    #360,d1
  2002.     bcc    killlaser            is it offscreen
  2003.     move.w    d1,(a4)                restore it
  2004.     bsr    draw.missile            and draw it
  2005.     bne    update6                
  2006.     move.w    (a4),d1                dont kill lasers
  2007.     move.w    2(a4),d2
  2008.     add.w    #16,d1                laser tip
  2009.     bsr    kill.alien
  2010.     beq    update6
  2011.     move.b    bonus.mode(a5),d5
  2012.     or.b    last.path(a5),d5
  2013.     beq    update6                kill lasers when guardian on
  2014.     bclr    d7,activelasers(a5)
  2015. update6    subq    #8,a4                work down thru buffer
  2016.     dbf    d7,update5            check for 4
  2017.  
  2018.     lea    mult(pc),a1            finally check mults
  2019.     lea    multmask(pc),a3
  2020.     lea    mult1data+8(a5),a4
  2021.     move.w    #%11000010,d3            size for mults
  2022.     moveq    #1,d7
  2023. update7    btst    d7,activemult1(a5)
  2024.     beq    update8
  2025.     move.w    (a4),d1                x coordinate in d1
  2026.     move.w    2(a4),d2            y coordinate in d2
  2027.     subq.w    #1,6(a4)            check range
  2028.     beq    killmult1            it's dead
  2029.     move.b    4(a4),d4
  2030.     ext.w    d4
  2031.     add.w    d4,d1                
  2032.     cmp.w    #360,d1
  2033.     bge    killmult1            is it offscreen
  2034.     cmp.w    #16,d1
  2035.     blt    killmult1
  2036.     move.w    d1,(a4)                restore it
  2037.     move.b    5(a4),d4
  2038.     ext.w    d4
  2039.     add.w    d4,d2                
  2040.     cmp.w    #186,d2
  2041.     bge    killmult1            is it offscreen
  2042.     cmp.w    #9,d2
  2043.     blt    killmult1
  2044.     move.w    d2,2(a4)            restore it
  2045.     
  2046.     bsr    draw.missile            and draw it
  2047.     bne    update8                
  2048.     move.w    (a4),d1                
  2049.     move.w    2(a4),d2
  2050.     addq    #1,d1                mult middle
  2051.     addq    #1,d2
  2052.     bsr    kill.alien
  2053.     beq    update8
  2054.     bclr    d7,activemult1(a5)
  2055. update8    subq    #8,a4                work down thru buffer
  2056.     dbf    d7,update7            check for 4
  2057.  
  2058.     lea    mult2data+8(a5),a4
  2059.     moveq    #1,d7
  2060. update9    btst    d7,activemult2(a5)
  2061.     beq    update10
  2062.     move.w    (a4),d1                x coordinate in d1
  2063.     move.w    2(a4),d2            y coordinate in d2
  2064.     subq.w    #1,6(a4)            check range
  2065.     beq    killmult2            it's dead
  2066.     move.b    4(a4),d4
  2067.     ext.w    d4
  2068.     add.w    d4,d1                
  2069.     cmp.w    #360,d1
  2070.     bge    killmult2            is it offscreen
  2071.     cmp.w    #16,d1
  2072.     blt    killmult2
  2073.     move.w    d1,(a4)                restore it
  2074.     move.b    5(a4),d4
  2075.     ext.w    d4
  2076.     add.w    d4,d2                
  2077.     cmp.w    #184,d2
  2078.     bge    killmult2            is it offscreen
  2079.     cmp.w    #9,d2
  2080.     blt    killmult2
  2081.     move.w    d2,2(a4)            restore it
  2082.     
  2083.     bsr    draw.missile            and draw it
  2084.     bne    update10                
  2085.     move.w    (a4),d1                
  2086.     move.w    2(a4),d2
  2087.     addq    #1,d1                mult middle
  2088.     addq    #1,d2
  2089.     bsr    kill.alien
  2090.     beq    update10
  2091.     bclr    d7,activemult2(a5)
  2092. update10
  2093.     subq    #8,a4                work down thru buffer
  2094.     dbf    d7,update9            check for 4
  2095.     rts                    all finished.
  2096.  
  2097. killcanon
  2098.     bclr    d7,activecanons(a5)        kill a canon etc.
  2099.     bra    update2
  2100. killmissile
  2101.     bclr    d7,activemissiles(a5)
  2102.     bra    update4
  2103. killlaser
  2104.     bclr    d7,activelasers(a5)
  2105.     bra    update6    
  2106. killmult1
  2107.     bclr    d7,activemult1(a5)
  2108.     bra    update8    
  2109. killmult2
  2110.     bclr    d7,activemult2(a5)
  2111.     bra    update10
  2112.  
  2113. kill.alien
  2114.     move.l    a0,-(sp)
  2115.     tst.b    bonus.mode(a5)
  2116.     bne    hit.bonus
  2117.     move.l    #path.buffer,a0
  2118.     moveq    #11,d5
  2119. kill.alien.loop
  2120.     tst.b    sprite.num(a0)
  2121.     beq    try.next            dont check explosions
  2122.     move.w    x.pos(a0),d4
  2123.     beq    try.next            alien's dead
  2124.     sub.w    #16,d4
  2125.     cmp.w    d4,d1                is d1 > xpos
  2126.     blt    try.next
  2127.     add.w    #32,d4
  2128.     cmp.w    d4,d1                is d1 < xpos+32
  2129.     bgt    try.next
  2130.     move.w    y.pos(a0),d4
  2131.     cmp.w    d4,d2                is d2 > ypos
  2132.     blt    try.next
  2133.     add.w    #24,d4
  2134.     cmp.w    d4,d2                is d2 < ypos+24
  2135.     bgt    try.next
  2136.     btst    #7,hits.num(a0)
  2137.     bne    no.more                indistructable ?
  2138.     cmp.b    #3,sprite.num(a0)
  2139.     seq    hit.guardian(a5)
  2140.     subq.b    #1,hits.num(a0)            found an alien
  2141.     beq    check.which            not dead yet though!
  2142.     move.w    #$0106,d0            not dead sound!
  2143. ;    jsr    initfx
  2144.     bra    no.more
  2145. check.which
  2146.     cmp.b    #3,sprite.num(a0)
  2147.     bne    not.guardian
  2148.     move.b    #2,last.path(a5)
  2149. not.guardian
  2150.     bsr    explode.alien
  2151.     move.l    alien.score(a5),score.add(a5)    the score
  2152.     move.w    kills.what(a0),d0
  2153.     move.l    #path.buffer,a0
  2154.     moveq    #11,d5
  2155. kill.more
  2156.     lsr.w    #1,d0
  2157.     bcc    kill.next    
  2158.     bsr    explode.alien
  2159.     move.l    #$0750,score.add(a5)
  2160. kill.next
  2161.     tst.w    next.path(a0)
  2162.     beq    resetz
  2163.     add.w    next.path(a0),a0
  2164.     dbf    d5,kill.more
  2165. resetz
  2166.     and.b    #0,ccr                z reset = a hit                
  2167.     bra    no.more
  2168. try.next
  2169.     add.w    next.path(a0),a0
  2170.     dbf    d5,kill.alien.loop
  2171.     or.b    #4,ccr                z set = no hit
  2172. no.more
  2173.     move.l    (sp)+,a0
  2174.     rts
  2175.  
  2176. explode.alien
  2177.     clr.b    anim.num(a0)            start the explosion
  2178.     clr.b    sprite.num(a0)
  2179.     move.b    #7,num.anims(a0)
  2180.     move.b    #2,anim.delay(a0)
  2181.     move.b    #2,anim.delay2(a0)
  2182.     bclr    #3,mode(a0)            up animate only
  2183.     move.w    d0,-(sp)
  2184.     move.w    #$0101,d0
  2185. ;    jsr    initfx
  2186.     move.w    (sp)+,d0
  2187.     rts
  2188.  
  2189. hit.bonus
  2190.     movem.l    a1-a2/d0,-(sp)
  2191.     move.w    #$0113,d0
  2192. ;    jsr    initfx
  2193.     subq.w    #1,bonus.count(a5)
  2194.     bne    hit.end
  2195.     move.w    #5,bonus.count(a5)
  2196.     move.w    bonus.num(a5),d1
  2197.     cmp.w    #6,d1
  2198.     beq    hit1
  2199.     addq    #1,d1
  2200. hit1    move.w    d1,bonus.num(a5)
  2201.     move.l    #path.buffer,a0
  2202.     move.b    d1,anim.num(a0)
  2203. hit.end
  2204.     movem.l    (sp)+,a1-a2/d0
  2205.     move.l    (sp)+,a0
  2206.     rts    
  2207.  
  2208.  
  2209. draw.missile
  2210.     movem.w    d1-d2,-(sp)            save for later
  2211.     bsr    coords.to.pf2offsets        convert to ofsset
  2212.     bsr    or.foregnds            a1 = missile sprite
  2213.     move.l    d6,d5                a3 = mask
  2214.     move.w    d3,d0                d5 & d6 = foreground buffer
  2215.     lsr.w    #4,d0                height*4 = number of bytes in 
  2216.     add.w    d0,d6                a an or'd foreground
  2217.     clr.w    bltcmod(a6)
  2218.     clr.w    bltamod(a6)
  2219.     clr.w    bltdmod(a6)
  2220.     clr.w    bltbmod(a6)
  2221.     move.l    a1,bltapt(a6)            a = sprite
  2222.     move.l    a3,bltbpt(a6)            b = mask
  2223.     move.l    d6,bltdpt(a6)            dest = buffer+height*4
  2224.     move.w    d2,bltcon1(a6)            c = buffer
  2225.     or.w    #$0f40,d2            use D = A.B.notC
  2226.     move.w    d2,bltcon0(a6)            which shows only where missile
  2227.     move.l    d5,bltcpt(a6)            can be drawn
  2228.     move.w    d3,bltsize(a6)
  2229.     move.l    d5,bltcpt(a6)
  2230.     move.w    d3,bltsize(a6)
  2231.  
  2232.     move.w    #88,bltdmod(a6)
  2233.     move.w    #88,bltbmod(a6)
  2234.     clr.w    bltcon1(a6)
  2235.     move.w    #$0dfc,bltcon0(a6)        D = A or B
  2236.     move.l    d6,bltapt(a6)            the new buffer being the mask only
  2237.     move.l    (a0),bltbpt(a6)            drawing where there is no 
  2238.     move.l    (a0)+,bltdpt(a6)        foreground
  2239.     move.w    d3,bltsize(a6)
  2240.     move.l    (a0),bltbpt(a6)
  2241.     move.l    (a0)+,bltdpt(a6)
  2242.     move.w    d3,bltsize(a6)
  2243.     clr.w    (a0)
  2244.  
  2245.     movem.w    (sp)+,d1-d2
  2246.     add.w    #16,d1
  2247.     move.w    pf1scroll(a5),pf1scroll2(a5)    copy scroll
  2248.     bsr    coords.to.pf1offsets        get pf1 offset
  2249.     ror.w    #4,d2                shift the scroll value
  2250.     or.w    #$aa0,d2            use D = A.C
  2251.     move.w    d2,bltcon0(a6)            with D turned off
  2252.     move.l    a1,bltapt(a6)            a1 = sprite
  2253.     move.l    a0,-(sp)
  2254.     lea    displayraster(a5),a0
  2255.     move.l    20(a0),d0
  2256.     move.l    (sp)+,a0
  2257.     add.l    d1,d0
  2258.     move.l    d0,bltcpt(a6)            d0 = background
  2259.     move.w    #96,bltcmod(a6)
  2260.     move.w    d3,bltsize(a6)            d3 = blitsize
  2261.     btst    #5,dmaconr(a6)
  2262.     rts
  2263.  
  2264. or.foregnds
  2265.     move.w    #88,bltamod(a6)            or the two foregrounds together
  2266.     move.w    #88,bltbmod(a6)
  2267.     clr.w    bltdmod(a6)
  2268.     move.w    d3,(a0)+            store the blitsize in the buffer
  2269.     move.l    12(a2),d0
  2270.     add.l    d1,d0
  2271.     move.l    d0,(a0)                store the plane 2 address
  2272.     move.l    d0,bltapt(a6)
  2273.     move.l    16(a2),d0
  2274.     add.l    d1,d0
  2275.     move.l    d0,4(a0)            store the plane 4 address
  2276.     move.l    d0,bltbpt(a6)
  2277.     clr.w    bltcon1(a6)
  2278.     move.w    #$0ffc,bltcon0(a6)        use D = A or B
  2279.     move.l    d6,bltdpt(a6)            d6 = foreground buffer
  2280.     move.w    d3,bltsize(a6)
  2281.     rts
  2282.  
  2283. erase.missiles
  2284.     move.l    #missiletable,a0
  2285.     move.l    #fgnd.buffer,a1
  2286.     clr.w    bltcon1(a6)
  2287.     clr.w    bltamod(a6)            a = or'd fgnd
  2288.     move.w    #$0dc0,bltcon0(a6)        D=A.B
  2289.     move.w    #88,bltbmod(a6)            b = foreground
  2290.     move.w    #88,bltdmod(a6)            d = foreground
  2291. eraseloop
  2292.     move.w    (a0),d0                d0 = blitsize                                
  2293.     beq    eraseend            zero if end
  2294.     clr.w    (a0)+
  2295.     move.w    d0,d1
  2296.     lsr.w    #4,d1
  2297.     move.l    (a0),bltbpt(a6)
  2298.     move.l    (a0)+,bltdpt(a6)
  2299.     move.l    a1,bltapt(a6)
  2300.     move.w    d0,bltsize(a6)
  2301.     move.l    (a0),bltbpt(a6)
  2302.     move.l    (a0)+,bltdpt(a6)
  2303.     move.l    a1,bltapt(a6)
  2304.     move.w    d0,bltsize(a6)
  2305.     add.w    d1,a1
  2306.     bra    eraseloop
  2307. eraseend
  2308.     rts
  2309.  
  2310. **************************************************************************
  2311.  
  2312. draw.guardian
  2313.     cmp.w    #$e,pf2scroll(a5)
  2314.     bne    no.draw
  2315.     move.w    guardian.frame(a5),d0
  2316.     cmp.w    #16,d0
  2317.     beq    no.draw
  2318.     mulu    #24,d0
  2319.     ext.l    d0
  2320.     move.l    #guardian,a0
  2321.     add.l    d0,a0
  2322.     move.l    guardian.data(a5),a1
  2323.     lea    rasters+12(a5),a4
  2324.     move.l    (a4)+,a2
  2325.     move.l    (a4)+,a3
  2326.     move.l    (a4),a4
  2327.     moveq    #46,d6
  2328.     add.l    d6,a2
  2329.     add.l    d6,a3
  2330.     add.l    d6,a4
  2331.     add.w    pf2offset(a5),a2
  2332.     add.w    pf2offset(a5),a3
  2333.     add.w    pf2offset(a5),a4
  2334.     moveq    #92,d5
  2335.     moveq    #23,d7
  2336. drawg1    moveq    #7,d6
  2337.     move.b    (a0)+,d0
  2338. drawg2    btst    d6,d0
  2339.     bne    draw.data
  2340.     clr.w    (a2)
  2341.     clr.w    (a3)
  2342.     clr.w    (a4)
  2343.     bra    donext
  2344. draw.data
  2345.     move.w    (a1)+,(a2)
  2346.     move.w    (a1)+,(a3)
  2347.     move.w    (a1)+,(a4)
  2348. donext    add.l    d5,a2
  2349.     add.l    d5,a3
  2350.     add.l    d5,a4
  2351.     dbf    d6,drawg2
  2352.     dbf    d7,drawg1
  2353.     move.l    a1,guardian.data(a5)    
  2354.     addq.w    #1,guardian.frame(a5)
  2355. no.draw    cmp.w    #6,pf2count(a5)
  2356.     bne    return
  2357.     cmp.w    #8,pf2scroll(a5)
  2358.     bne    return
  2359.     addq.w    #1,level.end(a5)
  2360.     rts
  2361.  
  2362. change.colours
  2363.     lea    colours+32(pc),a2
  2364.     moveq    #7,d7
  2365.     lea    guard.colours,a3
  2366.     move.w    level.number(a5),d2
  2367.     lsl.w    #4,d2
  2368.     add.w    d2,a3
  2369. change1    move.w    (a3)+,2(a2)
  2370.     addq    #4,a2
  2371.     dbf    d7,change1
  2372.     rts
  2373.  
  2374.  
  2375. levels.code
  2376.     tst.b    hit.guardian(a5)
  2377.     beq    return
  2378.     lea    colours+50(pc),a0
  2379.     tst.b    colour.updown(a5)
  2380.     bne    colour.down
  2381.     add.w    #$100,(a0)
  2382.     cmp.w    #$f00,(a0)
  2383.     seq    colour.updown(a5)
  2384.     rts
  2385. colour.down
  2386.     sub.w    #$100,(a0)
  2387.     cmp.w    #$700,(a0)
  2388.     bne    return
  2389.     not.b    colour.updown(a5)
  2390.     clr.b    hit.guardian(a5)
  2391.     rts
  2392.  
  2393.  
  2394. decrement.counter
  2395.     tst.w    guardian.count(a5)
  2396.     beq    death.path
  2397.     subq.w    #1,guardian.count(a5)
  2398.     rts
  2399. death.path
  2400.     move.l    #path.buffer,a0
  2401.     add.w    next.path(a0),a0
  2402.     tst.b    sprite.num(a0)
  2403.     beq    wait.explosion
  2404.     moveq    #10,d7
  2405. ex.loop    bsr    explode.alien
  2406.     move.w    next.path(a0),d0
  2407.     beq    return
  2408.     add.w    d0,a0
  2409.     dbf    d7,ex.loop
  2410.     rts
  2411. wait.explosion
  2412.     tst.w    x.pos(a0)
  2413.     bne    return
  2414.     move.l    #paths,a0
  2415. find.path3
  2416.     tst.l    (a0)+
  2417.     bne    find.path3
  2418.     addq    #8,a0
  2419.     move.l    (a0),a0
  2420.     move.b    #$ff,last.path(a5)
  2421.     bra    copy.path
  2422.  
  2423. check.all
  2424.     tst.b    last.path(a5)
  2425.     beq    start.guard.path
  2426.     cmp.b    #2,last.path(a5)
  2427.     beq    explosion.path
  2428.     cmp.b    #3,last.path(a5)
  2429.     seq.b    kill.game(a5)
  2430.     rts
  2431.  
  2432. start.guard.path
  2433.     move.l    #paths,a0
  2434. ;    moveq    #0,d0
  2435. ;    jsr    Initune
  2436. find.path
  2437.     tst.l    (a0)+
  2438.     bne    find.path
  2439.     move.l    (a0),a0
  2440.     move.b    #1,last.path(a5)
  2441.     bra    copy.path
  2442.  
  2443. explosion.path
  2444.     move.l    #paths,a0
  2445. find.path2
  2446.     tst.l    (a0)+
  2447.     bne    find.path2
  2448.     addq    #4,a0
  2449.     move.l    (a0),a0
  2450.     move.b    #3,last.path(a5)
  2451. ;    jsr    Turnoff
  2452.     bra    copy.path
  2453.  
  2454. **************************************************************************
  2455.  
  2456.  
  2457. clist        DC.W    $0A01,$FF00
  2458. copperlist    DC.W    bplpt+0,$0000,bplpt+2,$0000
  2459.         DC.W    bplpt+8,$0000,bplpt+10,$0000
  2460.         DC.W    bplpt+16,$0000,bplpt+18,$0000
  2461.         DC.W    bplpt+4,$0000,bplpt+6,$0000
  2462.         DC.W    bplpt+12,$0000,bplpt+14,$0000
  2463.         DC.W    bplpt+20,$0000,bplpt+22,$0000
  2464.         DC.W    bplcon0,$6600
  2465. scroll.value    DC.W    bplcon1,$00FF,bpl1mod,$0036
  2466.         DC.W    bpl2mod,$002E,bplcon2,$0044
  2467.         DC.W    ddfstrt,$0028,ddfstop,$00D8
  2468.         DC.W    diwstrt,$1F78,diwstop,$FFC6
  2469.  
  2470. colours        DC.W    color+0,$0000,color+2,$0000
  2471.         DC.W    color+4,$0000,color+6,$0000
  2472.         DC.W    color+8,$0000,color+10,$0000
  2473.         DC.W    color+12,$0000,color+14,$0000
  2474.         DC.W    color+16,$0000,color+18,$0000
  2475.         DC.W    color+20,$0000,color+22,$0000
  2476.         DC.W    color+24,$0000,color+26,$0000
  2477.         DC.W    color+28,$0000,color+30,$0000
  2478.         DC.W    color+32,$0000,color+34,$0000
  2479.         DC.W    color+36,$0000,color+38,$0000
  2480.         DC.W    color+40,$0000,color+42,$0000
  2481.         DC.W    color+44,$0000,color+46,$0000
  2482.         DC.W    color+48,$0000,color+50,$0000
  2483.         DC.W    color+52,$0000,color+54,$0000
  2484.         DC.W    color+56,$0000,color+58,$0000
  2485.         DC.W    color+60,$0000,color+62,$0000
  2486.  
  2487. sprite        DC.W    sprpt+0,$0000,sprpt+2,$0000
  2488.         DC.W    sprpt+4,$0000,sprpt+6,$0000
  2489.         DC.W    sprpt+8,$0000,sprpt+10,$0000
  2490.         DC.W    sprpt+12,$0000,sprpt+14,$0000
  2491.         DC.W    sprpt+16,$0000,sprpt+18,$0000
  2492.         DC.W    sprpt+20,$0000,sprpt+22,$0000
  2493.         DC.W    sprpt+24,$0000,sprpt+26,$0000
  2494.         DC.W    sprpt+28,$0000,sprpt+30,$0000
  2495.  
  2496.         DC.W    $DF01,$FF00
  2497.         DC.W    bplcon1,$0000,bplcon0,$4200,ddfstrt,$0030
  2498. rastersplit2    DC.W    bplpt+0,$0000,bplpt+2,$0000
  2499.         DC.W    bplpt+4,$0000,bplpt+6,$0000
  2500.         DC.W    bplpt+8,$0000,bplpt+10,$0000
  2501.         DC.W    bplpt+12,$0000,bplpt+14,$0000
  2502. colours2    DC.W    color+20,$0000,color+30,$0000
  2503.         DC.W    color+2,$0000,color+4,$0000
  2504.         DC.W    color+6,$0000,color+8,$0000
  2505.         DC.W    color+10,$0000,color+12,$0000
  2506.         DC.W    color+14,$0000,color+16,$0000
  2507.         DC.W    color+18,$0000,color+22,$0000
  2508.         DC.W    color+24,$0000,color+26,$0000
  2509.         DC.W    color+28,$0000,color+0,$0000
  2510.         DC.W    bpl1mod,$0000,bpl2mod,$0000
  2511.         DC.W    $DF01,$FF00,intreq,$8010
  2512.         DC.W    $FFFF,$FFFE
  2513.  
  2514.  
  2515. panel.colours    DC.W    $0600,$0333,$0fb3,$0d00,$0b00,$0720,$0fc2,$0c90
  2516.         DC.W    $0a40,$0eb0,$0eca,$0456,$0577,$0252,$0444,$0000
  2517.  
  2518.  
  2519. mult1offsets
  2520.     DC.B    5,0,5,-5,0,-5,-5,-5,-5,0
  2521. mult2offsets
  2522.     DC.B    5,0,5,5,0,5,-5,5,-5,0
  2523.  
  2524. explosion.sequence
  2525.     dc.b    0,1,2,3,4,5,6,7,8,9,10,-1
  2526.  
  2527.     rsreset
  2528. screen.num    RS.B    1    
  2529. vcount        RS.B    1    vertical blank counter
  2530. mult1.on    RS.B    1    byte set if a multiple is attached to ship
  2531. mult2.on    RS.B    1    same for another multiple (2 max)
  2532. canons.on    RS.B    1    bytes are set to signify what weapons
  2533. lasers.on    RS.B    1    are attached
  2534. ship.status    RS.B    1    values to indicate which ship to draw
  2535. activecanons    RS.B    1
  2536. activemissiles    RS.B    1
  2537. activelasers    RS.B    1
  2538. activemult1    RS.B    1
  2539. activemult2    RS.B    1
  2540. firekey        RS.B    1
  2541. ship.dead    RS.B    1
  2542. num.speedups    RS.B    1
  2543. num.outriders    RS.B    1
  2544. num.fields    RS.B    1
  2545. num.canons    RS.B    1
  2546. num.lasers    RS.B    1
  2547. num.shields    RS.B    1
  2548. kill.game    RS.B    1
  2549. hit.guardian    RS.B    1
  2550. colour.updown    RS.B    1
  2551.  
  2552. ship.speed    RS.W    1    speed in pixels
  2553. xpos        RS.W    1    ship x position
  2554. ypos        RS.W    1    ship y position
  2555. mult.number    RS.W    1    multiple animation number
  2556. mult.delay    RS.W    1    multiple animation delay
  2557. xvector        RS.W    1    inertia vectors for the ship
  2558. yvector        RS.W    1
  2559. oldmousex    RS.W    1    store the old mouse values to reference
  2560. oldmousey    RS.W    1    the new ones to
  2561. up.down        RS.W    1    this holds the graphic offset for a ship tilt
  2562.  
  2563. pf1count    RS.W    1    number of background words to scroll
  2564. pf2count    RS.W    1    number of foreground words to scroll
  2565. pf1scroll    RS.W    1    pixel scroll value (0-15) background
  2566. pf2scroll    RS.W    1    pixel scroll value (0-15) foreground
  2567. pf1scroll2    RS.W    1
  2568. pf2offset    RS.W    1
  2569. screenend    RS.W    1
  2570. level.end    RS.W    1
  2571. level.number    RS.W    1
  2572. canon.energy    RS.W    1    
  2573. laser.energy    RS.W    1
  2574. fire.delay    RS.W    1
  2575. ship.energy    RS.W    1
  2576. ship.count    RS.W    1
  2577. field.count    RS.W    1
  2578. difficulty    RS.W    1
  2579. guard.offset    RS.W    1
  2580.  
  2581. path.delay    RS.W    1
  2582. last.x        RS.W    1    x coord of last killed alien
  2583. last.y        RS.W    1    y coord of last killed alien
  2584. path.number    RS.W    1
  2585. all.coords    RS.W    1    zero if all aliens are dead
  2586. x.equal        RS.B    1
  2587. y.equal        RS.B    1
  2588. upsidedown    RS.B    1    draw alien upside down
  2589. no.bonus    RS.B    1    alien finished path so no bonus
  2590. last.path    RS.B    1
  2591. bonus.mode    RS.B    1    bonus icon on screen
  2592. bonus.num    RS.W    1    current bonus
  2593. bonus.count    RS.W    1    number of hits to change bonus
  2594. bonus.delay    RS.B    1
  2595. explosion.delay RS.W    1
  2596. guardian.frame    RS.W    1
  2597. guardian.count    RS.W    1
  2598.  
  2599. missiledata    RS.L    8
  2600. canondata    RS.L    8
  2601. laserdata    RS.L    8
  2602. mult1data    RS.L    4
  2603. mult2data    RS.L    4
  2604. score        RS.L    1
  2605. score.add    RS.L    1
  2606. alien.score    RS.L    1
  2607. fgndpointer    RS.L    1    foreground map pointer
  2608. displayraster    RS.L    6    holds the addresses of the planes
  2609. rasters     RS.L    9    updated plane addresses
  2610. shipaddress    RS.L    1    ship animation address
  2611. alien.buffer    RS.L    18
  2612. explosion.ptr    RS.L    1
  2613. guardian.data    RS.L    1
  2614.  
  2615. vars.length    RS.B    0
  2616. variables    DS.B    vars.length
  2617.  
  2618. *        *********************************
  2619. *        *    Data structures        *
  2620. *        *********************************
  2621.  
  2622.     rsreset
  2623. next.path    RS.W    1            offset to the next path
  2624. x.pos        RS.W    1            current x position
  2625. y.pos        RS.W    1            current y position
  2626. kills.what    RS.W    1            kills others if dead (0-11)
  2627. table.offset    RS.W    1            the current table offset
  2628. sprite.num    RS.B    1            sprite number
  2629. anim.num    RS.B    1            animation number
  2630. anim.delay    RS.B    1            delay in 1/25 secs
  2631. anim.delay2    RS.B    1            static delay
  2632. speed        RS.B    1            speed in pixels
  2633. pause.count    RS.B    1            dynamic pause counter
  2634. mode        RS.B    1            flags, see bleow
  2635. loop.offset    RS.B    1            loop offset (-ve)
  2636. loop.count    RS.B    1            dynamic loop count
  2637. hits.num    RS.B    1            number of hits to kill
  2638. num.anims    RS.B    1            no of animations
  2639. seek.count    RS.B    1            dynamic seek count
  2640. table.size    RS.B    0
  2641.  
  2642. * This is followed by x,y bytes to move to (always even) with the following
  2643. * special codes
  2644.  
  2645. *    x = 0, path finished, terminate alien
  2646. *    x = $e0, perform a pause (up to 10 secs), followed by the pause value, $ff forever
  2647. *    x = $e1, perform the loop
  2648. *    x = $e2, toggle the offset mode
  2649. *    x = $e3, speed change, followed by new speed byte
  2650. *    x = $e4, sprite change, followed by sprite num, max anims
  2651. *    x = $e5, start seek mode, followed by count & two 0 bytes
  2652. *    x = $e6, reload the aliens x,y coords, followed by two xy bytes
  2653. *    x = $e7, reload the table offset, old one stored in loop.offset
  2654. *    x = $e8, restore the old table offset
  2655. *    x = $e9, fire a heat seeker, followed by count
  2656. *    x = $ea, new animation number, followed by animation number
  2657. *    x = $eb, repeat table indefinitely
  2658.  
  2659. *    mode bit 0 = offset mode
  2660. *         bit 1 = seek mode
  2661. *         bit 2 = 
  2662. *         bit 3 = up/down animation type
  2663. *         bit 4 = 0-animate up/1-animate down
  2664. *         bit 5 = heat seeker path
  2665.  
  2666.  
  2667. backgroundtable    DC.W    $0123,$0123,$0123,$0123,$0123,$0123 background
  2668.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567 map
  2669.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  2670.         DC.W    $0123,$0123,$0123,$0123,$0123,$0123
  2671.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567
  2672.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  2673.         DC.W    $0123,$0123,$0123,$0123,$0123,$0123
  2674.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567
  2675.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  2676.         DC.W    $0123,$0123,$0123,$0123,$0123,$0123
  2677.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567
  2678.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  2679.  
  2680. backgrounds    DC.W  $1430,$0C30,$0C10,$0413,$8403,$4442,$2142,$3120
  2681.         DC.W  $3110,$2810,$141C,$1417,$140B,$0C71,$0A00,$DC08
  2682.         DC.W  $8A08,$9208,$0229,$8208,$4244,$2221,$12A1,$0891
  2683.         DC.W  $0888,$148A,$0A03,$2A48,$8A44,$9208,$8524,$2204
  2684.  
  2685.         DC.W  $0210,$0230,$1118,$0118,$8128,$414C,$314C,$10CA
  2686.         DC.W  $1005,$1013,$5103,$31C3,$5023,$D011,$3018,$6304
  2687.         DC.W  $0129,$0908,$0884,$0884,$4294,$22A2,$08A2,$0825
  2688.         DC.W  $0842,$0908,$2880,$C824,$2890,$2808,$0904,$1092
  2689.  
  2690.         DC.W  $0300,$4220,$0461,$0451,$0850,$08C8,$38C8,$1848
  2691.         DC.W  $0848,$0848,$0848,$08C8,$0148,$1050,$E060,$4041
  2692.         DC.W  $2084,$2110,$2210,$0228,$0429,$1424,$0424,$0424
  2693.         DC.W  $8424,$8424,$8424,$8424,$80A4,$8828,$1011,$2420
  2694.  
  2695.         DC.W  $1430,$0C08,$0800,$0413,$8083,$4442,$2242,$2120
  2696.         DC.W  $2110,$2810,$040C,$1487,$104B,$0C71,$0A10,$D908
  2697.         DC.W  $8A08,$9000,$042D,$8008,$4244,$2221,$1121,$0091
  2698.         DC.W  $0888,$048A,$0A03,$2240,$8220,$9208,$8124,$2004
  2699.  
  2700.         DC.W  $7028,$6218,$8218,$C208,$C210,$C210,$6420,$2420
  2701.         DC.W  $4820,$4820,$8843,$0882,$108C,$2118,$2220,$4421
  2702.         DC.W  $0914,$1104,$4104,$2504,$2508,$2508,$9250,$1250
  2703.         DC.W  $2450,$2410,$4420,$8441,$0840,$1080,$1110,$A210
  2704.  
  2705.         DC.W  $C60C,$C60A,$4609,$2209,$A201,$A223,$9011,$901F
  2706.         DC.W  $900C,$8C18,$0620,$060F,$0213,$0404,$1405,$1419
  2707.         DC.W  $2102,$2105,$2104,$5104,$5124,$5110,$4908,$4900
  2708.         DC.W  $4902,$4204,$8912,$0900,$2508,$0212,$4A02,$EA04
  2709.  
  2710.         DC.W  $0080,$0100,$0110,$0918,$0A14,$0A33,$8A31,$0621
  2711.         DC.W  $0220,$8204,$8204,$860D,$860A,$8A0C,$0108,$0101
  2712.         DC.W  $4940,$0888,$8888,$8484,$852A,$8508,$4508,$8110
  2713.         DC.W  $4911,$4902,$490A,$4102,$4905,$4502,$8084,$9088
  2714.  
  2715.         DC.W  $7028,$4318,$8298,$C248,$8250,$C210,$6120,$20A0
  2716.         DC.W  $5820,$4820,$8813,$188A,$108C,$2100,$2220,$4421
  2717.         DC.W  $0914,$1004,$4144,$2504,$4528,$2528,$9290,$1010
  2718.         DC.W  $2010,$2410,$4428,$8405,$0842,$1080,$1100,$A210
  2719.  
  2720.         DC.W  $8820,$0440,$0204,$1202,$8221,$8220,$8300,$8410
  2721.         DC.W  $C080,$0180,$20C0,$6040,$7060,$31A1,$2820,$2820
  2722.         DC.W  $4410,$8A24,$0122,$8921,$4910,$4110,$4090,$4208
  2723.         DC.W  $2448,$8048,$1020,$1220,$0910,$0850,$9492,$1412
  2724.  
  2725.         DC.W  $CE02,$4A02,$5402,$0442,$0844,$9048,$E148,$4150
  2726.         DC.W  $23A0,$31C4,$3185,$3842,$2820,$11A0,$23A0,$6322
  2727.         DC.W  $0101,$2501,$2A01,$9221,$9422,$68A4,$10A4,$A0A8
  2728.         DC.W  $1050,$0822,$0842,$04A1,$1412,$8850,$5051,$1091
  2729.  
  2730.         DC.W  $3100,$11C0,$10C1,$10E1,$4862,$8850,$9850,$88F0
  2731.         DC.W  $E830,$7031,$0028,$8248,$4088,$4018,$2018,$3018
  2732.         DC.W  $0881,$0821,$0820,$0810,$2411,$5429,$44A9,$4408
  2733.         DC.W  $0408,$0808,$8114,$4124,$2144,$2104,$1224,$0844
  2734.  
  2735.         DC.W  $C820,$4440,$2204,$1002,$8225,$8224,$8308,$8418
  2736.         DC.W  $C980,$1188,$20C4,$6040,$6260,$2121,$2820,$2820
  2737.         DC.W  $0410,$AA24,$1122,$8921,$4912,$0110,$4094,$4380
  2738.         DC.W  $2448,$8844,$1020,$1220,$0110,$0850,$9492,$1412
  2739.  
  2740. level.colours
  2741.         DC.W    $0332,$0055,$0543,$0000,$0000,$0000,$0000,$0000
  2742.         DC.W    $0000,$0F55,$0B05,$0700,$08A7,$0182,$0065,$0055
  2743.         DC.W    $0000,$0FF6,$0000,$0FD0,$0A00,$0BDF,$06AF,$004F
  2744.         DC.W    $0FFF,$0CDD,$0ABB,$0798,$0587,$0465,$0243,$0E32
  2745.  
  2746.  
  2747. alien.colours    DC.W    $0332,$0055,$0543,$0000,$0DFF,$06AC,$036A,$0038 level1
  2748.         DC.W    $0332,$0055,$0543,$0000,$0FE0,$0DA0,$0B62,$0900
  2749.         DC.W    $0332,$0055,$0543,$0000,$0FE0,$0DA0,$0B62,$0900
  2750.         DC.W    $0332,$0055,$0543,$0000,$0DE9,$0FE0,$0F90,$0D32
  2751.         DC.W    $0332,$0055,$0543,$0000,$0FE0,$0DA0,$0B62,$0900
  2752.         DC.W    $0332,$0055,$0543,$0000,$09E7,$06A0,$0D00,$0460
  2753.         DC.W    $0332,$0055,$0543,$0DDF,$099E,$0569,$0348,$0235
  2754.         DC.W    $0332,$0055,$0543,$0FFC,$0FF2,$0DE9,$0BC6,$09A4
  2755.         DC.W    $0332,$0055,$0543,$09FF,$0AF5,$03DF,$01BF,$008F
  2756.         DC.W    $0332,$0055,$0543,$0F77,$08A7,$0385,$0265,$0722
  2757.         DC.W    $0332,$0055,$0543,$0F66,$08A7,$0283,$0065,$0700
  2758.         DC.W    $0332,$0055,$0543,$0F66,$08A7,$0283,$0065,$0700
  2759.         DC.W    $0332,$0055,$0543,$0F66,$08A7,$0283,$0065,$0700
  2760.         DC.W    $0332,$0055,$0543,$0B85,$0DDA,$0C00,$0952,$0700
  2761.         DC.W    $0332,$0055,$0543,$0D8C,$0B5A,$000E,$0937,$0705
  2762.         DC.W    $0332,$0055,$0543,$0E00,$0A98,$0B60,$0832,$0733
  2763.         DC.W    $0332,$0055,$0543,$0E00,$0A98,$0B60,$0832,$0733
  2764.         DC.W    $0332,$0055,$0543,$0E00,$0A98,$0B60,$0832,$0733
  2765.         DC.W    0,0,0,0,0,0,0,0
  2766.         DC.W    0,0,0,0,0,0,0,0
  2767.         DC.W    0,0,0,0,0,0,0,0
  2768.         DC.W    0,0,0,0,0,0,0,0
  2769.         DC.W    0,0,0,0,0,0,0,0
  2770.         DC.W    0,0,0,0,0,0,0,0
  2771.  
  2772. guard.colours
  2773.         DC.W    $0000,$0A00,$0D22,$0E77,$0700,$0FDD,$0A73,$0C90
  2774.  
  2775. *******************************************************************************
  2776. *******************************************************************************
  2777.  
  2778. alldone
  2779.     bsr    FreeSystem
  2780.  
  2781. MemError
  2782.     move.l    _SysBase,a6
  2783.     move.l    MemBase,a1
  2784.     move.l    #MemNeeded,d0        free the memory we took
  2785.     jsr    _LVOFreeMem(a6)
  2786.     move.l    GraphicsBase,a1    
  2787.     jsr    _LVOCloseLibrary(a6)
  2788.     move.l    DOSBase,a1        finally close the 
  2789.     jsr    _LVOCloseLibrary(a6)    libraries
  2790.     clr.l    d0
  2791.     rts
  2792.  
  2793. *******************************************************************************
  2794.  
  2795. TakeSystem
  2796.     move.w    intenar(a6),SystemInts        save system interupts
  2797.     move.w    dmaconr(a6),SystemDMA        and DMA settings
  2798.     move.w    #$7fff,intena(a6)        kill everything!
  2799.     move.w    #$7fff,dmacon(a6)
  2800.     move.b    #%01111111,ICRA            kill keyboard
  2801.     move.l    $68,Level2Vector        save these interrupt vectors
  2802.     move.l    $6c,Level3Vector        as we will use our own 
  2803.     rts                    keyboard & vblank routines
  2804.  
  2805. FreeSystem
  2806.     move.l    Level2Vector,$68    restore the system vectors
  2807.     move.l    Level3Vector,$6c        and interrupts and DMA
  2808.     move.l    GraphicsBase,a1            and replace the system
  2809.     move.l    SystemCopper1(a1),Hardware+cop1lc    copper list
  2810.     move.l    SystemCopper2(a1),Hardware+cop2lc
  2811.     move.w    SystemInts,d0
  2812.     or.w    #$c000,d0
  2813.     move.w    d0,intena(a6)
  2814.     move.w    SystemDMA,d0
  2815.     or.w    #$8100,d0
  2816.     move.w    d0,dmacon(a6)
  2817.     move.b    #%10011011,ICRA    keyboard etc back on
  2818.     rts
  2819.  
  2820. *******************************************************************************
  2821.  
  2822. Level2Vector        dc.l    0
  2823. Level3Vector        dc.l    0
  2824. SystemInts        dc.w    0
  2825. SystemDMA        dc.w    0
  2826. MemBase            dc.l    0
  2827. DOSBase            dc.l    0
  2828. GraphicsBase        dc.l    0
  2829.  
  2830.     even
  2831. GraphicsName    dc.b    'graphics.library',0
  2832.     even
  2833. DOSName        dc.b    'dos.library',0
  2834.  
  2835. *******************************************************************************
  2836.  
  2837. graphics    incbin    :foregrounds
  2838. shipbase    include    :ships.s
  2839. paths        include    :paths.s
  2840. map        incbin    :map
  2841. panel        incbin    :panel
  2842. aliens        incbin    :aliens
  2843. bonus.sprite    include    :bonus.s
  2844. mine        include :mine.s
  2845. guardian    incbin    :guardian
  2846.  
  2847. missiletable    ds.b    512
  2848.  
  2849. alien.pointers
  2850. explosion1    equ    aliens
  2851. guardian.eye1    equ    explosion1+(9*384)
  2852. tadpole        equ    guardian.eye1+(4*384)
  2853. eye        equ    tadpole+(4*384)
  2854. bubble        equ    eye+(15*384)
  2855. jellyfish1    equ    bubble+(4*384)
  2856. jellyfish2    equ    jellyfish1+(4*384)
  2857. bordertl    equ    jellyfish2+(4*384)
  2858. borderbl    equ    bordertl+(6*384)
  2859. bordertr    equ    borderbl+(6*384)
  2860. borderbr    equ    bordertr+(6*384)
  2861. mouth        equ    borderbr+(6*384)
  2862. slime        equ    mouth+(8*384)
  2863. snakebody    equ    slime+(9*384)
  2864. snakehead    equ    snakebody+(1*384)
  2865.  
  2866.     dc.l    explosion1
  2867.     dc.l    bonus.sprite
  2868.     dc.l    mine
  2869.     dc.l    guardian.eye1
  2870.     dc.l    explosion1
  2871.     dc.l    tadpole
  2872.     dc.l    eye
  2873.     dc.l    bubble
  2874.     dc.l    jellyfish1
  2875.     dc.l    jellyfish2
  2876.     dc.l    bordertl
  2877.     dc.l    borderbl
  2878.     dc.l    bordertr
  2879.     dc.l    borderbr
  2880.     dc.l    mouth
  2881.     dc.l    slime
  2882.     dc.l    snakebody
  2883.     dc.l    snakehead
  2884.     ds.l    6
  2885.  
  2886. path.buffer    ds.b    2048
  2887. buffer0        ds.b    6144
  2888. buffer1        ds.b    6144
  2889. screen0bgnds    ds.b    256
  2890. screen1bgnds    ds.b    256
  2891. fgnd.buffer    ds.b    2048
  2892.     end
  2893.