diff options
| author | robojumper <robojumper@gmail.com> | 2025-04-24 14:56:08 +0200 |
|---|---|---|
| committer | robojumper <robojumper@gmail.com> | 2025-04-24 14:56:08 +0200 |
| commit | 892059c2997f7cf2da1c21244ba8db0edbbc00da (patch) | |
| tree | d38c4177423f44ec17109d64feb40f9db5423013 /src/libms/commonlib.c | |
| parent | 7fa483e8509e80725a4a6599eaf8c9e2308cfc19 (diff) | |
Most of LibMS OK
Diffstat (limited to 'src/libms/commonlib.c')
| -rw-r--r-- | src/libms/commonlib.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/libms/commonlib.c b/src/libms/commonlib.c index d3ab83d7..edbd7b8e 100644 --- a/src/libms/commonlib.c +++ b/src/libms/commonlib.c @@ -2,7 +2,6 @@ #include "libms/libms.h" - void LMSi_AnalyzeMessageHeader(struct MsbInfo *info) { info->version = info->header->version; info->sectionCount = info->header->sectionCount; @@ -14,23 +13,30 @@ void LMSi_AnalyzeMessageHeader(struct MsbInfo *info) { info->fileLength = info->header->fileLength; } +// Complete fakematch here but hey, it works inline static struct MsbBlockHeader *GetBlockHeader(struct MsbInfo *info, int offset) { + return (struct MsbBlockHeader *)((unsigned int)info->header + offset); +} + +inline static struct MsbBlockHeader *GetBlockHeader2(struct MsbInfo *info, int offset) { return (struct MsbBlockHeader *)(offset + (unsigned int)info->header); } void LMSi_AnalyzeMessageBlocks(struct MsbInfo *info) { - // TODO regswap int i; - int offset = ROUND_UP(sizeof(struct MsbHeader), 0x20); // file header + int offset; + struct MsbBlock *section; + + offset = ROUND_UP(sizeof(struct MsbHeader), 0x20); // file header for (i = 0; i < info->sectionCount; i++) { - struct MsbBlock *section = &info->sectionInfos[i]; + section = &info->sectionInfos[i]; section->ptr = &GetBlockHeader(info, offset)->numEntries; section->name[0] = GetBlockHeader(info, offset)->name[0]; - section->name[1] = GetBlockHeader(info, offset)->name[1]; - section->name[2] = GetBlockHeader(info, offset)->name[2]; - section->name[3] = GetBlockHeader(info, offset)->name[3]; - section->sectionLength = GetBlockHeader(info, offset)->sectionLength; - section->field_0x0C = GetBlockHeader(info, offset)->field_0x08; + section->name[1] = GetBlockHeader2(info, offset)->name[1]; + section->name[2] = GetBlockHeader2(info, offset)->name[2]; + section->name[3] = GetBlockHeader2(info, offset)->name[3]; + section->sectionLength = GetBlockHeader2(info, offset)->sectionLength; + section->field_0x0C = GetBlockHeader2(info, offset)->field_0x08; offset = offset + 0x10; // section header offset = offset + section->sectionLength; // section offset = ROUND_UP(offset, 0x10); // align |
