home *** CD-ROM | disk | FTP | other *** search
/ Sauce 'n' Code 3 / sauce-n-code-03.adf / Source_Code / Chex_Tunnel.asc < prev    next >
Text File  |  1996-01-21  |  6KB  |  202 lines

  1. MAIN:
  2. ' This routine - believe it or not - runs at full 50 fps on my A1200 
  3. ' (No Fast RAM either) before I've even compiled it!  You'll have to 
  4. ' edit it a little to get what you want, I've used four layers of
  5. ' chex to make it look better. 
  6. '                                                          Freak/NFA 
  7.  
  8. _MAKESCREENS
  9. _ENVIRONMENT
  10.  
  11. ' ------------------------------------- get original plane pointers
  12. Screen 1
  13. P0=Leek(Screen Base+24)
  14. P1=Leek(Screen Base+28)
  15. P2=Leek(Screen Base+32)
  16. P3=Leek(Screen Base+36)
  17.  
  18. ' ------------------------------------- find where work data starts
  19. Screen 0
  20. SRC=Phybase(0) : MEM=(Screen Width/8)*Screen Height
  21.  
  22. ' ------------------------------------- 66 frame (!) anim
  23. Reserve As Chip Work 10,(MEM*66)
  24.  
  25. ' ------------------------------------- this bit generates the chex at 
  26. '                                       increasing sizes to give the 
  27. '                                       impression of motion and then
  28. '                                       copies them into that big bank 
  29. OFF=0
  30. For SCALE=50 To 700 Step 10
  31.    Cls 0
  32.    XM=(Screen Width/2)+(SCALE/4)
  33.    YM=(Screen Height/2)-(SCALE/4)
  34.    For Y=-2 To 2
  35.       For X=-4 To 3
  36.          Ink 1
  37.          Bar XM+(X*SCALE)+1,YM+(Y*SCALE)+1 To XM+(X*SCALE)+(SCALE/2),YM+(Y*SCALE)+(SCALE/2)
  38.          Bar XM+(X*SCALE)+(SCALE/2)+1,YM+(Y*SCALE)+(SCALE/2)+1 To XM+(X*SCALE)+SCALE,YM+(Y*SCALE)+SCALE
  39.       Next X
  40.    Next Y
  41.    Copy SRC,SRC+MEM To Start(10)+(OFF*MEM) : Inc OFF
  42. Next SCALE
  43.  
  44. ' you might notice that the anim doesn't look as good as the ones
  45. ' you'll have seen in the demos, this is because I didn't use proper 
  46. ' distance scaling, I just increased each successive square size by
  47. ' 10 pixels each time, cos you have to use mathtrans.library to do 
  48. ' it properly, and besides which I don't KNOW how to DO that bloody
  49. ' perspective scaling thingy!
  50.  
  51. Screen Close 0
  52. SP=1 : Dec OFF
  53.  
  54. ' --------------------------- Space the bitplane offsets out at  
  55. '                             equal intervals through the 66 frames
  56. PLANE0=(OFF/4)*3
  57. PLANE1=(OFF/4)*2
  58. PLANE2=(OFF/4)*1
  59. PLANE3=(OFF/4)*0
  60.  
  61. ' --------------------------- Palette fading, you might want to do a 
  62. '                             bit of fiddling here to try and get a
  63. '                             nice see-through effect. 
  64. K=$FFF
  65. X0=$112 : X1=$55A : X2=$448 : X3=$336 : X4=$224
  66. Fade 2,X0,X1,X2,X1,X3,X1,X2,X1,X4,X1,X2,X1,X3,X1,X2,X1,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K
  67.  
  68. ' ----------------------------- The main loop (Deceptively EASY!)
  69. Screen 1
  70. Do 
  71.    Exit If Mouse Key<>0
  72.    
  73.    ' -------------------------- Which was the LAST bitplane to loop 
  74.    '                            back to frame 0?
  75.    '                            (M stores it until another change)
  76.    If PLANE0=0 Then M=0
  77.    If PLANE1=0 Then M=1
  78.    If PLANE2=0 Then M=2
  79.    If PLANE3=0 Then M=3
  80.    
  81.    ' -------------------------- Bitplanes have to be ordered so that
  82.    '                            they appear in accordance with the
  83.    '                            palette, not too difficult, I just
  84.    '                            wich there was a neater way to do it! 
  85.    If M=0
  86.       L3=PLANE0
  87.       L0=PLANE1
  88.       L1=PLANE2
  89.       L2=PLANE3
  90.    Else If M=1
  91.       L2=PLANE0
  92.       L3=PLANE1
  93.       L0=PLANE2
  94.       L1=PLANE3
  95.    Else If M=2
  96.       L1=PLANE0
  97.       L2=PLANE1
  98.       L3=PLANE2
  99.       L0=PLANE3
  100.    Else If M=3
  101.       L0=PLANE0
  102.       L1=PLANE1
  103.       L2=PLANE2
  104.       L3=PLANE3
  105.    End If 
  106.    
  107.    ' ------------------------------------- Eeek!  It's them funny LOKE
  108.    '                                       commands again!  
  109.    Loke Screen Base+24,Start(10)+(L0*MEM)
  110.    Loke Screen Base+28,Start(10)+(L1*MEM)
  111.    Loke Screen Base+32,Start(10)+(L2*MEM)
  112.    Loke Screen Base+36,Start(10)+(L3*MEM)
  113.    
  114.    ' ------------------------------------- Update the frame pointers
  115.    Add PLANE0,1,0 To OFF
  116.    Add PLANE1,1,0 To OFF
  117.    Add PLANE2,1,0 To OFF
  118.    Add PLANE3,1,0 To OFF
  119.    
  120.    ' ------------------------------------- Show changes to Screen Base
  121.    Wait SP : View 
  122. Loop 
  123.  
  124. _CLEANUP
  125.  
  126. Procedure _MAKESCREENS
  127.    
  128.    SH=200
  129.    
  130.    ' ------------------------------------- Screen 0 - work screen 
  131.    Screen Open 0,320,SH,2,Lowres
  132.    Curs Off : Flash Off : Cls 0
  133.    Screen Hide 0
  134.    
  135.    ' ------------------------------------- screen 1 - anim screen 
  136.    Screen Open 1,320,SH,32,Lowres
  137.    Curs Off : Flash Off : Cls 0 : K=$112
  138.    Palette K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K
  139.    Hide : Screen Display 1,,70,,
  140.    Gr Writing 0
  141.    
  142.    ' ------------------------------------ Some screen text using plane 3
  143.    '                                      What's interesting is that if 
  144.    '                                      you open your screen in E.H.B 
  145.    '                                      you can use pen 32 as a "shadow"
  146.    '                                      colour for your text and it will
  147.    '                                      do the colours for you! 
  148.    '                                      (I have not tried this!)
  149.    Pen 16 : Paper 0
  150.    For Y=18 To 23
  151.       Read T$
  152.       Locate 0,Y
  153.       Centre T$
  154.    Next Y
  155.    
  156.    Data "Freak says HI to ßudda!"
  157.    Data "-=-=-=-=-=-=-=-=-=-=-=-"
  158.    Data "Here's the routine you wanted dude,"
  159.    Data "now that I've done it I'll put in"
  160.    Data "some REMs so you can see what I was"
  161.    Data "getting up to, see the letter too!"
  162.    
  163. End Proc
  164. Procedure _ENVIRONMENT
  165.    
  166.    ' ----------------------------------> No stopping while we're messing
  167.    '                                     about with the bitplanes matey!
  168.    Amos Lock 
  169.    Break Off 
  170.    Request Off 
  171.    
  172. End Proc
  173. Procedure _CLEANUP
  174.    Shared P0,P1,P2,P3
  175.    
  176.    ' ----------------------------> Restore Screen 1's Screen Base with
  177.    '                               the values we got at the start, so 
  178.    '                               that AMOS won't throw a wobbler when 
  179.    '                               it tries to close the screen and finds 
  180.    '                               that the planes are not looking where
  181.    '                               they're supposed to be!
  182.    Screen 1
  183.    Loke Screen Base+24,P0
  184.    Loke Screen Base+28,P1
  185.    Loke Screen Base+32,P2
  186.    Loke Screen Base+36,P3
  187.    
  188.    ' ----------------------------> Free up the AMOS bits again. 
  189.    Erase 10
  190.    Amos Unlock 
  191.    Break On 
  192.    
  193.    End : Rem ----------------------> Fin! 
  194.    
  195. End Proc
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.