diff --git a/README.md b/README.md index 1bf60109..71f08187 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ This repo contains a work-in-progress decompilation of Diddy Kong Racing for the All versions are supported, and the US 1.0 version (SHA1 = 0cb115d8716dbbc2922fda38e533b9fe63bb9670) of the game is the default if not specified. -As of May 30, 2025, this is our current score: +As of June 1, 2025, this is our current score: -    Decomp progress: 89.02% +    Decomp progress: 89.17%     Documentation progress: 58.62% @@ -117,15 +117,15 @@ s32 is_drumstick_unlocked(void) { ``` -As of May 30, 2025, this is our current score: +As of June 1, 2025, this is our current score: ``` =================================================================== ADVENTURE ONE (ASM -> C Decompilation) - -------------- 89.02% Complete (90.35% NON_MATCHING) -------------- - # Decompiled functions: 1906 - # GLOBAL_ASM remaining: 45 + -------------- 89.17% Complete (90.50% NON_MATCHING) -------------- + # Decompiled functions: 1907 + # GLOBAL_ASM remaining: 44 # NON_MATCHING functions: 6 - # NON_EQUIVALENT WIP functions: 16 + # NON_EQUIVALENT WIP functions: 15 --------------------------- Game Status --------------------------- Balloons: 41/47, Keys: 4/4, Trophies: 4/5 T.T. Amulets: 4/4, Wizpig Amulets: 4/4 diff --git a/src/menu.c b/src/menu.c index ec45ec3b..635d116b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2130,17 +2130,16 @@ void menu_button_free(void) { gWoodPanelAllocCount = 0; } -#ifdef NON_EQUIVALENT -void func_8007FFEC(s32 arg0) { - s32 sp28; - s32 sp24; - s32 sp20; - Triangle *alloc; +// Allocate and initalize a certain number of wooden panels used for the UI. +void func_8007FFEC(s32 numberOfPanels) { s32 triListIndex; + s32 triItemIndex; s32 IndicesIndex; - s32 triIndex; + s32 panelIndex; s32 i; - s32 j; + s32 triangleCount; + s32 vertexSize; + s32 menuGeometrySize; if (gMenuGeometry != NULL) { menu_button_free(); @@ -2148,56 +2147,57 @@ void func_8007FFEC(s32 arg0) { 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 = (unk80080BC8 *) gWoodPanelTriangles[1] + sp20; - gWoodPanelVertices[1] = (Vertex *) gMenuGeometry; - gWoodPanelVertices[1] = gWoodPanelVertices[0] + arg0; + menuGeometrySize = sizeof(unk80080BC8) * numberOfPanels; + vertexSize = sizeof(Vertex) * (20 * numberOfPanels); + triangleCount = sizeof(Triangle) * (10 * numberOfPanels); - // This loop isn't quite right. - for (i = 0; i < arg0; i++) { - gMenuGeometry[i].vertices[0] = (Vertex *) gWoodPanelVertices[0] + i; - gMenuGeometry[i].vertices[1] = (Vertex *) gWoodPanelVertices[1] + i; - gMenuGeometry[i].triangles[0] = (Triangle *) gWoodPanelTriangles[0] + i; - gMenuGeometry[i].triangles[1] = (Triangle *) gWoodPanelTriangles[1] + i; + gWoodPanelTriangles[0] = (Triangle *)mempool_alloc_safe(((vertexSize + triangleCount) * 2) + menuGeometrySize, COLOUR_TAG_WHITE); + gWoodPanelTriangles[1] = (Triangle *)((u32)gWoodPanelTriangles[0] + triangleCount); + + gMenuGeometry = (unk80080BC8 *)((u32)gWoodPanelTriangles[1] + triangleCount); + + gWoodPanelVertices[0] = (Vertex *)((u32)gMenuGeometry + menuGeometrySize); + gWoodPanelVertices[1] = (Vertex *)((u32)gWoodPanelVertices[0] + vertexSize); + + panelIndex = 0; + triangleCount = 0; + for(i = 0; i < numberOfPanels; i++) { + gMenuGeometry[i].vertices[0] = &gWoodPanelVertices[0][panelIndex]; + gMenuGeometry[i].vertices[1] = &gWoodPanelVertices[1][panelIndex]; + gMenuGeometry[i].triangles[0] = &gWoodPanelTriangles[0][triangleCount]; + gMenuGeometry[i].triangles[1] = &gWoodPanelTriangles[1][triangleCount]; gMenuGeometry[i].texture[0] = 0; gMenuGeometry[i].texture[1] = 0; gMenuGeometry[i].unk18[0] = 0; gMenuGeometry[i].unk18[1] = 0; + panelIndex += 20; + triangleCount += 10; } - 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; + triItemIndex = 0; + for(i = 0; i < numberOfPanels; i++) { + panelIndex = 0; + for(IndicesIndex = 0; IndicesIndex < 10; triItemIndex++, panelIndex += 3, IndicesIndex++) { + for(triListIndex = 0; triListIndex < 2; triListIndex++) { + gWoodPanelTriangles[triListIndex][triItemIndex].verticesArray[0] = BACKFACE_DRAW; + gWoodPanelTriangles[triListIndex][triItemIndex].verticesArray[1] = gWoodPanelsIndices[panelIndex]; + gWoodPanelTriangles[triListIndex][triItemIndex].verticesArray[2] = gWoodPanelsIndices[panelIndex + 1]; + gWoodPanelTriangles[triListIndex][triItemIndex].verticesArray[3] = gWoodPanelsIndices[panelIndex + 2]; + gWoodPanelTriangles[triListIndex][triItemIndex].uv0.u = 0; + gWoodPanelTriangles[triListIndex][triItemIndex].uv0.v = 0; + gWoodPanelTriangles[triListIndex][triItemIndex].uv1.u = 0; + gWoodPanelTriangles[triListIndex][triItemIndex].uv1.v = 0; + gWoodPanelTriangles[triListIndex][triItemIndex].uv2.u = 0; + gWoodPanelTriangles[triListIndex][triItemIndex].uv2.v = 0; } } } gMenuTrisFlip = 0; gWoodPanelCount = 0; - gWoodPanelAllocCount = arg0; + gWoodPanelAllocCount = numberOfPanels; } -#else -#pragma GLOBAL_ASM("asm/nonmatchings/menu/func_8007FFEC.s") -#endif + /** * Resize the UV's of the menu panels.