From 6af653ad3decee10076179d8c2e869b604087fc5 Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Tue, 2 Apr 2024 15:00:35 -0400 Subject: Update some attempts, got a couple matches (#591) * Update some attempts, got a couple matches * More matches and updates Signed-off-by: Taggerung --- src/update_objects.c | 131 +++++++++++++++++++++------------------------------ 1 file changed, 54 insertions(+), 77 deletions(-) (limited to 'src/update_objects.c') diff --git a/src/update_objects.c b/src/update_objects.c index 37037b091..decde7c65 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -3669,10 +3669,6 @@ s16 func_8007AFB0(s32 objectIndex, s32 arg1) { return randomItem; } -#ifdef NON_MATCHING -// https://decomp.me/scratch/yWKlx -// More stupid register allocation nonsense - s32 func_8007B040(s32 objectIndex, s32 playerId) { s16 stackPadding; s32 temp_v1; @@ -3696,8 +3692,7 @@ s32 func_8007B040(s32 objectIndex, s32 playerId) { func_800C9060(playerId, 0x1900A058U); } var_t3 = 1; - gObjectList[objectIndex].unk_0A2 = var_v1; - gObjectList[objectIndex].itemDisplay = var_v1; + gObjectList[objectIndex].itemDisplay = gObjectList[objectIndex].unk_0A2 = var_v1; } else { for (var_v1_2 = 0; var_v1_2 < gPlayerCountSelection1; var_v1_2++) { temp_a0 = gItemWindowObjectByPlayerId[var_v1_2]; @@ -3711,11 +3706,11 @@ s32 func_8007B040(s32 objectIndex, s32 playerId) { } if (var_a3 != 0) { var_v1 = random_int(var_a3); - temp_v1 = sp50[var_v1]; - gObjectList[objectIndex].unk_0D1 = temp_v1; temp_a1 = sp40[var_v1]; gObjectList[objectIndex].unk_0A2 = temp_a1; gObjectList[objectIndex].itemDisplay = temp_a1; + temp_v1 = sp50[var_v1]; + gObjectList[objectIndex].unk_0D1 = temp_v1; temp_a0 = gItemWindowObjectByPlayerId[temp_v1]; sp38 = &gPlayerOne[temp_v1]; func_800722A4(temp_a0, 1); @@ -3730,9 +3725,6 @@ s32 func_8007B040(s32 objectIndex, s32 playerId) { } return var_t3; } -#else -GLOBAL_ASM("asm/non_matchings/update_objects/func_8007B040.s") -#endif void func_8007B254(s32 objectIndex, s32 arg1) { s8 test; // why? @@ -4163,34 +4155,30 @@ void wrapper_update_boos(void) { update_boos(); } -#ifdef MIPS_TO_C -//generated by m2c commit d9d3d6575355663122de59f6b2882d8f174e2355 on Dec-27-2022 +#ifdef NON_MATCHING +// https://decomp.me/scratch/9JBIl +// No idea what the source of the diff is void func_8007C360(s32 objectIndex, Camera *camera) { - Objects *sp20; - s32 sp1C; s32 temp_t0; - s32 temp_t2; s32 var_t1; Objects *temp_a2; temp_a2 = &gObjectList[objectIndex]; - temp_t0 = (((temp_a2->unk_0BE[1] - (u16) camera->rot[1]) + 0x8000) & 0xFFFF) * 0x24; + temp_t0 = (u16)camera->rot[1]; + temp_t0 = (((temp_a2->direction_angle[1] - temp_t0) + 0x8000) & 0xFFFF) * 0x24; var_t1 = temp_t0 >> 0x10; if (temp_t0 < 0) { - var_t1 = (s32) (temp_t0 + 0xFFFF) >> 0x10; - } - temp_t2 = var_t1 & 0xFFFF; - if (temp_t2 < 0x13) { - sp20 = temp_a2; - sp1C = temp_t2; - set_object_flag_status_false(objectIndex, 0x00000080); - temp_a2->itemDisplay = (s8) sp1C; - return; + var_t1 = temp_t0 + 0xFFFF; + var_t1 >>= 0x10; + } + var_t1 &= 0xFFFF; + if (var_t1 < 0x13) { + set_object_flag_status_false(objectIndex, 0x80); + temp_a2->itemDisplay = var_t1; + } else { + set_object_flag_status_true(objectIndex, 0x80); + temp_a2->itemDisplay = 0x24 - var_t1; } - sp20 = temp_a2; - sp1C = temp_t2; - set_object_flag_status_true(objectIndex, 0x00000080); - temp_a2->itemDisplay = 0x24 - temp_t2; } #else GLOBAL_ASM("asm/non_matchings/update_objects/func_8007C360.s") @@ -4210,34 +4198,28 @@ UNUSED void func_8007C49C(void) { } -#ifdef MIPS_TO_C -//generated by m2c commit 9841ff34ca242f5f14b2eab2b54a7a65ac47d80f +#ifdef NON_MATCHING +// https://decomp.me/scratch/IH8Vx +// No idea what the source of the diff is void func_8007C4A4(s32 objectIndex) { - Objects *sp20; - s32 sp1C; - s32 temp_t0; s32 temp_t8; - s32 var_t9; - Objects *temp_v1; + s32 var_t1; - temp_v1 = &gObjectList[objectIndex]; - temp_t8 = temp_v1->unk_0BE[1] * 0x24; - var_t9 = temp_t8 >> 0x10; + temp_t8 = gObjectList[objectIndex].direction_angle[1] * 0x24; + var_t1 = temp_t8 >> 0x10; if (temp_t8 < 0) { - var_t9 = (s32) (temp_t8 + 0xFFFF) >> 0x10; - } - temp_t0 = var_t9 & 0xFFFF; - if (temp_t0 < 0x13) { - sp20 = temp_v1; - sp1C = temp_t0; - set_object_flag_status_false(objectIndex, 0x00000080); - temp_v1->itemDisplay = (s8) sp1C; - return; + var_t1 = temp_t8 + 0xFFFF; + var_t1 >>= 0x10; + } + var_t1 &= 0xFFFF; + if (var_t1 < 0x13) { + set_object_flag_status_false(objectIndex, 0x80); + gObjectList[objectIndex].itemDisplay = var_t1; + } + else { + set_object_flag_status_true(objectIndex, 0x80); + gObjectList[objectIndex].itemDisplay = 0x24 - var_t1; } - sp20 = temp_v1; - sp1C = temp_t0; - set_object_flag_status_true(objectIndex, 0x00000080); - temp_v1->itemDisplay = 0x24 - temp_t0; } #else GLOBAL_ASM("asm/non_matchings/update_objects/func_8007C4A4.s") @@ -5966,9 +5948,8 @@ void func_80080DE4(s32 arg0) { } #ifdef NON_MATCHING -extern f32 D_800E594C[][2]; -extern u16 D_800E597C[6]; - +// https://decomp.me/scratch/YMJDJ +// No idea what the problem is void func_80080E8C(s32 objectIndex1, s32 objectIndex2, s32 arg2) { u16 anAngle; f32 thing0; @@ -6347,17 +6328,6 @@ void func_80081D34(s32 objectIndex) { } } -#ifdef NON_MATCHING -/** - * Nonmatching due to regalloc stuff - * The use of the `offset` variable is really really weird - * The intent of the function appears to be choose a random mole from a given - * group of moles (decided by arg1) - * `offset` then would then be offsetting the indexing into gMoleSpawns - * so that we choose the appropriate spawn location for that mole - * But as its written, `offset` is triple what it ought to be. - * So there' something kind of fucky happening - **/ void func_80081FF4(s32 objectIndex, s32 arg1) { UNUSED s32 stackPadding0; UNUSED s32 stackPadding1; @@ -6401,13 +6371,17 @@ void func_80081FF4(s32 objectIndex, s32 arg1) { break; } } - gObjectList[objectIndex].origin_pos[0] = gMoleSpawns[var_v1][offset + 0] * xOrientation; - gObjectList[objectIndex].origin_pos[1] = gMoleSpawns[var_v1][offset + 1] - 9.0; - gObjectList[objectIndex].origin_pos[2] = gMoleSpawns[var_v1][offset + 2]; + /* + Ideally `gMoleSpawns` wouldn't be a union at all and its just be a list of Vec3s + Even more ideally each mole group would have its own array for its spawns + gObjectList[objectIndex].origin_pos[0] = gMoleSpawns.asVec3sList[offset + var_v1][0] * xOrientation; + gObjectList[objectIndex].origin_pos[1] = gMoleSpawns.asVec3sList[offset + var_v1][1] - 9.0; + gObjectList[objectIndex].origin_pos[2] = gMoleSpawns.asVec3sList[offset + var_v1][2]; + */ + gObjectList[objectIndex].origin_pos[0] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 0] * xOrientation; + gObjectList[objectIndex].origin_pos[1] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 1] - 9.0; + gObjectList[objectIndex].origin_pos[2] = gMoleSpawns.asFlatList[offset + (var_v1 * 3) + 2]; } -#else -GLOBAL_ASM("asm/non_matchings/update_objects/func_80081FF4.s") -#endif void func_800821AC(s32 objectIndex, s32 arg1) { if (gObjectList[objectIndex].state != 0) { @@ -6671,16 +6645,19 @@ void update_crabs(void) { } #ifdef NON_MATCHING -// https://decomp.me/scratch/RquH0 -// Gollygee I sure love register allocation :^) +// https://decomp.me/scratch/PYAg4 +// Stack issue caused by the `test` variable, but removing it causes much, much larger differences void func_80082F1C(s32 objectIndex, s32 arg1) { + YVFlagPoleSpawn *test; gObjectList[objectIndex].model = (Gfx *) d_course_yoshi_valley_unk5; gObjectList[objectIndex].vertex = (Vtx *) d_course_yoshi_valley_unk4; gObjectList[objectIndex].sizeScaling = 0.027f; + if (test->rot && test->rot) {} + test = &D_800E5DF4[arg1]; func_80072488(objectIndex); - set_obj_origin_pos(objectIndex, D_800E5DF4[arg1].pos[0] * xOrientation, D_800E5DF4[arg1].pos[1], D_800E5DF4[arg1].pos[2]); + set_obj_origin_pos(objectIndex, test->pos[0] * xOrientation, test->pos[1], test->pos[2]); set_obj_origin_offset(objectIndex, 0.0f, 0.0f, 0.0f); - set_obj_direction_angle(objectIndex, 0U, D_800E5DF4[arg1].rot, 0U); + set_obj_direction_angle(objectIndex, 0U, test->rot, 0U); } #else GLOBAL_ASM("asm/non_matchings/update_objects/func_80082F1C.s") -- cgit v1.2.3