Post by JADERLINK on Jan 1, 2024 0:36:31 GMT 10
Extract and repack ps2 re4 TPL files
Note: the topic is being translated by google translator, because I only know Portuguese Brazil.
SourceCode: github.com/JADERLINK/RE4-PS2-TPL-TOOL
Download: github.com/JADERLINK/RE4-PS2-TPL-TOOL/releases
The content below is a translation of the README.md file of the source code.
Program designed to extract and repack images from the tpl file of the PS2 version of Re4.
Update B.1.1.0.0
The program has been restructured, now the images will be enumerated and placed in a folder with the same name as the Tpl file, and next to each image, there will be an IdxtplHeader file;
RE4_PS2_TPL_EXTRACT.exe
Intended to extract Tpl files, for example: with the file "idm000.tpl" a .idxps2tpl file (idm000.idxps2tpl) will be generated, and the images will be enumerated and placed in a folder with the same name as the tpl, which in this example will be "idm000".
The image names will be: 0000.tga, 0001.tga, 0002.tga, etc.;
And next to each image there will be a file with the same name as the image with the format "IdxtplHeader", in this file there is the necessary content to recompile the "Header" of the image.
RE4_PS2_TPL_REPACK.exe
Intended to recompile the Tpl file, the file used to recompile the tpl is "*.idxps2tpl". Before recompressing, see the topics below regarding editing the images and the one regarding the IdxtplHeader file;
Editing the images
When editing images, two things must be considered: the image resolution and the number of colors;
* Bitdepth 9: these are images with 256 colors (so your image can have a maximum of 256 colors);
* Bitdepth 8: these are 16-color images (so your image can have a maximum of 16 colors);
* Note: if your image contains more than the colors specified above, when repacking these colors will be discarded and any other color will be replaced;
* Bitdepth 6: these are images that allow you to use all colors, however, the game hardly uses these images, as they take up a lot of space and are heavy for the game, so I don't recommend using this type of image.
! If you want to change the resolution or color density, you must edit the IdxtplHeader file with the same name as the image, to fill this file with the correct data, use the IdxtplHeader files that are inside the "IdxtplHeader.zip" file that It is available along with the program files, this zip will contain all the known headers that you can use.
! Regarding the amount of colors in the image, you can use the "IrfanView" program to reduce the amount of colors in your image;
Interlace
In addition to the "Bitdepth" field, another important field is the "Interlace", which, in fact, this field is a set of bit-by-bit flags, which are the following flags:
* Rotate Image: this flag is intended to rotate the image, because in the tpl file all images are "lying down", that is, the width is greater than the height. To have a "standing" image in which the height is greater than the width, this flag must be activated.
* Swizzle: this flag defines that the image is stored with the pixel in a different order than the default (I had a lot of work to extract these images in the correct way), but, in practice, you will not see any visual difference, these images are supposed to be be more "performative" for the game;
Below is the list of combinations of these flags, so when you see these values, you will know which flags are active:
* 0x00: no flag active;
* 0x01: "Rotate Image";
* 0x02: "Swizzle";
* 0x03: "Swizzle" + "Rotate Image";
IdxtplHeader
This file contains the "header" of each image, it is where the "Bitdepth" and "Interlace" are defined, and also has the image resolution, in addition to having the fields "Next", "Qwc", "GsTex" , in which the values of these fields are filled according to the resolution and Bitdepth of the image, so to fill in these fields correctly, use the IdxtplHeader files that are inside "IdxtplHeader.zip" as a reference;
Note: the value of the "Width" field is always greater than or equal to the "Height" field;
If your image is at a different resolution than the IdxtplHeader file, the tool will warn you.
Warning: filling in the IdxtplHeader file incorrectly may cause the game to crash or display the image incorrectly;
Scenario Tpl and Mipmap
In the Tpl of the scenarios (SMD files), there are mipmap images, which are images smaller than the main image, the mipmap header is next to the IdxtplHeader of the main image;
The mipmap and the main image share the same color palette, so the 3 images must have the same colors;
The TPL images of scenarios must always be lying down, because in this specific case the game does not recognize the images as if I were standing up;
idxps2tpl
This is the file used to recompile the Tpl file, it has the following fields:
* ImageFlipY: if true, images are flipped in Y when recompressed, this is used for Tpl images that are used by BIN/SMD;
* ImageFolder: here contains the name of the folder that contains the images;
* ImageFormat: here contains the format of the images in the folder, normally TGA;
BY: JADERLINK
2023-12-31
Note: the topic is being translated by google translator, because I only know Portuguese Brazil.
SourceCode: github.com/JADERLINK/RE4-PS2-TPL-TOOL
Download: github.com/JADERLINK/RE4-PS2-TPL-TOOL/releases
The content below is a translation of the README.md file of the source code.
Program designed to extract and repack images from the tpl file of the PS2 version of Re4.
Update B.1.1.0.0
The program has been restructured, now the images will be enumerated and placed in a folder with the same name as the Tpl file, and next to each image, there will be an IdxtplHeader file;
RE4_PS2_TPL_EXTRACT.exe
Intended to extract Tpl files, for example: with the file "idm000.tpl" a .idxps2tpl file (idm000.idxps2tpl) will be generated, and the images will be enumerated and placed in a folder with the same name as the tpl, which in this example will be "idm000".
The image names will be: 0000.tga, 0001.tga, 0002.tga, etc.;
And next to each image there will be a file with the same name as the image with the format "IdxtplHeader", in this file there is the necessary content to recompile the "Header" of the image.
RE4_PS2_TPL_REPACK.exe
Intended to recompile the Tpl file, the file used to recompile the tpl is "*.idxps2tpl". Before recompressing, see the topics below regarding editing the images and the one regarding the IdxtplHeader file;
Editing the images
When editing images, two things must be considered: the image resolution and the number of colors;
* Bitdepth 9: these are images with 256 colors (so your image can have a maximum of 256 colors);
* Bitdepth 8: these are 16-color images (so your image can have a maximum of 16 colors);
* Note: if your image contains more than the colors specified above, when repacking these colors will be discarded and any other color will be replaced;
* Bitdepth 6: these are images that allow you to use all colors, however, the game hardly uses these images, as they take up a lot of space and are heavy for the game, so I don't recommend using this type of image.
! If you want to change the resolution or color density, you must edit the IdxtplHeader file with the same name as the image, to fill this file with the correct data, use the IdxtplHeader files that are inside the "IdxtplHeader.zip" file that It is available along with the program files, this zip will contain all the known headers that you can use.
! Regarding the amount of colors in the image, you can use the "IrfanView" program to reduce the amount of colors in your image;
Interlace
In addition to the "Bitdepth" field, another important field is the "Interlace", which, in fact, this field is a set of bit-by-bit flags, which are the following flags:
* Rotate Image: this flag is intended to rotate the image, because in the tpl file all images are "lying down", that is, the width is greater than the height. To have a "standing" image in which the height is greater than the width, this flag must be activated.
* Swizzle: this flag defines that the image is stored with the pixel in a different order than the default (I had a lot of work to extract these images in the correct way), but, in practice, you will not see any visual difference, these images are supposed to be be more "performative" for the game;
Below is the list of combinations of these flags, so when you see these values, you will know which flags are active:
* 0x00: no flag active;
* 0x01: "Rotate Image";
* 0x02: "Swizzle";
* 0x03: "Swizzle" + "Rotate Image";
IdxtplHeader
This file contains the "header" of each image, it is where the "Bitdepth" and "Interlace" are defined, and also has the image resolution, in addition to having the fields "Next", "Qwc", "GsTex" , in which the values of these fields are filled according to the resolution and Bitdepth of the image, so to fill in these fields correctly, use the IdxtplHeader files that are inside "IdxtplHeader.zip" as a reference;
Note: the value of the "Width" field is always greater than or equal to the "Height" field;
If your image is at a different resolution than the IdxtplHeader file, the tool will warn you.
Warning: filling in the IdxtplHeader file incorrectly may cause the game to crash or display the image incorrectly;
Scenario Tpl and Mipmap
In the Tpl of the scenarios (SMD files), there are mipmap images, which are images smaller than the main image, the mipmap header is next to the IdxtplHeader of the main image;
The mipmap and the main image share the same color palette, so the 3 images must have the same colors;
The TPL images of scenarios must always be lying down, because in this specific case the game does not recognize the images as if I were standing up;
idxps2tpl
This is the file used to recompile the Tpl file, it has the following fields:
* ImageFlipY: if true, images are flipped in Y when recompressed, this is used for Tpl images that are used by BIN/SMD;
* ImageFolder: here contains the name of the folder that contains the images;
* ImageFormat: here contains the format of the images in the folder, normally TGA;
BY: JADERLINK
2023-12-31