marco-calautti / Rainbow

A texture format converter for different consoles' graphics formats.
GNU General Public License v2.0
81 stars 8 forks source link

Invalid Bit Depth #2

Closed chrispable closed 9 years ago

chrispable commented 9 years ago

Rainbow is throwing some invalid bit depth errors on textures I manually extract from an archive.

The TIM2 first 16 byte header looks like it is intact correctly (TIM2, version, id, pictures and padding) when I pull the data out.

marco-calautti commented 9 years ago

Hi! Thank you for opening the issue. I had a look to the file you sent me. Actually, the problem is not the bit depth, but the TIM2 header itself. It seems that it has been added something in the middle of the header, which shifts every value. By the way, even getting rid of these additional bytes, the image data seems to be either corrupted or compressed. I even tried to open the raw graphics part with tile molester and TiledGGD, but it shows up like garbage data. You should first look at how these TGCD archives (containing the TIM2s) work. It might be the case that these are compressed archives, or something like that. By the way, what game are you working on? Is that a PS2 game or a PSP game?

marco-calautti commented 9 years ago

I checked in more details these archvies and I am 99% sure they are compressed archives. You can see, after the TGCD magic word two 32bit unisgned integers, representing the size of the decompressed TIM2 and the size of the compressed TIM2 respectivelly. In fact, considering a 256x64 4bit tim2 image with RGBA palette. The decompressed size is always 0x2080, which matches perfectly the size of the header (0x40 bytes) plus the size of the palette (0x40 bytes) plus the size of the pixel data (256x64/2=0x2000 bytes). So, you better find a way to decompress these TIM2s first, and then I'm pretty sure you will be able to use Rainbow to open and change them.

chrispable commented 9 years ago

Thanks for getting back to me so quickly. I looked at the general tim2 header and it seemed to jive with the spec I saw for the first 16 bytes. That game is actually a ps2 arcade game, DDR sn2. It's predecessor I actually was able to get some graphics to display by pasting a generic header and tweaking the bits.

I'll take a look at the compression, maybe I can figure out out. Not sure though.

I'll try and get you the file I was able to open from the predecessor. I know for fact it wasn't compressed.

Thank you again and thank you for the incredibly quick and detailed response.

marco-calautti commented 9 years ago

A good way to start finding out how the game decompresses the TIM2s is to dump the ps2 main memory and look for the decompressed TIM2. Try opening that TIM2 with Rainbow and let me know if there is some problem in that case.

Thank you for using Rainbow ;).

chrispable commented 9 years ago

Haha easy to do but then I wouldn't know what TIM2 corresponds with which file in the archive. Sadly most of the binary is encrypted so I'll see what I'm able to figure out.

marco-calautti commented 9 years ago

If it's ok with you, we can continue discussing by mail, this way I can set the issue as solved ;).

chrispable commented 9 years ago

Of course. I'll send you a mail.