LightTenshimaru
November 28th, 2014, 15:57
Hi everyone.
I have a lot of files with extension ".spr" who are compressed in a unique form unlike common .spr files.
Someone in another forum found a little about its structure.
This .spr files stores somes sequential images whos turn into a animation with the second file. Extension .ani
He found:
That's how I think the file is structured ...
npc_priz_card.spr
With the example file, the first image starts at offset 0x00000733 and that address is the base for the pointers.
It seem images start with F0 00 00 00 and are followed by 0x74 bytes with value 0x00. (This is for the few ones I looked into, so I may be wrong.)
After this come the compressed data. (For the first image in the example file it's offset 0x000007AB.)
Data compression is as follows:
The general structure for SPRs is:
Now, the trick to work with those files is to know where each element starts, its size and the encoding.
----------------
I would like someone to help me build a tool that can extract and insert images within these .spr files.
Or even create a valid .spr.
Some files will be attached for analysis.
2956
I have a lot of files with extension ".spr" who are compressed in a unique form unlike common .spr files.
Someone in another forum found a little about its structure.
This .spr files stores somes sequential images whos turn into a animation with the second file. Extension .ani
He found:
That's how I think the file is structured ...
npc_priz_card.spr
Code:
(11 bytes) Signature. ("DCSPRITE10" 00)
(4 bytes) Number of elements in the next 2 tables. (0x98) Maybe number of images.
Start of table 1:
(4 bytes) Width for the first image? (0x00000140 = 320)
... (Repeat for every element in the table. 0x98 times.)
Start of table 2:
(4 bytes) Height for the first image? (0x000000F0 = 240)
... (Repeat for every element in the table. 0x98 times.)
(4 bytes) Multiply by 2 to get pointer to a second structure. (*)
Array of pointers to images (0x98 elements):
(4 bytes) Multiply by 2 to get pointer to first image. (*)
... (Repeat for every element in the table. 0x98 times.)
Start of first image: (Note this is the base offset for the above pointers marked with *.)
... (Here come the images.)
Second structure: (I haven't looked too much into it, but it seems similar to the above structure.)
With the example file, the first image starts at offset 0x00000733 and that address is the base for the pointers.
It seem images start with F0 00 00 00 and are followed by 0x74 bytes with value 0x00. (This is for the few ones I looked into, so I may be wrong.)
After this come the compressed data. (For the first image in the example file it's offset 0x000007AB.)
Data compression is as follows:
Code:
(2 bytes) Number of sub-blocks for first scan line
Sub-block #1:
(2 bytes) Number of 0x0000 that should be injected.
(2 bytes) Number of half-words (each one a pixel in 16bpp format) that follow and are supposed to be injected as they are.
Pixels of sub-block:
(2 bytes) 16bpp color for the pixel.
... (Repeat for every pixel.)
Sub-block #2:
Sub-block #3:
... (Repeat for each sub-block.)
Scan line #2:
Scan line #3:
... (Repeat for every scan line.)
The general structure for SPRs is:
Code:
- Signature.
- Image count.
- Widths for all the images. (Array from 0 To image_count-1)
- Heights for all the images. (Array 0 To image_count-1)
- Pointer to second table ("table 1".
- First table ("table 0":
- Pointers to images. (Array from 0 To image_count-1)
- Collection of compressed images. (image_count images.)
- Pointer to end of secod table or third table?
- Second table ("table 1":
- Pointers to images. (Array from 0 To image_count-1)
- Collection of compressed images. (image_count images.)
Now, the trick to work with those files is to know where each element starts, its size and the encoding.
Code:
a) The signature seems to be the same in all the files you posted:
- It starts at offset 0.
- Its size is 11 bytes (including the 0x00).
- The encoding doesn't matter, but in ASCII it's the string "DCSPRITE10" followed by the byte 00.
b) The image count tells the total number of images that are stored inside the SPR file.
- It starts at offset 11. (Because the signature is fixed.)
- Its size is 4 bytes.
- It's the representation of a 32-bit integer.
c) The widths for the images are an array of integer with the widths in pixels.
- It starts at offset 15.
- Its size is '4*image_count' because each element is 4 bytes long.
- Each element represents a 32-bit integer.
d) The heights for the images are an array of integers with the heights in pixels.
- It starts at offset '15+4*image_count'.
- Its size is '4*image_count' because each element is 4 bytes long.
- Each element represents a 32-bit integer.
e) The pointer to the second table tells where in the file the pointers to the second group of compressed images start.
- It starts at offset '15+4*image_count*2'.
- Its size is 4 bytes.
- It's the representation of a 32-bit integer.
Note: This is not a direct offset in the file, but it has to be multiplied by 2 and added to a base offset instead. (* See below.)
f) The first table of pointers tells where each image from the first table can be found in the file.
- It starts at offset '15+4*image_count*2+4'
- Its size is '4*image_count' as each element is 4 bytes long.
- Each element represents a 32-bit integer.
Note: Each element is not a direct offset in the file, but they have to be multiplied by 2 and added to a base offset instead. (* See below.)
g) The collection of compressed images for the first table has all the images from the first table in compressed form.
- It starts at offset '15+4*image_count*2+4+4*image_count'.
- Its size is variable and it depends on the size of the images and the compression obtained.
- Each element is a compressed image and is described somewhere else.
h) Not sure how to interpret the pointer to the end of the second table (or third table).
- It's start is determined by the pointer explained in (e).
- Its size is 4 bytes.
- It's the representation of a 32-bit integer.
Note: This is not a direct offset in the file, but it has to be multiplied by 2 and added to a base offset instead. (** See below.)
i) The first table of pointers tells where each image from the second table can be found in the file.
- Its start is determined by adding 4 to the offset of (h).
- Its size is '4*image_count' as each element is 4 bytes long.
- Each element represents a 32-bit integer.
Note: Each element is not a direct offset in the file, but they have to be multiplied by 2 and added to a base offset instead. (** See below.)
j) The collection of compressed images for the second table has all the images from the second table in compressed form.
- It starts '4+4*image_count' bytes after the start of the array seen in (h).
- Its size is variable and it depends on the size of the images and the compression obtained.
- Each element is a compressed image and is described somewhere else.
(*) As the size of the data inside the images is always a multiple of 2 bytes, the pointers seem to be expressed as half-words (16 bits) instead of bytes, so they have to be multiplied by 2.
These pointers (multiplied by 2) are relative to a base offset. In the case of the pointers described in (e) and (f), the base offset is the start of (g).
(**) Similar to (*), but the base offset for the pointers in (h) and (i) is the start of (j).
----------------
I would like someone to help me build a tool that can extract and insert images within these .spr files.
Or even create a valid .spr.
Some files will be attached for analysis.
2956