Skip to content

spriteslib

Sprites are small images that the Amiga’s hardware shows on top of the display, without changing the bitmaps under them. A sprite is a Blitz object, numbered from 0. GetaSprite makes one from a shape of 4 or 16 colours, so all the shape commands can prepare its image first; the shape can then be freed to save chip memory. ShowSprite shows it on one of the eight sprite channels of the used slice, in Blitz mode:

GetaSprite 0,0
Free Shape 0
BLITZ
ShowSprite 0,160,100,0

A sprite channel is 16 pixels wide (32 or 64 pixels with the AGA chip set and SpriteMode). A wider sprite takes the channels after the one given, and a 16 colour sprite takes two channels for each part, joined as an attached pair. The colours of channels 0 and 1 are colour registers 17 to 19, those of channels 2 and 3 registers 21 to 23, and so on; a 16 colour sprite uses registers 17 to 31.

InFront, InFrontF and InFrontB decide which sprites appear in front of the bitmaps and which behind them. SaveSprites and LoadSprites keep sprites in a file of their own.

Based on the spriteslib guide by Acid Software.

Library number 112. It manages Sprite objects, by default at most 20 (the compiler options set the maximum).

Commands

GetaSprite

Makes a sprite from a shape of 4 or 16 colours, with the shape’s handle. The old image of the sprite is freed.

Statement. Help text: Sprite#,Shape#
Arguments: .w, .w

With runtime error checking, a shape of another number of colours is the error “Shape MUST be 4 or 16 colours”, one too wide for the sprite channels “Sprite too Wide”: a 4 colour shape may be 8 sprites wide, a 16 colour shape, which takes two channels per sprite, 4 (in SpriteMode 0 128 and 64 pixels). Where the shape ends inside the last sprite, the rest of that sprite is empty.

InFront

Sprites on channels from Sprite Channel on appear behind the bitmaps of the used slice, those on lower channels in front of them. Sprite Channel is an even number from 0 to 8. Blitz mode only.

Statement. Help text: Sprite Channel
Arguments: .w

After InFront 4, sprites on channels 0 to 3 appear in front of the bitmaps and those on channels 4 to 7 behind them. For a dual playfield slice, use InFrontF and InFrontB.

InFrontB

As InFront, for the background playfield of a dual playfield slice. Blitz mode only.

Statement. Help text: Sprite Channel
Arguments: .w

InFrontF

As InFront, for the foreground playfield of a dual playfield slice. Blitz mode only.

Statement. Help text: Sprite Channel
Arguments: .w

With InFrontF and InFrontB together, sprites can appear at three depths: in front of both playfields, between them, and behind both.

LoadSprites

Loads sprites saved with SaveSprites into the sprite objects from the first Sprite# on, up to the second if it is given. Amiga mode only.

Statement. Help text: Sprite#[,Sprite#],Filename$
2 forms:

  • .w, $
  • .w, .w, $

When the file has fewer sprites than the range, the sprite after the last one loaded is freed and the others stay as they are. The errors are those of SaveSprites. Each sprite keeps the size it was saved with, whatever the current SpriteMode.

SaveSprites

Saves the sprites from the first Sprite# to the second into a file. Amiga mode only.

Statement. Help text: Sprite#,Sprite#,Filename$
Arguments: .w, .w, $

A file that cannot be opened is the error “Can’t open Sprites file”, a failed write “Error reading/writing Sprites file”. Each sprite is saved in the size of the SpriteMode it was made in.

ShowSprite

Shows a sprite on the used slice at X,Y, always in low resolution pixels, through sprite channel Sprite Channel (0 to 7) and, for a wide or 16 colour sprite, the channels after it. Blitz mode only.

Statement. Help text: Sprite#,X,Y,Sprite Channel
Arguments: .w, .w, .w, .w

The sprite is cut at the top and the bottom of the slice, and switched off when it is completely outside. With runtime error checking, a channel the sprite does not fit into is the error “Sprite Channel Unavailable”.

Sprite

The object of a sprite, its image in chip memory and its handle, as the introduction describes.

Object name. No help text.

SpriteMode

The width of the sprite channels for the sprites made and shown after it, 0 for 16, 1 for 32 and 2 for 64 pixels. The wider modes need the AGA chip set and a display of the display library set up for them.

Statement. Help text: 0=16 1=32 2=64
Arguments: .w

With runtime error checking, a mode above 2 is the error “Illegal SpriteMode”. Sprites made before keep the size of their own mode.