Merge pull request #1 from LolHacksRule/main

Add DKCTF file support
This commit is contained in:
Phillip Stephens
2023-02-14 21:39:16 -08:00
committed by GitHub
7 changed files with 172 additions and 36 deletions
+17
View File
@@ -1,6 +1,23 @@
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;
+44 -13
View File
@@ -27,16 +27,30 @@ struct CustomDataLoader {
};
struct ModelHeader {
uint unk1;
if (isDKCTF == 1)
{
uint opaqueMeshes;
uint onePassTransMeshes;
uint TwoPassTransMeshes;
uint oneBitMeshes;
uint additiveMeshes;
}
else
{
uint unk1;
}
CAABox bounds;
uint dataSourceCount;
local int i;
for (i = 0; i < dataSourceCount; ++i) {
DataSourceLoader dataSource;
}
uchar unk2;
if (unk2) {
CustomDataLoader customData;
if (isDKCTF == 0)
{
uchar unk2;
if (unk2) {
CustomDataLoader customData;
}
}
};
@@ -273,15 +287,29 @@ string CMaterialDataRead(CMaterialData &mat)
typedef struct {
CStringFixed name;
GUID shaderID;
GUID guid2; //unsure
uint unk1;
uint unk2;
//material type list (can be 0)
uint typeCount;
if (isDKCTF == 1)
{
local uint typeCount <hidden=true> = 1; //Hack it to 1
}
else
{
GUID guid2; //unsure
uint unk1;
uint unk2;
//material type list (can be 0)
uint typeCount;
}
uint types[typeCount];
//material data types (with extra value)
uint renderTypeCount;
MaterialRenderTypes renderTypes[renderTypeCount];
if (isDKCTF == 1)
{
uint flags;
}
else
{
//material data types (with extra value)
uint renderTypeCount;
MaterialRenderTypes renderTypes[renderTypeCount];
}
//material data types
uint dataCount;
MaterialType dataTypes2[dataCount];
@@ -313,7 +341,10 @@ typedef struct {
ModelHeader header;
break;
case "MTRL":
uint unk;
if (isDKCTF == 0)
{
uint unk;
}
uint numMaterials;
CMaterialCache materials[numMaterials]<optimize = false>;
break;
+16 -7
View File
@@ -5,15 +5,24 @@ typedef struct
{
FourCC type;
GUID id;
uint32 versionA;
uint32 versionB;
if (isDKCTF == 0)
{
uint32 versionA;
uint32 versionB;
}
uint64 offset;
uint64 decompressedSize;
if (isDKCTF == 0)
{
uint64 decompressedSize;
}
else
{
local uint decompressedSize <hidden=true> = 0; //hack
}
uint64 size;
local uint64 pos <format=hex, hidden=true> = FTell();
FSeek(offset);
if (size == decompressedSize) {
if (size == decompressedSize || isDKCTF == 1) {
File data <size=size>;
} else {
enum <uint32> CompressionType
@@ -27,8 +36,8 @@ typedef struct
}
FSeek(pos);
} AssetDirectoryEntry <
size=52, // Parse on-demand
name=(Str("%s v%d %s", this.type, this.versionA, GUIDToString(this.id))),
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))
>;
+35
View File
@@ -0,0 +1,35 @@
//------------------------------------------------
//--- 010 Editor v13.0.1 Binary Template
//
// File:
// Authors:
// Version:
// Purpose:
// Category:
// File Mask:
// ID Bytes:
// History:
//------------------------------------------------
typedef struct
{ ChunkDescriptor chunk;
struct CScaleformFlashLibraryChunk
{
uint32 referencedTextures;
struct ReferencedTxtrs
{
struct ReferencedTxtr
{
GUID texRef;
CStringFixed texName;
} rtxtr[referencedTextures] <optimize = false>;
} rtxrs;
CStringFixed theSWFName;
FSkip(4); //Skip ahead to see the SWF size
LittleEndian(); //temp swap endian
uint32 swfSize<hidden=true>; //Pull SWF size
BigEndian(); //temp swap endian
FSkip(-8); //Go back to GFX
byte theGFXFile[swfSize]; //History
} GFXLChunk;
} CScaleformFlashLibrary;
+29 -12
View File
@@ -9,6 +9,7 @@ struct MSBTHeader {
char magic[8];
Assert(magic == "MsgStdBn");
ushort bom <format=hex>;
//Todo add a meaningful check for endian, this works for LE/DKCTF NS/MP1R for now
Assert(bom == 0xFEFF); // Big-Endian byte order
ushort unk1;
ubyte maybeMajorVersion;
@@ -71,11 +72,14 @@ struct AttributesSection {
local int64 tableStart = FTell();
uint offsetCount;
uint entrySize; // should always be 4
uint offset[offsetCount];
local uint i;
for (i = 0; i < offsetCount; i++) {
Assert(FTell() == tableStart + offset[i]);
AttributeEntry attribute<optimize=false,read=AttributeEntryRead>;
if (isDKCTF == 0)
{
uint offset[offsetCount];
local uint i;
for (i = 0; i < offsetCount; i++) {
Assert(FTell() == tableStart + offset[i]);
AttributeEntry attribute<optimize=false,read=AttributeEntryRead>;
}
}
while (ReadUByte(FTell()) == 0xAB) {
byte padding<hidden=true>;
@@ -144,18 +148,31 @@ struct Language (string expectedLanguage) {
};
struct MessageStudioBinaryText
{
{
Language us_english("USEN");
if (isDKCTF == 1)
{
Language us_french("USFR");
Language us_spanish("USSP");
}
Language eu_english("EUEN");
Language eu_french("EUFR");
Language us_french("USFR");
if (isDKCTF == 0)
{
Language us_french("USFR");
}
Language eu_spanish("EUSP");
Language eu_german("EUGE");
Language eu_italian("EUIT");
Language eu_dutch("EUDU");
if (isDKCTF == 0)
{
Language eu_dutch("EUDU");
}
Language jp_japanese("JPJP");
Language ko_korean("KOKO");
Language ch_traditionalchinese("CHTC");
Language ch_simplifiedchinese("CHSC");
Language us_spanish("USSP");
if (isDKCTF == 0)
{
Language ko_korean("KOKO");
Language ch_traditionalchinese("CHTC");
Language ch_simplifiedchinese("CHSC");
}
};
+12 -3
View File
@@ -87,8 +87,11 @@ struct STextureSamplerData
ETextureMipFilter mipFilter;
ETextureWrap wrapX;
ETextureWrap wrapY;
ETextureWrap wrapZ;
ETextureAnisotropicRatio aniso;
if (isDKCTF == 0)
{
ETextureWrap wrapZ;
ETextureAnisotropicRatio aniso;
}
};
enum <uint32> ETextureType
@@ -225,7 +228,13 @@ typedef struct
STextureHeader header;
break;
case "GPU ":
byte data[chunk.size];
LittleEndian();
uint32 compressionType;
if (isDKCTF == 1)
{
BigEndian();
}
byte data[chunk.size-4];
break;
}
FSeek(start + chunk.size);
+19 -1
View File
@@ -13,10 +13,18 @@
#include "CPakFile.bt"
#include "MessageStudioBinaryText.bt"
#include "MaterialArchive.bt"
//#include "CRuleSet.bt"
#include "CScaleformFlashLibrary.bt"
// 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;
@@ -24,7 +32,8 @@ typedef struct
switch (form.id)
{
case "MTRL":
MaterialArchive materialArchive(form.size);
byte MTRLRaw [form.size]; //For now
//MaterialArchive materialArchive(form.size);
break;
case "CHPR":
FCharInf charInfo;
@@ -42,6 +51,15 @@ typedef struct
case "TXTR":
NTextureFormat texture(form.size);
break;
/*case "RULE":
CRuleSet rulesetconfig(form.size);
break;*/
case "GFXL":
CScaleformFlashLibrary scaleformflashlibrary;
break;
/*case "GFX ":
CFlashMovieResource flashmovieresource(form.size);
break;*/
}
FSeek(start + form.size);
} File <open=true, bgcolor=cSilver>;