Difference between revisions of "SPR Spritesheet"
MrGudenheim (talk | contribs) m (→Palette Data: removed duplicate word) |
MrGudenheim (talk | contribs) m |
||
(16 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | SPR (Unit Sprite) files contain the bitmap data for a sprite. Sp2 are similar format used for extra images used by MON shp types. | + | SPR (Unit Sprite) files contain the bitmap data for a sprite. Sp2 are similar format used for extra images used by MON shp types, but they do not have palette data or compressed regions. |
− | |||
== Palette Data == | == Palette Data == | ||
The file starts with the palette data and contains 256 colors (512 bytes), 16 palettes of 16 colors each. Palette's use 2 bytes per color, 1 bit for alpha, followed by 5 bits per channel (B,G,R). The first 8 palettes are for the unit, the second 8 palettes are for the portrait. | The file starts with the palette data and contains 256 colors (512 bytes), 16 palettes of 16 colors each. Palette's use 2 bytes per color, 1 bit for alpha, followed by 5 bits per channel (B,G,R). The first 8 palettes are for the unit, the second 8 palettes are for the portrait. | ||
− | == Data == | + | OTHER.SPR is a special case and has 512 colors. 5 palettes each for chicken, frog, chest, and crystal, an all black palette between crystal and chests, and 11 mostly black palettes at the end that are normally unusable. |
− | Each | + | |
− | The lower half of unit spritesheets (the | + | == Pixel Data == |
+ | Each set of 4 bits is the palette color index of the pixel. The total decompressed spritesheet is 256 pixels wide and 488 pixels tall. | ||
+ | |||
+ | The lower half of unit spritesheets has compressed regions (see [[Decompress Attack spritesheet]]). This starts at file offset 0x9200 (row 288). Non-unit sprites, such as OTHER and WEP do not have the compressed section. The portrait and body parts in the row are in the uncompressed portion of the spr. | ||
+ | |||
+ | The compression algorithm is: 0 - some half byte - how many 0s there are | ||
+ | |||
+ | if halfbyte = 0, 1 digit in number of 0s | ||
+ | |||
+ | if halfbyte = 7, 2 digits in number of 0s | ||
+ | |||
+ | if halfbyte = 8, 3 digits in number of 0s | ||
+ | |||
+ | if halfbyte != [0,7,8], number of 0s = halfbyte | ||
+ | |||
+ | Example: 08100 is the hex string for 256 0s (128 bytes of 0). | ||
+ | |||
+ | Note, when looked at in the rom in a hex editor, 08100 may appear as 08001 due to little-endian format. |
Latest revision as of 14:07, 19 January 2025
SPR (Unit Sprite) files contain the bitmap data for a sprite. Sp2 are similar format used for extra images used by MON shp types, but they do not have palette data or compressed regions.
Palette Data
The file starts with the palette data and contains 256 colors (512 bytes), 16 palettes of 16 colors each. Palette's use 2 bytes per color, 1 bit for alpha, followed by 5 bits per channel (B,G,R). The first 8 palettes are for the unit, the second 8 palettes are for the portrait.
OTHER.SPR is a special case and has 512 colors. 5 palettes each for chicken, frog, chest, and crystal, an all black palette between crystal and chests, and 11 mostly black palettes at the end that are normally unusable.
Pixel Data
Each set of 4 bits is the palette color index of the pixel. The total decompressed spritesheet is 256 pixels wide and 488 pixels tall.
The lower half of unit spritesheets has compressed regions (see Decompress Attack spritesheet). This starts at file offset 0x9200 (row 288). Non-unit sprites, such as OTHER and WEP do not have the compressed section. The portrait and body parts in the row are in the uncompressed portion of the spr.
The compression algorithm is: 0 - some half byte - how many 0s there are
if halfbyte = 0, 1 digit in number of 0s
if halfbyte = 7, 2 digits in number of 0s
if halfbyte = 8, 3 digits in number of 0s
if halfbyte != [0,7,8], number of 0s = halfbyte
Example: 08100 is the hex string for 256 0s (128 bytes of 0).
Note, when looked at in the rom in a hex editor, 08100 may appear as 08001 due to little-endian format.