20 REM By, & (c) Daniel Cannon 30 REM Public Domain 40 REM ----------------------- 50 REM Variables 60 LET scr=1,max=4,tot=1 70 REM 80 REM Wipe Screens 90 SCREEN 1:DISPLAY:MODE 4:CLS#:FOR a=2 TO 16:CLOSE SCREEN a Line 90 is housekeeping. You're saying that the current screen displayed is to be screen 1. And the screen is set to MODE 4. Then screens 2 to 16 are closed. This is done in case these screens have been already been OPENed, perhaps in an earlier activity. This ensures no "screen is already open" error messages! 100 REM 110 REM 4 screens used in animation 120 FOR a=2 TO max 130 OPEN SCREEN a,4 140 NEXT a Lines 120 to 140 OPEN "max" number of screens, which are all setup as MODE 4 screens. The demo only uses 4 screens, so that it will run happily on both 256K and 512K SAMs. Perhaps you could try extending this number, to see what happens? 150 REM 160 REM Create ball sprite 170 CIRCLE PEN 4;12,173-12,11 180 CIRCLE PEN 12;10,173-10,6 190 CIRCLE PEN 15;9,173-9,2 200 FILL PEN 4;3,173-9 210 FILL PEN 12;5,173-9,1 220 FILL PEN 15;8,173-9,1 230 GRAB ball$,0,173,25,25 Lines 170 to 220 now draw a simple "ball" graphic. Line 230 then "grabs" the graphic, and stores it in the variable"ball$", ready to be used by the PUT command. 240 REM 250 REM Create sprite mask 260 CLS: CIRCLE PEN 15;12,173-12,12 270 FILL PEN 15;12,173-12 280 GRAB mask$,0,173,25,25:CLS A "mask" prevents the ball graphic from wiping out the graphics already on the screen in the same area. In this demo the mask also gives the ball graphic a black outline. 290 REM Main Program, SIN & COS 300 REM are used to make them spin 310 REM in a circle - a simple pattern 320 REM Pattern 330 FOR a=0 TO 2500 STEP 5 340 PAUSE 1:SCREEN scr:DISPLAY scr-1+(max AND scr=1):LET scr=scr+1-(max AND scr=max):IF scr=1 THEN LET tot=tot+1 350 PUT 128+(30+a DIV 45)*SIN (a/180*PI),88+(30+a DIV 45)* COS(a/180*PI),ball$,mask$:PRINT AT 18,0;tot: NEXT a Line 340 is the main routine for DISPLAY and SCREEN. Line 350 uses SIN and COS to form a simple display pattern. Why not try out different formulae and see what happens? 360 REM Fade down 370 PAUSE 10:PALETTE 4,0:PALETTE 12,64: PALETTE 15,68 380 PAUSE 10:PALETTE 12,0:PALETTE 15,64 390 PAUSE 10:PALETTE 15,0 Lines 370 to 390 give the impression of the colours fading. 400 REM Close screens 410 SCREEN 1:CLS:DISPLAY:FOR a=2 TO 4:CLOSE SCREEN a:NEXT a 420 PRINT "Just shows what can be done in SAM BASIC...." Line 410 will clear the used SCREENs away, leaving memory neat and tidy for your next program!