From 54a353de89ae31bf54e1a5e79c108db0925c8963 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 20 Sep 2020 23:54:48 +1000 Subject: [PATCH] Attempt to decompile menuRenderItemSelectable --- src/game/game_0e5ce0.c | 137 +++++++++++++++++++++++++++++++-- src/game/game_0f09f0.c | 34 ++++---- src/include/constants.h | 5 ++ src/include/game/game_0e5ce0.h | 2 +- src/include/game/game_0f09f0.h | 6 +- 5 files changed, 157 insertions(+), 27 deletions(-) diff --git a/src/game/game_0e5ce0.c b/src/game/game_0e5ce0.c index 22346590b..b8e7203d3 100644 --- a/src/game/game_0e5ce0.c +++ b/src/game/game_0e5ce0.c @@ -31,9 +31,6 @@ const char var7f1adfa0[] = "brcol"; const char var7f1adfa8[] = "%d: "; const char var7f1adfb0[] = "%s"; const char var7f1adfb4[] = ""; -const char var7f1adfb8[] = ""; -const char var7f1adfbc[] = ""; -const char var7f1adfc0[] = "%d\n"; s32 var80071190 = 0x00000000; s32 var80071194 = 0x00000000; @@ -5846,6 +5843,131 @@ glabel menuRenderItemSelectable /* f0eb468: 27bd0080 */ addiu $sp,$sp,0x80 ); +const char var7f1adfb8[] = ""; + +//Gfx *menuRenderItemSelectable(Gfx *gdl, struct menurenderthing *thing) +//{ +// u32 leftcolour; +// u32 rightcolour; +// char *text; +// s32 x = thing->x + 10; +// s32 y = thing->y + 2; +// u32 font1 = var8007fb10; +// u32 font2 = var8007fb0c; +// +// if (thing->item->param1 & 0x00000010) { +// x -= 6; +// } +// +// if (thing->item->param1 & 0x00400000) { +// font1 = var8007fb18; +// font2 = var8007fb14; +// } +// +// text = menuResolveParam2Text(thing->item); +// +// if (thing->unk10->unk40 < 0) { +// leftcolour = g_MenuColourPalettes[thing->unk10->colour1index].unk18; +// } else { +// leftcolour = colourBlend( +// g_MenuColourPalettes[thing->unk10->colour2index].unk18, +// g_MenuColourPalettes[thing->unk10->colour1index].unk18, +// thing->unk10->colourweight); +// } +// +// if (thing->unk10->unk0c) { +// leftcolour = colourBlend(leftcolour, 0, 127) & 0xffffff00 | leftcolour & 0xff; +// } +// +// rightcolour = leftcolour; +// +// if (thing->focused) { +// // Mismatch: The addiu and lui at eb030 and eb034 are swapped. The addiu +// // is adding the lower half of the address of g_MenuColourPalettes for +// // use in the else branch. The lui is loading a value into $at for the +// // float to u32 conversion for weight. +// u32 colour2; +// u32 weight = func0f006b08(40) * 255; +// +// if (thing->unk10->unk40 < 0) { +// colour2 = g_MenuColourPalettes[thing->unk10->colour1index].unk20; +// } else { +// colour2 = colourBlend( +// g_MenuColourPalettes[thing->unk10->colour2index].unk20, +// g_MenuColourPalettes[thing->unk10->colour1index].unk20, +// thing->unk10->colourweight); +// } +// +// leftcolour = colourBlend(colourBlend(leftcolour, leftcolour & 0x000000ff, 127), colour2, weight); +// +// func0f153e38( +// g_MenuColourPalettes3[thing->unk10->colour1index].unk20, +// g_MenuColourPalettes2[thing->unk10->colour1index].unk20); +// } else { +// func0f153e38( +// g_MenuColourPalettes3[thing->unk10->colour1index].unk18, +// g_MenuColourPalettes2[thing->unk10->colour1index].unk18); +// } +// +// if (func0f0f2588(thing->item, thing->unk10)) { +// if (thing->unk10->unk40 < 0) { +// leftcolour = g_MenuColourPalettes[thing->unk10->colour1index].unk1c; +// } else { +// leftcolour = colourBlend( +// g_MenuColourPalettes[thing->unk10->colour2index].unk1c, +// g_MenuColourPalettes[thing->unk10->colour1index].unk1c, +// thing->unk10->colourweight); +// } +// +// if (thing->unk10->unk0c) { +// leftcolour = colourBlend(leftcolour, 0x00000000, 127) & 0xffffff00 | leftcolour & 0xff; +// } +// +// rightcolour = leftcolour; +// +// func0f153e38( +// g_MenuColourPalettes3[thing->unk10->colour1index].unk1c, +// g_MenuColourPalettes2[thing->unk10->colour1index].unk1c); +// } +// +// if (thing->item->param1 & 0x00000020) { +// // Center text +// s32 textheight; +// s32 textwidth; +// textMeasure(&textheight, &textwidth, text, font1, font2, 0); +// x = thing->x + (thing->width - textwidth) / 2; +// } +// +// if (thing->item->param1 & 0x00400000) { +// x += 35; +// y += 6; +// } +// +// gdl = func0f153628(gdl); +// gdl = textRenderWhite(gdl, &x, &y, text, font1, font2, +// leftcolour, thing->width, thing->height, 0, 0); +// +// if ((thing->item->param1 & 0x00408000) == 0) { +// // Right side text +// text = menuResolveText(thing->item->param3, thing->item); +// +// // This is not how you check if a string is empty... +// if (text != NULL && text != "") { +// s32 textheight; +// s32 textwidth; +// +// y = thing->y + 2; +// textMeasure(&textheight, &textwidth, text, font1, font2, 0); +// x = thing->x + thing->width - textwidth - 10; +// +// gdl = textRenderWhite(gdl, &x, &y, text, font1, font2, +// rightcolour, thing->width, thing->height, 0, 0); +// } +// } +// +// return func0f153780(gdl); +//} + GLOBAL_ASM( glabel func0f0eb46c /* f0eb46c: 27bdffd0 */ addiu $sp,$sp,-48 @@ -5893,6 +6015,9 @@ glabel func0f0eb46c /* f0eb504: 00000000 */ nop ); +const char var7f1adfbc[] = ""; +const char var7f1adfc0[] = "%d\n"; + GLOBAL_ASM( glabel menuRenderItemSlider /* f0eb508: 27bdff50 */ addiu $sp,$sp,-176 @@ -6808,7 +6933,7 @@ Gfx *menuRenderItemCarousel(Gfx *gdl, struct menurenderthing *thing) if (thing->focused) { u32 colour1; - u32 alpha = func0f006b08(40) * 255; + u32 weight = func0f006b08(40) * 255; if (thing->unk10->unk40 < 0) { colour1 = g_MenuColourPalettes[thing->unk10->colour1index].unk20; @@ -6819,7 +6944,7 @@ Gfx *menuRenderItemCarousel(Gfx *gdl, struct menurenderthing *thing) thing->unk10->colourweight); } - colour = colourBlend(colourBlend(colour, 0x000000ff, 127), colour1, alpha); + colour = colourBlend(colourBlend(colour, 0x000000ff, 127), colour1, weight); } // Left arrow @@ -13265,7 +13390,7 @@ Gfx *menuRenderItem(Gfx *gdl, struct menurenderthing *thing) { switch (thing->item->type) { case MENUITEMTYPE_CUSTOM: return menuRenderItemCustom(gdl); - case MENUITEMTYPE_SELECTABLE: return menuRenderItemSelectable(gdl); + case MENUITEMTYPE_SELECTABLE: return menuRenderItemSelectable(gdl, thing); case MENUITEMTYPE_SLIDER: return menuRenderItemSlider(gdl); case MENUITEMTYPE_CHECKBOX: return menuRenderItemCheckbox(gdl); case MENUITEMTYPE_SCROLLABLE: return menuRenderItemScrollable(gdl, thing); diff --git a/src/game/game_0f09f0.c b/src/game/game_0f09f0.c index 0094e3f58..924a88a63 100644 --- a/src/game/game_0f09f0.c +++ b/src/game/game_0f09f0.c @@ -2091,30 +2091,30 @@ glabel func0f0f2588 /* f0f2670: 00000000 */ nop ); -bool func0f0f2674(u8 *arg0, u32 arg1, u32 arg2) +bool func0f0f2674(struct menuitem *item, struct menurenderthing10 *thing10, u32 arg2) { u32 thing1; u32 thing2; - switch (*arg0) { - case 1: - case 6: - case 7: - case 11: - case 18: - case 19: - case 21: - case 23: - case 25: + switch (item->type) { + case MENUITEMTYPE_LABEL: + case MENUITEMTYPE_OBJECTIVES: + case MENUITEMTYPE_07: + case MENUITEMTYPE_SEPARATOR: + case MENUITEMTYPE_MODEL: + case MENUITEMTYPE_13: + case MENUITEMTYPE_METER: + case MENUITEMTYPE_MARQUEE: + case MENUITEMTYPE_CONTROLLER: return false; - case 16: - case 20: - case 22: - case 24: - func0f0f2354(arg1, arg0, &thing1, &thing2); + case MENUITEMTYPE_10: + case MENUITEMTYPE_14: + case MENUITEMTYPE_16: + case MENUITEMTYPE_18: + func0f0f2354(thing10, item, &thing1, &thing2); } - if (func0f0f2588(arg0, arg1)) { + if (func0f0f2588(item, thing10)) { return false; } diff --git a/src/include/constants.h b/src/include/constants.h index dfa447a35..3e4b3bef2 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1068,10 +1068,15 @@ #define MENUITEMTYPE_KEYBOARD 0x0d #define MENUITEMTYPE_RANKING 0x0e #define MENUITEMTYPE_PLAYERSTATS 0x0f +#define MENUITEMTYPE_10 0x10 #define MENUITEMTYPE_CAROUSEL 0x11 #define MENUITEMTYPE_MODEL 0x12 +#define MENUITEMTYPE_13 0x13 +#define MENUITEMTYPE_14 0x14 #define MENUITEMTYPE_METER 0x15 +#define MENUITEMTYPE_16 0x16 #define MENUITEMTYPE_MARQUEE 0x17 +#define MENUITEMTYPE_18 0x18 #define MENUITEMTYPE_CONTROLLER 0x19 #define MENUITEMTYPE_END 0x1a diff --git a/src/include/game/game_0e5ce0.h b/src/include/game/game_0e5ce0.h index 66fd15629..8bec8b77f 100644 --- a/src/include/game/game_0e5ce0.h +++ b/src/include/game/game_0e5ce0.h @@ -23,7 +23,7 @@ Gfx *menuRenderItemObjectives(Gfx *gdl, struct menurenderthing *thing); Gfx *menuRenderItemModel(Gfx *gdl, struct menurenderthing *thing); Gfx *menuRenderItemLabel(Gfx *gdl); Gfx *menuRenderItemMeter(Gfx *gdl, struct menurenderthing *thing); -Gfx *menuRenderItemSelectable(Gfx *gdl); +Gfx *menuRenderItemSelectable(Gfx *gdl, struct menurenderthing *thing); u32 func0f0eb46c(void); Gfx *menuRenderItemSlider(Gfx *gdl); u32 func0f0ebec8(void); diff --git a/src/include/game/game_0f09f0.h b/src/include/game/game_0f09f0.h index 7e658c4b0..6aa256764 100644 --- a/src/include/game/game_0f09f0.h +++ b/src/include/game/game_0f09f0.h @@ -26,10 +26,10 @@ u32 func0f0f1618(void); void func0f0f1d6c(struct menudialog *dialog, struct menuframe *frame, struct menu *menu); u32 func0f0f1ef4(void); void func0f0f2134(struct menudialog *dialog, struct menuframe *frame, struct menu *menu); -void func0f0f2354(u32 arg0, u8 *arg1, u32 *arg2, u32 *arg3); +void func0f0f2354(struct menurenderthing10 *thing10, struct menuitem *item, u32 *arg2, u32 *arg3); bool func0f0f2534(struct menuitem *item); -bool func0f0f2588(u8 *arg0, u32 arg1); -bool func0f0f2674(u8 *arg0, u32 arg1, u32 arg2); +bool func0f0f2588(struct menuitem *item, struct menurenderthing10 *arg1); +bool func0f0f2674(struct menuitem *item, struct menurenderthing10 *thing10, u32 arg2); u32 func0f0f26fc(void); struct menuitem *func0f0f288c(struct menuframe *frame); u32 func0f0f2928(void);