Match func_80094D28 and fix several warnings in menu.c (#478)

* Fix most warnings in menu.c

* Better match for gWoodPanelVertCoords

* Realized s8 meant -1 instead of 255

* Match func_80094D28
This commit is contained in:
Ryan Myers
2025-03-11 19:32:15 -04:00
committed by GitHub
parent 88d0931f7a
commit be8410c33e
3 changed files with 130 additions and 701 deletions
+7 -7
View File
@@ -7,7 +7,7 @@ Currently, only the US 1.0 version (SHA1 = 0cb115d8716dbbc2922fda38e533b9fe63bb9
<!-- README_SCORE_SUMMARY_BEGIN -->
As of March 11, 2025, this is our current score:
&emsp;&emsp;&emsp;&emsp;Decomp progress: 74.53%
&emsp;&emsp;&emsp;&emsp;Decomp progress: 74.80%
&emsp;&emsp;&emsp;&emsp;Documentation progress: 49.99%
<!-- README_SCORE_SUMMARY_END -->
@@ -130,16 +130,16 @@ As of March 11, 2025, this is our current score:
```
=====================================================================
ADVENTURE ONE (ASM -> C Decompilation)
--------------- 74.53% Complete (77.02% NON_MATCHING) ---------------
# Decompiled functions: 1824
# GLOBAL_ASM remaining: 117
# NON_MATCHING functions: 14
# NON_EQUIVALENT WIP functions: 40
--------------- 74.80% Complete (77.02% NON_MATCHING) ---------------
# Decompiled functions: 1825
# GLOBAL_ASM remaining: 116
# NON_MATCHING functions: 13
# NON_EQUIVALENT WIP functions: 41
---------------------------- Game Status ----------------------------
Balloons: 35/47, Keys: 4/4, Trophies: 3/5
T.T. Amulets: 4/4, Wizpig Amulets: 3/4
---------------------------------------------------------------------
We are collecting silver coins in Windmill Plains. (1/8 silver coins)
We are collecting silver coins in Windmill Plains. (3/8 silver coins)
=====================================================================
ADVENTURE TWO (Cleanup & Documentation)
-------------------------- 49.99% Complete --------------------------
File diff suppressed because it is too large Load Diff
+123 -58
View File
@@ -1499,7 +1499,7 @@ Gfx dMenuHudDrawModes[][2] = {
};
// Triangle indices for the wood panels used in multiple menus.
s8 gWoodPanelsIndices[32] = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8,
u8 gWoodPanelsIndices[32] = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8,
10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 0, 0 };
// UV coordinate indices the wood panels.
@@ -1509,11 +1509,13 @@ u8 gWoodPanelTexCoords[5][12] = { { 0, 0, 3, 0, 2, 1, 0, 0, 2, 1, 1, 1 },
{ 0, 0, 1, 1, 1, 2, 0, 0, 1, 2, 0, 3 },
{ 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2 } };
// Position offsets for the wood panels.
u16 gWoodPanelVertCoords[10][4] = { { 0, 0, 256, 0 }, { 511, 255, 1, 255 }, { 511, 255, 256, 0 },
{ 256, -256, 511, -255 }, { 1, -255, 511, -255 }, { 256, -256, 0, -256 },
{ 0, 0, 1, 255 }, { 1, -255, 0, -256 }, { 1, 255, 511, 255 },
{ 511, -255, 1, -255 } };
// Position offsets for the wood panels. It has a X Width, X BorderWidth, Y Width, Y BorderWidth pattern.
s8 gWoodPanelVertCoords[][4] = {
{ 0, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, -1, 0, -1 }, { 0, 1, 0, -1 }, { 1, -1, 0, -1 },
{ 1, 0, 0, 0 }, { 1, 0, -1, 0 }, { 1, -1, -1, 1 }, { 0, 1, -1, 1 }, { 1, -1, -1, 1 },
{ 1, 0, -1, 0 }, { 0, 0, -1, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, -1 }, { 0, 1, -1, 1 },
{ 0, 0, -1, 0 }, { 0, 1, 0, -1 }, { 1, -1, 0, -1 }, { 1, -1, -1, 1 }, { 0, 1, -1, 1 }
};
// Colour filter, used for the shadows on the side of the panels.
s16 gWoodPanelVertColours[5][4] = {
@@ -1526,7 +1528,7 @@ s16 gWoodPanelVertColours[5][4] = {
s32 *gWoodPanelVertices[2] = { NULL, NULL };
s32 *gWoodPanelTriangles[2] = { NULL, NULL };
Triangle *gWoodPanelTriangles[2] = { NULL, NULL };
s32 gMenuTrisFlip = 0;
s32 gWoodPanelCount = 0;
@@ -1562,7 +1564,7 @@ void load_menu_text(s32 language) {
char **fake;
if (gMenuTextLangTable == NULL) {
gMenuTextLangTable = load_asset_section_from_rom(ASSET_MENU_TEXT_TABLE);
gMenuTextLangTable = (s32 *) load_asset_section_from_rom(ASSET_MENU_TEXT_TABLE);
}
switch (language) {
@@ -1589,13 +1591,13 @@ void load_menu_text(s32 language) {
return;
}
load_asset_to_address(ASSET_MENU_TEXT, temp, langIndex, size);
load_asset_to_address(ASSET_MENU_TEXT, (u32) temp, langIndex, size);
// TODO: Find a way to clean up the ugly hacks.
// Fill up the lookup table with proper RAM addresses
for (langIndex = 0; langIndex < gMenuTextLangTable[0]; langIndex++) {
menuText = gMenuText[langIndex];
if ((((s32) menuText) & 0xFFFFFFFF) == -1) {
menuText = (char **) gMenuText[langIndex];
if ((((s32) menuText) & 0xFFFFFFFF) == 0xFFFFFFFF) {
gMenuText[langIndex] = NULL;
} else {
gMenuText[langIndex] = &((char *) gMenuText)[(s32) (fake = menuText)];
@@ -1739,7 +1741,74 @@ void menu_button_free(void) {
gWoodPanelAllocCount = 0;
}
#ifdef NON_EQUIVALENT
void func_8007FFEC(s32 arg0) {
s32 sp28;
s32 sp24;
s32 sp20;
Triangle *alloc;
s32 triListIndex;
s32 IndicesIndex;
s32 triIndex;
s32 i;
s32 j;
if (gMenuGeometry != NULL) {
menu_button_free();
}
gWoodPanelTexScaleU = 32; // 32 = 1.0x scale
gWoodPanelTexScaleV = 32; // 32 = 1.0x scale
sp20 = arg0 * 0xA * 0x10;
// sp28 = arg0 << 5;
// sp24 = arg0 * 0x64 * 2;
// This is mostly wrong. Need to fix!
alloc = mempool_alloc_safe(arg0 * 0x2F0, COLOUR_TAG_WHITE);
gWoodPanelTriangles[0] = alloc;
gWoodPanelTriangles[1] = gWoodPanelTriangles[0] + sp20;
gMenuGeometry = gWoodPanelTriangles[1] + sp20;
gWoodPanelVertices[1] = gMenuGeometry;
gWoodPanelVertices[1] = gWoodPanelVertices[0] + arg0;
// This loop isn't quite right.
for (i = 0; i < arg0; i++) {
gMenuGeometry[i].vertices[0] = gWoodPanelVertices[0] + i;
gMenuGeometry[i].vertices[1] = gWoodPanelVertices[1] + i;
gMenuGeometry[i].triangles[0] = gWoodPanelTriangles[0] + i;
gMenuGeometry[i].triangles[1] = gWoodPanelTriangles[1] + i;
gMenuGeometry[i].texture[0] = 0;
gMenuGeometry[i].texture[1] = 0;
gMenuGeometry[i].unk18[0] = 0;
gMenuGeometry[i].unk18[1] = 0;
}
for (triIndex = 0; triIndex < arg0; triIndex++) {
for (IndicesIndex = 0; IndicesIndex < 10; IndicesIndex++) { // Index into gWoodPanelsIndices
for (triListIndex = 0; triListIndex < 2; triListIndex++) { // Index into gWoodPanelTriangles?
(gWoodPanelTriangles[triListIndex] + triIndex)->verticesArray[0] = 0x40;
(gWoodPanelTriangles[triListIndex] + triIndex)->verticesArray[1] =
gWoodPanelsIndices[IndicesIndex * 3 + 0];
(gWoodPanelTriangles[triListIndex] + triIndex)->verticesArray[2] =
gWoodPanelsIndices[IndicesIndex * 3 + 1];
(gWoodPanelTriangles[triListIndex] + triIndex)->verticesArray[3] =
gWoodPanelsIndices[IndicesIndex * 3 + 2];
(gWoodPanelTriangles[triListIndex] + triIndex)->uv0.u = 0;
(gWoodPanelTriangles[triListIndex] + triIndex)->uv0.v = 0;
(gWoodPanelTriangles[triListIndex] + triIndex)->uv1.u = 0;
(gWoodPanelTriangles[triListIndex] + triIndex)->uv1.v = 0;
(gWoodPanelTriangles[triListIndex] + triIndex)->uv2.u = 0;
(gWoodPanelTriangles[triListIndex] + triIndex)->uv2.v = 0;
}
}
}
gMenuTrisFlip = 0;
gWoodPanelCount = 0;
gWoodPanelAllocCount = arg0;
}
#else
GLOBAL_ASM("asm/non_matchings/menu/func_8007FFEC.s")
#endif
/**
* Resize the UV's of the menu panels.
@@ -1759,10 +1828,10 @@ void func_80080580(Gfx **dlist, s32 startX, s32 startY, s32 width, s32 height, s
s32 j;
s32 r, g, b, a;
s32 r0, g0, b0, a0;
s8 *texCoords;
s16 *texColors;
u8 *woodPanelTexCoords;
s32 temp;
s8(*texCoords)[4];
s16(*texColors)[4];
u8(*woodPanelTexCoords)[12];
UNUSED s32 pad;
gMenuGeometry[gWoodPanelCount].texture[gMenuTrisFlip] = tex;
if (tex != NULL) {
@@ -1781,19 +1850,19 @@ void func_80080580(Gfx **dlist, s32 startX, s32 startY, s32 width, s32 height, s
if (1) {}
if (1) {}
if (1) {} // fake
triangles[0].uv0.u = uVals[woodPanelTexCoords[0]];
triangles[0].uv0.v = vVals[woodPanelTexCoords[1]];
triangles[0].uv1.u = uVals[woodPanelTexCoords[2]];
triangles[0].uv1.v = vVals[woodPanelTexCoords[3]];
triangles[0].uv2.u = uVals[woodPanelTexCoords[4]];
triangles[0].uv2.v = vVals[woodPanelTexCoords[5]];
triangles[1].uv0.u = uVals[woodPanelTexCoords[6]];
triangles[1].uv0.v = vVals[woodPanelTexCoords[7]];
triangles[1].uv1.u = uVals[woodPanelTexCoords[8]];
triangles[1].uv1.v = vVals[woodPanelTexCoords[9]];
triangles[1].uv2.u = uVals[woodPanelTexCoords[10]];
triangles[1].uv2.v = vVals[woodPanelTexCoords[11]];
woodPanelTexCoords += 12;
triangles[0].uv0.u = uVals[(*woodPanelTexCoords)[0]];
triangles[0].uv0.v = vVals[(*woodPanelTexCoords)[1]];
triangles[0].uv1.u = uVals[(*woodPanelTexCoords)[2]];
triangles[0].uv1.v = vVals[(*woodPanelTexCoords)[3]];
triangles[0].uv2.u = uVals[(*woodPanelTexCoords)[4]];
triangles[0].uv2.v = vVals[(*woodPanelTexCoords)[5]];
triangles[1].uv0.u = uVals[(*woodPanelTexCoords)[6]];
triangles[1].uv0.v = vVals[(*woodPanelTexCoords)[7]];
triangles[1].uv1.u = uVals[(*woodPanelTexCoords)[8]];
triangles[1].uv1.v = vVals[(*woodPanelTexCoords)[9]];
triangles[1].uv2.u = uVals[(*woodPanelTexCoords)[10]];
triangles[1].uv2.v = vVals[(*woodPanelTexCoords)[11]];
woodPanelTexCoords += 1;
triangles += 2;
}
}
@@ -1803,24 +1872,24 @@ void func_80080580(Gfx **dlist, s32 startX, s32 startY, s32 width, s32 height, s
a0 = (colour & 0xFF);
vertices = gMenuGeometry[gWoodPanelCount].vertices[gMenuTrisFlip];
for (texColors = gWoodPanelVertColours, texCoords = gWoodPanelVertCoords, i = 0; i < 5; i++) {
r = (texColors[0] * r0) >> 8;
g = (texColors[1] * g0) >> 8;
b = (texColors[2] * b0) >> 8;
a = (texColors[3] * a0) >> 8;
texColors += 4;
r = ((*texColors)[0] * r0) >> 8;
g = ((*texColors)[1] * g0) >> 8;
b = ((*texColors)[2] * b0) >> 8;
a = ((*texColors)[3] * a0) >> 8;
texColors += 1;
for (j = 0; j < 4; j++) {
vertices->x = startX;
vertices->x += texCoords[0] * width;
vertices->x += (texCoords[1] * borderWidth);
vertices->x += (*texCoords)[0] * width;
vertices->x += (*texCoords)[1] * borderWidth;
vertices->y = startY;
vertices->y += texCoords[2] * height;
vertices->y += texCoords[3] * borderHeight;
vertices->y += (*texCoords)[2] * height;
vertices->y += (*texCoords)[3] * borderHeight;
vertices->z = 0;
vertices->r = r;
vertices->g = g;
vertices->b = b;
vertices->a = a;
texCoords += 4;
texCoords += 1;
vertices++;
}
}
@@ -1846,7 +1915,7 @@ void func_80080580(Gfx **dlist, s32 startX, s32 startY, s32 width, s32 height, s
}
void func_80080BC8(Gfx **dList) {
s16 temp_a1;
UNUSED s16 pad;
s32 i;
s32 var_t0;
TextureHeader *tex;
@@ -3282,7 +3351,7 @@ void menu_audio_options_init(void) {
}
// Probably soundoption_render
void func_80084854(s32 updateRate) {
void func_80084854(UNUSED s32 updateRate) {
s32 i;
s32 yOffset;
s32 j;
@@ -9666,7 +9735,6 @@ void postrace_music_fade(s32 updateRate) {
}
}
#ifdef NON_MATCHING
// postrace_render
void func_80094D28(UNUSED s32 updateRate) {
s32 temp;
@@ -9675,9 +9743,9 @@ void func_80094D28(UNUSED s32 updateRate) {
s32 sp50;
s32 var_s2;
s32 var_s0;
s32 sp40;
s32 i;
s32 sp3C;
s32 sp40;
s32 filterColour;
s32 var_v0;
settings = get_settings();
@@ -9707,7 +9775,7 @@ void func_80094D28(UNUSED s32 updateRate) {
break;
case 2:
for (i = 0; i < 3; i++) {
if (settings->display_times && settings->racers[0].best_times & (1 << i)) {
if (settings->display_times && settings->racers[PLAYER_ONE].best_times & (1 << i)) {
gRaceResultsMenuElements[i + 3].filterGreen = 192 - ((var_s3 * 3) >> 2);
gRaceResultsMenuElements[i + 3].filterBlue = 255 - var_s3;
} else {
@@ -9726,21 +9794,21 @@ void func_80094D28(UNUSED s32 updateRate) {
}
break;
case 3:
for (sp40 = 0; sp40 < 8; sp40++) {
i = sp40;
sp3C = 255;
for (i = 0; i < ARRAY_COUNT(settings->racers); i++) {
filterColour = 255;
sp40 = i;
if (is_in_two_player_adventure()) {
i = sp40 - 1;
if (i == settings->racers[1].starting_position) {
sp3C = (var_s3 >> 1) + 128;
sp40--;
if (sp40 == settings->racers[1].starting_position) {
filterColour = (var_s3 >> 1) + 128;
}
}
if (i == settings->racers[0].starting_position) {
sp3C = (var_s3 >> 1) + 128;
if (sp40 == settings->racers[0].starting_position) {
filterColour = (var_s3 >> 1) + 128;
}
gRaceOrderMenuElements[7 - sp40].filterRed = sp3C;
gRaceOrderMenuElements[7 - sp40].filterGreen = sp3C;
gRaceOrderMenuElements[7 - sp40].filterBlue = sp3C;
gRaceOrderMenuElements[7 - i].filterRed = filterColour;
gRaceOrderMenuElements[7 - i].filterGreen = filterColour;
gRaceOrderMenuElements[7 - i].filterBlue = filterColour;
}
break;
case 5:
@@ -9848,9 +9916,6 @@ void func_80094D28(UNUSED s32 updateRate) {
}
}
}
#else
GLOBAL_ASM("asm/non_matchings/menu/func_80094D28.s")
#endif
/**
* Set the postrace message depending on if a controller pak was detected.