mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
match func_8004447C (#615)
This commit is contained in:
@@ -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 June 10, 2025, this is our current score:
|
||||
As of June 11, 2025, this is our current score:
|
||||
|
||||
    Decomp progress: 90.32%
|
||||
    Decomp progress: 90.89%
|
||||
|
||||
    Documentation progress: 59.17%
|
||||
<!-- README_SCORE_SUMMARY_END -->
|
||||
@@ -117,20 +117,20 @@ s32 is_drumstick_unlocked(void) {
|
||||
```
|
||||
|
||||
<!-- README_SCORE_BEGIN -->
|
||||
As of June 10, 2025, this is our current score:
|
||||
As of June 11, 2025, this is our current score:
|
||||
```
|
||||
====================================================================
|
||||
ADVENTURE ONE (ASM -> C Decompilation)
|
||||
-------------- 90.32% Complete (91.65% NON_MATCHING) ---------------
|
||||
# Decompiled functions: 1911
|
||||
# GLOBAL_ASM remaining: 39
|
||||
# NON_MATCHING functions: 6
|
||||
# NON_EQUIVALENT WIP functions: 29
|
||||
-------------- 90.89% Complete (91.67% NON_MATCHING) ---------------
|
||||
# Decompiled functions: 1913
|
||||
# GLOBAL_ASM remaining: 38
|
||||
# NON_MATCHING functions: 4
|
||||
# NON_EQUIVALENT WIP functions: 19
|
||||
--------------------------- Game Status ----------------------------
|
||||
Balloons: 42/47, Keys: 4/4, Trophies: 4/5
|
||||
T.T. Amulets: 4/4, Wizpig Amulets: 4/4
|
||||
--------------------------------------------------------------------
|
||||
We are racing in Star City. (Lap 2/3)
|
||||
We are racing in Star City. (Lap 3/3)
|
||||
====================================================================
|
||||
ADVENTURE TWO (Cleanup & Documentation)
|
||||
------------------------- 59.17% Complete --------------------------
|
||||
|
||||
+27
-57
@@ -676,36 +676,29 @@ s32 roll_percent_chance(s32 chance) {
|
||||
return rand_range(0, 99) < chance;
|
||||
}
|
||||
|
||||
// https://decomp.me/scratch/jtFDz
|
||||
#ifdef NON_MATCHING
|
||||
#define FAKEMATCH
|
||||
// Handles the opponent A.I. for battle & banana challenges.
|
||||
void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
Object *sp74;
|
||||
Object_64 *tempRacer;
|
||||
LevelObjectEntry *sp6C;
|
||||
s32 var_v1;
|
||||
f32 xDiff; // sp64
|
||||
f32 zDiff; // sp60
|
||||
f32 dist; // sp5C
|
||||
s32 temp; // sp58
|
||||
s32 someBool;
|
||||
s16 i; // sp52
|
||||
s16 index; // sp50
|
||||
LevelObjectEntry *newvar;
|
||||
f32 xDiff;
|
||||
f32 zDiff;
|
||||
f32 dist;
|
||||
s32 temp;
|
||||
LevelHeader *levelHeader;
|
||||
s16 i;
|
||||
s16 index;
|
||||
s16 sp4E;
|
||||
s16 sp4C;
|
||||
s16 sp4A;
|
||||
s16 sp48;
|
||||
s16 sp46;
|
||||
LevelHeader *levelHeader;
|
||||
s32 var_v1;
|
||||
s8 raceType;
|
||||
s8 *sp38;
|
||||
Object *tempRacerObj;
|
||||
|
||||
#ifdef FAKEMATCH
|
||||
if ((!tempRacerObj->unk64) && (!tempRacerObj->unk64)) {} // Fake
|
||||
#endif
|
||||
|
||||
gCurrentButtonsPressed = 0;
|
||||
gCurrentButtonsReleased = 0;
|
||||
gCurrentRacerInput = 0;
|
||||
@@ -801,9 +794,6 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
tempRacer = tempRacerObj->unk64;
|
||||
if (sp46 == 0) {
|
||||
if (sp48 < tempRacer->racer.bananas) {
|
||||
#ifdef FAKEMATCH
|
||||
if (tempRacerObj->segment.trans.y_position) {} // Fake
|
||||
#endif
|
||||
sp48 = tempRacer->racer.bananas;
|
||||
sp4A = index;
|
||||
}
|
||||
@@ -876,21 +866,17 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
sp4E = aiRacer->elevation;
|
||||
tempRacerObj =
|
||||
ainode_get(aiRacer->unk1CE); // I'm assuming this is a Ai Node (Take with a grain of salt!)
|
||||
raceType = tempRacerObj->segment.level_entry->aiNode.elevation;
|
||||
someBool = FALSE;
|
||||
if (sp6C->aiNode.elevation < raceType) {
|
||||
if ((raceType < sp4E) || (sp4E < sp6C->aiNode.elevation)) {
|
||||
someBool = TRUE;
|
||||
}
|
||||
} else {
|
||||
#ifdef FAKEMATCH
|
||||
if (!(&sp74->segment)) {} // Fake
|
||||
#endif
|
||||
if ((sp6C->aiNode.elevation < sp4E) || (sp4E < raceType)) {
|
||||
someBool = TRUE;
|
||||
newvar = tempRacerObj->segment.level_entry;
|
||||
sp46 = FALSE;
|
||||
if (sp6C->aiNode.elevation < newvar->aiNode.elevation) {
|
||||
if (1) {} // FAKE
|
||||
if (newvar->aiNode.elevation < sp4E || sp4E < sp6C->aiNode.elevation) {
|
||||
sp46 = TRUE;
|
||||
}
|
||||
} else if (sp6C->aiNode.elevation < sp4E || sp4E < newvar->aiNode.elevation) {
|
||||
sp46 = TRUE;
|
||||
}
|
||||
if (someBool) {
|
||||
if (sp46) {
|
||||
if (aiRacer->unk1CD == 4) {
|
||||
D_8011D58C[aiRacer->eggHudCounter] = 0;
|
||||
}
|
||||
@@ -911,9 +897,11 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
gCurrentRacerInput = A_BUTTON;
|
||||
}
|
||||
}
|
||||
if (aiRacer->nodeCurrent != NULL) {
|
||||
xDiff = aiRacer->nodeCurrent->segment.trans.x_position - sp74->segment.trans.x_position;
|
||||
zDiff = aiRacer->nodeCurrent->segment.trans.z_position - sp74->segment.trans.z_position;
|
||||
|
||||
tempRacerObj = aiRacer->nodeCurrent;
|
||||
if (tempRacerObj != NULL) {
|
||||
xDiff = tempRacerObj->segment.trans.x_position - sp74->segment.trans.x_position;
|
||||
zDiff = tempRacerObj->segment.trans.z_position - sp74->segment.trans.z_position;
|
||||
if (sqrtf((xDiff * xDiff) + (zDiff * zDiff)) > 0.0) {
|
||||
temp = (arctan2_f(xDiff, zDiff) - 0x8000) & 0xFFFF;
|
||||
var_v1 = temp - (aiRacer->steerVisualRotation & 0xFFFF);
|
||||
@@ -941,15 +929,11 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
case 4:
|
||||
tempRacerObj = get_racer_object(aiRacer->eggHudCounter);
|
||||
tempRacer = tempRacerObj->unk64;
|
||||
#ifdef FAKEMATCH
|
||||
if (tempRacerObj->unk64->racer.playerIndex == -1) {
|
||||
#else
|
||||
if (tempRacer->racer.playerIndex == -1) {
|
||||
#endif
|
||||
temp = func_8001CD28(
|
||||
sp6C->animation.x_rotation,
|
||||
tempRacer->racer.unk154->segment.level_entry->animation.x_rotation | 0x100,
|
||||
aiRacer->unk1CE, aiRacer->racerIndex);
|
||||
tempRacerObj = tempRacer->racer.unk154;
|
||||
newvar = tempRacerObj->segment.level_entry;
|
||||
temp = func_8001CD28(sp6C->animation.x_rotation, newvar->animation.x_rotation | 0x100,
|
||||
aiRacer->unk1CE, aiRacer->racerIndex);
|
||||
} else {
|
||||
temp = ainode_find_nearest(tempRacerObj->segment.trans.x_position,
|
||||
tempRacerObj->segment.trans.y_position,
|
||||
@@ -966,12 +950,7 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
aiRacer->racerIndex);
|
||||
break;
|
||||
default:
|
||||
#ifdef FAKEMATCH
|
||||
temp = ainode_find_next(sp6C->animation.x_rotation, aiRacer->unk1CE,
|
||||
aiRacer->racerIndex & 0xFFFFFFFFFFFFFFFFu); // Fake
|
||||
#else
|
||||
temp = ainode_find_next(sp6C->animation.x_rotation, aiRacer->unk1CE, aiRacer->racerIndex);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1009,16 +988,10 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (i != aiRacer->racerIndex) {
|
||||
tempRacerObj = get_racer_object(i);
|
||||
#ifdef FAKEMATCH
|
||||
if (tempRacerObj->unk64->racer.playerIndex != -1) {
|
||||
D_8011D5B4[i] = tempRacerObj->unk64->racer.elevation;
|
||||
}
|
||||
#else
|
||||
tempRacer = tempRacerObj->unk64;
|
||||
if (tempRacer->racer.playerIndex != -1) {
|
||||
D_8011D5B4[i] = tempRacer->racer.elevation;
|
||||
}
|
||||
#endif
|
||||
if (D_8011D5B4[aiRacer->racerIndex] == D_8011D5B4[i]) {
|
||||
xDiff = aiRacerObj->segment.trans.x_position - tempRacerObj->segment.trans.x_position;
|
||||
zDiff = aiRacerObj->segment.trans.z_position - tempRacerObj->segment.trans.z_position;
|
||||
@@ -1044,9 +1017,6 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/nonmatchings/racer/func_8004447C.s")
|
||||
#endif
|
||||
|
||||
void func_80045128(Object **racerObjs) {
|
||||
Object_Racer *racer;
|
||||
|
||||
+7
-22
@@ -207,7 +207,7 @@ void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle,
|
||||
D_8011B0F8 = TRUE;
|
||||
}
|
||||
|
||||
func_8002C0C4(geometry);
|
||||
generate_track(geometry);
|
||||
|
||||
gWaveBlockCount = 0;
|
||||
|
||||
@@ -2826,16 +2826,12 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) {
|
||||
#pragma GLOBAL_ASM("asm/nonmatchings/tracks/func_8002BAB0.s")
|
||||
#endif
|
||||
|
||||
// https://decomp.me/scratch/tdASx
|
||||
#ifdef NON_MATCHING
|
||||
// generate_track
|
||||
// Loads a level track from the index in the models table.
|
||||
// Has regalloc issues.
|
||||
void func_8002C0C4(s32 modelId) {
|
||||
void generate_track(s32 modelId) {
|
||||
s32 i, j, k;
|
||||
s32 temp_s4;
|
||||
s32 temp;
|
||||
LevelModel *mdl;
|
||||
s32 mdl;
|
||||
|
||||
set_texture_colour_tag(COLOUR_TAG_GREEN);
|
||||
gTrackModelHeap = mempool_alloc_safe(LEVEL_MODEL_MAX_SIZE, COLOUR_TAG_YELLOW);
|
||||
@@ -2851,19 +2847,18 @@ void func_8002C0C4(s32 modelId) {
|
||||
modelId = 0;
|
||||
}
|
||||
|
||||
// offset = gLevelModelTable[modelId];
|
||||
temp_s4 = gLevelModelTable[modelId + 1] - gLevelModelTable[modelId];
|
||||
mdl = gLevelModelTable[modelId];
|
||||
temp_s4 = gLevelModelTable[modelId + 1] - mdl;
|
||||
|
||||
// temp = compressedRamAddr
|
||||
temp = (s32) gCurrentLevelModel;
|
||||
temp += (LEVEL_MODEL_MAX_SIZE - temp_s4);
|
||||
temp -= ((s32) temp % 16); // Align to 16-byte boundary.
|
||||
|
||||
load_asset_to_address(ASSET_LEVEL_MODELS, temp, gLevelModelTable[modelId], temp_s4);
|
||||
load_asset_to_address(ASSET_LEVEL_MODELS, temp, mdl, temp_s4);
|
||||
gzip_inflate((u8 *) temp, (u8 *) gCurrentLevelModel);
|
||||
mempool_free(gLevelModelTable); // Done with the level models table, so free it.
|
||||
|
||||
mdl = gCurrentLevelModel;
|
||||
mdl = (s32) gCurrentLevelModel;
|
||||
|
||||
LOCAL_OFFSET_TO_RAM_ADDRESS(TextureInfo *, gCurrentLevelModel->textures);
|
||||
LOCAL_OFFSET_TO_RAM_ADDRESS(LevelModelSegment *, gCurrentLevelModel->segments);
|
||||
@@ -2872,13 +2867,6 @@ void func_8002C0C4(s32 modelId) {
|
||||
LOCAL_OFFSET_TO_RAM_ADDRESS(u8 *, gCurrentLevelModel->segmentsBitfields);
|
||||
LOCAL_OFFSET_TO_RAM_ADDRESS(BspTreeNode *, gCurrentLevelModel->segmentsBspTree);
|
||||
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
if (1) {}
|
||||
if (1) {} // Fakematch
|
||||
|
||||
for (k = 0; k < gCurrentLevelModel->numberOfSegments; k++) {
|
||||
LOCAL_OFFSET_TO_RAM_ADDRESS(Vertex *, gCurrentLevelModel->segments[k].vertices);
|
||||
LOCAL_OFFSET_TO_RAM_ADDRESS(Triangle *, gCurrentLevelModel->segments[k].triangles);
|
||||
@@ -2929,9 +2917,6 @@ void func_8002C0C4(s32 modelId) {
|
||||
}
|
||||
set_texture_colour_tag(COLOUR_TAG_MAGENTA);
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/nonmatchings/tracks/func_8002C0C4.s")
|
||||
#endif
|
||||
|
||||
void func_8002C71C(LevelModelSegment *segment) {
|
||||
s32 curVertY;
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut);
|
||||
void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, u32 entranceId, u32 collectables, u32 arg6);
|
||||
void waves_init(LevelModel *, LevelHeader *, s32);
|
||||
void void_init(s32);
|
||||
void func_8002C0C4(s32 modelId);
|
||||
void generate_track(s32 modelId);
|
||||
void func_800304C8(unk8011C8B8 *arg0);
|
||||
s32 void_generate_primitive(f32 *arg0, f32 *arg1, f32 arg2, f32 arg3);
|
||||
s32 func_8002FF6C(s32, unk8011C8B8 *, s32, Vec2f *);
|
||||
|
||||
@@ -443,7 +443,7 @@ get_wave_properties = 0x8002AD08;
|
||||
func_8002B0F4 = 0x8002B0F4;
|
||||
func_8002B9BC = 0x8002B9BC;
|
||||
func_8002BAB0 = 0x8002BAB0;
|
||||
func_8002C0C4 = 0x8002C0C4;
|
||||
generate_track = 0x8002C0C4;
|
||||
func_8002C71C = 0x8002C71C;
|
||||
get_current_level_model = 0x8002C7C4;
|
||||
free_track = 0x8002C7D4;
|
||||
|
||||
@@ -443,7 +443,7 @@ get_wave_properties = 0x8002AD08;
|
||||
func_8002B0F4 = 0x8002B0F4;
|
||||
func_8002B9BC = 0x8002B9BC;
|
||||
func_8002BAB0 = 0x8002BAB0;
|
||||
func_8002C0C4 = 0x8002C0C4;
|
||||
generate_track = 0x8002C0C4;
|
||||
func_8002C71C = 0x8002C71C;
|
||||
get_current_level_model = 0x8002C7C4;
|
||||
free_track = 0x8002C7D4;
|
||||
|
||||
@@ -439,7 +439,7 @@ get_wave_properties = 0x8002AD48;
|
||||
func_8002B0F4 = 0x8002B134;
|
||||
func_8002B9BC = 0x8002B9FC;
|
||||
func_8002BAB0 = 0x8002BAF0;
|
||||
func_8002C0C4 = 0x8002C104;
|
||||
generate_track = 0x8002C104;
|
||||
func_8002C71C = 0x8002C75C;
|
||||
get_current_level_model = 0x8002C804;
|
||||
free_track = 0x8002C814;
|
||||
|
||||
@@ -443,7 +443,7 @@ get_wave_properties = 0x8002AD08;
|
||||
func_8002B0F4 = 0x8002B0F4;
|
||||
func_8002B9BC = 0x8002B9BC;
|
||||
func_8002BAB0 = 0x8002BAB0;
|
||||
func_8002C0C4 = 0x8002C0C4;
|
||||
generate_track = 0x8002C0C4;
|
||||
func_8002C71C = 0x8002C71C;
|
||||
get_current_level_model = 0x8002C7C4;
|
||||
free_track = 0x8002C7D4;
|
||||
|
||||
@@ -439,7 +439,7 @@ get_wave_properties = 0x8002AD48;
|
||||
func_8002B0F4 = 0x8002B134;
|
||||
func_8002B9BC = 0x8002B9FC;
|
||||
func_8002BAB0 = 0x8002BAF0;
|
||||
func_8002C0C4 = 0x8002C104;
|
||||
generate_track = 0x8002C104;
|
||||
func_8002C71C = 0x8002C75C;
|
||||
get_current_level_model = 0x8002C804;
|
||||
free_track = 0x8002C814;
|
||||
|
||||
Reference in New Issue
Block a user