home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Amos / amproe2x.dms / in.adf / Compiler_Examples / AMOS_versions / Stars2.AMOS / Stars2.amosSourceCode
Encoding:
AMOS Source Code  |  1993-06-16  |  2.3 KB  |  120 lines

  1. ' ---------------------------------  
  2. '
  3. ' AMOSPro Compiler Example 
  4. '
  5. ' 3D Star Scroller 
  6. '
  7. ' By Jean-Baptiste BOLCATO 
  8. '
  9. ' (from an original procedure  
  10. '  written by John Miaoulis)           
  11. '
  12. ' (c) 1993 Europress Software Ltd. 
  13. '
  14. ' ---------------------------------  
  15. '
  16. '
  17. ' --------------------------------------------------       
  18. ' Remark: A remake of the cool 3D stars scroller     
  19. '         (no more floating-point operations!) 
  20. '
  21. '         Average Acceleration:  400 % 
  22. '
  23. '         Test configuration: A1200, 6Mb   
  24. '
  25. '         Original AMOS Compiler:  200 %   
  26. ' --------------------------------------------------       
  27.  
  28. ' ---- Variables Init ---- 
  29.  
  30. Dim X(256),Y(256),N(16)
  31.  
  32. ' Ntsc screen ?
  33. YMAX=256-56*(Ntsc=True)
  34. YMID=128-28*(Ntsc=True)
  35. XDEC=160*256
  36. YDEC=YMID*256
  37.  
  38. ' Number of stars, timers
  39. N2=0 : N=1 : NL=6 : T=1
  40.  
  41. ' Speed of stars 
  42. W=264 : Rem (264/256 in fact)
  43.  
  44. ' Get random start positions for stars   
  45. For X=1 To 128
  46.    X(X)=(Rnd(320)-160)*256
  47.    Y(X)=(Rnd(200)-100)*256
  48. Next X
  49.  
  50. ' ---- Screen Init ----
  51.  
  52. Screen Open 0,320,YMAX,2,Lowres
  53. Curs Off : Hide 
  54. Palette $0,$FFF
  55.  
  56. ' Switch OFF multitask 
  57. Amos Lock : Break Off 
  58. Dreg(0)=Execall(-132)
  59.  
  60. ' ---- Main Loop ----
  61.  
  62. Repeat 
  63.    
  64.    CPT=0
  65.    
  66.    Repeat 
  67.       
  68.       ' Add a star every 8 loops 
  69.       Inc N2
  70.       If N2=8 : N2=0 : Inc N : End If 
  71.       
  72.       Timer=0
  73.       
  74.       For I=1 To N
  75.          X_OLD=X(I) : Y_OLD=Y(I)
  76.          X(I)=(X(I)*W)/256
  77.          Y(I)=(Y(I)*W)/256
  78.          If X(I)>XDEC Then X(I)=X(I)-XDEC
  79.          If Y(I)>YDEC Then Y(I)=Y(I)-YDEC
  80.          If X(I)<-XDEC Then X(I)=X(I)+XDEC
  81.          If Y(I)<-YDEC Then Y(I)=Y(I)+YDEC
  82.          
  83.          ' A simple plot & unplot for the stars!
  84.          Ink 0 : Plot 160+X_OLD/256,YMID+Y_OLD/256
  85.          Ink 1 : Plot 160+X(I)/256,YMID+Y(I)/256
  86.       Next I
  87.       
  88.       Wait Vbl 
  89.       
  90.       If Timer>T : Inc CPT : End If 
  91.       
  92.    Until CPT>4
  93.    
  94.    ' Needs more than T VBLs to display N stars
  95.    Bell : Home 
  96.    N(T)=N
  97.    Print "< Needs";N(T);" stars to pass under";T;" VBL >"
  98.    Inc T
  99.    
  100. Until T=NL+1
  101.  
  102. ' --- Final Report --- 
  103.  
  104. ' Switch ON  multitask 
  105. Dreg(0)=Execall(-138)
  106. Amos Unlock : Break On 
  107.  
  108. Home 
  109. Print "      --- Final status report ---     "
  110. Print 
  111. For T=1 To NL
  112.    Print "< Needs";N(T);" stars to pass under";T;" VBL >"
  113. Next T
  114. Print 
  115. Print "   Press mouse key to end"
  116.  
  117. Repeat 
  118.    Multi Wait 
  119. Until Mouse Key or(Inkey$<>"")
  120. End