ALRIGHT I HAVE FIGURED IT OUT
I FIGURED OUT THE SPRITE TPL FILES IN GUNGNIR MORE OR LESS
In each TPL file there will be a special image which is not an image at all, but is actually the instructions on how to assemble the randomly assorted image data that the previous image contains. This is how it works. For this example I'm using wine.tpl, which produces three sprites of a wine glass. The assembly data is as follows:
CODE
08 00 00 00 03 00 00 00 20 00 00 00 F4 4F 01 02
2C 00 00 00 F0 1F 01 02 38 00 00 00 EB DF 00 01
00 00 00 00 06 20 00 04 06 00 06 20 01 00 0C 00
09 20 00 04 15 00 07 14 00 00 1C 00 10 18 65 00
Looks like a bunch of crap.
First we have a header of sorts:
CODE
Int: Header Length
Int: Images
Followed by that is Images * 8 bytes of data.
CODE
Int: Offset (relative to header) of image construction code
Byte: Dunno. Usually a negative value.
Short: Dunno. Usually a negative value.
Byte: Construction Commands
The construction commands are actually fairly simple. The offset mentioned above will point to Construction Commands * 6 bytes of data to read in.
CODE
Byte: Horizontal Shift
Byte: Vertical Shift (>>1)
Short: Data start
Byte: Data to read in
Byte: Dunno. Usually 0x20
So yah. Let's parse wine.tpl based on this info:
CODE
Header Length: 0x8
Image Count: 0x3
I1 Offset: 0x20
I1 ?1: 0xF4
I1 ?2: 0x14F
I1 Commands: 0x2
I2 Offset: 0x2C
I2 ?1: 0xF0
I2 ?2: 0x11F
I2 Commands: 0x2
I3 Offset: 0x38
I3 ?1: 0xEB
I3 ?2: 0xDF
I3 Commands: 0x1
I1 Commands:
I1C1 Horizontal Shift: 0x0
I1C1 Vertical Shift: 0x0
I1C1 Data Start: 0x0
I1C1 Run length: 0x6
I1C1 ???: 0x20
I1C2 Horizontal Shift: 0x0
I1C2 Vertical Shift: 0x4 (=0x8)
I1C2 Data Start: 0x6
I1C2 Run length: 0x6
I1C2 ???: 0x20
I2 Commands:
I1C1 Horizontal Shift: 0x1
I1C1 Vertical Shift: 0x0
I1C1 Data Start: 0xC
I1C1 Run length: 0x9
I1C1 ???: 0x20
I1C2 Horizontal Shift: 0x0
I1C2 Vertical Shift: 0x4 (=0x8)
I1C2 Data Start: 0x15
I1C2 Run length: 0x7
I1C2 ???: 0x14
I3 Command:
I1C1 Horizontal Shift: 0x0
I1C1 Vertical Shift: 0x0
I1C1 Data Start: 0x1C
I1C1 Run length: 0x10
I1C1 ???: 0x18
Junk(?): 0x65, 0x00
When dumped as a straight image (scaled to 1000%), we get:
If you try assembling it per the information above, you'll end up with three wine bottle sprites, one standing vertically, one at about a thirty degree angle, and one lying horizontally.
Hopefully a little more exploration will reveal what the unknown fields do, but I have a feeling at least two of them are pointless counters. But first, time to try to generate an algorithm for this shiznass.
Писатель всегда будет в оппозиции к политике, пока сама политика будет в оппозиции к культуре.