mirror of
https://github.com/PrimeDecomp/PrimeRemasterStructs.git
synced 2026-07-12 18:18:58 -07:00
Rework DKCTF detection & many fixes
This commit is contained in:
@@ -1,23 +1,6 @@
|
||||
typedef struct
|
||||
{
|
||||
FourCC type;
|
||||
//So this is a check for DKCTF (Big Endian), basically 0x04 should be 0, if that's true, assume DKCTF, strange for DKCTF on NS was in BE, I'll prob fix this memory usage later
|
||||
if (isDKCTF == -1) //Like this
|
||||
{
|
||||
uint32 checkForDKCTF;
|
||||
FSkip(-4);
|
||||
if (checkForDKCTF == 0)
|
||||
{
|
||||
isDKCTF = 1;
|
||||
AssetDirEntryChunkSz = 36;
|
||||
BigEndian();
|
||||
}
|
||||
else
|
||||
{
|
||||
isDKCTF = 0;
|
||||
AssetDirEntryChunkSz = 52;
|
||||
}
|
||||
}
|
||||
uint64 size <format=hex>;
|
||||
uint64 unk1;
|
||||
FourCC id;
|
||||
|
||||
+3
-3
@@ -106,11 +106,11 @@ typedef struct{
|
||||
float color3[4];
|
||||
byte flags;
|
||||
GUID texture1ID;
|
||||
if (texture1ID != 0) CMaterialTextureTokenData texture1;
|
||||
if (texture1ID != GUIDZero) CMaterialTextureTokenData texture1;
|
||||
GUID texture2ID;
|
||||
if (texture2ID != 0) CMaterialTextureTokenData texture2;
|
||||
if (texture2ID != GUIDZero) CMaterialTextureTokenData texture2;
|
||||
GUID texture3ID;
|
||||
if (texture3ID != 0) CMaterialTextureTokenData texture3;
|
||||
if (texture3ID != GUIDZero) CMaterialTextureTokenData texture3;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
+26
-20
@@ -5,46 +5,52 @@ typedef struct
|
||||
{
|
||||
FourCC type;
|
||||
GUID id;
|
||||
if (isDKCTF == 0)
|
||||
if (!isDKCTF)
|
||||
{
|
||||
uint32 versionA;
|
||||
uint32 versionB;
|
||||
}
|
||||
uint64 offset;
|
||||
if (isDKCTF == 0)
|
||||
uint64 offset <format=hex>;
|
||||
if (!isDKCTF)
|
||||
{
|
||||
uint64 decompressedSize;
|
||||
uint64 decompressedSize <format=hex>;
|
||||
}
|
||||
else
|
||||
uint64 size <format=hex>;
|
||||
if (isDKCTF)
|
||||
{
|
||||
local uint decompressedSize <hidden=true> = 0; //hack
|
||||
local uint64 decompressedSize <hidden=true> = size;
|
||||
}
|
||||
uint64 size;
|
||||
|
||||
local uint64 pos <format=hex, hidden=true> = FTell();
|
||||
FSeek(offset);
|
||||
if (size == decompressedSize || isDKCTF == 1) {
|
||||
if (size == decompressedSize) {
|
||||
File data <size=size>;
|
||||
} else {
|
||||
enum <uint32> CompressionType
|
||||
{
|
||||
LZSS_8 = 0x1,
|
||||
LZSS_16 = 0x2,
|
||||
LZSS_32 = 0x3,
|
||||
ZLIB = 0xD,
|
||||
} compressionType;
|
||||
CompressionType compressionType;
|
||||
byte pad[3] <hidden=true>;
|
||||
byte compressedData[size - 4];
|
||||
}
|
||||
FSeek(pos);
|
||||
} AssetDirectoryEntry <
|
||||
size=AssetDirEntryChunkSz, // Parse on-demand
|
||||
name=(Str("%s v%d.%d %s", this.type, data.form.versionA, data.form.versionB, GUIDToString(this.id))), //Read the chunk ver and subver from form descriptor
|
||||
comment=(SizeComment(size))
|
||||
size=(isDKCTF ? 36 : 52), // Parse on-demand
|
||||
name=AssetDirectoryEntryName,
|
||||
comment=(SizeComment(this.size))
|
||||
>;
|
||||
|
||||
string AssetDirectoryEntryName(AssetDirectoryEntry& entry)
|
||||
{
|
||||
if (isDKCTF) {
|
||||
// Read the chunk ver and subver from form descriptor
|
||||
return Str("%s v%d.%d %s", entry.type, entry.data.form.versionA, entry.data.form.versionB, GUIDToString(entry.id));
|
||||
} else {
|
||||
return Str("%s v%d.%d %s", entry.type, entry.versionA, entry.versionB, GUIDToString(entry.id));
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GUID id;
|
||||
uint32 offset;
|
||||
uint32 offset <format=hex>;
|
||||
|
||||
// Find the FourCC for the asset ID
|
||||
// Assumes TOCC chunk 0 is ADIR
|
||||
@@ -61,7 +67,7 @@ typedef struct
|
||||
|
||||
local uint64 pos <format=hex, hidden=true> = FTell();
|
||||
FSeek(start + offset);
|
||||
uint32 size;
|
||||
uint32 size <format=hex>;
|
||||
Meta data(type, size, fileOffset);
|
||||
FSeek(pos);
|
||||
} MetaEntry <
|
||||
|
||||
@@ -65,3 +65,13 @@ string SizeComment(uint64 size)
|
||||
{
|
||||
return Str("Size: %s (0x%X)", FormatBytes(size), size);
|
||||
}
|
||||
|
||||
local GUID GUIDZero <hidden=true>;
|
||||
|
||||
typedef enum <byte>
|
||||
{
|
||||
LZSS_8 = 0x1,
|
||||
LZSS_16 = 0x2,
|
||||
LZSS_32 = 0x3,
|
||||
ZLIB = 0xD,
|
||||
} CompressionType;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
struct AssetInfo
|
||||
{
|
||||
GUID id;
|
||||
uint32 compressionMode;
|
||||
CompressionType compressionType;
|
||||
byte pad[3] <hidden=true>;
|
||||
uint64 origOffset <format=hex>;
|
||||
};
|
||||
|
||||
|
||||
+14
-9
@@ -16,7 +16,8 @@ struct STextureCompressedBufferInfo(uint64 fileStart)
|
||||
// Compressed data
|
||||
local uint64 pos <format=hex, hidden=true> = FTell();
|
||||
FSeek(fileStart + info[index].offset + offset);
|
||||
uint32 compressionMode;
|
||||
CompressionType compressionType;
|
||||
byte pad[3] <hidden=true>;
|
||||
byte data[size - 4] <bgcolor=cLtRed>;
|
||||
FSeek(pos);
|
||||
};
|
||||
@@ -30,9 +31,13 @@ struct STextureMetaData(uint64 fileStart)
|
||||
uint32 align;
|
||||
uint32 decompressedSize <format=hex>; // Total size decompressed
|
||||
uint32 infoCount;
|
||||
STextureReadInfo info[infoCount];
|
||||
if (infoCount != 0) {
|
||||
STextureReadInfo info[infoCount];
|
||||
}
|
||||
uint32 bufferCount;
|
||||
STextureCompressedBufferInfo buffer(fileStart)[bufferCount] <optimize=false>;
|
||||
if (bufferCount != 0) {
|
||||
STextureCompressedBufferInfo buffer(fileStart)[bufferCount] <optimize=false>;
|
||||
}
|
||||
};
|
||||
|
||||
enum <byte> ETextureWrap
|
||||
@@ -228,13 +233,13 @@ typedef struct
|
||||
STextureHeader header;
|
||||
break;
|
||||
case "GPU ":
|
||||
LittleEndian();
|
||||
uint32 compressionType;
|
||||
if (isDKCTF == 1)
|
||||
{
|
||||
BigEndian();
|
||||
if (isDKCTF) {
|
||||
CompressionType compressionType;
|
||||
byte pad[3] <hidden=true>;
|
||||
byte data[chunk.size - 4];
|
||||
} else {
|
||||
byte data[chunk.size];
|
||||
}
|
||||
byte data[chunk.size-4];
|
||||
break;
|
||||
}
|
||||
FSeek(start + chunk.size);
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
// Custom footer
|
||||
#include "Footer.bt"
|
||||
|
||||
|
||||
local uint isDKCTF <hidden=true> = -1;
|
||||
local uint AssetDirEntryChunkSz <hidden=true> = 0;
|
||||
|
||||
//Mod by LolHacksRule, added support for DKCTF (older Big Endian) formats
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FormDescriptor form;
|
||||
@@ -65,7 +59,11 @@ typedef struct
|
||||
} File <open=true, bgcolor=cSilver>;
|
||||
|
||||
// Template start
|
||||
LittleEndian();
|
||||
BigEndian();
|
||||
local uint isDKCTF <hidden=true> = (ReadInt(4) & 0xFFFFFF) == 0;
|
||||
if (!isDKCTF) {
|
||||
LittleEndian();
|
||||
}
|
||||
File file <bgcolor=cGray, name=(Str("%s v%d file", form.id, form.versionA))>;
|
||||
|
||||
// Custom footer for extracted files
|
||||
|
||||
Reference in New Issue
Block a user