Skip to content

Commit

Permalink
optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Niko committed Oct 15, 2024
1 parent a4723a5 commit 422129f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 38 deletions.
15 changes: 8 additions & 7 deletions decompile/General/230/230_50_MM_Characters_MenuProc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ void DECOMP_MM_Characters_MenuProc(struct RectMenu* unused)
struct CharacterSelectMeta* csm_Active;

struct GameTracker* gGT = sdata->gGT;

int* ot = gGT->backBuffer->otMem.startPlusFour;

for (i = 0; i < 4; i++)
{
Expand Down Expand Up @@ -470,8 +472,7 @@ void DECOMP_MM_Characters_MenuProc(struct RectMenu* unused)

color = *(Color *) puVar12;
DECOMP_RECTMENU_DrawOuterRect_HighLevel(
r, color, 0,
gGT->backBuffer->otMem.startPlusFour);
r, color, 0, ot);
}

DECOMP_MM_Characters_PreventOverlap();
Expand Down Expand Up @@ -588,7 +589,7 @@ void DECOMP_MM_Characters_MenuProc(struct RectMenu* unused)

Color color = *(Color *) &colorRGBA;
// this draws the flashing blue square that appears when you highlight a character in the character select screen
DECOMP_CTR_Box_DrawSolidBox(r, color, gGT->backBuffer->otMem.startPlusFour);
DECOMP_CTR_Box_DrawSolidBox(r, color, ot);
}
if
(
Expand Down Expand Up @@ -661,7 +662,7 @@ void DECOMP_MM_Characters_MenuProc(struct RectMenu* unused)

// Draw 2D Menu rectangle background
DECOMP_RECTMENU_DrawInnerRect(
r, 0, gGT->backBuffer->otMem.startPlusFour);
r, 0, ot);
}
}

Expand All @@ -688,7 +689,7 @@ void DECOMP_MM_Characters_MenuProc(struct RectMenu* unused)

color = *(Color *) &colorRGBA;
DECOMP_RECTMENU_DrawOuterRect_HighLevel(
r, color, 0, gGT->backBuffer->otMem.startPlusFour);
r, color, 0, ot);

// if player selected a character
if (((int)(short)sdata->characterSelectFlags >> j & 1U) != 0)
Expand All @@ -712,14 +713,14 @@ void DECOMP_MM_Characters_MenuProc(struct RectMenu* unused)
color = *(Color *) &colorRGBA;
DECOMP_RECTMENU_DrawOuterRect_HighLevel(
&r58, color, 0,
gGT->backBuffer->otMem.startPlusFour);
ot);
}
}
psVar22 = psVar22 + 2;

// Draw 2D Menu rectangle background
DECOMP_RECTMENU_DrawInnerRect(
r, 9, &gGT->backBuffer->otMem.startPlusFour[3]);
r, 9, &ot[3]);

// not screen-space anymore,
// this is viewport-space
Expand Down
14 changes: 8 additions & 6 deletions decompile/General/230/230_63_MM_Battle_MenuProc.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ void DECOMP_MM_Battle_MenuProc(struct RectMenu* unused)
}
}

int* ot = gGT->backBuffer->otMem.startPlusFour;

for (i = 0; i < 4; i++)
{
uVar4 = local_60b[i];
Expand Down Expand Up @@ -745,7 +747,7 @@ void DECOMP_MM_Battle_MenuProc(struct RectMenu* unused)
color.self = *data.ptrColor[PLAYER_BLUE+i];
DECOMP_CTR_Box_DrawSolidBox(
&local_48, color,
gGT->backBuffer->otMem.startPlusFour);
ot);
}

if (sdata->battleSetupRowHighlighted == 2)
Expand All @@ -755,7 +757,7 @@ void DECOMP_MM_Battle_MenuProc(struct RectMenu* unused)
local_50.x = tmbattle[4].currX + 0x9c + WIDE_PICK(0,25);
local_50.y = tmbattle[4].currY + sVar20 + 3;

DECOMP_CTR_Box_DrawClearBox(&local_50, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, gGT->backBuffer->otMem.startPlusFour);
DECOMP_CTR_Box_DrawClearBox(&local_50, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, ot);
}

local_40.w = WIDE_34(0x140);
Expand All @@ -765,7 +767,7 @@ void DECOMP_MM_Battle_MenuProc(struct RectMenu* unused)

// Draw 2D Menu rectangle background
DECOMP_RECTMENU_DrawInnerRect(
&local_40, 0, gGT->backBuffer->otMem.startPlusFour);
&local_40, 0, ot);

// "WEAPONS:"
DECOMP_DecalFont_DrawLine(
Expand Down Expand Up @@ -907,18 +909,18 @@ void DECOMP_MM_Battle_MenuProc(struct RectMenu* unused)
local_60.h = 0x20;
local_60.y = local_40.y + (sdata->battleSetupRowHighlighted - 3) * 0x20 + 2;

DECOMP_CTR_Box_DrawClearBox(&local_60, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, gGT->backBuffer->otMem.startPlusFour);
DECOMP_CTR_Box_DrawClearBox(&local_60, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, ot);
}

local_58.x = local_40.x + 3;
local_58.y = local_40.y + 2;
local_58.w = local_40.w - 6;
local_58.h = local_40.h - 4;

DECOMP_CTR_Box_DrawClearBox(&local_58, &D230.color3, TRANS_50_DECAL, gGT->backBuffer->otMem.startPlusFour);
DECOMP_CTR_Box_DrawClearBox(&local_58, &D230.color3, TRANS_50_DECAL, ot);

DECOMP_RECTMENU_DrawInnerRect(
&local_40, 0, gGT->backBuffer->otMem.startPlusFour);
&local_40, 0, ot);

// save all five battle settings
// these are selected rows from all battle options
Expand Down
6 changes: 4 additions & 2 deletions decompile/General/230/230_67_MM_HighScore_MenuProc.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ void DECOMP_MM_HighScore_MenuProc(struct RectMenu* menu_unused)
iVar7 = (FPS_DOUBLE(8) - D230.highScore_transitionFrames[1]) * D230.highScore_horizontalMove[0] * 0x40;
}

int* ot = sdata->gGT->backBuffer->otMem.startPlusFour;

if (((iVar7 != -0x200) && (iVar7 != 0x200)) && ((iVar4 != -0xd8 && (iVar4 != 0xd8))))
{
DECOMP_MM_HighScore_Draw(D230.highScore_trackCurr,(int)D230.highScore_rowCurr,(int)(short)iVar7,(int)(short)iVar4);
Expand All @@ -190,7 +192,7 @@ void DECOMP_MM_HighScore_MenuProc(struct RectMenu* menu_unused)
local_20.h = 0x19;
local_20.x = D230.transitionMeta_HighScores[0].currX + -0x14;
local_20.y = D230.transitionMeta_HighScores[0].currY + (short)iVar4 + 9;
DECOMP_RECTMENU_DrawInnerRect(&local_20,0,(u_long *)(sdata->gGT->backBuffer->otMem).startPlusFour);
DECOMP_RECTMENU_DrawInnerRect(&local_20,0,ot);
}
}
iVar5 = 0;
Expand All @@ -213,7 +215,7 @@ void DECOMP_MM_HighScore_MenuProc(struct RectMenu* menu_unused)
local_20.h = 0x19;
local_20.x = D230.transitionMeta_HighScores[0].currX + -0x14;
local_20.y = D230.transitionMeta_HighScores[0].currY + (short)iVar6 + 9;
DECOMP_RECTMENU_DrawInnerRect(&local_20,0,(u_long *)(sdata->gGT->backBuffer->otMem).startPlusFour);
DECOMP_RECTMENU_DrawInnerRect(&local_20,0,ot);

return;
}
5 changes: 3 additions & 2 deletions decompile/General/232/232_25_AH_Pause_Draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ void DECOMP_AH_Pause_Draw(int pageID, int posX)

Color color;
color.self = sdata->battleSetup_Color_UI_1;
DECOMP_RECTMENU_DrawOuterRect_Edge(&r, color, 0x20, gGT->backBuffer->otMem.startPlusFour);
int* ot = gGT->backBuffer->otMem.startPlusFour;
DECOMP_RECTMENU_DrawOuterRect_Edge(&r, color, 0x20, ot);

r.x = 0x100 - half;
r.y = 10;
Expand All @@ -448,7 +449,7 @@ void DECOMP_AH_Pause_Draw(int pageID, int posX)

// Draw 2D Menu rectangle background
DECOMP_RECTMENU_DrawInnerRect(
&r, 4, &gGT->backBuffer->otMem.startPlusFour[3]);
&r, 4, &ot[3]);

for(int i = 0; i < 0xe; i++)
{
Expand Down
14 changes: 8 additions & 6 deletions decompile/General/232/232_29_AH_HintMenu_MenuProc.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,24 @@ void DECOMP_AH_HintMenu_MenuProc(struct RectMenu* menu)
box.y = (short)iVar11 + 0x4e;
box.h = 0x11;

DECOMP_CTR_Box_DrawClearBox(&box, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, gGT->backBuffer->otMem.startPlusFour);
int* ot = gGT->backBuffer->otMem.startPlusFour;
DECOMP_CTR_Box_DrawClearBox(&box, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, ot);

box.y = 0x3c;
box.x = -0xe;
box.w = 0x21c;
box.h = 2;

color.self = sdata->battleSetup_Color_UI_1;
DECOMP_RECTMENU_DrawOuterRect_Edge(&box, color, 0x20, gGT->backBuffer->otMem.startPlusFour);
DECOMP_RECTMENU_DrawOuterRect_Edge(&box, color, 0x20, ot);

box.y = 0x28;
box.h = (short)iVar11 + 0x3b;
box.x = -0xe;
box.w = 0x21c;

DECOMP_RECTMENU_DrawInnerRect(
&box, 4, &gGT->backBuffer->otMem.startPlusFour[3]);
&box, 4, &ot[3]);

return;
}
Expand Down Expand Up @@ -321,23 +322,24 @@ void DECOMP_AH_HintMenu_MenuProc(struct RectMenu* menu)
box.y = (menu->rowSelected - D232.hintMenu_scrollIndex) * 0x10 + 0x4f;
box.h = 0x11;

DECOMP_CTR_Box_DrawClearBox(&box, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, gGT->backBuffer->otMem.startPlusFour);
int* ot = gGT->backBuffer->otMem.startPlusFour;
DECOMP_CTR_Box_DrawClearBox(&box, &sdata->menuRowHighlight_Normal, TRANS_50_DECAL, ot);

box.y = 0x3c;
box.h = 2;
box.x = -0x14;
box.w = 0x228;

color.self = sdata->battleSetup_Color_UI_1;
DECOMP_RECTMENU_DrawOuterRect_Edge(&box, color, 0x20, gGT->backBuffer->otMem.startPlusFour);
DECOMP_RECTMENU_DrawOuterRect_Edge(&box, color, 0x20, ot);

box.y = 0x28;
box.h = (short)iVar10 + 0x2b;
box.x = -0x14;
box.w = 0x228;

DECOMP_RECTMENU_DrawInnerRect(
&box, 4, gGT->backBuffer->otMem.startPlusFour);
&box, 4, ot);

if (
(bVar3) ||
Expand Down
9 changes: 3 additions & 6 deletions decompile/General/AltMods/MM_CustomCups.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,13 @@ void CustomCups_MenuProc(struct RectMenu* menu)
FONT_SMALL,
(JUSTIFY_CENTER | PERIWINKLE));

struct DB *backBuffer =
sdata->gGT->backBuffer;
int* ot = sdata->gGT->backBuffer->otMem.startPlusFour;

DECOMP_RECTMENU_DrawInnerRect(
&windowSel[CUP_SELECT], 1,
backBuffer->otMem.startPlusFour);
&windowSel[CUP_SELECT], 1, ot);

DECOMP_RECTMENU_DrawInnerRect(
&windowText, 1,
backBuffer->otMem.startPlusFour);
&windowText, 1, ot);
}
}

Expand Down
18 changes: 9 additions & 9 deletions decompile/General/UI/UI_RaceStart_IntroText1P.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,17 @@ void DECOMP_UI_RaceStart_IntroText1P(void) {

// Draw tiny rectangle near big black title bar (first)
rect.y = gGT->pushBuffer[0].rect.y - (windowHeight + -0x1c);
Color color;

Color color;
color.self = colors[0];
DECOMP_CTR_Box_DrawSolidBox(&rect, color,
gGT->backBuffer->otMem.startPlusFour);

int* ot = gGT->backBuffer->otMem.startPlusFour;

DECOMP_CTR_Box_DrawSolidBox(&rect, color, ot);

// Draw tiny rectangle near big black title bar (second)
rect.y = gGT->pushBuffer[0].rect.y + gGT->pushBuffer[0].rect.h + windowHeight + -0x1e;
DECOMP_CTR_Box_DrawSolidBox(&rect, color,
gGT->backBuffer->otMem.startPlusFour);
DECOMP_CTR_Box_DrawSolidBox(&rect, color, ot);

// 30-pixel height
// clear RGB, keep alpha (which is zero anyway)
Expand All @@ -230,13 +232,11 @@ void DECOMP_UI_RaceStart_IntroText1P(void) {

// draw big black title bar (first)
rect.y = gGT->pushBuffer[0].rect.y - windowHeight;
DECOMP_CTR_Box_DrawSolidBox(&rect, color,
gGT->backBuffer->otMem.startPlusFour);
DECOMP_CTR_Box_DrawSolidBox(&rect, color, ot);

// draw big black title bar (second)
rect.y = gGT->pushBuffer[0].rect.y + gGT->pushBuffer[0].rect.h + windowHeight + -0x1e;
DECOMP_CTR_Box_DrawSolidBox(&rect, color,
gGT->backBuffer->otMem.startPlusFour);
DECOMP_CTR_Box_DrawSolidBox(&rect, color, ot);
}
return;
}

0 comments on commit 422129f

Please sign in to comment.