(TlgFormat): recognize obfuscated images.

This commit is contained in:
morkt 2016-07-23 02:45:12 +04:00
parent d321d05e50
commit d7b4a7d6bb

View File

@ -46,11 +46,29 @@ namespace GameRes.Formats.KiriKiri
int offset = 0xf; int offset = 0xf;
if (!Binary.AsciiEqual (header, "TLG0.0\x00sds\x1a")) if (!Binary.AsciiEqual (header, "TLG0.0\x00sds\x1a"))
offset = 0; offset = 0;
bool version6 = Binary.AsciiEqual (header, offset, "TLG6.0\x00raw\x1a"); int version;
if (!version6 && !Binary.AsciiEqual (header, offset, "TLG5.0\x00raw\x1a")) if (!Binary.AsciiEqual (header, offset+6, "\x00raw\x1a"))
return null;
if (Binary.AsciiEqual (header, offset, "TLG6.0"))
version = 6;
else if (Binary.AsciiEqual (header, offset, "TLG5.0"))
version = 5;
else if (Binary.AsciiEqual (header, offset, "XXXYYY"))
{
version = 5;
header[offset+0x0C] ^= 0xAB;
header[offset+0x10] ^= 0xAC;
}
else if (Binary.AsciiEqual (header, offset, "XXXZZZ"))
{
version = 6;
header[offset+0x0F] ^= 0xAB;
header[offset+0x13] ^= 0xAC;
}
else
return null; return null;
int colors = header[offset+11]; int colors = header[offset+11];
if (version6) if (6 == version)
{ {
if (1 != colors && 4 != colors && 3 != colors) if (1 != colors && 4 != colors && 3 != colors)
return null; return null;
@ -70,7 +88,7 @@ namespace GameRes.Formats.KiriKiri
Width = width, Width = width,
Height = height, Height = height,
BPP = colors*8, BPP = colors*8,
Version = version6 ? 6 : 5, Version = version,
DataOffset = offset+8, DataOffset = offset+8,
}; };
} }