Skip to content

Instantly share code, notes, and snippets.

@dev-zzo
Last active August 29, 2015 14:12
Show Gist options
  • Save dev-zzo/6e1130f8a28e2e80e1cf to your computer and use it in GitHub Desktop.
Save dev-zzo/6e1130f8a28e2e80e1cf to your computer and use it in GitHub Desktop.
010 Templates: FF4 Saves
//--------------------------------------
//--- 010 Editor v6.0 Binary Template
//
// File: ff4save.bt
// Author: DJ
// Revision: 1
// Purpose: Parse FF4 save slot.
//--------------------------------------
local int doSteam = -1;
if (ReadUInt(0x19D0) == 0x59545250) {
Printf("Detected the 'Android' version.\n");
doSteam = 0;
} else if (ReadUInt(0x1AE8) == 0x59545250) {
Printf("Detected the 'Steam' version.\n");
doSteam = 1;
}
if (doSteam == -1) {
Warning("I don't know how to parse the file.\n");
Exit(-1);
}
typedef struct {
byte Signature[12] <bgcolor=cRed>;
uint32 Unknown1 <bgcolor=cGray>;
uint32 Unknown2 <bgcolor=cGray>;
uint32 Unknown3 <bgcolor=cGray>;
uint32 Unknown4 <bgcolor=cGray>;
uint32 CheckSum <format=hex, bgcolor=cLtRed>;
} Header <bgcolor=cYellow>;
Header header;
uint32 fixed_3D9C <bgcolor=cGray>;
enum <byte> CharIdType {
CharId_CecilDK,
CharId_CecilP,
CharId_Kain,
CharId_Rosa,
CharId_RydiaC,
CharId_RydiaA,
CharId_Tellah,
CharId_Porom,
CharId_Palom,
CharId_Edward,
CharId_Yang,
CharId_Cid,
CharId_Edge,
CharId_FuSoYa,
};
typedef struct {
CharIdType CharId;
byte Level;
uint16 CharPresent;
uint16 CurrHP;
uint16 MaxHP;
uint16 CurrMP;
uint16 MaxMP;
byte Unknown2[8];
} CharSlot <bgcolor=cAqua>;
CharSlot char_slots[5];
uint32 gil1 <bgcolor=cYellow>;
uint16 unknown1;
uint16 unknown2;
byte unknown3[12];
typedef struct {
byte LevelShort <bgcolor=cPurple>;
byte Unknown1 <bgcolor=cGray>;
uint16 Unknown2 <bgcolor=cGray>;
uint32 Exp <bgcolor=cYellow>;
uint16 Level <bgcolor=cPurple>;
uint16 MaxHPShort <bgcolor=cLtRed>;
uint32 CurrHP <bgcolor=cLtRed>;
uint32 MaxHP <bgcolor=cLtRed>;
uint32 CurrMP <bgcolor=cLtBlue>;
uint32 MaxMP <bgcolor=cLtBlue>;
byte Unknown3[10] <bgcolor=cGray>;
uint16 RHandEquip <bgcolor=cLtGreen>;
uint16 LHandEquip <bgcolor=cLtGreen>;
uint16 HeadEquip <bgcolor=cLtGreen>;
uint16 BodyEquip <bgcolor=cLtGreen>;
uint16 ArmsEquip <bgcolor=cLtGreen>;
// Steam version difference: each array extended by 2 items
if (doSteam) {
uint16 Arr1[42];
uint32 Arr1Count;
uint16 Arr2[42];
uint32 Arr2Count;
uint16 Arr3[34];
uint32 Arr3Count;
uint16 Arr4[18];
uint32 Arr4Count;
uint16 Arr5[18];
uint32 Arr5Count;
} else {
uint16 Arr1[40];
uint32 Arr1Count;
uint16 Arr2[40];
uint32 Arr2Count;
uint16 Arr3[32];
uint32 Arr3Count;
uint16 Arr4[16];
uint32 Arr4Count;
uint16 Arr5[16];
uint32 Arr5Count;
}
uint32 Unknown4[8] <bgcolor=cGray>;
byte Flags[24];
byte Zero1[8] <bgcolor=cLtGray>;
byte Unknown5[18] <bgcolor=cGray>;
byte StatStr <bgcolor=cGreen>;
byte StatSpd <bgcolor=cGreen>;
byte StatSta <bgcolor=cGreen>;
byte StatInt <bgcolor=cGreen>;
byte StatSpi <bgcolor=cGreen>;
byte Unknown6 <bgcolor=cGray>;
uint16 MaxMPShort <bgcolor=cLtBlue>;
uint16 Unknown7 <bgcolor=cGray>;
} CharData1;
CharData1 char_data[14];
uint16 unknown4[4] <bgcolor=cGray>;
byte reserved1[0xAC] <bgcolor=cLtGray>;
// Inventory data
typedef struct {
uint16 Type;
uint16 Amount;
} ItemRecord;
typedef struct {
uint32 Tag <bgcolor=cRed>;
uint32 Unknown1 <bgcolor=cGray>;
if (doSteam) {
ItemRecord Items1[385];
uint32 Items1Count;
ItemRecord Items2[129];
uint32 Items2Count;
} else {
ItemRecord Items1[384];
uint32 Items1Count;
ItemRecord Items2[128];
uint32 Items2Count;
}
uint32 Gil <bgcolor=cYellow>;
uint32 PlayTime <bgcolor=cLtGreen>; // seconds
byte Unknown2[0x34] <bgcolor=cGray>;
} PRTY;
PRTY prty;
// ???
typedef struct {
uint32 Tag <bgcolor=cRed>;
byte Data[0xB4];
} WRLD;
WRLD wrld;
// ???
typedef struct {
uint32 Tag <bgcolor=cRed>;
byte Data[0x7C];
} VSTY;
VSTY vsty;
// ???
typedef struct {
uint32 Tag <bgcolor=cRed>;
byte Data[4];
} BTTL;
BTTL bttl;
// ???
typedef struct {
uint32 Tag <bgcolor=cRed>;
byte Data[0x108];
} EVNT;
EVNT evnt;
// Bestiary
// see: https://www.dropbox.com/s/h3jvqhslf08q42g/FFIV%20Bestiary%20Notes.txt
typedef struct {
uint32 Tag <bgcolor=cRed>;
byte Data[0x204];
} PLSR;
PLSR plsr;
// ???
typedef struct {
uint32 Tag <bgcolor=cRed>;
byte Data[4];
} NAVI;
NAVI navi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment