XPlor/definitions/thqa/ctx2.xscript

61 lines
1.3 KiB
Plaintext
Raw Normal View History

// Texture Format (2xtc / ctx2) - THQ Australia Engine
// Contains texture/image data
// Big-endian (Xbox 360, Wii)
type thqa_ctx2 ui("THQA Texture") byteorder BE
{
criteria {
require ascii(bytesat(0, 4)) == "2xtc";
}
// Header
magic = ascii(read(4)) ui("Magic");
u32 version ui("Version");
u32 width ui("Width");
u32 height ui("Height");
// Format info
u32 texture_format ui("Format");
u32 mipmap_count ui("Mipmap Count");
u32 flags ui("Flags");
// Data info
u32 data_offset ui("Data Offset");
u32 data_size ui("Data Size");
// Decode format type
format_name = "Unknown";
if (texture_format == 0x00) {
format_name = "RGBA8888";
}
if (texture_format == 0x01) {
format_name = "RGB888";
}
if (texture_format == 0x02) {
format_name = "DXT1";
}
if (texture_format == 0x03) {
format_name = "DXT3";
}
if (texture_format == 0x04) {
format_name = "DXT5";
}
if (texture_format == 0x52) {
format_name = "Xbox360 DXT1";
}
if (texture_format == 0x53) {
format_name = "Xbox360 DXT3";
}
if (texture_format == 0x54) {
format_name = "Xbox360 DXT5";
}
format_name = format_name ui("Format Name");
// Read texture data
if (data_offset > 0 && data_size > 0) {
seek(data_offset);
texture_data = read(data_size) ui("Texture Data");
}
}