On 19 Mar, Richard Ashbery wrote in message
Post by Richard AshberyPost by Steve FryattI still don't like VDU23,27,1,n| though...
Although this method of creating a sprite group is probably
poor/deprecated it's easy to understand.
I need to get my head round the alternative (OS_SpriteOp). Although I've
been told its easy the last time I looked I didn't find it plain sailing -
I need a good tutorial - I'll do a web search and see what turns up.
A straight forward replacement is simply
SYS "OS_SpriteOp", &00E,, STR$(n)
because SpriteOp &0E is what VDU23,27,1,n| calls behind the scenes. However,
you're no longer limited to numeric names, because you can pass a string
where the STR$(n) is.
If you wished to save the file from the program, instead of using *SSave,
you could add a line
SYS "OS_SpriteOp", &00C,, "MyFileName"
to save the file to the current working directory (or pass a full pathname
instead). SpriteOp &0C is what *SSave calls.
However, you can also create your own areas, which aren't limited by the
16MB restriction of the system sprite area (your file is 15MB, so will be
close to hitting the limit). To do this, you make sure that your Next slot
is big enough to hold the area (so >32768K and a bit extra here), then DIM a
block of memory as the program starts.
REM Set the sprite area size in MB.
sprite_area_size% = 32
REM Get the size in bytes.
sprite_area_size% = sprite_area_size% * 1024 * 1024
REM Allocate the required number of bytes (BASIC allocates one more).
DIM sprite_area% (sprite_area_size% - 1)
REM Put the size of the area into the first word.
sprite_area%!0 = sprite_area_size%
REM The third word must be 16 on initialisation.
sprite_area%!8 = 16
REM Initialise the area.
SYS "OS_SpriteOp", &109, sprite_area%
Note that the call to OS_SpriteOp has &109 instead of &009... The *SNew
command calls
SYS "OS_SpriteOp", &009
but if we add &100 to the SpriteOp number, we can pass our own sprite area
in the second parameter (which is left empty with a double comma in the
first two SYS calls above). The basic SpriteOp codes use the System Sprite
Area; add &100 to the code, and they work on a user sprite area.
This means that the other two calls above become
SYS "OS_SpriteOp", &10E, sprite_area%, STR$(n)
and
SYS "OS_SpriteOp", &10C, sprite_area%, "MyFileName"
They do the same things, but using our sprite area instead. The whole
listing is now
sprite_area_size% = 32
sprite_area_size% = sprite_area_size% * 1024 * 1024
DIM sprite_area% (sprite_area_size% - 1)
sprite_area%!0 = sprite_area_size%
sprite_area%!8 = 16
SYS "OS_SpriteOp", &109, sprite_area%
MODE 1920,1080,32 : OFF
T2=0
n=0
REM Set up rotation variable for square
FOR m=0 TO 6*PI-PI/12 STEP PI/6
REM Set offset for ORIGIN (full circle)
X1=SIN RAD(T2)*100
Y1=COS RAD(T2)*100
REM ORIGIN 1920+X1,1080+Y1
T2+=10
GCOL 3,63 : PROCdraw_square(1920+X1, 1080+Y1, m)
z=INKEY(10)
REM Generate sprite group for animation
MOVE1920-330,1080-330
MOVE1920+330,1080+330
SYS "OS_SpriteOp", &10E, sprite_area%, STR$(n)
n+=1
REM Erase previous square after a delay
GCOL 3,63 : PROCdraw_square(1920+X1, 1080+Y1, m)
NEXT m
SYS "OS_SpriteOp", &10C, sprite_area%, "Sprites"
END
DEF PROCdraw_square(x%, y%, angle)
FOR T = 0 TO 2*PI STEP PI/2
X=x%+SIN(T+angle)*200
Y=y%+COS(T+angle)*200
IF T=0 THEN MOVE X,Y ELSE DRAW X,Y
NEXT T
ENDPROC
--
Steve Fryatt - Leeds, England
http://www.stevefryatt.org.uk/