home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-06-16 | 2.3 KB | 120 lines |
- ' ---------------------------------
- '
- ' AMOSPro Compiler Example
- '
- ' 3D Star Scroller
- '
- ' By Jean-Baptiste BOLCATO
- '
- ' (from an original procedure
- ' written by John Miaoulis)
- '
- ' (c) 1993 Europress Software Ltd.
- '
- ' ---------------------------------
- '
- '
- ' --------------------------------------------------
- ' Remark: A remake of the cool 3D stars scroller
- ' (no more floating-point operations!)
- '
- ' Average Acceleration: 400 %
- '
- ' Test configuration: A1200, 6Mb
- '
- ' Original AMOS Compiler: 200 %
- ' --------------------------------------------------
-
- ' ---- Variables Init ----
-
- Dim X(256),Y(256),N(16)
-
- ' Ntsc screen ?
- YMAX=256-56*(Ntsc=True)
- YMID=128-28*(Ntsc=True)
- XDEC=160*256
- YDEC=YMID*256
-
- ' Number of stars, timers
- N2=0 : N=1 : NL=6 : T=1
-
- ' Speed of stars
- W=264 : Rem (264/256 in fact)
-
- ' Get random start positions for stars
- For X=1 To 128
- X(X)=(Rnd(320)-160)*256
- Y(X)=(Rnd(200)-100)*256
- Next X
-
- ' ---- Screen Init ----
-
- Screen Open 0,320,YMAX,2,Lowres
- Curs Off : Hide
- Palette $0,$FFF
-
- ' Switch OFF multitask
- Amos Lock : Break Off
- Dreg(0)=Execall(-132)
-
- ' ---- Main Loop ----
-
- Repeat
-
- CPT=0
-
- Repeat
-
- ' Add a star every 8 loops
- Inc N2
- If N2=8 : N2=0 : Inc N : End If
-
- Timer=0
-
- For I=1 To N
- X_OLD=X(I) : Y_OLD=Y(I)
- X(I)=(X(I)*W)/256
- Y(I)=(Y(I)*W)/256
- If X(I)>XDEC Then X(I)=X(I)-XDEC
- If Y(I)>YDEC Then Y(I)=Y(I)-YDEC
- If X(I)<-XDEC Then X(I)=X(I)+XDEC
- If Y(I)<-YDEC Then Y(I)=Y(I)+YDEC
-
- ' A simple plot & unplot for the stars!
- Ink 0 : Plot 160+X_OLD/256,YMID+Y_OLD/256
- Ink 1 : Plot 160+X(I)/256,YMID+Y(I)/256
- Next I
-
- Wait Vbl
-
- If Timer>T : Inc CPT : End If
-
- Until CPT>4
-
- ' Needs more than T VBLs to display N stars
- Bell : Home
- N(T)=N
- Print "< Needs";N(T);" stars to pass under";T;" VBL >"
- Inc T
-
- Until T=NL+1
-
- ' --- Final Report ---
-
- ' Switch ON multitask
- Dreg(0)=Execall(-138)
- Amos Unlock : Break On
-
- Home
- Print " --- Final status report --- "
- Print
- For T=1 To NL
- Print "< Needs";N(T);" stars to pass under";T;" VBL >"
- Next T
- Print
- Print " Press mouse key to end"
-
- Repeat
- Multi Wait
- Until Mouse Key or(Inkey$<>"")
- End