EvilEngine/CRDT

From Heavy Iron Modding
Revision as of 14:52, 5 October 2023 by EnergyDrink (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

CRDT
Credits
TypeBinary
Games usedBattle for Bikini Bottom

The SpongeBob SquarePants Movie
The Incredibles
Rise of the Underminer

Ratatouille Prototype
Source codexCM.h

Format

xCMHeader

struct xCMheader
{
    unsigned int magic;
    unsigned int version;
    unsigned int crdID;
    unsigned int state;
    float total_time;
    unsigned int total_size;
};
Offset Type Variable Description
0x00 u32 magic 0xBEEEEEEF
0x04 u32 version
  • 256 (1.0) - BFBB
  • 512 (2.0) - TSSM - RatProto (Obfuscated)
0x08 AssetID crdID
0x0C u32 state
  • 1 = Not encrypted.
  • 3 = Encrypted, the game will decrypt the credits file.
0x10 f32 total_time Duration in seconds. After this it loops
0x14 u32 total_size Total size of CRDT asset

After this header the obfuscated data section (a XOR cipher with the key "xCMChunkHand", see example decrypt function) in version 2 credits begins. TSSM - RatProto still support non-obfuscated credits if state is set to 1.

xCMcredits

struct xCMcredits
{
    unsigned int credits_size;
    float len;
    unsigned int flags;
    sxy in;
    sxy out;
    float scroll_rate;
    float lifetime;
    fade fin;
    fade fout;
    unsigned int num_presets;
};
Offset Type Variable Description
0x00 u32 credits_size Size of credits entry
0x04 f32 len Duration of section in seconds
0x08 u32 flags unknown - Alternates between 0 and 1
0x0C f32 in.x Start X (Width) position. Doesn't seem to work.
0x10 f32 in.y Start Y (Height) position. 0 = Top, 1 = Bottom of screen
0x14 f32 out.x End X (Width) position. Doesn't seem to work.
0x18 f32 out.y End Y (Height) position. 0 = Top, 1 = Bottom of screen
0x1C f32 scroll_rate
0x20 f32 lifetime
0x24 f32 fin.start Start fade-in
0x28 f32 fin.end End fade-in
0x2C f32 fout.start Start fade-out
0x30 f32 fout.end End fade-out
0x34 u32 num_presets Number of preset entries

xCMpreset

struct xCMpreset
{
    unsigned short num; 
    unsigned short align;
    float delay;
    float innerspace;
    xCMtextbox box[2];
};
Offset Type Variable Description
0x00 u16 num Preset index
0x02 u16 align
  • 0 = Textbox
  • 4 = Texture
0x04 f32 delay
0x08 f32 innerspace
0x0C xCMtextbox[2] or xCMtexture[2]
xCMtexture

Unused in BFBB but still supported.

struct xCMtexture
{
    unsigned int assetID;
    xColor_tag color;
    float x;
    float y;
    float w;
    float h;
    RwTexture* texture;
    unsigned int pad;
};
Offset Type Variable Description
0x00 AssetID assetID Texture AssetID
0x04 Color color
0x08 f32 x
0x0C f32 y
0x10 f32 w
0x14 f32 h
0x18 RwTexture* texture Unknown
0x1C u32 pad Unknown
xCMtextbox
struct xCMtextbox
{
    unsigned int font;
    xColor_tag color;
    sxy char_size;
    sxy char_spacing;
    sxy box;
};
Offset Type Variable Description
0x00 u32 font
0x04 Color color
0x08 f32 char_size.x Char Width in pixels
0x0C f32 char_size.y Char Height in pixels
0x10 f32 char_spacing.x
0x14 f32 char_spacing.y
0x18 f32 box.x Max Screen Width - percentage of screen (0 to 1)
0x1C f32 box.y Max Screen Height - percentage of screen (0 to 1)

xCMhunk

Multiple present until it reaches credits_size.

struct xCMhunk
{
    unsigned int hunk_size;
    unsigned int preset;
    float t0;
    float t1;
    char* text1;
    char* text2;
};
Offset Type Variable Description
0x00 u32 hunk_size Size of hunk entry
0x04 u32 preset Preset index
0x08 f32 t0 Start Time
0x0C f32 t1 End Time
0x10 char* text1 Absolute offset of text, null if text is empty/null.
0x14 char* text2 Always null/unused?
0x18 char[] - Text, null-terminated 4-byte alignment

Example C# Decrypt Function

private void DecryptData(ref byte[] data)
{
    byte last = 0;
    string key = "xCMChunkHand";
    for (int i = 0x18; i < data.Length; i++)
    {
        last = (byte)(data[i] ^ last ^ key[i % key.Length]);
        data[i] = last;
    }
}