mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2025-02-18 12:08:16 +00:00
Menu refactor and portability (#841)
Quite big PR that aims to document most of `menu.c` and make the code more portable. I had to declare `u16* func_80106A28(u32 arg0, u16 kind);` on the top of `main.c`. Without it the compiler assumes it returns an `int`, which is not big enough for 64-bit pointers. It took me a while to realise that was the cause of the crash. We will have more of them in the future. EDIT: Ignore the commit `******* FIX`. It was meant to be squashed for a clearer commit history but I forgot to do it.
This commit is contained in:
parent
a8ff78f61d
commit
e37320de08
@ -114,12 +114,12 @@ segments:
|
||||
- [0x3C4D0, .rodata, 5087C] # func_800F298C
|
||||
- [0x3C548, .rodata, menu] # strings
|
||||
- [0x3C658, .rodata, menu] # HD exclusive array of strings
|
||||
- [0x3C6F8, .rodata, menu] # DrawMenuFamiliars
|
||||
- [0x3C718, .rodata, menu] # DrawMenu
|
||||
- [0x3C6F8, .rodata, menu] # MenuDrawFamiliars
|
||||
- [0x3C718, .rodata, menu] # MenuDraw
|
||||
- [0x3C758, .rodata, menu] # func_800F9F40
|
||||
- [0x3C788, .rodata, menu] # MenuHandleCursorInput
|
||||
- [0x3C7A0, .rodata, menu] # HandleMenu str
|
||||
- [0x3C7C8, .rodata, menu] # HandleMenu jtbl
|
||||
- [0x3C7A0, .rodata, menu] # MenuHandle str
|
||||
- [0x3C7C8, .rodata, menu] # MenuHandle jtbl
|
||||
- [0x3CC18, .rodata, 5D6C4]
|
||||
- [0x3CC60, rodata]
|
||||
- [0x3CC78, .rodata, 627C4] # jtbl_800DCC78
|
||||
|
@ -122,11 +122,11 @@ segments:
|
||||
- [0x3C534, .rodata, 5087C] # func_800F2860
|
||||
- [0x3C55C, .rodata, 5087C] # func_800F298C
|
||||
- [0x3C5D4, .rodata, menu] # strings
|
||||
- [0x3C68C, .rodata, menu] # DrawMenuFamiliars
|
||||
- [0x3C6AC, .rodata, menu] # DrawMenu
|
||||
- [0x3C68C, .rodata, menu] # MenuDrawFamiliars
|
||||
- [0x3C6AC, .rodata, menu] # MenuDraw
|
||||
- [0x3C71C, .rodata, menu] # MenuHandleCursorInput
|
||||
- [0x3C734, .rodata, menu] # HandleMenu str
|
||||
- [0x3C75C, .rodata, menu] # HandleMenu jtbl
|
||||
- [0x3C734, .rodata, menu] # MenuHandle str
|
||||
- [0x3C75C, .rodata, menu] # MenuHandle jtbl
|
||||
- [0x3CBAC, .rodata, 5D6C4] # func_800FD6C4
|
||||
- [0x3CBF4, rodata]
|
||||
- [0x3CC0C, .rodata, 627C4]
|
||||
|
@ -238,8 +238,8 @@ func_800F2658 = 0x800F2CDC;
|
||||
func_800F298C = 0x800F3010;
|
||||
func_800F53A4 = 0x800F59B8;
|
||||
func_800F7244 = 0x800F77BC;
|
||||
DrawMenuFamiliars = 0x800F8494;
|
||||
DrawMenu = 0x800F9458;
|
||||
MenuDrawFamiliars = 0x800F8494;
|
||||
MenuDraw = 0x800F9458;
|
||||
func_800F9F40 = 0x800FA0A0;
|
||||
MenuHandleCursorInput = 0x800FA190;
|
||||
func_800FA3C4 = 0x800FA520;
|
||||
@ -248,7 +248,7 @@ func_800FAE98 = 0x800FAFF0;
|
||||
func_800FB160 = 0x800FB2B8;
|
||||
func_800FB1EC = 0x800FB344;
|
||||
func_800FB23C = 0x800FB394;
|
||||
HandleMenu = 0x800FBD84;
|
||||
MenuHandle = 0x800FBD84;
|
||||
TimeAttackController = 0x800FD474;
|
||||
func_800FD6C4 = 0x800FD678;
|
||||
GetEquipOrder = 0x800FD6F8;
|
||||
@ -497,7 +497,7 @@ D_80137608 = 0x801371E0;
|
||||
g_IsSelectingEquipment = 0x801371E4;
|
||||
g_EquipmentCursor = 0x801371E8;
|
||||
D_80137614 = 0x801371EC;
|
||||
D_80137618 = 0x801371F0;
|
||||
g_EquipOrderType = 0x801371F0;
|
||||
g_MenuData = 0x801371F4;
|
||||
D_80137638 = 0x80137210;
|
||||
D_801376B0 = 0x80137288;
|
||||
|
@ -174,9 +174,9 @@ FreePrimitives = 0x800EDE78;
|
||||
RenderPrimitives = 0x800EDEDC;
|
||||
CheckCollision = 0x800EF45C;
|
||||
SetNextRoomToLoad = 0x800F0BC0;
|
||||
DrawMenu = 0x800F8F28;
|
||||
MenuDraw = 0x800F8F28;
|
||||
MenuHandleCursorInput = 0x800FA034;
|
||||
HandleMenu = 0x800FBC24;
|
||||
MenuHandle = 0x800FBC24;
|
||||
TimeAttackController = 0x800FD4C0;
|
||||
GetEquipOrder = 0x800FD744;
|
||||
GetEquipCount = 0x800FD760;
|
||||
@ -262,6 +262,7 @@ g_IsCloakLiningUnlocked = 0x80137600;
|
||||
g_IsCloakColorUnlocked = 0x80137604;
|
||||
g_IsSelectingEquipment = 0x8013760C;
|
||||
g_EquipmentCursor = 0x80137610;
|
||||
g_EquipOrderType = 0x80137618;
|
||||
g_MenuData = 0x8013761C;
|
||||
g_JosephsCloakContext = 0x801376EE;
|
||||
g_RelicMenuFadeTimer = 0x80137850;
|
||||
|
@ -1377,7 +1377,7 @@ void func_800F298C(void) {
|
||||
func_801028AC(1);
|
||||
break;
|
||||
case 0x2:
|
||||
HandleMenu();
|
||||
MenuHandle();
|
||||
func_801028AC(1);
|
||||
break;
|
||||
case 0x14:
|
||||
|
@ -26,6 +26,26 @@
|
||||
#define GET_GREEN(x) ((x)&GREEN_MASK)
|
||||
#define GET_BLUE(x) ((x)&BLUE_MASK)
|
||||
|
||||
typedef enum {
|
||||
MENU_DG_MAIN,
|
||||
MENU_DG_BG,
|
||||
MENU_DG_EQUIP_OVERVIEW,
|
||||
MENU_DG_EQUIP_SELECTOR,
|
||||
MENU_DG_INFO_BAR,
|
||||
MENU_DG_RELICS,
|
||||
MENU_DG_SPELLS,
|
||||
MENU_DG_SETTINGS,
|
||||
MENU_DG_CLOAK_COLOR,
|
||||
MENU_DG_CFG_BUTTONS,
|
||||
MENU_DG_CLOAK_LINING,
|
||||
MENU_DG_CFG_SOUND,
|
||||
MENU_DG_WINDOW_COLORS,
|
||||
MENU_DG_TIME_ATTACK,
|
||||
MENU_DG_EQUIP_SORT,
|
||||
MENU_DG_FAMILIARS,
|
||||
NUM_MENU,
|
||||
} MenuDialogue;
|
||||
|
||||
typedef enum {
|
||||
DEBUG_NORMAL,
|
||||
DEBUG_TEXTURE_VIEWER,
|
||||
@ -290,7 +310,7 @@ typedef struct {
|
||||
} DamageParam;
|
||||
|
||||
typedef struct {
|
||||
/* 8013761C */ MenuContext menus[0x10]; // 761C, 763A, 7658, 7676
|
||||
/* 8013761C */ MenuContext menus[NUM_MENU]; // 761C, 763A, 7658, 7676
|
||||
} MenuData;
|
||||
|
||||
// All the Joseph's Cloak color fields are in RGB555 format
|
||||
@ -445,7 +465,7 @@ extern Equipment g_EquipDefs[];
|
||||
extern Accessory g_AccessoryDefs[];
|
||||
extern RelicDesc g_RelicDefs[];
|
||||
extern u8* c_strTimeAttackHiddenEntry;
|
||||
extern s32 c_strTimeAttackEntries[];
|
||||
extern const char* c_strTimeAttackEntries[];
|
||||
extern u32 D_800AC90C;
|
||||
extern u16 D_800AC958[];
|
||||
extern s32 D_800ACC64[]; // probably a struct
|
||||
@ -619,7 +639,7 @@ extern s32 g_IsCloakColorUnlocked;
|
||||
extern s32 g_IsSelectingEquipment;
|
||||
extern s32 g_EquipmentCursor;
|
||||
extern s32 D_80137614;
|
||||
extern s32 D_80137618;
|
||||
extern s32 g_EquipOrderType;
|
||||
extern MenuData g_MenuData;
|
||||
extern u8 D_801376B0;
|
||||
extern s16 D_801376C4;
|
||||
@ -911,27 +931,16 @@ void CalcDefense(void);
|
||||
bool IsAlucart(void);
|
||||
void func_800F53A4(void);
|
||||
bool ScissorSprite(SPRT* arg0, MenuContext* arg1);
|
||||
void DrawMenuImg(MenuContext* ctx, s32 x, s32 y, s32 w, u32 h, s32 u, s32 v,
|
||||
void MenuDrawImg(MenuContext* ctx, s32 x, s32 y, s32 w, u32 h, s32 u, s32 v,
|
||||
s32 idx, s32 unk2, bool disableTexShade, s32 unk4);
|
||||
void DrawMenuSprite(
|
||||
void MenuDrawSprite(
|
||||
MenuContext* context, s32 x, s32 y, s32 width, s32 height, s32 u, s32 v,
|
||||
s32 clut, s32 tpage, s32 arg9, s32 colorIntensity, s32 argB);
|
||||
void DrawMenuRect(MenuContext* context, s32 posX, s32 posY, s32 width,
|
||||
void MenuDrawRect(MenuContext* context, s32 posX, s32 posY, s32 width,
|
||||
s32 height, s32 r, s32 g, s32 b);
|
||||
s32 func_800F62E8(s32 arg0);
|
||||
void InitStatsAndGear(bool isDeathTakingItems);
|
||||
void DrawMenuChar(u8 ch, int x, int y, MenuContext* context);
|
||||
void DrawMenuStr(const u8* str, s32 x, s32 y, MenuContext* context);
|
||||
void DrawMenuInt(s32 value, s32 x, s32 y, MenuContext*);
|
||||
void DrawSettingsReverseCloak(MenuContext* context);
|
||||
void DrawSettingsSound(MenuContext* context);
|
||||
void DrawPauseMenu(s32 arg0);
|
||||
void func_800F82F4(void);
|
||||
void func_800F8858(MenuContext* context);
|
||||
void CheckWeaponCombo(void);
|
||||
void func_800FABEC(s32 arg0);
|
||||
void func_800FAC30(void);
|
||||
void func_800FAF44(s32);
|
||||
|
||||
s32 TimeAttackController(TimeAttackEvents eventId, TimeAttackActions action);
|
||||
s32 func_800FD664(s32 arg0);
|
||||
s32 func_800FD6C4(s32 equipTypeFilter);
|
||||
|
757
src/dra/menu.c
757
src/dra/menu.c
File diff suppressed because it is too large
Load Diff
@ -83,6 +83,9 @@ u_long MyPadRead(int id) {
|
||||
|
||||
switch (id) {
|
||||
case 0:
|
||||
if (keyb[SDL_SCANCODE_ESCAPE]) {
|
||||
g_IsQuitRequested = 1;
|
||||
}
|
||||
if (keyb[SDL_SCANCODE_UP]) {
|
||||
pressed |= PAD_UP;
|
||||
}
|
||||
@ -212,11 +215,22 @@ void MyRenderPrimitives(void) {
|
||||
|
||||
for (int i = 0; i < LEN(g_PrimBuf); i++) {
|
||||
Primitive* prim = &g_PrimBuf[i];
|
||||
if (prim->blendMode & 8) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (prim->type) {
|
||||
case PRIM_G4:
|
||||
case PRIM_GT4:
|
||||
SetSdlVertexPrim(v, prim);
|
||||
SDL_RenderGeometry(g_Renderer, NULL, v, 6, NULL, 0);
|
||||
break;
|
||||
case PRIM_LINE_G2:
|
||||
SDL_SetRenderDrawColor(
|
||||
g_Renderer, prim->r0, prim->g0, prim->b0, 255);
|
||||
SDL_RenderDrawLine(
|
||||
g_Renderer, prim->x0, prim->y0, prim->x1, prim->y1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < g_GpuUsage.g4; i++) {
|
||||
|
@ -183,7 +183,7 @@ s32 g_IsCloakColorUnlocked;
|
||||
s32 g_IsSelectingEquipment;
|
||||
s32 g_EquipmentCursor;
|
||||
s32 D_80137614;
|
||||
s32 D_80137618;
|
||||
s32 g_EquipOrderType;
|
||||
MenuData g_MenuData = {0};
|
||||
u8 D_801376B0;
|
||||
s16 D_801376C4;
|
||||
@ -317,7 +317,16 @@ const char* c_strFamiliars = "dummy";
|
||||
const char* c_strFamiliar = "dummy";
|
||||
const char* c_strSpecial2 = "dummy";
|
||||
u8* c_strTimeAttackHiddenEntry = "dummy";
|
||||
s32 c_strTimeAttackEntries[0x40] = {0};
|
||||
const char* c_strTimeAttackEntries[] = {
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
||||
};
|
||||
ImgSrc* g_imgUnk8013C200_impl = {
|
||||
0,
|
||||
0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user