Move pokenav list item union out of list struct

This commit is contained in:
GriffinR 2021-11-13 11:27:11 -05:00
parent 3b91d8fdaf
commit ec05157568
5 changed files with 20 additions and 17 deletions

View File

@ -6,6 +6,7 @@
#include "pokemon_storage_system.h" #include "pokemon_storage_system.h"
typedef u32 (*LoopedTask)(s32 state); typedef u32 (*LoopedTask)(s32 state);
typedef void (*PokenavListItemBufferFunc)(struct PokenavListItem *, u8 *);
struct PokenavMonListItem struct PokenavMonListItem
{ {
@ -21,12 +22,17 @@ struct PokenavMatchCallEntry
u16 headerId; u16 headerId;
}; };
struct PokenavListTemplate struct PokenavListItem
{ {
union { union {
struct PokenavMonListItem *monList; struct PokenavMonListItem mon;
struct PokenavMatchCallEntry *matchCallEntries; struct PokenavMatchCallEntry call;
} list; } item;
};
struct PokenavListTemplate
{
struct PokenavListItem * list;
u16 count; u16 count;
u16 unk6; u16 unk6;
u8 unk8; u8 unk8;
@ -36,10 +42,7 @@ struct PokenavListTemplate
u8 maxShowed; u8 maxShowed;
u8 fillValue; u8 fillValue;
u8 fontId; u8 fontId;
union { PokenavListItemBufferFunc bufferItemFunc;
void (*bufferMonItemFunc)(struct PokenavMonListItem *, u8 *);
void (*bufferMatchCallItemFunc)(struct PokenavMatchCallEntry *, u8 *);
} listFunc;
void (*unk14)(u16 a0, u32 a1, u32 a2); void (*unk14)(u16 a0, u32 a1, u32 a2);
}; };

View File

@ -672,7 +672,7 @@ static void InitConditionSearchListMenuTemplate(void)
{ {
struct PokenavListTemplate template; struct PokenavListTemplate template;
template.list.monList = GetSearchResultsMonDataList(); template.list = (struct PokenavListItem *)GetSearchResultsMonDataList();
template.count = GetSearchResultsMonListCount(); template.count = GetSearchResultsMonListCount();
template.unk8 = 4; template.unk8 = 4;
template.unk6 = GetSearchResultsCurrentListIndex(); template.unk6 = GetSearchResultsCurrentListIndex();
@ -682,7 +682,7 @@ static void InitConditionSearchListMenuTemplate(void)
template.maxShowed = 8; template.maxShowed = 8;
template.fillValue = 2; template.fillValue = 2;
template.fontId = FONT_NORMAL; template.fontId = FONT_NORMAL;
template.listFunc.bufferMonItemFunc = BufferSearchMonListItem; template.bufferItemFunc = (PokenavListItemBufferFunc)BufferSearchMonListItem;
template.unk14 = NULL; template.unk14 = NULL;
sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0); sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0);
} }

View File

@ -870,7 +870,7 @@ static u32 ExitMatchCall(s32 state)
static void InitMatchCallPokenavListMenuTemplate(void) static void InitMatchCallPokenavListMenuTemplate(void)
{ {
struct PokenavListTemplate template; struct PokenavListTemplate template;
template.list.matchCallEntries = sub_81CAE94(); template.list = (struct PokenavListItem *)sub_81CAE94();
template.count = GetNumberRegistered(); template.count = GetNumberRegistered();
template.unk8 = 4; template.unk8 = 4;
template.unk6 = 0; template.unk6 = 0;
@ -880,7 +880,7 @@ static void InitMatchCallPokenavListMenuTemplate(void)
template.maxShowed = 8; template.maxShowed = 8;
template.fillValue = 3; template.fillValue = 3;
template.fontId = FONT_NARROW; template.fontId = FONT_NARROW;
template.listFunc.bufferMatchCallItemFunc = BufferMatchCallNameAndDesc; template.bufferItemFunc = (PokenavListItemBufferFunc)BufferMatchCallNameAndDesc;
template.unk14 = TryDrawRematchPokeballIcon; template.unk14 = TryDrawRematchPokeballIcon;
sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2); sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2);
CreateTask(Task_FlashPokeballIcons, 7); CreateTask(Task_FlashPokeballIcons, 7);

View File

@ -49,7 +49,7 @@ struct PokenavSub17Substruct
u32 loopedTaskId; u32 loopedTaskId;
s32 unk2C; s32 unk2C;
u32 unk30; u32 unk30;
void (*unk34)(struct PokenavMatchCallEntry *, u8*); PokenavListItemBufferFunc unk34;
void (*unk38)(u16, u32, u32); void (*unk38)(u16, u32, u32);
struct Sprite *rightArrow; struct Sprite *rightArrow;
struct Sprite *upArrow; struct Sprite *upArrow;
@ -936,7 +936,7 @@ void ToggleMatchCallVerticalArrows(bool32 shouldHide)
void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavListTemplate *template) void InitMatchCallWindowState(struct MatchCallWindowState *dst, struct PokenavListTemplate *template)
{ {
dst->unk10 = template->list.matchCallEntries; dst->unk10 = template->list;
dst->windowTopIndex = template->unk6; dst->windowTopIndex = template->unk6;
dst->listLength = template->count; dst->listLength = template->count;
dst->unkC = template->unk8; dst->unkC = template->unk8;
@ -968,7 +968,7 @@ static bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *dest, co
dest->listWindow.bg = bgTemplate->bg; dest->listWindow.bg = bgTemplate->bg;
dest->listWindow.unk6 = a3; dest->listWindow.unk6 = a3;
dest->unk34 = template->listFunc.bufferMatchCallItemFunc; dest->unk34 = template->bufferItemFunc;
dest->unk38 = template->unk14; dest->unk38 = template->unk14;
dest->listWindow.unk1 = template->fillValue; dest->listWindow.unk1 = template->fillValue;
dest->listWindow.unk2 = template->item_X; dest->listWindow.unk2 = template->item_X;

View File

@ -680,7 +680,7 @@ static void DrawListIndexNumber(s32 windowId, s32 index, s32 max)
static void InitMonRibbonPokenavListMenuTemplate(void) static void InitMonRibbonPokenavListMenuTemplate(void)
{ {
struct PokenavListTemplate template; struct PokenavListTemplate template;
template.list.monList = GetMonRibbonMonListData(); template.list = (struct PokenavListItem *)GetMonRibbonMonListData();
template.count = GetRibbonsMonListCount(); template.count = GetRibbonsMonListCount();
template.unk8 = 4; template.unk8 = 4;
template.unk6 = GetRibbonListMenuCurrIndex(); template.unk6 = GetRibbonListMenuCurrIndex();
@ -690,7 +690,7 @@ static void InitMonRibbonPokenavListMenuTemplate(void)
template.maxShowed = 8; template.maxShowed = 8;
template.fillValue = 2; template.fillValue = 2;
template.fontId = FONT_NORMAL; template.fontId = FONT_NORMAL;
template.listFunc.bufferMonItemFunc = BufferRibbonMonInfoText; template.bufferItemFunc = (PokenavListItemBufferFunc)BufferRibbonMonInfoText;
template.unk14 = NULL; template.unk14 = NULL;
sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0); sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0);
} }