REM Flying worms
REM
REM Disable the Escape key
REM
*ESC OFF
REM
REM Select 64-bit floating point mode (double-precision maths)
REM
*FLOAT 64
REM
REM Set up a simple error handler
REM
ON ERROR OSCLI "REFRESH ON" : MODE 8 : VDU 7 : REPORT : PRINT " at line ";ERL : END
REM
REM Make 3 MB of RAM available for use by this program
REM
M% = 3
HIMEM = LOMEM + M%*&100000
REM
REM Prevent the program window from being resized by the user
REM
SYS "GetWindowLong", @hwnd%, -16 TO S%
SYS "SetWindowLong", @hwnd%, -16, S% AND NOT &50000
SYS "SetWindowPos", @hwnd%, 0, 0, 0, 0, 0, 32+7
REM
REM Setup a 640x512 display mode, and turn OFF the flashing cursor
REM
MODE 8
OFF
REM
REM Install and initialise GFXLIB and required external modules
REM
INSTALL @lib$ + "GFXLIB2" : PROCInitGFXLIB
INSTALL @lib$ + "GFXLIB_modules\PlotTintBlend.BBC" : PROCInitModule
INSTALL @lib$ + "GFXLIB_modules\PlotInvertRGB.BBC" : PROCInitModule
INSTALL @lib$ + "GFXLIB_modules\PlotSwapRGB.BBC" : PROCInitModule
INSTALL @lib$ + "GFXLIB_modules\PlotBlend.BBC" : PROCInitModule
INSTALL @lib$ + "GFXLIB_modules\MMXCopy64.BBC" : PROCInitModule
REM
REM Load-in the images to be displayed and manipulated in this example program
REM
PRINT ''" Please wait...";
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere0Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere1Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere2Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere3Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere4Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere5Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere6Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere7Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere8Bm%, 0 )
PROCLoadBMP( @dir$ + "sphere003_64x64x24.BMP", sphere9Bm%, 0 )
PROCLoadBMP( @dir$ + "star_5001_48x48x24.BMP", starBm%, 0 )
REM
REM Create background bitmap
REM
bgBm% = FNmalloc( 4 * 640*512 )
FOR I% = 0 TO 511
FOR J% = 0 TO 639
bgBm%!(4*I%*640 + 4*J%) = &402000 + RND((639-I%)DIV2)
NEXT
NEXT
REM
REM Plot randomly coloured stars (of fixed opacity 25%) over the background
REM
REM Note that GFXLIB_PlotTintBlend's output will be redirected to bgBm%
REM
SYS GFXLIB_SetDispVars2%, dispVars{}, bgBm%, 640, 512
FOR I%=1 TO 100
col% = FNrgb( 128+RND(127), 128+RND(127), 128+RND(127) )
SYS GFXLIB_PlotTintBlend%, dispVars{}, starBm%, 48, 48, -24+RND(640+48), -24+RND(512+48), col%, 128, 25
NEXT I%
REM
REM Manipulate the colours of the original sphere bitmap
REM
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere1Bm%, 64, 64
SYS GFXLIB_PlotInvertRGB%, dispVars{}, sphere1Bm%, 64, 64, 0, 0, 1
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere2Bm%, 64, 64
SYS GFXLIB_PlotInvertRGB%, dispVars{}, sphere2Bm%, 64, 64, 0, 0, 2
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere3Bm%, 64, 64
SYS GFXLIB_PlotInvertRGB%, dispVars{}, sphere3Bm%, 64, 64, 0, 0, 3
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere4Bm%, 64, 64
SYS GFXLIB_PlotInvertRGB%, dispVars{}, sphere4Bm%, 64, 64, 0, 0, 4
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere5Bm%, 64, 64
SYS GFXLIB_PlotInvertRGB%, dispVars{}, sphere5Bm%, 64, 64, 0, 0, 5
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere6Bm%, 64, 64
SYS GFXLIB_PlotInvertRGB%, dispVars{}, sphere6Bm%, 64, 64, 0, 0, 6
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere7Bm%, 64, 64
SYS GFXLIB_PlotInvertRGB%, dispVars{}, sphere7Bm%, 64, 64, 0, 0, 7
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere8Bm%, 64, 64
SYS GFXLIB_PlotSwapRGB%, dispVars{}, sphere8Bm%, 64, 64, 0, 0, 1
SYS GFXLIB_SetDispVars2%, dispVars{}, sphere9Bm%, 64, 64
SYS GFXLIB_PlotSwapRGB%, dispVars{}, sphere9Bm%, 64, 64, 0, 0, 2
SYS GFXLIB_SetDispVars2%, dispVars{}, dibs%, 640, 512
theta1# = 0 : dtheta1# = 2.818
theta2# = 0 : dtheta2# = 1.233
D% = dispVars{}
P% = GFXLIB_PlotBlend%
*REFRESH OFF
REPEAT
REM
REM Draw the background bitmap (bg_bmp)
REM
REM
SYS GFXLIB_MMXCopy64%, dispVars{}, bgBm%, dibs%, 4*5120
REM
REM Plot the ball bitmaps
REM
FOR I%=11 TO 0 STEP -1
a# = theta1# - 3*I%*dtheta1#
b# = 0.25*theta2# - 0.5*I%*dtheta2#
X% = 400 * SINRADa# * COSRADb#
Y% = 300 * COSRADa# * SINRADb#
opacity% = 255 * ((11-I%)/11)
REM Reminder: P% = GFXLIB_PlotBlend%
REM D% = dispVars{}
SYS P%, D%, sphere9Bm%, 64, 64, 288-X%, 224-Y%, opacity%
SYS P%, D%, sphere8Bm%, 64, 64, 288+X%, 224-Y%, opacity%
SYS P%, D%, sphere7Bm%, 64, 64, 288-X%, 224+Y%, opacity%
SYS P%, D%, sphere6Bm%, 64, 64, 288+X%, 224+Y%, opacity%
SYS P%, D%, sphere5Bm%, 64, 64, 288+0.5*X%, 224+0.5*Y%, opacity%
SYS P%, D%, sphere4Bm%, 64, 64, 288-0.5*X%, 224+0.5*Y%, opacity%
SYS P%, D%, sphere3Bm%, 64, 64, 288+0.5*X%, 224-0.5*Y%, opacity%
SYS P%, D%, sphere2Bm%, 64, 64, 288-0.5*X%, 224-0.5*Y%, opacity%
SYS P%, D%, sphere1Bm%, 64, 64, 288-0.75*Y%, 224-0.75*X%, opacity%
SYS P%, D%, sphere0Bm%, 64, 64, 288+0.75*Y%, 224+0.75*X%, opacity%
NEXT I%
theta1# += dtheta1#
theta2# += dtheta2#
PROCdisplay
UNTIL FALSE