Refactor structs

This commit is contained in:
AnonymousRandomPerson 2026-03-17 23:40:02 -04:00
parent d5b05f0bd3
commit 2fc5d35ae1
18 changed files with 123 additions and 168 deletions

View File

@ -11,7 +11,22 @@ struct unkStruct_02058FCC {
const u8 field_0x18[4][0x4c];
};
struct WriteMonsterInfoToSave_struct {
u32 unk0;
u32 unk4;
s32 result;
u32 unkC;
};
bool8 ExplorerMazeMonsterExists(void);
void sub_02058FCC(struct unkStruct_02058FCC *ptr);
// Returns the name of the explorer maze team. If the language of the team name is different from the
// language of selected in this game a default team name is written to the buffer instead.
// dest: [output] Buffer
void GetExplorerMazeTeamName(u8 *dest);
u64 sub_020590C0(void);
void sub_020590DC(u64 param0);
struct ground_monster* GetExplorerMazeMonster(s16 entry_number);
s32 WriteMonsterInfoToSave(void* start_addr, u32 total_len);
#endif //PMDSKY_MAIN_02058FA4_H

View File

@ -1,20 +0,0 @@
#ifndef PMDSKY_MAIN_02059060_H
#define PMDSKY_MAIN_02059060_H
struct WriteMonsterInfoToSave_struct {
u32 unk0;
u32 unk4;
s32 result;
u32 unkC;
};
// Returns the name of the explorer maze team. If the language of the team name is different from the
// language of selected in this game a default team name is written to the buffer instead.
// dest: [output] Buffer
void GetExplorerMazeTeamName(u8 *dest);
u64 sub_020590C0(void);
void sub_020590DC(u64 param0);
struct ground_monster* GetExplorerMazeMonster(s16 entry_number);
s32 WriteMonsterInfoToSave(void* start_addr, u32 total_len);
#endif //PMDSKY_MAIN_02059060_H

View File

@ -1,6 +1,34 @@
#ifndef PMDSKY_MAIN_0205B690_H
#define PMDSKY_MAIN_0205B690_H
struct unkStruct_020B0A54_unk8_inner {
u8 fill0[0x44];
u16 unk44;
u16 unk46;
u16 unk48;
};
union unkStruct_020B0A54_unk8 {
struct ground_monster *monster;
struct unkStruct_020B0A54_unk8_inner *unk8;
};
struct unkStruct_020B0A54 {
u8 unk0;
u8 unk1[7];
union unkStruct_020B0A54_unk8 unk8;
u8 unkC[150];
u16 unkA2;
u8 unkA4[12];
};
// Stupid hack but it's needed for some matches.
union unkStruct_020B0A54_union {
struct unkStruct_020B0A54 *struct0;
struct unkStruct_020B0A54 struct1;
void (*fp[])(void);
};
s32 sub_0205B690(void);
#endif //PMDSKY_MAIN_0205B690_H

View File

@ -1,12 +1,9 @@
#ifndef PMDSKY_MAIN_0205B6EC_H
#define PMDSKY_MAIN_0205B6EC_H
#include "main_0205B690.h"
#include "util.h"
struct unkStruct_0205B6EC {
u32 data[44];
};
bool8 sub_0205B6EC(struct unkStruct_0205B6EC *src);
bool8 sub_0205B6EC(struct unkStruct_020B0A54 *src);
#endif //PMDSKY_MAIN_0205B6EC_H

View File

@ -1,13 +1,10 @@
#ifndef PMDSKY_MAIN_0205B77C_H
#define PMDSKY_MAIN_0205B77C_H
// Should match the struct in main_0205B690, but haven't gotten it to match yet.
// https://decomp.me/scratch/lmvJx
struct unkStruct_020B0A54 {
u32 data[44];
};
#include "main_0205B690.h"
u32* sub_0205B77C(u32 a);
u8* sub_0205B77C(u32 a);
void sub_0205B794(struct unkStruct_020B0A54 *dest, s32 index);
void sub_0205B7C8(s32 index);
#endif //PMDSKY_MAIN_0205B77C_H

View File

@ -1,15 +0,0 @@
#ifndef PMDSKY_MAIN_0205B7C8_H
#define PMDSKY_MAIN_0205B7C8_H
// Should match the struct in main_0205B690, but haven't gotten it to match yet.
// https://decomp.me/scratch/WXX6d
struct unkStruct_020B0A54 {
u8 f0;
u8 pad[161];
u16 fA2;
u8 pad2[12];
};
void sub_0205B7C8(s32 index);
#endif //PMDSKY_MAIN_0205B7C8_H

View File

@ -1,12 +1,16 @@
#ifndef PMDSKY_MAIN_0205BBFC_H
#define PMDSKY_MAIN_0205BBFC_H
// Should match the struct in main_0205B690, but haven't gotten it to match yet.
// https://decomp.me/scratch/VFs0J
struct unkStruct_020B0A54 {
u32 val[17];
#include "common.h"
struct unkStruct_0205BC94 {
u16 unk0;
u16 unk2;
u16 unk4;
};
void sub_0205BBFC(struct unkStruct_020B0A54 *dest);
void sub_0205BBFC(struct ground_monster *dest);
void sub_0205BC30(u32 a, u32 b);
void sub_0205BC94(struct unkStruct_0205BC94 *p);
#endif //PMDSKY_MAIN_0205BBFC_H

View File

@ -1,13 +0,0 @@
#ifndef PMDSKY_MAIN_0205BC30_H
#define PMDSKY_MAIN_0205BC30_H
struct unkStruct_0205BC94 {
u16 unk0;
u16 unk2;
u16 unk4;
};
void sub_0205BC30(u32 a, u32 b);
void sub_0205BC94(struct unkStruct_0205BC94 *p);
#endif //PMDSKY_MAIN_0205BC30_H

View File

@ -152,12 +152,10 @@ Static main
Object src/main_0205B6EC.o
Object asm/main_0205B738.o
Object src/main_0205B77C.o
Object src/main_0205B7C8.o
Object asm/main_0205B80C.o
Object src/main_0205B9C8.o
Object asm/main_0205BA0C.o
Object src/main_0205BBFC.o
Object src/main_0205BC30.o
Object asm/main_0205BCC4.o
Object src/dungeon_init_2.o
Object asm/main_0206A750.o

View File

@ -1,4 +1,4 @@
#include "main_02059060.h"
#include "main_02058FA4.h"
#include "common.h"
#include "main_0202593C.h"
#include "main_02058FA4.h"

View File

@ -1,12 +1,12 @@
#include "main_0205B440.h"
#include "main_0205B690.h"
extern union unkStruct_020B0A54_union _020B0A54;
extern u8 _020A3550;
extern void _022B5910(void);
extern void _022B57C0(void);
extern void _022B580C(void);
// Should match the struct in main_0205B77C, but haven't gotten it to match yet.
// https://decomp.me/scratch/fRcSA
extern void (*_020B0A54[])(void);
u8* sub_0205B440(void)
{
@ -15,7 +15,7 @@ u8* sub_0205B440(void)
void sub_0205B44C(void)
{
_020B0A54[0] = _022B5910;
_020B0A54[2] = _022B57C0;
_020B0A54[1] = _022B580C;
_020B0A54.fp[0] = _022B5910;
_020B0A54.fp[2] = _022B57C0;
_020B0A54.fp[1] = _022B580C;
}

View File

@ -1,19 +1,12 @@
#include "main_0205B690.h"
// Should match the struct in main_0205B77C, but haven't gotten it to match yet.
// https://decomp.me/scratch/J6Sh5
struct unkStruct_020B0A54 {
u8 unk0;
u8 fill0[175];
};
extern struct unkStruct_020B0A54 *_020B0A54;
extern union unkStruct_020B0A54_union _020B0A54;
s32 sub_0205B690(void)
{
for (s32 i = 2; i < 32; i++)
{
if (_020B0A54[i].unk0 == 0)
if (_020B0A54.struct0[i].unk0 == 0)
{
return i;
}

View File

@ -1,19 +1,17 @@
#include "main_0205B6EC.h"
extern struct unkStruct_0205B6EC *_020B0A54;
extern union unkStruct_020B0A54_union _020B0A54;
extern s32 sub_0205B690(struct unkStruct_0205B6EC *src);
bool8 sub_0205B6EC(struct unkStruct_0205B6EC *src)
bool8 sub_0205B6EC(struct unkStruct_020B0A54 *src)
{
s32 res = sub_0205B690(src);
s32 res = sub_0205B690();
if (res == -1)
{
return FALSE;
}
_020B0A54[res] = *src;
_020B0A54.struct0[res] = *src;
return TRUE;
}

View File

@ -1,13 +1,21 @@
#include "main_0205B77C.h"
#include "main_0200330C.h"
extern struct unkStruct_020B0A54 *_020B0A54;
extern union unkStruct_020B0A54_union _020B0A54;
u32* sub_0205B77C(u32 a)
u8* sub_0205B77C(u32 a)
{
return a * 44 + _020B0A54->data;
return a * 176 + &_020B0A54.struct0->unk0;
}
void sub_0205B794(struct unkStruct_020B0A54 *dest, s32 index)
{
*dest = _020B0A54[index];
*dest = _020B0A54.struct0[index];
}
void sub_0205B7C8(s32 index)
{
MemsetSimple((u8*) &_020B0A54.struct0[index], 0, 0xB0);
_020B0A54.struct0[index].unk0 = 0;
_020B0A54.struct0[index].unkA2 = 0;
}

View File

@ -1,11 +0,0 @@
#include "main_0205B7C8.h"
#include "main_0200330C.h"
extern struct unkStruct_020B0A54 *_020B0A54;
void sub_0205B7C8(s32 index)
{
MemsetSimple((u8*) &_020B0A54[index], 0, 0xB0);
_020B0A54[index].f0 = 0;
_020B0A54[index].fA2 = 0;
}

View File

@ -1,17 +1,16 @@
#include "main_0205B9C8.h"
#include "main_0205B7C8.h"
#include "main_0205B690.h"
extern struct unkStruct_020B0A54 *_020B0A54;
extern union unkStruct_020B0A54_union _020B0A54;
s32 sub_0205B9C8(s32 a)
{
struct unkStruct_020B0A54 *ptr = _020B0A54;
struct unkStruct_020B0A54 *ptr = _020B0A54.struct0;
s32 count = 0;
s32 i = (a != 0) ? 2 : 0;
for (; i < 32; i++)
for (s32 i = (a != 0) ? 2 : 0; i < 32; i++)
{
if (_020B0A54[i].f0 != 0)
if (_020B0A54.struct0[i].unk0 != 0)
{
count++;
}

View File

@ -1,8 +1,41 @@
#include "main_0205BBFC.h"
#include "main_0200330C.h"
#include "main_0205B690.h"
extern struct unkStruct_020B0A54 *_020B0A54[];
extern union unkStruct_020B0A54_union _020B0A54;
void sub_0205BBFC(struct unkStruct_020B0A54 *dest)
extern void sub_02055F04(struct ground_monster *p, u32 a);
extern u32 sub_02051788(u32 val);
void sub_0205BBFC(struct ground_monster *dest)
{
*dest = *_020B0A54[2];
*dest = *_020B0A54.struct1.unk8.monster;
}
void sub_0205BC30(u32 a, u32 b)
{
if (a == 0)
{
MemsetSimple((u8*) _020B0A54.struct1.unk8.monster, 0, 0x44);
return;
}
sub_02055F04(_020B0A54.struct1.unk8.monster, a);
if (b != 0)
{
return;
}
_020B0A54.struct1.unk8.monster->joined_at = sub_02051788(_020B0A54.struct1.unk8.monster->joined_at);
}
void sub_0205BC94(struct unkStruct_0205BC94 *p)
{
struct unkStruct_020B0A54_unk8_inner *inner = _020B0A54.struct1.unk8.unk8;
p->unk0 = inner->unk44;
p->unk2 = inner->unk46;
p->unk4 = inner->unk48;
*(u8 *)p = 1;
}

View File

@ -1,56 +0,0 @@
#include "main_0205BC30.h"
#include "main_0200330C.h"
#include "common.h"
struct unkStruct_020B0A54_inner {
u8 fill0[0x44];
u16 unk44;
u16 unk46;
u16 unk48;
};
union unkStruct_020B0A54_union
{
struct ground_monster *monster;
struct unkStruct_020B0A54_inner *inner;
};
// Should match the struct in main_0205B690, but haven't gotten it to match yet.
// https://decomp.me/scratch/e6YZI
struct unkStruct_020B0A54 {
u8 unk0[8];
union unkStruct_020B0A54_union inner;
};
extern void sub_02055F04(struct ground_monster *p, u32 a);
extern u32 sub_02051788(u32 val);
extern struct unkStruct_020B0A54 _020B0A54;
void sub_0205BC30(u32 a, u32 b)
{
if (a == 0)
{
MemsetSimple((u8*) _020B0A54.inner.monster, 0, 0x44);
return;
}
sub_02055F04(_020B0A54.inner.monster, a);
if (b != 0)
{
return;
}
_020B0A54.inner.monster->joined_at = sub_02051788(_020B0A54.inner.monster->joined_at);
}
void sub_0205BC94(struct unkStruct_0205BC94 *p)
{
struct unkStruct_020B0A54_inner *inner = _020B0A54.inner.inner;
p->unk0 = inner->unk44;
p->unk2 = inner->unk46;
p->unk4 = inner->unk48;
*(u8 *)p = 1;
}