More item related decomp (#45)

* decompile sub_80918EC

* some more item related functions

* more item functions

* more decomp, fix types in other places

* more small functions

* more item related decomp

* one more weird branching item function

* fix global.h includes

* figured out branch pattern

* decompile sub_8090F58

* make temporary struct for function

* 🦀 items.s is gone 🦀

* some renaming

* rename some obvious item related constants

* fix spelling error
This commit is contained in:
Dennis
2021-07-17 18:45:13 +02:00
committed by GitHub
parent a65d358927
commit bad7f7f688
38 changed files with 1447 additions and 2215 deletions

21
include/code_8092334.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef GUARD_CODE_8092334_H
#define GUARD_CODE_8092334_H
struct unkStruct_8094924
{
// size: 0x10?
u8 *unk0; // head?
u8 *unk4; // tail?
u32 unk8;
u32 unkC;
};
void sub_809486C(struct unkStruct_8094924 *r0, u8 *r1, s32 size);
void nullsub_102(struct unkStruct_8094924 *r0);
void sub_809488C(struct unkStruct_8094924 *r0, u8 *r1, s32 size);
void sub_809485C(struct unkStruct_8094924 *r0, u8 *r1, s32 size);
void sub_80948E4(struct unkStruct_8094924 *r0, u8 *r1, s32 size);
void sub_8094924(struct unkStruct_8094924 *r0, u8 *r1, s32 size);
#endif

View File

@@ -16,7 +16,7 @@ struct unkStruct_203B2BC
s16 unk8;
u16 unkA;
u32 unkC;
struct ItemSlot_ALT unk10;
struct HeldItem unk10;
u8 unk14;
u8 fill15[3];
struct unkSubStruct_203B2BC *unk18;

View File

@@ -1,6 +1,8 @@
#ifndef GUARD_ITEMS_H
#define GUARD_ITEMS_H
#include "code_8092334.h"
struct Item
{
/* 0x0 */ u8 *namePointer;
@@ -28,11 +30,9 @@ struct ItemSlot
u8 itemIndex;
};
struct ItemSlot_ALT
{
u8 itemIndex;
u8 numItems;
u8 unk2;
struct HeldItem {
u8 itemIndex;
u8 numItems;
};
struct unkStruct_80915F4
@@ -41,6 +41,15 @@ struct unkStruct_80915F4
u16 unk2;
};
struct unkStruct_8090F58
{
u32 unk0;
u8 unk4;
u8 unk5;
s16 unk6;
u8 unk8;
};
enum ItemType
{
ITEM_TYPE_THROWABLE,
@@ -337,16 +346,28 @@ u8 *GetItemDescription(u8 itemIndex);
u32 GetItemUnkFood(u8 itemIndex, u32 r1);
s32 GetNumberOfFilledInventorySlots(void);
bool8 IsThrowableItem(u8 itemIndex);
void sub_8090A8C(struct ItemSlot *param_1,u8 itemIndex,u8 param_3);
void sub_8090B08(struct ItemSlot_ALT *param_1,u8 itemIndex);
void sub_8090B64(struct ItemSlot *param_1, struct ItemSlot_ALT *param_2);
void sub_8090DC4(void* param_1,u8 itemIndex,u32 param_3);
void xxx_init_itemslot_8090A8C(struct ItemSlot *param_1,u8 itemIndex,u8 param_3);
void xxx_init_helditem_8090B08(struct HeldItem *param_1,u8 itemIndex);
void HeldItemToSlot(struct ItemSlot *param_1, struct HeldItem *param_2);
void sub_8090DC4(void* param_1,u8 itemIndex, struct unkStruct_8090F58* param_3);
bool8 AddItemToInventory(const struct ItemSlot* slot);
void ConvertMoneyItemToMoney();
void AddToTeamMoney(s32 amount);
u32 GetMoneyValue(struct ItemSlot* slot);
u16 GetItemMove(u8 index);
bool8 CanSellItem(u32 id);
bool8 IsGummiItem(u8);
void xxx_init_unk230_substruct(u8);
bool8 xxx_insert_unk230_80919FC(u8);
u32 xxx_count_non_empty_inv_unk250_8091A48();
void sub_8091BB4(u8);
void sub_8090F58(void*, u8 *, struct ItemSlot *, struct unkStruct_8090F58*);
// some sort of weird memcpy's?
// not sure what the second argument should be typed as
void sub_8091DC0(struct unkStruct_8094924 *r0, u8*);
void sub_8091DE0(struct unkStruct_8094924 *a1, u8 *a2);
void sub_8091E00(struct unkStruct_8094924 *a1, u8 *a2);
void sub_8091E28(struct unkStruct_8094924 *a1, u8 *a2);
#endif

View File

@@ -2,6 +2,8 @@
#define GUARD_POKEMON_H
#include "file_system.h"
#include "item.h"
struct PokemonStruct
{
@@ -28,9 +30,7 @@ struct PokemonStruct
u8 unk20[4];
u8 unk24;
u8 fill25[3];
u8 itemIndexHeld;
u8 unk29;
u8 fill2A[2];
struct HeldItem heldItem;
u8 unk2C[4];
u8 fill30[0x4C - 0x30];
/* 0x4C */ u8 name[0xA];

View File

@@ -1,18 +1,13 @@
#ifndef GUARD_TEAM_INVENTORY_H
#define GUARD_TEAM_INVENTORY_H
struct subStruct_203B460
{
u8 unk0;
u8 unk1;
};
struct TeamInventory
{
struct ItemSlot teamItems[INVENTORY_SIZE];
u16 teamStorage[NUMBER_OF_ITEM_IDS];
struct subStruct_203B460 unk230[8]; // this is probably actually the same struct as ItemSlot_ALT (see sub_80919FC)
struct subStruct_203B460 unk250[4]; // TODO: idk if this is identical struct or not.. Ghidra says sizes are same
// same type (initialized by same function):
struct HeldItem unk230[8];
struct HeldItem unk250[4];
/* 0x260 */ s32 teamMoney;
/* 0x264 */ u32 teamSavings;
};