.spr files for Sprite Editor and Level Editor for DS

Yeah, i know: all the world just didn't need was yet another file format for graphics. It would probably have been much easier for most artists if SEDS could just have worked with regular .png and maybe some .xml file for additional meta-data. Well, your DS is not a PC, guys, and i didn't wanted to clutter its RAM with extra import/export libraries while it is soo damn easy to do conversions once the file is retrieved on a PC.

Anyway, the .SPR files are mostly a dump of the DS video memory into a multi-chunk file (IFF-inspired) where you can transparently add information that only some readers will need (e.g. the editor need to know whether there are free tiles to be reallocated, while the game engine and the level editor don't care). Each chunk looks like

 +-4 bytes-+---------+--/ /-------+
 | T A G G |  size   | chunk data |
 +---------+---------+------------+

struct SprFileUnknown {
    u32 magic;
    u32 skipsize;
};
The TAGG (or magic) field is a 4-character identifier that indicate the content of the chunk. The two most important chunks will be CMAP that encode colors in DS' RGB15 format and TILE that stores unpacked pixels (tile per tile, thus 8x8 8-bit color index at once). The "chunksize" (also known as skipsize) is the amount of bytes for the chunk data. It allows readers to skip chunks they do not understand.


 +-4 bytes-+---------+---------+--/ /----------------+
 | C M A P |  size   | #colors | PALETTE memory dump |
 +---------+---------+---------+---------------------+

struct SprFileCmap {
    u32 magic;
    u32 skipsize;
    u32 ncols;   // bits 8-32 reserved
};

 +-4 bytes-+---------+---------+--/ /-------+
 | T I L E |  size   | #tiles  | chunk data |
 +---------+---------+---------+------------+

struct SprFileTile {
    u32 magic;
    u32 skipsize;
    u32 ntiles;  // bits 16-32 reserved
};

There are two major kind of spritesets (.spr files) that divert from how the content of the TILE area is used to form logical objects. The files generated by the Sprite Editor on the DS also contain 'BLCK' sections describing 'sprite pages', while the png->spr conversion script adds a 'TMAP' section that describes which tile goes where to form the complete image on a tile-by-tile basis (that can be moved into a 'map' region of the VRAM to display the whole image on the DS).

a demo .spr file for testing purposes.

Converting .spr to .png

The spr2png.pl script should be present in binary releases of the SpriteEditor. If you have downloaded a demo version (standalone .nds), you're suggested to download it now. This script is meant to be invoked from command line as

   perl spr2png.pl mysprites.spr nicefile.png
If you don't have perl installed on your system, please figure out how to install it first. It is a free, cross-platform interpreted and efficient language that perfectly fits the purpose of such file conversion tasks. You will also need the Image::Imlib2 package to be able to produce .png files.

Upload your .spr to convert it into .png

In the event you do not manage to use the spr->png converter script provided with SEDS (or that you're abroad and don't have your perl installation available) we provide you a "web service" for such translation. Upload your .spr file and you'll receive a png file with the content of the spritesheet. Please note that this is intended for use with sprites coming from SEDS only. Trying to convert back something generated with imlib2spr.pl will fail sooner or later.

attach
powered by ...
SourceForge.net Logo
Sylvain Martin
Last modified: Mon Oct 28 15:25:45 CET 2002