'Hello again, this little proggy is adapted to display the bouncing BOBS 
'as Icons.  With use the the faster F 16 Icon routine... 
'Compile it to get HYPER-speed ! 
' ---------------------------------  
'
' AMOSPro Compiler Example 
'
' Bouncin' Bobs
'
' By Jean-Baptiste BOLCATO 
'
' (c) 1993 Europress Software Ltd. 
'
' ---------------------------------  
'
' ---------------------------------------------------  
'  remark:  Shows how many Bobs can be displayed and moved 
'           at speed. Note the turning off of Multi-tasking below.   
'           This will speed up your Bobs and avoid them 'sticking'.  
'           when there's another task taking too much time.
'
'           Average Acceleration:  320 % 
'
'           Test configuration: A1200, 6Mb 
'
'           Original AMOS Compiler:  250 % 
' ---------------------------------------------------        
' ---- Variables Init ---- 
IC_MAX=350
Dim X(IC_MAX),Y(IC_MAX),VX(IC_MAX),VY(IC_MAX),N(10)
For I=1 To IC_MAX
   X(I)=0
   Y(I)=8+Rnd(200)
   VX(I)=Rnd(4)+1
   VY(I)=Rnd(4)+1
Next I
YMAX=256+56*(Ntsc=True)
VYMAX=10+3*(Ntsc=True)
N2=0 : N=1 : T=1
' ---- Screen Init ----
Screen Open 0,320,YMAX,4,Lowres
Screen Hide 0
Flash Off : Curs Off : Hide 
Palette 0,$FFF,$BBB,$888
Paper 0 : Pen 1
' ---- Init bobs ----  
Load ":TURBO_BANKS/TURBO_BOUNCE.ABK"
'Load Iff "AMOSPro_Extras:Compiler_Examples/Graphics/Sprites_pic.iff",0
'Get Bob 1,0,0 To 16,16
Cls 0 : Wait Vbl 
Paper 0 : Pen 1
Double Buffer 
Autoback 0
' Set bob backsave to color 0  
'For I=1 To 63 
'   Set Bob I,1,,
'Next I
' ---- Init Rainbow ---- 
Set Rainbow 0,0,64,"","",""
YR=0
For I=0 To 15
   For J=1 To I/2
      Inc YR
      Rain(0,YR)=(15-I)*$110
   Next J
Next I
Rainbow 0,0,YMAX,40
Screen Show 0
' ---- Main Loop ----
' Error managment  
On Error Proc _ERROR
Resume Label _EXIT
OVERFLOW_BOB=False
YMAX=Y Screen(YMAX)
' Switch OFF multitask 
Amos Lock : Break Off 
Make Mask 
Bank Swap 1,2
Multi No 
Repeat 
   CPT=0
   Repeat 
      ' Add a new bob every 16 loops.
      Inc N2
      If N2=16
         N2=0
         Inc N
      End If 
      Timer=0
      For I=1 To N
         ' Setup gravity & x speed
         Inc VY(I)
         Add X(I),VX(I)
         Add Y(I),VY(I)
         ' ybounce! 
         If Y(I)>=YMAX : Y(I)=YMAX : VY(I)=-10-Rnd(VYMAX) : End If 
         ' xbounce! 
         If X(I)>304 or X(I)<0 : VX(I)=-VX(I) : End If 
         ' Display (if it's possible, else jump to _EXIT!)
         F 16 Icon X(I),Y(I),1
      Next I
      Screen Swap 
      Wait Vbl 
      Blit Clear -1
       If Timer>T : Inc CPT : End If 
   Until CPT>4
   ' Report Message 
   Bell : Home 
   N(T)=N
   Print "< Needs";N(T);" bobs to pass under";T;" VBL >"
   Inc T
Until T=7
_EXIT:
' --- Final Report --- 
' Switch ON  multitask 
Multi Yes 
Amos Unlock : Break On 
Autoback 1 : Home 
Print "     --- Final status report ---     "
Print 
T2=T-1-(OVERFLOW_BOB=True)
For T2=1 To T-1
   Print "< Needs";N(T2);" bobs to pass under";T2;" VBL >"
Next T2
If OVERFLOW_BOB : Print : Print "--- Error: Bobs-overflow Error ! ---" : End If 
Print "     Press mouse key to end"
Repeat 
   Multi Wait 
Until Mouse Key or(Inkey$<>"")
End 
' ---- Error ----
Procedure _ERROR
   Shared OVERFLOW_BOB
   OVERFLOW_BOB=True
   Resume Label 
End Proc
