BASIC SPRITE Statements and Functions - fvdhoef/aquarius-plus GitHub Wiki
TYPE: plusBASIC graphics statement
FORMAT: DEF SPRITE spritedef , def_list
Action: Creates a sprite definition data structure.
- This data structure specifies the spritles that comprise the sprite, and their relative positions.
- spritedef is the string variable that will contain the sprite definition.
- def_list is a series of spritle specifiers separated by semicolons.
- Each spritle specifier consists of three byte values:
- The spritle number (
0
through63
). - The spritle X-offset.
- The spritle Y-offset.
- The spritle number (
plusBASIC v0.24b
FORMAT: DEF SPRITE spritedef , ^ stringvar
Action: As above, but creates the sprite definition from a string list.
- stringvar is a binary string containing a series of spritle specifiers
- Each spritle specifier consist of 3 bytes: spritle number, X-offset and Y-offset.
Examples
100 D1$=$"010000":'Spritle 1, X-offset 0, Y-Offset 0
102 D2$=$"020800":'Spritle 2, X-offset 8, Y-Offset 0
104 D3$=$"030008":'Spritle 3, X-offset 0, Y-Offset 8
108 D$=D1$+D2$+D3$
120 DEF SPRITE S$ = ^D$
TYPE: plusBASIC graphics statement
FORMAT: SET SPRITE spritedef commandlist [ ; commandlist ...]
Action: Sets the properties of a sprite.
- spritedef is a string containing the sprite definition.
-
commandlist is a series of the following commands that set various properties of the sprite.
-
ATTR attrlist
- attrlist is a string of attributes to created with the DEF ATTRLIST statement.
-
PALETTE palletelist
- palletelist is a string of palette numbers created with the DEF PALETELIST statement.
-
TILE tilelist
- tilelist is a string of tiles indexes created with the DEF TILELIST statement.
-
ON
- Enables the sprite, making it visible on the screen.
-
OFF
- Disables the sprite, making it no longer visible.
-
POS x , y
- Moves the sprite to screen pixel coordinate x , y.
-
ATTR attrlist
Examples
SET SPRITE S$ TILE T$ ATTR A$ POS X,Y ON
Sets tile and attributes for the individual spritles, positions the sprite at coordinates X,Y and enables the sprite.
SET SPRITE S1$ POS X1,Y1; S2$ X2,Y2; S3$ X3,Y3
Moves sprites S1$, S2$, and S3$ to coordinates (X1,Y1), (X2,Y2), and (X3,Y3), respectively.
FORMAT: SET SPRITE * command
Action: Sets properties of all spritles.
-
command can be either of the following.
-
CLEAR
- Clears all spritles, setting all of their properties to 0.
-
OFF
- Disables all spritles, making them no longer visible.
-
CLEAR
Examples
SET SPRITE * OFF
Disables all spritles.
SET SPRITE * CLEAR
Clears all spritles.
TYPE: plusBASIC graphics function
FORMAT: GETSPRITE$ ( spritedef )
Action: Returns a string containing the properties of all the spritles in a sprite.
- spritdef is a string containing a sprite definition created with the DEF SPRITE statement.
- Returns a binary string containing 5 bytes for each spritle in the sprite.
Result String
Offset | Description |
---|---|
0-1 | X-position |
2 | Y-position |
3-4 | Attrs+Tile |
Bits | Description |
---|---|
0-8 | Tile Index |
9 | Flip Horzontal |
10 | Flip Vertical |
11 | Double Height |
14 | Priority |
15 | Enable |
Example
- Warning: This code has not been tested.
700 REM 'Print Sprite Properties
710 GS$=GETSPRITE$(S$)
720 FOR I=1 TO LEN(GS$) STEP 5
730 PRINT " X: ";WORD(GS$,I);
735 PRINT " Y: ";ASC(GS$,I+2);
740 GA=WORD(GS$,I+3)
750 PRINT "Tile:";GA AND 511;
760 PRINT "FlipH:";ABS(BIT(GA,9));
765 PRINT "FlipV:";ABS(BIT(GA,10));
770 PRINT "DHeight:";ABS(BIT(GA,11));
780 PRINT "Priority:";ABS(BIT(GA,14));
785 PRINT "Enabled:";ABS(BIT(GA,15));