more menu

This commit is contained in:
DizzyEggg
2025-06-13 12:10:16 +02:00
parent 1693ec80d8
commit 30bdeee51e
51 changed files with 911 additions and 918 deletions

View File

@@ -17,6 +17,9 @@ typedef struct TouchScreenMenuInput
/* R=0x8 | B=0x6 */ DungeonPos unk8;
} TouchScreenMenuInput;
#define DEFAULT_MENU_ENTRY_HEIGHT 12
#define TWO_LINES_MENU_ENTRY_HEIGHT 24
// size: R=0x34 | NDS=0x32?
typedef struct MenuInputStruct
{
@@ -25,7 +28,7 @@ typedef struct MenuInputStruct
/* 0x6 */ s16 firstEntryY;
/* 0x8 */ DungeonPos cursorArrowPos;
/* 0xC */ DungeonPos leftRightArrowsPos;
/* 0x10 */ u32 unk10;
/* 0x10 */ s32 entryHeight; // Either 12, or 24 when each entry has text on two lines.
/* 0x14 */ DungeonPos unk14;
/* 0x18 */ s16 menuIndex;
/* 0x1A */ s16 currPageEntries;
@@ -78,4 +81,68 @@ typedef struct unkStructFor8013AA0
SpriteOAM unk28;
} unkStructFor8013AA0;
// Used for creating windows with an input menu.
// size: R=0x9C | B=?
typedef struct MenuWindow
{
/* 0x0 */ MenuInputStruct input;
/* 0x34 */ u32 menuWinId;
/* 0x38 */ WindowTemplate *menuWindow;
/* 0x3C */ WindowTemplates windows;
} MenuWindow;
// Same as above, but has one additional WindowHeader field.
// size: R=0xA0 | B=0x9C?
typedef struct MenuHeaderWindow
{
/* 0x0 */ MenuWindow m; // short name so it's easier to write. 'm' standing for 'menu' or 'menuWindow'
/* 0x9C */ WindowHeader header;
} MenuHeaderWindow;
// These macros are used for updating menu windows, as the last page can have less entries than other pages, so the window's height needs to reflect that.
// Note: In order to get matching ASM, this macro had to be created.
// It's probable the code below is not exactly how it was originally written, but it generates the same asm.
#define UPDATE_MENU_WINDOW_HEIGHT_INTERNAL(ptr, _newHeight) \
{ \
UNUSED s32 new10; \
s16 newHeight; \
s16 newHeightVal = (_newHeight); \
UNUSED s32 dummyMatch = newHeightVal; \
UNUSED s16 oldHeight = (ptr).windows.id[(ptr).menuWinId].height; \
dummyMatch = 0; \
new10 = newHeightVal + 2; \
newHeight = newHeightVal; \
\
(ptr).windows.id[(ptr).menuWinId].height = newHeight; \
(ptr).windows.id[(ptr).menuWinId].unk10 = newHeightVal + 2; \
\
ResetUnusedInputStruct(); \
ShowWindows(&(ptr).windows, TRUE, TRUE); \
}
#define UPDATE_MENU_WINDOW_HEIGHT(ptr) \
{ \
UPDATE_MENU_WINDOW_HEIGHT_INTERNAL(ptr, CalcEntriesTotalHeight((ptr).input.currPageEntries, DEFAULT_MENU_ENTRY_HEIGHT) + 2) \
}
// For Windows where height is the same as entries height.
#define UPDATE_MENU_WINDOW_HEIGHT_2(ptr) \
{ \
s32 newHeightVal = CalcEntriesTotalHeight((ptr).input.currPageEntries, DEFAULT_MENU_ENTRY_HEIGHT) + 2; \
UNUSED s16 oldHeight = (ptr).windows.id[(ptr).menuWinId].height; \
s16 newHeight = newHeightVal; \
\
(ptr).windows.id[(ptr).menuWinId].height = newHeight; \
(ptr).windows.id[(ptr).menuWinId].unk10 = newHeight; \
\
ResetUnusedInputStruct(); \
ShowWindows(&(ptr).windows, TRUE, TRUE); \
}
// For menu windows with two lines entries(for example job mail)
#define UPDATE_TWO_LINES_MENU_WINDOW_HEIGHT(ptr) \
{ \
UPDATE_MENU_WINDOW_HEIGHT_INTERNAL(ptr, CalcTwoLinesEntriesTotalHeight((ptr).input.currPageEntries, TWO_LINES_MENU_ENTRY_HEIGHT) + 2) \
}
#endif // GUARD_MENU_H

View File

@@ -1,73 +0,0 @@
#ifndef GUARD_struct_sub80095e4_H
#define GUARD_struct_sub80095e4_H
#include "structs/menu.h"
#include "structs/str_text.h"
#include "text_1.h"
#include "text_3.h"
// Struct related with sub_80095E4
// size: R=0x9C | B=?
typedef struct struct_Sub80095E4
{
/* 0x0 */ MenuInputStruct input;
/* 0x34 */ u32 winId;
/* 0x38 */ WindowTemplate *unk38;
/* 0x3C */ WindowTemplates windows;
} struct_Sub80095E4;
// Has 1 additional array
// size: R=0xA0 | B=0x9C?
typedef struct struct_Sub80095E4_2
{
/* 0x0 */ struct_Sub80095E4 s0; // s as in 'struct' ; decided to go against unk as to not have `->unk0->unk3C`
/* 0x9C */ WindowHeader header;
} struct_Sub80095E4_2;
// Note: In order to get matching ASM, this macro had to be created.
// It's probable the code below is not exactly how it was originally written, but it generates the same asm.
#define SUB_8009_MATCH(ptr, _a0) \
{ \
UNUSED s32 new10; \
s16 newE; \
s16 a0 = (_a0); \
UNUSED s32 a0_ = a0; \
UNUSED s16 oldE = (ptr).windows.id[(ptr).winId].height; \
a0_ = 0; \
new10 = a0 + 2; \
newE = a0; \
\
(ptr).windows.id[(ptr).winId].height = newE; \
(ptr).windows.id[(ptr).winId].unk10 = a0 + 2; \
\
ResetUnusedInputStruct(); \
ShowWindows(&(ptr).windows, TRUE, TRUE); \
}
#define SUB_80095E4_CALL(ptr) \
{ \
SUB_8009_MATCH(ptr, sub_80095E4((ptr).input.currPageEntries, 12) + 2) \
}
// For sub_801C440 and sub_8023420 where unkE and unk10 are the same.
#define SUB_80095E4_CALL_2(ptr) \
{ \
s32 a0 = sub_80095E4((ptr).input.currPageEntries, 12) + 2; \
UNUSED s16 oldE = (ptr).windows.id[(ptr).winId].height; \
s16 newE = a0; \
\
(ptr).windows.id[(ptr).winId].height = newE; \
(ptr).windows.id[(ptr).winId].unk10 = newE; \
\
ResetUnusedInputStruct(); \
ShowWindows(&(ptr).windows, TRUE, TRUE); \
}
// sub_802BF30 and sub_802C328 use a different function call, and 24 instead of 12
#define SUB_8009614_CALL(ptr) \
{ \
SUB_8009_MATCH(ptr, sub_8009614((ptr).input.currPageEntries, 24) + 2) \
}
#endif // GUARD_struct_sub80095e4_H