wii¶
Support for Wii ISOs, archives, textures and fonts.
ISO, ARC, TPL and BREFT files are handled with the wit, wszst and wimgt tools from Wiimms ISO/SZS Tools, which need to be installed separately. BRFNT fonts are converted by calling the brfnt2tpl executable externally.
- hacktools.wii.extractARC(infolder, outfolder)[source]¶
Extract all the .arc files in a folder with wszst.
- hacktools.wii.extractTPL(infolder, outfolder, splitName=True, flatten=False)[source]¶
Extract all the .tpl files in a folder to png with wimgt.
- Parameters:
infolder (str) – Path of the folder to scan.
outfolder (str) – Path of the folder to extract to.
splitName (bool) – Whether to name the output subfolder after the first component of each file path, instead of mirroring the whole path.
flatten (bool) – Whether to extract the files inside a .arc folder directly in it, instead of mirroring its inner folder structure.
- Return type:
None
- hacktools.wii.repackTPL(infolder, workfolder, outfolder)[source]¶
Repack modified pngs into the .arc folders extracted by extractARC.
For each png in workfolder that matches a .tpl file in infolder, the containing .arc folder is copied to outfolder, then the png is encoded over the tpl with wimgt, keeping the original image and palette formats.
- Parameters:
infolder (str) – Path of the folder extracted by
extractARC().workfolder (str) – Path of the folder with the modified pngs.
outfolder (str) – Path of the folder the .arc folders are copied to.
- Return type:
None
- hacktools.wii.repackARC(workfolder, outfolder)[source]¶
Repack all the .arc folders in a folder with wszst.
- hacktools.wii.extractBREFT(infolder, tempfolder, outfolder)[source]¶
Extract all the .breft files in a folder to png.
The files are first extracted with wszst to the temp folder, then every texture found in them is decoded with wimgt.
- hacktools.wii.extractBRTEX(infolder, tempfolder, outfolder)[source]¶
Extract all the .brtex files in a folder to png.
The files are extracted with wszst to the temp folder, alongside the paired .brplt files when they exist, then every texture is converted to a temporary TPL and decoded with wimgt.
- hacktools.wii.repackBRTEX(infolder, tempfolder, workfolder, outfolder)[source]¶
Repack modified pngs into .brtex and .brplt files.
For each folder in workfolder that matches a .brtex file in infolder, the file is extracted with wszst to the temp folder, alongside the paired .brplt file when it exists. Every png is encoded to a temporary TPL with wimgt, keeping the original image and palette formats, and the data is copied back into the TEX0 and PLT0 textures. The files are then rebuilt with wszst into outfolder.
- hacktools.wii.extractBRFNT(infile, outfile)[source]¶
Extract a BRFNT font to png, with brfnt2tpl and wimgt.
- hacktools.wii.repackBRFNT(outfile, workfile)[source]¶
Repack a png into a BRFNT font, with brfnt2tpl.
- hacktools.wii.repackIso(isofile, isopatch, workfolder, patchfile='')[source]¶
Repack an ISO with wit.
- hacktools.wii.getTexDataSize(width, height, format)[source]¶
Calculate the data size of an image in the given GX format.
- Parameters:
width (int) – Width of the image.
height (int) – Height of the image.
format (int) – Format of the image data.
- Returns:
The size of the block-aligned image data.
- Return type:
int
- hacktools.wii.getTexTransform(texfile, palfile=None)[source]¶
Read the image and palette formats of a TEX0 texture.
- hacktools.wii.texToTPL(texfile, tplfile, palfile=None)[source]¶
Convert a TEX0 texture and its optional PLT0 palette to a TPL file.
- hacktools.wii.tplToTex(tplfile, texfile, palfile=None)[source]¶
Copy the image and palette data of a TPL back into TEX0/PLT0 files.
The palette is padded to the original color count when possible, so the PLT0 file layout is unchanged.
- class hacktools.wii.TPL[source]¶
Structure of a TPL texture file.
Format reference: http://wiki.tockdom.com/wiki/TPL_(File_Format)
- imgnum¶
Number of images in the file.
- tableoff¶
Offset of the image table.
- images¶
List of images in the file.
- class hacktools.wii.TPLImage[source]¶
Structure of a single image in a TPL file.
- imgoff¶
Offset of the image header.
- paloff¶
Offset of the palette header, 0 if the image has no palette.
- palformat¶
Format of the palette colors, only 0x02 (RGB5A3) is supported.
- paldataoff¶
Offset of the palette data.
- palette¶
Palette colors, as a list of RGBA tuples.
- width¶
Width of the image.
- height¶
Height of the image.
- format¶
Format of the image data, only 0x02 (IA8), 0x08 (C4) and 0x09 (C8) are supported.
- dataoff¶
Offset of the image data.
- tilewidth¶
Width of a single tile.
- tileheight¶
Height of a single tile.
- blockwidth¶
Width rounded up to a multiple of the tile width.
- blockheight¶
Height rounded up to a multiple of the tile height.
- hacktools.wii.writeTPL(file, tpl, infile)[source]¶
Write png images back into a TPL file.
The first image is read from infile, the following ones from .mmN.png files next to it, with N being the image number. If an image size changed, the new size is written in the header.
- hacktools.wii.getFontGlyphs(file, encoding='shift_jis')[source]¶
Read the glyph information of a BRFNT font.
The glyph widths are read from the HDWC section, and matched with the character codes from the PAMC sections.
- hacktools.wii.extractFontData(file, outfile)[source]¶
Extract the glyph data of a font to a text file.
Each line has the char=start,width,length format, with “=” characters written as <3D>.
- hacktools.wii.repackFontData(infile, outfile, datafile)[source]¶
Repack the glyph data of a font from a text file.
- Parameters:
infile (str) – Path of the original font file.
outfile (str) – Path of the output font file.
datafile (str) – Path of the text file, in the format written by
extractFontData().
- Return type:
None