match: func_80018CE0 (#663)

This commit is contained in:
Dominik Peters
2025-07-04 00:36:52 +02:00
committed by GitHub
parent 5255e7fa52
commit da064ae8cc
5 changed files with 248 additions and 249 deletions
+8 -8
View File
@@ -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.
<!-- README_SCORE_SUMMARY_BEGIN -->
As of July 3, 2025, this is our current score:
As of July 4, 2025, this is our current score:
&emsp;&emsp;&emsp;&emsp;Decomp progress: 96.43%
&emsp;&emsp;&emsp;&emsp;Decomp progress: 96.67%
&emsp;&emsp;&emsp;&emsp;Documentation progress: 62.43%
<!-- README_SCORE_SUMMARY_END -->
@@ -117,20 +117,20 @@ s32 is_drumstick_unlocked(void) {
```
<!-- README_SCORE_BEGIN -->
As of July 3, 2025, this is our current score:
As of July 4, 2025, this is our current score:
```
======================================================================
ADVENTURE ONE (ASM -> C Decompilation)
--------------- 96.43% Complete (97.33% NON_MATCHING) ----------------
# Decompiled functions: 1939
# GLOBAL_ASM remaining: 13
--------------- 96.67% Complete (97.57% NON_MATCHING) ----------------
# Decompiled functions: 1940
# GLOBAL_ASM remaining: 12
# NON_MATCHING functions: 5
# NON_EQUIVALENT WIP functions: 8
# NON_EQUIVALENT WIP functions: 7
---------------------------- Game Status -----------------------------
Balloons: 46/47, Keys: 4/4, Trophies: 4/5
T.T. Amulets: 4/4, Wizpig Amulets: 4/4
----------------------------------------------------------------------
We are collecting silver coins in Star City. (5/8 silver coins)
We are collecting silver coins in Star City. (7/8 silver coins)
======================================================================
ADVENTURE TWO (Cleanup & Documentation)
-------------------------- 62.43% Complete ---------------------------
+25 -26
View File
@@ -5851,27 +5851,26 @@ Object *find_taj_object(void) {
return NULL;
}
// https://decomp.me/scratch/nWMak
#ifdef NON_EQUIVALENT
// Handles MidiFadePoint, MidiFade, and MidiSetChannel objects?
void func_80018CE0(Object *racerObj, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
f32 temp_f0;
f32 temp_f12;
s32 pad_spF8;
s32 spF4;
f32 temp_f14;
s32 pad_spF0;
f32 temp_f22;
f32 racerX; // f24
f32 racerY; // f26
f32 racerZ; // f28
s32 pad_spE8;
s32 pad_spE4;
s32 pad_spE0;
f32 temp_f2;
f32 var_f4;
f32 var_f8;
s32 pad_spD8;
f32 tempF2;
s32 temp_f10;
s32 temp_t3_2;
s32 i; // s1
s32 var_s2;
f32 spC0;
Object_MidiFadePoint *midiFadePoint; // spBC
f32 tempF;
u16 temp_t4;
s8 var_v0_2;
u8 var_v0_u;
@@ -5907,8 +5906,8 @@ void func_80018CE0(Object *racerObj, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
var_s2 = 0;
} else {
spC0 -= midiFadePoint->unk0;
var_f4 = 127.0f * (spC0);
var_s2 = var_f4 / (midiFadePoint->unk2 - midiFadePoint->unk0);
temp_f0 = (midiFadePoint->unk2 - midiFadePoint->unk0);
var_s2 = (127.0f * spC0) / temp_f0;
}
for (i = 0; i < 16; i++) {
switch (midiFadePoint->unkC[i]) {
@@ -5933,6 +5932,7 @@ void func_80018CE0(Object *racerObj, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
}
} else if (obj->behaviorId == BHV_MIDI_FADE) {
midiFade = obj->midi_fade;
temp_f0 =
(midiFade->unk8 * arg1) + (midiFade->unkC * arg2) + (midiFade->unk10 * arg3) + midiFade->unk14;
temp_f2 = (midiFade->unk8 * racerObj->trans.x_position) +
@@ -5946,18 +5946,20 @@ void func_80018CE0(Object *racerObj, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
var_v1 = 0;
}
if (var_v1 != 0) {
temp_f2 = -midiFade->unk8 * arg1 - midiFade->unkC * arg2 - midiFade->unk10 * arg3 - midiFade->unk14;
temp_f0 = midiFade->unk8 * (racerObj->trans.x_position - arg1) +
midiFade->unkC * (racerObj->trans.y_position - arg2) +
midiFade->unk10 * (racerObj->trans.z_position - arg3);
temp_f0 = racerObj->trans.x_position - arg1;
temp_f2 = racerObj->trans.y_position - arg2;
temp_f22 = temp_f2 / temp_f0;
if ((midiFade->unk18 <= (temp_f22 * (racerObj->trans.x_position - arg1)) + arg1) &&
((temp_f22 * (racerObj->trans.x_position - arg1)) + arg1 <= midiFade->unk24)) {
if ((midiFade->unk1C <= (temp_f22 * (racerObj->trans.y_position - arg2)) + arg2) &&
((temp_f22 * (racerObj->trans.y_position - arg2)) + arg2 <= midiFade->unk28)) {
if ((midiFade->unk20 <= (temp_f22 * (racerObj->trans.z_position - arg3)) + arg3) &&
((temp_f22 * (racerObj->trans.z_position - arg3)) + arg3 <= midiFade->unk2C)) {
temp_f22 =
(-midiFade->unk8 * arg1 - midiFade->unkC * arg2 - midiFade->unk10 * arg3 - midiFade->unk14) /
(midiFade->unk8 * temp_f0 + midiFade->unkC * temp_f2 +
midiFade->unk10 * (racerObj->trans.z_position - arg3));
tempF = temp_f22 * temp_f0;
if ((midiFade->unk18 <= tempF + arg1) && (tempF + arg1 <= midiFade->unk24)) {
tempF2 = racerObj->trans.z_position - arg3;
if ((midiFade->unk1C <= (temp_f22 * temp_f2) + arg2) &&
((temp_f22 * temp_f2) + arg2 <= midiFade->unk28)) {
if ((midiFade->unk20 <= (temp_f22 * (tempF2)) + arg3) &&
((temp_f22 * (tempF2)) + arg3 <= midiFade->unk2C)) {
midiFade->unk0 = var_v1;
midiFade->unk1 = 0;
midiFade->unk4 = 0;
@@ -6000,7 +6002,7 @@ void func_80018CE0(Object *racerObj, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
D_8011AF60->unk1 = 0xFE;
}
for (i = 0; i < 16; i++) {
var_v0_2 = D_8011AF60->unk2F[i + 1];
var_v0_2 = D_8011AF60->unk2F[i];
if (D_8011AF60->unk0 == -1) {
var_v0_2 >>= 2;
}
@@ -6041,9 +6043,6 @@ void func_80018CE0(Object *racerObj, f32 arg1, f32 arg2, f32 arg3, s32 arg4) {
D_8011AF60 = 0;
}
}
#else
#pragma GLOBAL_ASM("asm/nonmatchings/objects/func_80018CE0.s")
#endif
// Rocket Path
s32 func_8001955C(Object *obj, s32 checkpoint, u8 arg2, s32 arg3, s32 arg4, f32 checkpointDist, f32 *outX, f32 *outY,
+193 -197
View File
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -2734,8 +2734,7 @@ void func_80049794(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r
if ((var_v0 == PLAYER_COMPUTER) && (gCurrentPlayerIndex != PLAYER_COMPUTER)) {
gCurrentRacerHandlingStat = 1.4f;
}
var_f20 = sqrtf((obj->x_velocity * obj->x_velocity) +
(obj->z_velocity * obj->z_velocity) +
var_f20 = sqrtf((obj->x_velocity * obj->x_velocity) + (obj->z_velocity * obj->z_velocity) +
(obj->y_velocity * obj->y_velocity)) -
2.0;
if (racer->vehicleID >= VEHICLE_BOSSES) {
@@ -3304,8 +3303,8 @@ void func_80049794(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r
gCurrentRacerTransform.z_position = 0.0f;
gCurrentRacerTransform.scale = 1.0f;
mtxf_from_inverse_transform((MtxF *) &sp60, &gCurrentRacerTransform);
mtxf_transform_point((MtxF *) &sp60, obj->x_velocity, obj->y_velocity, obj->z_velocity,
&racer->lateral_velocity, &racer->unk34, &racer->velocity);
mtxf_transform_point((MtxF *) &sp60, obj->x_velocity, obj->y_velocity, obj->z_velocity, &racer->lateral_velocity,
&racer->unk34, &racer->velocity);
if (obj->attachPoints != NULL && obj->attachPoints->count >= 3) {
temp_v0_obj = obj->attachPoints->obj[2];
temp_v0_obj->trans.rotation.y_rotation = 0x4000;
+19 -14
View File
@@ -2557,7 +2557,7 @@ s32 func_8002B0F4(s32 levelSegmentIndex, f32 xIn, f32 zIn, WaterProperties ***ar
var_s1 = 0;
XInInt = xIn;
ZInInt = zIn;
temp_a2 = ((currentBoundingBox->x2 - currentBoundingBox->x1) >> 3) + 1;
var_t0 = temp_a2 + currentBoundingBox->x1;
var_t1 = currentBoundingBox->x1;
@@ -2569,7 +2569,7 @@ s32 func_8002B0F4(s32 levelSegmentIndex, f32 xIn, f32 zIn, WaterProperties ***ar
var_t1 += temp_a2;
var_a1 *= 2;
}
// Same as above, but for Z
temp_a2 = ((currentBoundingBox->z2 - currentBoundingBox->z1) >> 3) + 1;
// @fake for s3 vs s2
@@ -2584,7 +2584,7 @@ s32 func_8002B0F4(s32 levelSegmentIndex, f32 xIn, f32 zIn, WaterProperties ***ar
var_t1 += temp_a2;
var_a1 *= 2;
}
for (batchNum = 0; batchNum < currentSegment->numberOfBatches; batchNum++) {
currentBatch = &currentSegment->batches[batchNum];
surface = gCurrentLevelModel->textures[currentBatch->textureIndex].surfaceType;
@@ -2596,26 +2596,29 @@ s32 func_8002B0F4(s32 levelSegmentIndex, f32 xIn, f32 zIn, WaterProperties ***ar
(currentBatch->flags & (RENDER_HIDDEN | RENDER_NO_COLLISION))) {
currentFaceOffset = nextFaceOffset;
}
for (faceNum = currentFaceOffset; faceNum < nextFaceOffset; faceNum++) {
if (var_s1 == (currentSegment->unk10[faceNum] & var_s1)) {
tri = &currentSegment->triangles[faceNum];
vert = &currentSegment->vertices[tri->verticesArray[1] + currentVerticesOffset];
vert1X = vert->x;
vert1Z = vert->z;
vert = &currentSegment->vertices[tri->verticesArray[2] + currentVerticesOffset];
vert2X = vert->x;
vert2Z = vert->z;
vert = &currentSegment->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;
if (temp_ra_1 == temp_ra_2 && temp_ra_2 != temp_ra_3) {
temp = currentSegment->collisionFacets[faceNum].basePlaneIndex;
tempVec4f.x = currentSegment->collisionPlanes[temp * 4 + 0];
@@ -2624,7 +2627,8 @@ s32 func_8002B0F4(s32 levelSegmentIndex, f32 xIn, f32 zIn, WaterProperties ***ar
tempVec4f.w = currentSegment->collisionPlanes[temp * 4 + 3];
if (tempVec4f.y != 0.0) {
D_8011D128[yOutCount].type = surface;
D_8011D128[yOutCount].waveHeight = -(((tempVec4f.x * xIn) + (tempVec4f.z * zIn) + tempVec4f.w) / tempVec4f.y);
D_8011D128[yOutCount].waveHeight =
-(((tempVec4f.x * xIn) + (tempVec4f.z * zIn) + tempVec4f.w) / tempVec4f.y);
D_8011D128[yOutCount].rot.x = tempVec4f.x;
D_8011D128[yOutCount].rot.y = tempVec4f.y;
D_8011D128[yOutCount].rot.z = tempVec4f.z;
@@ -2647,7 +2651,8 @@ s32 func_8002B0F4(s32 levelSegmentIndex, f32 xIn, f32 zIn, WaterProperties ***ar
currentSegment = &gCurrentLevelModel->segments[levelSegmentIndex];
D_8011D128[yOutCount].type = SURFACE_WATER_WAVY;
if (currentSegment->hasWaves && gWaveBlockCount != 0) {
D_8011D128[yOutCount].waveHeight = func_800BB2F4(levelSegmentIndex, xIn, zIn, &(yOutCount + D_8011D128)->rot);
D_8011D128[yOutCount].waveHeight =
func_800BB2F4(levelSegmentIndex, xIn, zIn, &(yOutCount + D_8011D128)->rot);
} else {
D_8011D128[yOutCount].waveHeight = currentSegment->unk38;
D_8011D128[yOutCount].rot.x = 0.0f;
@@ -2661,7 +2666,7 @@ s32 func_8002B0F4(s32 levelSegmentIndex, f32 xIn, f32 zIn, WaterProperties ***ar
for (var_v0 = 0; var_v0 < yOutCount; var_v0++) {\
wave = &D_8011D128[var_v0];\
gTrackWaves[var_v0] = wave;\
}\
}
// clang-format on
do {