Post by Roger Cabo on Aug 22, 2023 9:24:22 GMT 1
I will play with this over the weekend. I would really like to see something like STOS that was developed for game design using sprites back in the day for the Atari ST. Or quite frankly any add-on program allowing multiple sprites for GB32.
cls : mode 0 : curs off : hide on
colour 11,$0
load "c:sprite.mbk"
sprite 1,100,100,1
move y 1,"(1,-4,5)(1,-1,20)(10,-1,10)(10,1,10)(1,1,20)L"
move on
wait key
default
What commands do you like to have from STOS`?
temlib.org/AtariForumWiki/index.php/STOS_BASIC_FAQ/INSTRUCTIONS
temlib.org/AtariForumWiki/index.php/STOS_BASIC_FAQ/INSTRUCTIONS
Memory banks
STOS Basic includes a number of powerful facilities for the
manipulation of sprites, screens and music. The data required by
these functions needs to be stored along with the Basic program.
STOS Basic uses a special set of 15 sections of memory for this
purpose called banks. Each bank is referred to by a unique number
ranging from 1-15. Many of these banks can be used for all types
of data, but some are dedicated solely to one sort of information
only such as sprite definitions. Every program stored in the ST's
memory has it's own separate set of banks.
There are two different forms of memory bank; permanent and
temporary. Permanent banks only need to be defined once, and are
all subsequently saved along with your program, temporary banks
are erased rom memory by the CLEAR command.
Types of memory bank
Each memory bank can be one of the following different types.
Class Stores Restrictions Type
Sprites Sprite definitions Only bank 1 (1) P
Icons Icon definitions Only bank 2 (1) P
Music Music Only bank 3 (1) P
3D Future 3D extension Only bank 4 (4) P
Set Holds new character sets Banks 1-15 P
Screen Stores a complete screen Banks 1-15 T
Datascreen Stores a screen Banks 1-15 P
Work Temporary workspace Banks 1-15 T
Data Permanent workspace Banks 1-15 P
Menu Menu lines Bank 15 (2) T
Program Machine-code program Banks 1-15 (3) V
Footnotes:
(1) Bank is not really general purpose. It is allocated
automatically by the appropriate accessory, or when a bank
of this type is loaded.
(2) Reserved automatically by MENU commands. Usable only by
programs which don't use menus.
(3) Reserved as either Work or Data. Renamed when program loaded
into bank.
(4) Reserved for future expansion.
(P) Permanent memory bank
(T) Temporary memory bank
(V) Variable between permanent or temporary.
LISTBANK Lists the numbers of the banks currently
reserved by a program, along with their
location and size.
S := Start address of the bank
E := End address of the bank
L := Length of the bank
HEXA ON/OFF Sets the LISTBANK to decimal or hexadecimal
notation.
RESERVE Any banks used by sprites, music, icons, 3D
extensions, and the menus are allocated
automatically by the system. The RESERVE
command allows you to allocate any other
banks which you require. Each different type
of bank has it's own individual form of the
RESERVE instruction.
RESERVE AS SCREEN bank Reserves a temporary bank of
memory for a screen. This bank
is always 32K long.
RESERVE AS DATASCREEN bank Reserves a permanent bank of
memory 32K long for use as a
screen. This screen is saved
along with your program, so
it's great for title screens.
RESERVE AS SET bank,length Reserves a permanent bank of
memory length bytes long for
use as a character set.
RESERVE AS WORK bank,length Reserves a temporary bank for
use as a workspace length
bytes long.
RESERVE AS DATA bank,length Reserves a permanent bank of
memory length bytes long for
use as a workspace.
Please note that bank may be any number between 1 and 15, but
since banks 1-4 are used by the system, it's wise to leave these
alone. Length is automatically rounded to the nearest 256 byte
page.
Copying banks
When using these memory banks, it's often useful to be able to
transfer the contents of one bank to another. This can be done
with the BCOPY command.
BCOPY #source TO #dest BCOPY copies the entire contents of bank
number source to bank number dest.
BGRAB prgno[,b] BGRAB copies one or more banks stored at
program number prgno into the current
program. Program numbers between 1-4
denote one of the four programs which
can be stored in memory at anyone time.
Numbers 5-16 represent an accessory.
If the optional bank number b is not
included, then all the banks attached to
program number prgno are copied into the
current program, and any other banks of
memory which are linked to this program
are erased. Otherwise, the bank number
specifies one bank which is to be
transferred into the current program.
All other banks remain unaffected.
ERASE b Delete the contents of memory bank b
from the program's memory and free the
bank.
=START([prgno,]b) This function returns the start of bank
b from either the current program, or
the program specified. prgno can be 1-4
for each of the four programs or 5-16
for the accessories.
=LENGTH([prgno,]b) This function returns the length of the
bank specified.
Saving and loading
SAVE
This instruction provides general and starightforward way
of saving a STOS Basic program on the disc. Unlike the
equivalent instruction found in most other versions of
Basic, STOS also allows you to save a variety of other types
of information. This is determined by the extension of the
filename used in the SAVE command. Here is a summary of the
various data types, along with their extensions.
Type of information Extension Comments
Basic Programs .BAS Normal basic program
Accessories .ACB Load using ACCLOAD
Images .PI1,PI2,PI3 Degas format screen
.NEO Neochrome format
Memory Banks .MBK One memory bank
.MBS All current banks
Basic Variables .VAR All current vars.
Listings .ASC Ascii format
RUN-ONLY programs .PRG GEM programs
If none of these extensions is found, STOS automatically adds
.BAS
.ACB files are simple Basic files which may be loaded as
accessories. To create them, write your program in Basic as
normal, but save it with the different extension. You can load it
either as an accessory using ACCLOAD or a Basic program using
LOAD.
Image Files. You can also save the current screen, bank or memory
address as an image file in degas or neochrome format using this
method.
SAVE "Filename.???"[,address of screen]
Memory Banks: SAVE "Filename.MBK",b
SAVE "Filename.MBS"
Variables: SAVE "Filename.VAR"
Listings: SAVE "Filename.ASC"
Blocks: BSAVE file$, start TO end
Save the memory from start to end as a binary
file.
(All of the above saves can be re-loaded into STOS by replacing
the LOAD or BLOAD with SAVE or BSAVE.)
BLOAD file$,addr The file file$ will be loaded into the
address specified.
BLOAD file$,#bank The file file$ is loaded into the specified
bank.
The accessories
ACCLOAD Loads any of the accessories into memory.
Either specify which file to load, or use "*"
to load all the accessories from disk.
ACCNEW Erases all the accessories from memory.
ACCNB Returns the value of zero if the program is
not an accessory, else it returns a number
between 4 and 15
Sprite Commands
SPRITE n,x,y,p Display sprite number n on the screen at
coordinates x,y using image p.
n is the number of the sprite, which can range from 1-15. It
is the number which will be used to identify the sprite in
any subsequent calls to MOVE and ANIM instructions.
x and y are the coordinates of the point on the screen where
the sprite is to be drawn. Unlike normal screen coordinates,
these can take negative values. The x coordinate can vary
from -640 to +1280, and y coordinate from -400 to +800. This
allows you to move a sprite off the screen without causing
an error.
p specifies which of the images in bank 1 is to be used for
a particular sprite. The only limit to the number of these
images is the amount of available memory.
Each sprite has an invisible handle through which it can be
manipulated, called a Hot Spot. Whenever we draw a sprite,
we always specify the coordinates of the hot spot.
Moving a sprite
MOVE X n,m$ This defines a list of horizontal movements which
will be subsequently performed by sprite number n.
m$ contains a sequence of commands which determine
the speed and direction of the sprite:
"(sp,st,ct)[A]"
SP is the speed of the sprite in 50ths of a second and can
range from 1 (v.fast) to 32767 (v.slow)
ST is the step size, i.e. how many pixels it will be moved.
CT is the number of times that this particular set of
commands will be obeyed. 0 indicates that the movement is to
be repeated indefinately. This can range from 0 to 32767.
E.G. The command
MOVE X 1,"(1,5,60)(1,5,-60)"
will move sprite 1, 5 pixels to the right every 50th of a
second, 60 times, then move it 5 pixels to the left every
50th of a second, 60 times. Movement will then stop.
The optional A can take either L to signify that, once the
command list has finished, it is to be restarted or Looped.
It may also be followed by a number (e.g. L100) which will
cause the sprite to be restarted from this coordinate.
Additionally, it can take the form of Ex which will cause
the sprite to stop when it reaches point x on the screen.
NOTE that the sprite must actually reach point x exactly for
this to work. If the sprite passes this point without
stopping on it, it will not work.
e.g. MOVE X 1,"(1,2,100)E150" will work whereas
MOVE X 1,"(1,2,101)E150" will not as the sprite uses
points 149 and 151, but not 150.
MOVE Y n,y$ Acts in the same way to MOVE X but will move the
sprite along the Y coordinate. Both commands may
be used together to cause a sprite to move
diagonally.
MOVE ON/OFF [n] Before any sprite movements you have defined
by MOVE X and MOVE Y commands will be
performed, they need to be initiated by the
instruction MOVE ON. n specifies the sprite
whose movement is to be switched on or off,
and if omitted, the command affects all
sprites.
MOVE FREEZE [n] This command can be used to temporarily halt
one or all of the sprites on the screen. This
can then be restarted with the MOVE ON
command.
=MOVON(n) Return the state of a sprite. If the sprite
is currently stationary, it will return 0
(False).
=X SPRITE(n) Return the X coordinate of the sprite n.
=Y SPRITE(n) Return the Y coordinate of the sprite n.
LIMIT SPRITE [x1,y1 TO x2,y2]
This command allows an area of the screen to
be used to display the sprites rather than
the entire screen. If any sprites leave this
area, they will disappear from the screen.
The x1,y1 coordinates define the top left
coordinate of the rectangle and the x2,y2
coordinates define the bottom right. All the
X coordinates specified are rounded down to
their nearest multiple of 16. To cancel this
command, use LIMIT SPRITE with no parameters.
Animation
ANIM n,m$ This enables you to page through a chain of
sprite images one after another. This
sequence will be executed at the same time as
your sprite is being displayed, even if it is
also being moved.
n refers to the number of the sprite to which the animation
is to be applied.
m$ holds the animation control string in the same way as the
movement commands do. This takes the format:
"(Image,Delay)[A]"
Image specifies which image is to be used by the sprite
(refer to parameter p of SPRITE) to be displayed during each
step of the animation.
Delay specifies the amount of time that the image will be
held on the screen before the next image is displayed. This
delay is specified in 50ths of a second.
Again, then optional parameter A can be used to specify that
the animation string is to be repeated upon completion by
including L.
ANIM ON/OFF [n] This command is used the same way as MOVE
ON/OFF to turn the animation control on or
off.
ANIM FREEZE [n] This command is used to temporarily suspend
animation until ANIM ON is reissued.
Controlling the sprite using the mouse
CHANGE MOUSE m This allows you to completely redesign the
shape of the mouse cursor. m gives the number
of the image to be used, as follows:
1 Arrow (Default)
2 Pointing Hand
3 Clock
If you specify a value greater then 3, then this is assumed
to refer to sprite image m-3.
=X MOUSE Return the X coordinate of the mouse.
=Y MOUSE Return the Y coordinate of the mouse.
=MOUSE KEY Return the state of the mouse buttons:
0 No button has been pressed
1 Left button pressed
2 Right button pressed
3 Both buttons pressed
LIMIT MOUSE [x1,y1 TO x2,y2]
Restricts the mouse pointer to a rectangle defined by
x1,y1 as the top left hand corner and x2,y2 as the
lower right hand corner and also positions the mouse in
the centre of the box. LIMIT MOUSE with no parameters
will cancel this command.
HIDE [ON] Will hide the mouse pointer and maintain a count of how
many HIDE commands have been used. The equivalent
number of SHOW commands must be used to restore the
mouse. HIDE ON will override the count and always hide
the mouse.
SHOW[ON] Will show the mouse in the same way as HIDE will hide
it.
Reading the joystick (Port 1)
=JOY Returns a bit pattern showing which way the joystick is
being moved.
BIT No. Significance
0 Up
1 Down
2 Left
3 Right
4 Fire button pressed
=JLEFT Returns TRUE if the joystick is being moved left.
=JRIGHT Returns TRUE if the joystick is being moved right.
=JUP Returns TRUE if the joystick is being moved up.
=JDOWN Returns TRUE if the joystick is being moved down.
=FIRE Returns TRUE if the fire button has been pressed.
Detecting collisions with a sprite
=COLLIDE(n,w,h) Test sprite number n for collisions with
other sprites. The collision is detected from
the Hot Spot of the sprite over an area w
wide and h high. The return is a bit pattern
with the appropriate bits 1-15 set if
collision with these sprites has been
detected.
Detecting collision with rectangular blocks
SET ZONE z,x1,y1 TO x2,y2
Defines one of 128 rectangular zones which can then be
tested using the ZONE command for the presence of
either the mouse or a sprite. z specifies a number from
1-128 which represents the zone to be created. x1,y1
and x2,y2 denote the top left and bottom right
coordinates of the zone.
=ZONE(n) This searches the zones for the presence of sprite n. n
can range from 0-15 with 0 representing the mouse. This
function will return 0 if no zone can be detected, or
else it will return the zone number the sprite is
currently in. Note, only the first zone may be found.
RESET ZONE [z] Reset one or all zones.
Detecting collisions with an irregular shape
=DETECT (n) Return the colour directly under the Hot Spot
of the sprite specified (0-15).
PUT SPRITE n Place a copy of sprite n on the screen
directly under the sprite's current position.
This doesn't affect the sprite in any way.
GET SPRITE x,y,i[,mask]
Grabs an image off the screen from
coordinates x,y to image i in the sprite
bank. This image must already exist in the
sprite bank as it's dimensions are used
during the grab. The optional mask allows you
to set which colour is to become transparent.
This is usually colour 0 (the background),
but some interesting effects can be made by
altering this.
Sprite Priority
PRIORITY ON/OFF Determines which sprite priority system is to
be used. ON is used to give priority to the
sprites with the largest Y coordinate. If you
are using this method, it is advisable to set
the hot spot of the sprites to the bottom of
the sprite.
OFF is the default system which gives
priority to sprite 0..1..2... ...15
The Background
AUTOBACK ON/OFF ON (default) causes all graphics commands to
operate on the foreground and background
screens. OFF causes these operations to be
performed on the foreground screen only. (Use
this mode only if you are not using the
sprites or the mouse.)
Miscellaneous sprite commands
UPDATE [ON/OFF] Turn on or off the automatic updating of the
sprites. UPDATE used on it's own will redraw
any sprites which have changed their position
since their last update.
REDRAW Redraw all the sprites regardless of whether
they have changed position.
OFF Turn off all the sprites.
FREEZE Temporarily freeze all sprite movement and
music.
UNFREEZE Resume any sprite movement and music
suspended by FREEZE.