<!-- PDF page 131 -->

#### SPRITE BANK *b [,o, p, n]*

which lets *NextBASIC* know in which bank *b*, are the sprite *patterns* located. Optionally you can define a number *n* of sprite *patterns* beginning with pattern *p*, located at bank *offset o*.

In the case above, we already know the bank and we do not need any more identification factors so let's tell *NextBASIC* where we put the sprites by adding:

```
90 SPRITE BANK a
```

All is now left to do, is show our sprite. For this we need two commands. First we need to enable sprites with:

#### SPRITE PRINT *n*

where *n* can be **0** or **1** enables sprites (**1**) or disables (**0**) them. This is actually showing the sprites, but freshly initialised sprites contain no image (*pattern*), nor display information. We need to assign at least one *pattern* to one sprite "slot" and tell the Sprite System that the particular sprite "slot" is visible for that to happen.

In our example so far (that will soon change), we only have one pattern so that's not particularly difficult. We also need to place the sprite somewhere on the screen AND possibly rotate it. If you go back to our sprite design, you'll see it's a spaceship facing upwards; we may need to make it turn to the left or right. All of the above (and one more thing) can be achieved with a single command:

#### SPRITE *s, x, y , p, f,rf,mx,my*

which in one go: sets sprite number *s*, to pattern number *p*, then update its position to location *x*, y with flags *f,* relative flags *rf,* x-scaling *mx* and y-scaling *my.*

If the sprite id s is negative, this sprite is a relative sprite, and its position is relative to the previous anchor sprite (defined with a positive sprite id). See later for more information on relative sprites. Flags is a bitmask (we've covered bitmasks before in *Chapter 6* so that should be easy already) that sets the following:

Bit **0** is the *visibility* flag. **0** is for invisible and **1** is for visible

Bit **1** is the *rotate* flag. **0** for standard, **1** for a 90° clockwise rotation

Bit **2** is the *Y–mirror* flag. **0** is for non-mirrored vertically while **1** is for mirrored

Bit **3** is the *X-mirror* flag. Again it's **0** for non-mirrored horizontally while **1** is for mirrored

while

Bits **4** through **7** define a 4-bit *palette offset* (or **0**).

The Relative Flags *rf* is also a bitmask that sets the following:

The relative-flags parameter, rf, is also a bitmask:

Bit **0**: type: **0**=composite, **1**=unified [only valid for anchor sprites]

Bit **1**: pattern is relative to the anchor [only valid for relative sprites]

Bit **2**: palette offset is relative to the anchor [only valid for relative sprites]

The scaling parameters *mx* and *m*y are:

0=1x (no scaling)

1=2x

2=4x

3=8x

Any parameters in the **SPRITE** command can be omitted, and its value will be left unchanged from the last time it was explicitly specified. It's a good idea again to use the **BIN** function to easily specify the flag parameters in a more convenient way.

We'll explain in a little bit the part about the *palette offset* but for now, let's add a non-mirrored, non-rotated sprite **0** with the pattern **0** we defined, put it at approximately the centre

