Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document poffin.c and poffin case struct #339

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions include/overlay082/struct_ov82_0223B164.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#ifndef POKEPLATINUM_STRUCT_OV82_0223B164_H
#define POKEPLATINUM_STRUCT_OV82_0223B164_H

#include "struct_decls/struct_0202AB28_decl.h"

#include "bag.h"
#include "game_options.h"
#include "journal.h"
#include "poffin.h"
#include "savedata.h"
#include "trainer_info.h"

typedef struct {
u8 padding_00[4];
int unk_04;
UnkStruct_0202AB28 *unk_08;
PoffinCase *unk_08;
SaveData *unk_0C;
TrainerInfo *unk_10;
Bag *unk_14;
Expand Down
4 changes: 2 additions & 2 deletions include/overlay083/ov83_0223F7F4.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef POKEPLATINUM_OV83_0223F7F4_H
#define POKEPLATINUM_OV83_0223F7F4_H

#include "struct_defs/struct_0202A93C.h"

#include "overlay083/struct_ov83_0223F820.h"
#include "overlay083/struct_ov83_0223F88C.h"
#include "overlay083/struct_ov83_0223F8AC.h"
Expand All @@ -14,6 +12,8 @@
#include "overlay083/struct_ov83_0223FDB0_sub1.h"
#include "overlay083/struct_ov83_0223FE50.h"

#include "poffin.h"

s32 ov83_0223F7F4(int param0, int param1, int param2, int param3, int param4, int param5);
void ov83_0223F820(UnkStruct_ov83_0223F820 *param0);
void ov83_0223F83C(UnkStruct_ov83_0223F820 *param0);
Expand Down
3 changes: 1 addition & 2 deletions include/overlay083/struct_ov83_0223FE50.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#ifndef POKEPLATINUM_STRUCT_OV83_0223FE50_H
#define POKEPLATINUM_STRUCT_OV83_0223FE50_H

#include "struct_defs/struct_0202A93C.h"

#include "overlay083/struct_ov83_0223D2E8.h"
#include "overlay083/struct_ov83_0223DB4C.h"
#include "overlay083/struct_ov83_0223DB4C_sub1.h"
#include "overlay083/struct_ov83_022401AC.h"

#include "poffin.h"
#include "trainer_info.h"

typedef struct {
Expand Down
56 changes: 38 additions & 18 deletions include/poffin.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
#ifndef POKEPLATINUM_POFFIN_H
#define POKEPLATINUM_POFFIN_H

#include "struct_decls/struct_0202AB28_decl.h"
#include "struct_defs/struct_0202A93C.h"

#include "savedata.h"

#define POFFIN_NONE 0xFFFF
#define MAX_POFFINS 100

typedef struct {
union {
struct {
u8 flavor;
u8 spiciness;
u8 dryness;
u8 sweetness;
u8 bitterness;
u8 sourness;
u8 val1_06;
u8 dummy;
};
u8 attributes[8];
};
} Poffin;

typedef struct PoffinCase {
Poffin slot[MAX_POFFINS];
} PoffinCase;

typedef enum {
POFFIN_ATTRIBUTEID_FLAVOR,
POFFIN_ATTRIBUTEID_SPICINESS,
Expand All @@ -17,25 +37,25 @@ typedef enum {
POFFIN_ATTRIBUTEID_NUM
} PoffinAttributeID;

int Poffin_sizeof(void);
BOOL sub_0202A914(Poffin *poffin);
void Poffin_clear(Poffin *poffin);
Poffin *Poffin_malloc(int heapID);
void Poffin_copy(Poffin *src, Poffin *dest);
int Poffin_SizeOf(void);
BOOL Poffin_HasValidFlavor(Poffin *poffin);
void Poffin_Clear(Poffin *poffin);
Poffin *Poffin_New(int heapID);
void Poffin_Copy(Poffin *src, Poffin *dest);
u8 Poffin_GetAttribute(Poffin *poffin, PoffinAttributeID attributeID);
int sub_0202A9E4(Poffin *poffin, u8 *param1, u8 param2, BOOL isFoul);
void Poffin_StoreAttributesToArray(Poffin *poffin, u8 *dest);
u8 Poffin_CalcLevel(Poffin *poffin);
UnkStruct_0202AB28 *Poffin_GetSavedataBlock(SaveData *savedata);
PoffinCase *Poffin_GetSavedataBlock(SaveData *savedata);
int Poffin_SaveSize(void);
void Poffin_Init(UnkStruct_0202AB28 *param0);
u16 sub_0202AB54(UnkStruct_0202AB28 *param0);
u16 sub_0202AB74(UnkStruct_0202AB28 *param0, Poffin *param1);
BOOL sub_0202AB98(UnkStruct_0202AB28 *param0, u16 param1);
void sub_0202ABD4(UnkStruct_0202AB28 *param0);
void sub_0202AC54(UnkStruct_0202AB28 *param0, u16 param1, Poffin *param2);
Poffin *sub_0202AC70(UnkStruct_0202AB28 *param0, u16 param1, int param2);
u16 sub_0202AC98(UnkStruct_0202AB28 *param0);
u16 sub_0202ACC0(UnkStruct_0202AB28 *param0);
void Poffin_Init(PoffinCase *poffinCase);
u16 Poffin_GetEmptyCaseSlot(PoffinCase *poffinCase);
u16 Poffin_AddToCase(PoffinCase *poffinCase, Poffin *poffin);
BOOL Poffin_ClearCaseSlot(PoffinCase *poffinCase, u16 slot);
void Poffin_CompactCase(PoffinCase *poffinCase);
void Poffin_CopyToCaseSlot(PoffinCase *poffinCase, u16 destSlot, Poffin *poffin);
Poffin *Poffin_AllocateForCaseSlot(PoffinCase *poffinCase, u16 destSlot, int heapID);
u16 Poffin_GetNumberOfFilledSlots(PoffinCase *poffinCase);
u16 Poffin_GetNumberOfEmptySlots(PoffinCase *poffinCase);

#endif // POKEPLATINUM_POFFIN_H
6 changes: 0 additions & 6 deletions include/struct_decls/struct_0202AB28_decl.h

This file was deleted.

20 changes: 0 additions & 20 deletions include/struct_defs/struct_0202A93C.h

This file was deleted.

10 changes: 0 additions & 10 deletions include/struct_defs/struct_0202AB28.h

This file was deleted.

4 changes: 2 additions & 2 deletions include/struct_defs/struct_0203D9B8.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef POKEPLATINUM_STRUCT_0203D9B8_H
#define POKEPLATINUM_STRUCT_0203D9B8_H

#include "struct_decls/struct_0202AB28_decl.h"
#include "struct_decls/struct_party_decl.h"
#include "struct_defs/struct_020989DC.h"

#include "bag.h"
#include "game_options.h"
#include "poffin.h"
#include "trainer_info.h"

typedef struct {
Expand All @@ -16,7 +16,7 @@ typedef struct {
u8 unk_03;
u16 unk_04;
u16 unk_06;
UnkStruct_0202AB28 *unk_08;
PoffinCase *unk_08;
TrainerInfo *unk_0C;
Party *unk_10;
Bag *unk_14;
Expand Down
3 changes: 1 addition & 2 deletions include/struct_defs/struct_02098DE8.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef POKEPLATINUM_STRUCT_02098DE8_H
#define POKEPLATINUM_STRUCT_02098DE8_H

#include "struct_defs/struct_0202A93C.h"

#include "poffin.h"
#include "pokemon.h"

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion include/unk_020989DC.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef POKEPLATINUM_UNK_020989DC_H
#define POKEPLATINUM_UNK_020989DC_H

#include "struct_defs/struct_0202A93C.h"
#include "struct_defs/struct_0203D9B8.h"

#include "enums.h"
#include "poffin.h"
#include "pokemon.h"
#include "savedata.h"

Expand Down
2 changes: 1 addition & 1 deletion src/overlay065/ov65_0222DCE0.c
Original file line number Diff line number Diff line change
Expand Up @@ -3797,7 +3797,7 @@ static u32 ov65_022319B8 (UnkStruct_ov65_0222EBE0 * param0)
return 3;
}

if (sub_0202AC98(Poffin_GetSavedataBlock(param0->unk_160)) >= 100) {
if (Poffin_GetNumberOfFilledSlots(Poffin_GetSavedataBlock(param0->unk_160)) >= MAX_POFFINS) {
return 2;
}

Expand Down
13 changes: 6 additions & 7 deletions src/overlay083/ov83_0223B5A0.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "struct_decls/struct_0202440C_decl.h"
#include "struct_decls/struct_0202B370_decl.h"
#include "struct_defs/struct_0202A93C.h"

#include "overlay004/ov4_021D0D80.h"
#include "overlay083/ov83_0223C958.h"
Expand Down Expand Up @@ -598,9 +597,9 @@ static int ov83_0223BCEC(UnkStruct_ov83_0223C344 *param0, UnkStruct_ov83_0223B78
break;
case 4:
if (ov83_0223D570(param1->unk_148C) == 0) {
v0 = Poffin_malloc(param1->unk_00);
v0 = Poffin_New(param1->unk_00);
ov83_0223FFD4(&param1->unk_34C, v0, &param1->unk_1494, param1->unk_1488, param1->unk_00);
v1 = ov83_0223D508(28, v0, Poffin_sizeof(), param1->unk_148C);
v1 = ov83_0223D508(28, v0, Poffin_SizeOf(), param1->unk_148C);
Heap_FreeToHeap(v0);

if (v1 == 1) {
Expand Down Expand Up @@ -713,7 +712,7 @@ static int ov83_0223BF74(UnkStruct_ov83_0223C344 *param0, UnkStruct_ov83_0223B78

if ((v0 == 1) || (v0 == 2)) {
if (v0 == 1) {
if (sub_0202AC98(param0->unk_10->unk_08) >= 100) {
if (Poffin_GetNumberOfFilledSlots(param0->unk_10->unk_08) >= MAX_POFFINS) {
ov83_0223EC8C(&param1->unk_6A0, 2);
(*param2) = 10;
param1->unk_1C = (30 * 5);
Expand Down Expand Up @@ -1058,7 +1057,7 @@ static void ov83_0223C82C(UnkStruct_ov83_0223C344 *param0, UnkStruct_ov83_0223B7
{
int v0;

param1->unk_1494.unk_100 = Poffin_malloc(param1->unk_00);
param1->unk_1494.unk_100 = Poffin_New(param1->unk_00);
param1->unk_1494.unk_144 = ov83_0223D570(param1->unk_148C);

for (v0 = 0; v0 < 4; v0++) {
Expand Down Expand Up @@ -1092,9 +1091,9 @@ static BOOL ov83_0223C8B0(UnkStruct_ov83_0223C344 *param0, Poffin *param1, int p
TVBroadcast *v4 = SaveData_TVBroadcast(param0->unk_10->unk_0C);

for (v0 = 0; v0 < param2; v0++) {
v1 = sub_0202AB74(param0->unk_10->unk_08, param1);
v1 = Poffin_AddToCase(param0->unk_10->unk_08, param1);

if (v1 == 0xFFFF) {
if (v1 == POFFIN_NONE) {
v3 = 0;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/overlay083/ov83_0223D144.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static const CommCmdTable Unk_ov83_02240390[] = {
{ ov83_0223D258, ov83_0223D4B8, NULL },
{ ov83_0223D2E8, ov83_0223D4BC, NULL },
{ ov83_0223D3D8, ov83_0223D4C0, NULL },
{ ov83_0223D3F8, Poffin_sizeof, NULL },
{ ov83_0223D3F8, Poffin_SizeOf, NULL },
{ ov83_0223D410, ov83_0223D4B0, NULL },
{ ov83_0223D430, ov83_0223D4B0, NULL },
{ ov83_0223D354, ov83_0223D4C4, NULL },
Expand Down
2 changes: 0 additions & 2 deletions src/overlay083/ov83_0223F7F4.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <nitro.h>
#include <string.h>

#include "struct_defs/struct_0202A93C.h"

#include "overlay083/struct_ov83_0223DB4C_sub1.h"
#include "overlay083/struct_ov83_0223F820.h"
#include "overlay083/struct_ov83_0223F88C.h"
Expand Down
2 changes: 1 addition & 1 deletion src/overlay084/ov84_0223F040.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ void ov84_02240328(UnkStruct_ov84_0223B5A0 *param0)
Strbuf_Free(v1);

v1 = MessageLoader_GetNewStrbuf(param0->unk_114, 109);
StringTemplate_SetNumber(param0->unk_118, 0, sub_0202AC98(Poffin_GetSavedataBlock(param0->unk_C4->unk_00)), 3, 1, 1);
StringTemplate_SetNumber(param0->unk_118, 0, Poffin_GetNumberOfFilledSlots(Poffin_GetSavedataBlock(param0->unk_C4->unk_00)), 3, 1, 1);
StringTemplate_Format(param0->unk_118, param0->unk_3F8, v1);
Strbuf_Free(v1);

Expand Down
Loading
Loading