list menu is decompiled

This commit is contained in:
DizzyEggg
2018-03-03 14:58:41 +01:00
parent 87274b9eed
commit 18a92fdcc0
11 changed files with 303 additions and 654 deletions

View File

@@ -45,7 +45,6 @@ extern void DestroyListMenuTask(u8, u16*, u16*);
extern void sub_819746C(u8, bool8);
extern void NewMenuHelpers_DrawStdWindowFrame(u8, bool8);
extern void sub_81B9328(void);
extern void sub_81AF078(u32, bool8, struct ListMenu *);
extern void CB2_ReturnToField(void);
// this file's functions
@@ -79,18 +78,18 @@ static const struct ListMenuTemplate sDaycareListMenuLevelTemplate =
.unk_08 = DaycarePrintMonInfo,
.totalItems = 3,
.maxShowed = 3,
.unk_10 = 0,
.windowId = 0,
.unk_11 = 0,
.unk_12 = 8,
.cursor_Y = 0,
.cursor_X = 0,
.upText_Y = 1,
.cursorColor = 2,
.fillColor = 1,
.cursorShadowColor = 3,
.unk_16_0 = TRUE,
.spaceBetweenItems = 0,
.cursorPal = 2,
.fillValue = 1,
.cursorShadowPal = 3,
.lettersSpacing = 1,
.unk_16_3 = 0,
.scrollMultiple = LIST_NO_MULTIPLE_SCROLL,
.unk_17_0 = 1,
.fontId = 1,
.cursorKind = 0
};
@@ -1299,7 +1298,7 @@ void ShowDaycareLevelMenu(void)
NewMenuHelpers_DrawStdWindowFrame(windowId, FALSE);
menuTemplate = sDaycareListMenuLevelTemplate;
menuTemplate.unk_10 = windowId;
menuTemplate.windowId = windowId;
listMenuTaskId = ListMenuInit(&menuTemplate, 0, 0);
CopyWindowToVram(windowId, 3);

View File

@@ -113,7 +113,7 @@ void sub_812719C(u8 taskId);
void sub_81271CC(u8 taskId);
void sub_8127268(u8 taskId);
void sub_8127454(u8 *dest, u16 decorId);
void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu);
void sub_8127480(s32 a0, bool8 flag, struct ListMenu *menu);
void sub_81274A0(u8 a0, s32 a1, u8 a2);
void sub_8127620(u8 taskId);
void sub_812764C(u8 taskId);
@@ -813,7 +813,7 @@ void sub_8127454(u8 *dest, u16 decorId)
StringAppend(dest, gDecorations[decorId].name);
}
void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu)
void sub_8127480(s32 a0, bool8 flag, struct ListMenu *menu)
{
if (flag != TRUE)
{

View File

@@ -128,7 +128,7 @@ void sub_81ABAC4(void);
void sub_81ABAE0(void);
u8 sub_81AB1F0(u8);
void sub_81AC23C(u8);
void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu*);
void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu*);
void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a);
void ItemMenu_UseOutOfBattle(u8 taskId);
void ItemMenu_Toss(u8 taskId);
@@ -688,7 +688,7 @@ void get_name(s8 *dest, u16 itemId)
}
}
void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu *unused)
void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu *unused)
{
if (b != 1)
{

View File

@@ -6,8 +6,11 @@
#include "main.h"
#include "task.h"
#include "menu_indicators.h"
#include "strings.h"
#include "sound.h"
#include "constants/songs.h"
struct ListMenuStruct
struct UnknownMysteryGiftLinkMenuStruct
{
s32 field_0;
u8 field_4;
@@ -15,27 +18,33 @@ struct ListMenuStruct
u8 field_6;
};
struct UnknownListMenuStruct
struct UnknownListMenuPals
{
u8 x;
u8 y;
u8 width;
u8 height;
u8 palNum;
u8 cursorPal:4;
u8 fillValue:4;
u8 cursorShadowPal:4;
u8 lettersSpacing:6;
u8 field_2_2:6; // unused
u8 fontId:7;
u8 field_3_7:1;
};
extern struct ListMenuStruct gUnknown_0203CE84;
extern struct UnknownMysteryGiftLinkMenuStruct gUnknown_0203CE84;
// this file's functions
u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow);
bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown);
void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count);
void ListMenuDrawCursor(struct ListMenu *list);
void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2);
u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind);
static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow);
static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown);
static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count);
static void ListMenuDrawCursor(struct ListMenu *list);
static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2);
static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind);
// IWRAM common
struct UnknownListMenuPals gUnknown_03006300;
struct ListMenuTemplate gMultiuseListMenuTemplate;
// code
void ListMenuDummyTask(u8 taskId)
static void ListMenuDummyTask(u8 taskId)
{
}
@@ -111,7 +120,7 @@ u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16
}
// unused
u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuStruct *arg1, u16 scrollOffset, u16 selectedRow)
u8 ListMenuInitWithWindows(struct ListMenuTemplate *listMenuTemplate, struct UnknownListMenuWindowStruct *arg1, u16 scrollOffset, u16 selectedRow)
{
s32 i;
@@ -208,19 +217,19 @@ void sub_81AE70C(u8 listTaskId)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
FillWindowPixelBuffer(list->template.windowId, (list->template.fillPal << 4) | (list->template.fillPal));
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
ListMenuDrawCursor(list);
CopyWindowToVram(list->template.windowId, 2);
}
// unused
void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillPal, u8 cursorShadowPal)
void ChangeListMenuPals(u8 listTaskId, u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
{
struct ListMenu *list = (void*) gTasks[listTaskId].data;
list->template.cursorPal = cursorPal;
list->template.fillPal = fillPal;
list->template.fillValue = fillValue;
list->template.cursorShadowPal = cursorShadowPal;
}
@@ -283,20 +292,7 @@ u16 ListMenuGetYCoordForPrintingArrowCursor(u8 listTaskId)
return list->selectedRow * yMultiplier + list->template.upText_Y;
}
struct ListMenuPals
{
u8 field_0_0:4;
u8 field_0_4:4;
u8 field_1_0:4;
u8 lettersSpacing:6;
u8 field_2_2:6;
u8 fontId:7;
u8 field_3_7:1;
};
extern struct ListMenuPals gUnknown_03006300;
u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow)
static u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow)
{
u8 listTaskId = CreateTask(ListMenuDummyTask, 0);
struct ListMenu *list = (void*) gTasks[listTaskId].data;
@@ -309,9 +305,9 @@ u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOff
list->unk_1E = 0xFF;
list->unk_1F = 0;
gUnknown_03006300.field_0_0 = list->template.cursorPal;
gUnknown_03006300.field_0_4 = list->template.fillPal;
gUnknown_03006300.field_1_0 = list->template.cursorShadowPal;
gUnknown_03006300.cursorPal = list->template.cursorPal;
gUnknown_03006300.fillValue = list->template.fillValue;
gUnknown_03006300.cursorShadowPal = list->template.cursorShadowPal;
gUnknown_03006300.lettersSpacing = list->template.lettersSpacing;
gUnknown_03006300.fontId = list->template.fontId;
gUnknown_03006300.field_3_7 = 0;
@@ -319,7 +315,7 @@ u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOff
if (list->template.totalItems < list->template.maxShowed)
list->template.maxShowed = list->template.totalItems;
FillWindowPixelBuffer(list->template.windowId, (list->template.fillPal << 4) | (list->template.fillPal));
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
ListMenuDrawCursor(list);
ListMenuCallSelectionChangedCallback(list, 1);
@@ -327,14 +323,14 @@ u8 ListMenuInitInternal(struct ListMenuTemplate *listMenuTemplate, u16 scrollOff
return listTaskId;
}
void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
{
u8 colors[3];
if (gUnknown_03006300.field_3_7)
{
colors[0] = gUnknown_03006300.field_0_4;
colors[1] = gUnknown_03006300.field_0_0;
colors[2] = gUnknown_03006300.field_1_0;
colors[0] = gUnknown_03006300.fillValue;
colors[1] = gUnknown_03006300.cursorPal;
colors[2] = gUnknown_03006300.cursorShadowPal;
AddTextPrinterParameterized2(list->template.windowId,
gUnknown_03006300.fontId,
x, y,
@@ -345,7 +341,7 @@ void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
}
else
{
colors[0] = list->template.fillPal;
colors[0] = list->template.fillValue;
colors[1] = list->template.cursorPal;
colors[2] = list->template.cursorShadowPal;
AddTextPrinterParameterized2(list->template.windowId,
@@ -356,7 +352,7 @@ void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y)
}
}
void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count)
static void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u16 count)
{
s32 i;
u8 x, y;
@@ -378,12 +374,10 @@ void ListMenuPrintEntries(struct ListMenu *list, u16 startIndex, u16 yOffset, u1
}
}
extern const u8 gText_SelectorArrow2[];
void ListMenuDrawCursor(struct ListMenu *list)
static void ListMenuDrawCursor(struct ListMenu *list)
{
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
u8 x = list->template.cursor_Y;
u8 x = list->template.cursor_X;
u8 y = list->selectedRow * yMultiplier + list->template.upText_Y;
switch (list->template.cursorKind)
{
@@ -409,7 +403,7 @@ void ListMenuDrawCursor(struct ListMenu *list)
}
}
u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind)
static u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind)
{
struct CursorStruct cursor;
@@ -423,3 +417,213 @@ u8 ListMenuAddCursorObject(struct ListMenu *list, u32 cursorKind)
return ListMenuAddCursorObjectInternal(&cursor, cursorKind);
}
static void ListMenuErasePrintedCursor(struct ListMenu *list, u16 selectedRow)
{
u8 cursorKind = list->template.cursorKind;
if (cursorKind == 0)
{
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
u8 width = GetMenuCursorDimensionByFont(list->template.fontId, 0);
u8 height = GetMenuCursorDimensionByFont(list->template.fontId, 1);
FillWindowPixelRect(list->template.windowId,
(list->template.fillValue << 4) | (list->template.fillValue),
list->template.cursor_X,
selectedRow * yMultiplier + list->template.upText_Y,
width,
height);
}
}
static u8 ListMenuUpdateSelectedRowIndexAndScrollOffset(struct ListMenu *list, bool8 movingDown)
{
u16 selectedRow = list->selectedRow;
u16 scrollOffset = list->scrollOffset;
u16 newRow;
u32 newScroll;
if (!movingDown)
{
if (list->template.maxShowed == 1)
newRow = 0;
else
newRow = list->template.maxShowed - ((list->template.maxShowed / 2) + (list->template.maxShowed % 2)) - 1;
if (scrollOffset == 0)
{
while (selectedRow != 0)
{
selectedRow--;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
return 0;
}
else
{
while (selectedRow > newRow)
{
selectedRow--;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
newScroll = scrollOffset - 1;
}
}
else
{
if (list->template.maxShowed == 1)
newRow = 0;
else
newRow = ((list->template.maxShowed / 2) + (list->template.maxShowed % 2));
if (scrollOffset == list->template.totalItems - list->template.maxShowed)
{
while (selectedRow < list->template.maxShowed - 1)
{
selectedRow++;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
return 0;
}
else
{
while (selectedRow < newRow)
{
selectedRow++;
if (list->template.items[scrollOffset + selectedRow].id != -3)
{
list->selectedRow = selectedRow;
return 1;
}
}
newScroll = scrollOffset + 1;
}
}
list->selectedRow = newRow;
list->scrollOffset = newScroll;
return 2;
}
static void ListMenuScroll(struct ListMenu *list, u8 count, bool8 movingDown)
{
if (count >= list->template.maxShowed)
{
FillWindowPixelBuffer(list->template.windowId, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed);
}
else
{
u8 yMultiplier = GetFontAttribute(list->template.fontId, 1) + list->template.unk_16_3;
if (!movingDown)
{
u16 y, width, height;
ScrollWindow(list->template.windowId, 1, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset, 0, count);
y = (list->template.maxShowed * yMultiplier) + list->template.upText_Y;
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
height = (GetWindowAttribute(list->template.windowId, WINDOW_HEIGHT) * 8) - y;
FillWindowPixelRect(list->template.windowId,
(list->template.fillValue << 4) | (list->template.fillValue),
0, y, width, height);
}
else
{
u16 width;
ScrollWindow(list->template.windowId, 0, count * yMultiplier, (list->template.fillValue << 4) | (list->template.fillValue));
ListMenuPrintEntries(list, list->scrollOffset + (list->template.maxShowed - count), list->template.maxShowed - count, count);
width = GetWindowAttribute(list->template.windowId, WINDOW_WIDTH) * 8;
FillWindowPixelRect(list->template.windowId,
(list->template.fillValue << 4) | (list->template.fillValue),
0, 0, width, list->template.upText_Y);
}
}
}
static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown)
{
u16 oldSelectedRow;
u8 selectionChange, i, cursorCount;
oldSelectedRow = list->selectedRow;
cursorCount = 0;
selectionChange = 0;
for (i = 0; i < count; i++)
{
do
{
u8 ret = ListMenuUpdateSelectedRowIndexAndScrollOffset(list, movingDown);
selectionChange |= ret;
if (ret != 2)
break;
cursorCount++;
} while (list->template.items[list->scrollOffset + list->selectedRow].id == -3);
}
if (updateCursorAndCallCallback)
{
switch (selectionChange)
{
case 0:
default:
return TRUE;
case 1:
ListMenuErasePrintedCursor(list, oldSelectedRow);
ListMenuDrawCursor(list);
ListMenuCallSelectionChangedCallback(list, 0);
CopyWindowToVram(list->template.windowId, 2);
break;
case 2:
case 3:
ListMenuErasePrintedCursor(list, oldSelectedRow);
ListMenuScroll(list, cursorCount, movingDown);
ListMenuDrawCursor(list);
ListMenuCallSelectionChangedCallback(list, 0);
CopyWindowToVram(list->template.windowId, 2);
break;
}
}
return FALSE;
}
static void ListMenuCallSelectionChangedCallback(struct ListMenu *list, u8 a2)
{
if (list->template.moveCursorFunc != NULL)
list->template.moveCursorFunc(list->template.items[list->scrollOffset + list->selectedRow].id, a2, list);
}
// unused
void sub_81AF028(u8 cursorPal, u8 fillValue, u8 cursorShadowPal)
{
gUnknown_03006300.cursorPal = cursorPal;
gUnknown_03006300.fillValue = fillValue;
gUnknown_03006300.cursorShadowPal = cursorShadowPal;
gUnknown_03006300.field_3_7 = 1;
}
void sub_81AF078(s32 arg0, u8 arg1, struct ListMenu *list)
{
if (!arg1)
PlaySE(SE_SELECT);
}

View File

@@ -91,7 +91,7 @@ static void sub_81362E0(void);
static void sub_8136344(void);
static void HandlePokeblockListMenuItems(void);
static void sub_81363BC(void);
static void MovePokeblockMenuCursor(u32 pkblId, bool8 arg1, struct ListMenu *arg2);
static void MovePokeblockMenuCursor(s32 pkblId, bool8 arg1, struct ListMenu *arg2);
static void PutPokeblockInfoText(void);
static void HandlePokeblockMenuCursor(u16 cursorPos, u16 arg1);
static void PutPokeblockListMenuString(u8 *dst, u16 pkblId);
@@ -322,15 +322,15 @@ static const struct ListMenuTemplate sPokeblockListMenuTemplate =
.windowId = 1,
.unk_11 = 0,
.unk_12 = 1,
.cursor_Y = 0,
.cursor_X = 0,
.upText_Y = 1,
.cursorPal = 2,
.fillPal = 0,
.fillValue = 0,
.cursorShadowPal = 3,
.unk_16_0 = FALSE,
.spaceBetweenItems = 32,
.lettersSpacing = 0,
.unk_16_3 = 0,
.scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD,
.unk_17_0 = 1,
.fontId = 1,
.cursorKind = 1
};
@@ -620,7 +620,7 @@ static void HandlePokeblockListMenuItems(void)
sPokeblockMenu->items[i].id = LIST_B_PRESSED;
gMultiuseListMenuTemplate = sPokeblockListMenuTemplate;
gMultiuseListMenuTemplate.unk_17_0 = 7;
gMultiuseListMenuTemplate.fontId = 7;
gMultiuseListMenuTemplate.totalItems = sPokeblockMenu->itemsNo;
gMultiuseListMenuTemplate.items = sPokeblockMenu->items;
gMultiuseListMenuTemplate.maxShowed = sPokeblockMenu->maxShowed;
@@ -639,7 +639,7 @@ static void PutPokeblockListMenuString(u8 *dst, u16 pkblId)
StringExpandPlaceholders(txtPtr, gText_LvVar1);
}
static void MovePokeblockMenuCursor(u32 pkblId, bool8 arg1, struct ListMenu *arg2)
static void MovePokeblockMenuCursor(s32 pkblId, bool8 arg1, struct ListMenu *arg2)
{
if (arg1 != TRUE)
{

View File

@@ -6,8 +6,8 @@
#include "main.h"
#include "task.h"
#include "palette.h"
#include "list_menu.h"
#include "window.h"
#include "list_menu.h"
#include "menu.h"
#include "menu_helpers.h"
#include "menu_indicators.h"
@@ -66,7 +66,7 @@ EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL;
void sub_80E9C9C(u8 taskId);
void game_continue(u8 taskId);
void sub_80E9DEC(u32 a0, bool8 flag, struct ListMenu *menu);
void sub_80E9DEC(s32 a0, bool8 flag, struct ListMenu *menu);
void sub_80E9E00(u8 taskId);
void sub_80E9E44(u8 taskId);
void sub_80E9E90(u8 taskId);
@@ -919,7 +919,7 @@ void game_continue(u8 taskId)
gMultiuseListMenuTemplate.maxShowed = data[3];
}
void sub_80E9DEC(u32 a0, bool8 flag, struct ListMenu *menu)
void sub_80E9DEC(s32 a0, bool8 flag, struct ListMenu *menu)
{
if (flag != TRUE)
{