Monday, October 5, 2009

R-Type Final

Been a while, not much interest lately. Heres the deal. I decoded the P6T format and am at 90% or so on the IMD format.

To the left are skins for the ships. There are a little more than 2000 textures. The blue, black, garbage looking textures are 4-bit swizzled and I haven't yet worked that out. I'll try to describe the P6T format as best as I have understood it.

The beginning of the file is a header, its size is 0x0000-0x002C. It contains an 8 character identifying code from 0x00 followed by the width and height as 16-bits each. All data except for colors and pixels are 16-bit values null padded to 32-bit. For example, a width of 128 pixels would be stored as 0x80000000. (This also applies to IMD format where all data except vertices is 16-bit, where verts are 32-bit IEEE floats.) Width and height are followed by an offset to the CLUT, or NULL if the image is 32-bit direct color. This is followed by an offset to the pixel data itself. I dont know what the next 10 bytes are used for but there are at least two 16-bit values at 0x1C and 0x1E(often 0x0200 0000 0100 0000). The next 16-bits are the 'index flag'. This flag indicates if the file is 32-bit direct color or 4/8-bit indexed. Known values are 0x0000 for 32-bit and 0x0100 for indexed. There is one more unknown 16-bit value after this.

As far as pixel format goes there are three verisons. 32-bit indexed color in RGBA format and 8 or 4-bit swizzled indexed color. The oddball is the swizzled format. Swizzling is an optimization technique for PS2(and other GPU's) that rearranges the pixels in such a way that the GPU can read sequential blocks of pixels. I'm not really clear on the algorithm and admittedly borrowed my 8-bit deswizzle code from another project. I don't yet have 4-bit working, I have a borrowed deswizzle that works but I dont yet have a 4-bit to 8-bit conversion. The other hitch is that the CLUT for indexed color is arranged in an unusual way. Instead of each color in order, 0-255, they are in blocks. Color 0-3, 9-12, 4-7, 12-15, etc...

The pixels are simple, either 4 or 8 bit indices into the CLUT or 32-bit RGBA direct color.

No comments:

Post a Comment