From a5c90b097045a50df6ecb7cc37ce50f3fc9f142f Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Tue, 1 Mar 2022 19:40:00 -0800 Subject: decomp some more saving functions --- src/code_80972F4.c | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 src/code_80972F4.c (limited to 'src/code_80972F4.c') diff --git a/src/code_80972F4.c b/src/code_80972F4.c new file mode 100644 index 0000000..7e87832 --- /dev/null +++ b/src/code_80972F4.c @@ -0,0 +1,200 @@ +#include "global.h" +#include "pokemon.h" +#include "wonder_mail.h" + +extern void xxx_save_poke_sub_4_80902F4(struct unkStruct_8094924*, struct unkPokeSubStruct_4*); +extern void xxx_restore_poke_sub_4_8090314(struct unkStruct_8094924*, struct unkPokeSubStruct_4*); +extern void sub_80015C0(u32, u32); + +struct unkStruct_8097270 +{ + u8 unk0; + u8 unk1; + u8 unk2; + struct unkPokeSubStruct_4 unk4; + u32 unk8; + u16 unkC; + u16 unkE; + u8 unk10; + u8 unk11; + u8 unk12; + u8 unk13; +}; + +struct subStruct_203B490 +{ + // size: 0xC + struct unkPokeSubStruct_4 unk0; + u32 unk4; + u32 unk8; +}; + + +struct unkStruct_203B490 +{ + // size: 0x330? + + struct unkStruct_8097270 unk0[4]; + struct unkStruct_8097270 unk50[8]; + struct unkStruct_8097270 unkF0[8]; + u8 unk190[0x28]; + u8 unk1B8[0x78]; + struct subStruct_203B490 unk230[16]; + u8 unk2F0[0x38]; + u8 unk328; +}; +extern struct unkStruct_203B490 *gUnknown_203B490; + +void sub_8097270(struct unkStruct_8094924 *a, struct unkStruct_8097270 *b); +void sub_80971EC(struct unkStruct_8094924 *a, struct unkStruct_8097270 *b); +extern s32 sub_8096EB0(void); + +bool8 sub_8096F50(struct WonderMail *r0) +{ + s32 index; + s32 temp2; + struct subStruct_203B490 *temp; + + temp2 = sub_8096EB0(); + + + for(index = 0; index < 0x10; index++) + { + temp = &gUnknown_203B490->unk230[index]; + if(temp->unk0.unk4 == r0->dungeon) + if(temp->unk0.unk5 == r0->floor) + if(temp->unk4 == r0->unk8) + if(temp->unk8 == temp2) + return TRUE; + } + return FALSE; +} + +u32 sub_8096FA0(u8 *r0, u32 size) +{ + s32 index; + struct unkStruct_8094924 backup; + u32 temp; + + xxx_init_struct_8094924_restore_809485C(&backup, r0, size); + for(index = 0; index < 4; index++) + { + sub_80971EC(&backup, &gUnknown_203B490->unk0[index]); + } + for(index = 0; index < 8; index++) + { + sub_80971EC(&backup, &gUnknown_203B490->unk50[index]); + } + for(index = 0; index < 8; index++) + { + sub_80971EC(&backup, &gUnknown_203B490->unkF0[index]); + } + for(index = 0; index < 0x38; index++) + { + RestoreIntegerBits(&backup, &temp, 1); + if(temp & 1) + gUnknown_203B490->unk2F0[index] = 1; + else + gUnknown_203B490->unk2F0[index] = 0; + } + RestoreIntegerBits(&backup, &temp, 1); + if(temp & 1) + gUnknown_203B490->unk328 = 1; + else + gUnknown_203B490->unk328 = 0; + + RestoreIntegerBits(&backup, gUnknown_203B490->unk190, 0x140); + RestoreIntegerBits(&backup, gUnknown_203B490->unk1B8, 0x3C0); + for(index = 0; index < 0x10; index++) + { + RestoreIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk8, 0x20); + RestoreIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk4, 0x18); + xxx_restore_poke_sub_4_8090314(&backup, &gUnknown_203B490->unk230[index].unk0); + } + nullsub_102(&backup); + return backup.unk8; +} + +u32 sub_80970D8(u8 *r0, u32 size) +{ + s32 index; + struct unkStruct_8094924 backup; + u32 temp; + + xxx_init_struct_8094924_save_809486C(&backup, r0, size); + for(index = 0; index < 4; index++) + { + sub_8097270(&backup, &gUnknown_203B490->unk0[index]); + } + for(index = 0; index < 8; index++) + { + sub_8097270(&backup, &gUnknown_203B490->unk50[index]); + } + for(index = 0; index < 8; index++) + { + sub_8097270(&backup, &gUnknown_203B490->unkF0[index]); + } + for(index = 0; index < 0x38; index++) + { + if(gUnknown_203B490->unk2F0[index] != 0) + temp = -1; + else + temp = 0; + SaveIntegerBits(&backup, &temp, 1); + } + if(gUnknown_203B490->unk328 != 0) + temp = -1; + else + temp = 0; + SaveIntegerBits(&backup, &temp, 1); + SaveIntegerBits(&backup, gUnknown_203B490->unk190, 0x140); + SaveIntegerBits(&backup, gUnknown_203B490->unk1B8, 0x3C0); + for(index = 0; index < 0x10; index++) + { + SaveIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk8, 0x20); + SaveIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk4, 0x18); + xxx_save_poke_sub_4_80902F4(&backup, &gUnknown_203B490->unk230[index].unk0); + } + nullsub_102(&backup); + return backup.unk8; +} + +void sub_80971EC(struct unkStruct_8094924 *a, struct unkStruct_8097270 *b) +{ + RestoreIntegerBits(a, &b->unk0, 4); + RestoreIntegerBits(a, &b->unk1, 3); + RestoreIntegerBits(a, &b->unk2, 4); + RestoreIntegerBits(a, &b->unkC, 9); + RestoreIntegerBits(a, &b->unkE, 9); + RestoreIntegerBits(a, &b->unk10, 8); + RestoreIntegerBits(a, &b->unk11, 4); + RestoreIntegerBits(a, &b->unk12, 8); + RestoreIntegerBits(a, &b->unk13, 6); + RestoreIntegerBits(a, &b->unk8, 0x18); + xxx_restore_poke_sub_4_8090314(a, &b->unk4); +} + +void sub_8097270(struct unkStruct_8094924 *a, struct unkStruct_8097270 *b) +{ + SaveIntegerBits(a, &b->unk0, 4); + SaveIntegerBits(a, &b->unk1, 3); + SaveIntegerBits(a, &b->unk2, 4); + SaveIntegerBits(a, &b->unkC, 9); + SaveIntegerBits(a, &b->unkE, 9); + SaveIntegerBits(a, &b->unk10, 8); + SaveIntegerBits(a, &b->unk11, 4); + SaveIntegerBits(a, &b->unk12, 8); + SaveIntegerBits(a, &b->unk13, 6); + SaveIntegerBits(a, &b->unk8, 0x18); + xxx_save_poke_sub_4_80902F4(a, &b->unk4); +} + +void sub_80972F4(void) +{ + sub_80015C0(0, 0x2B); + sub_80015C0(0, 0x2C); + sub_80015C0(0, 0x2D); +} + +void nullsub_128(void) +{} -- cgit v1.2.3 From aa939e0955ec683efb5dd963430eace695a26af9 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sun, 6 Mar 2022 14:41:40 -0600 Subject: All saving functions decomped - poke_sub_4 was determined to be Dungeon Index/Floor - Clean up code that references these functions --- src/code_80972F4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/code_80972F4.c') diff --git a/src/code_80972F4.c b/src/code_80972F4.c index 7e87832..c0fa1a3 100644 --- a/src/code_80972F4.c +++ b/src/code_80972F4.c @@ -61,8 +61,8 @@ bool8 sub_8096F50(struct WonderMail *r0) for(index = 0; index < 0x10; index++) { temp = &gUnknown_203B490->unk230[index]; - if(temp->unk0.unk4 == r0->dungeon) - if(temp->unk0.unk5 == r0->floor) + if(temp->unk0.dungeonIndex == r0->dungeon) + if(temp->unk0.dungeonFloor == r0->floor) if(temp->unk4 == r0->unk8) if(temp->unk8 == temp2) return TRUE; -- cgit v1.2.3 From 57f540b320ae8439fe4b42c6149641b877c7ea73 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Mon, 21 Mar 2022 17:48:40 -0700 Subject: fix a few nonmatchings and code cleanup --- src/code_80972F4.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/code_80972F4.c') diff --git a/src/code_80972F4.c b/src/code_80972F4.c index c0fa1a3..1c7e125 100644 --- a/src/code_80972F4.c +++ b/src/code_80972F4.c @@ -2,8 +2,8 @@ #include "pokemon.h" #include "wonder_mail.h" -extern void xxx_save_poke_sub_4_80902F4(struct unkStruct_8094924*, struct unkPokeSubStruct_4*); -extern void xxx_restore_poke_sub_4_8090314(struct unkStruct_8094924*, struct unkPokeSubStruct_4*); +extern void SaveDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*); +extern void RestoreDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*); extern void sub_80015C0(u32, u32); struct unkStruct_8097270 @@ -11,7 +11,7 @@ struct unkStruct_8097270 u8 unk0; u8 unk1; u8 unk2; - struct unkPokeSubStruct_4 unk4; + struct DungeonLocation unk4; u32 unk8; u16 unkC; u16 unkE; @@ -24,7 +24,7 @@ struct unkStruct_8097270 struct subStruct_203B490 { // size: 0xC - struct unkPokeSubStruct_4 unk0; + struct DungeonLocation unk0; u32 unk4; u32 unk8; }; @@ -109,7 +109,7 @@ u32 sub_8096FA0(u8 *r0, u32 size) { RestoreIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk8, 0x20); RestoreIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk4, 0x18); - xxx_restore_poke_sub_4_8090314(&backup, &gUnknown_203B490->unk230[index].unk0); + RestoreDungeonLocation(&backup, &gUnknown_203B490->unk230[index].unk0); } nullsub_102(&backup); return backup.unk8; @@ -153,7 +153,7 @@ u32 sub_80970D8(u8 *r0, u32 size) { SaveIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk8, 0x20); SaveIntegerBits(&backup, &gUnknown_203B490->unk230[index].unk4, 0x18); - xxx_save_poke_sub_4_80902F4(&backup, &gUnknown_203B490->unk230[index].unk0); + SaveDungeonLocation(&backup, &gUnknown_203B490->unk230[index].unk0); } nullsub_102(&backup); return backup.unk8; @@ -171,7 +171,7 @@ void sub_80971EC(struct unkStruct_8094924 *a, struct unkStruct_8097270 *b) RestoreIntegerBits(a, &b->unk12, 8); RestoreIntegerBits(a, &b->unk13, 6); RestoreIntegerBits(a, &b->unk8, 0x18); - xxx_restore_poke_sub_4_8090314(a, &b->unk4); + RestoreDungeonLocation(a, &b->unk4); } void sub_8097270(struct unkStruct_8094924 *a, struct unkStruct_8097270 *b) @@ -186,7 +186,7 @@ void sub_8097270(struct unkStruct_8094924 *a, struct unkStruct_8097270 *b) SaveIntegerBits(a, &b->unk12, 8); SaveIntegerBits(a, &b->unk13, 6); SaveIntegerBits(a, &b->unk8, 0x18); - xxx_save_poke_sub_4_80902F4(a, &b->unk4); + SaveDungeonLocation(a, &b->unk4); } void sub_80972F4(void) -- cgit v1.2.3