Wiki

Clone wiki

agtools / Tutorial 3 - Preparing Sprite Data

Preparing Sprite Data:

All of tutorial 3's steps depend on some sprite files which get produced by makedata.sh. We'll look at this process in a bit more detail here.

The first few lines of makedata.sh look something like this:

-cm imspr -gm -prv -vis -s tutor3_spr.png -crn 224 -p xpal.pi1 -o armor.ims -sxp 96 -syp 0 -sxs 16 -sys 16 -sc 1
-cm emspr -prv -vis -s tutor3_spr.png -crn 224 -p xpal.pi1 -o spinner.ems -sxp 80 -syp 0 -sxs 16 -sys 16 -syi 16 -sc 8
-cm emxspr -prv -vis -s tutor3_spr.png -crn 224 -p xpal.pi1 -o ball.emx -sxp 64 -syp 0 -sxs 16 -sys 15 -syi 15 -sc 8
-cm emxspr -prv -vis -s tutor3_spr.png -crn 224 -p xpal.pi1 -o n.emx -sxp 0 -syp 94 -sxs 25 -sys 23 -sc 1

Each of these commands cuts a sequence of sprite frames to a distinct sprite asset file.

The -s switch specifies the source image containing the sprite material. The -o switch is the output filename.

As the sprites are cut, the images are being remapped to fit a palette which has been prepared in advance, using the -p switch. The palette file we're using here is a Degas .PI1 format xpal.pi1 This ensures all sprites end up using the same palette as the playfield map.

The -crn switch renormalises/rescales the source image to remove up-scaling of RGBs which happens when saving 16 colour graphics as 24bit PNGs, when using screengrabs or some graphics packages. Here we rescale 0-255 back to 0-224 (maximum for the eight intensity levels 0-7 for the original Atari ST source material. 8x32=256, 7x32=224).

If source images are already reduced to 16 colours, agtcut will not remap the images. It will assume you have done that. If your input images then don't agree on the palette beforehand... you'll have problems. You can mix colour-reducing with pre-reduced cutting steps and use the results in the same program - if you're careful to ensure the specified reduction palette (e.g. xpal.pi1) is the same as used by any pre-reduced 16 colour source images. In any case, pay attention to palettes - it can be a source of confusion.

The -prv switch gives you an ASCII preview of the sprite frames - it helps confirm you're cutting from the correct coordinates, and that the mask has been picked up, and not turning transparent areas solid.

The '-vis' switch gives you a .TGA preview (review?) after cutting. It's a bit more helpful than -prv for proper inspections. Colour reduction results are also visible in the review.

We don't need to specify the key (transparent) colour index, since we're colour reducing from RGB with each of these source images, and we've painted transparent areas in magenta. This is the default keyrgb in agtcut so thats fine left as it is. For setting the key index for pre-reduced art, or for alternate keyrgb colours, see agtcut's usage guide.

The -cm switch specifies the cutmode - the asset format to produce. Here we cut all 3 sprite formats: emspr, emxspr, imspr (earlier versions used 'sprites' for imspr format, but has been changed in agtcut v0.35 onwards for consistency).

Note that we pass -gm for the imspr case because its a general format used by both STE/Blitter and STF. The -gm switch generates explicit mask data for STE. It should be omitted for STF, since masking is implicit in the sprite routine itself (any non-zero colour is solid, zero is transparent).

The remaining switches specify the cutting coordinates, cutting frame size, the stride or increment between each frame to be cut and the number to cut (in rows, columns or a grid of rows).

See agtcut's usage guide for more information on cutting sprites, the switches involved and ways to perform more complex cutting via spriteguide scripts.

Updated