From 0a1502afa32f7a06a4b2f41e2d80df96cb7a9358 Mon Sep 17 00:00:00 2001 From: Unnunu Date: Sat, 21 Jun 2025 14:32:02 +0300 Subject: [PATCH] match func_8002BAB0 (#640) * match func_8002BAB0 * update score --- README.md | 16 ++++++++-------- src/tracks.c | 40 +++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index eb03d7e1..b82b5fdd 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 June 20, 2025, this is our current score: +As of June 21, 2025, this is our current score: -    Decomp progress: 93.54% +    Decomp progress: 93.71%     Documentation progress: 59.95% @@ -117,20 +117,20 @@ s32 is_drumstick_unlocked(void) { ``` -As of June 20, 2025, this is our current score: +As of June 21, 2025, this is our current score: ``` ====================================================================== ADVENTURE ONE (ASM -> C Decompilation) - --------------- 93.54% Complete (94.42% NON_MATCHING) ---------------- - # Decompiled functions: 1928 - # GLOBAL_ASM remaining: 22 - # NON_MATCHING functions: 5 + --------------- 93.71% Complete (94.42% NON_MATCHING) ---------------- + # Decompiled functions: 1929 + # GLOBAL_ASM remaining: 21 + # NON_MATCHING functions: 4 # NON_EQUIVALENT WIP functions: 17 ---------------------------- Game Status ----------------------------- Balloons: 44/47, Keys: 4/4, Trophies: 4/5 T.T. Amulets: 4/4, Wizpig Amulets: 4/4 ---------------------------------------------------------------------- - We are collecting silver coins in Darkmoon Caverns. (6/8 silver coins) + We are collecting silver coins in Darkmoon Caverns. (7/8 silver coins) ====================================================================== ADVENTURE TWO (Cleanup & Documentation) -------------------------- 59.95% Complete --------------------------- diff --git a/src/tracks.c b/src/tracks.c index 7bc77c44..9ce821b3 100644 --- a/src/tracks.c +++ b/src/tracks.c @@ -2694,8 +2694,6 @@ s32 func_8002B9BC(Object *obj, f32 *arg1, Vec3f *arg2, s32 arg3) { } } -// https://decomp.me/scratch/Y39p2 -#ifdef NON_MATCHING // Collision: Returns the Y Values in yOut, and the number of values in the array as the return. // Get's the Y Offset acrross a surface. // Basically it goes down, finds a triangle, then locates where the intersection is and returns the Y level of that. @@ -2740,6 +2738,7 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { } vert = NULL; // fake? + currentSegment = &gCurrentLevelModel->segments[levelSegmentIndex]; currentBoundingBox = &gCurrentLevelModel->segmentsBoundingBoxes[levelSegmentIndex]; var_a1 = 1; @@ -2774,39 +2773,37 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { yOutCount = 0; for (batchNum = 0; batchNum < currentSegment->numberOfBatches; batchNum++) { - if (1) {} - currentBatch = ¤tSegment->batches[batchNum]; - currentFaceOffset = currentBatch->facesOffset; - nextFaceOffset = currentBatch[1].facesOffset; - currentVerticesOffset = currentBatch->verticesOffset; + do { + } while (0); // fakematch + currentFaceOffset = currentSegment->batches[batchNum].facesOffset; + nextFaceOffset = currentSegment->batches[batchNum + 1].facesOffset; + currentVerticesOffset = currentSegment->batches[batchNum].verticesOffset; for (faceNum = currentFaceOffset; faceNum < nextFaceOffset; faceNum++) { if (var_s1 == (currentSegment->unk10[faceNum] & var_s1)) { tri = ¤tSegment->triangles[faceNum]; + vert = ¤tSegment->vertices[tri->verticesArray[1] + currentVerticesOffset]; vert1X = vert->x; vert1Z = vert->z; + vert = ¤tSegment->vertices[tri->verticesArray[2] + currentVerticesOffset]; vert2X = vert->x; vert2Z = vert->z; + vert = ¤tSegment->vertices[tri->verticesArray[3] + currentVerticesOffset]; vert3X = vert->x; vert3Z = vert->z; - temp_ra_1 = ((((XInInt - vert2X) * (vert3Z - vert2Z)) - ((vert3X - vert2X) * (ZInInt - vert2Z))) >= 0); - temp_ra_2 = ((((XInInt - vert1X) * (vert2Z - vert1Z)) - ((vert2X - vert1X) * (ZInInt - vert1Z))) >= 0); - temp_ra_3 = ((((XInInt - vert1X) * (vert3Z - vert1Z)) - ((vert3X - vert1X) * (ZInInt - vert1Z))) >= 0); + + temp_ra_1 = (((XInInt - vert2X) * (vert3Z - vert2Z)) - ((vert3X - vert2X) * (ZInInt - vert2Z))) >= 0; + temp_ra_2 = (((XInInt - vert1X) * (vert2Z - vert1Z)) - ((vert2X - vert1X) * (ZInInt - vert1Z))) >= 0; + temp_ra_3 = (((XInInt - vert1X) * (vert3Z - vert1Z)) - ((vert3X - vert1X) * (ZInInt - vert1Z))) >= 0; var_v0 = faceNum; // fake? if (temp_ra_1 == temp_ra_2 && temp_ra_2 != temp_ra_3) { temp = currentSegment->unk14[faceNum].triangleIndex; - temp_v1_4 = (f32 *) ¤tSegment->unk18[temp * 4]; - tempVec4f.x = temp_v1_4[0]; - tempVec4f.y = temp_v1_4[1]; - tempVec4f.z = temp_v1_4[2]; - tempVec4f.w = temp_v1_4[3]; - // temp = currentSegment->unk14[faceNum].triangleIndex; - // tempVec4f.x = currentSegment->unk18_vec4f[temp].x; - // tempVec4f.y = currentSegment->unk18_vec4f[temp].y; - // tempVec4f.z = currentSegment->unk18_vec4f[temp].z; - // tempVec4f.w = currentSegment->unk18_vec4f[temp].w; + tempVec4f.x = currentSegment->unk18[4 * temp + 0]; + tempVec4f.y = currentSegment->unk18[4 * temp + 1]; + tempVec4f.z = currentSegment->unk18[4 * temp + 2]; + tempVec4f.w = currentSegment->unk18[4 * temp + 3]; if (tempVec4f.y != 0.0) { yOut[yOutCount] = -(((tempVec4f.x * xIn) + (tempVec4f.z * zIn) + tempVec4f.w) / tempVec4f.y); yOutCount++; @@ -2830,9 +2827,6 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { return yOutCount; } -#else -#pragma GLOBAL_ASM("asm/nonmatchings/tracks/func_8002BAB0.s") -#endif // Loads a level track from the index in the models table. void generate_track(s32 modelId) {