Posts: 1,649
Threads: 99
Joined: Jan 2009
2013-11-15, 03:42 AM
(This post was last modified: 2013-11-15, 03:45 AM by HwitVlf.)
The info in that document was a work in progress so it's not necessarily complete. If you're trying to convert the KFTIM to a regular TIM then you need to build the missing parts of the TIM header.
The missing parts needed for the first 20 bytes of the TIM header:
"10 00 00 00" TIM tag
always the same in every TIM
"08 00 00 00" BPP tag
Though all KFTIMS I saw were 4BPP, there might be other types. This value is not directly in the KFTIM as far as I know, but you could calculate it from the KFTIM's "colors in CLUT" value at 0x4-5. A CLUT with 16 colors would always be 4BPP etc.
"2C 00 00 00" Size of CLUT+12
This data in not directly in the KFTIMs either, but could be calculated from the KFTIM's "colors in CLUT" and "Number of CLUTs" at 0x4-7.
"42 02 FF 01" Palette load coordinates
These are not needed and can be left blank.
"10 00 01 00" Colors in CLUT and number of CLUTs
This is in the KFTIM at 0x4-7 and repeated at 0xC-F
After the above parts of the TIM header comes the CLUT palette which can be directly copied from the KFTIM.
After the CLUT palette the TIM needs 12 more bytes of header:
"0C 80 00 00" This is the image data size +12
This is not in the KFTIM directly, but can be calculated from image width and height (0x34-37 in KFTIM). For example a 256x256 image would have 256*256 pixels (65536). In a 4BPP image each byte would represent 2 pixels so we divide the previous number in half (65536/2). So the image data is 32768 bytes big. Add 12 to the that final at and we get 32780. Which is 0x800C in hex. As seen backwards in the TIM it would be "0C 80 00 00".
"C0 03 00 01" Image coordinates in RAM
These are not needed and can be left blank.
"40 00 00 01" Image width/4 and image height
These are in the KFTIM at 0x34-37 and again at 0x3C-3F. They're shown in green and pink in the picture, but I confused things because the "Normal TIM" pic shows a 256x256 TIM and the KFTIM shows a 64x64 image. These values can be directly transfered from KFTIM to TIM.
Finally, just tack the KFTIM image data onto the end of the header described above and viola! A bouncing baby named TIM is born.
Does that answer your question?