diff --git a/include/main_02058FA4.h b/include/main_02058FA4.h index e5b101fa..d61b76bc 100644 --- a/include/main_02058FA4.h +++ b/include/main_02058FA4.h @@ -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 diff --git a/include/main_02059060.h b/include/main_02059060.h deleted file mode 100644 index 520cfe98..00000000 --- a/include/main_02059060.h +++ /dev/null @@ -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 diff --git a/include/main_0205B690.h b/include/main_0205B690.h index 7f73eaf4..54baf627 100644 --- a/include/main_0205B690.h +++ b/include/main_0205B690.h @@ -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 diff --git a/include/main_0205B6EC.h b/include/main_0205B6EC.h index fe07c71c..55fee11f 100644 --- a/include/main_0205B6EC.h +++ b/include/main_0205B6EC.h @@ -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 diff --git a/include/main_0205B77C.h b/include/main_0205B77C.h index 5ef2bd5d..c44ccdc3 100644 --- a/include/main_0205B77C.h +++ b/include/main_0205B77C.h @@ -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 diff --git a/include/main_0205B7C8.h b/include/main_0205B7C8.h deleted file mode 100644 index c41c8bfd..00000000 --- a/include/main_0205B7C8.h +++ /dev/null @@ -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 diff --git a/include/main_0205BBFC.h b/include/main_0205BBFC.h index 543c9f16..88d9af07 100644 --- a/include/main_0205BBFC.h +++ b/include/main_0205BBFC.h @@ -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 diff --git a/include/main_0205BC30.h b/include/main_0205BC30.h deleted file mode 100644 index bb2c121d..00000000 --- a/include/main_0205BC30.h +++ /dev/null @@ -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 diff --git a/main.lsf b/main.lsf index db4dcf2e..cff94e1d 100644 --- a/main.lsf +++ b/main.lsf @@ -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 diff --git a/src/main_02059060.c b/src/main_02059060.c index 5df56b97..8ce15a4a 100644 --- a/src/main_02059060.c +++ b/src/main_02059060.c @@ -1,4 +1,4 @@ -#include "main_02059060.h" +#include "main_02058FA4.h" #include "common.h" #include "main_0202593C.h" #include "main_02058FA4.h" diff --git a/src/main_0205B440.c b/src/main_0205B440.c index 46108a7b..7c75f8f0 100644 --- a/src/main_0205B440.c +++ b/src/main_0205B440.c @@ -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; } diff --git a/src/main_0205B690.c b/src/main_0205B690.c index 811b2665..6c96a4a8 100644 --- a/src/main_0205B690.c +++ b/src/main_0205B690.c @@ -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; } diff --git a/src/main_0205B6EC.c b/src/main_0205B6EC.c index ac231d76..75798f10 100644 --- a/src/main_0205B6EC.c +++ b/src/main_0205B6EC.c @@ -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; } diff --git a/src/main_0205B77C.c b/src/main_0205B77C.c index c6ea3a3b..23f02a57 100644 --- a/src/main_0205B77C.c +++ b/src/main_0205B77C.c @@ -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; } diff --git a/src/main_0205B7C8.c b/src/main_0205B7C8.c deleted file mode 100644 index d8b54cd5..00000000 --- a/src/main_0205B7C8.c +++ /dev/null @@ -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; -} diff --git a/src/main_0205B9C8.c b/src/main_0205B9C8.c index c9b29b21..e85fd5a2 100644 --- a/src/main_0205B9C8.c +++ b/src/main_0205B9C8.c @@ -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++; } diff --git a/src/main_0205BBFC.c b/src/main_0205BBFC.c index e132d601..a8f69e02 100644 --- a/src/main_0205BBFC.c +++ b/src/main_0205BBFC.c @@ -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; } diff --git a/src/main_0205BC30.c b/src/main_0205BC30.c deleted file mode 100644 index 10acb346..00000000 --- a/src/main_0205BC30.c +++ /dev/null @@ -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; -}