mirror of
https://github.com/zeldaret/ph
synced 2026-05-23 06:54:18 -04:00
document most of the BMG file format
This commit is contained in:
@@ -1304,7 +1304,7 @@ func_0202a8dc kind:function(arm,size=0x1cc) addr:0x202a8dc
|
||||
func_0202aaa8 kind:function(arm,size=0x40) addr:0x202aaa8
|
||||
func_0202aae8 kind:function(thumb,size=0x10) addr:0x202aae8
|
||||
func_0202aaf8 kind:function(thumb,size=0x40) addr:0x202aaf8
|
||||
_Z13func_0202ab38i kind:function(thumb,size=0x10) addr:0x202ab38
|
||||
_Z13func_0202ab38Pj kind:function(thumb,size=0x10) addr:0x202ab38
|
||||
func_0202ab48 kind:function(thumb,size=0x4) addr:0x202ab48
|
||||
func_0202ab4c kind:function(thumb,size=0x8) addr:0x202ab4c
|
||||
func_0202ab54 kind:function(thumb,size=0x10) addr:0x202ab54
|
||||
@@ -1395,7 +1395,7 @@ func_0202d164 kind:function(thumb,size=0x60) addr:0x202d164
|
||||
func_0202d1c4 kind:function(thumb,size=0x58) addr:0x202d1c4
|
||||
func_0202d21c kind:function(thumb,size=0x20) addr:0x202d21c
|
||||
func_0202d23c kind:function(thumb,size=0x180) addr:0x202d23c
|
||||
func_0202d3bc kind:function(thumb,size=0xb8) addr:0x202d3bc
|
||||
_Z13func_0202d3bciPjPciibii kind:function(thumb,size=0xb8) addr:0x202d3bc
|
||||
func_0202d474 kind:function(thumb,size=0xdc) addr:0x202d474
|
||||
_Z13func_0202d550iPjPciii kind:function(thumb,size=0x1c) addr:0x202d550
|
||||
func_0202d56c kind:function(thumb,size=0x24) addr:0x202d56c
|
||||
@@ -1821,10 +1821,10 @@ func_020370e8 kind:function(arm,size=0x70) addr:0x20370e8
|
||||
func_02037158 kind:function(arm,size=0x20) addr:0x2037158
|
||||
func_02037178 kind:function(arm,size=0x38) addr:0x2037178
|
||||
func_020371b0 kind:function(arm,size=0x4) addr:0x20371b0
|
||||
_Z13func_020371b4P11UnknownData kind:function(thumb,size=0x14) addr:0x20371b4
|
||||
_Z13func_020371c8P11UnknownDataPji kind:function(thumb,size=0x90) addr:0x20371c8
|
||||
_Z13func_02037258P11UnknownDatai kind:function(arm,size=0x34) addr:0x2037258
|
||||
_Z13func_0203728cP11UnknownDatai kind:function(arm,size=0x64) addr:0x203728c
|
||||
_Z13func_020371b4P11BMGFileInfo kind:function(thumb,size=0x14) addr:0x20371b4
|
||||
_Z13func_020371c8P11BMGFileInfoPji kind:function(thumb,size=0x90) addr:0x20371c8
|
||||
_Z13func_02037258P11BMGFileInfoi kind:function(arm,size=0x34) addr:0x2037258
|
||||
_Z13func_0203728cP11BMGFileInfoi kind:function(arm,size=0x64) addr:0x203728c
|
||||
_ZN14MessageManager13func_020372f0Eiii kind:function(thumb,size=0xc4) addr:0x20372f0
|
||||
func_020373b4 kind:function(thumb,size=0x38) addr:0x20373b4
|
||||
func_020373ec kind:function(arm,size=0x60) addr:0x20373ec
|
||||
|
||||
@@ -1304,7 +1304,7 @@ func_0202a8dc kind:function(arm,size=0x1cc) addr:0x202a8dc
|
||||
func_0202aaa8 kind:function(arm,size=0x40) addr:0x202aaa8
|
||||
func_0202aae8 kind:function(thumb,size=0x10) addr:0x202aae8
|
||||
func_0202aaf8 kind:function(thumb,size=0x28) addr:0x202aaf8
|
||||
_Z13func_0202ab38i kind:function(thumb,size=0x10) addr:0x202ab20
|
||||
_Z13func_0202ab38Pj kind:function(thumb,size=0x10) addr:0x202ab20
|
||||
func_0202ab48 kind:function(thumb,size=0x4) addr:0x202ab30
|
||||
func_0202ab4c kind:function(thumb,size=0x8) addr:0x202ab34
|
||||
func_0202ab54 kind:function(thumb,size=0x10) addr:0x202ab3c
|
||||
@@ -1395,7 +1395,7 @@ func_0202d164 kind:function(thumb,size=0x74) addr:0x202d14c
|
||||
func_0202d1c4 kind:function(thumb,size=0x58) addr:0x202d1c0
|
||||
func_0202d21c kind:function(thumb,size=0x20) addr:0x202d218
|
||||
func_0202d23c kind:function(thumb,size=0x180) addr:0x202d238
|
||||
func_0202d3bc kind:function(thumb,size=0xb8) addr:0x202d3b8
|
||||
_Z13func_0202d3bciPjPciibii kind:function(thumb,size=0xb8) addr:0x202d3b8
|
||||
func_0202d474 kind:function(thumb,size=0xdc) addr:0x202d470
|
||||
_Z13func_0202d550iPjPciii kind:function(thumb,size=0x1c) addr:0x202d54c
|
||||
func_0202d56c kind:function(thumb,size=0x24) addr:0x202d568
|
||||
@@ -1821,10 +1821,10 @@ func_020370e8 kind:function(arm,size=0x70) addr:0x20370a4
|
||||
func_02037158 kind:function(arm,size=0x20) addr:0x2037114
|
||||
func_02037178 kind:function(arm,size=0x38) addr:0x2037134
|
||||
func_020371b0 kind:function(arm,size=0x4) addr:0x203716c
|
||||
_Z13func_020371b4P11UnknownData kind:function(thumb,size=0x14) addr:0x2037170
|
||||
_Z13func_020371c8P11UnknownDataPji kind:function(thumb,size=0x90) addr:0x2037184
|
||||
_Z13func_02037258P11UnknownDatai kind:function(arm,size=0x34) addr:0x2037214
|
||||
_Z13func_0203728cP11UnknownDatai kind:function(arm,size=0x64) addr:0x2037248
|
||||
_Z13func_020371b4P11BMGFileInfo kind:function(thumb,size=0x14) addr:0x2037170
|
||||
_Z13func_020371c8P11BMGFileInfoPji kind:function(thumb,size=0x90) addr:0x2037184
|
||||
_Z13func_02037258P11BMGFileInfoi kind:function(arm,size=0x34) addr:0x2037214
|
||||
_Z13func_0203728cP11BMGFileInfoi kind:function(arm,size=0x64) addr:0x2037248
|
||||
_ZN14MessageManager13func_020372f0Eiii kind:function(thumb,size=0xc4) addr:0x20372ac
|
||||
func_020373b4 kind:function(thumb,size=0x38) addr:0x2037370
|
||||
func_020373ec kind:function(arm,size=0x60) addr:0x20373a8
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
#include "types.h"
|
||||
|
||||
#define BMG_MAGIC "MESGbmg1"
|
||||
#define BMG_TAG(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
|
||||
|
||||
typedef enum BMGTag {
|
||||
/* "INF1" */ BMG_TAG_INF1 = BMG_TAG('I', 'N', 'F', '1'),
|
||||
/* "FLW1" */ BMG_TAG_FLW1 = BMG_TAG('F', 'L', 'W', '1'),
|
||||
/* "FLI1" */ BMG_TAG_FLI1 = BMG_TAG('F', 'L', 'I', '1'),
|
||||
/* "DAT1" */ BMG_TAG_DAT1 = BMG_TAG('D', 'A', 'T', '1'),
|
||||
} BMGTag;
|
||||
|
||||
typedef enum BMGEncoding {
|
||||
/* 1 */ BMG_ENCODING_CP1252 = 1,
|
||||
/* 2 */ BMG_ENCODING_UTF16_BE,
|
||||
/* 3 */ BMG_ENCODING_SHIFT_JIS,
|
||||
/* 4 */ BMG_ENCODING_UTF8,
|
||||
/* 5 */ BMG_ENCODING_MAX
|
||||
} BMGEncoding;
|
||||
|
||||
typedef struct BMGSectionBase {
|
||||
/* 0x00 */ char tag[4]; // "INF1", "DAT1", ...
|
||||
/* 0x04 */ u32 size; // the size of the section
|
||||
} BMGSectionBase; // size = 0x8
|
||||
|
||||
typedef struct BMGHeader {
|
||||
/* 0x00 */ char magic[8]; // always "MESGbmg1"
|
||||
/* 0x08 */ u32 fileSize; // the size of the BMG file
|
||||
/* 0x0C */ u32 numSections; // the number of sections (INF1, DAT1, ...)
|
||||
/* 0x10 */ u8 encoding; // see `BMGEncoding`
|
||||
/* 0x11 */ u8 unk_11[0xF]; // alignment padding?
|
||||
/* 0x20 */ BMGSectionBase* firstSection; // technically not part of the header but used by functions
|
||||
} BMGHeader; // size = 0x24
|
||||
|
||||
typedef struct EntryINF1 {
|
||||
/* 0x00 */ u32 offset; // relative to the end of the DAT1 header
|
||||
/* 0x04 */ u32 unk_04; // flags?
|
||||
} EntryINF1; // size = 0x8
|
||||
|
||||
typedef struct SectionINF1 {
|
||||
/* 0x00 */ BMGSectionBase base;
|
||||
/* 0x08 */ u16 numEntries;
|
||||
/* 0x0A */ u16 entrySize;
|
||||
/* 0x0C */ u16 groupId;
|
||||
/* 0x0E */ u8 colorId;
|
||||
/* 0x0F */ u8 unk_0F[0x1]; // alignment padding?
|
||||
/* 0x10 */ EntryINF1* entries;
|
||||
} SectionINF1;
|
||||
|
||||
typedef struct EntryFLW1 {
|
||||
/* 0x00 */ u8* data; //! TODO: find what's the format
|
||||
} EntryFLW1;
|
||||
|
||||
typedef struct SectionFLW1 {
|
||||
/* 0x00 */ BMGSectionBase base;
|
||||
/* 0x08 */ EntryFLW1* entries;
|
||||
} SectionFLW1;
|
||||
|
||||
typedef struct EntryFLI1 {
|
||||
/* 0x00 */ u8* data; //! TODO: find what's the format
|
||||
} EntryFLI1;
|
||||
|
||||
typedef struct SectionFLI1 {
|
||||
/* 0x00 */ BMGSectionBase base;
|
||||
/* 0x08 */ EntryFLI1* entries;
|
||||
} SectionFLI1;
|
||||
|
||||
typedef struct EntryDAT1 {
|
||||
/* 0x00 */ char* text;
|
||||
} EntryDAT1;
|
||||
|
||||
typedef struct SectionDAT1 {
|
||||
/* 0x00 */ BMGSectionBase base;
|
||||
/* 0x08 */ EntryDAT1* entries;
|
||||
} SectionDAT1;
|
||||
|
||||
typedef struct BMGFileInfo {
|
||||
/* 0x00 */ BMGHeader* pHeader; // pointer to the file's header
|
||||
/* 0x04 */ SectionINF1* pINF1; // pointer to the data informations (INF -> informations)
|
||||
/* 0x08 */ SectionFLW1* pFLW1; // pointer to an unknown dataset (FLW -> ?)
|
||||
/* 0x0C */ SectionFLI1* pFLI1; // pointer to an unknown dataset (FLI -> ?)
|
||||
/* 0x10 */ SectionDAT1* pDAT1; // pointer to the data (DAT -> data)
|
||||
/* 0x14 */ BMGHeader* unk_14; // same as unk_00 (?)
|
||||
/* 0x18 */ s16 unk_18; // stores `func_020372f0`->param_3 value (currently undetermined purpose)
|
||||
/* 0x1A */ s16 unk_1A; // stores result of `func_020371c8` (currently undetermined purpose)
|
||||
} BMGFileInfo; // size = 0x1C
|
||||
@@ -2,21 +2,19 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "types.h"
|
||||
#include "Message/BMG.hpp"
|
||||
|
||||
typedef struct UnknownData {
|
||||
unk32 unk_00;
|
||||
unk32 unk_04;
|
||||
unk32 unk_08;
|
||||
unk32 unk_0C;
|
||||
unk32 unk_10;
|
||||
unk32 unk_14;
|
||||
unk16 unk_18;
|
||||
unk16 unk_1A;
|
||||
} UnknownData;
|
||||
/**
|
||||
* - pHeader
|
||||
* 021ACFD0
|
||||
* 021FD7B0
|
||||
* 02204380
|
||||
* 023D98B0
|
||||
*/
|
||||
|
||||
class MessageManager {
|
||||
private:
|
||||
UnknownData* aUnknownData;
|
||||
BMGFileInfo* aUnknownData;
|
||||
|
||||
public:
|
||||
void func_020372f0(int index, int param_3, int param_4);
|
||||
|
||||
+102
-25
@@ -3,33 +3,108 @@ extern "C" {
|
||||
}
|
||||
#include "Message/MessageManager.hpp"
|
||||
|
||||
char* func_0202ab38(int lang);
|
||||
char* func_0202ab38(u32* lang);
|
||||
u32* func_0202d550(int, u32*, char* path, int, int, int);
|
||||
|
||||
extern u32 *data_027e0ce0[];
|
||||
extern u32 data_027e05f4; // language
|
||||
extern u32* data_ov002_0210016c;
|
||||
|
||||
THUMB void func_020371b4(UnknownData* pData) {
|
||||
pData->unk_00 = 0;
|
||||
pData->unk_04 = 0;
|
||||
pData->unk_08 = 0;
|
||||
pData->unk_0C = 0;
|
||||
pData->unk_10 = 0;
|
||||
pData->unk_14 = 0;
|
||||
THUMB void func_020371b4(BMGFileInfo* pData) {
|
||||
pData->pHeader = NULL;
|
||||
pData->pINF1 = NULL;
|
||||
pData->pFLW1 = NULL;
|
||||
pData->pFLI1 = NULL;
|
||||
pData->pDAT1 = NULL;
|
||||
pData->unk_14 = NULL;
|
||||
pData->unk_18 = 0;
|
||||
}
|
||||
|
||||
THUMB int func_020371c8(UnknownData* pData, u32* param_2, int param_3) {
|
||||
/* TODO */
|
||||
THUMB int func_020371c8(BMGFileInfo* pData, u32* pFile, int param_3) {
|
||||
char acVar1;
|
||||
char* pacVar2;
|
||||
char acVar3;
|
||||
int dVar4;
|
||||
u32 uVar5;
|
||||
|
||||
pData->unk_14 = (BMGHeader*)pFile;
|
||||
pData->unk_18 = param_3;
|
||||
pData->pHeader = (BMGHeader*)pFile;
|
||||
|
||||
acVar1 = BMG_TAG_FLI1;
|
||||
|
||||
// acVar1 = 'FLI1';
|
||||
// pacVar2 = pHeader->firstSection;
|
||||
// uVar5 = 0;
|
||||
// dVar4 = 0xFFFF;
|
||||
|
||||
if (pData->pFLI1 != NULL) {
|
||||
// do {
|
||||
// acVar3 = *pacVar2;
|
||||
|
||||
if (acVar1 < acVar3) {
|
||||
// if ('DAT1' < acVar3) {
|
||||
// if (acVar3 == 'FLW1') {
|
||||
// pData->pFLW1 = (int)pacVar2;
|
||||
// }
|
||||
// } else if ('DAT1' <= acVar3) {
|
||||
// pData->pDAT1 = (int)(pacVar2 + 2);
|
||||
// }
|
||||
} else if (acVar3 < acVar1) {
|
||||
// if (('MID1' < acVar3) && (acVar3 == 'INF1')) {
|
||||
// pData->pINF1 = (int)pacVar2;
|
||||
// dVar4 = pacVar2[3];
|
||||
// }
|
||||
} else {
|
||||
// pData->pFLI1 = (int)pacVar2;
|
||||
}
|
||||
|
||||
// uVar5 = uVar5 + 1;
|
||||
// pacVar2++;
|
||||
// } while (uVar5 < pData->pFLI1);
|
||||
}
|
||||
|
||||
return dVar4;
|
||||
}
|
||||
|
||||
THUMB int func_02037258(UnknownData* pData, unk32 param_2) {
|
||||
/* TODO */
|
||||
ARM int func_02037258(BMGFileInfo* pData, unk32 param_2) {
|
||||
// u32 iVar1;
|
||||
|
||||
// iVar1 = pData->pINF1;
|
||||
|
||||
// if (iVar1 == 0) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// if (param_2 < iVar1) {
|
||||
// return (iVar1 + 10) * param_2 + iVar1 + 0x10;
|
||||
// }
|
||||
|
||||
// return 0;
|
||||
}
|
||||
|
||||
THUMB unk16 func_0203728c(UnknownData* pData, unk32 param_2) {
|
||||
/* TODO */
|
||||
ARM s64 func_0203728c(BMGFileInfo* pData, unk32 param_2) {
|
||||
// u32* iVar1;
|
||||
// u32 uVar2;
|
||||
// u32 uVar3;
|
||||
|
||||
// iVar1 = pData->unk_0C;
|
||||
// if (iVar1 == 0) {
|
||||
// return 0xFFFF;
|
||||
// }
|
||||
|
||||
// uVar2 = 0;
|
||||
// if (iVar1 + 0xC + 8 != 0) {
|
||||
// do {
|
||||
// if (param_2 == *(int *)(iVar1 + 0x10 + uVar2 * 8)) {
|
||||
// return iVar1 + 0x10 + uVar2 * 8 + 4;
|
||||
// }
|
||||
// uVar3 = uVar2 + 1;
|
||||
// uVar2 = uVar3 & 0xFFFF;
|
||||
// } while ((uVar3 & 0xFFFF) < iVar1 + 0xC + 8);
|
||||
// }
|
||||
|
||||
// return 0xFFFF;
|
||||
}
|
||||
|
||||
static char* sBMGFiles[] = {
|
||||
@@ -71,32 +146,34 @@ static char* sBMGFiles[] = {
|
||||
|
||||
THUMB void MessageManager::func_020372f0(int index, int param_3, int param_4) {
|
||||
char bmgPath[64];
|
||||
UnknownData local_70;
|
||||
u32* uVar2;
|
||||
BMGFileInfo bmgFile;
|
||||
u32* pFile;
|
||||
int iVar1;
|
||||
|
||||
// path to the bmg file for the current language (i.e.: "English/Message/battle.bmg")
|
||||
strcpy(bmgPath, func_0202ab38(data_027e05f4));
|
||||
strcpy(bmgPath, func_0202ab38(&data_027e05f4));
|
||||
strcat(bmgPath, "/Message/");
|
||||
strcat(bmgPath, sBMGFiles[index]);
|
||||
strcat(bmgPath, ".bmg");
|
||||
|
||||
uVar2 = data_027e0ce0[1];
|
||||
pFile = data_027e0ce0[1];
|
||||
|
||||
if (param_3 != 1) {
|
||||
if (param_3 != 4) {
|
||||
uVar2 = data_027e0ce0[0];
|
||||
pFile = data_027e0ce0[0];
|
||||
} else {
|
||||
uVar2 = data_ov002_0210016c;
|
||||
pFile = data_ov002_0210016c;
|
||||
}
|
||||
} else {
|
||||
// pFile = data_027e0ce0[0];
|
||||
}
|
||||
|
||||
uVar2 = func_0202d550(0xC4, uVar2, bmgPath, 0, 0x10, 0);
|
||||
pFile = func_0202d550(0xC4, pFile, bmgPath, 0, 0x10, 0);
|
||||
|
||||
local_70.unk_1A = 0;
|
||||
func_020371b4(&local_70);
|
||||
bmgFile.unk_1A = 0;
|
||||
func_020371b4(&bmgFile);
|
||||
|
||||
iVar1 = func_020371c8(&local_70, uVar2, param_3);
|
||||
this->aUnknownData[iVar1] = local_70;
|
||||
iVar1 = func_020371c8(&bmgFile, pFile, param_3);
|
||||
this->aUnknownData[iVar1] = bmgFile;
|
||||
this->aUnknownData[iVar1].unk_1A = iVar1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user