Document Poffin Manager portion of Poffin Case App (#858)

This commit is contained in:
VicSevenT
2026-01-01 14:57:07 -06:00
committed by GitHub
parent 60dbc6ee43
commit 86bfb86eb3
58 changed files with 2590 additions and 2659 deletions

View File

@@ -461,9 +461,9 @@ TEXT_BANK_POKETCH_BERRY_SEARCHER
TEXT_BANK_DUMMY_0460
TEXT_BANK_POKETCH_LINK_SEARCHER
TEXT_BANK_UNK_0462
TEXT_BANK_UNK_0463
TEXT_BANK_POFFIN_CASE
TEXT_BANK_POFFIN_MAKING
TEXT_BANK_POFFIN_NAMES
TEXT_BANK_POFFIN_TYPES
TEXT_BANK_ROUTE_201
TEXT_BANK_ROUTE_202
TEXT_BANK_ROUTE_203

View File

@@ -0,0 +1,57 @@
#ifndef POKEPLATINUM_POFFIN_CASE_MAIN_H
#define POKEPLATINUM_POFFIN_CASE_MAIN_H
#include "struct_defs/pokemon.h"
#include "bag.h"
#include "enums.h"
#include "game_options.h"
#include "party.h"
#include "poffin.h"
#include "savedata.h"
#include "trainer_info.h"
typedef struct PoffinCaseAppItem {
u8 caseIndex;
u8 level;
u8 type;
u8 smoothness;
union {
struct {
u8 spiciness : 1;
u8 dryness : 1;
u8 sweetness : 1;
u8 bitterness : 1;
u8 sourness : 1;
u8 isListed : 1;
u8 deleted : 1;
u8 alwaysTrue : 1;
};
u8 flavors;
};
u8 index;
u8 next;
u8 prev;
} PoffinCaseAppItem;
typedef struct PoffinCaseAppData {
u8 poffinCount;
u8 selectedPoffin;
u8 poffinRemoved;
u8 flavorFilter;
u16 listPos;
u16 cursorPos;
PoffinCase *poffinCase;
TrainerInfo *trainerInfo;
Party *party;
Bag *bag;
Options *options;
PoffinCaseAppItem poffins[MAX_POFFINS];
} PoffinCaseAppData;
PoffinCaseAppData *PoffinCaseAppData_New(SaveData *saveData, int heapID);
void PoffinCaseAppData_Free(PoffinCaseAppData *appData);
UnkEnum_02098EAC sub_02098EAC(Poffin *param0, u8 param1);
void sub_02098EF8(Poffin *param0, Pokemon *param1);
#endif // POKEPLATINUM_POFFIN_CASE_MAIN_H

View File

@@ -0,0 +1,87 @@
#ifndef POKEPLATINUM_APPLICATIONS_POFFIN_CASE_MANAGER_H
#define POKEPLATINUM_APPLICATIONS_POFFIN_CASE_MANAGER_H
#include "constants/flavor.h"
#include "applications/poffin_case/main.h"
#include "bg_window.h"
#include "list_menu.h"
#include "menu.h"
#include "message.h"
#include "overlay_manager.h"
#include "poffin_sprite.h"
#include "poffin_types.h"
#include "sprite.h"
#include "sprite_system.h"
#include "string_template.h"
#define POFFIN_LIST_SENTINEL 0xFF
#define NUM_LIST_SPRITES 3
#define LIST_SPRITE_SELECT_BOX 0
#define LIST_SPRITE_UP_ARROW 1
#define LIST_SPRITE_DOWN_ARROW 2
#define NUM_WINDOWS 13
typedef struct PoffinManagerMessages {
StringTemplate *template;
String *string;
String *closeStr;
String *listItemStr;
String *smoothStr;
String *discardStr;
String *thrownOutStr;
String *headerStr;
String *flavorStrs[FLAVOR_MAX + 1];
String *flavorDescs[FLAVOR_MAX];
u8 textDelay;
u8 unused[3];
} PoffinManagerMessages;
typedef struct PoffinManager {
enum HeapID heapID;
int lifecycle;
int loadState;
int dummy;
BOOL givePoffin;
u16 buttonHeld;
u16 dummy2;
u16 state;
u8 selectedPoffin;
u8 flavorFilter;
u8 poffinCount;
u8 lastPoffin;
u8 firstPoffin;
u8 printerID;
PoffinCaseAppData *data;
BgConfig *bgConfig;
PoffinTypeList *poffinTypes;
MessageLoader *msgLoader;
PoffinManagerMessages messages;
u16 listPos;
u16 cursorPos;
ListMenuTemplate menuTemplate;
ListMenuTemplate actionMenuTemplate;
ListMenu *poffinMenu;
ListMenu *actionMenu;
StringList *poffinList;
StringList *actionList;
Menu *yesNoMenu;
u32 unused[4];
Window windows[NUM_WINDOWS];
SpriteSystem *spriteSys;
SpriteManager *spriteMan;
Sprite *listSprites[NUM_LIST_SPRITES];
Sprite *flavorSprites[FLAVOR_MAX];
Sprite *buttonSprites[FLAVOR_MAX + 1];
PoffinSpriteManager *poffinSpriteMan;
PoffinSprite *poffinSprite;
} PoffinManager;
BOOL PoffinManager_Init(ApplicationManager *appMan, int *unused);
BOOL PoffinManager_Main(ApplicationManager *appMan, int *unused);
BOOL PoffinManager_Exit(ApplicationManager *appMan, int *unused);
#endif // POKEPLATINUM_APPLICATIONS_POFFIN_CASE_MANAGER_H

View File

@@ -0,0 +1,23 @@
#ifndef POKEPLATINUM_APPLICATIONS_POFFIN_CASE_MENUS_H
#define POKEPLATINUM_APPLICATIONS_POFFIN_CASE_MENUS_H
#include "applications/poffin_case/manager.h"
#define BUTTON_ACTION_DESELECT 0
#define BUTTON_ACTION_SELECT 1
#define BUTTON_ACTION_RELEASE_SELECTED 2
#define BUTTON_ACTION_REPRESS_SELECTED 3
#define BUTTON_ACTION_SET_AS_ACTIVE 4
void PoffinManager_InitPoffinList(PoffinManager *app);
void PoffinManager_FreePoffinList(PoffinManager *app, BOOL clear);
void PoffinManager_UpdateFilterButton(PoffinManager *app, u8 poffinType, u8 buttonAction);
void PoffinManager_UpdatePoffinFilter(PoffinManager *app, u8 poffinType);
void PoffinManager_CreateActionMenu(PoffinManager *app);
void PoffinManager_FreeActionMenu(PoffinManager *app);
void PoffinManager_ShowDiscardQuestion(PoffinManager *app);
void PoffinManager_ShowThrownOutMessage(PoffinManager *app);
void PoffinManager_CreateYesNoMenu(PoffinManager *app);
void PoffinManager_PrintHeaderandButtons(PoffinManager *app);
#endif // POKEPLATINUM_APPLICATIONS_POFFIN_CASE_MENUS_H

View File

@@ -1,8 +1,8 @@
#ifndef POKEPLATINUM_OV79_021D3768_H
#define POKEPLATINUM_OV79_021D3768_H
#include "overlay079/struct_ov79_021D3820.h"
#include "overlay079/struct_ov79_021D38D0.h"
#include "applications/poffin_case/struct_ov79_021D3820.h"
#include "applications/poffin_case/struct_ov79_021D38D0.h"
void ov79_021D3768(UnkStruct_ov79_021D3820 *param0, UnkStruct_ov79_021D38D0 *param1, int heapID);
void ov79_021D3820(UnkStruct_ov79_021D3820 *param0);

View File

@@ -0,0 +1,11 @@
#ifndef POKEPLATINUM_APPLICATIONS_POFFIN_CASE_SPRITES_H
#define POKEPLATINUM_APPLICATIONS_POFFIN_CASE_SPRITES_H
#include "applications/poffin_case/manager.h"
void PoffinManager_InitSpriteSystem(PoffinManager *app);
void PoffinManager_FreeSpriteSystem(PoffinManager *app);
void PoffinManager_UpdateSprites(PoffinManager *app);
void PoffinCaseApp_UpdateListSprites(PoffinManager *app, BOOL actionMenuOpen);
#endif // POKEPLATINUM_APPLICATIONS_POFFIN_CASE_SPRITES_H

View File

@@ -46,8 +46,8 @@ enum HeapID {
HEAP_ID_41,
HEAP_ID_JOURNAL,
HEAP_ID_43,
HEAP_ID_44,
HEAP_ID_45,
HEAP_ID_POFFIN_CASE,
HEAP_ID_POFFIN_MANAGER,
HEAP_ID_46,
HEAP_ID_CHOOSE_STARTER_APP,
HEAP_ID_48,

View File

@@ -3,6 +3,6 @@
#include "overlay_manager.h"
extern const ApplicationManagerTemplate Unk_020F6890;
extern const ApplicationManagerTemplate gPoffinCaseAppTemplate;
#endif // POKEPLATINUM_CONST_020F6890_H

View File

@@ -1,10 +0,0 @@
#ifndef POKEPLATINUM_OV79_021D0D80_H
#define POKEPLATINUM_OV79_021D0D80_H
#include "overlay_manager.h"
int ov79_021D0D80(ApplicationManager *appMan, int *param1);
int ov79_021D0DC4(ApplicationManager *appMan, int *param1);
int ov79_021D0DDC(ApplicationManager *appMan, int *param1);
#endif // POKEPLATINUM_OV79_021D0D80_H

View File

@@ -1,17 +0,0 @@
#ifndef POKEPLATINUM_OV79_021D183C_H
#define POKEPLATINUM_OV79_021D183C_H
#include "overlay079/struct_ov79_021D0E1C_decl.h"
void ov79_021D196C(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D1AB8(UnkStruct_ov79_021D0E1C *param0, BOOL param1);
void ov79_021D1B24(UnkStruct_ov79_021D0E1C *param0, u8 param1, u8 param2);
void ov79_021D1C44(UnkStruct_ov79_021D0E1C *param0, u8 param1);
void ov79_021D1ED8(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D1F60(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D1FBC(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D2008(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D2054(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D2078(UnkStruct_ov79_021D0E1C *param0);
#endif // POKEPLATINUM_OV79_021D183C_H

View File

@@ -1,11 +0,0 @@
#ifndef POKEPLATINUM_OV79_021D20F4_H
#define POKEPLATINUM_OV79_021D20F4_H
#include "overlay079/struct_ov79_021D0E1C_decl.h"
void ov79_021D20F4(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D21CC(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D21F8(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D2214(UnkStruct_ov79_021D0E1C *param0, BOOL param1);
#endif // POKEPLATINUM_OV79_021D20F4_H

View File

@@ -1,64 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_OV79_021D0E1C_H
#define POKEPLATINUM_STRUCT_OV79_021D0E1C_H
#include <nnsys.h>
#include "struct_defs/struct_020158A8.h"
#include "struct_defs/struct_0203D9B8.h"
#include "struct_defs/struct_0209903C.h"
#include "struct_defs/struct_0209916C.h"
#include "overlay079/struct_ov79_021D0E1C_sub1.h"
#include "bg_window.h"
#include "list_menu.h"
#include "menu.h"
#include "message.h"
#include "sprite.h"
#include "sprite_system.h"
#include "string_list.h"
typedef struct UnkStruct_ov79_021D0E1C_t {
int heapID;
int unk_04;
int unk_08;
int unk_0C;
int unk_10;
u16 unk_14;
u16 unk_16;
u16 unk_18;
u8 unk_1A;
u8 unk_1B;
u8 unk_1C;
u8 unk_1D;
u8 unk_1E;
u8 unk_1F;
UnkStruct_0203D9B8 *unk_20;
BgConfig *unk_24;
UnkStruct_020158A8 *unk_28;
MessageLoader *unk_2C;
UnkStruct_ov79_021D0E1C_sub1 unk_30;
u16 unk_80;
u16 unk_82;
ListMenuTemplate unk_84;
ListMenuTemplate unk_A4;
ListMenu *unk_C4;
ListMenu *unk_C8;
StringList *unk_CC;
StringList *unk_D0;
Menu *unk_D4;
void *unk_D8;
void *unk_DC;
NNSG2dScreenData *unk_E0;
NNSG2dScreenData *unk_E4;
Window unk_E8[13];
SpriteSystem *unk_1B8;
SpriteManager *unk_1BC;
Sprite *unk_1C0[3];
Sprite *unk_1CC[5];
Sprite *unk_1E0[6];
UnkStruct_0209903C *unk_1F8;
UnkStruct_0209916C *unk_1FC;
} UnkStruct_ov79_021D0E1C;
#endif // POKEPLATINUM_STRUCT_OV79_021D0E1C_H

View File

@@ -1,6 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_OV79_021D0E1C_DECL_H
#define POKEPLATINUM_STRUCT_OV79_021D0E1C_DECL_H
typedef struct UnkStruct_ov79_021D0E1C_t UnkStruct_ov79_021D0E1C;
#endif // POKEPLATINUM_STRUCT_OV79_021D0E1C_DECL_H

View File

@@ -1,22 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_OV79_021D0E1C_SUB1_H
#define POKEPLATINUM_STRUCT_OV79_021D0E1C_SUB1_H
#include "string_gf.h"
#include "string_template.h"
typedef struct {
StringTemplate *unk_00;
String *unk_04;
String *unk_08;
String *unk_0C;
String *unk_10;
String *unk_14;
String *unk_18;
String *unk_1C;
String *unk_20[6];
String *unk_38[5];
u8 unk_4C;
u8 unk_4D[3];
} UnkStruct_ov79_021D0E1C_sub1;
#endif // POKEPLATINUM_STRUCT_OV79_021D0E1C_SUB1_H

View File

@@ -1,12 +1,11 @@
#ifndef POKEPLATINUM_STRUCT_OV83_0223F770_H
#define POKEPLATINUM_STRUCT_OV83_0223F770_H
#include "struct_defs/struct_0209903C.h"
#include "struct_defs/struct_0209916C.h"
#include "poffin_sprite.h"
typedef struct {
UnkStruct_0209903C *unk_00;
UnkStruct_0209916C *unk_04;
PoffinSpriteManager *unk_00;
PoffinSprite *unk_04;
} UnkStruct_ov83_0223F770;
#endif // POKEPLATINUM_STRUCT_OV83_0223F770_H

View File

@@ -6,42 +6,10 @@
#define POFFIN_NONE 0xFFFF
#define MAX_POFFINS 100
enum PoffinFlavors {
POFFIN_FLAVOR_SPICY = 0,
POFFIN_FLAVOR_SPICY_DRY,
POFFIN_FLAVOR_SPICY_SWEET,
POFFIN_FLAVOR_SPICY_BITTER,
POFFIN_FLAVOR_SPICY_SOUR,
POFFIN_FLAVOR_DRY_SPICY,
POFFIN_FLAVOR_DRY,
POFFIN_FLAVOR_DRY_SWEET,
POFFIN_FLAVOR_DRY_BITTER,
POFFIN_FLAVOR_DRY_SOUR,
POFFIN_FLAVOR_SWEET_SPICY,
POFFIN_FLAVOR_SWEET_DRY,
POFFIN_FLAVOR_SWEET,
POFFIN_FLAVOR_SWEET_BITTER,
POFFIN_FLAVOR_SWEET_SOUR,
POFFIN_FLAVOR_BITTER_SPICY,
POFFIN_FLAVOR_BITTER_DRY,
POFFIN_FLAVOR_BITTER_SWEET,
POFFIN_FLAVOR_BITTER,
POFFIN_FLAVOR_BITTER_SOUR,
POFFIN_FLAVOR_SOUR_SPICY,
POFFIN_FLAVOR_SOUR_DRY,
POFFIN_FLAVOR_SOUR_SWEET,
POFFIN_FLAVOR_SOUR_BITTER,
POFFIN_FLAVOR_SOUR,
POFFIN_FLAVOR_RICH,
POFFIN_FLAVOR_OVERRIPE,
POFFIN_FLAVOR_FOUL,
POFFIN_FLAVOR_MILD,
};
typedef struct {
union {
struct PoffinInner {
u8 flavor;
u8 type;
u8 spiciness;
u8 dryness;
u8 sweetness;
@@ -59,7 +27,7 @@ typedef struct PoffinCase {
} PoffinCase;
enum PoffinAttributeID {
POFFIN_ATTRIBUTEID_FLAVOR,
POFFIN_ATTRIBUTEID_TYPE,
POFFIN_ATTRIBUTEID_SPICINESS,
POFFIN_ATTRIBUTEID_DRYNESS,
POFFIN_ATTRIBUTEID_SWEETNESS,
@@ -85,7 +53,7 @@ u16 PoffinCase_GetEmptySlot(PoffinCase *poffinCase);
u16 PoffinCase_AddPoffin(PoffinCase *poffinCase, Poffin *poffin);
BOOL PoffinCase_ClearSlot(PoffinCase *poffinCase, u16 slot);
void PoffinCase_Compact(PoffinCase *poffinCase);
void PoffinCase_CopyPoffinToSlot(PoffinCase *poffinCase, u16 destSlot, Poffin *poffin);
void PoffinCase_CopyPoffinFromSlot(PoffinCase *poffinCase, u16 destSlot, Poffin *poffin);
Poffin *PoffinCase_AllocateForSlot(PoffinCase *poffinCase, u16 destSlot, int heapID);
u16 PoffinCase_CountFilledSlots(PoffinCase *poffinCase);
u16 PoffinCase_CountEmptySlots(PoffinCase *poffinCase);

42
include/poffin_sprite.h Normal file
View File

@@ -0,0 +1,42 @@
#ifndef POKEPLATINUM_POFFIN_SPRITE_H
#define POKEPLATINUM_POFFIN_SPRITE_H
#include "poffin_types.h"
#include "sprite.h"
#include "sprite_resource.h"
#include "sprite_util.h"
typedef struct PoffinSpriteItem {
u8 inUse;
u8 type;
u16 index;
} PoffinSpriteItem;
typedef struct PoffinSpriteManager {
enum HeapID heapID;
int transferType;
u16 unused;
u16 numPalettes;
u16 maxSprites;
u16 vramType;
SpriteList *spriteList;
G2dRenderer renderer;
u32 unused2;
SpriteResourceCollection *ownedResources[4];
SpriteResourceList *unownedResources[4];
PoffinSpriteItem *poffinList;
} PoffinSpriteManager;
typedef struct PoffinSprite {
u16 index;
ManagedSprite *sprite;
} PoffinSprite;
PoffinSpriteManager *PoffinSpriteManager_New(enum HeapID heapID, u16 maxSprites, u16 numPalettes, u16 vramType, int transferType);
void PoffinSpriteManager_Free(PoffinSpriteManager *spriteMan);
void PoffinSpriteManager_DrawSprites(PoffinSpriteManager *spriteMan);
PoffinSprite *PoffinSprite_New(PoffinSpriteManager *spriteMan, enum PoffinType type, u16 x, u16 y, u16 z, u8 bgPriority, u8 priority, BOOL onSubScreen);
void PoffinSprite_UpdateType(PoffinSpriteManager *spriteMan, PoffinSprite *sprite, enum PoffinType poffinType);
void PoffinSprite_Free(PoffinSpriteManager *spriteMan, PoffinSprite *poffinSprite);
#endif // POKEPLATINUM_POFFIN_SPRITE_H

52
include/poffin_types.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef POKEPLATINUM_POFFIN_TYPES_H
#define POKEPLATINUM_POFFIN_TYPES_H
#include "constants/heap.h"
#include "message.h"
#include "string_gf.h"
#define NUM_POFFIN_TYPES 29
enum PoffinType {
POFFIN_TYPE_SPICY = 0,
POFFIN_TYPE_SPICY_DRY,
POFFIN_TYPE_SPICY_SWEET,
POFFIN_TYPE_SPICY_BITTER,
POFFIN_TYPE_SPICY_SOUR,
POFFIN_TYPE_DRY_SPICY,
POFFIN_TYPE_DRY,
POFFIN_TYPE_DRY_SWEET,
POFFIN_TYPE_DRY_BITTER,
POFFIN_TYPE_DRY_SOUR,
POFFIN_TYPE_SWEET_SPICY,
POFFIN_TYPE_SWEET_DRY,
POFFIN_TYPE_SWEET,
POFFIN_TYPE_SWEET_BITTER,
POFFIN_TYPE_SWEET_SOUR,
POFFIN_TYPE_BITTER_SPICY,
POFFIN_TYPE_BITTER_DRY,
POFFIN_TYPE_BITTER_SWEET,
POFFIN_TYPE_BITTER,
POFFIN_TYPE_BITTER_SOUR,
POFFIN_TYPE_SOUR_SPICY,
POFFIN_TYPE_SOUR_DRY,
POFFIN_TYPE_SOUR_SWEET,
POFFIN_TYPE_SOUR_BITTER,
POFFIN_TYPE_SOUR,
POFFIN_TYPE_RICH,
POFFIN_TYPE_OVERRIPE,
POFFIN_TYPE_FOUL,
POFFIN_TYPE_MILD,
};
typedef struct PoffinTypeList {
MessageLoader *msgLoader;
String *names[NUM_POFFIN_TYPES];
} PoffinTypeList;
PoffinTypeList *PoffinTypeList_New(enum HeapID heapID);
void PoffinTypeList_Free(PoffinTypeList *types);
const String *PoffinTypeList_GetString(PoffinTypeList *poffinNames, enum PoffinType type);
#endif // POKEPLATINUM_POFFIN_TYPES_H

View File

@@ -1,12 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_020158A8_H
#define POKEPLATINUM_STRUCT_020158A8_H
#include "message.h"
#include "string_gf.h"
typedef struct {
MessageLoader *unk_00;
String *unk_04[29];
} UnkStruct_020158A8;
#endif // POKEPLATINUM_STRUCT_020158A8_H

View File

@@ -1,27 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_0203D9B8_H
#define POKEPLATINUM_STRUCT_0203D9B8_H
#include "struct_defs/struct_020989DC.h"
#include "bag.h"
#include "game_options.h"
#include "party.h"
#include "poffin.h"
#include "trainer_info.h"
typedef struct {
u8 unk_00;
u8 unk_01;
u8 unk_02;
u8 unk_03;
u16 unk_04;
u16 unk_06;
PoffinCase *poffinCase;
TrainerInfo *unk_0C;
Party *unk_10;
Bag *unk_14;
Options *options;
UnkStruct_020989DC unk_1C[100];
} UnkStruct_0203D9B8;
#endif // POKEPLATINUM_STRUCT_0203D9B8_H

View File

@@ -1,27 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_020989DC_H
#define POKEPLATINUM_STRUCT_020989DC_H
typedef struct {
u8 unk_00;
u8 unk_01;
u8 unk_02;
u8 unk_03;
union {
struct {
u8 val1_01 : 1;
u8 unk_04_val1_1 : 1;
u8 sweetness : 1;
u8 bitterness : 1;
u8 sourness : 1;
u8 unk_04_val1_5 : 1;
u8 unk_04_val1_6 : 1;
u8 unk_04_val1_7 : 1;
};
u8 unk_20_val2;
};
u8 unk_05;
u8 unk_06;
u8 unk_07;
} UnkStruct_020989DC;
#endif // POKEPLATINUM_STRUCT_020989DC_H

View File

@@ -1,25 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_0209903C_H
#define POKEPLATINUM_STRUCT_0209903C_H
#include "struct_defs/struct_0209903C_sub1.h"
#include "sprite.h"
#include "sprite_resource.h"
#include "sprite_util.h"
typedef struct {
int heapID;
int unk_04;
u16 unk_08;
u16 unk_0A;
u16 unk_0C;
u16 unk_0E;
SpriteList *unk_10;
G2dRenderer unk_14;
SpriteResourcesHeaderList *unk_1A0;
SpriteResourceCollection *unk_1A4[4];
SpriteResourceList *unk_1B4[4];
UnkStruct_0209903C_sub1 *unk_1C4;
} UnkStruct_0209903C;
#endif // POKEPLATINUM_STRUCT_0209903C_H

View File

@@ -1,10 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_0209903C_SUB1_H
#define POKEPLATINUM_STRUCT_0209903C_SUB1_H
typedef struct {
u8 unk_00;
u8 unk_01;
u16 unk_02;
} UnkStruct_0209903C_sub1;
#endif // POKEPLATINUM_STRUCT_0209903C_SUB1_H

View File

@@ -1,11 +0,0 @@
#ifndef POKEPLATINUM_STRUCT_0209916C_H
#define POKEPLATINUM_STRUCT_0209916C_H
#include "sprite_system.h"
typedef struct {
u16 unk_00;
ManagedSprite *unk_04;
} UnkStruct_0209916C;
#endif // POKEPLATINUM_STRUCT_0209916C_H

View File

@@ -1,12 +0,0 @@
#ifndef POKEPLATINUM_UNK_020158A8_H
#define POKEPLATINUM_UNK_020158A8_H
#include "struct_defs/struct_020158A8.h"
#include "string_gf.h"
UnkStruct_020158A8 *sub_020158A8(int heapID);
void sub_020158F4(UnkStruct_020158A8 *param0);
const String *sub_02015918(UnkStruct_020158A8 *param0, int param1);
#endif // POKEPLATINUM_UNK_020158A8_H

View File

@@ -7,7 +7,6 @@
#include "struct_decls/struct_0209747C_decl.h"
#include "struct_defs/choose_starter_data.h"
#include "struct_defs/struct_0203D9B8.h"
#include "struct_defs/struct_0203E234.h"
#include "struct_defs/struct_0203E274.h"
#include "struct_defs/struct_0203E348.h"
@@ -16,6 +15,7 @@
#include "applications/naming_screen.h"
#include "applications/party_menu/defs.h"
#include "applications/pc_boxes/pokemon_storage_session.h"
#include "applications/poffin_case/main.h"
#include "applications/pokemon_summary_screen/main.h"
#include "applications/town_map/main.h"
#include "field/field_system_decl.h"
@@ -64,7 +64,7 @@ void *FieldSystem_OpenOptionsMenu(FieldSystem *fieldSystem);
UnkStruct_02097728 *sub_0203D920(FieldSystem *fieldSystem, int param1, u8 param2, u8 mailType, int unusedHeapID);
UnkStruct_02097728 *sub_0203D94C(FieldSystem *fieldSystem, int param1, u8 param2, int heapID);
UnkStruct_02097728 *sub_0203D984(FieldSystem *fieldSystem, Pokemon *param1, int heapID);
UnkStruct_0203D9B8 *sub_0203D9B8(FieldSystem *fieldSystem, int heapID);
PoffinCaseAppData *FieldSystem_LaunchPoffinCaseApp(FieldSystem *fieldSystem, int heapID);
void sub_0203D9D8(FieldSystem *fieldSystem, UnkStruct_ov90_021D0D80 *param1);
void sub_0203DAC0(FieldTask *param0, u16 *param1, SaveData *saveData, u16 param3, u16 param4);
BOOL sub_0203DB10(FieldSystem *fieldSystem, void *param1);

View File

@@ -1,16 +0,0 @@
#ifndef POKEPLATINUM_UNK_020989DC_H
#define POKEPLATINUM_UNK_020989DC_H
#include "struct_defs/struct_0203D9B8.h"
#include "enums.h"
#include "poffin.h"
#include "pokemon.h"
#include "savedata.h"
UnkStruct_0203D9B8 *sub_020989DC(SaveData *saveData, int heapID);
void sub_02098AF0(UnkStruct_0203D9B8 *param0);
UnkEnum_02098EAC sub_02098EAC(Poffin *param0, u8 param1);
void sub_02098EF8(Poffin *param0, Pokemon *param1);
#endif // POKEPLATINUM_UNK_020989DC_H

View File

@@ -1,14 +0,0 @@
#ifndef POKEPLATINUM_UNK_02098FFC_H
#define POKEPLATINUM_UNK_02098FFC_H
#include "struct_defs/struct_0209903C.h"
#include "struct_defs/struct_0209916C.h"
UnkStruct_0209903C *sub_02098FFC(int heapID, u16 param1, u16 param2, u16 param3, int param4);
void sub_0209903C(UnkStruct_0209903C *param0);
void sub_02099160(UnkStruct_0209903C *param0);
UnkStruct_0209916C *sub_0209916C(UnkStruct_0209903C *param0, int param1, u16 param2, u16 param3, u16 param4, u8 param5, u8 param6, int param7);
void sub_0209933C(UnkStruct_0209903C *param0, UnkStruct_0209916C *param1, int param2);
void sub_02099370(UnkStruct_0209903C *param0, UnkStruct_0209916C *param1);
#endif // POKEPLATINUM_UNK_02098FFC_H

View File

@@ -60,7 +60,7 @@ Static main
Object main.nef.p/src_unk_02014D38.c.o
Object main.nef.p/src_software_sprite.c.o
Object main.nef.p/src_unk_0201567C.c.o
Object main.nef.p/src_unk_020158A8.c.o
Object main.nef.p/src_poffin_types.c.o
Object main.nef.p/src_unk_02015920.c.o
Object main.nef.p/src_pokemon_anim.c.o
Object main.nef.p/src_unk_02017038.c.o
@@ -344,8 +344,8 @@ Static main
Object main.nef.p/src_pokedex_heightweight.c.o
Object main.nef.p/src_pokedex_data_index.c.o
Object main.nef.p/src_rowan_intro_app_template.c.o
Object main.nef.p/src_unk_020989DC.c.o
Object main.nef.p/src_unk_02098FFC.c.o
Object main.nef.p/src_applications_poffin_case_main.c.o
Object main.nef.p/src_poffin_sprite.c.o
Object main.nef.p/src_unk_02099500.c.o
Object main.nef.p/src_unk_02099550.c.o
Object main.nef.p/src_unk_02099604.c.o
@@ -1302,14 +1302,14 @@ Overlay choose_starter
Object main.nef.p/src_choose_starter_choose_starter_app.c.o
}
Overlay overlay79
Overlay poffin_case
{
After main
Object main.nef.p/src_overlay079_ov79_021D0D80.c.o
Object main.nef.p/src_overlay079_ov79_021D183C.c.o
Object main.nef.p/src_overlay079_ov79_021D20F4.c.o
Object main.nef.p/src_overlay079_ov79_021D2268.c.o
Object main.nef.p/src_overlay079_ov79_021D3768.c.o
Object main.nef.p/src_applications_poffin_case_manager.c.o
Object main.nef.p/src_applications_poffin_case_menus.c.o
Object main.nef.p/src_applications_poffin_case_sprites.c.o
Object main.nef.p/src_applications_poffin_case_ov79_021D2268.c.o
Object main.nef.p/src_applications_poffin_case_ov79_021D3768.c.o
}
Overlay town_map

View File

@@ -78,7 +78,7 @@ deecf01a5608b25883804ef30c9d4c3d0c904ee5 *rowan_intro.sbin
13777fa8b44e026c4eb960cce2309451c4594726 *overlay76.sbin
d7a304050d0049809b21cf75937e4d14aaf858c5 *game_opening.sbin
8571cf57764db093c9ce385586894659297b783e *choose_starter.sbin
b8c85f32459d20b3a6cfde5a1e349215dd0157a0 *overlay79.sbin
b8c85f32459d20b3a6cfde5a1e349215dd0157a0 *poffin_case.sbin
0ba83af5f2cafb311dbc552d77cb1b6b4f45d34e *town_map.sbin
1982ed52ba9469dd625dc5951277fd1c001b26af *journal_display.sbin
429a576c3e5a24f25167051957b22f194d2af781 *overlay82.sbin

View File

@@ -2,101 +2,101 @@
"key": 9471,
"messages": [
{
"id": "pl_msg_00000463_00000",
"id": "PoffinCase_Text_PoffinCase",
"en_US": "POFFIN CASE"
},
{
"id": "pl_msg_00000463_00001",
"id": "PoffinCase_Text_Give",
"en_US": "GIVE"
},
{
"id": "pl_msg_00000463_00002",
"id": "PoffinCase_Text_Trash",
"en_US": "TRASH"
},
{
"id": "pl_msg_00000463_00003",
"id": "PoffinCase_Text_Back",
"en_US": "BACK"
},
{
"id": "pl_msg_00000463_00004",
"id": "PoffinCase_Text_Smooth",
"en_US": "SMOOTH / {STRVAR_1 51, 0, 0}"
},
{
"id": "pl_msg_00000463_00005",
"id": "PoffinCase_Text_Dummy",
"garbage": 8
},
{
"id": "pl_msg_00000463_00006",
"id": "PoffinCase_Text_Close",
"en_US": "CLOSE"
},
{
"id": "pl_msg_00000463_00007",
"id": "PoffinCase_Text_Discard",
"en_US": [
"Discard this\n",
"{STRVAR_1 9, 0, 0}?"
]
},
{
"id": "pl_msg_00000463_00008",
"id": "PoffinCase_Text_ThrownOut",
"en_US": [
"The {STRVAR_1 9, 0, 0} was\n",
"thrown out."
]
},
{
"id": "pl_msg_00000463_00009",
"id": "PoffinCase_Text_Yes",
"en_US": "YES"
},
{
"id": "pl_msg_00000463_00010",
"id": "PoffinCase_Text_No",
"en_US": "NO"
},
{
"id": "pl_msg_00000463_00011",
"id": "PoffinCase_Text_Spicy",
"en_US": "SPICY"
},
{
"id": "pl_msg_00000463_00012",
"id": "PoffinCase_Text_Dry",
"en_US": "DRY"
},
{
"id": "pl_msg_00000463_00013",
"id": "PoffinCase_Text_Sweet",
"en_US": "SWEET"
},
{
"id": "pl_msg_00000463_00014",
"id": "PoffinCase_Text_Bitter",
"en_US": "BITTER"
},
{
"id": "pl_msg_00000463_00015",
"id": "PoffinCase_Text_Sour",
"en_US": "SOUR"
},
{
"id": "pl_msg_00000463_00016",
"id": "PoffinCase_Text_All",
"en_US": "ALL"
},
{
"id": "pl_msg_00000463_00017",
"id": "PoffinCase_Text_RaiseCoolness",
"en_US": "Raises coolness."
},
{
"id": "pl_msg_00000463_00018",
"id": "PoffinCase_Text_RaiseBeauty",
"en_US": "Raises beauty."
},
{
"id": "pl_msg_00000463_00019",
"id": "PoffinCase_Text_RaiseCuteness",
"en_US": "Raises cuteness."
},
{
"id": "pl_msg_00000463_00020",
"id": "PoffinCase_Text_RaiseSmartness",
"en_US": "Raises smartness."
},
{
"id": "pl_msg_00000463_00021",
"id": "PoffinCase_Text_RaiseToughness",
"en_US": "Raises toughness."
},
{
"id": "pl_msg_00000463_00022",
"id": "PoffinCase_Text_ListItem",
"en_US": "{STRVAR_1 9, 0, 0}{CURSOR_X 138}Lv. {STRVAR_1 51, 1, 0}"
}
]

View File

@@ -0,0 +1,523 @@
#include "applications/poffin_case/main.h"
#include <nitro.h>
#include "generated/natures.h"
#include "struct_defs/struct_02098DE8.h"
#include "applications/party_menu/defs.h"
#include "applications/party_menu/main.h"
#include "applications/poffin_case/manager.h"
#include "applications/poffin_case/ov79_021D2268.h"
#include "applications/pokemon_summary_screen/main.h"
#include "bag.h"
#include "enums.h"
#include "game_options.h"
#include "heap.h"
#include "overlay_manager.h"
#include "party.h"
#include "poffin.h"
#include "pokemon.h"
#include "save_player.h"
#include "savedata.h"
#include "string_template.h"
#include "constdata/const_020F410C.h"
FS_EXTERN_OVERLAY(poffin_case);
// clang-format off
static const u8 sFlavorPreferences[][2] = {
[NATURE_HARDY] = { FLAVOR_MAX, FLAVOR_MAX },
[NATURE_LONELY] = { FLAVOR_SPICY, FLAVOR_SOUR },
[NATURE_BRAVE] = { FLAVOR_SPICY, FLAVOR_SWEET },
[NATURE_ADAMANT] = { FLAVOR_SPICY, FLAVOR_DRY },
[NATURE_NAUGHTY] = { FLAVOR_SPICY, FLAVOR_BITTER },
[NATURE_BOLD] = { FLAVOR_SOUR, FLAVOR_SPICY },
[NATURE_DOCILE] = { FLAVOR_MAX, FLAVOR_MAX },
[NATURE_RELAXED] = { FLAVOR_SOUR, FLAVOR_SWEET },
[NATURE_IMPISH] = { FLAVOR_SOUR, FLAVOR_DRY },
[NATURE_LAX] = { FLAVOR_SOUR, FLAVOR_BITTER },
[NATURE_TIMID] = { FLAVOR_SWEET, FLAVOR_SPICY },
[NATURE_HASTY] = { FLAVOR_SWEET, FLAVOR_SOUR },
[NATURE_SERIOUS] = { FLAVOR_MAX, FLAVOR_MAX },
[NATURE_JOLLY] = { FLAVOR_SWEET, FLAVOR_DRY },
[NATURE_NAIVE] = { FLAVOR_SWEET, FLAVOR_BITTER },
[NATURE_MODEST] = { FLAVOR_DRY, FLAVOR_SPICY },
[NATURE_MILD] = { FLAVOR_DRY, FLAVOR_SOUR },
[NATURE_QUIET] = { FLAVOR_DRY, FLAVOR_SWEET },
[NATURE_BASHFUL] = { FLAVOR_MAX, FLAVOR_MAX },
[NATURE_RASH] = { FLAVOR_DRY, FLAVOR_BITTER },
[NATURE_CALM] = { FLAVOR_BITTER, FLAVOR_SPICY },
[NATURE_GENTLE] = { FLAVOR_BITTER, FLAVOR_SOUR },
[NATURE_SASSY] = { FLAVOR_BITTER, FLAVOR_SWEET },
[NATURE_CAREFUL] = { FLAVOR_BITTER, FLAVOR_DRY },
[NATURE_QUIRKY] = { FLAVOR_MAX, FLAVOR_MAX }
};
// clang-format on
enum PoffinCaseAppState {
STATE_INIT_POFFIN_MANAGER = 0,
STATE_INIT_PARTY_MENU,
STATE_INIT_POKEMON_SUMMARY,
STATE_OPEN_SUMMARY_BEFORE_GIVING,
STATE_INIT_GIVING_CUTSCENE,
STATE_PLAY_GIVING_CUTSCENE,
STATE_INIT_SUMMARY_AFTER_GIVING,
STATE_OPEN_SUMMARY_AFTER_GIVING,
STATE_EXIT,
};
typedef struct {
enum HeapID heapID;
int unused;
u8 monIndex;
u16 unused2;
PoffinCaseAppData *data;
void *subAppData;
ApplicationManager *subApp;
} PoffinCaseApp;
static int PoffinCaseApp_Init(ApplicationManager *appMan, int *state);
static int PoffinCaseApp_Main(ApplicationManager *appMan, int *state);
static int PoffinCaseApp_Exit(ApplicationManager *appMan, int *state);
static void RemoveDeletedPoffins(PoffinCaseApp *app);
static int State_InitPoffinManager(PoffinCaseApp *app);
static int State_InitPartyMenu(PoffinCaseApp *app);
static int State_InitPokemonSummaryBeforeGiving(PoffinCaseApp *app);
static int State_OpenSummaryBeforeGiving(PoffinCaseApp *app);
static int State_InitPoffinGivingCutscene(PoffinCaseApp *app);
static int State_PlayPoffinGivingCutscene(PoffinCaseApp *app);
static int State_InitSummaryAfterGiving(PoffinCaseApp *app);
static int State_OpenSummaryAfterGiving(PoffinCaseApp *app);
const ApplicationManagerTemplate gPoffinCaseAppTemplate = {
PoffinCaseApp_Init,
PoffinCaseApp_Main,
PoffinCaseApp_Exit,
FS_OVERLAY_ID_NONE
};
PoffinCaseAppData *PoffinCaseAppData_New(SaveData *saveData, int heapID)
{
StringTemplate *unused;
u8 count = 0, j = 0;
PoffinCaseAppData *appData = Heap_Alloc(heapID, sizeof(PoffinCaseAppData));
MI_CpuClear8(appData, sizeof(PoffinCaseAppData));
appData->poffinCase = SaveData_GetPoffinCase(saveData);
appData->trainerInfo = SaveData_GetTrainerInfo(saveData);
appData->party = SaveData_GetParty(saveData);
appData->bag = SaveData_GetBag(saveData);
appData->options = SaveData_GetOptions(saveData);
Poffin *poffin = Poffin_New(heapID);
unused = StringTemplate_New(1, 32, heapID);
for (u8 i = 0; i < MAX_POFFINS; i++) {
PoffinCase_CopyPoffinFromSlot(appData->poffinCase, i, poffin);
if (!Poffin_HasValidFlavor(poffin)) {
continue;
}
u8 poffinAttributes[7];
Poffin_StoreAttributesToArray(poffin, poffinAttributes);
PoffinCaseAppItem *caseItem = &appData->poffins[count];
caseItem->caseIndex = i;
caseItem->level = Poffin_CalcLevel(poffin);
caseItem->type = poffinAttributes[POFFIN_ATTRIBUTEID_TYPE];
caseItem->smoothness = poffinAttributes[POFFIN_ATTRIBUTEID_SMOOTHNESS];
u8 poffinTypeBitMask = 1;
for (j = 0; j < FLAVOR_MAX; j++) {
if (poffinAttributes[j + 1]) {
caseItem->flavors |= poffinTypeBitMask;
}
poffinTypeBitMask <<= 1;
}
caseItem->alwaysTrue = caseItem->isListed = TRUE;
caseItem->index = count++;
caseItem->prev = caseItem->next = 0xFF;
}
StringTemplate_Free(unused);
Heap_Free(poffin);
appData->poffinCount = count;
appData->flavorFilter = FLAVOR_MAX;
return appData;
}
void PoffinCaseAppData_Free(PoffinCaseAppData *appData)
{
Heap_Free(appData);
}
static BOOL RunSubApplication(ApplicationManager **appManPtr)
{
if (*appManPtr) {
if (ApplicationManager_Exec(*appManPtr)) {
ApplicationManager_Free(*appManPtr);
*appManPtr = NULL;
return TRUE;
}
}
return FALSE;
}
static BOOL PoffinCaseApp_Init(ApplicationManager *appMan, int *state)
{
void *appData = ApplicationManager_Args(appMan);
Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_POFFIN_CASE, 0x1000);
PoffinCaseApp *app = ApplicationManager_NewData(appMan, sizeof(PoffinCaseApp), HEAP_ID_POFFIN_CASE);
MI_CpuClear8(app, sizeof(PoffinCaseApp));
app->heapID = HEAP_ID_POFFIN_CASE;
app->data = appData;
return TRUE;
}
static BOOL PoffinCaseApp_Main(ApplicationManager *appMan, int *state)
{
PoffinCaseApp *poffinAppMan = ApplicationManager_Data(appMan);
switch (*state) {
case STATE_INIT_POFFIN_MANAGER:
*state = State_InitPoffinManager(poffinAppMan);
break;
case STATE_INIT_PARTY_MENU:
*state = State_InitPartyMenu(poffinAppMan);
break;
case STATE_INIT_POKEMON_SUMMARY:
*state = State_InitPokemonSummaryBeforeGiving(poffinAppMan);
break;
case STATE_OPEN_SUMMARY_BEFORE_GIVING:
*state = State_OpenSummaryBeforeGiving(poffinAppMan);
break;
case STATE_INIT_GIVING_CUTSCENE:
*state = State_InitPoffinGivingCutscene(poffinAppMan);
break;
case STATE_PLAY_GIVING_CUTSCENE:
*state = State_PlayPoffinGivingCutscene(poffinAppMan);
break;
case STATE_INIT_SUMMARY_AFTER_GIVING:
*state = State_InitSummaryAfterGiving(poffinAppMan);
break;
case STATE_OPEN_SUMMARY_AFTER_GIVING:
*state = State_OpenSummaryAfterGiving(poffinAppMan);
break;
case STATE_EXIT:
return TRUE;
}
return FALSE;
}
static BOOL PoffinCaseApp_Exit(ApplicationManager *appMan, int *state)
{
PoffinCaseApp *poffinAppMan = ApplicationManager_Data(appMan);
RemoveDeletedPoffins(poffinAppMan);
ApplicationManager_FreeData(appMan);
Heap_Destroy(poffinAppMan->heapID);
return TRUE;
}
static void RemoveDeletedPoffins(PoffinCaseApp *app)
{
u8 deletionsOccurred = FALSE;
for (u8 i = 0; i < app->data->poffinCount; i++) {
PoffinCaseAppItem *poffin = &app->data->poffins[i];
if (poffin->deleted) {
PoffinCase_ClearSlot(app->data->poffinCase, poffin->caseIndex);
deletionsOccurred = TRUE;
}
}
if (!deletionsOccurred) {
return;
}
PoffinCase_Compact(app->data->poffinCase);
}
static int State_InitPoffinManager(PoffinCaseApp *app)
{
FS_EXTERN_OVERLAY(poffin_case);
static const ApplicationManagerTemplate poffinManagerTemplate = {
PoffinManager_Init,
PoffinManager_Main,
PoffinManager_Exit,
FS_OVERLAY_ID(poffin_case),
};
app->subApp = ApplicationManager_New(&poffinManagerTemplate, app->data, app->heapID);
return STATE_INIT_PARTY_MENU;
}
static int State_InitPartyMenu(PoffinCaseApp *app)
{
if (!RunSubApplication(&app->subApp)) {
return STATE_INIT_PARTY_MENU;
}
if (!app->data->poffinRemoved) {
return STATE_EXIT;
}
app->data->poffinRemoved = FALSE;
PartyMenu *partyMenu = Heap_Alloc(app->heapID, sizeof(PartyMenu));
MI_CpuClear8(partyMenu, sizeof(PartyMenu));
partyMenu->party = app->data->party;
partyMenu->bag = app->data->bag;
partyMenu->type = PARTY_MENU_TYPE_BASIC;
partyMenu->mode = PARTY_MENU_MODE_FEED_POFFIN;
partyMenu->options = app->data->options;
app->subApp = ApplicationManager_New(&gPokemonPartyAppTemplate, partyMenu, app->heapID);
app->subAppData = partyMenu;
return STATE_INIT_POKEMON_SUMMARY;
}
static int State_InitPokemonSummaryBeforeGiving(PoffinCaseApp *app)
{
static const u8 summaryPages[] = {
SUMMARY_PAGE_CONDITION, SUMMARY_PAGE_EXIT, SUMMARY_PAGE_MAX
};
if (!RunSubApplication(&app->subApp)) {
return STATE_INIT_POKEMON_SUMMARY;
}
PartyMenu *partyMenu = app->subAppData;
u8 monIndex = partyMenu->selectedMonSlot;
app->monIndex = monIndex;
Heap_Free(app->subAppData);
if (monIndex == 7) {
return STATE_INIT_POFFIN_MANAGER;
}
PokemonSummary *monSummary = Heap_Alloc(app->heapID, sizeof(PokemonSummary));
monSummary->monData = app->data->party;
monSummary->options = app->data->options;
monSummary->dataType = SUMMARY_DATA_PARTY_MON;
monSummary->monIndex = monIndex;
monSummary->monMax = Party_GetCurrentCount(monSummary->monData);
monSummary->move = 0;
monSummary->mode = SUMMARY_MODE_FEED_POFFIN;
monSummary->showContest = TRUE;
monSummary->chatotCry = NULL;
PokemonSummaryScreen_FlagVisiblePages(monSummary, summaryPages);
PokemonSummaryScreen_SetPlayerProfile(monSummary, app->data->trainerInfo);
app->subApp = ApplicationManager_New(&gPokemonSummaryScreenApp, partyMenu, app->heapID);
app->subAppData = monSummary;
return STATE_OPEN_SUMMARY_BEFORE_GIVING;
}
static int State_OpenSummaryBeforeGiving(PoffinCaseApp *app)
{
if (!RunSubApplication(&app->subApp)) {
return STATE_OPEN_SUMMARY_BEFORE_GIVING;
}
PokemonSummary *monSummary = app->subAppData;
u8 returnMode = monSummary->returnMode;
app->monIndex = monSummary->monIndex;
Heap_Free(app->subAppData);
if (returnMode == SUMMARY_RETURN_CANCEL) {
return STATE_INIT_POFFIN_MANAGER;
}
app->data->poffins[app->data->selectedPoffin].deleted = TRUE;
app->data->poffinRemoved = TRUE;
return STATE_INIT_GIVING_CUTSCENE;
}
static int State_InitPoffinGivingCutscene(PoffinCaseApp *app)
{
FS_EXTERN_OVERLAY(poffin_case);
static const ApplicationManagerTemplate v0 = {
ov79_021D22AC,
ov79_021D22E4,
ov79_021D2460,
FS_OVERLAY_ID(poffin_case),
};
UnkStruct_02098DE8 *v1 = Heap_Alloc(app->heapID, sizeof(UnkStruct_02098DE8));
MI_CpuClear8(v1, sizeof(UnkStruct_02098DE8));
v1->unk_08 = app->data->poffins[app->data->selectedPoffin].type;
v1->unk_04 = PoffinCase_AllocateForSlot(app->data->poffinCase, app->data->poffins[app->data->selectedPoffin].caseIndex, app->heapID);
v1->unk_00 = Party_GetPokemonBySlotIndex(app->data->party, app->monIndex);
v1->unk_0A = Options_TextFrameDelay(app->data->options);
v1->unk_0B = Options_Frame(app->data->options);
app->subApp = ApplicationManager_New(&v0, v1, app->heapID);
app->subAppData = v1;
return STATE_PLAY_GIVING_CUTSCENE;
}
static int State_PlayPoffinGivingCutscene(PoffinCaseApp *app)
{
if (!RunSubApplication(&app->subApp)) {
return STATE_PLAY_GIVING_CUTSCENE;
}
UnkStruct_02098DE8 *v0 = app->subAppData;
Heap_Free(v0->unk_04);
Heap_Free(v0);
return STATE_INIT_SUMMARY_AFTER_GIVING;
}
static int State_InitSummaryAfterGiving(PoffinCaseApp *app)
{
static const u8 summaryPages[] = {
SUMMARY_PAGE_CONDITION, SUMMARY_PAGE_MAX
};
PokemonSummary *monSummary = Heap_Alloc(app->heapID, sizeof(PokemonSummary));
Poffin *poffin = PoffinCase_AllocateForSlot(app->data->poffinCase, app->data->poffins[app->data->selectedPoffin].caseIndex, app->heapID);
monSummary->monData = app->data->party;
monSummary->options = app->data->options;
monSummary->dataType = SUMMARY_DATA_PARTY_MON;
monSummary->monIndex = app->monIndex;
monSummary->monMax = Party_GetCurrentCount(monSummary->monData);
monSummary->move = 0;
monSummary->mode = SUMMARY_MODE_SHOW_CONDITION_CHANGE;
monSummary->poffin = poffin;
monSummary->showContest = TRUE;
monSummary->chatotCry = NULL;
PokemonSummaryScreen_FlagVisiblePages(monSummary, summaryPages);
PokemonSummaryScreen_SetPlayerProfile(monSummary, app->data->trainerInfo);
app->subApp = ApplicationManager_New(&gPokemonSummaryScreenApp, monSummary, app->heapID);
app->subAppData = monSummary;
return STATE_OPEN_SUMMARY_AFTER_GIVING;
}
static int State_OpenSummaryAfterGiving(PoffinCaseApp *app)
{
if (!RunSubApplication(&app->subApp)) {
return STATE_OPEN_SUMMARY_AFTER_GIVING;
}
PokemonSummary *monSummary = app->subAppData;
Heap_Free(monSummary->poffin);
Heap_Free(app->subAppData);
return STATE_INIT_POFFIN_MANAGER;
}
UnkEnum_02098EAC sub_02098EAC(Poffin *param0, u8 param1)
{
u8 v0[7];
u8 v1, v2, v3;
u8 v4 = sFlavorPreferences[param1][0];
u8 v5 = sFlavorPreferences[param1][1];
if (v4 == 5) {
return 2;
}
Poffin_StoreAttributesToArray(param0, v0);
v1 = v0[0];
v2 = v0[v4 + 1];
v3 = v0[v5 + 1];
if (v2 == v3) {
return 2;
}
if (v2 > v3) {
return 0;
} else {
return 1;
}
}
void sub_02098EF8(Poffin *param0, Pokemon *param1)
{
u8 v0, v1;
u8 v2, v3;
u8 v4, v5;
float v6;
int v7[6];
u8 v8[7];
u8 v9[7];
v2 = Pokemon_GetNature(param1);
v4 = sFlavorPreferences[v2][0];
v5 = sFlavorPreferences[v2][1];
Poffin_StoreAttributesToArray(param0, v8);
for (v0 = 0; v0 < 6; v0++) {
v7[v0] = Pokemon_GetValue(param1, MON_DATA_COOL + v0, NULL);
}
v1 = 0;
for (v0 = 1; v0 <= 6; v0++) {
v9[v1++] = v8[v0];
}
if (v4 != 5) {
v6 = (float)v9[v4] * 1.1f;
v9[v4] = (u8)v6;
v6 = (float)v9[v5] * 0.9f;
v9[v5] = (u8)v6;
}
for (v0 = 0; v0 < 6; v0++) {
v7[v0] += v9[v0];
if (v7[v0] > 255) {
v7[v0] = 255;
}
Pokemon_SetValue(param1, 19 + v0, &v7[v0]);
}
v3 = Pokemon_GetValue(param1, MON_DATA_FRIENDSHIP, NULL);
if (v3 < 255) {
++v3;
Pokemon_SetValue(param1, MON_DATA_FRIENDSHIP, &v3);
}
}

View File

@@ -0,0 +1,790 @@
#include "applications/poffin_case/manager.h"
#include <nitro.h>
#include "struct_defs/struct_02099F80.h"
#include "applications/poffin_case/main.h"
#include "applications/poffin_case/menus.h"
#include "applications/poffin_case/sprites.h"
#include "bg_window.h"
#include "font.h"
#include "game_options.h"
#include "gx_layers.h"
#include "heap.h"
#include "list_menu.h"
#include "menu.h"
#include "message.h"
#include "narc.h"
#include "overlay_manager.h"
#include "poffin_sprite.h"
#include "poffin_types.h"
#include "render_window.h"
#include "screen_fade.h"
#include "sound_playback.h"
#include "sprite.h"
#include "sprite_system.h"
#include "string_gf.h"
#include "string_template.h"
#include "system.h"
#include "text.h"
#include "touch_pad.h"
#include "touch_screen.h"
#include "unk_0208C098.h"
#include "vram_transfer.h"
#include "res/graphics/poffin_case/poru_gra.naix.h"
#include "res/text/bank/poffin_case.h"
typedef enum PoffinManagerState {
STATE_SELECT_POFFIN = 0,
STATE_INIT_ACTION_MENU,
STATE_SELECT_ACTION,
STATE_INIT_DELETE_POFFIN_CONFIRM,
STATE_CONFIRM_DELETE_POFFIN,
STATE_DELETE_POFFIN,
} PoffinManagerState;
typedef BOOL (*PoffinManagerStateFunc)(PoffinManager *);
static int UpdateApp(PoffinManager *app);
static int LoadApp(PoffinManager *app);
static int UnloadApp(PoffinManager *app);
static void SetGXBanks(void);
static void InitBackgrounds(PoffinManager *app);
static void FreeBackgrounds(PoffinManager *app);
static void LoadGraphics(PoffinManager *app);
static void Dummy(PoffinManager *app);
static void InitWindows(PoffinManager *app);
static void FreeWindows(PoffinManager *app);
static void InitMessages(PoffinManager *app);
static void FreeMessages(PoffinManager *app);
static void InitSprites(PoffinManager *app);
static void FreeSprites(PoffinManager *app);
static int State_SelectPoffin(PoffinManager *app);
static int State_InitActionMenu(PoffinManager *app);
static int State_SelectAction(PoffinManager *app);
static int State_InitDeletePoffinConfirm(PoffinManager *app);
static int State_ConfirmDeletePoffin(PoffinManager *app);
static int State_DeletePoffin(PoffinManager *app);
static const PoffinManagerStateFunc sStateFuncs[] = {
[STATE_SELECT_POFFIN] = State_SelectPoffin,
[STATE_INIT_ACTION_MENU] = State_InitActionMenu,
[STATE_SELECT_ACTION] = State_SelectAction,
[STATE_INIT_DELETE_POFFIN_CONFIRM] = State_InitDeletePoffinConfirm,
[STATE_CONFIRM_DELETE_POFFIN] = State_ConfirmDeletePoffin,
[STATE_DELETE_POFFIN] = State_DeletePoffin
};
BOOL PoffinManager_Init(ApplicationManager *appMan, int *unused)
{
PoffinCaseAppData *caseData = ApplicationManager_Args(appMan);
Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_POFFIN_MANAGER, 0x20000);
PoffinManager *app = ApplicationManager_NewData(appMan, sizeof(PoffinManager), HEAP_ID_POFFIN_MANAGER);
MI_CpuClear8(app, sizeof(PoffinManager));
app->heapID = HEAP_ID_POFFIN_MANAGER;
app->data = caseData;
app->flavorFilter = caseData->flavorFilter;
app->buttonHeld = 0xffff;
return TRUE;
}
BOOL PoffinManager_Main(ApplicationManager *appMan, int *unused)
{
PoffinManager *app = ApplicationManager_Data(appMan);
if (UpdateApp(app)) {
return TRUE;
}
return FALSE;
}
BOOL PoffinManager_Exit(ApplicationManager *appMan, int *unused)
{
PoffinManager *app = ApplicationManager_Data(appMan);
app->data->selectedPoffin = app->selectedPoffin;
app->data->poffinRemoved = app->givePoffin;
app->data->flavorFilter = app->flavorFilter;
app->data->listPos = app->listPos;
app->data->cursorPos = app->cursorPos;
ApplicationManager_FreeData(appMan);
Heap_Destroy(app->heapID);
return TRUE;
}
static int UpdateApp(PoffinManager *app)
{
switch (app->lifecycle) {
case 0:
SetVBlankCallback(NULL, NULL);
DisableHBlank();
GXLayers_DisableEngineALayers();
GXLayers_DisableEngineBLayers();
GX_SetVisiblePlane(0);
GXS_SetVisiblePlane(0);
SetScreenColorBrightness(DS_SCREEN_MAIN, COLOR_BLACK);
SetScreenColorBrightness(DS_SCREEN_SUB, COLOR_BLACK);
ResetVisibleHardwareWindows(DS_SCREEN_MAIN);
ResetVisibleHardwareWindows(DS_SCREEN_SUB);
EnableTouchPad();
InitializeTouchPad(4);
break;
case 1:
if (!LoadApp(app)) {
return FALSE;
}
app->dummy = 0;
StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_IN, FADE_TYPE_BRIGHTNESS_IN, COLOR_BLACK, 6, 1, app->heapID);
break;
case 2:
PoffinManager_UpdateSprites(app);
if (!IsScreenFadeDone()) {
return FALSE;
}
break;
case 3:
PoffinManager_UpdateSprites(app);
if (!sStateFuncs[app->state](app)) {
return FALSE;
}
app->dummy = 0;
StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_OUT, FADE_TYPE_BRIGHTNESS_OUT, COLOR_BLACK, 6, 1, app->heapID);
break;
case 4:
PoffinManager_UpdateSprites(app);
if (!IsScreenFadeDone()) {
return FALSE;
}
break;
case 5:
if (!UnloadApp(app)) {
return FALSE;
}
break;
case 6:
DisableTouchPad();
SetScreenColorBrightness(DS_SCREEN_MAIN, COLOR_BLACK);
SetScreenColorBrightness(DS_SCREEN_SUB, COLOR_BLACK);
SetVBlankCallback(NULL, NULL);
GXLayers_DisableEngineALayers();
GXLayers_DisableEngineBLayers();
GX_SetVisiblePlane(0);
GXS_SetVisiblePlane(0);
break;
default:
return TRUE;
}
app->lifecycle++;
return FALSE;
}
static void VBlankCallback(void *ptr)
{
PoffinManager *app = ptr;
if (app->spriteSys != NULL) {
SpriteSystem_TransferOam();
}
VramTransfer_Process();
Bg_RunScheduledUpdates(app->bgConfig);
OS_SetIrqCheckFlag(OS_IE_V_BLANK);
}
static int ProcessTouchScreenAction(PoffinManager *app)
{
int hitbox;
static const TouchScreenRect sHitboxes[] = {
[FLAVOR_SPICY] = { .rect = { .top = 34, .bottom = 62, .left = 96, .right = 160 } },
[FLAVOR_DRY] = { .rect = { .top = 82, .bottom = 110, .left = 160, .right = 224 } },
[FLAVOR_SWEET] = { .rect = { .top = 148, .bottom = 176, .left = 136, .right = 200 } },
[FLAVOR_BITTER] = { .rect = { .top = 150, .bottom = 178, .left = 56, .right = 120 } },
[FLAVOR_SOUR] = { .rect = { .top = 82, .bottom = 110, .left = 32, .right = 96 } },
[FLAVOR_MAX] = { .rect = { .top = 102, .bottom = 130, .left = 96, .right = 160 } },
{ .rect = { .top = 255, .bottom = 0, .left = 0, .right = 0 } }
};
hitbox = TouchScreen_CheckRectanglePressed(sHitboxes);
if (hitbox != TOUCHSCREEN_INPUT_NONE) {
return hitbox;
}
hitbox = TouchScreen_CheckRectangleHeld(sHitboxes);
if (hitbox == TOUCHSCREEN_INPUT_NONE) {
if (app->buttonHeld == TRUE) {
PoffinManager_UpdateFilterButton(app, app->flavorFilter, BUTTON_ACTION_RELEASE_SELECTED);
}
}
return -1;
}
static BOOL State_SelectPoffin(PoffinManager *app)
{
u32 menuSelection = LIST_NOTHING_CHOSEN;
if (app->poffinMenu == NULL) {
return FALSE;
}
int touchScreenAction = ProcessTouchScreenAction(app);
if (gSystem.heldKeys != 0) {
if (!app->buttonHeld) {
menuSelection = ListMenu_ProcessInput(app->poffinMenu);
}
} else {
if (touchScreenAction >= 0) {
PoffinManager_UpdatePoffinFilter(app, touchScreenAction);
}
return FALSE;
}
if (menuSelection == LIST_NOTHING_CHOSEN) {
return FALSE;
}
if (gSystem.pressedKeys & PAD_BUTTON_B) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
app->selectedPoffin = POFFIN_LIST_SENTINEL;
app->givePoffin = FALSE;
return TRUE;
}
if (gSystem.pressedKeys & PAD_BUTTON_A) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
switch (menuSelection) {
case LIST_NOTHING_CHOSEN:
case LIST_CANCEL:
case POFFIN_LIST_SENTINEL:
app->selectedPoffin = POFFIN_LIST_SENTINEL;
app->givePoffin = FALSE;
return TRUE;
default:
app->selectedPoffin = menuSelection;
app->state = STATE_INIT_ACTION_MENU;
return FALSE;
}
}
return FALSE;
}
static BOOL State_InitActionMenu(PoffinManager *app)
{
PoffinCaseApp_UpdateListSprites(app, 1);
PoffinManager_CreateActionMenu(app);
app->state = STATE_SELECT_ACTION;
return FALSE;
}
static BOOL State_SelectAction(PoffinManager *app)
{
u32 menuSelection = ListMenu_ProcessInput(app->actionMenu);
if (gSystem.pressedKeys & PAD_BUTTON_B) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
PoffinManager_FreeActionMenu(app);
PoffinCaseApp_UpdateListSprites(app, 0);
app->state = STATE_SELECT_POFFIN;
return FALSE;
}
if (gSystem.pressedKeys & PAD_BUTTON_A) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
switch (menuSelection) {
case 0:
app->givePoffin = TRUE;
return TRUE;
case 1:
PoffinManager_FreeActionMenu(app);
PoffinManager_ShowDiscardQuestion(app);
app->state = STATE_INIT_DELETE_POFFIN_CONFIRM;
break;
case LIST_NOTHING_CHOSEN:
case LIST_CANCEL:
default:
PoffinManager_FreeActionMenu(app);
PoffinCaseApp_UpdateListSprites(app, 0);
app->state = STATE_SELECT_POFFIN;
break;
}
}
return FALSE;
}
static BOOL State_InitDeletePoffinConfirm(PoffinManager *app)
{
if (Text_IsPrinterActive(app->printerID)) {
return FALSE;
}
PoffinManager_CreateYesNoMenu(app);
app->state = STATE_CONFIRM_DELETE_POFFIN;
return FALSE;
}
static BOOL State_ConfirmDeletePoffin(PoffinManager *app)
{
switch (Menu_ProcessInputAndHandleExit(app->yesNoMenu, app->heapID)) {
case 0:
Sound_PlayEffect(SEQ_SE_CONFIRM);
PoffinManager_ShowThrownOutMessage(app);
app->state = STATE_DELETE_POFFIN;
return FALSE;
case MENU_CANCELED:
Sound_PlayEffect(SEQ_SE_CONFIRM);
Window_EraseMessageBox(&app->windows[2], FALSE);
app->state = STATE_INIT_ACTION_MENU;
return FALSE;
}
return FALSE;
}
static BOOL State_DeletePoffin(PoffinManager *app)
{
if (Text_IsPrinterActive(app->printerID)) {
return FALSE;
}
if ((gSystem.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) == 0) {
return FALSE;
}
Window_EraseMessageBox(&app->windows[2], TRUE);
Window_ClearAndCopyToVRAM(&app->windows[2]);
app->data->poffins[app->selectedPoffin].deleted = 1;
app->data->poffinRemoved = TRUE;
PoffinManager_FreePoffinList(app, 0);
PoffinManager_InitPoffinList(app);
PoffinCaseApp_UpdateListSprites(app, 0);
app->state = STATE_SELECT_POFFIN;
return FALSE;
}
static BOOL LoadApp(PoffinManager *app)
{
switch (app->loadState) {
case 0:
InitBackgrounds(app);
break;
case 1:
LoadGraphics(app);
break;
case 2:
InitMessages(app);
InitWindows(app);
break;
case 3:
PoffinManager_InitSpriteSystem(app);
break;
case 4:
InitSprites(app);
break;
case 5:
PoffinManager_InitPoffinList(app);
PoffinManager_UpdateFilterButton(app, app->flavorFilter, BUTTON_ACTION_SET_AS_ACTIVE);
SetVBlankCallback(VBlankCallback, app);
app->loadState = 0;
return TRUE;
}
app->loadState++;
return FALSE;
}
static int UnloadApp(PoffinManager *app)
{
switch (app->loadState) {
case 0:
if (app->actionList != NULL) {
PoffinManager_FreeActionMenu(app);
}
PoffinManager_FreePoffinList(app, TRUE);
break;
case 1:
FreeSprites(app);
PoffinManager_FreeSpriteSystem(app);
break;
case 2:
FreeWindows(app);
FreeMessages(app);
break;
case 3:
Dummy(app);
break;
case 4:
FreeBackgrounds(app);
break;
case 5:
return TRUE;
}
app->loadState++;
return FALSE;
}
static void SetGXBanks(void)
{
UnkStruct_02099F80 banks = {
GX_VRAM_BG_128_A,
GX_VRAM_BGEXTPLTT_NONE,
GX_VRAM_SUB_BG_128_C,
GX_VRAM_SUB_BGEXTPLTT_NONE,
GX_VRAM_OBJ_64_E,
GX_VRAM_OBJEXTPLTT_NONE,
GX_VRAM_SUB_OBJ_16_I,
GX_VRAM_SUB_OBJEXTPLTT_NONE,
GX_VRAM_TEX_NONE,
GX_VRAM_TEXPLTT_NONE
};
GXLayers_SetBanks(&banks);
}
static void InitBackgrounds(PoffinManager *app)
{
SetGXBanks();
app->bgConfig = BgConfig_New(app->heapID);
GraphicsModes graphicsModes = {
GX_DISPMODE_GRAPHICS,
GX_BGMODE_0,
GX_BGMODE_0,
GX_BG0_AS_2D
};
SetAllGraphicsModes(&graphicsModes);
BgTemplate bgTemplates[] = {
{
.x = 0,
.y = 0,
.bufferSize = 0x800,
.baseTile = 0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf800,
.charBase = GX_BG_CHARBASE_0x00000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0,
.areaOver = 0,
.mosaic = FALSE,
},
{
.x = 0,
.y = 0,
.bufferSize = 0x800,
.baseTile = 0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf000,
.charBase = GX_BG_CHARBASE_0x10000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 1,
.areaOver = 0,
.mosaic = FALSE,
},
{
.x = 0,
.y = 0,
.bufferSize = 0x800,
.baseTile = 0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xe800,
.charBase = GX_BG_CHARBASE_0x10000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 3,
.areaOver = 0,
.mosaic = FALSE,
},
{
.x = 0,
.y = 0,
.bufferSize = 0x800,
.baseTile = 0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xe000,
.charBase = GX_BG_CHARBASE_0x00000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 3,
.areaOver = 0,
.mosaic = FALSE,
},
{
.x = 0,
.y = 0,
.bufferSize = 0x800,
.baseTile = 0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf800,
.charBase = GX_BG_CHARBASE_0x10000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0,
.areaOver = 0,
.mosaic = FALSE,
},
{
.x = 0,
.y = 0,
.bufferSize = 0x800,
.baseTile = 0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf000,
.charBase = GX_BG_CHARBASE_0x00000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 1,
.areaOver = 0,
.mosaic = FALSE,
},
};
for (int i = 0, j = 0; j < 6; ++i, j++) {
Bg_InitFromTemplate(app->bgConfig, i, &bgTemplates[j], BG_TYPE_STATIC);
Bg_ClearTilemap(app->bgConfig, i);
Bg_ClearTilesRange(i, 32, 0, app->heapID);
}
}
static void FreeBackgrounds(PoffinManager *app)
{
for (int i = 0; i < 6; i++) {
Bg_FreeTilemapBuffer(app->bgConfig, i);
}
Heap_Free(app->bgConfig);
}
static void LoadGraphics(PoffinManager *poffinCase)
{
NARC *poru_gra = NARC_ctor(NARC_INDEX_GRAPHIC__PORU_GRA, poffinCase->heapID);
App_LoadGraphicMember(poffinCase->bgConfig, poffinCase->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, main_tiles_NCGR, BG_LAYER_MAIN_0, GRAPHICSMEMBER_TILES, 0, 0);
App_LoadGraphicMember(poffinCase->bgConfig, poffinCase->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, sub_tiles_NCGR, BG_LAYER_SUB_1, GRAPHICSMEMBER_TILES, 0, 0);
App_LoadGraphicMember(poffinCase->bgConfig, poffinCase->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, background_NCLR, BG_LAYER_MAIN_0, GRAPHICSMEMBER_PALETTE, PALETTE_SIZE_BYTES * 12, 0);
App_LoadGraphicMember(poffinCase->bgConfig, poffinCase->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, background_NCLR, BG_LAYER_SUB_0, GRAPHICSMEMBER_PALETTE, PALETTE_SIZE_BYTES * 12, 0);
App_LoadGraphicMember(poffinCase->bgConfig, poffinCase->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, main_tilemap_NSCR, BG_LAYER_MAIN_3, GRAPHICSMEMBER_TILEMAP, 0, 0);
App_LoadGraphicMember(poffinCase->bgConfig, poffinCase->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, sub_tilemap_NSCR, BG_LAYER_SUB_1, GRAPHICSMEMBER_TILEMAP, 0, 0);
NARC_dtor(poru_gra);
Bg_ScheduleTilemapTransfer(poffinCase->bgConfig, BG_LAYER_MAIN_3);
Bg_ScheduleTilemapTransfer(poffinCase->bgConfig, BG_LAYER_SUB_1);
}
static void Dummy(PoffinManager *app)
{
return;
}
static void InitWindows(PoffinManager *app)
{
static const struct {
u8 bgLayer, left, top, width, height, palette;
u16 baseTile;
} windowParams[] = {
{ 2, 2, 4, 22, 12, 13, 40 },
{ 2, 11, 20, 10, 2, 13, 305 },
{ 1, 2, 19, 27, 4, 12, 325 },
{ 1, 26, 17, 5, 6, 13, 433 },
{ 1, 26, 13, 5, 4, 13, 463 },
{ 1, 0, 0, 16, 2, 13, 483 },
{ 4, 6, 0, 20, 3, 13, 1 },
{ 4, 12, 5, 8, 3, 5, 65 },
{ 4, 20, 10, 8, 3, 6, 89 },
{ 4, 17, 19, 8, 3, 7, 113 },
{ 4, 7, 19, 8, 3, 8, 137 },
{ 4, 4, 10, 8, 3, 9, 161 },
{ 4, 12, 13, 8, 3, 10, 185 }
};
LoadStandardWindowGraphics(app->bgConfig, BG_LAYER_MAIN_1, 31, 15, STANDARD_WINDOW_SYSTEM, app->heapID);
LoadMessageBoxGraphics(app->bgConfig, BG_LAYER_MAIN_1, 1, 14, Options_Frame(app->data->options), app->heapID);
Font_LoadTextPalette(PAL_LOAD_MAIN_BG, PLTT_OFFSET(13), app->heapID);
Font_LoadScreenIndicatorsPalette(PAL_LOAD_MAIN_BG, PLTT_OFFSET(12), app->heapID);
Font_LoadTextPalette(PAL_LOAD_SUB_BG, PLTT_OFFSET(13), app->heapID);
for (int i = 0; i < NUM_WINDOWS; i++) {
Window_Add(app->bgConfig, &app->windows[i], windowParams[i].bgLayer, windowParams[i].left, windowParams[i].top, windowParams[i].width, windowParams[i].height, windowParams[i].palette, windowParams[i].baseTile);
Window_FillTilemap(&app->windows[i], 0);
}
PoffinManager_PrintHeaderandButtons(app);
}
static void FreeWindows(PoffinManager *app)
{
for (int i = 0; i < NUM_WINDOWS; i++) {
Window_ClearAndCopyToVRAM(&app->windows[i]);
Window_Remove(&app->windows[i]);
}
}
static void InitMessages(PoffinManager *app)
{
Font_InitManager(FONT_SUBSCREEN, app->heapID);
app->msgLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_POFFIN_CASE, app->heapID);
app->poffinTypes = PoffinTypeList_New(app->heapID);
app->messages.template = StringTemplate_New(2, 64, app->heapID);
app->messages.string = String_Init(64, app->heapID);
app->messages.closeStr = MessageLoader_GetNewString(app->msgLoader, PoffinCase_Text_Close);
app->messages.listItemStr = MessageLoader_GetNewString(app->msgLoader, PoffinCase_Text_ListItem);
app->messages.smoothStr = MessageLoader_GetNewString(app->msgLoader, PoffinCase_Text_Smooth);
app->messages.discardStr = MessageLoader_GetNewString(app->msgLoader, PoffinCase_Text_Discard);
app->messages.thrownOutStr = MessageLoader_GetNewString(app->msgLoader, PoffinCase_Text_ThrownOut);
app->messages.headerStr = MessageLoader_GetNewString(app->msgLoader, PoffinCase_Text_PoffinCase);
for (int i = 0; i < FLAVOR_MAX + 1; i++) {
app->messages.flavorStrs[i] = MessageLoader_GetNewString(app->msgLoader, 11 + i);
if (i >= FLAVOR_MAX) {
break;
}
app->messages.flavorDescs[i] = MessageLoader_GetNewString(app->msgLoader, 17 + i);
}
app->messages.textDelay = Options_TextFrameDelay(app->data->options);
}
static void FreeMessages(PoffinManager *app)
{
for (int i = 0; i < FLAVOR_MAX + 1; i++) {
String_Free(app->messages.flavorStrs[i]);
if (i >= FLAVOR_MAX) {
break;
}
String_Free(app->messages.flavorDescs[i]);
}
String_Free(app->messages.headerStr);
String_Free(app->messages.thrownOutStr);
String_Free(app->messages.discardStr);
String_Free(app->messages.smoothStr);
String_Free(app->messages.listItemStr);
String_Free(app->messages.closeStr);
String_Free(app->messages.string);
StringTemplate_Free(app->messages.template);
PoffinTypeList_Free(app->poffinTypes);
MessageLoader_Free(app->msgLoader);
Font_Free(FONT_SUBSCREEN);
}
static void InitSprites(PoffinManager *app)
{
static const SpriteTemplateFromResourceHeader templates[] = {
{ 0, 105, 40, 0, 0, 1, 0, NNS_G2D_VRAM_TYPE_2DMAIN, 0, 0, 0, 0 },
{ 0, 80, 18, 0, 1, 2, 0, NNS_G2D_VRAM_TYPE_2DMAIN, 0, 0, 0, 0 },
{ 0, 80, 140, 0, 2, 2, 0, NNS_G2D_VRAM_TYPE_2DMAIN, 0, 0, 0, 0 },
{ 0, 10, 100, 0, 3, 3, 1, NNS_G2D_VRAM_TYPE_2DMAIN, 0, 0, 0, 0 },
{ 1, 10, 100, 0, 0, 1, 2, NNS_G2D_VRAM_TYPE_2DSUB, 0, 0, 0, 0 }
};
for (int i = 0; i < NUM_LIST_SPRITES; i++) {
app->listSprites[i] = SpriteSystem_NewSpriteFromResourceHeader(app->spriteSys, app->spriteMan, &templates[i]);
Sprite_SetDrawFlag(app->listSprites[i], TRUE);
}
Sprite_SetAnimateFlag(app->listSprites[0], FALSE);
Sprite_SetAnimateFlag(app->listSprites[1], TRUE);
Sprite_SetAnimateFlag(app->listSprites[2], TRUE);
for (int i = 0; i < FLAVOR_MAX; i++) {
static const struct {
u16 x, y;
} sTypeIconPositions[] = {
[FLAVOR_SPICY] = { 40, 156 },
[FLAVOR_DRY] = { 54, 165 },
[FLAVOR_SWEET] = { 49, 180 },
[FLAVOR_BITTER] = { 31, 180 },
[FLAVOR_SOUR] = { 26, 165 }
};
app->flavorSprites[i] = SpriteSystem_NewSpriteFromResourceHeader(app->spriteSys, app->spriteMan, &templates[3]);
Sprite_SetDrawFlag(app->flavorSprites[i], TRUE);
Sprite_SetAnim(app->flavorSprites[i], i + 3);
Sprite_SetPositionXY(app->flavorSprites[i], sTypeIconPositions[i].x, sTypeIconPositions[i].y);
}
for (int i = 0; i < FLAVOR_MAX + 1; i++) {
static const struct {
u16 x, y;
} sButtonPositions[] = {
[FLAVOR_SPICY] = { 128, 48 },
[FLAVOR_DRY] = { 192, 96 },
[FLAVOR_SWEET] = { 168, 162 },
[FLAVOR_BITTER] = { 88, 164 },
[FLAVOR_SOUR] = { 64, 96 },
[FLAVOR_MAX] = { 128, 116 }
};
app->buttonSprites[i] = SpriteSystem_NewSpriteFromResourceHeader(app->spriteSys, app->spriteMan, &templates[4]);
Sprite_SetDrawFlag(app->buttonSprites[i], TRUE);
Sprite_SetAnim(app->buttonSprites[i], i * 3);
Sprite_SetAnimSpeed(app->buttonSprites[i], FX32_CONST(2));
Sprite_SetExplicitPalette(app->buttonSprites[i], i + 2);
Sprite_SetAnimateFlag(app->buttonSprites[i], FALSE);
Sprite_SetPositionXY(app->buttonSprites[i], sButtonPositions[i].x, sButtonPositions[i].y);
}
app->poffinSprite = PoffinSprite_New(app->poffinSpriteMan, 0, 231, 76, 0, 1, 0, FALSE);
ManagedSprite_SetDrawFlag(app->poffinSprite->sprite, FALSE);
}
static void FreeSprites(PoffinManager *app)
{
PoffinSprite_Free(app->poffinSpriteMan, app->poffinSprite);
for (int i = 0; i < FLAVOR_MAX + 1; i++) {
Sprite_Delete2(app->buttonSprites[i]);
}
for (int i = 0; i < FLAVOR_MAX; i++) {
Sprite_Delete2(app->flavorSprites[i]);
}
for (int i = 0; i < NUM_LIST_SPRITES; i++) {
Sprite_Delete2(app->listSprites[i]);
}
}

View File

@@ -0,0 +1,451 @@
#include "applications/poffin_case/menus.h"
#include <nitro.h>
#include "applications/poffin_case/main.h"
#include "applications/poffin_case/manager.h"
#include "bg_window.h"
#include "font.h"
#include "list_menu.h"
#include "menu.h"
#include "poffin_sprite.h"
#include "poffin_types.h"
#include "render_text.h"
#include "render_window.h"
#include "sound_playback.h"
#include "sprite.h"
#include "sprite_system.h"
#include "string_gf.h"
#include "string_list.h"
#include "string_template.h"
#include "text.h"
#define POFFIN_LIST_VIEW_HEIGHT 6
static void DummyCallback(ListMenu *menu, u32 unused, u8 unused2);
static void UpdateSelectedPoffin(ListMenu *menu, u32 index, u8 onInit);
static void PlaySound(ListMenu *menu, u32 index, u8 onInit);
static const ListMenuTemplate sPoffinMenuTemplate = {
.choices = NULL,
.cursorCallback = UpdateSelectedPoffin,
.printCallback = DummyCallback,
.window = NULL,
.count = 0,
.maxDisplay = POFFIN_LIST_VIEW_HEIGHT,
.headerXOffset = 0,
.textXOffset = 8,
.cursorXOffset = 0,
.yOffset = 0,
.textColorFg = 1,
.textColorBg = 0,
.textColorShadow = 2,
.letterSpacing = 0,
.lineSpacing = 0,
.pagerMode = PAGER_MODE_LEFT_RIGHT_PAD,
.fontID = 0,
.cursorType = 1,
.parent = NULL
};
static const ListMenuTemplate sActionMenuTemplate = {
.choices = NULL,
.cursorCallback = PlaySound,
.printCallback = NULL,
.window = NULL,
.count = 0,
.maxDisplay = 3,
.headerXOffset = 0,
.textXOffset = 8,
.cursorXOffset = 0,
.yOffset = 0,
.textColorFg = 1,
.textColorBg = 15,
.textColorShadow = 2,
.letterSpacing = 0,
.lineSpacing = 0,
.pagerMode = PAGER_MODE_NONE,
.fontID = 0,
.cursorType = 0,
.parent = NULL
};
static void ResetPoffinsFilterDetails(PoffinCaseAppItem *poffin)
{
poffin->isListed = FALSE;
poffin->prev = poffin->next = POFFIN_LIST_SENTINEL;
}
static void PrintMessageBox(PoffinManager *app, String *string, u8 renderDelay, u8 hasScroll)
{
u32 color = TEXT_COLOR(1, 2, 15);
if (hasScroll) {
Window_DrawMessageBoxWithScrollCursor(&app->windows[2], TRUE, 1, 14);
}
Window_FillRectWithColor(&app->windows[2], PIXEL_FILL(15), 0, 0, 216, 32);
RenderControlFlags_SetCanABSpeedUpPrint(TRUE);
RenderControlFlags_SetAutoScrollFlags(AUTO_SCROLL_DISABLED);
app->printerID = Text_AddPrinterWithParamsAndColor(&app->windows[2], FONT_MESSAGE, string, 0, 0, renderDelay, color, NULL);
}
static u16 PoffinManager_FilterPoffins(PoffinCaseAppData *appData, PoffinManager *app)
{
u16 i, count = 0;
u8 poffinTypeMask;
PoffinCaseAppItem *poffin;
app->lastPoffin = app->firstPoffin = POFFIN_LIST_SENTINEL;
if (app->flavorFilter == 5) {
poffinTypeMask = 0x1F;
} else {
poffinTypeMask = 1;
for (i = 0; i < app->flavorFilter; i++) {
poffinTypeMask <<= 1;
}
}
for (i = 0; i < appData->poffinCount; i++) {
poffin = &appData->poffins[i];
ResetPoffinsFilterDetails(poffin);
if (!poffin->alwaysTrue || poffin->deleted) {
continue;
}
u8 poffinType = poffin->flavors & 0x1F;
if ((poffinType & poffinTypeMask) == 0) {
continue;
}
poffin->isListed = TRUE;
if (app->lastPoffin == POFFIN_LIST_SENTINEL) {
app->lastPoffin = poffin->index;
} else {
appData->poffins[app->firstPoffin].prev = poffin->index;
}
poffin->next = app->firstPoffin;
app->firstPoffin = poffin->index;
++count;
}
count += 1;
return count;
}
void PoffinManager_InitPoffinList(PoffinManager *app)
{
app->poffinCount = PoffinManager_FilterPoffins(app->data, app);
app->poffinList = StringList_New(app->poffinCount, app->heapID);
u8 next = 0;
for (u8 i = app->firstPoffin; i != POFFIN_LIST_SENTINEL; i = next) {
PoffinCaseAppItem *poffin = &app->data->poffins[i];
next = poffin->next;
StringTemplate_SetString(app->messages.template, 0, PoffinTypeList_GetString(app->poffinTypes, poffin->type), 0, 0, GAME_LANGUAGE);
StringTemplate_SetNumber(app->messages.template, 1, poffin->level, 2, PADDING_MODE_ZEROES, CHARSET_MODE_EN);
StringTemplate_Format(app->messages.template, app->messages.string, app->messages.listItemStr);
StringList_AddFromString(app->poffinList, app->messages.string, poffin->index);
}
StringList_AddFromString(app->poffinList, app->messages.closeStr, POFFIN_LIST_SENTINEL);
MI_CpuCopy8(&sPoffinMenuTemplate, &app->menuTemplate, sizeof(ListMenuTemplate));
app->cursorPos = app->data->cursorPos;
app->listPos = app->data->listPos;
if (app->data->poffinRemoved) {
if (app->listPos == 0) {
if (app->cursorPos != 0 && app->cursorPos >= app->poffinCount - 1) {
--app->cursorPos;
}
} else {
if (app->listPos + POFFIN_LIST_VIEW_HEIGHT >= app->poffinCount) {
--app->listPos;
}
}
app->data->poffinRemoved = FALSE;
}
app->menuTemplate.window = &app->windows[0];
app->menuTemplate.choices = app->poffinList;
app->menuTemplate.parent = app;
app->menuTemplate.count = app->poffinCount;
app->dummy2 = 0;
app->poffinMenu = ListMenu_New(&app->menuTemplate, app->listPos, app->cursorPos, app->heapID);
app->dummy2 = 1;
}
void PoffinManager_FreePoffinList(PoffinManager *app, BOOL clear)
{
Window_FillRectWithColor(&app->windows[0], 0, 0, 0, 176, 96);
if (clear) {
Window_ClearAndCopyToVRAM(&app->windows[0]);
}
ListMenu_Free(app->poffinMenu, &app->listPos, &(app->cursorPos));
StringList_Free(app->poffinList);
app->data->listPos = app->listPos;
app->data->cursorPos = app->cursorPos;
app->poffinMenu = NULL;
app->poffinList = NULL;
}
void PoffinManager_UpdateFilterButton(PoffinManager *app, u8 poffinType, u8 buttonAction)
{
switch (buttonAction) {
case BUTTON_ACTION_DESELECT:
Sprite_SetAnim(app->buttonSprites[poffinType], poffinType * 3);
Sprite_SetAnimateFlag(app->buttonSprites[poffinType], FALSE);
Window_Scroll(
&app->windows[7 + poffinType], 1, 2, 0);
break;
case BUTTON_ACTION_SELECT:
Sprite_RestartAnim(app->buttonSprites[poffinType]);
Sprite_SetAnimateFlag(app->buttonSprites[poffinType], TRUE);
Window_Scroll(&app->windows[7 + poffinType], 0, 4, 0);
app->buttonHeld = TRUE;
break;
case BUTTON_ACTION_RELEASE_SELECTED:
Sprite_SetAnim(app->buttonSprites[poffinType], poffinType * 3 + 1);
Window_Scroll(&app->windows[7 + poffinType], 1, 2, 0);
app->buttonHeld = FALSE;
break;
case BUTTON_ACTION_REPRESS_SELECTED:
Sprite_SetAnim(app->buttonSprites[poffinType], poffinType * 3 + 2);
Window_Scroll(&app->windows[7 + poffinType], 0, 2, 0);
app->buttonHeld = TRUE;
break;
case BUTTON_ACTION_SET_AS_ACTIVE:
Sprite_SetAnim(app->buttonSprites[poffinType], poffinType * 3 + 1);
Sprite_SetAnimateFlag(app->buttonSprites[poffinType], TRUE);
Window_Scroll(&app->windows[7 + poffinType], 0, 2, 0);
app->buttonHeld = FALSE;
break;
}
Window_CopyToVRAM(&app->windows[7 + poffinType]);
}
void PoffinManager_UpdatePoffinFilter(PoffinManager *app, u8 poffinType)
{
Sound_PlayEffect(SEQ_SE_DP_BUTTON9);
if (app->buttonHeld != 0xffff) {
if (poffinType == app->flavorFilter) {
PoffinManager_UpdateFilterButton(app, poffinType, BUTTON_ACTION_REPRESS_SELECTED);
return;
}
PoffinManager_UpdateFilterButton(app, app->flavorFilter, BUTTON_ACTION_DESELECT);
}
PoffinManager_UpdateFilterButton(app, poffinType, BUTTON_ACTION_SELECT);
app->flavorFilter = poffinType;
PoffinManager_FreePoffinList(app, 0);
app->listPos = app->cursorPos = 0;
app->data->listPos = app->data->cursorPos = 0;
PoffinManager_InitPoffinList(app);
Window_FillRectWithColor(&app->windows[6], 0, 0, 0, 160, 24);
if (app->flavorFilter == FLAVOR_MAX) {
Window_CopyToVRAM(&app->windows[6]);
return;
}
int width = 160 - Font_CalcStringWidth(FONT_SYSTEM, app->messages.flavorDescs[app->flavorFilter], 0);
TextColor color = TEXT_COLOR(1, 2, 0);
Text_AddPrinterWithParamsAndColor(&app->windows[6], FONT_SYSTEM, app->messages.flavorDescs[app->flavorFilter], width / 2, 3, TEXT_SPEED_INSTANT, color, NULL);
}
static void PoffinManager_UpdateFlavorSprites(PoffinManager *app, PoffinCaseAppItem *poffin)
{
u8 poffinTypeMask = 1;
if (poffin == NULL) {
for (u8 i = 0; i < FLAVOR_MAX; i++) {
Sprite_SetDrawFlag(app->flavorSprites[i], FALSE);
}
return;
}
for (u8 i = 0; i < FLAVOR_MAX; i++) {
if (poffin->flavors & poffinTypeMask) {
Sprite_SetDrawFlag(app->flavorSprites[i], TRUE);
} else {
Sprite_SetDrawFlag(app->flavorSprites[i], FALSE);
}
poffinTypeMask <<= 1;
}
}
static void DummyCallback(ListMenu *menu, u32 unused, u8 unused2)
{
ListMenu_GetAttribute(menu, LIST_MENU_PARENT);
}
static void UpdateSelectedPoffin(ListMenu *menu, u32 index, u8 onInit)
{
PoffinManager *app = (PoffinManager *)ListMenu_GetAttribute(menu, LIST_MENU_PARENT);
if (!onInit) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
}
u16 listPos, cursorPos;
ListMenu_GetListAndCursorPos(menu, &listPos, &cursorPos);
Sprite_SetPositionXY(app->listSprites[LIST_SPRITE_SELECT_BOX], 105, cursorPos * 16 + 40);
if (listPos == 0) {
Sprite_SetDrawFlag(app->listSprites[LIST_SPRITE_UP_ARROW], FALSE);
} else {
Sprite_SetDrawFlag(app->listSprites[LIST_SPRITE_UP_ARROW], TRUE);
}
if (listPos < (app->poffinCount - 6)) {
Sprite_SetDrawFlag(app->listSprites[LIST_SPRITE_DOWN_ARROW], TRUE);
} else {
Sprite_SetDrawFlag(app->listSprites[LIST_SPRITE_DOWN_ARROW], FALSE);
}
Window_FillRectWithColor(&app->windows[1], 0, 0, 0, 80, 16);
if (index == POFFIN_LIST_SENTINEL) {
PoffinManager_UpdateFlavorSprites(app, NULL);
Window_CopyToVRAM(&app->windows[1]);
ManagedSprite_SetDrawFlag(app->poffinSprite->sprite, FALSE);
return;
}
PoffinManager_UpdateFlavorSprites(app, &app->data->poffins[index]);
String_Clear(app->messages.string);
u8 smoothness = app->data->poffins[index].smoothness;
if (smoothness > 99) {
smoothness = 99;
}
TextColor color = TEXT_COLOR(1, 2, 0);
StringTemplate_SetNumber(app->messages.template, 0, smoothness, 2, PADDING_MODE_NONE, CHARSET_MODE_EN);
StringTemplate_Format(app->messages.template, app->messages.string, app->messages.smoothStr);
Text_AddPrinterWithParamsAndColor(&app->windows[1], FONT_SYSTEM, app->messages.string, 8, 0, TEXT_SPEED_INSTANT, color, NULL);
PoffinSprite_UpdateType(app->poffinSpriteMan, app->poffinSprite, app->data->poffins[index].type);
ManagedSprite_SetDrawFlag(app->poffinSprite->sprite, TRUE);
}
void PoffinManager_CreateActionMenu(PoffinManager *app)
{
app->actionList = StringList_New(3, app->heapID);
for (u8 i = 0; i < 3; i++) {
StringList_AddFromMessageBank(app->actionList, app->msgLoader, 1 + i, i);
}
MI_CpuCopy8(&sActionMenuTemplate, &app->actionMenuTemplate, sizeof(ListMenuTemplate));
app->actionMenuTemplate.window = &app->windows[3];
app->actionMenuTemplate.choices = app->actionList;
app->actionMenuTemplate.parent = app;
app->actionMenuTemplate.count = 3;
Window_DrawStandardFrame(&app->windows[3], 1, 31, 15);
app->actionMenu = ListMenu_New(&app->actionMenuTemplate, 0, 0, app->heapID);
}
void PoffinManager_FreeActionMenu(PoffinManager *app)
{
Window_EraseStandardFrame(&app->windows[3], FALSE);
Window_ClearAndCopyToVRAM(&app->windows[3]);
u16 cursorPos, listPos;
ListMenu_Free(app->actionMenu, &listPos, &cursorPos);
StringList_Free(app->actionList);
app->actionMenu = NULL;
app->actionList = NULL;
}
static void PlaySound(ListMenu *menu, u32 index, u8 onInit)
{
if (!onInit) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
}
}
void PoffinManager_ShowDiscardQuestion(PoffinManager *app)
{
String_Clear(app->messages.string);
StringTemplate_SetString(app->messages.template, 0, PoffinTypeList_GetString(app->poffinTypes, app->data->poffins[app->selectedPoffin].type), 2, TRUE, GAME_LANGUAGE);
StringTemplate_Format(app->messages.template, app->messages.string, app->messages.discardStr);
PrintMessageBox(app, app->messages.string, app->messages.textDelay, TRUE);
}
void PoffinManager_ShowThrownOutMessage(PoffinManager *app)
{
String_Clear(app->messages.string);
StringTemplate_SetString(app->messages.template, 0, PoffinTypeList_GetString(app->poffinTypes, app->data->poffins[app->selectedPoffin].type), 2, TRUE, GAME_LANGUAGE);
StringTemplate_Format(app->messages.template, app->messages.string, app->messages.thrownOutStr);
PrintMessageBox(app, app->messages.string, app->messages.textDelay, FALSE);
}
void PoffinManager_CreateYesNoMenu(PoffinManager *app)
{
static const WindowTemplate winTemplate = {
1, 26, 13, 5, 4, 13, 463
};
app->yesNoMenu = Menu_MakeYesNoChoice(app->bgConfig, &winTemplate, 31, 15, app->heapID);
}
void PoffinManager_PrintHeaderandButtons(PoffinManager *app)
{
Text_AddPrinterWithParamsAndColor(
&app->windows[5],
FONT_SYSTEM,
app->messages.headerStr,
4,
0,
TEXT_SPEED_INSTANT,
TEXT_COLOR(1, 2, 0),
NULL);
TextColor buttonTextColor = TEXT_COLOR(2, 3, 1);
for (int i = 0; i < FLAVOR_MAX + 1; i++) {
static const u8 yOffsets[] = { 2, 10, 4, 6, 10, 6 };
int width = 64 - Font_CalcStringWidth(FONT_SUBSCREEN, app->messages.flavorStrs[i], 0);
Text_AddPrinterWithParamsAndColor(
&app->windows[7 + i],
FONT_SUBSCREEN,
app->messages.flavorStrs[i],
width / 2,
yOffsets[i],
TEXT_SPEED_INSTANT,
buttonTextColor,
NULL);
}
}

View File

@@ -1,17 +1,15 @@
#include "overlay079/ov79_021D2268.h"
#include "applications/poffin_case/ov79_021D2268.h"
#include <nitro.h>
#include <string.h>
#include "struct_defs/struct_020158A8.h"
#include "struct_defs/struct_02098DE8.h"
#include "struct_defs/struct_0209903C.h"
#include "struct_defs/struct_0209916C.h"
#include "struct_defs/struct_02099F80.h"
#include "overlay079/ov79_021D3768.h"
#include "overlay079/struct_ov79_021D3820.h"
#include "overlay079/struct_ov79_021D38D0.h"
#include "applications/poffin_case/main.h"
#include "applications/poffin_case/ov79_021D3768.h"
#include "applications/poffin_case/struct_ov79_021D3820.h"
#include "applications/poffin_case/struct_ov79_021D38D0.h"
#include "bg_window.h"
#include "communication_system.h"
@@ -22,6 +20,8 @@
#include "message.h"
#include "narc.h"
#include "overlay_manager.h"
#include "poffin_sprite.h"
#include "poffin_types.h"
#include "pokemon.h"
#include "pokemon_sprite.h"
#include "render_oam.h"
@@ -38,8 +38,6 @@
#include "text.h"
#include "unk_020393C8.h"
#include "unk_0208C098.h"
#include "unk_020989DC.h"
#include "unk_02098FFC.h"
#include "vram_transfer.h"
typedef struct {
@@ -93,13 +91,13 @@ typedef struct {
u16 unk_0C;
u16 unk_0E;
UnkStruct_02098DE8 *unk_10;
UnkStruct_020158A8 *unk_14;
PoffinTypeList *unk_14;
MessageLoader *unk_18;
UnkStruct_ov79_021D2928_sub1 unk_1C;
UnkStruct_ov79_021D38D0 unk_30;
UnkStruct_ov79_021D3820 unk_40;
UnkStruct_0209903C *unk_5C;
UnkStruct_0209916C *unk_60[2];
PoffinSpriteManager *unk_5C;
PoffinSprite *unk_60[2];
BgConfig *unk_68;
Window unk_6C;
SpriteSystem *unk_7C;
@@ -184,7 +182,7 @@ int ov79_021D22E4(ApplicationManager *appMan, int *param1)
if ((*param1 >= 2) && (*param1 <= 5)) {
ov79_021D3820(&v0->unk_40);
sub_02099160(v0->unk_5C);
PoffinSpriteManager_DrawSprites(v0->unk_5C);
}
switch (*param1) {
@@ -548,10 +546,10 @@ static void ov79_021D2864(UnkStruct_ov79_021D2928 *param0)
RenderOam_ClearMain(param0->heapID);
}
param0->unk_5C = sub_02098FFC(param0->heapID, 2, 2, NNS_G2D_VRAM_TYPE_2DMAIN, 0);
param0->unk_60[0] = sub_0209916C(param0->unk_5C, param0->unk_10->unk_08, 100, 90, 0, 1, 0, 0);
param0->unk_5C = PoffinSpriteManager_New(param0->heapID, 2, 2, NNS_G2D_VRAM_TYPE_2DMAIN, 0);
param0->unk_60[0] = PoffinSprite_New(param0->unk_5C, param0->unk_10->unk_08, 100, 90, 0, 1, 0, 0);
ManagedSprite_SetDrawFlag(param0->unk_60[0]->unk_04, 0);
ManagedSprite_SetDrawFlag(param0->unk_60[0]->sprite, 0);
if (CommSys_IsInitialized()) {
sub_02039734();
@@ -562,8 +560,8 @@ static void ov79_021D2864(UnkStruct_ov79_021D2928 *param0)
static void ov79_021D2908(UnkStruct_ov79_021D2928 *param0)
{
sub_02099370(param0->unk_5C, param0->unk_60[0]);
sub_0209903C(param0->unk_5C);
PoffinSprite_Free(param0->unk_5C, param0->unk_60[0]);
PoffinSpriteManager_Free(param0->unk_5C);
SpriteSystem_Free(param0->unk_7C);
VramTransfer_Free();
}
@@ -632,7 +630,7 @@ static int ov79_021D2A04(UnkStruct_ov79_021D2928 *param0, UnkStruct_ov79_021D29B
MI_CpuClear8(param1, sizeof(UnkStruct_ov79_021D29B4));
param1->unk_C4 = param0->unk_60[0]->unk_04->sprite;
param1->unk_C4 = param0->unk_60[0]->sprite->sprite;
param1->unk_C8 = param0->unk_40.unk_18;
param1->unk_08 = param0->unk_30.unk_09;
param1->unk_00 = 24;

View File

@@ -1,10 +1,10 @@
#include "overlay079/ov79_021D3768.h"
#include "applications/poffin_case/ov79_021D3768.h"
#include <nitro.h>
#include <string.h>
#include "overlay079/struct_ov79_021D3820.h"
#include "overlay079/struct_ov79_021D38D0.h"
#include "applications/poffin_case/struct_ov79_021D3820.h"
#include "applications/poffin_case/struct_ov79_021D38D0.h"
#include "camera.h"
#include "gx_layers.h"
@@ -79,15 +79,15 @@ static void ov79_021D3870(UnkStruct_ov79_021D3820 *param0, int param1)
static void ov79_021D38D0(UnkStruct_ov79_021D3820 *param0, UnkStruct_ov79_021D38D0 *param1, int heapID)
{
PokemonSpriteTemplate v0;
PokemonSprite *v1;
PokemonSpriteTemplate spriteTemplate;
PokemonSprite *sprite;
param0->unk_04 = PokemonSpriteManager_New(heapID);
Pokemon_BuildSpriteTemplate(&v0, param1->unk_00, 2);
Pokemon_BuildSpriteTemplate(&spriteTemplate, param1->unk_00, 2);
v1 = PokemonSpriteManager_CreateSprite(param0->unk_04, &v0, 128, 96, 0, 0, NULL, NULL);
PokemonSprite_SetAttribute(v1, MON_SPRITE_FLIP_H, param1->unk_08);
sprite = PokemonSpriteManager_CreateSprite(param0->unk_04, &spriteTemplate, 128, 96, 0, 0, NULL, NULL);
PokemonSprite_SetAttribute(sprite, MON_SPRITE_FLIP_H, param1->unk_08);
param0->unk_18 = v1;
param0->unk_18 = sprite;
}

View File

@@ -0,0 +1,96 @@
#include "applications/poffin_case/sprites.h"
#include <nitro.h>
#include "communication_system.h"
#include "gx_layers.h"
#include "poffin_sprite.h"
#include "render_oam.h"
#include "sprite.h"
#include "sprite_system.h"
#include "unk_020393C8.h"
#include "vram_transfer.h"
void PoffinManager_InitSpriteSystem(PoffinManager *param0);
void PoffinManager_FreeSpriteSystem(PoffinManager *param0);
void PoffinManager_UpdateSprites(PoffinManager *param0);
void PoffinManager_InitSpriteSystem(PoffinManager *app)
{
VramTransfer_New(32, app->heapID);
app->spriteSys = SpriteSystem_Alloc(app->heapID);
app->spriteMan = SpriteManager_New(app->spriteSys);
RenderOamTemplate oamTemplate = {
0,
128,
0,
32,
0,
128,
0,
32,
};
CharTransferTemplateWithModes charTransferTemplate = {
3,
1024,
1024,
GX_OBJVRAMMODE_CHAR_1D_32K,
GX_OBJVRAMMODE_CHAR_1D_32K,
};
SpriteSystem_Init(app->spriteSys, &oamTemplate, &charTransferTemplate, 32);
SpriteSystem_InitSprites(app->spriteSys, app->spriteMan, NUM_LIST_SPRITES + 2 * FLAVOR_MAX + 1);
RenderOam_ClearMain(app->heapID);
RenderOam_ClearSub(app->heapID);
SpriteResourceDataPaths resourcePaths = {
"data/porucase_chr.resdat",
"data/porucase_pal.resdat",
"data/porucase_cell.resdat",
"data/porucase_canm.resdat",
NULL,
NULL,
"data/porucase_celact.cldat"
};
SpriteSystem_LoadResourceDataFromFilepaths(app->spriteSys, app->spriteMan, &resourcePaths);
app->poffinSpriteMan = PoffinSpriteManager_New(app->heapID, 1, 1, NNS_G2D_VRAM_TYPE_2DMAIN, 0);
if (CommSys_IsInitialized()) {
sub_02039734();
}
GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, TRUE);
GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, TRUE);
}
void PoffinManager_FreeSpriteSystem(PoffinManager *app)
{
PoffinSpriteManager_Free(app->poffinSpriteMan);
SpriteSystem_DestroySpriteManager(app->spriteSys, app->spriteMan);
SpriteSystem_Free(app->spriteSys);
VramTransfer_Free();
}
void PoffinManager_UpdateSprites(PoffinManager *app)
{
SpriteSystem_DrawSprites(app->spriteMan);
PoffinSpriteManager_DrawSprites(app->poffinSpriteMan);
}
void PoffinCaseApp_UpdateListSprites(PoffinManager *app, BOOL actionMenuOpen)
{
if (!actionMenuOpen) {
Sprite_SetExplicitPalette(app->listSprites[LIST_SPRITE_SELECT_BOX], 0);
Sprite_SetAnimateFlag(app->listSprites[1], TRUE);
Sprite_SetAnimateFlag(app->listSprites[2], TRUE);
} else {
Sprite_SetExplicitPalette(app->listSprites[LIST_SPRITE_SELECT_BOX], 9);
Sprite_SetAnimateFlag(app->listSprites[1], FALSE);
Sprite_SetAnimateFlag(app->listSprites[2], FALSE);
}
}

View File

@@ -12,6 +12,7 @@
#include "struct_defs/struct_02099F80.h"
#include "applications/poffin_case/main.h"
#include "applications/pokemon_summary_screen/3d_anim.h"
#include "applications/pokemon_summary_screen/main.h"
#include "applications/pokemon_summary_screen/sprites.h"
@@ -53,7 +54,6 @@
#include "unk_020393C8.h"
#include "unk_0208C098.h"
#include "unk_02094EDC.h"
#include "unk_020989DC.h"
#include "vars_flags.h"
#include "vram_transfer.h"

View File

@@ -7,12 +7,12 @@
#include "constants/savedata/vars_flags.h"
#include "struct_decls/struct_02061AB4_decl.h"
#include "struct_defs/struct_0203D9B8.h"
#include "struct_defs/struct_020708E0.h"
#include "struct_defs/struct_02097728.h"
#include "applications/party_menu/defs.h"
#include "applications/party_menu/main.h"
#include "applications/poffin_case/main.h"
#include "field/field_system.h"
#include "overlay005/fieldmap.h"
#include "overlay005/fishing.h"
@@ -61,7 +61,6 @@
#include "unk_020553DC.h"
#include "unk_0205F180.h"
#include "unk_0206B9D8.h"
#include "unk_020989DC.h"
#include "vars_flags.h"
#include "res/text/bank/location_names.h"
@@ -602,9 +601,9 @@ static void UsePoffinCaseFromMenu(ItemMenuUseContext *usageContext, const ItemUs
{
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(usageContext->fieldTask);
StartMenu *menu = FieldTask_GetEnv(usageContext->fieldTask);
UnkStruct_0203D9B8 *v2 = sub_0203D9B8(fieldSystem, HEAP_ID_FIELD2);
PoffinCaseAppData *poffinCase = FieldSystem_LaunchPoffinCaseApp(fieldSystem, HEAP_ID_FIELD2);
menu->taskData = v2;
menu->taskData = poffinCase;
sub_0203B674(menu, sub_0203C710);
}
@@ -616,7 +615,7 @@ static BOOL UsePoffinCaseInField(ItemFieldUseContext *usageContext)
static void *sub_02068B9C(void *some_param)
{
return sub_0203D9B8(some_param, HEAP_ID_FIELD2);
return FieldSystem_LaunchPoffinCaseApp(some_param, HEAP_ID_FIELD2);
}
static void UsePalPadFromMenu(ItemMenuUseContext *usageContext, const ItemUseContext *additionalContext)
@@ -1136,7 +1135,7 @@ static BOOL RegisteredItem_GoToApp(FieldTask *task)
if (v1->unk_24 != NULL) {
if (v1->unk_20 == sub_02068B9C) {
sub_02098AF0(v1->unk_24);
PoffinCaseAppData_Free(v1->unk_24);
} else {
Heap_Free(v1->unk_24);
}

View File

@@ -55,7 +55,7 @@ pokeplatinum_c = files(
'unk_02014D38.c',
'software_sprite.c',
'unk_0201567C.c',
'unk_020158A8.c',
'poffin_types.c',
'unk_02015920.c',
'pokemon_anim.c',
'unk_02017038.c',
@@ -326,8 +326,8 @@ pokeplatinum_c = files(
'pokedex_language.c',
'pokedex_heightweight.c',
'pokedex_data_index.c',
'unk_020989DC.c',
'unk_02098FFC.c',
'applications/poffin_case/main.c',
'poffin_sprite.c',
'unk_02099500.c',
'unk_02099550.c',
'unk_02099604.c',
@@ -815,11 +815,11 @@ pokeplatinum_c = files(
'game_opening/ov77_021D6670.c',
'game_opening/ov77_021D6C70.c',
'choose_starter/choose_starter_app.c',
'overlay079/ov79_021D0D80.c',
'overlay079/ov79_021D183C.c',
'overlay079/ov79_021D20F4.c',
'overlay079/ov79_021D2268.c',
'overlay079/ov79_021D3768.c',
'applications/poffin_case/manager.c',
'applications/poffin_case/menus.c',
'applications/poffin_case/sprites.c',
'applications/poffin_case/ov79_021D2268.c',
'applications/poffin_case/ov79_021D3768.c',
'applications/town_map/main.c',
'applications/town_map/graphics.c',
'applications/town_map/sprites.c',

View File

@@ -1,811 +0,0 @@
#include "overlay079/ov79_021D0D80.h"
#include <nitro.h>
#include <string.h>
#include "struct_defs/struct_0203D9B8.h"
#include "struct_defs/struct_02099F80.h"
#include "overlay079/ov79_021D183C.h"
#include "overlay079/ov79_021D20F4.h"
#include "overlay079/struct_ov79_021D0E1C.h"
#include "bg_window.h"
#include "font.h"
#include "game_options.h"
#include "gx_layers.h"
#include "heap.h"
#include "list_menu.h"
#include "menu.h"
#include "message.h"
#include "narc.h"
#include "overlay_manager.h"
#include "render_window.h"
#include "screen_fade.h"
#include "sound_playback.h"
#include "sprite.h"
#include "sprite_system.h"
#include "string_gf.h"
#include "string_template.h"
#include "system.h"
#include "text.h"
#include "touch_pad.h"
#include "touch_screen.h"
#include "unk_020158A8.h"
#include "unk_0208C098.h"
#include "unk_02098FFC.h"
#include "vram_transfer.h"
#include "res/graphics/poffin_case/poru_gra.naix.h"
typedef int (*UnkFuncPtr_ov79_021D394C)(UnkStruct_ov79_021D0E1C *);
int ov79_021D0D80(ApplicationManager *appMan, int *param1);
int ov79_021D0DC4(ApplicationManager *appMan, int *param1);
int ov79_021D0DDC(ApplicationManager *appMan, int *param1);
static int ov79_021D0E1C(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D122C(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D12A0(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D130C(void);
static void ov79_021D132C(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D13A4(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D13C4(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D14A0(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D14A4(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D1548(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D1568(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D1618(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D167C(UnkStruct_ov79_021D0E1C *param0);
static void ov79_021D17E8(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D0FEC(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D10A0(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D10B8(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D114C(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D116C(UnkStruct_ov79_021D0E1C *param0);
static int ov79_021D11C0(UnkStruct_ov79_021D0E1C *param0);
static const UnkFuncPtr_ov79_021D394C Unk_ov79_021D394C[] = {
ov79_021D0FEC,
ov79_021D10A0,
ov79_021D10B8,
ov79_021D114C,
ov79_021D116C,
ov79_021D11C0
};
int ov79_021D0D80(ApplicationManager *appMan, int *param1)
{
UnkStruct_ov79_021D0E1C *v0 = NULL;
UnkStruct_0203D9B8 *v1 = ApplicationManager_Args(appMan);
Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_45, 0x20000);
v0 = ApplicationManager_NewData(appMan, sizeof(UnkStruct_ov79_021D0E1C), HEAP_ID_45);
MI_CpuClear8(v0, sizeof(UnkStruct_ov79_021D0E1C));
v0->heapID = HEAP_ID_45;
v0->unk_20 = v1;
v0->unk_1B = v1->unk_03;
v0->unk_14 = 0xFFFF;
return 1;
}
int ov79_021D0DC4(ApplicationManager *appMan, int *param1)
{
UnkStruct_ov79_021D0E1C *v0 = (UnkStruct_ov79_021D0E1C *)ApplicationManager_Data(appMan);
if (ov79_021D0E1C(v0)) {
return 1;
}
return 0;
}
int ov79_021D0DDC(ApplicationManager *appMan, int *param1)
{
UnkStruct_ov79_021D0E1C *v0 = (UnkStruct_ov79_021D0E1C *)ApplicationManager_Data(appMan);
v0->unk_20->unk_01 = v0->unk_1A;
v0->unk_20->unk_02 = v0->unk_10;
v0->unk_20->unk_03 = v0->unk_1B;
v0->unk_20->unk_04 = v0->unk_80;
v0->unk_20->unk_06 = v0->unk_82;
ApplicationManager_FreeData(appMan);
Heap_Destroy(v0->heapID);
return 1;
}
static int ov79_021D0E1C(UnkStruct_ov79_021D0E1C *param0)
{
switch (param0->unk_04) {
case 0:
SetVBlankCallback(NULL, NULL);
DisableHBlank();
GXLayers_DisableEngineALayers();
GXLayers_DisableEngineBLayers();
GX_SetVisiblePlane(0);
GXS_SetVisiblePlane(0);
SetScreenColorBrightness(DS_SCREEN_MAIN, COLOR_BLACK);
SetScreenColorBrightness(DS_SCREEN_SUB, COLOR_BLACK);
ResetVisibleHardwareWindows(DS_SCREEN_MAIN);
ResetVisibleHardwareWindows(DS_SCREEN_SUB);
EnableTouchPad();
InitializeTouchPad(4);
break;
case 1:
if (!ov79_021D122C(param0)) {
return 0;
}
param0->unk_0C = 0;
StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_IN, FADE_TYPE_BRIGHTNESS_IN, COLOR_BLACK, 6, 1, param0->heapID);
break;
case 2:
ov79_021D21F8(param0);
if (!IsScreenFadeDone()) {
return 0;
}
break;
case 3:
ov79_021D21F8(param0);
if ((Unk_ov79_021D394C[param0->unk_18])(param0) == 0) {
return 0;
}
param0->unk_0C = 0;
StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_OUT, FADE_TYPE_BRIGHTNESS_OUT, COLOR_BLACK, 6, 1, param0->heapID);
break;
case 4:
ov79_021D21F8(param0);
if (!IsScreenFadeDone()) {
return 0;
}
break;
case 5:
if (!ov79_021D12A0(param0)) {
return 0;
}
break;
case 6:
DisableTouchPad();
SetScreenColorBrightness(DS_SCREEN_MAIN, COLOR_BLACK);
SetScreenColorBrightness(DS_SCREEN_SUB, COLOR_BLACK);
SetVBlankCallback(NULL, NULL);
GXLayers_DisableEngineALayers();
GXLayers_DisableEngineBLayers();
GX_SetVisiblePlane(0);
GXS_SetVisiblePlane(0);
break;
default:
return 1;
}
param0->unk_04++;
return 0;
}
static void ov79_021D0F7C(void *param0)
{
UnkStruct_ov79_021D0E1C *v0 = (UnkStruct_ov79_021D0E1C *)param0;
if (v0->unk_1B8 != NULL) {
SpriteSystem_TransferOam();
}
VramTransfer_Process();
Bg_RunScheduledUpdates(v0->unk_24);
OS_SetIrqCheckFlag(OS_IE_V_BLANK);
}
static int ov79_021D0FB0(UnkStruct_ov79_021D0E1C *param0)
{
int v0;
u16 v1;
static const TouchScreenRect v2[] = {
{ 0x22, 0x3E, 0x60, 0xA0 },
{ 0x52, 0x6E, 0xA0, 0xE0 },
{ 0x94, 0xB0, 0x88, 0xC8 },
{ 0x96, 0xB2, 0x38, 0x78 },
{ 0x52, 0x6E, 0x20, 0x60 },
{ 0x66, 0x82, 0x60, 0xA0 },
{ 0xFF, 0x0, 0x0, 0x0 }
};
v0 = TouchScreen_CheckRectanglePressed(v2);
if (v0 != 0xffffffff) {
return v0;
}
v0 = TouchScreen_CheckRectangleHeld(v2);
if (v0 == 0xffffffff) {
if (param0->unk_14 == 1) {
ov79_021D1B24(param0, param0->unk_1B, 2);
}
}
return -1;
}
static int ov79_021D0FEC(UnkStruct_ov79_021D0E1C *param0)
{
u32 v0 = 0xffffffff;
int v1 = 0;
if (param0->unk_C4 == NULL) {
return 0;
}
v1 = ov79_021D0FB0(param0);
if (gSystem.heldKeys != 0) {
if (param0->unk_14 == 0) {
v0 = ListMenu_ProcessInput(param0->unk_C4);
}
} else {
if (v1 >= 0) {
ov79_021D1C44(param0, (u8)v1);
}
return 0;
}
if (v0 == 0xffffffff) {
return 0;
}
if (gSystem.pressedKeys & PAD_BUTTON_B) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
param0->unk_1A = 0xFF;
param0->unk_10 = 0;
return 1;
}
if (gSystem.pressedKeys & PAD_BUTTON_A) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
switch (v0) {
case 0xffffffff:
case 0xfffffffe:
case 0xFF:
param0->unk_1A = 0xFF;
param0->unk_10 = 0;
return 1;
default:
param0->unk_1A = v0;
param0->unk_18 = 1;
return 0;
}
}
return 0;
}
static int ov79_021D10A0(UnkStruct_ov79_021D0E1C *param0)
{
u32 v0;
ov79_021D2214(param0, 1);
ov79_021D1ED8(param0);
param0->unk_18 = 2;
return 0;
}
static int ov79_021D10B8(UnkStruct_ov79_021D0E1C *param0)
{
u32 v0 = ListMenu_ProcessInput(param0->unk_C8);
if (gSystem.pressedKeys & PAD_BUTTON_B) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
ov79_021D1F60(param0);
ov79_021D2214(param0, 0);
param0->unk_18 = 0;
return 0;
}
if (gSystem.pressedKeys & PAD_BUTTON_A) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
switch (v0) {
case 0:
param0->unk_10 = 1;
return 1;
case 1:
ov79_021D1F60(param0);
ov79_021D1FBC(param0);
param0->unk_18 = 3;
break;
case 0xffffffff:
case 0xfffffffe:
default:
ov79_021D1F60(param0);
ov79_021D2214(param0, 0);
param0->unk_18 = 0;
break;
}
}
return 0;
}
static int ov79_021D114C(UnkStruct_ov79_021D0E1C *param0)
{
if (Text_IsPrinterActive(param0->unk_1F)) {
return 0;
}
ov79_021D2054(param0);
param0->unk_18 = 4;
return 0;
}
static int ov79_021D116C(UnkStruct_ov79_021D0E1C *param0)
{
switch (Menu_ProcessInputAndHandleExit(param0->unk_D4, param0->heapID)) {
case 0:
Sound_PlayEffect(SEQ_SE_CONFIRM);
ov79_021D2008(param0);
param0->unk_18 = 5;
return 0;
case 0xfffffffe:
Sound_PlayEffect(SEQ_SE_CONFIRM);
Window_EraseMessageBox(&param0->unk_E8[2], 0);
param0->unk_18 = 1;
return 0;
}
return 0;
}
static int ov79_021D11C0(UnkStruct_ov79_021D0E1C *param0)
{
if (Text_IsPrinterActive(param0->unk_1F)) {
return 0;
}
if ((gSystem.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) == 0) {
return 0;
}
Window_EraseMessageBox(&param0->unk_E8[2], 1);
Window_ClearAndCopyToVRAM(&param0->unk_E8[2]);
param0->unk_20->unk_1C[param0->unk_1A].unk_04_val1_6 = 1;
param0->unk_20->unk_02 = 1;
ov79_021D1AB8(param0, 0);
ov79_021D196C(param0);
ov79_021D2214(param0, 0);
param0->unk_18 = 0;
return 0;
}
static int ov79_021D122C(UnkStruct_ov79_021D0E1C *param0)
{
switch (param0->unk_08) {
case 0:
ov79_021D132C(param0);
break;
case 1:
ov79_021D13C4(param0);
break;
case 2:
ov79_021D1568(param0);
ov79_021D14A4(param0);
break;
case 3:
ov79_021D20F4(param0);
break;
case 4:
ov79_021D167C(param0);
break;
case 5:
ov79_021D196C(param0);
ov79_021D1B24(param0, param0->unk_1B, 4);
SetVBlankCallback(ov79_021D0F7C, param0);
param0->unk_08 = 0;
return 1;
}
param0->unk_08++;
return 0;
}
static int ov79_021D12A0(UnkStruct_ov79_021D0E1C *param0)
{
switch (param0->unk_08) {
case 0:
if (param0->unk_D0 != NULL) {
ov79_021D1F60(param0);
}
ov79_021D1AB8(param0, 1);
break;
case 1:
ov79_021D17E8(param0);
ov79_021D21CC(param0);
break;
case 2:
ov79_021D1548(param0);
ov79_021D1618(param0);
break;
case 3:
ov79_021D14A0(param0);
break;
case 4:
ov79_021D13A4(param0);
break;
case 5:
return 1;
}
param0->unk_08++;
return 0;
}
static void ov79_021D130C(void)
{
UnkStruct_02099F80 v0 = {
GX_VRAM_BG_128_A,
GX_VRAM_BGEXTPLTT_NONE,
GX_VRAM_SUB_BG_128_C,
GX_VRAM_SUB_BGEXTPLTT_NONE,
GX_VRAM_OBJ_64_E,
GX_VRAM_OBJEXTPLTT_NONE,
GX_VRAM_SUB_OBJ_16_I,
GX_VRAM_SUB_OBJEXTPLTT_NONE,
GX_VRAM_TEX_NONE,
GX_VRAM_TEXPLTT_NONE
};
GXLayers_SetBanks(&v0);
}
static void ov79_021D132C(UnkStruct_ov79_021D0E1C *param0)
{
int v0, v1;
ov79_021D130C();
param0->unk_24 = BgConfig_New(param0->heapID);
{
GraphicsModes v2 = {
GX_DISPMODE_GRAPHICS,
GX_BGMODE_0,
GX_BGMODE_0,
GX_BG0_AS_2D
};
SetAllGraphicsModes(&v2);
}
{
BgTemplate v3[] = {
{
.x = 0x0,
.y = 0x0,
.bufferSize = 0x800,
.baseTile = 0x0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf800,
.charBase = GX_BG_CHARBASE_0x00000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0x0,
.areaOver = 0x0,
.mosaic = FALSE,
},
{
.x = 0x0,
.y = 0x0,
.bufferSize = 0x800,
.baseTile = 0x0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf000,
.charBase = GX_BG_CHARBASE_0x10000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0x1,
.areaOver = 0x0,
.mosaic = FALSE,
},
{
.x = 0x0,
.y = 0x0,
.bufferSize = 0x800,
.baseTile = 0x0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xe800,
.charBase = GX_BG_CHARBASE_0x10000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0x3,
.areaOver = 0x0,
.mosaic = FALSE,
},
{
.x = 0x0,
.y = 0x0,
.bufferSize = 0x800,
.baseTile = 0x0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xe000,
.charBase = GX_BG_CHARBASE_0x00000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0x3,
.areaOver = 0x0,
.mosaic = FALSE,
},
{
.x = 0x0,
.y = 0x0,
.bufferSize = 0x800,
.baseTile = 0x0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf800,
.charBase = GX_BG_CHARBASE_0x10000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0x0,
.areaOver = 0x0,
.mosaic = FALSE,
},
{
.x = 0x0,
.y = 0x0,
.bufferSize = 0x800,
.baseTile = 0x0,
.screenSize = BG_SCREEN_SIZE_256x256,
.colorMode = GX_BG_COLORMODE_16,
.screenBase = GX_BG_SCRBASE_0xf000,
.charBase = GX_BG_CHARBASE_0x00000,
.bgExtPltt = GX_BG_EXTPLTT_01,
.priority = 0x1,
.areaOver = 0x0,
.mosaic = FALSE,
},
};
v1 = 0;
for (v0 = 0; v0 < 6; v0++) {
Bg_InitFromTemplate(param0->unk_24, v1, &(v3[v0]), 0);
Bg_ClearTilemap(param0->unk_24, v1);
Bg_ClearTilesRange(v1, 32, 0, param0->heapID);
++v1;
}
}
}
static void ov79_021D13A4(UnkStruct_ov79_021D0E1C *param0)
{
int v0;
for (v0 = 0; v0 < 6; v0++) {
Bg_FreeTilemapBuffer(param0->unk_24, v0);
}
Heap_Free(param0->unk_24);
}
static void ov79_021D13C4(UnkStruct_ov79_021D0E1C *param0)
{
NARC *poru_gra = NARC_ctor(NARC_INDEX_GRAPHIC__PORU_GRA, param0->heapID);
App_LoadGraphicMember(param0->unk_24, param0->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, main_tiles_NCGR, BG_LAYER_MAIN_0, GRAPHICSMEMBER_TILES, 0, 0);
App_LoadGraphicMember(param0->unk_24, param0->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, sub_tiles_NCGR, BG_LAYER_SUB_1, GRAPHICSMEMBER_TILES, 0, 0);
App_LoadGraphicMember(param0->unk_24, param0->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, background_NCLR, BG_LAYER_MAIN_0, GRAPHICSMEMBER_PALETTE, 0x20 * 0xC, 0);
App_LoadGraphicMember(param0->unk_24, param0->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, background_NCLR, BG_LAYER_SUB_0, GRAPHICSMEMBER_PALETTE, 0x20 * 0xC, 0);
App_LoadGraphicMember(param0->unk_24, param0->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, main_tilemap_NSCR, BG_LAYER_MAIN_3, GRAPHICSMEMBER_TILEMAP, 0, 0);
App_LoadGraphicMember(param0->unk_24, param0->heapID, poru_gra, NARC_INDEX_GRAPHIC__PORU_GRA, sub_tilemap_NSCR, BG_LAYER_SUB_1, GRAPHICSMEMBER_TILEMAP, 0, 0);
NARC_dtor(poru_gra);
Bg_ScheduleTilemapTransfer(param0->unk_24, BG_LAYER_MAIN_3);
Bg_ScheduleTilemapTransfer(param0->unk_24, BG_LAYER_SUB_1);
}
static void ov79_021D14A0(UnkStruct_ov79_021D0E1C *param0)
{
return;
}
static void ov79_021D14A4(UnkStruct_ov79_021D0E1C *param0)
{
int v0;
static const struct {
u8 unk_00, unk_01, unk_02, unk_03, unk_04, unk_05;
u16 unk_06;
} v1[] = {
{ 0x2, 0x2, 0x4, 0x16, 0xC, 0xD, 0x28 },
{ 0x2, 0xB, 0x14, 0xA, 0x2, 0xD, 0x131 },
{ 0x1, 0x2, 0x13, 0x1B, 0x4, 0xC, 0x145 },
{ 0x1, 0x1A, 0x11, 0x5, 0x6, 0xD, 0x1B1 },
{ 0x1, 0x1A, 0xD, 0x5, 0x4, 0xD, 0x1CF },
{ 0x1, 0x0, 0x0, 0x10, 0x2, 0xD, 0x1E3 },
{ 0x4, 0x6, 0x0, 0x14, 0x3, 0xD, 0x1 },
{ 0x4, 0xC, 0x5, 0x8, 0x3, 0x5, 0x41 },
{ 0x4, 0x14, 0xA, 0x8, 0x3, 0x6, 0x59 },
{ 0x4, 0x11, 0x13, 0x8, 0x3, 0x7, 0x71 },
{ 0x4, 0x7, 0x13, 0x8, 0x3, 0x8, 0x89 },
{ 0x4, 0x4, 0xA, 0x8, 0x3, 0x9, 0xA1 },
{ 0x4, 0xC, 0xD, 0x8, 0x3, 0xA, 0xB9 }
};
LoadStandardWindowGraphics(param0->unk_24, BG_LAYER_MAIN_1, 1 + 18 + 12, 15, 0, param0->heapID);
LoadMessageBoxGraphics(param0->unk_24, BG_LAYER_MAIN_1, 1, 14, Options_Frame(param0->unk_20->options), param0->heapID);
Font_LoadTextPalette(0, 13 * 32, param0->heapID);
Font_LoadScreenIndicatorsPalette(0, 12 * 32, param0->heapID);
Font_LoadTextPalette(4, 13 * 32, param0->heapID);
for (v0 = 0; v0 < 13; v0++) {
Window_Add(param0->unk_24, &param0->unk_E8[v0], v1[v0].unk_00, v1[v0].unk_01, v1[v0].unk_02, v1[v0].unk_03, v1[v0].unk_04, v1[v0].unk_05, v1[v0].unk_06);
Window_FillTilemap(&(param0->unk_E8[v0]), 0);
}
ov79_021D2078(param0);
}
static void ov79_021D1548(UnkStruct_ov79_021D0E1C *param0)
{
int v0 = 0;
for (v0 = 0; v0 < 13; v0++) {
Window_ClearAndCopyToVRAM(&param0->unk_E8[v0]);
Window_Remove(&param0->unk_E8[v0]);
}
}
static void ov79_021D1568(UnkStruct_ov79_021D0E1C *param0)
{
int v0 = 0;
Font_InitManager(FONT_SUBSCREEN, param0->heapID);
param0->unk_2C = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_UNK_0463, param0->heapID);
param0->unk_28 = sub_020158A8(param0->heapID);
param0->unk_30.unk_00 = StringTemplate_New(2, 64, param0->heapID);
param0->unk_30.unk_04 = String_Init(64, param0->heapID);
param0->unk_30.unk_08 = MessageLoader_GetNewString(param0->unk_2C, 6);
param0->unk_30.unk_0C = MessageLoader_GetNewString(param0->unk_2C, 22);
param0->unk_30.unk_10 = MessageLoader_GetNewString(param0->unk_2C, 4);
param0->unk_30.unk_14 = MessageLoader_GetNewString(param0->unk_2C, 7);
param0->unk_30.unk_18 = MessageLoader_GetNewString(param0->unk_2C, 8);
param0->unk_30.unk_1C = MessageLoader_GetNewString(param0->unk_2C, 0);
for (v0 = 0; v0 < 6; v0++) {
param0->unk_30.unk_20[v0] = MessageLoader_GetNewString(param0->unk_2C, 11 + v0);
if (v0 >= 5) {
break;
}
param0->unk_30.unk_38[v0] = MessageLoader_GetNewString(param0->unk_2C, 17 + v0);
}
param0->unk_30.unk_4C = Options_TextFrameDelay(param0->unk_20->options);
}
static void ov79_021D1618(UnkStruct_ov79_021D0E1C *param0)
{
int v0 = 0;
for (v0 = 0; v0 < 6; v0++) {
String_Free(param0->unk_30.unk_20[v0]);
if (v0 >= 5) {
break;
}
String_Free(param0->unk_30.unk_38[v0]);
}
String_Free(param0->unk_30.unk_1C);
String_Free(param0->unk_30.unk_18);
String_Free(param0->unk_30.unk_14);
String_Free(param0->unk_30.unk_10);
String_Free(param0->unk_30.unk_0C);
String_Free(param0->unk_30.unk_08);
String_Free(param0->unk_30.unk_04);
StringTemplate_Free(param0->unk_30.unk_00);
sub_020158F4(param0->unk_28);
MessageLoader_Free(param0->unk_2C);
Font_Free(FONT_SUBSCREEN);
}
static void ov79_021D167C(UnkStruct_ov79_021D0E1C *param0)
{
int v0;
static const SpriteTemplateFromResourceHeader v1[] = {
{ 0x0, 0x69, 0x28, 0x0, 0x0, 0x1, 0x0, NNS_G2D_VRAM_TYPE_2DMAIN, 0x0, 0x0, 0x0, 0x0 },
{ 0x0, 0x50, 0x12, 0x0, 0x1, 0x2, 0x0, NNS_G2D_VRAM_TYPE_2DMAIN, 0x0, 0x0, 0x0, 0x0 },
{ 0x0, 0x50, 0x8C, 0x0, 0x2, 0x2, 0x0, NNS_G2D_VRAM_TYPE_2DMAIN, 0x0, 0x0, 0x0, 0x0 },
{ 0x0, 0xA, 0x64, 0x0, 0x3, 0x3, 0x1, NNS_G2D_VRAM_TYPE_2DMAIN, 0x0, 0x0, 0x0, 0x0 },
{ 0x1, 0xA, 0x64, 0x0, 0x0, 0x1, 0x2, NNS_G2D_VRAM_TYPE_2DSUB, 0x0, 0x0, 0x0, 0x0 }
};
for (v0 = 0; v0 < 3; v0++) {
param0->unk_1C0[v0] = SpriteSystem_NewSpriteFromResourceHeader(param0->unk_1B8, param0->unk_1BC, &v1[v0]);
Sprite_SetDrawFlag(param0->unk_1C0[v0], TRUE);
}
Sprite_SetAnimateFlag(param0->unk_1C0[0], 0);
Sprite_SetAnimateFlag(param0->unk_1C0[1], 1);
Sprite_SetAnimateFlag(param0->unk_1C0[2], 1);
for (v0 = 0; v0 < 5; v0++) {
static const struct {
u16 unk_00, unk_02;
} v2[] = {
{ 0x28, 0x9C },
{ 0x36, 0xA5 },
{ 0x31, 0xB4 },
{ 0x1F, 0xB4 },
{ 0x1A, 0xA5 }
};
param0->unk_1CC[v0] = SpriteSystem_NewSpriteFromResourceHeader(param0->unk_1B8, param0->unk_1BC, &v1[3]);
Sprite_SetDrawFlag(param0->unk_1CC[v0], TRUE);
Sprite_SetAnim(param0->unk_1CC[v0], v0 + 3);
Sprite_SetPositionXY(param0->unk_1CC[v0], v2[v0].unk_00, v2[v0].unk_02);
}
for (v0 = 0; v0 < 6; v0++) {
static const struct {
u16 unk_00, unk_02;
} v3[] = {
{ 0x80, 0x30 },
{ 0xC0, 0x60 },
{ 0xA8, 0xA2 },
{ 0x58, 0xA4 },
{ 0x40, 0x60 },
{ 0x80, 0x74 }
};
param0->unk_1E0[v0] = SpriteSystem_NewSpriteFromResourceHeader(param0->unk_1B8, param0->unk_1BC, &v1[4]);
Sprite_SetDrawFlag(param0->unk_1E0[v0], TRUE);
Sprite_SetAnim(param0->unk_1E0[v0], v0 * 3);
Sprite_SetAnimSpeed(param0->unk_1E0[v0], FX32_CONST(2));
Sprite_SetExplicitPalette(param0->unk_1E0[v0], v0 + 2);
Sprite_SetAnimateFlag(param0->unk_1E0[v0], 0);
Sprite_SetPositionXY(param0->unk_1E0[v0], v3[v0].unk_00, v3[v0].unk_02);
}
param0->unk_1FC = sub_0209916C(param0->unk_1F8, 0, 231, 76, 0, 1, 0, 0);
ManagedSprite_SetDrawFlag(param0->unk_1FC->unk_04, 0);
}
static void ov79_021D17E8(UnkStruct_ov79_021D0E1C *param0)
{
int v0;
sub_02099370(param0->unk_1F8, param0->unk_1FC);
for (v0 = 0; v0 < 6; v0++) {
Sprite_Delete2(param0->unk_1E0[v0]);
}
for (v0 = 0; v0 < 5; v0++) {
Sprite_Delete2(param0->unk_1CC[v0]);
}
for (v0 = 0; v0 < 3; v0++) {
Sprite_Delete2(param0->unk_1C0[v0]);
}
}

View File

@@ -1,450 +0,0 @@
#include "overlay079/ov79_021D183C.h"
#include <nitro.h>
#include <string.h>
#include "struct_defs/struct_0203D9B8.h"
#include "struct_defs/struct_020989DC.h"
#include "overlay079/struct_ov79_021D0E1C.h"
#include "bg_window.h"
#include "font.h"
#include "list_menu.h"
#include "menu.h"
#include "render_text.h"
#include "render_window.h"
#include "sound_playback.h"
#include "sprite.h"
#include "sprite_system.h"
#include "string_gf.h"
#include "string_list.h"
#include "string_template.h"
#include "text.h"
#include "unk_020158A8.h"
#include "unk_02098FFC.h"
static void ov79_021D1D88(ListMenu *param0, u32 param1, u8 param2);
static void ov79_021D1D94(ListMenu *param0, u32 param1, u8 param2);
static void ov79_021D1FA8(ListMenu *param0, u32 param1, u8 param2);
static const ListMenuTemplate Unk_ov79_021D3BB0 = {
NULL,
ov79_021D1D94,
ov79_021D1D88,
NULL,
0x0,
0x6,
0x0,
0x8,
0x0,
0x0,
0x1,
0x0,
0x2,
0x0,
0x0,
0x1,
0x0,
0x1,
NULL
};
static const ListMenuTemplate Unk_ov79_021D3B90 = {
NULL,
ov79_021D1FA8,
NULL,
NULL,
0x0,
0x3,
0x0,
0x8,
0x0,
0x0,
0x1,
0xF,
0x2,
0x0,
0x0,
0x0,
0x0,
0x0,
NULL
};
static void ov79_021D183C(UnkStruct_020989DC *param0)
{
param0->unk_04_val1_5 = 0;
param0->unk_07 = param0->unk_06 = 0xFF;
}
static void ov79_021D1850(UnkStruct_ov79_021D0E1C *param0, String *param1, u8 param2, u8 param3)
{
u32 v0 = TEXT_COLOR(1, 2, 15);
if (param3) {
Window_DrawMessageBoxWithScrollCursor(&param0->unk_E8[2], 1, 1, 14);
}
Window_FillRectWithColor(&(param0->unk_E8[2]), ((15 << 4) | 15), 0, 0, 27 * 8, 4 * 8);
RenderControlFlags_SetCanABSpeedUpPrint(TRUE);
RenderControlFlags_SetAutoScrollFlags(AUTO_SCROLL_DISABLED);
param0->unk_1F = Text_AddPrinterWithParamsAndColor(&param0->unk_E8[2], FONT_MESSAGE, param1, 0, 0, param2, v0, NULL);
}
static u16 ov79_021D18B4(UnkStruct_0203D9B8 *param0, UnkStruct_ov79_021D0E1C *param1)
{
u16 v0, v1 = 0;
u8 v2, v3;
UnkStruct_020989DC *v4;
param1->unk_1D = param1->unk_1E = 0xFF;
if (param1->unk_1B == 5) {
v2 = 0x1F;
} else {
v2 = 1;
for (v0 = 0; v0 < param1->unk_1B; v0++) {
v2 <<= 1;
}
}
for (v0 = 0; v0 < param0->unk_00; v0++) {
v4 = &param0->unk_1C[v0];
ov79_021D183C(v4);
if ((!v4->unk_04_val1_7) || v4->unk_04_val1_6) {
continue;
}
v3 = (v4->unk_20_val2 & 0x1F);
if ((v3 & v2) == 0) {
continue;
}
v4->unk_04_val1_5 = 1;
if (param1->unk_1D == 0xFF) {
param1->unk_1D = v4->unk_05;
} else {
param0->unk_1C[param1->unk_1E].unk_07 = v4->unk_05;
}
v4->unk_06 = param1->unk_1E;
param1->unk_1E = v4->unk_05;
++v1;
}
v1 += 1;
return v1;
}
void ov79_021D196C(UnkStruct_ov79_021D0E1C *param0)
{
u8 v0 = 0, v1 = 0;
UnkStruct_020989DC *v2;
param0->unk_1C = ov79_021D18B4(param0->unk_20, param0);
param0->unk_CC = StringList_New(param0->unk_1C, param0->heapID);
for (v0 = param0->unk_1E; v0 != 0xFF; v0 = v1) {
v2 = &(param0->unk_20->unk_1C[v0]);
v1 = v2->unk_06;
StringTemplate_SetString(param0->unk_30.unk_00, 0, sub_02015918(param0->unk_28, v2->unk_02), 0, 0, GAME_LANGUAGE);
StringTemplate_SetNumber(param0->unk_30.unk_00, 1, v2->unk_01, 2, 2, 1);
StringTemplate_Format(param0->unk_30.unk_00, param0->unk_30.unk_04, param0->unk_30.unk_0C);
StringList_AddFromString(param0->unk_CC, param0->unk_30.unk_04, v2->unk_05);
}
StringList_AddFromString(param0->unk_CC, param0->unk_30.unk_08, 0xFF);
MI_CpuCopy8(&Unk_ov79_021D3BB0, &param0->unk_84, sizeof(ListMenuTemplate));
param0->unk_82 = param0->unk_20->unk_06;
param0->unk_80 = param0->unk_20->unk_04;
if (param0->unk_20->unk_02) {
if (param0->unk_80 == 0) {
if ((param0->unk_82 != 0) && (param0->unk_82 >= (param0->unk_1C - 1))) {
--param0->unk_82;
}
} else {
if (param0->unk_80 + 6 >= param0->unk_1C) {
--param0->unk_80;
}
}
param0->unk_20->unk_02 = 0;
}
param0->unk_84.window = &(param0->unk_E8[0]);
param0->unk_84.choices = param0->unk_CC;
param0->unk_84.parent = (void *)param0;
param0->unk_84.count = param0->unk_1C;
param0->unk_16 = 0;
param0->unk_C4 = ListMenu_New(&param0->unk_84, param0->unk_80, param0->unk_82, param0->heapID);
param0->unk_16 = 1;
}
void ov79_021D1AB8(UnkStruct_ov79_021D0E1C *param0, BOOL param1)
{
Window_FillRectWithColor(&(param0->unk_E8[0]), ((0 << 4) | 0), 0, 0, 22 * 8, 12 * 8);
if (param1) {
Window_ClearAndCopyToVRAM(&param0->unk_E8[0]);
}
ListMenu_Free(param0->unk_C4, &(param0->unk_80), &(param0->unk_82));
StringList_Free(param0->unk_CC);
param0->unk_20->unk_04 = param0->unk_80;
param0->unk_20->unk_06 = param0->unk_82;
param0->unk_C4 = NULL;
param0->unk_CC = NULL;
}
void ov79_021D1B24(UnkStruct_ov79_021D0E1C *param0, u8 param1, u8 param2)
{
switch (param2) {
case 0:
Sprite_SetAnim(param0->unk_1E0[param1], param1 * 3);
Sprite_SetAnimateFlag(param0->unk_1E0[param1], 0);
Window_Scroll(
&param0->unk_E8[7 + param1], 1, 2, ((0 << 4) | 0));
break;
case 1:
Sprite_RestartAnim(param0->unk_1E0[param1]);
Sprite_SetAnimateFlag(param0->unk_1E0[param1], 1);
Window_Scroll(&param0->unk_E8[7 + param1], 0, 4, ((0 << 4) | 0));
param0->unk_14 = 1;
break;
case 2:
Sprite_SetAnim(param0->unk_1E0[param1], param1 * 3 + 1);
Window_Scroll(&param0->unk_E8[7 + param1], 1, 2, ((0 << 4) | 0));
param0->unk_14 = 0;
break;
case 3:
Sprite_SetAnim(param0->unk_1E0[param1], param1 * 3 + 2);
Window_Scroll(&param0->unk_E8[7 + param1], 0, 2, ((0 << 4) | 0));
param0->unk_14 = 1;
break;
case 4:
Sprite_SetAnim(param0->unk_1E0[param1], param1 * 3 + 1);
Sprite_SetAnimateFlag(param0->unk_1E0[param1], 1);
Window_Scroll(&param0->unk_E8[7 + param1], 0, 2, ((0 << 4) | 0));
param0->unk_14 = 0;
break;
}
Window_CopyToVRAM(&param0->unk_E8[7 + param1]);
}
void ov79_021D1C44(UnkStruct_ov79_021D0E1C *param0, u8 param1)
{
int v0;
TextColor v1 = TEXT_COLOR(1, 2, 0);
Sound_PlayEffect(SEQ_SE_DP_BUTTON9);
if (param0->unk_14 != 0xFFFF) {
if (param1 == param0->unk_1B) {
ov79_021D1B24(param0, param1, 3);
return;
}
ov79_021D1B24(param0, param0->unk_1B, 0);
}
ov79_021D1B24(param0, param1, 1);
param0->unk_1B = param1;
ov79_021D1AB8(param0, 0);
param0->unk_80 = param0->unk_82 = 0;
param0->unk_20->unk_04 = param0->unk_20->unk_06 = 0;
ov79_021D196C(param0);
Window_FillRectWithColor(&(param0->unk_E8[6]), ((0 << 4) | 0), 0, 0, 20 * 8, 3 * 8);
if (param0->unk_1B == 5) {
Window_CopyToVRAM(&param0->unk_E8[6]);
return;
}
v0 = (20 * 8) - Font_CalcStringWidth(FONT_SYSTEM, param0->unk_30.unk_38[param0->unk_1B], 0);
Text_AddPrinterWithParamsAndColor(&param0->unk_E8[6], FONT_SYSTEM, param0->unk_30.unk_38[param0->unk_1B], v0 / 2, 3, TEXT_SPEED_INSTANT, v1, NULL);
}
static void ov79_021D1D20(UnkStruct_ov79_021D0E1C *param0, UnkStruct_020989DC *param1)
{
u8 v0 = 0, v1 = 0x1;
if (param1 == NULL) {
for (v0 = 0; v0 < 5; v0++) {
Sprite_SetDrawFlag(param0->unk_1CC[v0], FALSE);
}
return;
}
for (v0 = 0; v0 < 5; v0++) {
if (param1->unk_20_val2 & v1) {
Sprite_SetDrawFlag(param0->unk_1CC[v0], TRUE);
} else {
Sprite_SetDrawFlag(param0->unk_1CC[v0], FALSE);
}
v1 <<= 1;
}
}
static void ov79_021D1D88(ListMenu *param0, u32 param1, u8 param2)
{
UnkStruct_ov79_021D0E1C *v0 = (UnkStruct_ov79_021D0E1C *)ListMenu_GetAttribute(param0, 19);
TextColor v1;
v1 = TEXT_COLOR(1, 2, 0);
}
static void ov79_021D1D94(ListMenu *param0, u32 param1, u8 param2)
{
UnkStruct_ov79_021D0E1C *v0 = (UnkStruct_ov79_021D0E1C *)ListMenu_GetAttribute(param0, 19);
TextColor v1;
u16 v2, v3;
u8 v4 = 0;
v1 = TEXT_COLOR(1, 2, 0);
if (!param2) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
}
ListMenu_GetListAndCursorPos(param0, &v2, &v3);
Sprite_SetPositionXY(v0->unk_1C0[0], 105, v3 * 16 + 40);
if (v2 == 0) {
Sprite_SetDrawFlag(v0->unk_1C0[1], FALSE);
} else {
Sprite_SetDrawFlag(v0->unk_1C0[1], TRUE);
}
if (v2 < (v0->unk_1C - 6)) {
Sprite_SetDrawFlag(v0->unk_1C0[2], TRUE);
} else {
Sprite_SetDrawFlag(v0->unk_1C0[2], FALSE);
}
Window_FillRectWithColor(&(v0->unk_E8[1]), ((0 << 4) | 0), 0, 0, 10 * 8, 2 * 8);
if (param1 == 0xFF) {
ov79_021D1D20(v0, NULL);
Window_CopyToVRAM(&v0->unk_E8[1]);
ManagedSprite_SetDrawFlag(v0->unk_1FC->unk_04, 0);
return;
}
ov79_021D1D20(v0, &v0->unk_20->unk_1C[param1]);
String_Clear(v0->unk_30.unk_04);
v4 = v0->unk_20->unk_1C[param1].unk_03;
if (v4 > 99) {
v4 = 99;
}
StringTemplate_SetNumber(v0->unk_30.unk_00, 0, v4, 2, 0, 1);
StringTemplate_Format(v0->unk_30.unk_00, v0->unk_30.unk_04, v0->unk_30.unk_10);
Text_AddPrinterWithParamsAndColor(&v0->unk_E8[1], FONT_SYSTEM, v0->unk_30.unk_04, 8, 0, TEXT_SPEED_INSTANT, v1, NULL);
sub_0209933C(v0->unk_1F8, v0->unk_1FC, v0->unk_20->unk_1C[param1].unk_02);
ManagedSprite_SetDrawFlag(v0->unk_1FC->unk_04, 1);
}
void ov79_021D1ED8(UnkStruct_ov79_021D0E1C *param0)
{
u8 v0 = 0;
param0->unk_D0 = StringList_New(3, param0->heapID);
for (v0 = 0; v0 < 3; v0++) {
StringList_AddFromMessageBank(param0->unk_D0, param0->unk_2C, 1 + v0, v0);
}
MI_CpuCopy8(&Unk_ov79_021D3B90, &param0->unk_A4, sizeof(ListMenuTemplate));
param0->unk_A4.window = &(param0->unk_E8[3]);
param0->unk_A4.choices = param0->unk_D0;
param0->unk_A4.parent = (void *)param0;
param0->unk_A4.count = 3;
Window_DrawStandardFrame(&param0->unk_E8[3], 1, 1 + 18 + 12, 15);
param0->unk_C8 = ListMenu_New(&param0->unk_A4, 0, 0, param0->heapID);
}
void ov79_021D1F60(UnkStruct_ov79_021D0E1C *param0)
{
u16 v0, v1;
Window_EraseStandardFrame(&(param0->unk_E8[3]), 0);
Window_ClearAndCopyToVRAM(&param0->unk_E8[3]);
ListMenu_Free(param0->unk_C8, &v1, &v0);
StringList_Free(param0->unk_D0);
param0->unk_C8 = NULL;
param0->unk_D0 = NULL;
}
static void ov79_021D1FA8(ListMenu *param0, u32 param1, u8 param2)
{
if (!param2) {
Sound_PlayEffect(SEQ_SE_CONFIRM);
}
}
void ov79_021D1FBC(UnkStruct_ov79_021D0E1C *param0)
{
String_Clear(param0->unk_30.unk_04);
StringTemplate_SetString(param0->unk_30.unk_00, 0, sub_02015918(param0->unk_28, param0->unk_20->unk_1C[param0->unk_1A].unk_02), 2, 1, GAME_LANGUAGE);
StringTemplate_Format(param0->unk_30.unk_00, param0->unk_30.unk_04, param0->unk_30.unk_14);
ov79_021D1850(param0, param0->unk_30.unk_04, param0->unk_30.unk_4C, 1);
}
void ov79_021D2008(UnkStruct_ov79_021D0E1C *param0)
{
String_Clear(param0->unk_30.unk_04);
StringTemplate_SetString(param0->unk_30.unk_00, 0, sub_02015918(param0->unk_28, param0->unk_20->unk_1C[param0->unk_1A].unk_02), 2, 1, GAME_LANGUAGE);
StringTemplate_Format(param0->unk_30.unk_00, param0->unk_30.unk_04, param0->unk_30.unk_18);
ov79_021D1850(param0, param0->unk_30.unk_04, param0->unk_30.unk_4C, 0);
}
void ov79_021D2054(UnkStruct_ov79_021D0E1C *param0)
{
static const WindowTemplate v0 = {
1, 26, 13, 5, 4, 13, 463
};
param0->unk_D4 = Menu_MakeYesNoChoice(param0->unk_24, &v0, 1 + 18 + 12, 15, param0->heapID);
}
void ov79_021D2078(UnkStruct_ov79_021D0E1C *param0)
{
int v0, v1;
TextColor v2 = TEXT_COLOR(1, 2, 0);
TextColor v3 = TEXT_COLOR(2, 3, 1);
Text_AddPrinterWithParamsAndColor(&param0->unk_E8[5], FONT_SYSTEM, param0->unk_30.unk_1C, 4, 0, TEXT_SPEED_INSTANT, v2, NULL);
for (v1 = 0; v1 < 6; v1++) {
static const u8 v4[] = { 2, 10, 4, 6, 10, 6 };
v0 = (8 * 8) - Font_CalcStringWidth(FONT_SUBSCREEN, param0->unk_30.unk_20[v1], 0);
Text_AddPrinterWithParamsAndColor(&param0->unk_E8[7 + v1], FONT_SUBSCREEN, param0->unk_30.unk_20[v1], v0 / 2, v4[v1], TEXT_SPEED_INSTANT, v3, NULL);
}
}

View File

@@ -1,103 +0,0 @@
#include "overlay079/ov79_021D20F4.h"
#include <nitro.h>
#include <string.h>
#include "overlay079/struct_ov79_021D0E1C.h"
#include "communication_system.h"
#include "gx_layers.h"
#include "render_oam.h"
#include "sprite.h"
#include "sprite_system.h"
#include "unk_020393C8.h"
#include "unk_02098FFC.h"
#include "vram_transfer.h"
void ov79_021D20F4(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D21CC(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D21F8(UnkStruct_ov79_021D0E1C *param0);
void ov79_021D20F4(UnkStruct_ov79_021D0E1C *param0)
{
VramTransfer_New(32, param0->heapID);
param0->unk_1B8 = SpriteSystem_Alloc(param0->heapID);
param0->unk_1BC = SpriteManager_New(param0->unk_1B8);
{
RenderOamTemplate v0 = {
0,
128,
0,
32,
0,
128,
0,
32,
};
CharTransferTemplateWithModes v1 = {
3,
1024,
1024,
GX_OBJVRAMMODE_CHAR_1D_32K,
GX_OBJVRAMMODE_CHAR_1D_32K,
};
SpriteSystem_Init(param0->unk_1B8, &v0, &v1, 32);
SpriteSystem_InitSprites(param0->unk_1B8, param0->unk_1BC, 3 + 5 + 6);
RenderOam_ClearMain(param0->heapID);
RenderOam_ClearSub(param0->heapID);
}
{
SpriteResourceDataPaths v2 = {
"data/porucase_chr.resdat",
"data/porucase_pal.resdat",
"data/porucase_cell.resdat",
"data/porucase_canm.resdat",
NULL,
NULL,
"data/porucase_celact.cldat"
};
SpriteSystem_LoadResourceDataFromFilepaths(param0->unk_1B8, param0->unk_1BC, &v2);
}
param0->unk_1F8 = sub_02098FFC(param0->heapID, 1, 1, (NNS_G2D_VRAM_TYPE_2DMAIN), 0);
if (CommSys_IsInitialized()) {
sub_02039734();
}
GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1);
GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, 1);
}
void ov79_021D21CC(UnkStruct_ov79_021D0E1C *param0)
{
sub_0209903C(param0->unk_1F8);
SpriteSystem_DestroySpriteManager(param0->unk_1B8, param0->unk_1BC);
SpriteSystem_Free(param0->unk_1B8);
VramTransfer_Free();
}
void ov79_021D21F8(UnkStruct_ov79_021D0E1C *param0)
{
SpriteSystem_DrawSprites(param0->unk_1BC);
sub_02099160(param0->unk_1F8);
}
void ov79_021D2214(UnkStruct_ov79_021D0E1C *param0, BOOL param1)
{
if (param1 == 0) {
Sprite_SetExplicitPalette(param0->unk_1C0[0], 0);
Sprite_SetAnimateFlag(param0->unk_1C0[1], 1);
Sprite_SetAnimateFlag(param0->unk_1C0[2], 1);
} else {
Sprite_SetExplicitPalette(param0->unk_1C0[0], 9);
Sprite_SetAnimateFlag(param0->unk_1C0[1], 0);
Sprite_SetAnimateFlag(param0->unk_1C0[2], 0);
}
}

View File

@@ -38,6 +38,7 @@
#include "int_distance.h"
#include "math_util.h"
#include "narc.h"
#include "poffin_sprite.h"
#include "render_window.h"
#include "software_sprite.h"
#include "sound_playback.h"
@@ -51,7 +52,6 @@
#include "sys_task_manager.h"
#include "text.h"
#include "unk_02015920.h"
#include "unk_02098FFC.h"
typedef struct {
fx32 unk_00;
@@ -390,7 +390,7 @@ void ov83_0223DB4C(UnkStruct_ov83_0223DB30 *param0, UnkStruct_ov83_0223DB4C *par
for (v0 = 0; v0 < 4; v0++) {
if (param1->unk_00[v0].unk_00 != 0) {
ov83_0223D7A8(param2, &param0->unk_28[v1], v2, (70 + ((param1->unk_00[v0].unk_00) - 149)), 1, (6 + ((param1->unk_00[v0].unk_00) - 149)), 5, 4, 1000 + v0, heapID);
ov83_0223D7A8(param2, &param0->unk_28[v1], v2, 70 + ((param1->unk_00[v0].unk_00) - 149), 1, 6 + ((param1->unk_00[v0].unk_00) - 149), 5, 4, 1000 + v0, heapID);
param0->unk_08[v1] = ov83_0223D9A8(param2, &param0->unk_28[v1], 0, 0, 0, 0, heapID);
Sprite_SetDrawFlag(param0->unk_08[v1], FALSE);
@@ -680,7 +680,7 @@ void ov83_0223E260(UnkStruct_ov83_0223E244 *param0)
void ov83_0223E28C(UnkStruct_ov83_0223E244 *param0, UnkStruct_ov83_0223D784 *param1, UnkStruct_ov83_0223D95C *param2, u32 param3, u32 param4, u32 param5)
{
param0->unk_08 = ov83_0223D9A8(param1, &param2[param4], (128 * FX32_ONE), (96 * FX32_ONE), 0, 0, param3);
param0->unk_08 = ov83_0223D9A8(param1, &param2[param4], 128 * FX32_ONE , 96 * FX32_ONE , 0, 0, param3);
Sprite_SetDrawFlag(param0->unk_08, FALSE);
Sprite_SetAnim(param0->unk_08, param5);
param0->unk_00 = 1;
@@ -1049,7 +1049,7 @@ static void ov83_0223E77C(UnkStruct_ov83_0223E824 *param0, u32 heapID)
LoadMessageBoxGraphics(param0->unk_04, BG_LAYER_MAIN_2, 1, 0, param0->unk_18, heapID);
Font_LoadScreenIndicatorsPalette(0, 2 * 32, heapID);
LoadStandardWindowGraphics(param0->unk_04, BG_LAYER_MAIN_2, (1 + (18 + 12)), 1, 0, heapID);
LoadStandardWindowGraphics(param0->unk_04, BG_LAYER_MAIN_2, 1 + (18 + 12), 1, 0, heapID);
Font_LoadTextPalette(0, 3 * 32, heapID);
for (v0 = 0; v0 < 4; v0++) {
@@ -1164,10 +1164,10 @@ static void ov83_0223E9E4(UnkStruct_ov83_0223E824 *param0)
Text_AddPrinterWithParamsAndColor(param0->unk_08[1], FONT_SYSTEM, param0->unk_1C->unk_34, v0, 0, TEXT_SPEED_INSTANT, TEXT_COLOR(1, 2, 15), NULL);
}
Window_DrawStandardFrame(param0->unk_08[1], 0, (1 + (18 + 12)), 1);
Window_DrawStandardFrame(param0->unk_08[1], 0, 1 + (18 + 12), 1);
Window_FillTilemap(param0->unk_08[2], 15);
Text_AddPrinterWithParamsAndColor(param0->unk_08[2], FONT_SYSTEM, param0->unk_1C->unk_4C[6], 0, 0, TEXT_SPEED_INSTANT, TEXT_COLOR(1, 2, 15), NULL);
Window_DrawStandardFrame(param0->unk_08[2], 0, (1 + (18 + 12)), 1);
Window_DrawStandardFrame(param0->unk_08[2], 0, 1 + (18 + 12), 1);
Window_ScheduleCopyToVRAM(param0->unk_08[1]);
Window_ScheduleCopyToVRAM(param0->unk_08[2]);
}
@@ -1557,7 +1557,7 @@ void ov83_0223F2C4(UnkStruct_ov83_0223F29C *param0, UnkStruct_ov83_0223D784 *par
ov83_0223D7A8(param1, &param0->unk_04, param3, 33, 2, 32, 31, 30, 7000, param2);
for (v0 = 0; v0 < 4; v0++) {
param0->unk_3C[v0].unk_00 = ov83_0223D9A8(param1, &param0->unk_04, (128 * FX32_ONE), (96 * FX32_ONE), 0, 0, param2);
param0->unk_3C[v0].unk_00 = ov83_0223D9A8(param1, &param0->unk_04, 128 * FX32_ONE , 96 * FX32_ONE , 0, 0, param2);
if (v0 >= 2) {
Sprite_SetAnim(param0->unk_3C[v0].unk_00, 1);
@@ -1731,10 +1731,10 @@ void ov83_0223F544(UnkStruct_ov83_0223F4AC *param0, int param1, int param2)
int v6;
v1 = FX_Atan2Idx(param1 - 128, param2 - 96);
v2 = FX_Mul(FX_CosIdx(v1), (FX32_CONST(16)));
v3 = FX_Mul(FX_SinIdx(v1), (FX32_CONST(16)));
v4 = FX_Mul(FX_CosIdx(v1), (FX32_CONST(1)));
v5 = FX_Mul(FX_SinIdx(v1), (FX32_CONST(1)));
v2 = FX_Mul(FX_CosIdx(v1), FX32_CONST(16));
v3 = FX_Mul(FX_SinIdx(v1), FX32_CONST(16));
v4 = FX_Mul(FX_CosIdx(v1), FX32_CONST(1));
v5 = FX_Mul(FX_SinIdx(v1), FX32_CONST(1));
v0 = ov83_0223F650(param0);
if (v0) {
@@ -1814,19 +1814,19 @@ static void ov83_0223F6CC(UnkStruct_ov83_0223F670 *param0, int param1, fx32 para
void ov83_0223F730(UnkStruct_ov83_0223F770 *param0, int param1, int param2, int param3, int param4)
{
param0->unk_00 = sub_02098FFC(param4, 1, 1, (NNS_G2D_VRAM_TYPE_2DMAIN), 2);
param0->unk_04 = sub_0209916C(param0->unk_00, param3, param1, param2, 0, 0, 0, 0);
param0->unk_00 = PoffinSpriteManager_New(param4, 1, 1, NNS_G2D_VRAM_TYPE_2DMAIN, 2);
param0->unk_04 = PoffinSprite_New(param0->unk_00, param3, param1, param2, 0, 0, 0, 0);
}
void ov83_0223F770(UnkStruct_ov83_0223F770 *param0)
{
sub_02099370(param0->unk_00, param0->unk_04);
sub_0209903C(param0->unk_00);
PoffinSprite_Free(param0->unk_00, param0->unk_04);
PoffinSpriteManager_Free(param0->unk_00);
}
void ov83_0223F784(UnkStruct_ov83_0223F770 *param0)
{
sub_02099160(param0->unk_00);
PoffinSpriteManager_DrawSprites(param0->unk_00);
}
void ov83_0223F790(UnkStruct_ov83_0223F7A4 *param0, int heapID, BgConfig *param2)

View File

@@ -7,9 +7,10 @@
#include "heap.h"
#include "math_util.h"
#include "poffin_types.h"
#include "savedata.h"
#define FLAVOR_NONE 30
#define TYPE_NONE 30
int Poffin_SizeOf(void)
{
@@ -18,7 +19,7 @@ int Poffin_SizeOf(void)
BOOL Poffin_HasValidFlavor(Poffin *poffin)
{
if (poffin->flavor == FLAVOR_NONE) {
if (poffin->type == TYPE_NONE) {
return FALSE;
}
@@ -27,7 +28,7 @@ BOOL Poffin_HasValidFlavor(Poffin *poffin)
void Poffin_Clear(Poffin *poffin)
{
poffin->flavor = FLAVOR_NONE;
poffin->type = TYPE_NONE;
poffin->spiciness = 0;
poffin->dryness = 0;
poffin->sweetness = 0;
@@ -47,7 +48,7 @@ Poffin *Poffin_New(int heapID)
void Poffin_Copy(Poffin *src, Poffin *dest)
{
dest->flavor = src->flavor;
dest->type = src->type;
dest->spiciness = src->spiciness;
dest->dryness = src->dryness;
dest->sweetness = src->sweetness;
@@ -60,8 +61,8 @@ void Poffin_Copy(Poffin *src, Poffin *dest)
u8 Poffin_GetAttribute(Poffin *poffin, enum PoffinAttributeID attributeID)
{
switch (attributeID) {
case POFFIN_ATTRIBUTEID_FLAVOR:
return poffin->flavor;
case POFFIN_ATTRIBUTEID_TYPE:
return poffin->type;
case POFFIN_ATTRIBUTEID_SPICINESS:
return poffin->spiciness;
case POFFIN_ATTRIBUTEID_DRYNESS:
@@ -96,7 +97,7 @@ static void Poffin_MakeFoul(Poffin *poffin, u8 param1)
++v0;
} while (v0 < 3);
poffin->flavor = POFFIN_FLAVOR_FOUL;
poffin->type = POFFIN_TYPE_FOUL;
poffin->smoothness = param1;
}
@@ -104,13 +105,13 @@ int Poffin_MakePoffin(Poffin *poffin, u8 *flavors, u8 smoothness, BOOL isFoul)
{
int i, flavorCount = 0;
u8 poffinFlavors[FLAVOR_MAX];
u8 isMild = FALSE, flavor = 0;
u8 isMild = FALSE, type = 0;
flavor = POFFIN_FLAVOR_FOUL;
type = POFFIN_TYPE_FOUL;
if (isFoul) {
Poffin_MakeFoul(poffin, smoothness);
return flavor;
return type;
}
for (i = 0; i < FLAVOR_MAX; i++) {
@@ -126,43 +127,43 @@ int Poffin_MakePoffin(Poffin *poffin, u8 *flavors, u8 smoothness, BOOL isFoul)
switch (flavorCount) {
case 0:
Poffin_MakeFoul(poffin, smoothness);
return flavor;
return type;
case 1:
flavor = poffinFlavors[0] * FLAVOR_MAX + poffinFlavors[0];
type = poffinFlavors[0] * FLAVOR_MAX + poffinFlavors[0];
break;
case 2:
if (flavors[poffinFlavors[0]] >= flavors[poffinFlavors[1]]) {
flavor = poffinFlavors[0] * FLAVOR_MAX + poffinFlavors[1];
type = poffinFlavors[0] * FLAVOR_MAX + poffinFlavors[1];
} else {
flavor = poffinFlavors[1] * FLAVOR_MAX + poffinFlavors[0];
type = poffinFlavors[1] * FLAVOR_MAX + poffinFlavors[0];
}
break;
case 3:
flavor = POFFIN_FLAVOR_RICH;
type = POFFIN_TYPE_RICH;
break;
case 4:
case 5:
flavor = POFFIN_FLAVOR_OVERRIPE;
type = POFFIN_TYPE_OVERRIPE;
break;
}
if (isMild) {
flavor = POFFIN_FLAVOR_MILD;
type = POFFIN_TYPE_MILD;
}
for (i = 0; i < FLAVOR_MAX; i++) {
poffin->attributes[i + 1] = flavors[i];
}
poffin->flavor = flavor;
poffin->type = type;
poffin->smoothness = smoothness;
return flavor;
return type;
}
void Poffin_StoreAttributesToArray(Poffin *poffin, u8 *dest)
{
dest[0] = poffin->flavor;
dest[0] = poffin->type;
dest[1] = poffin->spiciness;
dest[2] = poffin->dryness;
dest[3] = poffin->sweetness;
@@ -176,7 +177,7 @@ u8 Poffin_CalcLevel(Poffin *poffin)
u8 v0 = 0;
u8 level = 0;
v0 = poffin->flavor / 5;
v0 = poffin->type / 5;
switch (v0) {
case 0:
@@ -247,7 +248,7 @@ u16 PoffinCase_GetEmptySlot(PoffinCase *poffinCase)
u16 i;
for (i = 0; i < MAX_POFFINS; i++) {
if (poffinCase->slot[i].flavor == FLAVOR_NONE) {
if (poffinCase->slot[i].type == TYPE_NONE) {
return i;
}
}
@@ -282,7 +283,7 @@ static u16 PoffinCase_GetFirstValidPoffin(PoffinCase *poffinCase, u16 startingSl
u16 i;
for (i = startingSlot; i < MAX_POFFINS; i++) {
if (poffinCase->slot[i].flavor != FLAVOR_NONE) {
if (poffinCase->slot[i].type != TYPE_NONE) {
return i;
}
}
@@ -298,7 +299,7 @@ void PoffinCase_Compact(PoffinCase *poffinCase)
for (i = 0; i < remainingSlots; i++) {
// skip over occupied slots
if (poffinCase->slot[i].flavor != FLAVOR_NONE) {
if (poffinCase->slot[i].type != TYPE_NONE) {
continue;
}
@@ -322,14 +323,14 @@ void PoffinCase_Compact(PoffinCase *poffinCase)
}
}
void PoffinCase_CopyPoffinToSlot(PoffinCase *poffinCase, u16 destSlot, Poffin *poffin)
void PoffinCase_CopyPoffinFromSlot(PoffinCase *poffinCase, u16 srcSlot, Poffin *poffin)
{
if (destSlot >= MAX_POFFINS) {
if (srcSlot >= MAX_POFFINS) {
Poffin_Clear(poffin);
return;
}
Poffin_Copy(&poffinCase->slot[destSlot], poffin);
Poffin_Copy(&poffinCase->slot[srcSlot], poffin);
return;
}
@@ -364,7 +365,7 @@ u16 PoffinCase_CountEmptySlots(PoffinCase *poffinCase)
u16 i, j = 0;
for (i = 0; i < MAX_POFFINS; i++) {
if (poffinCase->slot[i].flavor == FLAVOR_NONE) {
if (poffinCase->slot[i].type == TYPE_NONE) {
j++;
}
}

270
src/poffin_sprite.c Normal file
View File

@@ -0,0 +1,270 @@
#include "poffin_sprite.h"
#include <nitro.h>
#include "constants/narc.h"
#include "heap.h"
#include "narc.h"
#include "sprite.h"
#include "sprite_resource.h"
#include "sprite_system.h"
#include "sprite_transfer.h"
#include "sprite_util.h"
static void InitSprites(PoffinSpriteManager *spriteMan);
static void FreeResources(PoffinSpriteManager *spriteMan);
static void LoadResources(PoffinSpriteManager *spriteMan);
static s16 GetAvailableIndex(PoffinSpriteManager *spriteMan, u8 flavor);
PoffinSpriteManager *PoffinSpriteManager_New(enum HeapID heapID, u16 maxSprites, u16 numPalettes, u16 vramType, int transferType)
{
PoffinSpriteManager *spriteMan = Heap_Alloc(heapID, sizeof(PoffinSpriteManager));
MI_CpuClear8(spriteMan, sizeof(PoffinSpriteManager));
spriteMan->heapID = heapID;
if (maxSprites > 16) {
spriteMan->numPalettes = 16;
} else {
spriteMan->numPalettes = numPalettes;
}
spriteMan->maxSprites = maxSprites;
spriteMan->vramType = vramType;
spriteMan->transferType = transferType;
InitSprites(spriteMan);
return spriteMan;
}
void PoffinSpriteManager_Free(PoffinSpriteManager *spriteMan)
{
FreeResources(spriteMan);
MI_CpuClear8(spriteMan, sizeof(PoffinSpriteManager));
Heap_Free(spriteMan);
}
static void InitSprites(PoffinSpriteManager *spriteMan)
{
u8 resourceCounts[] = { 1, 1, 1, 1 };
spriteMan->spriteList = SpriteList_InitRendering(spriteMan->maxSprites, &spriteMan->renderer, spriteMan->heapID);
resourceCounts[SPRITE_RESOURCE_PLTT] = spriteMan->numPalettes;
for (u32 i = 0; i < 4; i++) {
spriteMan->ownedResources[i] = SpriteResourceCollection_New(resourceCounts[i], i, spriteMan->heapID);
spriteMan->unownedResources[i] = SpriteResourceList_New(resourceCounts[i], spriteMan->heapID);
for (u32 j = 0; j < spriteMan->unownedResources[i]->capacity; j++) {
spriteMan->unownedResources[i]->resources[j] = NULL;
}
}
LoadResources(spriteMan);
spriteMan->poffinList = Heap_Alloc(spriteMan->heapID, sizeof(PoffinSpriteItem));
MI_CpuClear8(spriteMan->poffinList, sizeof(PoffinSpriteItem));
}
static void FreeResources(PoffinSpriteManager *spriteMan)
{
Heap_Free(spriteMan->poffinList);
SpriteList_Delete(spriteMan->spriteList);
SpriteTransfer_ResetCharTransferList(spriteMan->unownedResources[SPRITE_RESOURCE_CHAR]);
SpriteTransfer_ResetPlttTransferList(spriteMan->unownedResources[SPRITE_RESOURCE_PLTT]);
for (u32 i = 0; i < 4; i++) {
SpriteResourceList_Delete(spriteMan->unownedResources[i]);
SpriteResourceCollection_Delete(spriteMan->ownedResources[i]);
}
}
void PoffinSpriteManager_DrawSprites(PoffinSpriteManager *spriteMan)
{
SpriteList_Update(spriteMan->spriteList);
}
PoffinSprite *PoffinSprite_New(PoffinSpriteManager *spriteMan, enum PoffinType type, u16 x, u16 y, u16 z, u8 bgPriority, u8 priority, BOOL onSubScreen)
{
s16 index = GetAvailableIndex(spriteMan, type);
if (index < 0) {
GF_ASSERT(FALSE);
return NULL;
}
PoffinSprite *poffinSprite = Heap_Alloc(spriteMan->heapID, sizeof(PoffinSprite));
MI_CpuClear8(poffinSprite, sizeof(PoffinSprite));
poffinSprite->index = index;
u8 vRamType;
if (onSubScreen == FALSE) {
vRamType = NNS_G2D_VRAM_TYPE_2DMAIN;
} else {
vRamType = NNS_G2D_VRAM_TYPE_2DSUB;
}
SpriteResource *resource = spriteMan->unownedResources[SPRITE_RESOURCE_PLTT]->resources[index];
SpriteResourceCollection_ModifyPalette(
spriteMan->ownedResources[SPRITE_RESOURCE_PLTT],
spriteMan->unownedResources[SPRITE_RESOURCE_PLTT]->resources[index],
NARC_INDEX_GRAPHIC__PORUACT,
3 + type,
FALSE,
spriteMan->heapID);
SpriteTransfer_ReplacePlttData(spriteMan->unownedResources[SPRITE_RESOURCE_PLTT]->resources[index]);
ManagedSprite *managedSprite = Heap_Alloc(spriteMan->heapID, sizeof(ManagedSprite));
managedSprite->resourceHeaderList = Heap_Alloc(spriteMan->heapID, sizeof(SpriteResourcesHeaderList));
managedSprite->resourceHeaderList->headers = Heap_Alloc(spriteMan->heapID, sizeof(SpriteResourcesHeader));
managedSprite->resourceHeader = managedSprite->resourceHeaderList->headers;
SpriteResourcesHeader_Init(
managedSprite->resourceHeader,
0xe000,
0xe000 + index,
0xe000,
0xe000,
-1,
-1,
FALSE,
bgPriority,
spriteMan->ownedResources[SPRITE_RESOURCE_CHAR],
spriteMan->ownedResources[SPRITE_RESOURCE_PLTT],
spriteMan->ownedResources[SPRITE_RESOURCE_CELL],
spriteMan->ownedResources[SPRITE_RESOURCE_ANIM],
NULL,
NULL);
AffineSpriteListTemplate spriteTemplate;
spriteTemplate.list = spriteMan->spriteList;
spriteTemplate.resourceData = managedSprite->resourceHeader;
spriteTemplate.position.x = FX32_CONST(x);
spriteTemplate.position.y = FX32_CONST(y);
spriteTemplate.position.z = FX32_CONST(z);
if (vRamType == NNS_G2D_VRAM_TYPE_2DSUB) {
spriteTemplate.position.y += FX32_CONST(192);
}
spriteTemplate.affineScale.x = FX32_ONE;
spriteTemplate.affineScale.y = FX32_ONE;
spriteTemplate.affineScale.z = FX32_ONE;
spriteTemplate.affineZRotation = 0;
spriteTemplate.priority = priority;
spriteTemplate.vramType = vRamType;
spriteTemplate.heapID = spriteMan->heapID;
managedSprite->sprite = SpriteList_AddAffine(&spriteTemplate);
if (managedSprite->sprite != NULL) {
Sprite_SetAnim(managedSprite->sprite, 0);
u32 palette = SpriteTransfer_GetPlttOffset(resource, vRamType);
Sprite_SetExplicitPalette(managedSprite->sprite, palette);
} else {
GF_ASSERT(FALSE);
}
poffinSprite->sprite = managedSprite;
return poffinSprite;
}
void PoffinSprite_UpdateType(PoffinSpriteManager *spriteMan, PoffinSprite *sprite, enum PoffinType poffinType)
{
SpriteResource *resource = spriteMan->unownedResources[SPRITE_RESOURCE_PLTT]->resources[sprite->index];
SpriteResourceCollection_ModifyPalette(spriteMan->ownedResources[SPRITE_RESOURCE_PLTT], resource, NARC_INDEX_GRAPHIC__PORUACT, 3 + poffinType, FALSE, spriteMan->heapID);
SpriteTransfer_ReplacePlttData(resource);
}
void PoffinSprite_Free(PoffinSpriteManager *spriteMan, PoffinSprite *poffinSprite)
{
Sprite_DeleteAndFreeResources(poffinSprite->sprite);
spriteMan->poffinList[poffinSprite->index].inUse = FALSE;
spriteMan->poffinList[poffinSprite->index].index = 0;
spriteMan->poffinList[poffinSprite->index].type = 0;
Heap_Free(poffinSprite);
}
static void LoadResources(PoffinSpriteManager *spriteMan)
{
NARC *narc = NARC_ctor(NARC_INDEX_GRAPHIC__PORUACT, spriteMan->heapID);
SpriteResourceList *resourceList = spriteMan->unownedResources[SPRITE_RESOURCE_CHAR];
resourceList->resources[0] = SpriteResourceCollection_AddTilesFrom(
spriteMan->ownedResources[SPRITE_RESOURCE_CHAR],
narc,
0,
FALSE,
0xe000,
spriteMan->vramType,
spriteMan->heapID);
GF_ASSERT(resourceList->resources[0] != NULL);
switch (spriteMan->transferType) {
case 1:
SpriteTransfer_RequestCharAtEnd(resourceList->resources[0]);
break;
case 2:
SpriteTransfer_RequestCharAtEndWithHardwareMappingType(resourceList->resources[0]);
break;
case 0:
default:
SpriteTransfer_RequestChar(resourceList->resources[0]);
break;
}
for (int i = 0; i < 2; i++) {
resourceList = spriteMan->unownedResources[2 + i];
resourceList->resources[0] = SpriteResourceCollection_AddFrom(
spriteMan->ownedResources[2 + i],
narc,
1 + i,
FALSE,
0xe000,
2 + i,
spriteMan->heapID);
GF_ASSERT(resourceList->resources[0] != NULL);
}
resourceList = spriteMan->unownedResources[1];
for (int i = 0; i < spriteMan->numPalettes; i++) {
resourceList->resources[i] = SpriteResourceCollection_AddPaletteFrom(
spriteMan->ownedResources[SPRITE_RESOURCE_PLTT],
narc,
3 + 1,
FALSE,
0xe000 + i,
spriteMan->vramType,
1,
spriteMan->heapID);
GF_ASSERT(resourceList->resources[i] != NULL);
SpriteTransfer_RequestPlttWholeRange(resourceList->resources[i]);
}
NARC_dtor(narc);
}
static s16 GetAvailableIndex(PoffinSpriteManager *spriteMan, u8 type)
{
for (u16 i = 0; i < spriteMan->numPalettes; i++) {
if (!spriteMan->poffinList[i].inUse) {
spriteMan->poffinList[i].index = i;
spriteMan->poffinList[i].type = type;
spriteMan->poffinList[i].inUse = TRUE;
return i;
}
}
return -1;
}

37
src/poffin_types.c Normal file
View File

@@ -0,0 +1,37 @@
#include "poffin_types.h"
#include <nitro.h>
#include "heap.h"
#include "message.h"
#include "string_gf.h"
PoffinTypeList *PoffinTypeList_New(enum HeapID heapID)
{
PoffinTypeList *types = Heap_Alloc(heapID, sizeof(PoffinTypeList));
MI_CpuClear8(types, sizeof(PoffinTypeList));
types->msgLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_POFFIN_TYPES, heapID);
for (int i = 0; i < NUM_POFFIN_TYPES; i++) {
types->names[i] = String_Init(22, heapID);
MessageLoader_GetString(types->msgLoader, i, types->names[i]);
}
return types;
}
void PoffinTypeList_Free(PoffinTypeList *types)
{
for (int i = NUM_POFFIN_TYPES - 1; i >= 0; i--) {
String_Free(types->names[i]);
}
MessageLoader_Free(types->msgLoader);
Heap_Free(types);
}
const String *PoffinTypeList_GetString(PoffinTypeList *poffinNames, enum PoffinType type)
{
return poffinNames->names[type];
}

View File

@@ -19,6 +19,7 @@
#include "applications/party_menu/defs.h"
#include "applications/party_menu/main.h"
#include "applications/poffin_case/main.h"
#include "applications/pokedex/pokedex_main.h"
#include "applications/pokemon_summary_screen/main.h"
#include "applications/town_map/main.h"
@@ -87,7 +88,6 @@
#include "unk_020972FC.h"
#include "unk_0209747C.h"
#include "unk_02097624.h"
#include "unk_020989DC.h"
#include "vars_flags.h"
#include "constdata/const_020EA02C.h"
@@ -537,7 +537,7 @@ static void sub_0203ADFC(FieldTask *taskMan)
menu = FieldTask_GetEnv(taskMan);
optionCount = StartMenu_MakeList(menu, menu->options);
Window_Add(fieldSystem->bgConfig, &menu->unk_00, 3, 20, 1, 11, optionCount * 3, 12, ((((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4)) - (11 * 22)));
Window_Add(fieldSystem->bgConfig, &menu->unk_00, 3, 20, 1, 11, optionCount * 3, 12, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4)) - (11 * 22));
LoadStandardWindowGraphics(fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 1, HEAP_ID_FIELD2);
Window_DrawStandardFrame(&menu->unk_00, 1, 1024 - (18 + 12) - 9, 11);
@@ -678,7 +678,7 @@ static void sub_0203B094(FieldTask *taskMan)
return;
}
Window_Add(fieldSystem->bgConfig, &menu->unk_10, 3, 1, 1, 12, 4, 13, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4)));
Window_Add(fieldSystem->bgConfig, &menu->unk_10, 3, 1, 1, 12, 4, 13, ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4));
LoadStandardWindowGraphics(fieldSystem->bgConfig, BG_LAYER_MAIN_3, 1024 - (18 + 12) - 9, 11, 1, HEAP_ID_FIELD2);
Window_DrawStandardFrame(&menu->unk_10, 1, 1024 - (18 + 12) - 9, 11);
Window_FillTilemap(&menu->unk_10, 15);
@@ -790,7 +790,7 @@ static void sub_0203B318(StartMenu *menu, u8 *options, u32 optionCount, u8 gende
};
u32 i;
SpriteResourceManager_SetCapacities(&menu->spriteManager, &v0, (7 + 1), HEAP_ID_FIELD2);
SpriteResourceManager_SetCapacities(&menu->spriteManager, &v0, 7 + 1, HEAP_ID_FIELD2);
NARC *narc = NARC_ctor(NARC_INDEX_GRAPHIC__MENU_GRA, HEAP_ID_FIELD2);
@@ -1784,7 +1784,7 @@ BOOL sub_0203C710(FieldTask *taskMan)
FieldSystem *fieldSystem = FieldTask_GetFieldSystem(taskMan);
StartMenu *menu = FieldTask_GetEnv(taskMan);
sub_02098AF0(menu->taskData);
PoffinCaseAppData_Free(menu->taskData);
menu->taskData = sub_0203D20C(fieldSystem, &menu->unk_230);
sub_0203B674(menu, sub_0203BC5C);

View File

@@ -502,7 +502,7 @@ void StringTemplate_SetMetLocationName(StringTemplate *template, u32 idx, u32 lo
void StringTemplate_SetPoffinName(StringTemplate *template, u32 idx, u32 poffin)
{
SetArgFromArchive(template, idx, poffin, TEXT_BANK_POFFIN_NAMES);
SetArgFromArchive(template, idx, poffin, TEXT_BANK_POFFIN_TYPES);
}
void StringTemplate_SetContestAccessoryName(StringTemplate *template, u32 idx, u32 accessory)

View File

@@ -47,7 +47,7 @@
#include "math_util.h"
#include "message.h"
#include "party.h"
#include "poffin.h"
#include "poffin_types.h"
#include "pokedex.h"
#include "pokemon.h"
#include "record_mixed_rng.h"
@@ -1838,13 +1838,13 @@ static int TVEpisodeSegment_LoadMessage_ThreeCheersForPoffinCorner(FieldSystem *
StringTemplate_SetCustomMessageWord(template, 2, threeCheersForPoffinCorner->customMessageWord);
switch (poffin) {
case POFFIN_FLAVOR_RICH:
case POFFIN_TYPE_RICH:
return TVProgramInterviews_Text_ThreeCheersForPoffinCorner_RichPoffin;
case POFFIN_FLAVOR_OVERRIPE:
case POFFIN_TYPE_OVERRIPE:
return TVProgramInterviews_Text_ThreeCheersForPoffinCorner_OverripePoffin;
case POFFIN_FLAVOR_FOUL:
case POFFIN_TYPE_FOUL:
return TVProgramInterviews_Text_ThreeCheersForPoffinCorner_FoulPoffin;
case POFFIN_FLAVOR_MILD:
case POFFIN_TYPE_MILD:
return TVProgramInterviews_Text_ThreeCheersForPoffinCorner_MildPoffin;
default:
return TVProgramInterviews_Text_ThreeCheersForPoffinCorner_RegularPoffin;

View File

@@ -1,45 +0,0 @@
#include "unk_020158A8.h"
#include <nitro.h>
#include <string.h>
#include "struct_defs/struct_020158A8.h"
#include "heap.h"
#include "message.h"
#include "string_gf.h"
UnkStruct_020158A8 *sub_020158A8(int heapID)
{
UnkStruct_020158A8 *v0;
int v1;
v0 = Heap_Alloc(heapID, sizeof(UnkStruct_020158A8));
MI_CpuClear8(v0, sizeof(UnkStruct_020158A8));
v0->unk_00 = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_POFFIN_NAMES, heapID);
for (v1 = 0; v1 < 29; v1++) {
v0->unk_04[v1] = String_Init(22, heapID);
MessageLoader_GetString(v0->unk_00, v1, v0->unk_04[v1]);
}
return v0;
}
void sub_020158F4(UnkStruct_020158A8 *param0)
{
int v0;
for (v0 = (29 - 1); v0 >= 0; v0--) {
String_Free(param0->unk_04[v0]);
}
MessageLoader_Free(param0->unk_00);
Heap_Free(param0);
}
const String *sub_02015918(UnkStruct_020158A8 *param0, int param1)
{
return (const String *)param0->unk_04[param1];
}

View File

@@ -14,7 +14,6 @@
#include "struct_decls/struct_0209747C_decl.h"
#include "struct_defs/choose_starter_data.h"
#include "struct_defs/gts_player_data.h"
#include "struct_defs/struct_0203D9B8.h"
#include "struct_defs/struct_0203DA00.h"
#include "struct_defs/struct_0203DDFC.h"
#include "struct_defs/struct_0203DE34.h"
@@ -39,6 +38,7 @@
#include "applications/pc_boxes/box_app_manager.h"
#include "applications/pc_boxes/pokemon_storage_session.h"
#include "applications/pc_hall_of_fame/manager.h"
#include "applications/poffin_case/main.h"
#include "applications/pokedex/pokedex_main.h"
#include "applications/pokemon_summary_screen/main.h"
#include "applications/town_map/main.h"
@@ -128,7 +128,6 @@
#include "unk_0209747C.h"
#include "unk_02097624.h"
#include "unk_02098218.h"
#include "unk_020989DC.h"
#include "vars_flags.h"
#include "constdata/const_020EA02C.h"
@@ -791,17 +790,17 @@ UnkStruct_02097728 *sub_0203D984(FieldSystem *fieldSystem, Pokemon *param1, int
return v0;
}
static void sub_0203D9A8(FieldSystem *fieldSystem, UnkStruct_0203D9B8 *param1)
static void OpenPoffinCaseApp(FieldSystem *fieldSystem, PoffinCaseAppData *poffinCaseAppData)
{
FieldSystem_StartChildProcess(fieldSystem, &Unk_020F6890, param1);
FieldSystem_StartChildProcess(fieldSystem, &gPoffinCaseAppTemplate, poffinCaseAppData);
}
UnkStruct_0203D9B8 *sub_0203D9B8(FieldSystem *fieldSystem, int heapID)
PoffinCaseAppData *FieldSystem_LaunchPoffinCaseApp(FieldSystem *fieldSystem, int heapID)
{
UnkStruct_0203D9B8 *v0 = sub_020989DC(FieldSystem_GetSaveData(fieldSystem), heapID);
sub_0203D9A8(fieldSystem, v0);
PoffinCaseAppData *appData = PoffinCaseAppData_New(FieldSystem_GetSaveData(fieldSystem), heapID);
OpenPoffinCaseApp(fieldSystem, appData);
return v0;
return appData;
}
void sub_0203D9D8(FieldSystem *fieldSystem, UnkStruct_ov90_021D0D80 *param1)

View File

@@ -1,533 +0,0 @@
#include "unk_020989DC.h"
#include <nitro.h>
#include <string.h>
#include "struct_defs/struct_0203D9B8.h"
#include "struct_defs/struct_020989DC.h"
#include "struct_defs/struct_02098DE8.h"
#include "applications/party_menu/defs.h"
#include "applications/party_menu/main.h"
#include "applications/pokemon_summary_screen/main.h"
#include "overlay079/ov79_021D0D80.h"
#include "overlay079/ov79_021D2268.h"
#include "bag.h"
#include "enums.h"
#include "game_options.h"
#include "heap.h"
#include "overlay_manager.h"
#include "party.h"
#include "poffin.h"
#include "pokemon.h"
#include "save_player.h"
#include "savedata.h"
#include "string_template.h"
#include "constdata/const_020F410C.h"
#include "constdata/const_020F6890.h"
FS_EXTERN_OVERLAY(overlay79);
static const u8 Unk_020F685C[][2] = {
{ 0x5, 0x5 },
{ 0x0, 0x4 },
{ 0x0, 0x2 },
{ 0x0, 0x1 },
{ 0x0, 0x3 },
{ 0x4, 0x0 },
{ 0x5, 0x5 },
{ 0x4, 0x2 },
{ 0x4, 0x1 },
{ 0x4, 0x3 },
{ 0x2, 0x0 },
{ 0x2, 0x4 },
{ 0x5, 0x5 },
{ 0x2, 0x1 },
{ 0x2, 0x3 },
{ 0x1, 0x0 },
{ 0x1, 0x4 },
{ 0x1, 0x2 },
{ 0x5, 0x5 },
{ 0x1, 0x3 },
{ 0x3, 0x0 },
{ 0x3, 0x4 },
{ 0x3, 0x2 },
{ 0x3, 0x1 },
{ 0x5, 0x5 }
};
typedef struct {
int heapID;
int unk_04;
u8 unk_08;
u8 unk_09;
u16 unk_0A;
UnkStruct_0203D9B8 *unk_0C;
void *unk_10;
ApplicationManager *appMan;
} UnkStruct_02098BE4;
static int sub_02098B1C(ApplicationManager *appMan, int *param1);
static int sub_02098B50(ApplicationManager *appMan, int *param1);
static int sub_02098BC4(ApplicationManager *appMan, int *param1);
static void sub_02098BE4(UnkStruct_02098BE4 *param0);
static int sub_02098C2C(UnkStruct_02098BE4 *param0);
static int sub_02098C44(UnkStruct_02098BE4 *param0);
static int sub_02098CB0(UnkStruct_02098BE4 *param0);
static int sub_02098D38(UnkStruct_02098BE4 *param0);
static int sub_02098D7C(UnkStruct_02098BE4 *param0);
static int sub_02098DE8(UnkStruct_02098BE4 *param0);
static int sub_02098E0C(UnkStruct_02098BE4 *param0);
static int sub_02098E88(UnkStruct_02098BE4 *param0);
const ApplicationManagerTemplate Unk_020F6890 = {
sub_02098B1C,
sub_02098B50,
sub_02098BC4,
0xFFFFFFFF
};
UnkStruct_0203D9B8 *sub_020989DC(SaveData *saveData, int heapID)
{
UnkStruct_0203D9B8 *v0;
Poffin *v1;
UnkStruct_020989DC *v2;
StringTemplate *v3;
u8 v4[7];
u8 v5 = 0, v6 = 0, v7 = 0;
u8 v8 = 0;
v0 = Heap_Alloc(heapID, sizeof(UnkStruct_0203D9B8));
MI_CpuClear8(v0, sizeof(UnkStruct_0203D9B8));
v0->poffinCase = SaveData_GetPoffinCase(saveData);
v0->unk_0C = SaveData_GetTrainerInfo(saveData);
v0->unk_10 = SaveData_GetParty(saveData);
v0->unk_14 = SaveData_GetBag(saveData);
v0->options = SaveData_GetOptions(saveData);
v1 = Poffin_New(heapID);
v3 = StringTemplate_New(1, 32, heapID);
for (v5 = 0; v5 < MAX_POFFINS; v5++) {
PoffinCase_CopyPoffinToSlot(v0->poffinCase, v5, v1);
if (!Poffin_HasValidFlavor(v1)) {
continue;
}
Poffin_StoreAttributesToArray(v1, v4);
v2 = &(v0->unk_1C[v6]);
v2->unk_00 = v5;
v2->unk_01 = Poffin_CalcLevel(v1);
v2->unk_02 = v4[0];
v2->unk_03 = v4[6];
v8 = 1;
for (v7 = 0; v7 < 5; v7++) {
if (v4[v7 + 1]) {
v2->unk_20_val2 |= v8;
}
v8 <<= 1;
}
v2->unk_04_val1_7 = v2->unk_04_val1_5 = 1;
v2->unk_05 = v6++;
v2->unk_07 = v2->unk_06 = 0xFF;
}
StringTemplate_Free(v3);
Heap_Free(v1);
v0->unk_00 = v6;
v0->unk_03 = 5;
return v0;
}
void sub_02098AF0(UnkStruct_0203D9B8 *param0)
{
int v0;
Heap_Free(param0);
}
static BOOL sub_02098AF8(ApplicationManager **appManPtr)
{
if (*appManPtr) {
if (ApplicationManager_Exec(*appManPtr)) {
ApplicationManager_Free(*appManPtr);
*appManPtr = NULL;
return 1;
}
}
return 0;
}
static int sub_02098B1C(ApplicationManager *appMan, int *param1)
{
UnkStruct_02098BE4 *v0 = NULL;
void *v1 = ApplicationManager_Args(appMan);
Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_44, 0x1000);
v0 = ApplicationManager_NewData(appMan, sizeof(UnkStruct_02098BE4), HEAP_ID_44);
MI_CpuClear8(v0, sizeof(UnkStruct_02098BE4));
v0->heapID = HEAP_ID_44;
v0->unk_0C = v1;
return 1;
}
static int sub_02098B50(ApplicationManager *appMan, int *param1)
{
UnkStruct_02098BE4 *v0 = (UnkStruct_02098BE4 *)ApplicationManager_Data(appMan);
switch (*param1) {
case 0:
*param1 = sub_02098C2C(v0);
break;
case 1:
*param1 = sub_02098C44(v0);
break;
case 2:
*param1 = sub_02098CB0(v0);
break;
case 3:
*param1 = sub_02098D38(v0);
break;
case 4:
*param1 = sub_02098D7C(v0);
break;
case 5:
*param1 = sub_02098DE8(v0);
break;
case 6:
*param1 = sub_02098E0C(v0);
break;
case 7:
*param1 = sub_02098E88(v0);
break;
case 8:
return 1;
}
return 0;
}
static int sub_02098BC4(ApplicationManager *appMan, int *param1)
{
UnkStruct_02098BE4 *v0 = (UnkStruct_02098BE4 *)ApplicationManager_Data(appMan);
sub_02098BE4(v0);
ApplicationManager_FreeData(appMan);
Heap_Destroy(v0->heapID);
return 1;
}
static void sub_02098BE4(UnkStruct_02098BE4 *param0)
{
u8 v0 = 0, v1 = 0;
UnkStruct_020989DC *v2;
for (v0 = 0; v0 < param0->unk_0C->unk_00; v0++) {
v2 = &param0->unk_0C->unk_1C[v0];
if (v2->unk_04_val1_6) {
PoffinCase_ClearSlot(param0->unk_0C->poffinCase, v2->unk_00);
v1 = 1;
}
}
if (!v1) {
return;
}
PoffinCase_Compact(param0->unk_0C->poffinCase);
}
static int sub_02098C2C(UnkStruct_02098BE4 *param0)
{
FS_EXTERN_OVERLAY(overlay79);
static const ApplicationManagerTemplate v0 = {
ov79_021D0D80,
ov79_021D0DC4,
ov79_021D0DDC,
FS_OVERLAY_ID(overlay79),
};
param0->appMan = ApplicationManager_New(&v0, param0->unk_0C, param0->heapID);
return 1;
}
static int sub_02098C44(UnkStruct_02098BE4 *param0)
{
if (!sub_02098AF8(&param0->appMan)) {
return 1;
}
if (param0->unk_0C->unk_02 == 0) {
return 8;
}
param0->unk_0C->unk_02 = 0;
PartyMenu *partyMenu = Heap_Alloc(param0->heapID, sizeof(PartyMenu));
MI_CpuClear8(partyMenu, sizeof(PartyMenu));
partyMenu->party = param0->unk_0C->unk_10;
partyMenu->bag = param0->unk_0C->unk_14;
partyMenu->type = PARTY_MENU_TYPE_BASIC;
partyMenu->mode = PARTY_MENU_MODE_FEED_POFFIN;
partyMenu->options = param0->unk_0C->options;
param0->appMan = ApplicationManager_New(&gPokemonPartyAppTemplate, partyMenu, param0->heapID);
param0->unk_10 = (void *)partyMenu;
return 2;
}
static int sub_02098CB0(UnkStruct_02098BE4 *param0)
{
u8 v0;
PartyMenu *partyMenu;
PokemonSummary *v2;
static const u8 v3[] = {
4, 7, 8
};
if (!sub_02098AF8(&param0->appMan)) {
return 2;
}
partyMenu = (PartyMenu *)param0->unk_10;
v0 = partyMenu->selectedMonSlot;
param0->unk_08 = v0;
Heap_Free(param0->unk_10);
if (v0 == 7) {
return 0;
}
v2 = Heap_Alloc(param0->heapID, sizeof(PokemonSummary));
v2->monData = param0->unk_0C->unk_10;
v2->options = param0->unk_0C->options;
v2->dataType = SUMMARY_DATA_PARTY_MON;
v2->monIndex = v0;
v2->monMax = Party_GetCurrentCount(v2->monData);
v2->move = 0;
v2->mode = SUMMARY_MODE_FEED_POFFIN;
v2->showContest = TRUE;
v2->chatotCry = NULL;
PokemonSummaryScreen_FlagVisiblePages(v2, v3);
PokemonSummaryScreen_SetPlayerProfile(v2, param0->unk_0C->unk_0C);
param0->appMan = ApplicationManager_New(&gPokemonSummaryScreenApp, partyMenu, param0->heapID);
param0->unk_10 = (void *)v2;
return 3;
}
static int sub_02098D38(UnkStruct_02098BE4 *param0)
{
PokemonSummary *summaryScreen;
if (!sub_02098AF8(&param0->appMan)) {
return 3;
}
summaryScreen = (PokemonSummary *)param0->unk_10;
u8 returnMode = summaryScreen->returnMode;
param0->unk_08 = summaryScreen->monIndex;
Heap_Free(param0->unk_10);
if (returnMode == SUMMARY_RETURN_CANCEL) {
return 0;
}
param0->unk_0C->unk_1C[param0->unk_0C->unk_01].unk_04_val1_6 = 1;
param0->unk_0C->unk_02 = 1;
return 4;
}
static int sub_02098D7C(UnkStruct_02098BE4 *param0)
{
FS_EXTERN_OVERLAY(overlay79);
static const ApplicationManagerTemplate v0 = {
ov79_021D22AC,
ov79_021D22E4,
ov79_021D2460,
FS_OVERLAY_ID(overlay79),
};
UnkStruct_02098DE8 *v1 = Heap_Alloc(param0->heapID, sizeof(UnkStruct_02098DE8));
MI_CpuClear8(v1, sizeof(UnkStruct_02098DE8));
v1->unk_08 = param0->unk_0C->unk_1C[param0->unk_0C->unk_01].unk_02;
v1->unk_04 = PoffinCase_AllocateForSlot(param0->unk_0C->poffinCase, param0->unk_0C->unk_1C[param0->unk_0C->unk_01].unk_00, param0->heapID);
v1->unk_00 = Party_GetPokemonBySlotIndex(param0->unk_0C->unk_10, param0->unk_08);
v1->unk_0A = Options_TextFrameDelay(param0->unk_0C->options);
v1->unk_0B = Options_Frame(param0->unk_0C->options);
param0->appMan = ApplicationManager_New(&v0, v1, param0->heapID);
param0->unk_10 = v1;
return 5;
}
static int sub_02098DE8(UnkStruct_02098BE4 *param0)
{
UnkStruct_02098DE8 *v0;
if (!sub_02098AF8(&param0->appMan)) {
return 5;
}
v0 = (UnkStruct_02098DE8 *)param0->unk_10;
Heap_Free(v0->unk_04);
Heap_Free(v0);
return 6;
}
static int sub_02098E0C(UnkStruct_02098BE4 *param0)
{
u8 v0;
PokemonSummary *v1;
Poffin *v2;
static const u8 v3[] = {
4, 8
};
v1 = Heap_Alloc(param0->heapID, sizeof(PokemonSummary));
v2 = PoffinCase_AllocateForSlot(param0->unk_0C->poffinCase, param0->unk_0C->unk_1C[param0->unk_0C->unk_01].unk_00, param0->heapID);
v1->monData = param0->unk_0C->unk_10;
v1->options = param0->unk_0C->options;
v1->dataType = SUMMARY_DATA_PARTY_MON;
v1->monIndex = param0->unk_08;
v1->monMax = Party_GetCurrentCount(v1->monData);
v1->move = 0;
v1->mode = SUMMARY_MODE_SHOW_CONDITION_CHANGE;
v1->poffin = v2;
v1->showContest = TRUE;
v1->chatotCry = NULL;
PokemonSummaryScreen_FlagVisiblePages(v1, v3);
PokemonSummaryScreen_SetPlayerProfile(v1, param0->unk_0C->unk_0C);
param0->appMan = ApplicationManager_New(&gPokemonSummaryScreenApp, v1, param0->heapID);
param0->unk_10 = (void *)v1;
return 7;
}
static int sub_02098E88(UnkStruct_02098BE4 *param0)
{
u8 v0;
PokemonSummary *v1;
Poffin *v2;
if (!sub_02098AF8(&param0->appMan)) {
return 7;
}
v1 = (PokemonSummary *)param0->unk_10;
Heap_Free(v1->poffin);
Heap_Free(param0->unk_10);
return 0;
}
UnkEnum_02098EAC sub_02098EAC(Poffin *param0, u8 param1)
{
u8 v0[7];
u8 v1, v2, v3;
u8 v4 = Unk_020F685C[param1][0];
u8 v5 = Unk_020F685C[param1][1];
if (v4 == 5) {
return 2;
}
Poffin_StoreAttributesToArray(param0, v0);
v1 = v0[0];
v2 = v0[v4 + 1];
v3 = v0[v5 + 1];
if (v2 == v3) {
return 2;
}
if (v2 > v3) {
return 0;
} else {
return 1;
}
}
void sub_02098EF8(Poffin *param0, Pokemon *param1)
{
u8 v0, v1;
u8 v2, v3;
u8 v4, v5;
float v6;
int v7[6];
u8 v8[7];
u8 v9[7];
v2 = Pokemon_GetNature(param1);
v4 = Unk_020F685C[v2][0];
v5 = Unk_020F685C[v2][1];
Poffin_StoreAttributesToArray(param0, v8);
for (v0 = 0; v0 < 6; v0++) {
v7[v0] = Pokemon_GetValue(param1, MON_DATA_COOL + v0, NULL);
}
v1 = 0;
for (v0 = 1; v0 <= 6; v0++) {
v9[v1++] = v8[v0];
}
if (v4 != 5) {
v6 = (float)v9[v4] * 1.1f;
v9[v4] = (u8)v6;
v6 = (float)v9[v5] * 0.9f;
v9[v5] = (u8)v6;
}
for (v0 = 0; v0 < 6; v0++) {
v7[v0] += v9[v0];
if (v7[v0] > 255) {
v7[v0] = 255;
}
Pokemon_SetValue(param1, 19 + v0, &v7[v0]);
}
v3 = Pokemon_GetValue(param1, MON_DATA_FRIENDSHIP, NULL);
if (v3 < 255) {
++v3;
Pokemon_SetValue(param1, MON_DATA_FRIENDSHIP, &v3);
}
}

View File

@@ -1,246 +0,0 @@
#include "unk_02098FFC.h"
#include <nitro.h>
#include <string.h>
#include "struct_defs/struct_0209903C.h"
#include "struct_defs/struct_0209903C_sub1.h"
#include "struct_defs/struct_0209916C.h"
#include "heap.h"
#include "narc.h"
#include "sprite.h"
#include "sprite_resource.h"
#include "sprite_system.h"
#include "sprite_transfer.h"
#include "sprite_util.h"
static void sub_02099058(UnkStruct_0209903C *param0);
static void sub_02099118(UnkStruct_0209903C *param0);
static void sub_020993A8(UnkStruct_0209903C *param0);
static s16 sub_020994B8(UnkStruct_0209903C *param0, u8 param1);
UnkStruct_0209903C *sub_02098FFC(int heapID, u16 param1, u16 param2, u16 param3, int param4)
{
UnkStruct_0209903C *v0 = Heap_Alloc(heapID, sizeof(UnkStruct_0209903C));
MI_CpuClear8(v0, sizeof(UnkStruct_0209903C));
v0->heapID = heapID;
if (param1 > 16) {
v0->unk_0A = 16;
} else {
v0->unk_0A = param2;
}
v0->unk_0C = param1;
v0->unk_0E = param3;
v0->unk_04 = param4;
sub_02099058(v0);
return v0;
}
void sub_0209903C(UnkStruct_0209903C *param0)
{
sub_02099118(param0);
MI_CpuClear8(param0, sizeof(UnkStruct_0209903C));
Heap_Free(param0);
}
static void sub_02099058(UnkStruct_0209903C *param0)
{
u32 v0, v1;
u8 v2[] = { 1, 1, 1, 1 };
param0->unk_10 = SpriteList_InitRendering(param0->unk_0C, &param0->unk_14, param0->heapID);
v2[1] = param0->unk_0A;
for (v0 = 0; v0 < 4; v0++) {
param0->unk_1A4[v0] = SpriteResourceCollection_New(v2[v0], v0, param0->heapID);
param0->unk_1B4[v0] = SpriteResourceList_New(v2[v0], param0->heapID);
for (v1 = 0; v1 < param0->unk_1B4[v0]->capacity; v1++) {
param0->unk_1B4[v0]->resources[v1] = NULL;
}
}
sub_020993A8(param0);
param0->unk_1C4 = Heap_Alloc(param0->heapID, sizeof(UnkStruct_0209903C_sub1));
MI_CpuClear8(param0->unk_1C4, sizeof(UnkStruct_0209903C_sub1));
}
static void sub_02099118(UnkStruct_0209903C *param0)
{
u32 v0;
Heap_Free(param0->unk_1C4);
SpriteList_Delete(param0->unk_10);
SpriteTransfer_ResetCharTransferList(param0->unk_1B4[0]);
SpriteTransfer_ResetPlttTransferList(param0->unk_1B4[1]);
for (v0 = 0; v0 < 4; v0++) {
SpriteResourceList_Delete(param0->unk_1B4[v0]);
SpriteResourceCollection_Delete(param0->unk_1A4[v0]);
}
}
void sub_02099160(UnkStruct_0209903C *param0)
{
SpriteList_Update(param0->unk_10);
}
UnkStruct_0209916C *sub_0209916C(UnkStruct_0209903C *param0, int param1, u16 param2, u16 param3, u16 param4, u8 param5, u8 param6, int param7)
{
u8 v0;
s16 v1;
u32 v2;
UnkStruct_0209916C *v3;
ManagedSprite *v4 = NULL;
AffineSpriteListTemplate v5;
SpriteResource *v6;
v1 = sub_020994B8(param0, param1);
if (v1 < 0) {
GF_ASSERT(FALSE);
return NULL;
}
v3 = Heap_Alloc(param0->heapID, sizeof(UnkStruct_0209916C));
MI_CpuClear8(v3, sizeof(UnkStruct_0209916C));
v3->unk_00 = v1;
if (param7 == 0) {
v0 = NNS_G2D_VRAM_TYPE_2DMAIN;
} else {
v0 = NNS_G2D_VRAM_TYPE_2DSUB;
}
v6 = param0->unk_1B4[1]->resources[v1];
SpriteResourceCollection_ModifyPalette(param0->unk_1A4[1], param0->unk_1B4[1]->resources[v1], 88, 3 + param1, 0, param0->heapID);
SpriteTransfer_ReplacePlttData(param0->unk_1B4[1]->resources[v1]);
v4 = Heap_Alloc(param0->heapID, sizeof(ManagedSprite));
v4->resourceHeaderList = Heap_Alloc(param0->heapID, sizeof(SpriteResourcesHeaderList));
v4->resourceHeaderList->headers = Heap_Alloc(param0->heapID, sizeof(SpriteResourcesHeader));
v4->resourceHeader = v4->resourceHeaderList->headers;
SpriteResourcesHeader_Init(v4->resourceHeader, 0xe000, 0xe000 + v1, 0xe000, 0xe000, 0xffffffff, 0xffffffff, 0, param5, param0->unk_1A4[0], param0->unk_1A4[1], param0->unk_1A4[2], param0->unk_1A4[3], NULL, NULL);
v5.list = param0->unk_10;
v5.resourceData = v4->resourceHeader;
v5.position.x = FX32_CONST(param2);
v5.position.y = FX32_CONST(param3);
v5.position.z = FX32_CONST(param4);
if (v0 == NNS_G2D_VRAM_TYPE_2DSUB) {
v5.position.y += (192 << FX32_SHIFT);
}
v5.affineScale.x = FX32_ONE;
v5.affineScale.y = FX32_ONE;
v5.affineScale.z = FX32_ONE;
v5.affineZRotation = 0;
v5.priority = param6;
v5.vramType = v0;
v5.heapID = param0->heapID;
v4->sprite = SpriteList_AddAffine(&v5);
if (v4->sprite != NULL) {
Sprite_SetAnim(v4->sprite, 0);
v2 = SpriteTransfer_GetPlttOffset(
v6, v0);
Sprite_SetExplicitPalette(v4->sprite, v2);
} else {
GF_ASSERT(FALSE);
}
v3->unk_04 = v4;
return v3;
}
void sub_0209933C(UnkStruct_0209903C *param0, UnkStruct_0209916C *param1, int param2)
{
SpriteResource *v0 = param0->unk_1B4[1]->resources[param1->unk_00];
SpriteResourceCollection_ModifyPalette(param0->unk_1A4[1], v0, 88, 3 + param2, 0, param0->heapID);
SpriteTransfer_ReplacePlttData(v0);
}
void sub_02099370(UnkStruct_0209903C *param0, UnkStruct_0209916C *param1)
{
Sprite_DeleteAndFreeResources(param1->unk_04);
param0->unk_1C4[param1->unk_00].unk_00 = 0;
param0->unk_1C4[param1->unk_00].unk_02 = 0;
param0->unk_1C4[param1->unk_00].unk_01 = 0;
Heap_Free(param1);
}
static void sub_020993A8(UnkStruct_0209903C *param0)
{
int v0;
SpriteResourceCollection *v1;
SpriteResourceList *v2;
SpriteResource *v3;
NARC *v4 = NARC_ctor(NARC_INDEX_GRAPHIC__PORUACT, param0->heapID);
v2 = param0->unk_1B4[0];
v2->resources[0] = SpriteResourceCollection_AddTilesFrom(param0->unk_1A4[0], v4, 0, 0, 0xe000, param0->unk_0E, param0->heapID);
GF_ASSERT(v2->resources[0] != NULL);
switch (param0->unk_04) {
case 1:
SpriteTransfer_RequestCharAtEnd(v2->resources[0]);
break;
case 2:
SpriteTransfer_RequestCharAtEndWithHardwareMappingType(v2->resources[0]);
break;
case 0:
default:
SpriteTransfer_RequestChar(v2->resources[0]);
break;
}
for (v0 = 0; v0 < 2; v0++) {
v2 = param0->unk_1B4[2 + v0];
v2->resources[0] = SpriteResourceCollection_AddFrom(param0->unk_1A4[2 + v0], v4, 1 + v0, 0, 0xe000, 2 + v0, param0->heapID);
GF_ASSERT(v2->resources[0] != NULL);
}
v2 = param0->unk_1B4[1];
for (v0 = 0; v0 < param0->unk_0A; v0++) {
v2->resources[v0] = SpriteResourceCollection_AddPaletteFrom(param0->unk_1A4[1], v4, 3 + 1, 0, 0xe000 + v0, param0->unk_0E, 1, param0->heapID);
GF_ASSERT(v2->resources[v0] != NULL);
SpriteTransfer_RequestPlttWholeRange(v2->resources[v0]);
}
NARC_dtor(v4);
}
static s16 sub_020994B8(UnkStruct_0209903C *param0, u8 param1)
{
u16 v0 = 0;
for (v0 = 0; v0 < param0->unk_0A; v0++) {
if (!param0->unk_1C4[v0].unk_00) {
param0->unk_1C4[v0].unk_02 = v0;
param0->unk_1C4[v0].unk_01 = param1;
param0->unk_1C4[v0].unk_00 = 1;
return v0;
}
}
return -1;
}