• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

Wiimms SZS Tools

Bighead

Smash Rookie
Joined
May 29, 2017
Messages
2
Hi everyone, I'm not sure where else to go with this question so I ended up on these boards hoping someone here can help me. I am one of the main contributors to the Paper Mario: TTYD texture pack on the Dolphin forums. Using Wiimms SZS tools and xxhash I wrote a powershell script to dump the entire game disc, extract all the textures, hash them with xxhash to the name Dolphin would use, and organize them into folders.

But it seems I hit a snag with certain textures. According to this page, there are three palette formats.

0x00 IA8 2
0x01 RGB565 2
0x02 RGB5A3 2

Whenever these textures are converted with Wiimms tools, they just come out as grayscale textures. Is there some kind of flag or option that I can send wimgt.exe to let it know these are palette formats? According to this page, they are supported. I appreciate any help anyone can offer.
 

DRGN

Technowizard
Moderator
Premium
Joined
Aug 20, 2005
Messages
2,175
Location
Sacramento, CA
If you're talking about encoding, you need to append a string designating the palette type to the end of the format string. For example, for a command given through command line when using the -x option:

[pathToWimgt.exe] copy [pathToSomeImage.png] "[newImagePath.tpl]" -x tpl.c8.P-RGB5A3

That will convert PNG file to a paletted CI8 (type _9) TPL format, using the third palette type you listed (you should be able to use the other two with ".P-IA8" or ".P-RGB565"). If you want to convert from TPL to PNG, you shouldn't need to specify the palette type. For example:

[pathToWimgt.exe] copy [pathToSomeImage.tpl] "[newImagePath.png]"

I wrote a script that allows you to do conversions between these with multiple files by drag-and-drop, "PNG to-from TPL.bat", which can be found here. It comes with the standard DTW program download. But you can also find more info on it in the "Old Tools" spoiler. It will automatically detect what direction/conversion to use. Note that the script cannot determine whether the images use transparency, so for paletted images, the palette type is specified within the script, which you can easily edit (you'll find a variable toward the beginning of the script).

However, be warned that wimgt doesn't preserve palettes; it will create a new palette, not always preserving exact colors, if encoding an image to TPL (even if the given image already has a palette); and it will discard palettes when decoding to PNG (the resulting image will be RGBA with no palette. I don't remember if I ever tested whether it will preserve the exact colors). wimgt also does not properly handle transparency when it comes to palettes in PNG format (incomplete handling of the tRNS chunk IIRC). This and other reasons led me to write my own TPL codec for DTW in python. A frontend would need to be written for it if used for something else that's not written in python, but I can send you the source code for it if you'd be interested in playing with it.

What are you sending to xxhash to generate a hash? And is this for the old or new naming format?
 

Bighead

Smash Rookie
Joined
May 29, 2017
Messages
2
Some of this may be hard to follow without the context of the powershell script but I'll do my best to explain what I'm doing. I don't have a very good understanding of Wiimms tools so I may be doing something wrong. Here goes.

First I extract the disc image with wit using the command:

wit extract $GameISO $DiscExtract

This gives me a folder with all the contents of the disc. The next step is to loop through all extracted disc files, and extract the contents of each file. Most of the time these are TPL files, some don't have a file extension but I'm assuming they follow a similar format since they do extract. The ExportPath is equal to the name of the file being extracted. So if "battle_common.tpl" is the current loop item, the exported path will be to a folder named "battle_common". If multiple files with the same name are found, an integer is appended to the end of the folder (for example, PM:TTYD has over 300 "t" files, so over 300 "t" folders are created, like t_000, t_001, t_002, ..., t_312, etc). This scheme is also used for the final texture folder, and lets me rearrange the textures later on.

wszst extract $FilePath --recurse --decode --number -d $ExportPath

This gives me a folder with the file name, and the file's contents (raw images), per file found. Now this next part uses some trickery. I once again loop through all disc files, find the matching folder based on the file name, then loop through that folder. Here PNG images are created from the extracted disc file into that same folder.

wimgt decode $FilePath --number -D ($FolderPath + '\image.png')

This PNG will now be renamed to a Dolphin texture. The dimensions are pulled from the extracted file name (ex: image-0.184x216.CMPR), this raw image is sent through xxhash (ex: 9528c4565b936dad), and its CMPR format so we know its identifier is 14. So put it all together and we get "tex1_184x216_9528c4565b936dad_14". This is exactly what Dolphin would dump, I have verified a few hundred textures and they are all correct. This newly named image is then moved to a separate folder, using the same name scheme as the extracted files from the disc.

The final step is to re-arrange/rename all texture folders into something useful. This step is not important to discuss since its just a bunch of moving stuff around to end up with this: http://i.imgur.com/wAfKC27.png

So the TPL files are ran through wimgt to create the PNG image, but the corresponding extracted CMPR files are where the hashes and dimensions come from and serve no purpose other than to provide this information.

Now with all that said....

I have managed to fix the issue with the loss of color by running this command:
wimgt decode $FilePath --transform 'RGBA32' --number -D ($FolderPath + '\image.png')

Adding (--transform 'RGBA32') kinda works, but, transparency is not preserved in some textures. I was wrong in my assumption that this only affects paletted types, as its also affecting some CMPR textures as well. It's seemingly random which ones lose transparency, as most PNG images are correctly created with an alpha channel. But there are some that aren't for some reason.

So really I guess my only issue right now is preserving transparency when creating (some) PNG images, as most come out fine.

Basically the only purpose of all this is to dump the images into names that Dolphin recognizes. This will mostly only be used by contributors to the PM:TTYD pack. The images themselves serve as a template of all PM textures that will be redrawn, so its not extremely important that the images have transparency since common sense will usually notify the artist that the black background is not meant to be there. But I'm OCD and would like to get it working 100% so the artist knows exactly what it is they need to redraw.

EDIT: I guess all this can be ignored. I contacted Wiimm and apparently its a bug.

Wiimm said:
Now I know what you mean.
The tools tries always to find the optimal PNG format. And here only grayscale is used at the main image (first image). And TPL is special, because it supports multiple images. Internal they are manages like mipmaps and stored in the same format as the first image.

Thanks for pointing this bug! it is now at my to-do list.
 
Last edited:
Top Bottom