From a7ae8e7b5e9856d45bf063aa348ede08319bdfd6 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Wed, 4 Jun 2025 15:39:44 -0400 Subject: [PATCH] Quick fix for score script (#606) * WIP func_80060EA8 * Quick fix for score script --- src/menu.c | 4 +- src/object_models.c | 321 ++++++++++++++++++++++++++++++++++++++++++++ src/objects.c | 8 +- src/racer.c | 4 +- 4 files changed, 329 insertions(+), 8 deletions(-) diff --git a/src/menu.c b/src/menu.c index 9d835275..4bc97dbe 100644 --- a/src/menu.c +++ b/src/menu.c @@ -4328,8 +4328,8 @@ void savemenu_render_element(SaveFileData *file, s32 x, s32 y) { draw_text(&sMenuCurrDisplayList, x + (79 + SAVE_MENU_TEXT_OFFSET_2), y + 47, text2, ALIGN_TOP_CENTER); } } -#else // No match JPN savemenu_render_element +#else #pragma GLOBAL_ASM("asm/nonmatchings/menu/savemenu_render_element.s") #endif @@ -11391,8 +11391,8 @@ void results_render(UNUSED s32 updateRate, f32 opacity) { open_dialogue_box(7); } } -#else // No match JPN results_render +#else #pragma GLOBAL_ASM("asm/nonmatchings/menu/results_render.s") #endif diff --git a/src/object_models.c b/src/object_models.c index 86a95d3b..28d95040 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -671,7 +671,328 @@ s32 func_80060C58(Vertex *vertices, s32 i1, s32 i2, s32 i3, s32 i4) { #undef NEARBY } +#ifdef NON_EQUIVALENT +s32 func_80060EA8(ObjectModel *arg0) { + Triangle *spB0; + f32 *spAC; + Vec3s *spA0; + s16 sp98; + TriangleBatchInfo *sp50; + f32 *sp58; + f32 sp5C; + f32 sp60; + f32 *sp64; + f32 sp68; + f32 sp6C; + f32 *sp70; + f32 sp74; + f32 sp78; + s16 *temp_v0_2; + f32 *temp_v0_3; + s16 *temp_v0_5; + Vec3f *temp_v0_6; + TriangleBatchInfo *temp_a3; + TriangleBatchInfo *temp_a3_2; + TriangleBatchInfo *temp_ra; + TriangleBatchInfo *temp_t0; + TriangleBatchInfo *temp_t8_2; + TriangleBatchInfo *temp_v0; + TriangleBatchInfo *temp_v0_4; + TriangleBatchInfo *var_ra; + Vertex *temp_s3; + Vertex *temp_v1_2; + Vertex *temp_v1_3; + Vertex *temp_v1_4; + Vertex *temp_v1_5; + Vertex *temp_v1_6; + f32 *temp_t7; + f32 *temp_t8; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f0_3; + f32 temp_f0_4; + f32 temp_f14; + f32 temp_f14_2; + f32 temp_f2; + f32 temp_f2_2; + f32 temp_f2_3; + s16 temp_a2; + s16 temp_a2_2; + s16 temp_s4; + s16 temp_t7_2; + s16 temp_t8_3; + s16 temp_v1; + s16 var_a0; + s16 var_a0_2; + s16 var_a0_3; + s16 var_a1; + s16 var_a1_2; + s16 var_a2; + s16 var_a2_2; + s16 var_a3; + s16 var_a3_2; + s16 var_a3_3; + s16 var_a3_4; + s16 var_a3_5; + s16 var_s1_2; + s16 batchNum; + s16 var_s5; + s16 var_s5_2; + s16 var_s6; + s16 var_t3; + s16 var_v1; + s16 var_v1_2; + s16 var_v1_3; + s32 temp_a3_3; + s32 temp_lo; + s32 temp_s1; + s32 temp_s1_2; + s16 var_s1; + s32 var_s1_4; + s32 var_t7; + s32 var_t8; + s32 var_t8_2; + s32 var_t9; + s32 var_t9_2; + u8 *temp_a0; + u8 *var_t6; + u8 temp_t4; + f32 *temp_s0; + f32 *temp_s0_2; + f32 *temp_s0_3; + f32 *temp_v0_7; + f32 *temp_v1_7; + f32 *temp_v1_8; + s16 *temp_v1_9; + + temp_v1 = arg0->numberOfBatches; + temp_ra = arg0->batches; + arg0->unk40 = NULL; + + var_a3 = 0; + for (var_s1 = 0; var_s1 < temp_v1; var_s1++) { + if (temp_ra[var_s1].miscData != BATCH_VTX_COL || (temp_ra[var_s1].flags & RENDER_ENVMAP)) { + var_a3 = (var_a3 + (temp_ra[var_s1 + 1]).verticesOffset) - temp_ra[var_s1].verticesOffset; + } + } + if (var_a3 > 0) { + temp_s3 = arg0->vertices; + spB0 = arg0->triangles; + sp98 = var_a3; + temp_v0_2 = mempool_alloc(arg0->numberOfTriangles * 0xC, COLOUR_TAG_ORANGE); + spAC = temp_v0_2; + if (temp_v0_2 == NULL) { + return 1; + } + temp_v0_3 = mempool_alloc(var_a3 * 6, COLOUR_TAG_ORANGE); + var_ra = temp_ra; + spA0 = temp_v0_3; + if (temp_v0_3 == NULL) { + mempool_free(spAC); + return 1; + } + + var_v1 = arg0->numberOfBatches; + for (var_s1_2 = 0; var_s1_2 < var_v1; var_s1_2++) { + temp_v0_4 = &var_ra[var_s1_2]; + temp_s4 = temp_v0_4->verticesOffset; + for (var_s5 = temp_v0_4->facesOffset; var_s5 < (temp_v0_4 + 1)->facesOffset; var_s5 += 1) { + for (var_a3_2 = 0; var_a3_2 < 3; var_a3_2++) { + temp_v1_2 = &temp_s3[(s16) (spB0[var_s5].verticesArray[var_a3_2 + 1] + temp_s4)]; + temp_t7 = &(&sp64[0])[var_a3_2]; + temp_t8 = &(&sp58[0])[var_a3_2]; + (&sp70[0])[var_a3_2] = (f32) temp_v1_2->x; + *temp_t7 = (f32) temp_v1_2->y; + *temp_t8 = (f32) temp_v1_2->z; + } + temp_s0 = spAC + (var_s5 * 0xC); + temp_s0[0] = (f32) (((sp58[0] - sp60) * (sp64[0] - sp68)) - ((sp58[0] - sp5C) * (sp64[0] - sp6C))); + temp_s0[1] = (f32) (((sp58[0] - sp5C) * (sp70[0] - sp78)) - ((sp58[0] - sp60) * (sp70[0] - sp74))); + temp_s0[2] = (f32) (((sp70[0] - sp74) * (sp64[0] - sp6C)) - ((sp64[0] - sp68) * (sp70[0] - sp78))); + temp_f0_2 = sqrtf((temp_s0[2] * temp_s0[2]) + ((temp_s0[0] * temp_s0[0]) + (temp_s0[1] * temp_s0[1]))); + if (temp_f0_2 != 0.0f) { + temp_s0[0] = (f32) (temp_s0[0] / temp_f0_2); + temp_s0[1] = (f32) (temp_s0[1] / temp_f0_2); + temp_s0[2] = (f32) (temp_s0[2] / temp_f0_2); + } + } + } + temp_v0_5 = mempool_alloc(arg0->numberOfVertices * 2, COLOUR_TAG_ORANGE); + if (temp_v0_5 == NULL) { + mempool_free(spAC); + mempool_free(spA0); + return 1; + } + var_s6 = 0; + for (batchNum = 0; batchNum < arg0->numberOfBatches; batchNum++) { + temp_t8_2 = &var_ra[batchNum]; + sp50 = temp_t8_2; + var_t3 = temp_t8_2->verticesOffset; + if (var_t3 < (temp_t8_2 + 1)->verticesOffset) { + do { + if (sp50->miscData < 0xFE) { + var_a2 = -1; + var_a1 = 0; + temp_v1_3 = &temp_s3[var_t3]; + if (batchNum >= 0) { +loop_30: + temp_a3 = &var_ra[var_a1]; + if ((sp50->miscData == temp_a3->miscData) && (((var_a0 = temp_a3->verticesOffset, (var_a1 == batchNum)) && (var_a0 < var_t3)) || ((var_a1 != batchNum) && (var_a0 < (temp_a3 + 1)->verticesOffset))) && (var_a2 < 0)) { +loop_36: + temp_v1_4 = &temp_s3[var_a0]; + if ((temp_v1_3->x == temp_v1_4->x) && (temp_v1_3->y == temp_v1_4->y) && (temp_v1_3->z == temp_v1_4->z)) { + var_a2 = *(temp_v0_5 + (var_a0 * 2)); + } + temp_t8_3 = var_a0 + 1; + var_a0 = temp_t8_3; + if ((((var_a1 == batchNum) && (temp_t8_3 < var_t3)) || ((var_a1 != batchNum) && (var_a0 < (temp_a3 + 1)->verticesOffset))) && (var_a2 < 0)) { + goto loop_36; + } + } + var_a1 += 1; + if ((batchNum >= var_a1) && (var_a2 < 0)) { + goto loop_30; + } + } + if (var_a2 < 0) { + *(temp_v0_5 + (var_t3 * 2)) = var_s6; + var_s6 += 1; + } else { + *(temp_v0_5 + (var_t3 * 2)) = var_a2; + } + } else if (sp50->miscData == 0xFE) { + *(temp_v0_5 + (var_t3 * 2)) = var_s6; + var_s6 += 1; + } else if (sp50->flags & RENDER_ENVMAP) { + var_a2_2 = -1; + var_a1_2 = 0; + temp_v1_5 = &temp_s3[var_t3]; + if (batchNum >= 0) { +loop_54: + temp_a3_2 = &var_ra[var_a1_2]; + if ((temp_a3_2->flags & RENDER_ENVMAP) && (((var_a0_2 = temp_a3_2->verticesOffset, (var_a1_2 == batchNum)) && (var_a0_2 < var_t3)) || ((var_a1_2 != batchNum) && (var_a0_2 < (temp_a3_2 + 1)->facesOffset))) && (var_a2_2 < 0)) { +loop_60: + temp_v1_6 = &temp_s3[var_a0_2]; + if ((temp_v1_5->x == temp_v1_6->x) && (temp_v1_5->y == temp_v1_6->y) && (temp_v1_5->z == temp_v1_6->z)) { + var_a2_2 = *(temp_v0_5 + (var_a0_2 * 2)); + } + var_a0_2++; + if ((((var_a1_2 == batchNum) && (var_a0_2 < var_t3)) || ((var_a1_2 != batchNum) && (var_a0_2 < (temp_a3_2 + 1)->facesOffset))) && (var_a2_2 < 0)) { + goto loop_60; + } + } + var_a1_2 += 1; + if ((batchNum >= var_a1_2) && (var_a2_2 < 0)) { + goto loop_54; + } + } + if (var_a2_2 < 0) { + *(temp_v0_5 + (var_t3 * 2)) = var_s6; + var_s6 += 1; + } else { + *(temp_v0_5 + (var_t3 * 2)) = var_a2_2; + } + } else { + *(temp_v0_5 + (var_t3 * 2)) = -1; + } + var_t3 += 1; + } while (var_t3 < (sp50 + 1)->verticesOffset); + } + } + temp_v0_6 = mempool_alloc(var_s6 * 0xC, COLOUR_TAG_ORANGE); + if (temp_v0_6 == NULL) { + mempool_free(spAC); + mempool_free(spA0); + mempool_free(temp_v0_5); + return 1; + } + var_a3_3 = 0; + var_s1_4 = 0; + while (var_a3_3 < var_s6) { + temp_lo = var_a3_3 * 0xC; + var_a3_3 += 1; + temp_v1_7 = temp_v0_6 + temp_lo; + temp_v1_7[0] = 0.0f; + temp_v1_7[1] = 0.0f; + temp_v1_7[2] = 0.0f; + } + var_v1_3 = arg0->numberOfBatches; + while (var_s1_4 < var_v1_3) { + temp_s1_2 = var_s1_4 + 1; + temp_t0 = &var_ra[var_s1_4]; + if ((temp_t0->miscData != BATCH_VTX_COL) || (var_t8_2 = temp_s1_2 << 0x10, ((temp_t0->flags & RENDER_ENVMAP) != 0))) { + var_s5_2 = temp_t0->facesOffset; + var_t8_2 = temp_s1_2 << 0x10; + if (var_s5_2 < (temp_t0 + 1)->facesOffset) { + var_t7 = var_s5_2 * 0x10; + do { + temp_a0 = &spB0->verticesArray[var_t7]; + var_a3_4 = 0; + var_t6 = temp_a0; +loop_89: + temp_a2 = *(temp_v0_5 + ((s16) (var_t6[1] + temp_t0->verticesOffset) * 2)); + var_a3_4 += 1; + if (temp_a2 >= 0) { + temp_v1_8 = temp_v0_6 + (temp_a2 * 0xC); + temp_s0_2 = spAC + (var_s5_2 * 0xC); + temp_v1_8[0] += temp_s0_2[0]; + temp_v1_8[1] += temp_s0_2[1]; + temp_v1_8[2] += temp_s0_2[2]; + } + var_t6 = &temp_a0[var_a3_4]; + if (var_a3_4 < 3) { + goto loop_89; + } + var_s5_2 += 1; + var_t7 = var_s5_2 * 0x10; + } while (var_s5_2 < (temp_t0 + 1)->verticesOffset); + var_v1_3 = arg0->numberOfBatches; + var_t8_2 = temp_s1_2 << 0x10; + } + } + var_s1_4 = var_t8_2 >> 0x10; + } + for (var_a3_5 = 0; var_a3_5 < var_s6; var_a3_5++) { + temp_s0_3 = temp_v0_6 + (var_a3_5 * 0xC); + temp_f2_2 = temp_s0_3[0]; + temp_f14_2 = temp_s0_3[1]; + temp_f0_3 = temp_s0_3[2]; + sp98 = var_a3_5; + temp_f0_4 = sqrtf((temp_f0_3 * temp_f0_3) + ((temp_f2_2 * temp_f2_2) + (temp_f14_2 * temp_f14_2))); + if (temp_f0_4 != 0.0f) { + temp_f0_4 *= 0.00012207031f; + temp_s0_3[0] /= temp_f0_4; + temp_s0_3[1] /= temp_f0_4; + temp_s0_3[2] /= temp_f0_4; + } + } + var_a3_5 = 0; + var_a0_3 = 0; + var_t9 = 0 * 2; + while (var_a3_5 < arg0->numberOfVertices) { + temp_a2_2 = temp_v0_5[var_t9]; + temp_a3_3 = var_a3_5 + 1; + var_t9_2 = temp_a3_3 << 0x10; + if (temp_a2_2 >= 0) { + spA0[var_a0_3].x = temp_v0_6[temp_a2_2].x; + spA0[var_a0_3].y= temp_v0_6[temp_a2_2].y; + spA0[var_a0_3].z = temp_v0_6[temp_a2_2].z; + var_t9_2 = temp_a3_3 << 0x10; + var_a0_3++; + } + var_a3_5 = (s16) (var_t9_2 >> 0x10); + var_t9 = var_a3_5 * 2; + } + arg0->unk40 = (Vec3s *) spA0; + mempool_free(temp_v0_5); + mempool_free(temp_v0_6); + mempool_free(spAC); + } + return 0; +} +#else #pragma GLOBAL_ASM("asm/nonmatchings/object_models/func_80060EA8.s") +#endif void func_800619F4(s32 arg0) { D_8011D640 = arg0; diff --git a/src/objects.c b/src/objects.c index 09cc8aa6..c0a3c1e8 100644 --- a/src/objects.c +++ b/src/objects.c @@ -2430,6 +2430,7 @@ void gParticlePtrList_flush(void) { gFreeListCount = 0; } +// https://decomp.me/scratch/DW6EX #ifdef NON_EQUIVALENT void func_800101AC(Object *obj, s32 arg1) { Object *tempObj; @@ -2645,7 +2646,6 @@ void func_800101AC(Object *obj, s32 arg1) { mempool_free(obj); } #else -// https://decomp.me/scratch/DW6EX #pragma GLOBAL_ASM("asm/nonmatchings/objects/func_800101AC.s") #endif @@ -5021,6 +5021,7 @@ s32 func_8001955C(Object *obj, s32 checkpoint, u8 arg2, s32 arg3, s32 arg4, f32 return TRUE; } +// https://decomp.me/scratch/QupaR #ifdef NON_EQUIVALENT extern s32 D_B0000574; @@ -5412,7 +5413,6 @@ void func_80019808(s32 updateRate) { } } #else -// https://decomp.me/scratch/QupaR #pragma GLOBAL_ASM("asm/nonmatchings/objects/func_80019808.s") #endif @@ -6365,6 +6365,7 @@ s32 ainode_find_nearest(f32 diffX, f32 diffY, f32 diffZ, s32 useElevation) { return result; } +// https://decomp.me/scratch/cfVAM #ifdef NON_EQUIVALENT f32 func_8001C6C4(Object_NPC *npc, Object *npcParentObj, f32 updateRateF, f32 speedF, s32 direction) { Object *aiNode; @@ -6496,7 +6497,6 @@ f32 func_8001C6C4(Object_NPC *npc, Object *npcParentObj, f32 updateRateF, f32 sp } } #else -// https://decomp.me/scratch/cfVAM #pragma GLOBAL_ASM("asm/nonmatchings/objects/func_8001C6C4.s") #endif @@ -7245,6 +7245,7 @@ void func_8001E89C(void) { } } +// https://decomp.me/scratch/OKbBN #ifdef NON_EQUIVALENT void func_8001E93C(void) { s32 pad[3]; @@ -7366,7 +7367,6 @@ void func_8001E93C(void) { D_8011AE7E = FALSE; } #else -// https://decomp.me/scratch/OKbBN #pragma GLOBAL_ASM("asm/nonmatchings/objects/func_8001E93C.s") #endif diff --git a/src/racer.c b/src/racer.c index cd94b2d7..ed09fefa 100644 --- a/src/racer.c +++ b/src/racer.c @@ -2531,6 +2531,7 @@ f32 rotate_racer_in_water(Object *obj, Object_Racer *racer, Vec3f *pos, s8 arg3, return velocity; } +// https://decomp.me/scratch/SlvtN #ifdef NON_EQUIVALENT // Plane physics, largest function in DKR. void func_80049794(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer) { @@ -3388,7 +3389,6 @@ void func_80049794(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } } #else -// https://decomp.me/scratch/SlvtN #pragma GLOBAL_ASM("asm/nonmatchings/racer/func_80049794.s") #endif @@ -3691,6 +3691,7 @@ void update_camera_plane(f32 updateRate, Object *obj, Object_Racer *racer) { #pragma GLOBAL_ASM("asm/nonmatchings/racer/update_camera_plane.s") #endif +// https://decomp.me/scratch/yfGqf - 97.27% #ifdef NON_EQUIVALENT // Handles loop de loops void func_8004CC20(s32 updateRate, f32 updateRateF, Object *racerObj, Object_Racer *racer) { @@ -3942,7 +3943,6 @@ void func_8004CC20(s32 updateRate, f32 updateRateF, Object *racerObj, Object_Rac } } #else -// https://decomp.me/scratch/yfGqf - 97.27% #pragma GLOBAL_ASM("asm/nonmatchings/racer/func_8004CC20.s") #endif