home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 11 / af011.adf / Dave Jones' Locker / menace.s < prev    next >
Encoding:
Text File  |  1978-02-05  |  49.7 KB  |  1,851 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    1
  41. aliensize        equ    24<<6!3
  42.  
  43. *******************************************************************************
  44.  
  45. start    lea    GraphicsName(pc),a1    open the graphics library purely
  46.     move.l    _SysBase,a6        to find the system copper
  47.     clr.l    d0
  48.     jsr    _LVOOpenLibrary(a6)
  49.     move.l    d0,GraphicsBase
  50.     lea    DOSName(pc),a1        open the DOS library to allow
  51.     clr.l    d0            the loading of data before
  52.     jsr    _LVOOpenLibrary(a6)    killing the system
  53.     move.l    d0,DOSBase
  54.  
  55.     move.l    #MemNeeded,d0        properly allocate some chip
  56.     moveq.l    #2,d1            memory for screens etc.
  57.     jsr    _LVOAllocMem(a6)    d1 = 2, specifies chip memory
  58.     tst.l    d0            where screens,samples etc
  59.     beq    MemError        must be (bottom 512K)
  60.     move.l    d0,MemBase
  61.  
  62. *******************************************************************************
  63.  
  64.     lea    variables(pc),a5    a5 is the variables pointer
  65.     lea    rasters(a5),a0
  66.     lea    displayraster(a5),a1
  67.     move.l    d0,(a0)+        calculate the address of each plane
  68.     move.l    d0,(a1)+        store them in the variables area,
  69.     add.l    #BytesPerBackPlane,d0    twice for the background as it is
  70.     move.l    d0,(a0)+        double buffered            
  71.     move.l    d0,(a1)+
  72.     add.l    #BytesPerBackPlane,d0
  73.     move.l    d0,(a0)+            
  74.     move.l    d0,(a1)+
  75.     add.l    #BytesPerBackPlane,d0
  76.     move.l    d0,(a0)+            
  77.     add.l    #BytesPerForePlane,d0
  78.     move.l    d0,(a0)+            
  79.     add.l    #BytesPerForePlane,d0
  80.     move.l    d0,(a0)+            
  81.     add.l    #BytesPerForePlane,d0
  82.     move.l    d0,(a0)+            
  83.     move.l    d0,(a1)+
  84.     add.l    #BytesPerBackPlane,d0
  85.     move.l    d0,(a0)+            
  86.     move.l    d0,(a1)+
  87.     add.l    #BytesPerBackPlane,d0
  88.     move.l    d0,(a0)+            
  89.     move.l    d0,(a1)+
  90.  
  91.     move.l    #Hardware,a6
  92.     jsr    TakeSystem
  93.  
  94. *******************************************************************************
  95.  
  96.     move.l    #$dff000,a6        a6 ALWAYS point to base of
  97.     move.l    #-1,bltafwm(a6)        custom chips
  98.     bsr    GameInit
  99.     move.l    #clist,cop1lc(a6)
  100.     move.w    #$87e0,dmacon(a6)    enable copper,sprite,blitter
  101.     move.w    #$7fff,intreq(a6)    clear all int request flags
  102.  
  103. *******************************************************************************
  104.  
  105. * Main game loop with the routines we are yet to cover commented out
  106.  
  107. *******************************************************************************
  108.  
  109. vloop    bsr    waitline223        interrupt set at vertical 
  110.     not.b    vcount(a5)        position 223 (panel start)
  111.     beq    twoblanks        alternate every frame
  112.  
  113.     lea    copperlist(pc),a1    set up registers for routine
  114.     move.w    pf2scroll(a5),d0    checkpf2
  115.     move.w    pf1scroll(a5),d1
  116.     bsr    checkpf2        and branch to it
  117.     bsr    moveship    
  118. *    bsr    check.collision
  119. *    bsr    erase.missiles
  120. *    bsr    levels.code
  121. *    bsr    update.missiles
  122.     bsr    drawfgnds
  123. *    bsr    print.score
  124. *    bsr    check.keys
  125.     bsr    check.path
  126.     bra    vloop
  127. twoblanks    
  128.     bsr    checkpf1        the following routines are only
  129.     bsr    flipbgnd        executed every second frame
  130.     bsr    moveship
  131.     bsr    restorebgnds        restore backgrounds behind aliens
  132.     bsr    process.aliens        
  133.     bsr    save.aliens        save the backgrounds behind aliens
  134.     bsr    draw.aliens        and then draw the aliens
  135.  
  136.     btst    #LeftMouse,PortA    lest mouse button to exit
  137.     bne    vloop
  138.     bra    alldone    
  139.  
  140. **************************************************************************
  141.  
  142. waitline223
  143.     btst    #4,intreqr+1(a6)    wait for vertical line 223
  144.     beq    waitline223        interrupt set by the
  145.     move.w    #$10,intreq(a6)        copperlist
  146. return    rts
  147.  
  148. **************************************************************************
  149.  
  150. checkpf1
  151.     cmp.w    #3,level.end(a5)    level.end = 3 means 
  152.     beq    return            guardian on, so no scroll
  153.     lea    copperlist(pc),a1
  154.     move.w    pf2scroll(a5),d0    d0 = pf2 scroll value (0-15)
  155.     move.w    pf1scroll(a5),d1    d1 = pf1 scroll value (0-15)
  156.     subq.w    #1,d1            scroll a pixel
  157.     bcs    resetpf1        reset back to 15
  158. checkpf2
  159.     cmp.w    #3,level.end(a5)    as above
  160.     beq    return
  161.     subq.w    #1,d0            scroll a pixel
  162.     bcs    resetpf2        reset to 15 and update pointers
  163. storescroll                    
  164.     move.w    d1,pf1scroll(a5)    resave the values
  165.     move.w    d0,pf2scroll(a5)
  166.     move.w    pf1count(a5),d2
  167.     subq.w    #1,d2            check if at the end of the two
  168.     or.w    d1,d2            screens and flag for the sprite
  169.     move.w    d2,screenend(a5)    routine if true    
  170.     lsl.w    #4,d0
  171.     or.w    d0,d1
  172.     move.w    d1,54(a1)        put the new scroll value into 
  173.     rts                the copper list
  174.  
  175. resetpf1
  176.     moveq    #$f,d1            reset scroll to 15
  177.     subq.w    #1,pf1count(a5)        decrement words scrolled
  178.     bne    storepf1        carry on if not zero
  179.     move.w    #23,pf1count(a5)    otherwise reset the number of
  180.     lea    rasters(a5),a4        words to scroll and reset the 
  181.     lea    displayraster(a5),a3    display planes back to the very
  182.     move.l    (a4)+,(a3)+        start.
  183.     move.l    (a4)+,(a3)+
  184.     move.l    (a4)+,(a3)+        six planes in all
  185.     add.w    #12,a4
  186.     move.l    (a4)+,(a3)+
  187.     move.l    (a4)+,(a3)+
  188.     move.l    (a4)+,(a3)+
  189.     bra    checkpf2        now check pf2
  190. storepf1
  191.     lea    displayraster(a5),a3    increment the plane pointers
  192.     addq.l    #2,(a3)            by a word each
  193.     addq.l    #2,4(a3)        these are background planes
  194.     addq.l    #2,8(a3)        and are therefore double
  195.     addq.l    #2,12(a3)        buffered
  196.     addq.l    #2,16(a3)
  197.     addq.l    #2,20(a3)
  198.     bra    checkpf2
  199.  
  200. resetpf2
  201.     lea    rasters(a5),a4
  202.     moveq    #$f,d0            reset scroll back to 15
  203.     subq.w    #1,pf2count(a5)        decrement the word scroll
  204.     bne    respf2            value and reset if zero
  205.     move.w    #23,pf2count(a5)
  206.     clr.w    pf2offset(a5)        offset is reverse of pf2count
  207.     cmp.w    #1,level.end(a5)    and is used for the copper
  208.     bne    respf2            level.end = 1 when map finished
  209.     addq.w    #1,level.end(a5)    so start to draw guardian
  210. *    bsr    change.colours        setup the guardian colours
  211. *    move.w    #6*72,guard.offset(a5)    changes the missiles
  212. respf2 
  213.     move.l    12(a4),d2        get the foreground plane 
  214.     move.l    16(a4),d3        pointers and add the offset to
  215.     move.l    20(a4),d4        them
  216.     addq.w    #2,pf2offset(a5)
  217.     add.w    pf2offset(a5),d2    store these in the copper list
  218.     add.w    pf2offset(a5),d3
  219.     add.w    pf2offset(a5),d4
  220. storepf2
  221.     move.w    d2,30(a1)
  222.     move.w    d3,38(a1)
  223.     move.w    d4,46(a1)
  224.     bra    storescroll
  225.  
  226. **************************************************************************
  227.  
  228. flipbgnd    
  229.     lea    copperlist(pc),a1    swap the background displays
  230.     lea    displayraster(a5),a3    every second frame
  231.     move.l    (a3),d4
  232.     move.l    4(a3),d5
  233.     move.l    8(a3),d6
  234.     move.l    12(a3),(a3)
  235.     move.l    16(a3),4(a3)
  236.     move.l    20(a3),8(a3)
  237.     move.l    d4,12(a3)
  238.     move.l    d5,16(a3)
  239.     move.l    d6,20(a3)
  240.     addq    #4,d4            add 4 bytes (32 pixels) to the
  241.     addq    #4,d5            pointers so that clipping can
  242.     addq    #4,d6            be carried out on the left
  243.     move.w    d4,6(a1)        hand side
  244.     swap    d4
  245.     move.w    d4,2(a1)        store the new ones in the copper
  246.     move.w    d5,14(a1)        list
  247.     swap    d5
  248.     move.w    d5,10(a1)
  249.     move.w    d6,22(a1)
  250.     swap    d6
  251.     move.w    d6,18(a1)
  252.     not.b    screen.num(a5)
  253.     rts
  254.  
  255. **************************************************************************
  256.  
  257. drawfgnds
  258.     cmp.w    #3,level.end(a5)    3 for guardian fully on
  259.     beq    return
  260.     cmp.w    #2,level.end(a5)    2 for drawing guardian
  261.     beq    return
  262.     tst.w    pf2scroll(a5)        every 16 pixels a new strip
  263.     beq    drawbegin        of foreground graphics are
  264.     cmp.w    #$e,pf2scroll(a5)    drawn into a hidden part
  265.     beq    drawend            of the screen
  266.     rts
  267. drawbegin
  268.     bsr    setupblit
  269.     clr.l    d6            d6 = offset into the screen
  270.     move.l    fgndpointer(a5),a0    for the start of the screen
  271.     bsr    drawfgnd        this will be zero
  272.     subq    #1,a0
  273.     move.l    a0,fgndpointer(a5)
  274.     rts
  275.  
  276. drawend
  277.     bsr    setupblit
  278.     moveq    #46,d6            as the screen is 46 bytes
  279.     move.l    fgndpointer(a5),a0    wide, this is the offset
  280.     cmp.b    #$ff,(a0)        at which to draw the strip
  281.     bne    drawfgnd
  282.     sub.w    #12,a0            the end of map is flagged
  283.     move.l    a0,fgndpointer(a5)    by an FF block number
  284.     move.w    #1,level.end(a5)    flag the end of the map
  285.  
  286. drawfgnd
  287.     clr.l    d0
  288.     move.b    (a0)+,d0        d0 = block number (0-254)
  289.     lea    rasters(a5),a4        get the current foreground
  290.     move.l    12(a4),d1        plane pointers in d1,d2,d3
  291.     move.l    16(a4),d2
  292.     move.l    20(a4),d3
  293.     add.l    d6,d1            add the offset passed
  294.     add.l    d6,d2
  295.     add.l    d6,d3
  296.     add.w    pf2offset(a5),d1    add the scrolled words
  297.     add.w    pf2offset(a5),d2    offset to each plane
  298.     add.w    pf2offset(a5),d3
  299.     moveq    #11,d7            12 blocks in height
  300.     move.l    #graphics,a4        a4 = base address of the graphics
  301. fgndloop                    
  302.     move.l    a4,d4
  303.     mulu    #96,d0            96 bytes per graphic blocks
  304.     ext.l    d0            (2 bytes wide x 16 high
  305.     add.l    d0,d4             x 3 planes)
  306.     bsr    blitfgnd
  307.     add.l    #ForegroundWidth*16,d1    work out address of 16 scanlines
  308.     add.l    #ForegroundWidth*16,d2    down 
  309.     add.l    #ForegroundWidth*16,d3
  310.     clr.l    d0
  311.     move.b    (a0)+,d0        get next block number
  312.     dbf    d7,fgndloop        and repeat for all 12
  313.     rts
  314.  
  315. blitfgnd
  316.     move.l    d1,bltdpt(a6)        blit a 16x16 pixel block
  317.     move.l    d4,bltapt(a6)        into the foreground screen
  318.     move.w    #$0401,bltsize(a6)    unmasked with no shift
  319.     add.l    #32,d4
  320.     move.l    d2,bltdpt(a6)
  321.     move.l    d4,bltapt(a6)
  322.     move.w    #$0401,bltsize(a6)
  323.     add.l    #32,d4
  324.     move.l    d3,bltdpt(a6)
  325.     move.l    d4,bltapt(a6)
  326.     move.w    #$0401,bltsize(a6)
  327.     rts
  328.  
  329. setupblit
  330.     move.w    #$09f0,bltcon0(a6)        minterm for D = A
  331.     clr.w    bltcon1(a6)
  332.     clr.w    bltamod(a6)            data is stored sequentially
  333.     move.w    #ForegroundWidth-2,bltdmod(a6)
  334.     rts
  335.  
  336. **************************************************************************
  337.  
  338. buildbackgnd
  339.     lea    rasters(a5),a0
  340.     move.l    (a0),a1            get the background plane pointers
  341.     move.l    4(a0),a2        in a1-a4 (double buffered so 2 sets)
  342.     move.l    24(a0),a3        background graphics are only 4 colour
  343.     move.l    28(a0),a4        (2 planes) so third plane is ignored
  344.     addq    #4,a1            skip the hidden words used for
  345.     addq    #4,a2            clipping
  346.     addq    #4,a3
  347.     addq    #4,a4
  348.     move.l    #backgroundtable,a0    a0 = the background map
  349.     move.w    level.number(a5),d0
  350.     mulu    #144,d0            144 bytes per background map
  351.     add.w    d0,a0
  352.     moveq    #11,d0            12 blocks high
  353. build1    moveq    #11,d1            24 blocks across
  354.     movem.l    a1-a4,-(sp)
  355. build2    move.b    (a0),d2            this loop draws 2 across
  356.     lsr.b    #4,d2            block number stored in 4 bits
  357.     bsr    drawback
  358.     move.b    (a0)+,d2
  359.     and.b    #$f,d2
  360.     tst.w    d1
  361.     beq    skipit
  362.     bsr    drawback
  363. skipit    dbf    d1,build2        do all 24 across
  364.     movem.l    (sp)+,a1-a4
  365.     add.l    #BackgroundWidth*16,a1    next block down the way
  366.     add.l    #BackgroundWidth*16,a2
  367.     add.l    #BackgroundWidth*16,a3
  368.     add.l    #BackgroundWidth*16,a4
  369.     dbf    d0,build1        do all 12 high
  370.     move.l    #$dff000,a6
  371.     rts
  372.  
  373. drawback
  374.     lea    backgrounds,a6        a6 = the background graphics
  375.     move.w    level.number(a5),d3
  376.     mulu    #1024,d3        1024 bytes per level of background
  377.     add.w    d3,a6            graphics (16 blocks)
  378.     and.w    #$f,d2
  379.     mulu    #64,d2            64 bytes per block
  380.     add.l    d2,a6            (2 bytes x 16 high x 2 planes)
  381.     movem.l    a1-a4,-(sp)
  382.     moveq    #15,d3
  383. drawb1    move.w    (a6),(a1)        draw into both the screens
  384.     move.w    (a6),(a3)
  385.     move.w    (a6),46(a1)        
  386.     move.w    (a6),46(a3)
  387.     move.w    32(a6),(a2)
  388.     move.w    32(a6),(a4)
  389.     move.w    32(a6),46(a4)
  390.     move.w    32(a6),46(a2)
  391.     add.w    #BackgroundWidth,a1
  392.     add.w    #BackgroundWidth,a2
  393.     add.w    #BackgroundWidth,a3
  394.     add.w    #BackgroundWidth,a4
  395.     addq    #2,a6
  396.     dbf    d3,drawb1
  397.     movem.l    (sp)+,a1-a4
  398.     addq    #2,a1            next block along
  399.     addq    #2,a2
  400.     addq    #2,a3
  401.     addq    #2,a4
  402.     rts
  403.  
  404. **************************************************************************
  405.  
  406. GameInit
  407.     lea    map,a0
  408.     move.l    a0,fgndpointer(a5)    set up the map index
  409.     move.w    #23,pf1count(a5)    width of the foreground in words
  410.     move.w    #24,pf2count(a5)    width of the background in words
  411.     move.w    #15,pf1scroll(a5)    initial scroll value
  412.     move.w    #15,pf2scroll(a5)
  413.     move.w    #100,xpos(A5)        ships initial x,y & speed
  414.     move.w    #80,ypos(a5)
  415.     move.w    #2,ship.speed(a5)
  416.     move.w    #1,mult.number(a5)
  417.     move.l    #ship1.2,shipaddress(a5) setup address of initial ship
  418.     move.w    #10,path.delay(a5)
  419.  
  420.     lea    copperlist(pc),a1
  421.     lea    rasters(a5),a0
  422.     move.w    (a0),2(a1)        copy the plane adresses into the
  423.     move.w    2(a0),6(a1)        copperlist
  424.     move.w    4(a0),10(a1)
  425.     move.w    6(a0),14(a1)
  426.     move.w    8(a0),18(a1)
  427.     move.w    10(a0),22(a1)
  428.     move.w    12(a0),26(a1)
  429.     move.w    14(a0),30(a1)
  430.     move.w    16(a0),34(a1)
  431.     move.w    18(a0),38(a1)
  432.     move.w    20(a0),42(a1)
  433.     move.w    22(a0),46(a1)
  434.     addq.w    #4,6(a1)        skip the hidden words in the
  435.     addq.w    #4,14(a1)        background
  436.     addq.w    #4,22(a1)
  437.     lea    scroll.value(pc),a0
  438.     move.w    #$ff,2(a0)
  439.  
  440.     move.l    #panel+32,d0        put the address of the panel
  441.     lea    rastersplit2(pc),a1    graphics into the copper
  442.     moveq    #3,d1            the panel is 4 planes
  443. setup1    move.w    d0,6(a1)
  444.     swap    d0
  445.     move.w    d0,2(a1)
  446.     swap    d0
  447.     add.l    #1408,d0        panel size is 352x32 (1408 bytes
  448.     addq    #8,a1            per plane)
  449.     dbf    d1,setup1
  450.  
  451.     lea    level.colours(pc),a0    copy the level colours into the
  452.     lea    colours(pc),a1        copperlist
  453.     moveq    #31,d0
  454. .copy    move.w    (a0)+,2(a1)
  455.     addq    #4,a1
  456.     dbf    d0,.copy
  457.  
  458.     lea    panel.colours(pc),a0    copy the panel colours into the
  459.     lea    colours2(pc),a1        copperlist
  460.     moveq    #15,d0
  461. .copy2    move.w    (a0)+,2(a1)
  462.     addq    #4,a1
  463.     dbf    d0,.copy2
  464.  
  465.     bsr    ship.to.copper        setup the hardware sprite pointers
  466.  
  467.     bsr    clear.screen
  468.     bsr    buildbackgnd        and draw the background
  469.     bsr    setup.mouse
  470.  
  471.     IFNE    FullFirepower
  472.     st.b    mult1.on(a5)
  473.     st.b    mult2.on(a5)
  474.     st.b    canons.on(a5)
  475.     st.b    lasers.on(A5)
  476.     move.w    #2,ship.speed(A5)
  477.     move.b    #3,ship.status(a5)    
  478.     bsr    change.ship
  479.     ENDC
  480.     rts
  481.  
  482.  
  483. clear.screen
  484.     move.l    rasters(a5),a0        clear all the screen memory
  485.     move.w    #MemNeeded/4-1,d0
  486. clear.scr1
  487.     clr.l    (a0)+
  488.     dbf    d0,clear.scr1
  489.     rts
  490.  
  491. **************************************************************************
  492.  
  493. moveship
  494.     bsr    joy            read joystick & mouse
  495.     tst.w    ypos(a5)        upper y limit of 0
  496.     bge    up.ok
  497.     clr.w    d0            reset up flag if not allowed
  498.     clr.w    yvector(a5)        and no y movement
  499. up.ok    cmp.w    #150,ypos(a5)        maximum y value is 150
  500.     ble    down.ok
  501.     clr.w    d1            if at max signal down no more
  502.     clr.w    yvector(a5)
  503. down.ok    tst.w    xpos(a5)        minimum x position is 0
  504.     bge    left.ok
  505.     clr.w    d3
  506.     clr.w    xvector(a5)
  507. left.ok    cmp.w    #266,xpos(a5)        maximum x position is 266
  508.     ble    right.ok
  509.     clr.w    d2
  510.     clr.w    xvector(a5)
  511. right.ok
  512.  
  513.     move.w    ship.speed(a5),d4    d4 = ship speed
  514.     move.w    d4,d5            d5 = -ve ship speed
  515.     neg.w    d5                
  516.     clr.w    up.down(a5)        make ship untilt
  517.     move.w    yvector(a5),d7        change the y vector first
  518. up    tst.w    d0            are we going up?
  519.     beq    down            no, so check down    
  520.     move.w    #-560,up.down(a5)    yes, so tilt ship up (anims 560 bytes apart)
  521.     cmp.w    d7,d5            are we at max y speed
  522.     beq    right            yes, so go and check x movement
  523.     subq.w    #1,d7            no, so decrease the vector
  524.     bra    right
  525. down    tst.w    d1            are we going down?
  526.     beq    right            no, so check right
  527.     move.w    #560,up.down(a5)    yes, so tilt the ship down
  528.     cmp.w    d7,d4            are we at max y speed
  529.     beq    right            yes, so check x movement
  530.     addq.w    #1,d7            no, so increase the y vector
  531. right    move.w    d7,yvector(a5)        store the new y vector
  532.     move.w    xvector(a5),d7
  533.     clr.w    d6            now do the x vector which is
  534.     tst.w    d2            virtually identical to the y above
  535.     beq    left
  536.     moveq    #1,d6
  537.     cmp.w    d7,d4
  538.     beq    add.vectors
  539.     addq    #1,d7
  540.     bra    add.vectors
  541. left    tst.w    d3
  542.     beq    add.vectors
  543.     moveq    #-1,d6
  544.     cmp.w    d7,d5
  545.     beq    add.vectors
  546.     subq    #1,d7
  547. add.vectors
  548.     move.w    d7,xvector(a5)
  549.  
  550.     or.w    d2,d3            if we have moved left or right we
  551.     bne    checky            may have to alter the animation
  552.     move.w    #4,mult.delay(a5)    of the multiples
  553.  
  554.     moveq    #1,d7            if the ship is not being moved but
  555.     tst.w    xvector(a5)        still has some inertia then decrease
  556.     beq    checky            the x & y vectors until they hit 0
  557.     bmi    xto0
  558.     neg.w    d7
  559. xto0    add.w    d7,xvector(a5)
  560. checky    or.w    d0,d1
  561.     bne    add.vectors2
  562.     moveq    #1,d7
  563.     tst.w    yvector(a5)
  564.     beq    add.vectors2
  565.     bmi    yto0
  566.     neg.w    d7
  567. yto0    add.w    d7,yvector(a5)
  568.  
  569. add.vectors2
  570.     move.w    xpos(a5),d4        finally add the new vectors to
  571.     move.w    ypos(a5),d5        the x & y coordinates
  572.     add.w    xvector(a5),d4
  573.     add.w    yvector(a5),d5
  574.     move.w    d4,xpos(a5)
  575.     move.w    d5,ypos(a5)
  576.     bsr    xytosprite        convert the xy coords into
  577.     move.l    shipaddress(a5),a0    hardware sprite format
  578.     add.w    up.down(a5),a0        add the up/down offset
  579.  
  580.  
  581.     * now set up the four hardware sprite control words
  582.  
  583.     move.l    d0,(a0)            ship 1.1 (rear end)
  584.     bset    #7,d0
  585.     move.l    d0,184(a0)        ship 1.2 with attach bit set
  586.     add.l    #$0b080000,d0        add 11 to vstart & 16 to hstart
  587.     bclr    #7,d0            reset attach bit
  588.     sub.w    #$0b00,d0        vstop is 11 less
  589.     move.l    d0,2*184(a0)        ship 1.3 (front)
  590.     bset    #7,d0            set attach
  591.     move.l    d0,2*184+96(a0)        ship 1.4
  592.     bsr    ship.to.copper        put the address of the current
  593.     subq.w    #1,mult.delay(a5)    ship in the copper
  594.     bne    same.outrider        and finally work out which multiple 
  595.     move.w    #4,mult.delay(a5)    to display
  596.     add.w    d6,mult.number(a5)    outriders must be between
  597.     bne    max.mult        1 & 5
  598.     move.w    #1,mult.number(a5)
  599. max.mult
  600.     cmp.w    #6,mult.number(a5)
  601.     bne    same.outrider
  602.     move.w    #5,mult.number(a5)
  603. same.outrider
  604.     bsr    draw.outrider        draw the multiple into the sprite
  605.     rts
  606.  
  607. **************************************************************************
  608.  
  609. xytosprite
  610. *    d4 = x coordinate
  611. *    d5 = y coordinate
  612. *    returns d0.l as the control words
  613.  
  614.     clr.l    d0            return longword in do
  615.     add.w    #44-11,d5        hardware offset vertical
  616.     lsl.w    #8,d5            into bits 8-15
  617.     add.w    #128,d4            horizontal offset
  618.     lsr.w    #1,d4            /2 low bit into extend
  619.     or.w    d5,d4            X intact
  620.     move.w    d4,d0            X still intact
  621.     swap    d0            ditto
  622.     roxl.w    #1,d0            get low bit of hstart into bit 0
  623.     add.w    #$2c00,d5        calcualate vstop (+44 lines)
  624.     or.w    d5,d0            low word set up
  625.     rts
  626.  
  627. **************************************************************************
  628.  
  629. draw.outrider
  630.     move.w    mult.number(a5),d0    get the animation number
  631.     tst.b    mult1.on(a5)        for the multiple
  632.     bne    mult1ok
  633.     clr.w    d0
  634. mult1ok
  635.     lea    outriders,a0        base address of outriders
  636.     mulu    #44,d0            44 bytes per plane for pair
  637.     add.w    d0,a0
  638.     move.l    a0,a1            a0 = plane 1
  639.     add.w    #264,a1            a1 = plane 2
  640.     move.l    shipaddress(a5),a2    current ship address
  641.     add.w    up.down(a5),a2
  642.     addq    #4,a2            get past sprite header
  643.     movem.l    a0-a2,-(sp)
  644.     moveq    #10,d7            11 lines high
  645. out1    move.w    (a0)+,(a2)+
  646.     move.w    (a1)+,(a2)+
  647.     dbf    d7,out1
  648.     tst.b    mult2.on(a5)
  649.     bne    mult2ok
  650.     lea    outriders,a0        if mult 2 not on then
  651.     move.l    a0,a1            point the data to zeroes
  652. mult2ok
  653.     add.w    #22*2*2,a2        pass the ship graphics
  654.     moveq    #10,d7            and draw the bottom one
  655. out2    move.w    (a0)+,(a2)+
  656.     move.w    (a1)+,(a2)+
  657.     dbf    d7,out2            planes 1 & 2 done
  658.  
  659.     movem.l    (sp)+,a0-a2        get back pointers
  660.     add.w    #528,a0            a0 = plane 3
  661.     add.w    #528,a1            a1 = plane 4
  662.     add.w    #44*4+8,a2        next sprite
  663.     moveq    #10,d7            11 lines high
  664. out3    move.w    (a0)+,(a2)+
  665.     move.w    (a1)+,(a2)+
  666.     dbf    d7,out3
  667.     tst.b    mult2.on(a5)
  668.     bne    mult3ok
  669.     lea    outriders,a0        if mult 2 not on then
  670.     move.l    a0,a1            point the data to zeroes
  671. mult3ok
  672.     add.w    #22*2*2,a2        pass the ship graphics
  673.     moveq    #10,d7            and draw the bottom one
  674. out4    move.w    (a0)+,(a2)+
  675.     move.w    (a1)+,(a2)+
  676.     dbf    d7,out4            planes 3 & 4 done
  677.     rts
  678.  
  679.  
  680. **************************************************************************
  681.  
  682. setup.mouse
  683.     move.w    joy0dat(a6),d4        read the mouse x,y position so
  684.     move.w    d4,-(sp)
  685.     and.w    #$ff,d4            the ship doesnt jump when we
  686.     move.w    d4,oldmousex(a5)    start
  687.     move.w    (sp)+,d4
  688.     lsr.w    #8,d4
  689.     move.w    d4,oldmousey(a5)
  690.     rts
  691.  
  692. joy    move.w    #$0100,d0        setup the mask for each bit in
  693.     move.w    #$0001,d1        the joystick register
  694.     move.w    #$0002,d2        the routine returns left/right
  695.     move.w    #$0200,d3        /up/down in d0..d3
  696.     move.w    joy1dat(a6),d4        if the corresponding data register
  697.     and.w    d4,d0            is not = 0 then the joystick
  698.     and.w    d4,d1            had been pressed in that direction
  699.     and.w    d4,d2
  700.     and.w    d4,d3
  701.     lsl.w    #1,d0
  702.     lsl.w    #1,d1
  703.     eor.w    d2,d1
  704.     eor.w    d3,d0
  705.  
  706.     move.w    joy0dat(a6),d4        read the mouse counters, if a move
  707.     move.w    d4,-(sp)        has been detected then set the
  708.     and.w    #$ff,d4            appropiate joystick registers
  709.     sub.w    oldmousex(a5),d4    to mimick a joystick move
  710.     beq    noxmove
  711.     bmi    leftmove        this is not a proper proportional
  712.     moveq    #1,d2            read but a simple up/dowm/left/right
  713.     bra    noxmove            check
  714. leftmove
  715.     moveq    #1,d3
  716. noxmove    move.w    (sp),d4
  717.     lsr.w    #8,d4
  718.     sub.w    oldmousey(a5),d4
  719.     beq    joyend
  720.     bmi    upmove
  721.     moveq    #1,d1
  722.     bra    joyend
  723. upmove    moveq    #1,d0
  724. joyend    move.w    (sp),d4
  725.     and.w    #$ff,d4
  726.     move.w    d4,oldmousex(a5)    save the mouse values for comparison
  727.     move.w    (sp)+,d4        next time around
  728.     lsr.w    #8,d4
  729.     move.w    d4,oldmousey(a5)
  730.     rts
  731.  
  732. **************************************************************************
  733.  
  734. ship.to.copper
  735.     move.l    shipaddress(a5),a1    get the current ship address
  736.     add.w    up.down(a5),a1        and update the four sprite
  737.     move.l    a1,d0            pointers in the copperlist
  738.     move.l    a1,d1            
  739.     move.l    a1,d2
  740.     move.l    a1,d3    
  741.     add.w    #184,d1            work out the address of each        
  742.     add.w    #184*2,d2        hardware sprite
  743.     add.w    #184*2+96,d3
  744.     lea    sprite(pc),a0
  745.     move.w    d0,6(a0)
  746.     swap    d0
  747.     move.w    d0,2(a0)
  748.     move.w    d1,14(a0)
  749.     swap    d1
  750.     move.w    d1,10(a0)
  751.     move.w    d2,22(a0)
  752.     swap    d2
  753.     move.w    d2,18(a0)
  754.     move.w    d3,30(a0)
  755.     swap    d3
  756.     move.w    d3,26(a0)
  757.     rts
  758.  
  759. **************************************************************************
  760.  
  761. change.ship
  762.     clr.w    d0
  763.     move.b    ship.status(a5),d0    1 = canons, 2 = lasers, 3 = both
  764.     lea    ship1.2(pc),a0
  765.     mulu    #1680,d0        968 bytes for the four sprites
  766.     add.l    d0,a0            per ship
  767.     move.l    a0,shipaddress(a5)    store the ship address
  768.     rts
  769.  
  770. **************************************************************************
  771.  
  772. restorebgnds
  773.     bsr    getscreeninfo
  774.     clr.w    bltamod(a6)
  775.     move.l    d0,bltapt(a6)        set blitter A channel to the saved
  776.     clr.w    bltcon1(a6)        background data
  777. restoreloop
  778.     move.w    (a0)+,d1        fetch the blit size
  779.     beq    return            once zero all have been replaced
  780.     move.w    d1,d3
  781.     addq    #2,a0
  782.     and.w    #$3f,d1            work out the length in bytes
  783.     lsl.w    #1,d1
  784.     move.w    #100,d2            subtract from the screen width
  785.     sub.w    d1,d2            to give the destination modulo
  786.     move.w    d2,bltdmod(a6)
  787.     move.w    #$09f0,bltcon0(a6)    use D = A for the blit
  788.     move.l    (a0)+,bltdpt(a6)    and do all three planes.
  789.     move.w    d3,bltsize(a6)
  790.     move.l    (a0)+,bltdpt(a6)
  791.     move.w    d3,bltsize(a6)
  792.     move.l    (a0)+,bltdpt(a6)
  793.     move.w    d3,bltsize(a6)
  794.     bra    restoreloop
  795.  
  796. savebgnds
  797.     bsr    check.end.screen    watch out for screen wraparound
  798.     bsr    coords.to.pf1offsets    convert pixel coords to byte offsets
  799.     move.w    #aliensize,d3
  800.     move.w    #94,bltamod(a6)
  801.     clr.w    bltdmod(a6)
  802.     clr.w    bltcon1(a6)
  803.     move.w    #$09f0,bltcon0(a6)    use D = A for the blit
  804.     bsr    setup.addresses        save the blitsize and addresses
  805.     bsr    blit.to.buffer        and save the background data
  806.     rts
  807.  
  808. **************************************************************************
  809.  
  810. drawbobs
  811.     move.w    #94,bltdmod(a6)        set up the destination modulos
  812.     move.w    #94,bltcmod(a6)
  813.     clr.l    d6            d6 will hold an offset if the
  814.     tst.b    upsidedown(a5)        bob is drawn upside down
  815.     beq    normal
  816.     move.w    #-106,bltdmod(a6)    draw from the bottom up by using
  817.     move.w    #-106,bltcmod(a6)    a negative modulo
  818.     move.l    #23*100,d6
  819. normal    move.w    (a0),d3            get the blitsize in d3
  820.     move.w    2(a0),d1        the scroll value in d1 (0-15)
  821.     ror.w    #4,d1
  822.     move.w    d1,bltcon1(a6)        set up the B scroll value
  823.     or.w    #$0fca,d1        set up the A scroll value and the
  824.     move.w    d1,bltcon0(a6)        minterm for D = notA.C + B
  825.     move.w    #-2,bltbmod(a6)
  826.     move.w    #-2,bltamod(a6)
  827.     move.l    a1,bltbpt(a6)
  828.     bsr    blit.to.backgnd        draw to the screen
  829.     rts
  830.  
  831. **************************************************************************
  832.  
  833. getscreeninfo
  834. *    returns the address in a0 of the data listing the screeen locations
  835. *    where the backgrounds have to be replaced
  836. *    d0 points to the buffer containing the saved backgrounds
  837.  
  838.     tst.b    screen.num(a5)        double buffering means we have 
  839.     bne    getscreen1        to have two lists running
  840.     move.l    #buffer0,d0
  841.     move.l    #screen0bgnds,a0
  842.     rts
  843. getscreen1
  844.     move.l    #buffer1,d0
  845.     move.l    #screen1bgnds,a0
  846.     rts
  847.  
  848. **************************************************************************
  849.  
  850. process.aliens
  851.     clr.w    all.coords(a5)
  852.     move.l    #path.buffer,a0
  853.     lea    alien.buffer(a5),a1        where to store the info
  854.     moveq    #11,d7                12 aliens max
  855. process.loop
  856.     move.w    table.offset(a0),d0        get offset in d0
  857.     move.b    mode(a0),d6            d6 contains the mode byte
  858.     move.w    x.pos(a0),d1
  859.     beq    finished            alien dead
  860.     clr.w    last.x(a5)
  861.     clr.w    last.y(a5)
  862.     move.w    y.pos(a0),d2
  863.     subq.b    #1,anim.delay(a0)
  864.     bne    same.anim
  865.  
  866.     move.b    num.anims(a0),d3
  867.     beq    same.anim
  868.     btst    #3,d6
  869.     beq    up.only
  870.     btst    #4,d6
  871.     bne    down.anim
  872.     addq.b    #1,anim.num(a0)            increase anim num
  873.     cmp.b    anim.num(a0),d3
  874.     bne    process1
  875.     bchg    #4,d6
  876.     bra    process1
  877. down.anim
  878.     subq.b    #1,anim.num(a0)
  879.     bpl    process1
  880.     move.b    #1,anim.num(a0)
  881.     bchg    #4,d6
  882.     bra    process1
  883. up.only
  884.     addq.b    #1,anim.num(a0)            next animation
  885.     addq.b    #1,d3
  886.     cmp.b    anim.num(a0),d3            wrap around anims
  887.     bne    process1
  888.     clr.b    anim.num(a0)
  889.     tst.b    sprite.num(a0)            was it an explosion
  890.     bne    process1
  891.     clr.w    x.pos(a0)            yes so
  892.     move.w    d1,last.x(a5)            store its coords
  893.     move.w    d2,last.y(a5)
  894.     clr.w    d1                kill this alien
  895.     bra    finished
  896. process1
  897.     move.b    anim.delay2(a0),anim.delay(a0)    restore the delay
  898. same.anim
  899.     tst.b    sprite.num(a0)        
  900.     beq    finished            dont move explosions
  901.     tst.b    pause.count(a0)
  902.     beq    no.pause            no pause 
  903.     cmp.b    #$ff,pause.count(a0)
  904.     beq    finished            ff means pause forever...
  905.     subq.b    #1,pause.count(a0)
  906.     beq    update                if zero update the offset
  907.     bra    finished            not zero so do nufink
  908. no.pause
  909.     clr.w    d3
  910.     clr.w    d4
  911.     clr.w    d5
  912.     move.b    speed(a0),d5            speed in d5
  913.     move.b    0(a0,d0.w),d3            d3 is the x coord to go to
  914.     move.b    1(a0,d0.w),d4            d4 is the y coord to go to
  915.     bsr    check.seek            check all seek bits
  916.     tst.b    sprite.num(a0)
  917.     beq    store.coords            a heat seeker may have exploded
  918.     btst    #0,d6                test for offset mode
  919.     bne    add.offsets
  920.     tst.w    d3                if x goto is minus then
  921.     bmi    check.y                leave x coord alone
  922.     lsl.w    #1,d3                even coord only
  923.     cmp.w    d3,d1                check difference between the 
  924.     sne    x.equal(a5)            two x coords
  925.     beq    check.y
  926.     blt    increase.x            if d1<d3 then increase x
  927.     sub.w    d5,d1                else decrease it
  928.     cmp.w    d3,d1                has it now passed
  929.     bgt    check.y                the x coord
  930.     move.w    d3,d1                if so, make it equal to the x
  931.     sf    x.equal(a5)
  932.     bra    check.y
  933. increase.x
  934.     add.w    d5,d1
  935.     cmp.w    d3,d1
  936.     blt    check.y                is it still less than x
  937.     move.w    d3,d1
  938.     sf    x.equal(a5)
  939. check.y    tst.w    d4
  940.     bmi    store.coords            check wether to leave y alone
  941.     lsl.w    #1,d4                
  942.     cmp.w    d4,d2                compares d2 to d4
  943.     sne    y.equal(a5)
  944.     beq    store.coords
  945.     blt    increase.y            if d2<d4 then increase y
  946.     sub.w    d5,d2
  947.     cmp.w    d4,d2
  948.     bgt    store.coords
  949.     move.w    d4,d2
  950.     sf    y.equal(a5)
  951.     bra    store.coords
  952. increase.y
  953.     add.w    d5,d2
  954.     cmp.w    d4,d2
  955.     blt    store.coords
  956.     move.w    d4,d2
  957.     sf    y.equal(a5)
  958.     bra    store.coords
  959.  
  960. add.offsets
  961.     ext.w    d3
  962.     ext.w    d4
  963.     add.w    d3,d1                add the offsets
  964.     add.w    d4,d2
  965.     clr.b    x.equal(a5)            signal to update table
  966.     clr.b    y.equal(a5)
  967.  
  968. store.coords
  969.     move.w    d1,x.pos(a0)            restore the new coords
  970.     move.w    d2,y.pos(a0)
  971.     move.b    x.equal(a5),d3
  972.     or.b    d3,y.equal(a5)            is the alien there
  973.     bne    finished            no, so dont update the table
  974.     btst    #5,d6                heat seeker ?
  975.     beq    update
  976. ;    bsr    explode.alien            heat seekers explode when they
  977.     bra    finished            hit their target
  978. update
  979.     btst    #1,d6                check for seek mode
  980.     beq    new.offset
  981.     bsr    copy.coords
  982.     subq.b    #1,seek.count(a0)
  983.     bne    finished
  984.     bclr    #1,d6                reset seek mode
  985. new.offset
  986.     addq.w    #2,d0
  987.     move.w    d0,table.offset(a0)        new offset
  988.     tst.w    0(a0,d0.w)
  989.     beq    path.finished            path finished, so branch
  990.     move.b    0(a0,d0.w),d4            get code in d4 & d3
  991.     move.w    d4,d3
  992.     and.w    #$f0,d4                get upper 4 bits
  993.     cmp.w    #$e0,d4                hex E for a code
  994.     bne    finished            no code so carry on
  995.     and.w    #$f,d3                otherwise get code number in d3
  996.     lsl.w    #2,d3                x4
  997.     lea    vector.table(pc),a2        get table base
  998.     move.l    0(a2,d3.w),a2            get routine address in a2
  999.     jmp    (a2)                and jump to it
  1000.  
  1001. vector.table
  1002.     dc.l    init.pause
  1003.     dc.l    loop.back
  1004.     dc.l    toggle.offset
  1005.     dc.l    change.speed
  1006.     dc.l    change.sprite
  1007.     dc.l    seek.mode
  1008.     dc.l    reload.coords
  1009.     dc.l    new.table
  1010.     dc.l    restore.offset
  1011.     dc.l    fire.heatseeker
  1012.     dc.l    change.anim
  1013.     dc.l    restart.table
  1014.     dc.l    start.xy
  1015.     dc.l    start.seekx
  1016.     dc.l    start.seeky
  1017.     dc.l    return                16 codes maximum
  1018.  
  1019. finished                    
  1020.     or.w    d1,all.coords(a5)
  1021.     move.w    d1,(a1)+            
  1022.     move.w    d2,(a1)+            store it all in the 
  1023.     move.b    sprite.num(a0),(a1)+        buffer
  1024.     move.b    anim.num(a0),(a1)+
  1025.     move.b    d6,mode(a0)            save the mode byte
  1026.     add.w    next.path(a0),a0
  1027.     dbf    d7,process.loop
  1028.     rts
  1029.  
  1030. path.finished
  1031.     clr.w    d1                make x = 0
  1032.     clr.w    x.pos(a0)
  1033.     btst    #2,d6
  1034.     seq     no.bonus(a5)
  1035.     bra    finished
  1036.  
  1037. check.seek
  1038.     btst    #6,d6                bit 6 for seek on ship x
  1039.     beq    check.seeky
  1040.     st    y.equal(a5)            make sure it never updates table
  1041.     move.w    xpos(a5),d3            get new x coord to goto
  1042.     moveq    #-1,d4                signal to leave y alone
  1043.     add.w    #54,d3                hardware sprite offset
  1044.     lsr.w    #1,d3                even coords only
  1045.     subq.b    #1,seek.count(a0)        check count
  1046.     bne    check.seeky
  1047.     bclr    #6,d6                reset if count zero
  1048. check.seeky
  1049.     btst    #7,d6                bit 7 for seek on ship y
  1050.     beq    check.heat
  1051.     st    x.equal(a5)            make sure it never updates table
  1052.     move.w    ypos(a5),d4            get new y coord to goto
  1053.     moveq    #-1,d3                signal to leave x alone
  1054.     add.w    #14,d4                hardware sprite offset
  1055.     lsr.w    #1,d4                even coords only
  1056.     subq.b    #1,seek.count(a0)        check count
  1057.     bne    check.heat
  1058.     bclr    #7,d6                reset if count zero
  1059. check.heat
  1060.     btst    #5,d6                bit 5 for a heat seeking mine
  1061.     beq    return                all finished
  1062.     move.w    xpos(a5),d3            get new x coord to goto
  1063.     move.w    ypos(a5),d4            get new y coord to goto
  1064.     add.w    #56,d3                hardware sprite offset
  1065.     add.w    #16,d4                hardware sprite offset
  1066.     lsr.w    #1,d3                even coords only
  1067.     lsr.w    #1,d4                even coords only
  1068.     subq.b    #1,seek.count(a0)        check count
  1069.     bne    return
  1070. ;    bsr    explode.alien            kill mine if count zero
  1071.     rts
  1072.  
  1073. init.pause
  1074.     move.b    1(a0,d0.w),pause.count(a0)    setup the pause
  1075.     bra    finished
  1076.  
  1077. loop.back
  1078.     clr.w    d3
  1079.     move.b    loop.offset(a0),d3        get the loop offset in words
  1080.     lsl.w    #1,d3                convert to bytes
  1081.     subq.b    #1,loop.count(a0)        reduce the loop counter
  1082.     beq    update
  1083.     sub.w    d3,table.offset(a0)        and work out the new path PC
  1084.     bra    finished
  1085.  
  1086. toggle.offset
  1087.     bchg    #0,d6                start or end offset mode
  1088.     bra    update                get the next path value
  1089.                 
  1090. seek.mode
  1091.     bset    #1,d6                set the seek mode bit
  1092.     move.b    1(a0,d0.w),seek.count(a0)    copy the count
  1093.     addq.w    #2,d0
  1094.     move.w    d0,table.offset(a0)
  1095.     bsr    copy.coords
  1096.     bra    finished
  1097.  
  1098. start.seekx
  1099.     bset    #6,d6                set the seek on X bit
  1100.     move.b    1(a0,d0.w),seek.count(a0)    copy the count
  1101.     addq.w    #2,d0
  1102.     move.w    d0,table.offset(a0)
  1103.     bra    finished
  1104.  
  1105. start.seeky
  1106.     bset    #7,d6                set the seek on Y bit
  1107.     move.b    1(a0,d0.w),seek.count(a0)    copy the count
  1108.     addq.w    #2,d0
  1109.     move.w    d0,table.offset(a0)
  1110.     bra    finished
  1111.  
  1112. copy.coords
  1113.     move.w    xpos(a5),d3            copy the ship coords
  1114.     move.w    ypos(a5),d4            for the seek functions
  1115.     add.w    #54,d3                into the path table
  1116.     add.w    #14,d4
  1117.     lsr.w    #1,d3
  1118.     lsr.w    #1,d4
  1119.     move.b    d3,0(a0,d0.w)
  1120.     move.b    d4,1(a0,d0.w)
  1121.     rts
  1122.  
  1123. change.speed
  1124.     move.b    1(a0,d0.w),speed(a0)        copy the new speed byte
  1125.     bra    update
  1126.  
  1127. change.sprite
  1128.     addq.w    #2,d0
  1129.     move.b    0(a0,d0.w),sprite.num(a0)    new sprite number
  1130.     move.b    1(a0,d0.w),num.anims(a0)    new max anims
  1131.     clr.b    anim.num(a0)            
  1132.     move.b    anim.delay2(a0),anim.delay(a0)    new anim delay
  1133.     bra    update
  1134.  
  1135. reload.coords
  1136.     addq    #2,d0
  1137.     clr.w    d1                copy a new x,y position
  1138.     clr.w    d2                into the sprite structure
  1139.     move.b    0(a0,d0.w),d1    
  1140.     move.b    1(a0,d0.w),d2
  1141.     lsl.w    #1,d1
  1142.     lsl.w    #1,d2
  1143.     move.w    d1,x.pos(a0)
  1144.     move.w    d2,y.pos(a0)
  1145.     bra    update    
  1146.  
  1147. new.table
  1148.     addq.w    #2,d0                setup a new path PC
  1149.     move.w    d0,d4                saving the old one in the
  1150.     move.b    d4,loop.offset+1(a0)        loop.offset word
  1151.     lsr.w    #8,d4
  1152.     move.b    d4,loop.offset(a0)
  1153.     move.w    0(a0,d0.w),d0
  1154.     subq.w    #2,d0
  1155.     bra    new.offset
  1156.  
  1157. restore.offset
  1158.     move.b    loop.offset(a0),d0        restore the old path PC
  1159.     lsl.w    #8,d0
  1160.     move.b    loop.offset+1(a0),d0
  1161.     bra    new.offset
  1162.  
  1163. fire.heatseeker
  1164.     move.l    #path.buffer,a2            start a new path at the
  1165.     moveq    #11,d5                present paths x,y coord
  1166.     addq    #2,d0
  1167. heat1    btst    #5,mode(a2)            only if a free path entry
  1168.     beq    heat2                can be found
  1169.     tst.w    x.pos(a2)
  1170.     bne    heat2
  1171.     move.w    d1,x.pos(a2)
  1172.     move.w    d2,y.pos(a2)
  1173.     move.b    0(a0,d0.w),seek.count(a2)
  1174.     move.b    1(a0,d0.w),hits.num(a2)
  1175.     move.b    #2,sprite.num(a2)
  1176.     move.b    #2,anim.delay(a2)
  1177.     clr.b    anim.num(a2)
  1178.     move.b    #3,num.anims(a2)
  1179.     bra    new.offset
  1180. heat2    add.w    (a2),a2
  1181.     dbf    d5,heat1
  1182.     bra    new.offset
  1183.  
  1184. change.anim
  1185.     move.b    1(a0,d0.w),anim.num(a0)        new animation number
  1186.     bra    new.offset
  1187.  
  1188. restart.table
  1189.     move.w    #table.size-2,d0        restart the path from the
  1190.     bra    update                beginning
  1191.  
  1192. start.xy
  1193.     move.b    1(a0,d0.w),d4            get path number to start
  1194.     subq.b    #2,d4                cant use path 0
  1195.     move.l    a0,-(sp)            save path pointer
  1196.     move.l    #path.buffer,a0
  1197. find.num
  1198.     add.w    next.path(a0),a0
  1199.     dbf    d4,find.num            get the path
  1200.     move.w    d1,x.pos(a0)            new one starts at present x & y
  1201.     move.w    d2,y.pos(a0)
  1202.     move.w    d1,d4
  1203.     lsr.w    #1,d4
  1204.     move.b    d4,table.size(a0)        set up the first xy coord to
  1205.     move.w    d2,d4                goto. Must be the same as
  1206.     lsr.w    #1,d4                the present xy
  1207.     move.b    d4,table.size+1(a0)
  1208.     move.w    #table.size,table.offset(a0)    start of path
  1209.     move.b    #128,hits.num(a0)        indistrutable
  1210.     move.b    #2,anim.delay(a0)
  1211.     clr.b    pause.count(a0)
  1212.     clr.b    anim.num(a0)            reset anim info
  1213.     move.l    (sp)+,a0
  1214.     bra    new.offset
  1215.  
  1216. **************************************************************************
  1217.  
  1218. save.aliens
  1219.     lea    alien.buffer+66(a5),a4        the buffer contains
  1220.     moveq    #11,d7                word x-cord
  1221.     bsr    getscreeninfo            word y-cord
  1222. save.alien1                    
  1223.     move.w    (a4),d1                byte sprite number
  1224.     beq    save.next            byte animation number
  1225.     move.w    2(a4),d2
  1226.     bsr    savebgnds
  1227. save.next
  1228.     subq    #6,a4
  1229.     dbf    d7,save.alien1
  1230.     rts
  1231.  
  1232. **************************************************************************
  1233.  
  1234. draw.aliens
  1235.     clr.w    bltalwm(a6)
  1236.     moveq    #11,d7
  1237.     bsr    getscreeninfo
  1238.     lea    alien.buffer+66(a5),a4        work DOWN through
  1239. draw.alien2
  1240.     tst.w    (a4)                the buffer so that the first
  1241.     beq    draw.next2            sprite is drawn first and
  1242.     clr.w    d1                therefore hit first.
  1243.     clr.w    d2
  1244.     move.b    4(a4),d1            d1 = sprite number
  1245.     bclr    #7,d1
  1246.     sne    upsidedown(a5)
  1247.     move.b    5(a4),d2            d2 = animation number
  1248.     move.l    #alien.pointers,a1
  1249.     move.w    level.number(a5),d3
  1250.     mulu    #24*4,d3
  1251.     ext.l    d3
  1252.     add.l    d3,a1
  1253.     lsl.w    #2,d1
  1254.     add.w    d1,a1
  1255.     move.l    (a1),a1                get the sprite pointer in a1
  1256.     mulu    #384,d2                from the lookup table
  1257.     ext.l    d2                and then work out the animation
  1258.     add.l    d2,a1                number address
  1259.     move.l    a1,a2
  1260.     add.w    #288,a2                a2 = mask address
  1261.     bsr    drawbobs
  1262. draw.next2
  1263.     subq    #6,a4
  1264.     dbf    d7,draw.alien2
  1265.     move.w    #$ffff,bltalwm(a6)
  1266.     rts    
  1267.     
  1268. **************************************************************************
  1269.  
  1270. blit.to.backgnd
  1271.     addq    #4,a0            skip the hidden words
  1272.     move.l    (a0)+,d5        get the screen offset
  1273.     add.l    d6,d5
  1274.     move.l    d5,bltcpt(a6)        setup the screen pointers
  1275.     move.l    d5,bltdpt(a6)
  1276.     move.l    a2,bltapt(a6)        setup the bob mask
  1277.     move.w    d3,bltsize(a6)        and blit the bob to the screen
  1278.     move.l    (a0)+,d5
  1279.     add.l    d6,d5
  1280.     move.l    d5,bltcpt(a6)
  1281.     move.l    d5,bltdpt(a6)
  1282.     move.l    a2,bltapt(a6)
  1283.     move.w    d3,bltsize(a6)        plane 2
  1284.     move.l    (a0)+,d5
  1285.     add.l    d6,d5
  1286.     move.l    d5,bltcpt(a6)
  1287.     move.l    d5,bltdpt(a6)
  1288.     move.l    a2,bltapt(a6)
  1289.     move.w    d3,bltsize(a6)        plane 3
  1290.     rts
  1291.  
  1292. **************************************************************************
  1293.  
  1294. blit.to.buffer
  1295.     tst.l    d6            copy the background where a 
  1296.     beq    no.blit            bob  is to be drawn into
  1297.     move.l    d0,bltdpt(a6)        the buffer
  1298.     addq    #4,a0
  1299.     move.l    (a0)+,bltapt(a6)
  1300.     move.w    d3,bltsize(a6)
  1301.     move.l    (a0)+,bltapt(a6)
  1302.     move.w    d3,bltsize(a6)
  1303.     addq    #4,a0
  1304. no.blit    clr.w    (a0)
  1305.     add.l    #3*6*24,d0
  1306.     rts
  1307.  
  1308. **************************************************************************
  1309.  
  1310. coords.to.pf1offsets    
  1311. *    convert the x,y coordinate in d1,d2 into a byte offset
  1312. *    in d1 and a scroll offset (0-15) in d2
  1313.             
  1314.     add.w    #16,d1
  1315.     sub.w    pf1scroll2(a5),d1        d2 = y coord
  1316.     mulu    #100,d2                d1 = x coord
  1317.     swap    d2
  1318.     move.w    d1,d2
  1319.     and.w    #$f,d2
  1320.     swap    d2
  1321.     lsr.w    #3,d1
  1322.     add.w    d2,d1
  1323.     swap    d2                d2 = scroll value
  1324.     ext.l    d1                d1 = offset
  1325.     rts
  1326.  
  1327. **************************************************************************
  1328.  
  1329. coords.to.pf2offsets
  1330. *    As the above routine but for the front playfield which is only
  1331. *    92 bytes wide
  1332.  
  1333.     sub.w    pf2scroll(a5),d1
  1334.     mulu    #92,d2
  1335.     swap    d2
  1336.     move.w    d1,d2
  1337.     and.w    #$f,d2
  1338.     swap    d2
  1339.     lsr.w    #3,d1
  1340.     add.w    d2,d1
  1341.     swap    d2
  1342.     ror.w    #4,d2
  1343.     add.w    pf2offset(a5),d1
  1344.     ext.l    d1
  1345.     rts
  1346.  
  1347. **************************************************************************
  1348.  
  1349. setup.addresses
  1350. *    setup the list of addresses to which bobs are to be blitted
  1351.  
  1352.     move.w    d3,(a0)                d3 = blitsize
  1353.     move.w    d2,2(a0)            d2 = scroll value
  1354.     move.l    (a2),d6                d1 = offset
  1355.     add.l    d1,d6                stores the addresses
  1356.     cmp.l    4(a0),d6
  1357.     beq    dont.save
  1358.     move.l    d6,4(a0)            without updating the
  1359.     move.l    4(a2),d6            pointer
  1360.     add.l    d1,d6
  1361.     move.l    d6,8(a0)
  1362.     move.l    8(a2),d6
  1363.     add.l    d1,d6
  1364.     move.l    d6,12(a0)
  1365.     rts
  1366. dont.save
  1367.     clr.l    d6
  1368.     add.w    #16,a0
  1369.     rts
  1370.  
  1371. **************************************************************************
  1372.  
  1373. check.end.screen
  1374.     tst.w    screenend(a5)
  1375.     bne    notend
  1376.     lea    rasters(a5),a2
  1377.     move.w    #16,pf1scroll2(a5)
  1378.     rts
  1379. notend    lea    displayraster(a5),a2
  1380.     move.w    pf1scroll(a5),pf1scroll2(a5)
  1381.     rts
  1382.  
  1383. **************************************************************************
  1384.  
  1385. check.path
  1386.     tst.w    all.coords(a5)        wait until all the x coords are 0 
  1387.     bne    check.end        before a new path can start
  1388.     not.b    bonus.delay(a5)
  1389.     bne    check.end        a small delay before the bonus
  1390.     tst.b    last.path(a5)        path can start
  1391.     bne    start.path
  1392.     clr.b    bonus.mode(a5)
  1393.     move.w    last.x(a5),d1
  1394.     beq    start.path        if all the aliens had been killed
  1395.     tst.b    no.bonus(a5)        then we will start the bonus path
  1396.     bne    start.path
  1397.     move.w    #10,path.delay(a5)
  1398.     move.w    last.y(a5),d2
  1399.     lea    paths,a0
  1400.     st    bonus.mode(a5)
  1401.     clr.w    bonus.num(a5)
  1402.     move.w    #5,bonus.count(a5)    setup the bonus path coordinates
  1403.     move.w    d1,x.pos+2(a0)
  1404.     move.w    d2,y.pos+2(a0)
  1405.     clr.b    anim.num+2(a0)
  1406.     lsr.w    #1,d2
  1407.     move.w    #$0200,d1
  1408.     or.w    d2,d1
  1409.     move.w    d1,table.size+2(a0)
  1410.     bra    copy.path    
  1411. check.end
  1412.     rts
  1413.  
  1414. start.path
  1415.     cmp.w    #1,level.end(a5)    start a new path, providing
  1416.     beq    return            the guardian is not scrolling on
  1417.     cmp.w    #2,level.end(a5)
  1418.     beq    return
  1419.     subq.w    #1,path.delay(a5)
  1420.     beq    start.path1
  1421.     rts
  1422. start.path1
  1423.     move.w    #10,path.delay(a5)    start a normal path
  1424.     move.w    path.number(a5),d0
  1425.     lea    paths,a0
  1426.     add.w    d0,a0
  1427.     move.l    (a0),d1
  1428.     bne    start1
  1429.     moveq    #4,d0
  1430.     lea    paths,a0
  1431.     move.l    4(a0),d1
  1432. start1
  1433.     addq    #4,d0
  1434.     move.w    d0,path.number(a5)
  1435.     move.l    d1,a0
  1436. copy.path
  1437.     clr.w    d0            copy the new path data
  1438.     lea    colours(pc),a2        and set up the new alien colours
  1439.     move.b    sprite.num+2(a0),d0        get sprite num
  1440.     and.b    #$7f,d0
  1441.     subq.w    #1,d0
  1442.     lea    alien.colours(pc),a1        get colour table
  1443.     move.w    level.number(a5),d3
  1444.     mulu    #384,d3    
  1445.     add.w    d3,a1
  1446.     lsl.w    #4,d0                16 bytes per alien
  1447.     add.w    d0,a1
  1448.     move.w    (a1)+,2(a2)            copy 8 colours
  1449.     move.w    (a1)+,6(a2)            
  1450.     move.w    (a1)+,10(a2)            
  1451.     move.w    (a1)+,14(a2)            
  1452.     move.w    (a1)+,18(a2)            
  1453.     move.w    (a1)+,22(a2)
  1454.     move.w    (a1)+,26(a2)
  1455.     move.w    (a1)+,30(a2)
  1456.     move.w    (a0)+,d0
  1457.     move.l    #path.buffer,a1
  1458.     lsr.w    #2,d0
  1459. copyloop
  1460.     move.l    (a0)+,(a1)+
  1461.     dbf    d0,copyloop
  1462.     clr.b    no.bonus(a5)
  1463.     rts
  1464.  
  1465. **************************************************************************
  1466.  
  1467.  
  1468. clist        DC.W    $0A01,$FF00
  1469. copperlist    DC.W    bplpt+0,$0000,bplpt+2,$0000
  1470.         DC.W    bplpt+8,$0000,bplpt+10,$0000
  1471.         DC.W    bplpt+16,$0000,bplpt+18,$0000
  1472.         DC.W    bplpt+4,$0000,bplpt+6,$0000
  1473.         DC.W    bplpt+12,$0000,bplpt+14,$0000
  1474.         DC.W    bplpt+20,$0000,bplpt+22,$0000
  1475.         DC.W    bplcon0,$6600
  1476. scroll.value    DC.W    bplcon1,$00FF,bpl1mod,$0036
  1477.         DC.W    bpl2mod,$002E,bplcon2,$0044
  1478.         DC.W    ddfstrt,$0028,ddfstop,$00D8
  1479.         DC.W    diwstrt,$1F78,diwstop,$FFC6
  1480. colours        DC.W    color+0,$0000,color+2,$0000
  1481.         DC.W    color+4,$0000,color+6,$0000
  1482.         DC.W    color+8,$0000,color+10,$0000
  1483.         DC.W    color+12,$0000,color+14,$0000
  1484.         DC.W    color+16,$0000,color+18,$0000
  1485.         DC.W    color+20,$0000,color+22,$0000
  1486.         DC.W    color+24,$0000,color+26,$0000
  1487.         DC.W    color+28,$0000,color+30,$0000
  1488.         DC.W    color+32,$0000,color+34,$0000
  1489.         DC.W    color+36,$0000,color+38,$0000
  1490.         DC.W    color+40,$0000,color+42,$0000
  1491.         DC.W    color+44,$0000,color+46,$0000
  1492.         DC.W    color+48,$0000,color+50,$0000
  1493.         DC.W    color+52,$0000,color+54,$0000
  1494.         DC.W    color+56,$0000,color+58,$0000
  1495.         DC.W    color+60,$0000,color+62,$0000
  1496.  
  1497. sprite        DC.W    sprpt+0,$0000,sprpt+2,$0000
  1498.         DC.W    sprpt+4,$0000,sprpt+6,$0000
  1499.         DC.W    sprpt+8,$0000,sprpt+10,$0000
  1500.         DC.W    sprpt+12,$0000,sprpt+14,$0000
  1501.         DC.W    sprpt+16,$0000,sprpt+18,$0000
  1502.         DC.W    sprpt+20,$0000,sprpt+22,$0000
  1503.         DC.W    sprpt+24,$0000,sprpt+26,$0000
  1504.         DC.W    sprpt+28,$0000,sprpt+30,$0000
  1505.  
  1506.         DC.W    $DF01,$FF00
  1507.         DC.W    bplcon1,$0000,bplcon0,$4200,ddfstrt,$0030
  1508. rastersplit2    DC.W    bplpt+0,$0000,bplpt+2,$0000
  1509.         DC.W    bplpt+4,$0000,bplpt+6,$0000
  1510.         DC.W    bplpt+8,$0000,bplpt+10,$0000
  1511.         DC.W    bplpt+12,$0000,bplpt+14,$0000
  1512. colours2    DC.W    color+20,$0000,color+30,$0000
  1513.         DC.W    color+2,$0000,color+4,$0000
  1514.         DC.W    color+6,$0000,color+8,$0000
  1515.         DC.W    color+10,$0000,color+12,$0000
  1516.         DC.W    color+14,$0000,color+16,$0000
  1517.         DC.W    color+18,$0000,color+22,$0000
  1518.         DC.W    color+24,$0000,color+26,$0000
  1519.         DC.W    color+28,$0000,color+0,$0000
  1520.         DC.W    bpl1mod,$0000,bpl2mod,$0000
  1521.         DC.W    $DF01,$FF00,intreq,$8010
  1522.         DC.W    $FFFF,$FFFE
  1523.  
  1524.  
  1525. panel.colours    DC.W    $0600,$0333,$0fb3,$0d00,$0b00,$0720,$0fc2,$0c90
  1526.         DC.W    $0a40,$0eb0,$0eca,$0456,$0577,$0252,$0444,$0000
  1527.  
  1528.     rsreset
  1529. screen.num    RS.B    1    
  1530. vcount        RS.B    1    vertical blank counter
  1531. mult1.on    RS.B    1    byte set if a multiple is attached to ship
  1532. mult2.on    RS.B    1    same for another multiple (2 max)
  1533. canons.on    RS.B    1    bytes are set to signify what weapons
  1534. lasers.on    RS.B    1    are attached
  1535. ship.status    RS.B    1    values to indicate which ship to draw
  1536.  
  1537. ship.speed    RS.W    1    speed in pixels
  1538. xpos        RS.W    1    ship x position
  1539. ypos        RS.W    1    ship y position
  1540. mult.number    RS.W    1    multiple animation number
  1541. mult.delay    RS.W    1    multiple animation delay
  1542. xvector        RS.W    1    inertia vectors for the ship
  1543. yvector        RS.W    1
  1544. oldmousex    RS.W    1    store the old mouse values to reference
  1545. oldmousey    RS.W    1    the new ones to
  1546. up.down        RS.W    1    this holds the graphic offset for a ship tilt
  1547.  
  1548. pf1count    RS.W    1    number of background words to scroll
  1549. pf2count    RS.W    1    number of foreground words to scroll
  1550. pf1scroll    RS.W    1    pixel scroll value (0-15) background
  1551. pf2scroll    RS.W    1    pixel scroll value (0-15) foreground
  1552. pf1scroll2    RS.W    1
  1553. pf2offset    RS.W    1
  1554. screenend    RS.W    1
  1555. level.end    RS.W    1
  1556. level.number    RS.W    1
  1557.  
  1558. path.delay    RS.W    1
  1559. last.x        RS.W    1
  1560. last.y        RS.W    1
  1561. path.number    RS.W    1
  1562. all.coords    RS.W    1
  1563. x.equal        RS.B    1
  1564. y.equal        RS.B    1
  1565. upsidedown    RS.B    1
  1566. no.bonus    RS.B    1
  1567. last.path    RS.B    1
  1568. bonus.mode    RS.B    1
  1569. bonus.num    RS.W    1
  1570. bonus.count    RS.W    1
  1571. bonus.delay    RS.B    1
  1572.  
  1573. fgndpointer    RS.L    1    foreground map pointer
  1574. displayraster    RS.L    6    holds the addresses of the planes
  1575. rasters     RS.L    9    updated plane addresses
  1576. shipaddress    RS.L    1    ship animation address
  1577. alien.buffer    RS.L    18
  1578.  
  1579. vars.length    RS.B    0
  1580. variables    DS.B    vars.length
  1581.  
  1582. *        *********************************
  1583. *        *    Data structures        *
  1584. *        *********************************
  1585.  
  1586.     rsreset
  1587. next.path    RS.W    1            offset to the next path
  1588. x.pos        RS.W    1            current x position
  1589. y.pos        RS.W    1            current y position
  1590. kills.what    RS.W    1            kills others if dead (0-11)
  1591. table.offset    RS.W    1            the current table offset
  1592. sprite.num    RS.B    1            sprite number
  1593. anim.num    RS.B    1            animation number
  1594. anim.delay    RS.B    1            delay in 1/25 secs
  1595. anim.delay2    RS.B    1            static delay
  1596. speed        RS.B    1            speed in pixels
  1597. pause.count    RS.B    1            dynamic pause counter
  1598. mode        RS.B    1            flags, see bleow
  1599. loop.offset    RS.B    1            loop offset (-ve)
  1600. loop.count    RS.B    1            dynamic loop count
  1601. hits.num    RS.B    1            number of hits to kill
  1602. num.anims    RS.B    1            no of animations
  1603. seek.count    RS.B    1            dynamic seek count
  1604. table.size    RS.B    0
  1605.  
  1606. * This is followed by x,y bytes to move to (always even) with the following
  1607. * special codes
  1608.  
  1609. *    x = 0, path finished, terminate alien
  1610. *    x = $e0, perform a pause (up to 10 secs), followed by the pause value, $ff forever
  1611. *    x = $e1, perform the loop
  1612. *    x = $e2, toggle the offset mode
  1613. *    x = $e3, speed change, followed by new speed byte
  1614. *    x = $e4, sprite change, followed by sprite num, max anims
  1615. *    x = $e5, start seek mode, followed by count & two 0 bytes
  1616. *    x = $e6, reload the aliens x,y coords, followed by two xy bytes
  1617. *    x = $e7, reload the table offset, old one stored in loop.offset
  1618. *    x = $e8, restore the old table offset
  1619. *    x = $e9, fire a heat seeker, followed by count
  1620. *    x = $ea, new animation number, followed by animation number
  1621. *    x = $eb, repeat table indefinitely
  1622.  
  1623. *    mode bit 0 = offset mode
  1624. *         bit 1 = seek mode
  1625. *         bit 2 = 
  1626. *         bit 3 = up/down animation type
  1627. *         bit 4 = 0-animate up/1-animate down
  1628. *         bit 5 = heat seeker path
  1629.  
  1630.  
  1631. backgroundtable    DC.W    $0123,$0123,$0123,$0123,$0123,$0123 background
  1632.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567 map
  1633.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  1634.         DC.W    $0123,$0123,$0123,$0123,$0123,$0123
  1635.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567
  1636.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  1637.         DC.W    $0123,$0123,$0123,$0123,$0123,$0123
  1638.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567
  1639.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  1640.         DC.W    $0123,$0123,$0123,$0123,$0123,$0123
  1641.         DC.W    $4567,$4567,$4567,$4567,$4567,$4567
  1642.         DC.W    $89AB,$89AB,$89AB,$89AB,$89AB,$89AB
  1643.  
  1644. backgrounds    DC.W  $1430,$0C30,$0C10,$0413,$8403,$4442,$2142,$3120
  1645.         DC.W  $3110,$2810,$141C,$1417,$140B,$0C71,$0A00,$DC08
  1646.         DC.W  $8A08,$9208,$0229,$8208,$4244,$2221,$12A1,$0891
  1647.         DC.W  $0888,$148A,$0A03,$2A48,$8A44,$9208,$8524,$2204
  1648.  
  1649.         DC.W  $0210,$0230,$1118,$0118,$8128,$414C,$314C,$10CA
  1650.         DC.W  $1005,$1013,$5103,$31C3,$5023,$D011,$3018,$6304
  1651.         DC.W  $0129,$0908,$0884,$0884,$4294,$22A2,$08A2,$0825
  1652.         DC.W  $0842,$0908,$2880,$C824,$2890,$2808,$0904,$1092
  1653.  
  1654.         DC.W  $0300,$4220,$0461,$0451,$0850,$08C8,$38C8,$1848
  1655.         DC.W  $0848,$0848,$0848,$08C8,$0148,$1050,$E060,$4041
  1656.         DC.W  $2084,$2110,$2210,$0228,$0429,$1424,$0424,$0424
  1657.         DC.W  $8424,$8424,$8424,$8424,$80A4,$8828,$1011,$2420
  1658.  
  1659.         DC.W  $1430,$0C08,$0800,$0413,$8083,$4442,$2242,$2120
  1660.         DC.W  $2110,$2810,$040C,$1487,$104B,$0C71,$0A10,$D908
  1661.         DC.W  $8A08,$9000,$042D,$8008,$4244,$2221,$1121,$0091
  1662.         DC.W  $0888,$048A,$0A03,$2240,$8220,$9208,$8124,$2004
  1663.  
  1664.         DC.W  $7028,$6218,$8218,$C208,$C210,$C210,$6420,$2420
  1665.         DC.W  $4820,$4820,$8843,$0882,$108C,$2118,$2220,$4421
  1666.         DC.W  $0914,$1104,$4104,$2504,$2508,$2508,$9250,$1250
  1667.         DC.W  $2450,$2410,$4420,$8441,$0840,$1080,$1110,$A210
  1668.  
  1669.         DC.W  $C60C,$C60A,$4609,$2209,$A201,$A223,$9011,$901F
  1670.         DC.W  $900C,$8C18,$0620,$060F,$0213,$0404,$1405,$1419
  1671.         DC.W  $2102,$2105,$2104,$5104,$5124,$5110,$4908,$4900
  1672.         DC.W  $4902,$4204,$8912,$0900,$2508,$0212,$4A02,$EA04
  1673.  
  1674.         DC.W  $0080,$0100,$0110,$0918,$0A14,$0A33,$8A31,$0621
  1675.         DC.W  $0220,$8204,$8204,$860D,$860A,$8A0C,$0108,$0101
  1676.         DC.W  $4940,$0888,$8888,$8484,$852A,$8508,$4508,$8110
  1677.         DC.W  $4911,$4902,$490A,$4102,$4905,$4502,$8084,$9088
  1678.  
  1679.         DC.W  $7028,$4318,$8298,$C248,$8250,$C210,$6120,$20A0
  1680.         DC.W  $5820,$4820,$8813,$188A,$108C,$2100,$2220,$4421
  1681.         DC.W  $0914,$1004,$4144,$2504,$4528,$2528,$9290,$1010
  1682.         DC.W  $2010,$2410,$4428,$8405,$0842,$1080,$1100,$A210
  1683.  
  1684.         DC.W  $8820,$0440,$0204,$1202,$8221,$8220,$8300,$8410
  1685.         DC.W  $C080,$0180,$20C0,$6040,$7060,$31A1,$2820,$2820
  1686.         DC.W  $4410,$8A24,$0122,$8921,$4910,$4110,$4090,$4208
  1687.         DC.W  $2448,$8048,$1020,$1220,$0910,$0850,$9492,$1412
  1688.  
  1689.         DC.W  $CE02,$4A02,$5402,$0442,$0844,$9048,$E148,$4150
  1690.         DC.W  $23A0,$31C4,$3185,$3842,$2820,$11A0,$23A0,$6322
  1691.         DC.W  $0101,$2501,$2A01,$9221,$9422,$68A4,$10A4,$A0A8
  1692.         DC.W  $1050,$0822,$0842,$04A1,$1412,$8850,$5051,$1091
  1693.  
  1694.         DC.W  $3100,$11C0,$10C1,$10E1,$4862,$8850,$9850,$88F0
  1695.         DC.W  $E830,$7031,$0028,$8248,$4088,$4018,$2018,$3018
  1696.         DC.W  $0881,$0821,$0820,$0810,$2411,$5429,$44A9,$4408
  1697.         DC.W  $0408,$0808,$8114,$4124,$2144,$2104,$1224,$0844
  1698.  
  1699.         DC.W  $C820,$4440,$2204,$1002,$8225,$8224,$8308,$8418
  1700.         DC.W  $C980,$1188,$20C4,$6040,$6260,$2121,$2820,$2820
  1701.         DC.W  $0410,$AA24,$1122,$8921,$4912,$0110,$4094,$4380
  1702.         DC.W  $2448,$8844,$1020,$1220,$0110,$0850,$9492,$1412
  1703.  
  1704. level.colours
  1705.         DC.W    $0332,$0055,$0543,$0000,$0000,$0000,$0000,$0000
  1706.         DC.W    $0000,$0F55,$0B05,$0700,$08A7,$0182,$0065,$0055
  1707.         DC.W    $0000,$0FF6,$0000,$0FD0,$0A00,$0BDF,$06AF,$004F
  1708.         DC.W    $0FFF,$0CDD,$0ABB,$0798,$0587,$0465,$0243,$0E32
  1709.  
  1710.  
  1711. alien.colours    DC.W    $0332,$0055,$0543,$0000,$0DFF,$06AC,$036A,$0038 level1
  1712.         DC.W    $0332,$0055,$0543,$0000,$0FE0,$0DA0,$0B62,$0900
  1713.         DC.W    $0332,$0055,$0543,$0000,$0FE0,$0DA0,$0B62,$0900
  1714.         DC.W    $0332,$0055,$0543,$0000,$0DE9,$0FE0,$0F90,$0D32
  1715.         DC.W    $0332,$0055,$0543,$0000,$0FE0,$0DA0,$0B62,$0900
  1716.         DC.W    $0332,$0055,$0543,$0000,$09E7,$06A0,$0D00,$0460
  1717.         DC.W    $0332,$0055,$0543,$0DDF,$099E,$0569,$0348,$0235
  1718.         DC.W    $0332,$0055,$0543,$0FFC,$0FF2,$0DE9,$0BC6,$09A4
  1719.         DC.W    $0332,$0055,$0543,$09FF,$0AF5,$03DF,$01BF,$008F
  1720.         DC.W    $0332,$0055,$0543,$0F77,$08A7,$0385,$0265,$0722
  1721.         DC.W    $0332,$0055,$0543,$0F66,$08A7,$0283,$0065,$0700
  1722.         DC.W    $0332,$0055,$0543,$0F66,$08A7,$0283,$0065,$0700
  1723.         DC.W    $0332,$0055,$0543,$0F66,$08A7,$0283,$0065,$0700
  1724.         DC.W    $0332,$0055,$0543,$0B85,$0DDA,$0C00,$0952,$0700
  1725.         DC.W    $0332,$0055,$0543,$0D8C,$0B5A,$000E,$0937,$0705
  1726.         DC.W    $0332,$0055,$0543,$0E00,$0A98,$0B60,$0832,$0733
  1727.         DC.W    $0332,$0055,$0543,$0E00,$0A98,$0B60,$0832,$0733
  1728.         DC.W    $0332,$0055,$0543,$0E00,$0A98,$0B60,$0832,$0733
  1729.         DC.W    0,0,0,0,0,0,0,0
  1730.         DC.W    0,0,0,0,0,0,0,0
  1731.         DC.W    0,0,0,0,0,0,0,0
  1732.         DC.W    0,0,0,0,0,0,0,0
  1733.         DC.W    0,0,0,0,0,0,0,0
  1734.         DC.W    0,0,0,0,0,0,0,0
  1735.  
  1736.  
  1737. *******************************************************************************
  1738. *******************************************************************************
  1739.  
  1740. alldone
  1741.     bsr    FreeSystem
  1742.  
  1743. MemError
  1744.     move.l    _SysBase,a6
  1745.     move.l    MemBase,a1
  1746.     move.l    #MemNeeded,d0        free the memory we took
  1747.     jsr    _LVOFreeMem(a6)
  1748.     move.l    GraphicsBase,a1    
  1749.     jsr    _LVOCloseLibrary(a6)
  1750.     move.l    DOSBase,a1        finally close the 
  1751.     jsr    _LVOCloseLibrary(a6)    libraries
  1752.     clr.l    d0
  1753.     rts
  1754.  
  1755. *******************************************************************************
  1756.  
  1757. TakeSystem
  1758.     move.w    intenar(a6),SystemInts        save system interupts
  1759.     move.w    dmaconr(a6),SystemDMA        and DMA settings
  1760.     move.w    #$7fff,intena(a6)        kill everything!
  1761.     move.w    #$7fff,dmacon(a6)
  1762.     move.b    #%01111111,ICRA            kill keyboard
  1763.     move.l    $68,Level2Vector        save these interrupt vectors
  1764.     move.l    $6c,Level3Vector        as we will use our own 
  1765.     rts                    keyboard & vblank routines
  1766.  
  1767. FreeSystem
  1768.     move.l    Level2Vector,$68    restore the system vectors
  1769.     move.l    Level3Vector,$6c        and interrupts and DMA
  1770.     move.l    GraphicsBase,a1            and replace the system
  1771.     move.l    SystemCopper1(a1),Hardware+cop1lc    copper list
  1772.     move.l    SystemCopper2(a1),Hardware+cop2lc
  1773.     move.w    SystemInts,d0
  1774.     or.w    #$c000,d0
  1775.     move.w    d0,intena(a6)
  1776.     move.w    SystemDMA,d0
  1777.     or.w    #$8100,d0
  1778.     move.w    d0,dmacon(a6)
  1779.     move.b    #%10011011,ICRA    keyboard etc back on
  1780.     rts
  1781.  
  1782. *******************************************************************************
  1783.  
  1784. Level2Vector        dc.l    0
  1785. Level3Vector        dc.l    0
  1786. SystemInts        dc.w    0
  1787. SystemDMA        dc.w    0
  1788. MemBase            dc.l    0
  1789. DOSBase            dc.l    0
  1790. GraphicsBase        dc.l    0
  1791.  
  1792.     even
  1793. GraphicsName    dc.b    'graphics.library',0
  1794.     even
  1795. DOSName        dc.b    'dos.library',0
  1796.  
  1797. *******************************************************************************
  1798.  
  1799. shipbase    include    ships.s
  1800. paths        include    paths.s
  1801. graphics    incbin    foregrounds
  1802. map        incbin    map
  1803. panel        incbin    panel
  1804. aliens        incbin    aliens
  1805.  
  1806. alien.pointers
  1807. explosion1    equ    aliens
  1808. guardian.eye1    equ    explosion1+(9*384)
  1809. tadpole        equ    guardian.eye1+(4*384)
  1810. eye        equ    tadpole+(4*384)
  1811. bubble        equ    eye+(15*384)
  1812. jellyfish1    equ    bubble+(4*384)
  1813. jellyfish2    equ    jellyfish1+(4*384)
  1814. bordertl    equ    jellyfish2+(4*384)
  1815. borderbl    equ    bordertl+(6*384)
  1816. bordertr    equ    borderbl+(6*384)
  1817. borderbr    equ    bordertr+(6*384)
  1818. mouth        equ    borderbr+(6*384)
  1819. slime        equ    mouth+(8*384)
  1820. snakebody    equ    slime+(9*384)
  1821. snakehead    equ    snakebody+(1*384)
  1822.  
  1823.     dc.l    explosion1
  1824.     dc.l    0 ;bonus.sprite
  1825.     dc.l    0 ;mine
  1826.     dc.l    guardian.eye1
  1827.     dc.l    explosion1
  1828.     dc.l    tadpole
  1829.     dc.l    eye
  1830.     dc.l    bubble
  1831.     dc.l    jellyfish1
  1832.     dc.l    jellyfish2
  1833.     dc.l    bordertl
  1834.     dc.l    borderbl
  1835.     dc.l    bordertr
  1836.     dc.l    borderbr
  1837.     dc.l    mouth
  1838.     dc.l    slime
  1839.     dc.l    snakebody
  1840.     dc.l    snakehead
  1841.     ds.l    6
  1842.  
  1843. path.buffer    ds.b    2048
  1844. buffer0        ds.b    6144
  1845. buffer1        ds.b    6144
  1846. screen0bgnds    ds.b    256
  1847. screen1bgnds    ds.b    256
  1848.  
  1849.     end
  1850.  
  1851.