summaryrefslogtreecommitdiff
path: root/include/libms/commonlib.h
blob: 6829f27889a996696129f7c72a5bd3bd62a2eb41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef LIBMS_COMMONLIB_H
#define LIBMS_COMMONLIB_H

#include "common.h"

#ifdef __cplusplus
extern "C" {
#endif

struct MsbBlockHeader {
    /* 0x00 */ char name[4];
    /* 0x04 */ int sectionLength;
    /* 0x08 */ unsigned short field_0x08;
    /* 0x0A */ unsigned char field_0x0A[0x10 - 0x0A];
    /* 0x10 */ int numEntries;
};

struct MsbBlock {
    /* 0x00 */ int *ptr;
    /* 0x04 */ char name[4];
    /* 0x08 */ int sectionLength;
    /* 0x0C */ u16 field_0x0C;
};

#pragma pack(push ,2)

struct MsbHeader {
    /* 0x00 */ unsigned char field_0x00[0x0C - 0x00];
    /* 0x0C */ unsigned char version;
    /* 0x0E */ unsigned short sectionCount;
    /* 0x10 */ unsigned char field_0x10[0x12 - 0x10];
    /* 0x12 */ int fileLength;
};

#pragma pack(pop)

struct MsbInfo {
    /* 0x00 */ struct MsbHeader *header;
    /* 0x04 */ int fileLength;
    /* 0x08 */ unsigned char version;
    /* 0x0A */ unsigned short sectionCount;
    /* 0x0C */ struct MsbBlock *sectionInfos;
};

void LMSi_AnalyzeMessageHeader(struct MsbInfo *info);
void LMSi_AnalyzeMessageBlocks(struct MsbInfo *info);
void LMSi_AnalyzeMessageBinary(struct MsbInfo *info, const char *type);
int LMSi_SearchBlockByName(struct MsbInfo *info, const char *name);
int LMSi_GetHashTableIndexFromLabel(const char *label, int tableSize);

#define LMS_OFS_TO_PTR(ty, ptr, offset) (ty *)((char *)(ptr) + (offset))

#ifdef __cplusplus
}
#endif

#endif