diff --git a/README.md b/README.md index 6bbe9bed..bf488b58 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ 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 24, 2025, this is our current score: +As of June 25, 2025, this is our current score:     Decomp progress: 94.29% -    Documentation progress: 59.95% +    Documentation progress: 61.33% --- @@ -117,7 +117,7 @@ s32 is_drumstick_unlocked(void) { ``` -As of June 24, 2025, this is our current score: +As of June 25, 2025, this is our current score: ``` ===================================================================== ADVENTURE ONE (ASM -> C Decompilation) @@ -133,14 +133,14 @@ As of June 24, 2025, this is our current score: We are collecting silver coins in Spaceport Alpha. (2/8 silver coins) ===================================================================== ADVENTURE TWO (Cleanup & Documentation) - -------------------------- 59.95% Complete -------------------------- - # Documented functions: 1210 - # Undocumented remaining: 440 + -------------------------- 61.33% Complete -------------------------- + # Documented functions: 1218 + # Undocumented remaining: 432 ---------------------------- Game Status ---------------------------- - Balloons: 29/47, Keys: 3/4, Trophies: 2/5 + Balloons: 30/47, Keys: 3/4, Trophies: 2/5 T.T. Amulets: 3/4, Wizpig Amulets: 2/4 --------------------------------------------------------------------- - We are collecting silver coins in Treasure Caves. (5/8 silver coins) + We are racing in the rematch against Bubbler. (Lap 2/3) ===================================================================== ``` diff --git a/include/structs.h b/include/structs.h index d9c4d648..c189e0c1 100644 --- a/include/structs.h +++ b/include/structs.h @@ -665,7 +665,7 @@ typedef struct ObjectModel { /* 0x34 */ u8 pad34[4]; /* 0x38 */ TriangleBatchInfo* batches; /* 0x3C */ f32 unk3C; - /* 0x40 */ Vec3s* unk40; + /* 0x40 */ Vec3s* normals; /* 0x44 */ ObjectModel_44* animations; /* 0x48 */ s16 numberOfAnimations; /* 0x4A */ s16 unk4A; @@ -841,7 +841,7 @@ typedef struct ObjectHeader { /* 0x53 */ s8 modelType; /* 0x54 */ s8 behaviorId; /* 0x55 */ s8 numberOfModelIds; // size of array pointed by Object->unk68 - /* 0x56 */ s8 unk56; + /* 0x56 */ s8 attachPointCount; /* 0x57 */ s8 particleCount; // Number of different particle types that are attached /* 0x58 */ s8 unk58; /* 0x59 */ u8 pad59; @@ -940,11 +940,11 @@ typedef struct Object_5C { /* 0x0108 */ s32 unk108; } Object_5C; -typedef struct Object_60 { - s32 unk0; - struct Object *unk4[10]; - s8 *unk2C; -} Object_60; +typedef struct AttachPoint { + s32 count; // Number of active attach points. + struct Object *obj[10]; // Object Ptr List for attachments. + s8 *unk2C; // Attachment indices. +} AttachPoint; typedef struct Object_LaserGun { /* 0x00 */ s32 unk0; @@ -1378,9 +1378,9 @@ typedef struct Object_Racer { /* 0x1A4 */ s16 x_rotation_vel; /* 0x1A6 */ s16 z_rotation_vel; /* 0x1A8 */ s16 unk1A8; - /* 0x1AA */ s16 unk1AA; + /* 0x1AA */ s16 racerOrder; // Current racer index order, but doesn't necessarily mean their exact race place. /* 0x1AC */ s16 finishPosition; - /* 0x1AE */ s16 racePosition; + /* 0x1AE */ s16 racePosition; // Current decided race position. /* 0x1B0 */ s16 unk1B0; /* 0x1B2 */ s16 unk1B2; /* 0x1B4 */ s32 unk1B4; @@ -1840,7 +1840,7 @@ typedef struct Object { /* 0x0054 */ ShadeProperties *shading; //player + 0x2C0 /* 0x0058 */ WaterEffect *waterEffect; //player + 0x304 /* 0x005C */ Object_5C *unk5C; - /* 0x0060 */ Object_60 *unk60; //player + 0x340 + /* 0x0060 */ AttachPoint *attachPoints; // Object attachments. This includes vehicle parts. /* 0x0064 */ Object_64 *unk64; //player + 0x98 /* 0x0068 */ union { ModelInstance **modelInstances; diff --git a/src/audiomgr.c b/src/audiomgr.c index 8983901a..a59d392c 100644 --- a/src/audiomgr.c +++ b/src/audiomgr.c @@ -78,8 +78,8 @@ s32 gAudioCmdLen; // Set but not used /**** Anti Piracy - Sets random audio frequency ****/ s16 gAntiPiracyCRCStart; s8 gAntiPiracyAudioFreq = FALSE; -s32 gFunc80019808Checksum = Func80019808Checksum; -s32 gFunc80019808Length = 0xFD0; +s32 gRaceCheckFinishChecksum = Func80019808Checksum; +s32 gRaceCheckFinishFuncLength = 0xFD0; /** Queues and storage for use with audio DMA's ****/ OSIoMesg audDMAIOMesgBuf[NUM_DMA_MESSAGES]; @@ -162,16 +162,16 @@ void amCreateAudioMgr(ALSynConfig *c, OSPri pri, OSSched *audSched) { #ifdef ANTI_TAMPER // Antipiracy measure gAntiPiracyCRCStart = DMA_BUFFER_LENGTH; - checksum = (s32) &func_80019808 - gAntiPiracyCRCStart; + checksum = (s32) &race_check_finish - gAntiPiracyCRCStart; crc_region_start = (u8 *) checksum; crc_region = &crc_region_start[gAntiPiracyCRCStart]; gAntiPiracyAudioFreq = FALSE; i = 0; - for (checksum = 0; i < gFunc80019808Length; i++) { + for (checksum = 0; i < gRaceCheckFinishFuncLength; i++) { checksum += crc_region[i]; gAntiPiracyCRCStart++; } - if (checksum != gFunc80019808Checksum) { + if (checksum != gRaceCheckFinishChecksum) { gAntiPiracyAudioFreq = TRUE; } #endif diff --git a/src/menu.c b/src/menu.c index 26c65e82..fe23c209 100644 --- a/src/menu.c +++ b/src/menu.c @@ -135,11 +135,10 @@ UNUSED s32 D_80127FE4_EE794; SavefileInfo gSavefileInfo[4]; s32 gCpakGhostData; s32 gGhostMenuTotal; -u8 gGhostLevelIDsPak[4]; -UNUSED s32 D_80128024_EE7D4; -u8 gGhostCharacterIDsPak[4]; +u8 gGhostLevelIDsPak[6]; +u8 gGhostCharacterIDsPak[6]; void *gMenuAssets[128]; // lookup table? Contains Textures, Objects, and Sprites. Need to change name and type. -u8 gGhostVehicleIDsPak[4]; +u8 gGhostVehicleIDsPak[6]; u8 gMenuAssetActive[128]; u16 gGhostChecksumIDsPak[6]; u8 gGhostLevelIDsMenu[6]; @@ -344,14 +343,10 @@ SavefileInfo gSavefileInfo[4]; s32 gCpakGhostData; s32 gGhostMenuTotal; s8 gDialogueSubmenu; -u8 gGhostLevelIDsPak[4]; -UNUSED s8 D_801264E0; -UNUSED s8 D_801264E1; +u8 gGhostLevelIDsPak[6]; s8 sCurrentMenuID; -u8 gGhostCharacterIDsPak[4]; -UNUSED s32 D_801264E8; -u8 gGhostVehicleIDsPak[4]; -UNUSED s32 D_801264F0[2]; +u8 gGhostCharacterIDsPak[6]; +u8 gGhostVehicleIDsPak[6]; u16 gGhostChecksumIDsPak[6]; s8 sDialogueOptionMax; u8 gGhostLevelIDsMenu[6]; @@ -1433,8 +1428,11 @@ s16 gTrophyRaceImageIndices[3] = { 0, 1, -1 }; MenuElement gTrophyRankingsTitle[] = { { 320 + 160 + 1, 35, SCREEN_WIDTH_HALF + 1, 35, -159, 35, 0, 0, 0, 255, 128, ASSET_FONTS_BIGFONT, 12, 0, { 0 }, { { 0, 0, 0, 0 } } }, { 320 + 160, 32, SCREEN_WIDTH_HALF, 32, -160, 32, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { 0 }, { { 0, 0, 0, 0 } } }, +// Not the most glamourous approach, but the least worst one without a proper rematching solution. +#ifndef AVOID_UB }; MenuElement gTrophyRankingsRacers[] = { +#endif { 64, -192, 64, 48, 64, 288, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, { { 0, 0, 0, 0 } } }, { 32, -192, 32, 48, 32, 288, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gFirstPlace }, { { 0, 0, 0, 0 } } }, { 130, -172, 130, 68, 130, 308, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[0] }, { { 0, 0, 0, 0 } } }, @@ -10416,7 +10414,9 @@ void menu_racer_portraits(void) { } /** - * + * Initialises the post race variables. + * Sets different defaults based on being in adventure mode, tracks mode, or multiplayer. + * Loads the menu assets for the postrace too. */ void postrace_start(s32 finishState, s32 worldID) { s16 *var_v1; @@ -10582,8 +10582,11 @@ void postrace_music_fade(s32 updateRate) { } } -// postrace_render -void func_80094D28(UNUSED s32 updateRate) { +/** + * Resizes the viewport when shrinking it down. + * Renders race order, lap times and text options beneath. + */ +void postrace_viewport(UNUSED s32 updateRate) { s32 temp; s32 var_s3; Settings *settings; @@ -10852,7 +10855,7 @@ s32 menu_postrace(Gfx **dList, Mtx **matrices, Vertex **vertices, s32 updateRate postrace_music_fade(updateRate); if (gMenuDelay < 20 && gPostraceFinishState == 0) { if (gPostRace.unk0_s32 < 0) { - func_80094D28(updateRate); + postrace_viewport(updateRate); } } else { bgdraw_texture_init(NULL, NULL, 0); @@ -12232,9 +12235,15 @@ void rankings_render_order(s32 updateRate) { (gMenuStage != POSTRACE_ENTER && gRankingsPlayers[i]))) { fade = (highlight >> 1) + 128; } +#ifdef AVOID_UB + gTrophyRankingsTitle[2 + (i * 3)].filterRed = fade; + gTrophyRankingsTitle[2 + (i * 3)].filterGreen = fade; + gTrophyRankingsTitle[2 + (i * 3)].filterBlue = fade; +#else gTrophyRankingsRacers[i * 3].filterRed = fade; gTrophyRankingsRacers[i * 3].filterGreen = fade; gTrophyRankingsRacers[i * 3].filterBlue = fade; +#endif } stage = gMenuStage; if (stage == RANKINGS_ORDER || stage == RANKINGS_EXIT) { diff --git a/src/menu.h b/src/menu.h index d619e248..ab80cd72 100644 --- a/src/menu.h +++ b/src/menu.h @@ -692,7 +692,7 @@ void func_80080E90(Gfx **dList, s32 startX, s32 startY, s32 width, s32 height, s s32 colour0, s32 colour1, s32 colour2, s32 colour3); void func_80084854(s32 updateRate); void func_80098774(s32); -void func_80094D28(UNUSED s32 updateRate); +void postrace_viewport(UNUSED s32 updateRate); void func_80082BC8_837C8(s32 dialogueBoxID, s32 xPos1, s32 yPos1, s32 xPos2, s32 yPos2, char *text, AlignmentFlags alignment, s32 textColour, s32 alpha); diff --git a/src/object_functions.c b/src/object_functions.c index fb919a23..e6985ebc 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -269,7 +269,7 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { racer->bubbleTrapTimer = 60; obj->properties.fireball.timer = -60; obj->properties.fireball.obj = someObj; - sound_play(SOUND_BUBBLE_RISE, &weapon->soundMask); + sound_play(SOUND_BUBBLE_RISE, (SoundHandle *) &weapon->soundMask); } } } @@ -304,7 +304,7 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { } } if (obj->properties.fireball.timer == 0) { - soundMask = weapon->soundMask; + soundMask = (SoundHandle) weapon->soundMask; if (soundMask != NULL) { sndp_stop(soundMask); } @@ -1056,7 +1056,7 @@ void obj_loop_timetrialghost(Object *obj, s32 updateRate) { Object *someObj; Object *someOtherObj; Object_UnkId58 *someOtherObj64; - Object_60 *obj60; + AttachPoint *attachPoint; s8 vehicleID; obj->segment.object.animationID = 0; @@ -1068,11 +1068,11 @@ void obj_loop_timetrialghost(Object *obj, s32 updateRate) { obj_spawn_particle(obj, updateRate); someOtherObj = get_racer_object(PLAYER_ONE); someOtherObj64 = &someOtherObj->unk64->unkid58; - obj60 = obj->unk60; - if (obj60->unk0 == 1) { + attachPoint = obj->attachPoints; + if (attachPoint->count == 1) { vehicleID = someOtherObj64->vehicleID; if (vehicleID == VEHICLE_HOVERCRAFT || vehicleID == VEHICLE_PLANE) { - someObj = (Object *) obj60->unk4[0]; + someObj = (Object *) attachPoint->obj[0]; someObj->segment.trans.rotation.y_rotation = 0x4000; someObj->segment.object.modelIndex++; someObj->segment.object.modelIndex &= 1; @@ -1905,7 +1905,7 @@ void obj_loop_wizpigship(Object *wizShipObj, s32 updateRate) { } else { wizShipObj->properties.fireball.timer = 0; } - if ((wizShipObj->unk60 != NULL) && (wizShipObj->properties.fireball.timer == 0)) { + if (wizShipObj->attachPoints != NULL && wizShipObj->properties.fireball.timer == 0) { if (wizShipObj->particleEmittersEnabled & OBJ_EMIT_1) { wizShipObj->properties.fireball.timer = 20; mtxf_from_transform(&shipMtx, &wizShipObj->segment.trans); @@ -1918,8 +1918,8 @@ void obj_loop_wizpigship(Object *wizShipObj, s32 updateRate) { trans.rotation.z_rotation = 0; mtxf_from_transform(&laserMtx, &trans); - for (i = 0; i < wizShipObj->unk60->unk0; i++) { - index = wizShipObj->unk60->unk2C[i]; + for (i = 0; i < wizShipObj->attachPoints->count; i++) { + index = wizShipObj->attachPoints->unk2C[i]; if ((index >= 0) && (index < wizShipModel->unk18)) { if (wizShipObj->curVertData != NULL) { posX = wizShipObj->curVertData[wizShipModel->unk14[index]].x; @@ -1954,21 +1954,25 @@ void obj_loop_wizpigship(Object *wizShipObj, s32 updateRate) { } } +/** + * Cutscene Vehicle loop behaviour. + * Performs its set behaviour while having its own handler for the attached vehicle parts. +*/ void obj_loop_vehicleanim(Object *obj, s32 updateRate) { - Object_60_800380F8 *obj60; - Object *someObj; + AttachPoint *attachPoint; + Object *attachObj; func_8001F460(obj, updateRate, obj); - obj60 = (Object_60_800380F8 *) obj->unk60; - if (obj60 != NULL) { - if (obj60->unk0 > 0) { - someObj = obj60->unk0 == 3 ? obj60->unkC : obj60->unk4; - someObj->segment.trans.rotation.y_rotation = 0x4000; - someObj->segment.object.modelIndex++; - if (someObj->segment.object.modelIndex == someObj->segment.header->numberOfModelIds) { - someObj->segment.object.modelIndex = 0; - } - } + attachPoint = obj->attachPoints; + if (attachPoint == NULL || attachPoint->count <= 0) { + return; + } + + attachObj = attachPoint->count == 3 ? attachPoint->obj[2] : attachPoint->obj[0]; + attachObj->segment.trans.rotation.y_rotation = 0x4000; + attachObj->segment.object.modelIndex++; + if (attachObj->segment.object.modelIndex == attachObj->segment.header->numberOfModelIds) { + attachObj->segment.object.modelIndex = 0; } } @@ -4963,8 +4967,8 @@ void weapon_projectile(Object *obj, s32 updateRate) { } block_37: obj->properties.projectile.unk4 += updateRate; - if (obj->unk60 != NULL) { - temp_s1_2 = obj->unk60->unk4[0]; + if (obj->attachPoints != NULL) { + temp_s1_2 = obj->attachPoints->obj[0]; if (obj->properties.projectile.unk4 < 8) { temp_s1_2->segment.trans.scale = obj->properties.projectile.unk4 * 0.5f; } else if (obj->properties.projectile.unk4 < 16) { diff --git a/src/object_functions.h b/src/object_functions.h index 0aa9e924..b1d634b4 100644 --- a/src/object_functions.h +++ b/src/object_functions.h @@ -135,14 +135,6 @@ typedef struct unk80037D08_arg0 { unk80037D08_arg0_64 *unk64; } unk80037D08_arg0; -// Not sure if Object_60 differs between objects yet. -typedef struct Object_60_800380F8 { - s32 unk0; - Object *unk4; - s32 pad8; - Object *unkC; -} Object_60_800380F8; - typedef struct unk80038B74 { u8 pad0[8]; s8 unk8; diff --git a/src/object_models.c b/src/object_models.c index 725323c3..6f13e777 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -13,8 +13,8 @@ /************ .data ************/ -s32 gTractionTableChecksum = TractionTableChecksum; -s32 gTrackRenderFuncLength = 1980; +s32 gRenderSceneChecksum = TractionTableChecksum; +s32 gRenderSceneFuncLength = 1980; /*******************************/ @@ -39,7 +39,7 @@ s32 gNumModelIDs; s32 D_8011D634; s16 *gAnimationTable; s32 *gObjectAnimationTable; -s32 D_8011D640; +s32 gModelAnimOffsetID; s32 D_8011D644; /******************************/ @@ -64,15 +64,15 @@ void allocate_object_model_pools(void) { gAnimationTable = (s16 *) load_asset_section_from_rom(ASSET_ANIMATION_IDS); gObjectAnimationTable = (s32 *) load_asset_section_from_rom(ASSET_OBJECT_ANIMATIONS_TABLE); D_8011D644 = (s32) mempool_alloc_safe(0xC00, COLOUR_TAG_GREEN); - D_8011D640 = 0; + gModelAnimOffsetID = 0; #ifdef ANTI_TAMPER // Antipiracy measure checksum = 0; - for (i = 0; i < gTrackRenderFuncLength; i++) { + for (i = 0; i < gRenderSceneFuncLength; i++) { checksum += *(u8 *) (((s32) &render_scene) + i); } - if (checksum != gTractionTableChecksum) { + if (checksum != gRenderSceneChecksum) { drm_vehicle_traction(); } #endif @@ -107,7 +107,7 @@ ModelInstance *object_model_init(s32 modelID, s32 flags) { for (i = 0; i < gModelCacheCount; i++) { if (modelID == gModelCache[ASSETCACHE_ID(i)]) { objMdl = (ObjectModel *) gModelCache[ASSETCACHE_PTR(i)]; - instance = model_init_type(objMdl, flags); + instance = model_instance_init(objMdl, flags); if (instance != NULL) { objMdl->references++; } @@ -163,7 +163,7 @@ ModelInstance *object_model_init(s32 modelID, s32 flags) { objMdl->unk10 = 0; objMdl->unk32 = 0; objMdl->texOffsetUpdateRate = 0; - objMdl->unk40 = 0; + objMdl->normals = NULL; objMdl->numberOfAnimations = 0; objMdl->animations = NULL; sp3F = 0; @@ -181,8 +181,8 @@ ModelInstance *object_model_init(s32 modelID, s32 flags) { goto block_30; } } - if (func_80060EA8(objMdl) == 0 && func_80061A00(objMdl, modelID) == 0) { - instance = model_init_type(objMdl, flags); + if (model_calc_normals(objMdl) == 0 && model_anim_init(objMdl, modelID) == 0) { + instance = model_instance_init(objMdl, flags); if (instance != NULL) { gModelCache[ASSETCACHE_ID(cacheIndex)] = modelID; gModelCache[ASSETCACHE_PTR(cacheIndex)] = (s32) objMdl; @@ -208,7 +208,13 @@ block_30: return NULL; } -ModelInstance *model_init_type(ObjectModel *model, s32 flags) { +/** + * Initialises the model instance. + * Objects that do nothing special get a standard instance assigned, + * otherwise, ones that utilise shading or animation will have their own copies of the vertex data. + * Returns null if it failed. + */ +ModelInstance *model_instance_init(ObjectModel *model, s32 flags) { s32 temp; ModelInstance *result; Vertex *var_v1; @@ -226,7 +232,7 @@ ModelInstance *model_init_type(ObjectModel *model, s32 flags) { (Vertex *) ((u8 *) result + (model->numberOfVertices * sizeof(Vertex)) + sizeof(ModelInstance)); result->vertices[2] = (Vertex *) ((u8 *) result + temp); result->modelType = MODELTYPE_ANIMATED; - } else if (model->unk40 != NULL && (flags & OBJECT_BEHAVIOUR_SHADED)) { + } else if (model->normals != NULL && (flags & OBJECT_BEHAVIOUR_SHADED)) { temp = (model->numberOfVertices * sizeof(Vertex)) + sizeof(ModelInstance); result = (ModelInstance *) mempool_alloc(temp, COLOUR_TAG_BLUE); if (result == NULL) { @@ -356,9 +362,9 @@ void free_model_data(ObjectModel *mdl) { if (mdl->unk10 != NULL) { mempool_free(mdl->unk10); } - // ??? - if (mdl->unk40 != NULL) { - mempool_free(mdl->unk40); + + if (mdl->normals != NULL) { + mempool_free(mdl->normals); } // free the animations if (mdl->animations != NULL) { @@ -672,13 +678,13 @@ s32 func_80060C58(Vertex *vertices, s32 i1, s32 i2, s32 i3, s32 i4) { } // Returns 0 if successful, or 1 if an error occured. -s32 func_80060EA8(ObjectModel *model) { +s32 model_calc_normals(ObjectModel *model) { Vertex *vertices; Triangle *triangles; - Vec3f *spAC; + Vec3f *floatNorms; s16 i; TriangleBatchInfo *batches; - Vec3s *spA0; + Vec3s *normals; s16 s6; s16 l; s16 q; @@ -693,7 +699,7 @@ s32 func_80060EA8(ObjectModel *model) { s16 vx, vy, vz; batches = model->batches; - model->unk40 = NULL; + model->normals = NULL; k = 0; for (i = 0; i < model->numberOfBatches; i++) { @@ -706,17 +712,18 @@ s32 func_80060EA8(ObjectModel *model) { vertices = model->vertices; triangles = model->triangles; - spAC = (Vec3f *) mempool_alloc(model->numberOfTriangles * sizeof(Vec3f), COLOUR_TAG_ORANGE); - if (spAC == NULL) { + floatNorms = (Vec3f *) mempool_alloc(model->numberOfTriangles * sizeof(Vec3f), COLOUR_TAG_ORANGE); + if (floatNorms == NULL) { return 1; } - spA0 = (Vec3s *) mempool_alloc(k * sizeof(Vec3s), COLOUR_TAG_ORANGE); - if (spA0 == NULL) { - mempool_free(spAC); + normals = (Vec3s *) mempool_alloc(k * sizeof(Vec3s), COLOUR_TAG_ORANGE); + if (normals == NULL) { + mempool_free(floatNorms); return 1; } + // Calculate vertex normals and store them as floating point. for (i = 0; i < model->numberOfBatches; i++) { vertOffset = batches[i].verticesOffset; for (j = batches[i].facesOffset; j < batches[i + 1].facesOffset; j++) { @@ -730,22 +737,23 @@ s32 func_80060EA8(ObjectModel *model) { sp58[k] = vertices[a2].z; } - spAC[j].x = (sp58[0] - sp58[2]) * (sp64[0] - sp64[1]) - (sp64[0] - sp64[2]) * (sp58[0] - sp58[1]); - spAC[j].y = (sp58[0] - sp58[1]) * (sp70[0] - sp70[2]) - (sp70[0] - sp70[1]) * (sp58[0] - sp58[2]); - spAC[j].z = (sp70[0] - sp70[1]) * (sp64[0] - sp64[2]) - (sp70[0] - sp70[2]) * (sp64[0] - sp64[1]); - length = sqrtf(spAC[j].x * spAC[j].x + spAC[j].y * spAC[j].y + spAC[j].z * spAC[j].z); + floatNorms[j].x = (sp58[0] - sp58[2]) * (sp64[0] - sp64[1]) - (sp64[0] - sp64[2]) * (sp58[0] - sp58[1]); + floatNorms[j].y = (sp58[0] - sp58[1]) * (sp70[0] - sp70[2]) - (sp70[0] - sp70[1]) * (sp58[0] - sp58[2]); + floatNorms[j].z = (sp70[0] - sp70[1]) * (sp64[0] - sp64[2]) - (sp70[0] - sp70[2]) * (sp64[0] - sp64[1]); + length = sqrtf(floatNorms[j].x * floatNorms[j].x + floatNorms[j].y * floatNorms[j].y + + floatNorms[j].z * floatNorms[j].z); if (length != 0.0f) { - spAC[j].x /= length; - spAC[j].y /= length; - spAC[j].z /= length; + floatNorms[j].x /= length; + floatNorms[j].y /= length; + floatNorms[j].z /= length; } } } v0 = (s16 *) mempool_alloc(model->numberOfVertices * sizeof(s16), COLOUR_TAG_ORANGE); if (v0 == NULL) { - mempool_free(spAC); - mempool_free(spA0); + mempool_free(floatNorms); + mempool_free(normals); return 1; } @@ -807,8 +815,8 @@ s32 func_80060EA8(ObjectModel *model) { v06 = (Vec3f *) mempool_alloc(s6 * sizeof(Vec3f), COLOUR_TAG_ORANGE); if (v06 == NULL) { - mempool_free(spAC); - mempool_free(spA0); + mempool_free(floatNorms); + mempool_free(normals); mempool_free(v0); return 1; } @@ -828,9 +836,9 @@ s32 func_80060EA8(ObjectModel *model) { a2 = v0[a2]; if (a2 >= 0) { - v06[a2].x += spAC[j].x; - v06[a2].y += spAC[j].y; - v06[a2].z += spAC[j].z; + v06[a2].x += floatNorms[j].x; + v06[a2].y += floatNorms[j].y; + v06[a2].z += floatNorms[j].z; } } } @@ -850,27 +858,36 @@ s32 func_80060EA8(ObjectModel *model) { for (k = 0; k < model->numberOfVertices; k++) { a2 = v0[k]; if (a2 >= 0) { - spA0[a0].x = v06[a2].x; - spA0[a0].y = v06[a2].y; - spA0[a0].z = v06[a2].z; + normals[a0].x = v06[a2].x; + normals[a0].y = v06[a2].y; + normals[a0].z = v06[a2].z; a0++; } } - model->unk40 = spA0; + model->normals = normals; mempool_free(v0); mempool_free(v06); - mempool_free(spAC); + mempool_free(floatNorms); } return 0; } -void func_800619F4(s32 arg0) { - D_8011D640 = arg0; +/** + * Sets the animation end offset for new models when loading. + * This lets you choose to load more animations than the model normally would. + */ +void model_anim_offset(s32 offset) { + gModelAnimOffsetID = offset; } -// Returns 0 if successful, or 1 if an error occured. -s32 func_80061A00(ObjectModel *model, s32 animTableIndex) { +/** + * Checks the animation table for the model ID for animation entries. + * Zero entries just set the anim count to zero and return early. + * Otherwise, allocate space for animation data for each animation and loads each into each data slot. + * Returns nonzero if something went wrong. + */ +s32 model_anim_init(ObjectModel *model, s32 modelID) { s32 j; s32 end; ObjectModel_44 *allocAnimData; @@ -883,15 +900,15 @@ s32 func_80061A00(ObjectModel *model, s32 animTableIndex) { u32 animAddress; s32 *temp; - start = gAnimationTable[animTableIndex]; - end = gAnimationTable[animTableIndex + 1]; + start = gAnimationTable[modelID]; + end = gAnimationTable[modelID + 1]; if (start == end) { model->numberOfAnimations = 0; return 0; } - if (D_8011D640 != 0) { - if (start + D_8011D640 < end) { - end = start + D_8011D640; + if (gModelAnimOffsetID != 0) { + if (start + gModelAnimOffsetID < end) { + end = start + gModelAnimOffsetID; } } model->numberOfAnimations = end - start; diff --git a/src/object_models.h b/src/object_models.h index 7d02fd4c..662a0b77 100644 --- a/src/object_models.h +++ b/src/object_models.h @@ -17,22 +17,22 @@ typedef struct unk8011D624 { ObjectModel *model; } unk8011D624; -extern s32 gTractionTableChecksum; -extern s32 gTrackRenderFuncLength; +extern s32 gRenderSceneChecksum; +extern s32 gRenderSceneFuncLength; void allocate_object_model_pools(void); -void func_800619F4(s32 arg0); +void model_anim_offset(s32 offset); void func_80061C0C(Object* obj); void free_3d_model(ModelInstance *modInst); -s32 func_80061A00(ObjectModel *model, s32 animTableIndex); +s32 model_anim_init(ObjectModel *model, s32 modelID); s32 check_nearby_vertices(Vertex *vertices, s32 arg1, s32 arg2, s32 arg3, s32 arg4); -ModelInstance *model_init_type(ObjectModel *model, s32 flags); +ModelInstance *model_instance_init(ObjectModel *model, s32 flags); ModelInstance *object_model_init(s32 modelID, s32 flags); s32 func_80060C58(Vertex *vertices, s32 i1, s32 i2, s32 i3, s32 i4); void free_model_data(ObjectModel *mdl); // Non Matching void func_80060910(ObjectModel *); s32 func_80060AC8(ObjectModel *mdl, s32 arg1, s32 arg2, s32 arg3, s32 *outBatchIndex, s32 *outVertexIndex); -s32 func_80060EA8(ObjectModel *); +s32 model_calc_normals(ObjectModel *); #endif diff --git a/src/objects.c b/src/objects.c index cbd22e9b..f3ab9ee6 100644 --- a/src/objects.c +++ b/src/objects.c @@ -242,10 +242,10 @@ s16 D_8011ADA4; f32 gObjectUpdateRateF; s32 gPathUpdateOff; s32 gEventCountdown; -s32 D_8011ADB4; +s32 gRaceFinishTriggered; s32 gEventStartTimer; s32 D_8011ADBC; -s32 D_8011ADC0; +s32 gNumFinishedRacers; s8 gFirstTimeFinish; s8 D_8011ADC5; u32 gBalloonCutsceneTimer; @@ -1009,7 +1009,7 @@ void func_8000C8F8(s32 arg0, s32 arg1) { } D_8011AE98[arg1] = (u8 *) (D_8011AEB0[arg1] + 4); D_8011AE70 = 0; - D_8011ADC0 = 1; + gNumFinishedRacers = 1; if (gPathUpdateOff == FALSE) { gParticlePtrList_flush(); func_80017E98(); @@ -1294,7 +1294,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { entry->common.z = spB4[i6]; entry->unkC = sp94[i6]; if (entry->unkE == 4) { - func_800619F4(1); + model_anim_offset(1); } if (entry->unkE == 4) { spawnObjFlags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK04; @@ -1309,7 +1309,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } if (vehicle >= VEHICLE_BOSSES) { spawnObjFlags = OBJECT_SPAWN_UNK01; - func_800619F4(0); + model_anim_offset(0); } newRacerObj = spawn_object((LevelObjectEntryCommon *) entry, spawnObjFlags); newRacerObj->segment.trans.rotation.y_rotation = sp94[i6]; @@ -1489,7 +1489,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } } gRaceEndTimer = 0; - D_8011ADB4 = 0; + gRaceFinishTriggered = 0; set_next_taj_challenge_menu(0); if (settings->worldId == WORLD_CENTRAL_AREA) { if (!is_in_tracks_mode()) { @@ -1768,10 +1768,10 @@ void func_8000E5EC(LevelObjectEntryCommon *arg0) { dst = (u8 *) arg0; src = (u8 *) ((s32) arg0 + size); end = sp30[sp1C]; - if ((u32) src < end) { + if ((u32) src < (u32) end) { do { *dst++ = *src++; - } while ((u32) src != end); + } while ((u32) src != (u32) end); } D_8011AEA0[sp1C] -= size; @@ -1810,7 +1810,7 @@ void func_8000E79C(u8 *arg0, u8 *arg1) { var_a2 = arg0 + arg1Value; var_t0 = arg0 + arg0Value2; k = (u32) var_a3; - while (((u32) var_t0) < k) { + while (((u32) var_t0) < (u32) k) { *var_a2 = *var_t0; var_a2++; var_t0++; @@ -1820,7 +1820,7 @@ void func_8000E79C(u8 *arg0, u8 *arg1) { var_a2 -= arg0Value2; var_t0 = var_a3; k = (u32) (arg0 + arg1Value); - while (k < ((u32) var_a2)) { + while ((u32) k < ((u32) var_a2)) { var_a2--; var_t0--; *var_a2 = *var_t0; @@ -1969,7 +1969,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 spawnFlags) { i = 0; // a2 switch (curObj->segment.header->behaviorId) { case BHV_PARK_WARDEN: - func_800619F4(7); + model_anim_offset(7); break; case BHV_ANIMATED_OBJECT_4: i = get_character_id_from_slot(PLAYER_ONE); @@ -2104,9 +2104,9 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 spawnFlags) { if (behaviourFlags & OBJECT_BEHAVIOUR_UNK20) { address += func_8000FD34(curObj, (Object_5C *) address); } - if (curObj->segment.header->unk56 > 0 && curObj->segment.header->unk56 < 10) { - curObj->unk60 = (Object_60 *) address; - address += sizeof(Object_60); + if (curObj->segment.header->attachPointCount > 0 && curObj->segment.header->attachPointCount < 10) { + curObj->attachPoints = (AttachPoint *) address; + address += sizeof(AttachPoint); } if (curObj->segment.header->particleCount > 0) { address += obj_init_emitter(curObj, (ParticleEmitter *) address); @@ -2165,8 +2165,9 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 spawnFlags) { if (curObj->unk5C != NULL) { curObj->unk5C = (Object_5C *) (((uintptr_t) curObj + (uintptr_t) curObj->unk5C) - (uintptr_t) gSpawnObjectHeap); } - if (curObj->unk60 != NULL) { - curObj->unk60 = (Object_60 *) (((uintptr_t) curObj + (uintptr_t) curObj->unk60) - (uintptr_t) gSpawnObjectHeap); + if (curObj->attachPoints != NULL) { + curObj->attachPoints = + (AttachPoint *) (((uintptr_t) curObj + (uintptr_t) curObj->attachPoints) - (uintptr_t) gSpawnObjectHeap); } if (curObj->segment.header->particleCount > 0) { curObj->particleEmitter = (ParticleEmitter *) (((uintptr_t) curObj + (uintptr_t) curObj->particleEmitter) - @@ -2188,7 +2189,8 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 spawnFlags) { curObj->interactObj->y_position = curObj->segment.trans.y_position; curObj->interactObj->z_position = curObj->segment.trans.z_position; } - if (curObj->segment.header->unk56 > 0 && curObj->segment.header->unk56 < 10 && func_8000F99C(curObj)) { + if (curObj->segment.header->attachPointCount > 0 && curObj->segment.header->attachPointCount < 10 && + obj_init_attachpoint(curObj)) { if (D_8011AE50 != NULL) { tex_free((TextureHeader *) (s32) D_8011AE50); } @@ -2206,7 +2208,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 spawnFlags) { if (curObj->segment.header->numLightSources > 0) { light_setup_light_sources(curObj); } - func_800619F4(0); + model_anim_offset(0); update_object_stack_trace(OBJECT_SPAWN, -1); return curObj; } @@ -2258,7 +2260,7 @@ s32 init_object_shading(Object *obj, ShadeProperties *shadeData) { returnSize = 0; if (obj->segment.header->modelType == OBJECT_MODEL_TYPE_3D_MODEL) { for (i = 0; obj->modelInstances[i] == NULL; i++) {} - if (obj->modelInstances[i] != NULL && obj->modelInstances[i]->objModel->unk40 != NULL) { + if (obj->modelInstances[i] != NULL && obj->modelInstances[i]->objModel->normals != NULL) { set_shading_properties(obj->shading, obj->segment.header->shadeAmbient, obj->segment.header->shadeDiffuse, 0, obj->segment.header->shadeAngleY, obj->segment.header->shadeAngleZ); if (obj->segment.header->unk3D != 0) { @@ -2286,34 +2288,35 @@ s32 init_object_shading(Object *obj, ShadeProperties *shadeData) { return (returnSize & ~3) + 4; } -s32 func_8000F99C(Object *obj) { - Object *temp_v0; - Object_60 *obj60; +s32 obj_init_attachpoint(Object *obj) { + Object *attachObj; + AttachPoint *attachPoint; s32 i; - s32 var_s4; + s32 failed; - obj60 = obj->unk60; - obj60->unk0 = obj->segment.header->unk56; - obj60->unk0 = obj60->unk0; // Fakematch? - var_s4 = FALSE; - for (i = 0; i < obj60->unk0; i++) { - obj60->unk4[i] = func_8000FD54(obj->segment.header->vehiclePartIds[i ^ 0]); // i ^ 0 fakematch - if (obj60->unk4[i] == NULL) { - var_s4 = TRUE; + attachPoint = obj->attachPoints; + attachPoint->count = obj->segment.header->attachPointCount; + attachPoint->count = attachPoint->count; // Fakematch? + failed = FALSE; + for (i = 0; i < attachPoint->count; i++) { + attachPoint->obj[i] = obj_spawn_attachment(obj->segment.header->vehiclePartIds[i ^ 0]); // i ^ 0 fakematch + if (attachPoint->obj[i] == NULL) { + failed = TRUE; } } - if (var_s4) { - for (i = 0; i < obj60->unk0; i++) { - temp_v0 = obj60->unk4[i]; - if (temp_v0 != NULL) { - objFreeAssets(temp_v0, temp_v0->segment.header->numberOfModelIds, temp_v0->segment.header->modelType); - try_free_object_header(temp_v0->segment.object.unk2C); - mempool_free(temp_v0); + if (failed) { + for (i = 0; i < attachPoint->count; i++) { + attachObj = attachPoint->obj[i]; + if (attachObj != NULL) { + objFreeAssets(attachObj, attachObj->segment.header->numberOfModelIds, + attachObj->segment.header->modelType); + try_free_object_header(attachObj->segment.object.unk2C); + mempool_free(attachObj); } } return TRUE; } - obj60->unk2C = obj->segment.header->vehiclePartIndices; + attachPoint->unk2C = obj->segment.header->vehiclePartIndices; return FALSE; } @@ -2397,8 +2400,11 @@ s32 func_8000FD34(Object *obj, Object_5C *matrices) { return sizeof(Object_5C); } -// Loads an object from object header index -Object *func_8000FD54(s32 objectHeaderIndex) { +/** + * Attempts to spawn an attachment object. + * Similar to the regular object spawning function, but cut down considerably. + */ +Object *obj_spawn_attachment(s32 objID) { s32 modelType; Object *object; ObjectHeader *objHeader; @@ -2408,17 +2414,17 @@ Object *func_8000FD54(s32 objectHeaderIndex) { s8 numModelIds; u8 *objectAsRawBytes; - if (objectHeaderIndex >= gAssetsObjectHeadersTableLength) { - objectHeaderIndex = 0; + if (objID >= gAssetsObjectHeadersTableLength) { + objID = 0; } - objHeader = load_object_header(objectHeaderIndex); + objHeader = load_object_header(objID); if (objHeader == NULL) { return NULL; } objSize = (objHeader->numberOfModelIds * 4) + 0x80; object = (Object *) mempool_alloc(objSize, COLOUR_TAG_BLUE); if (object == NULL) { - try_free_object_header(objectHeaderIndex); + try_free_object_header(objID); return NULL; } @@ -2429,8 +2435,8 @@ Object *func_8000FD54(s32 objectHeaderIndex) { object->segment.trans.flags = OBJ_FLAGS_UNK_0002; object->segment.header = objHeader; - object->segment.object.unk2C = objectHeaderIndex; - object->objectID = objectHeaderIndex; + object->segment.object.unk2C = objID; + object->objectID = objID; object->segment.trans.scale = objHeader->scale; if (objHeader->flags & HEADER_FLAGS_UNK_0080) { object->segment.trans.flags |= OBJ_FLAGS_UNK_0080; @@ -2457,7 +2463,7 @@ Object *func_8000FD54(s32 objectHeaderIndex) { } if (failedToLoadModel) { objFreeAssets(object, numModelIds, modelType); - try_free_object_header(objectHeaderIndex); + try_free_object_header(objID); mempool_free(object); return NULL; } @@ -2546,14 +2552,14 @@ void func_800101AC(Object *obj, s32 arg1) { return; } - if (obj->unk60 != NULL) { - for (i = 0; i < obj->unk60->unk0; i++) { - tempObj = obj->unk60->unk4[i]; + if (obj->attachPoints != NULL) { + for (i = 0; i < obj->attachPoints->count; i++) { + tempObj = obj->attachPoints->obj[i]; numberOfModelIds = tempObj->segment.header->numberOfModelIds; modelType = tempObj->segment.header->modelType; if (modelType == OBJECT_MODEL_TYPE_3D_MODEL) { for (j = 0; j < numberOfModelIds; j++) { - free_3d_model(&tempObj->modelInstances[j]->objModel); + free_3d_model((ModelInstance *) &tempObj->modelInstances[j]->objModel); } } else { for (j = 0; j < numberOfModelIds; j++) { @@ -2888,7 +2894,7 @@ void obj_update(s32 updateRate) { } if (gNumRacers != 0) { if (gRaceEndTimer == 0) { - func_80019808(updateRate); + race_check_finish(updateRate); } else { race_transition_adventure(updateRate); } @@ -3363,7 +3369,7 @@ void render_3d_model(Object *obj) { s32 intensity; s32 opacity; s32 vertOffset; - s32 obj60_unk0; + s32 attachPointCount; s32 hasOpacity; s32 hasLighting; s32 flags; @@ -3373,7 +3379,7 @@ void render_3d_model(Object *obj) { f32 vtxY; f32 vtxZ; s8 index; - s8 var_v0_2; + s8 isCargo; Object *loopObj; ModelInstance *modInst; Object_Racer *racerObj; @@ -3402,7 +3408,7 @@ void render_3d_model(Object *obj) { if (modInst->modelType == MODELTYPE_ANIMATED) { obj_animate(obj); } - if (modInst->modelType != MODELTYPE_BASIC && objModel->unk40 != NULL) { + if (modInst->modelType != MODELTYPE_BASIC && objModel->normals != NULL) { flags = TRUE; if (racerObj != NULL && racerObj->vehicleID < VEHICLE_BOSSES && racerObj->playerIndex == PLAYER_COMPUTER) { @@ -3486,15 +3492,15 @@ void render_3d_model(Object *obj) { } directional_lighting_off(); } - if (obj->unk60 != NULL) { - obj60_unk0 = obj->unk60->unk0; + if (obj->attachPoints != NULL) { + attachPointCount = obj->attachPoints->count; if (racerObj != NULL && racerObj->vehicleID == VEHICLE_FLYING_CAR) { - obj60_unk0 = 0; + attachPointCount = 0; } - for (i = 0; i < obj60_unk0; i++) { - loopObj = obj->unk60->unk4[i]; + for (i = 0; i < attachPointCount; i++) { + loopObj = obj->attachPoints->obj[i]; if (!(loopObj->segment.trans.flags & OBJ_FLAGS_INVISIBLE)) { - index = obj->unk60->unk2C[i]; + index = obj->attachPoints->unk2C[i]; if (index >= 0 && index < objModel->unk18) { something = loopObj->sprites[loopObj->segment.object.modelIndex]; vtxX = obj->curVertData[objModel->unk14[index]].x; @@ -3521,11 +3527,12 @@ void render_3d_model(Object *obj) { #else if (1) { #endif - var_v0_2 = (loopObj->segment.trans.flags & OBJ_FLAGS_UNK_0080 && obj60_unk0 == 3); + // In this instance, cargo refers to the eggs in the fire mountain challenge. + isCargo = (loopObj->segment.trans.flags & OBJ_FLAGS_UNK_0080 && attachPointCount == 3); if (racerObj != NULL && racerObj->transparency < 255) { - var_v0_2 = FALSE; + isCargo = FALSE; } - if (var_v0_2) { + if (isCargo) { func_80012C98(&gObjectCurrDisplayList); gDPSetEnvColor(gObjectCurrDisplayList++, 255, 255, 255, 0); gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, intensity, intensity, intensity, @@ -3534,7 +3541,7 @@ void render_3d_model(Object *obj) { loopObj->properties.common.unk0 = render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, loopObj, something, flags); - if (var_v0_2) { + if (isCargo) { gSPSelectMatrixDKR(gObjectCurrDisplayList++, G_MTX_DKR_INDEX_0); func_80012CE8(&gObjectCurrDisplayList); } @@ -6192,7 +6199,7 @@ void func_80018CE0(Object *racerObj, f32 xPos, f32 yPos, f32 zPos, s32 updateRat midiFade->unk0 = var_v1; midiFade->unk1 = 0; midiFade->unk4 = 0; - D_8011AF60[0] = (s32) midiFade; + D_8011AF60[0] = (Object_MidiFade *) midiFade; } } } @@ -6355,26 +6362,32 @@ s32 func_8001955C(Object *obj, s32 checkpoint, u8 arg2, s32 arg3, s32 arg4, f32 // D_B0000574 is a direct read from the ROM as opposed to RAM extern s32 D_B0000574; -void func_80019808(s32 updateRate) { - s32 prevUnk1AA; +/** + * Check the win conditions of the current race. + * This varies based on the race type, so this does a multitude of different possible things. + * When the race is finished, it will then for the most part trigger the next menu, + * but adventure mode will start the balloon cutscene if it has not yet been awarded. + */ +void race_check_finish(s32 updateRate) { + s32 prevRacerPos; s32 i; - s32 j; // sp94 - s32 newUnk1AA; + s32 j; + s32 racerPos; Settings *settings; - s16 numHumanRacers; // sp8A - s16 numHumanRacersFinished; // sp88 + s16 numHumanRacers; + s16 numHumanRacersFinished; Object_Racer *curRacer2; - Object_Racer *curRacer; // sp80 + Object_Racer *curRacer; s16 numFinishedRacers; s16 foundIndex; - Object_Racer *racer[4]; // sp6C + Object_Racer *racer[4]; s16 racerIndex; s8 raceType; s8 someBool; - LevelHeader *currentLevelHeader; // sp64 + LevelHeader *currentLevelHeader; s32 newStartingPosition; s8 sp5C[4]; - s8 someBool2; // sp5B + s8 someBool2; s8 flags[3]; s32 camera; @@ -6387,11 +6400,12 @@ void func_80019808(s32 updateRate) { if (someBool2 != RACETYPE_DEFAULT && someBool2 != RACETYPE_HORSESHOE_GULCH && someBool2 != RACETYPE_BOSS) { if (someBool2 & RACETYPE_CHALLENGE) { if (someBool2 == RACETYPE_CHALLENGE_EGGS) { - func_80045128(*gRacers); + racer_update_eggs(*gRacers); } - if (D_8011ADB4 == 0) { + if (gRaceFinishTriggered == FALSE) { for (i = 0; i < gNumRacers; i++) { racer[i] = &(*gRacers)[i]->unk64->racer; + // Manage eliminated racers in deathmatch. if (currentLevelHeader->race_type == RACETYPE_CHALLENGE_BATTLE && racer[i]->bananas <= 0 && !racer[i]->raceFinished) { racer[i]->raceFinished = TRUE; @@ -6399,8 +6413,8 @@ void func_80019808(s32 updateRate) { racer_sound_free((*gRacers)[i]); (*gRacers)[i]->segment.trans.flags |= OBJ_FLAGS_INVISIBLE; (*gRacers)[i]->interactObj->flags = INTERACT_FLAGS_NONE; - racer[i]->finishPosition = 5 - D_8011ADC0; - D_8011ADC0++; + racer[i]->finishPosition = 5 - gNumFinishedRacers; + gNumFinishedRacers++; } if (racer[i]->playerIndex != PLAYER_COMPUTER) { if (racer[i]->raceFinished) { @@ -6411,8 +6425,8 @@ void func_80019808(s32 updateRate) { if (racer[i]->raceFinished) { numFinishedRacers++; if (racer[i]->finishPosition == 0) { - racer[i]->finishPosition = D_8011ADC0; - D_8011ADC0++; + racer[i]->finishPosition = gNumFinishedRacers; + gNumFinishedRacers++; } } } @@ -6454,21 +6468,23 @@ void func_80019808(s32 updateRate) { } if (racerIndex != -1) { + // In battle mode, last to finish wins, so flip the finish order. if (currentLevelHeader->race_type == RACETYPE_CHALLENGE_BATTLE) { - racer[racerIndex]->finishPosition = 5 - D_8011ADC0; + racer[racerIndex]->finishPosition = 5 - gNumFinishedRacers; } else { - racer[racerIndex]->finishPosition = D_8011ADC0; + racer[racerIndex]->finishPosition = gNumFinishedRacers; } - D_8011ADC0++; + gNumFinishedRacers++; racer[racerIndex]->raceFinished = TRUE; } i = 0; } while (racerIndex != -1); gSwapLeadPlayer = FALSE; + // Award the winner a TT amulet if not in tracks mode. if (!is_in_tracks_mode() && (racer[0]->finishPosition == 1 || - is_in_two_player_adventure() && racer[1]->finishPosition == 1) && + (is_in_two_player_adventure() && racer[1]->finishPosition == 1)) && (!(settings->courseFlagsPtr[settings->courseId] & RACE_CLEARED))) { settings->courseFlagsPtr[settings->courseId] |= RACE_CLEARED; i = settings->ttAmulet + 1; @@ -6477,36 +6493,37 @@ void func_80019808(s32 updateRate) { } settings->ttAmulet = i; } - for (newUnk1AA = 0; newUnk1AA < 8;) { - settings->racers[newUnk1AA++].starting_position = -1; + for (racerPos = 0; racerPos < 8;) { + settings->racers[racerPos++].starting_position = -1; } newStartingPosition = SEQUENCE_BATTLE_LOSE; - for (newUnk1AA = 0; newUnk1AA < gNumRacers; newUnk1AA++) { - if (racer[newUnk1AA]->playerIndex != PLAYER_COMPUTER && racer[newUnk1AA]->finishPosition == 1) { + for (racerPos = 0; racerPos < gNumRacers; racerPos++) { + if (racer[racerPos]->playerIndex != PLAYER_COMPUTER && racer[racerPos]->finishPosition == 1) { newStartingPosition = SEQUENCE_BATTLE_VICTORY; } - settings->racers[newUnk1AA].starting_position = racer[newUnk1AA]->finishPosition - 1; + settings->racers[racerPos].starting_position = racer[racerPos]->finishPosition - 1; } music_play(newStartingPosition); newStartingPosition = 4; - for (prevUnk1AA = 0; prevUnk1AA < 8; prevUnk1AA++) { - if (settings->racers[prevUnk1AA].starting_position == -1) { - settings->racers[prevUnk1AA].starting_position = newStartingPosition; + for (prevRacerPos = 0; prevRacerPos < 8; prevRacerPos++) { + if (settings->racers[prevRacerPos].starting_position == -1) { + settings->racers[prevRacerPos].starting_position = newStartingPosition; newStartingPosition++; } } - gSwapLeadPlayer = 0; + gSwapLeadPlayer = FALSE; if (is_in_two_player_adventure() && settings->racers[PLAYER_TWO].starting_position < settings->racers[PLAYER_ONE].starting_position) { - gSwapLeadPlayer = 1; + gSwapLeadPlayer = TRUE; } + // i will be nonzero if any adventure mode award triggers happened. if (i == 0) { if (is_in_two_player_adventure()) { if (gSwapLeadPlayer) { - gSwapLeadPlayer = 0; + gSwapLeadPlayer = FALSE; swap_lead_player(); if (D_800DC73C != 0) { D_800DC748 = TRUE; @@ -6520,9 +6537,9 @@ void func_80019808(s32 updateRate) { push_level_property_stack(SPECIAL_MAP_ID_NO_LEVEL, 0, VEHICLE_CAR, CUTSCENE_ID_NONE); push_level_property_stack(ASSET_LEVEL_TTAMULETSEQUENCE, 0, VEHICLE_NO_OVERRIDE, settings->ttAmulet - 1); - race_finish_adventure(1); + race_finish_adventure(TRUE); } - D_8011ADB4 = 1; + gRaceFinishTriggered = TRUE; } } } @@ -6531,39 +6548,39 @@ void func_80019808(s32 updateRate) { i = 0; do { - newUnk1AA = 1; + racerPos = 1; curRacer = &(*gRacers)[i]->unk64->racer; - prevUnk1AA = curRacer->unk1AA; + prevRacerPos = curRacer->racerOrder; j = 0; do { if (j != i) { curRacer2 = &(*gRacers)[j]->unk64->racer; if (curRacer->raceFinished == FALSE && curRacer2->raceFinished != FALSE) { - newUnk1AA++; + racerPos++; } else if (curRacer->courseCheckpoint < curRacer2->courseCheckpoint) { - newUnk1AA++; + racerPos++; } else if (curRacer->courseCheckpoint == curRacer2->courseCheckpoint) { if (curRacer2->unk1A8 < curRacer->unk1A8) { - newUnk1AA++; + racerPos++; } if (curRacer->unk1A8 == curRacer2->unk1A8 && i < j) { - newUnk1AA++; + racerPos++; } } } j++; } while (j < gNumRacers); - curRacer->unk1AA = newUnk1AA; + curRacer->racerOrder = racerPos; if (curRacer->lap < currentLevelHeader->laps) { - if (prevUnk1AA == curRacer->unk1AA) { + if (prevRacerPos == curRacer->racerOrder) { if (curRacer->unk1B0 < 2) { if (curRacer->vehicleID != VEHICLE_LOOPDELOOP) { curRacer->unk1B0++; } - } else if (curRacer->unk1AA != curRacer->racePosition) { + } else if (curRacer->racerOrder != curRacer->racePosition) { curRacer->unk1B2 = 10; - curRacer->racePosition = curRacer->unk1AA; + curRacer->racePosition = curRacer->racerOrder; } } else { curRacer->unk1B0 = 0; @@ -6578,11 +6595,11 @@ void func_80019808(s32 updateRate) { if (curRacer->lap >= currentLevelHeader->laps && curRacer->raceFinished == FALSE) { if (get_game_mode() != GAMEMODE_UNUSED_4) { curRacer->raceFinished = TRUE; - curRacer->finishPosition = D_8011ADC0; - if (D_8011ADC0 == 1 && curRacer->playerIndex == PLAYER_COMPUTER) { + curRacer->finishPosition = gNumFinishedRacers; + if (gNumFinishedRacers == 1 && curRacer->playerIndex == PLAYER_COMPUTER) { sound_play(SOUND_WHOOSH5, NULL); } - D_8011ADC0++; + gNumFinishedRacers++; } } if (curRacer->playerIndex != PLAYER_COMPUTER) { @@ -6609,11 +6626,11 @@ void func_80019808(s32 updateRate) { do { curRacer = &(*gRacers)[i]->unk64->racer; if (curRacer->raceFinished) { - newUnk1AA = curRacer->finishPosition - 1; + racerPos = curRacer->finishPosition - 1; } else { - newUnk1AA = curRacer->unk1AA - 1; + racerPos = curRacer->racerOrder - 1; } - gRacersByPosition[newUnk1AA] = (*gRacers)[i]; + gRacersByPosition[racerPos] = (*gRacers)[i]; i++; } while (i < gNumRacers); @@ -6662,10 +6679,10 @@ void func_80019808(s32 updateRate) { curRacer = &(*gRacers)[0]->unk64->racer; if (!curRacer->raceFinished) { curRacer->raceFinished = TRUE; - curRacer->finishPosition = D_8011ADC0; - D_8011ADC0 += 1; + curRacer->finishPosition = gNumFinishedRacers; + gNumFinishedRacers++; } - } else if (D_8011ADB4 == 0) { + } else if (gRaceFinishTriggered == FALSE) { someBool2 = FALSE; if (is_in_two_player_adventure() && numHumanRacersFinished > 0 && get_trophy_race_world_id() == 0 && set_course_finish_flags(settings) != 0) { @@ -6681,15 +6698,15 @@ void func_80019808(s32 updateRate) { if (curRacer->raceFinished == FALSE) { if (curRacer->playerIndex >= 0) { set_active_camera(curRacer->playerIndex); - camera = cam_get_active_camera_no_cutscenes(); + camera = (s32) cam_get_active_camera_no_cutscenes(); // we need the camera to be a s32 for the WAIT_ON_IOBUSY anti tamper call to work // but we *know* that cam_get_active_camera_no_cutscenes returns a Camera pointer so this // should be safe ((Camera *) camera)->mode = CAMERA_FINISH_CHALLENGE; } curRacer->raceFinished = TRUE; - curRacer->finishPosition = D_8011ADC0; - D_8011ADC0++; + curRacer->finishPosition = gNumFinishedRacers; + gNumFinishedRacers++; } i++; } while (i < gNumRacers); @@ -6710,8 +6727,8 @@ void func_80019808(s32 updateRate) { i = 0; do { curRacer = &gRacersByPosition[i]->unk64->racer; - newUnk1AA = curRacer->racerIndex; - settings->racers[newUnk1AA].starting_position = i; + racerPos = curRacer->racerIndex; + settings->racers[racerPos].starting_position = i; i++; } while (i < gNumRacers); } @@ -6761,9 +6778,9 @@ void func_80019808(s32 updateRate) { if (settings->worldId != 0) { settings->balloonsPtr[0]++; } - race_finish_adventure(1); + race_finish_adventure(TRUE); } - D_8011ADB4 = -1; + gRaceFinishTriggered = -1; // -1 doesn't do anything different. if (get_number_of_active_players() == 1) { race_finish_time_trial(); } @@ -7252,7 +7269,7 @@ void set_ghost_none(void) { Object *func_8001B7A8(Object_Racer *racer, s32 position, f32 *distance) { UNUSED s32 pad; Object *tempRacerObj; - position = (racer->unk1AA - position) - 1; + position = (racer->racerOrder - position) - 1; if (position < 0 || position >= gNumRacers) { return NULL; } @@ -8195,7 +8212,7 @@ void calc_dynamic_lighting_for_object_1(Object *object, ObjectModel *model, s16 } vertices = object->curVertData; - normals = model->unk40; + normals = model->normals; normIdx = 0; direction.x = -(object->shading->lightDirX << 3); @@ -8294,7 +8311,7 @@ void calc_env_mapping_for_object(ObjectModel *model, s16 zRot, s16 xRot, s16 yRo count = 0; triangles = model->triangles; - model40Entries = model->unk40; + model40Entries = model->normals; objTrans.rotation.z_rotation = zRot; objTrans.rotation.x_rotation = xRot; objTrans.rotation.y_rotation = yRot; @@ -9089,7 +9106,7 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { temp_s3->racer.unk2A = temp_v0_3 - arg1; if ((s16) temp_s3->racer.unk2A <= 0) { temp_s3->effect_box.unkE[0x37] = 1; - temp_s1 = temp_s3->racer.unk1C->pan; + temp_s1 = (LevelObjectEntry_Animation *) temp_s3->racer.unk1C->pan; func_80021104(arg0, &temp_s3->animation, temp_s1); temp_s3->racer.unk2A = 0; func_8002125C(arg0, (LevelObjectEntry_CharacterSelect *) temp_s1, (Object_CharacterSelect *) temp_s3, -1); @@ -10477,8 +10494,8 @@ void mode_init_taj_race(void) { racer->unk1BA = 0; settings = get_settings(); gEventCountdown = 80; - D_8011ADB4 = 0; - D_8011ADC0 = 1; + gRaceFinishTriggered = FALSE; + gNumFinishedRacers = 1; levelHeader->laps = 3; levelHeader->race_type = RACETYPE_DEFAULT; hud_init_element(); @@ -10497,7 +10514,7 @@ void mode_init_taj_race(void) { newRacerEntry.angleZ = 0; newRacerEntry.playerIndex = 4; newRacerEntry.common.objectID = ASSET_OBJECT_ID_FLYINGCARPET; - func_800619F4(0); + model_anim_offset(0); racerObj = spawn_object(&newRacerEntry.common, OBJECT_SPAWN_UNK01); (*gRacers)[1] = racerObj; gRacersByPosition[1] = racerObj; diff --git a/src/objects.h b/src/objects.h index 0141a751..2858a6f5 100644 --- a/src/objects.h +++ b/src/objects.h @@ -491,7 +491,7 @@ void render_bubble_trap(ObjectTransform *trans, Sprite *gfxData, Object *obj, s3 void gParticlePtrList_flush(void); s32 init_object_shading(Object *obj, ShadeProperties *shadeData); ObjectHeader *load_object_header(s32 index); -s32 func_8000F99C(Object *); +s32 obj_init_attachpoint(Object *); void try_free_object_header(s32 index); s32 get_object_property_size(Object *obj, Object_64 *obj64); void light_setup_light_sources(Object *obj); @@ -513,7 +513,7 @@ void render_3d_model(Object *obj); void mode_end_taj_race(s32 reason); void ainode_update(void); void func_8001E6EC(s8); -Object *func_8000FD54(s32 objectHeaderIndex); +Object *obj_spawn_attachment(s32 objID); void sort_objects_by_dist(s32 startIndex, s32 lastIndex); void func_80016748(Object *obj0, Object *obj1); void race_finish_time_trial(void); @@ -551,7 +551,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32); s32 func_8001F460(Object*, s32, Object*); void func_8000B750(Object *racerObj, s32 racerIndex, s32 vehicleIDPrev, s32 boostType, s32 arg4); void func_80018CE0(Object* racerObj, f32 xPos, f32 yPos, f32 zPos, s32 updateRate); -s32 func_800185E4(s32 checkpointIndex, Object *obj, f32 objX, f32 objY, f32 objZ, f32 *checkpointDistance, u8 *arg6); +s32 func_800185E4(s32 checkpointIndex, Object *obj, f32 objX, f32 objY, f32 objZ, f32 *arg5, u8 *arg6); void obj_tex_animate(Object *, s32); Object *find_furthest_telepoint(f32 x, f32 z); void func_8006017C(ObjectModel *); @@ -562,7 +562,7 @@ void func_8000CC7C(Vehicle, u32, s32); void func_80017E98(void); void spectate_update(void); void func_8001E93C(void); -void func_80019808(s32 updateRate); +void race_check_finish(s32 updateRate); void func_80014090(Object*, s32); void audspat_update_all(Object**, s32, s32); void func_8001E89C(void); diff --git a/src/particles.c b/src/particles.c index b609be5b..aa49969b 100644 --- a/src/particles.c +++ b/src/particles.c @@ -96,8 +96,8 @@ s32 gMaxRectangleParticles = 0; s32 gMaxSpriteParticles = 0; s32 gMaxLineParticles = 0; s32 gMaxPointParticles = 0; -Sprite **D_800E2E60 = NULL; // Sprites loaded from asset 47; appears to be unused -s32 D_800E2E64 = 0; // Number of sprites in D_800E2E60 +Sprite **gParticleDummys = NULL; // Sprites loaded from asset 47; appears to be unused +s32 gParticleDummyCount = 0; // Number of sprites in gParticleDummys Vec2s gParticleCoordListTri[3] = { { { { 0, 8 } } }, @@ -157,7 +157,7 @@ s16 gHovercraftParticleOpacities[8]; void reset_particles(void) { free_particle_buffers(); free_particle_vertices_triangles(); - free_unknown_particle_sprites(); + particle_free_dummy(); } /** @@ -167,21 +167,21 @@ void reset_particles_with_assets(void) { free_particle_buffers(); free_particle_vertices_triangles(); free_particle_assets(); - free_unknown_particle_sprites(); + particle_free_dummy(); } /** - * Deallocate buffers used for sprites from asset 47. + * Free dummy particles from RAM. */ -void free_unknown_particle_sprites(void) { +void particle_free_dummy(void) { s32 i; - if (D_800E2E60 != NULL) { - for (i = 0; i < D_800E2E64; i++) { - sprite_free(D_800E2E60[i]); + if (gParticleDummys != NULL) { + for (i = 0; i < gParticleDummyCount; i++) { + sprite_free(gParticleDummys[i]); } - mempool_free(D_800E2E60); - D_800E2E60 = 0; + mempool_free(gParticleDummys); + gParticleDummys = NULL; } } @@ -412,16 +412,16 @@ void init_particle_buffers(s32 maxTriangleParticles, s32 maxRectangleParticles, gPointParticleBuffer[i].base.kind = PARTICLE_KIND_NONE; } - if (D_800E2E60 == NULL) { + if (gParticleDummys == NULL) { asset2F = (s16 *) load_asset_section_from_rom(ASSET_BINARY_47); - D_800E2E64 = 0; - while (asset2F[D_800E2E64] != -1) { - D_800E2E64++; + gParticleDummyCount = 0; + while (asset2F[gParticleDummyCount] != -1) { + gParticleDummyCount++; } - D_800E2E60 = mempool_alloc_safe(D_800E2E64 * 4, COLOUR_TAG_BLUE); - for (i = 0; i < D_800E2E64; i++) { - D_800E2E60[i] = (Sprite *) tex_load_sprite(asset2F[i] & 0x3FFF, 1); + gParticleDummys = mempool_alloc_safe(gParticleDummyCount * 4, COLOUR_TAG_BLUE); + for (i = 0; i < gParticleDummyCount; i++) { + gParticleDummys[i] = (Sprite *) tex_load_sprite(asset2F[i] & 0x3FFF, 1); } mempool_free(asset2F); diff --git a/src/particles.h b/src/particles.h index 2217f852..763b3dd1 100644 --- a/src/particles.h +++ b/src/particles.h @@ -281,7 +281,7 @@ typedef struct PointParticle { void reset_particles(void); void reset_particles_with_assets(void); -void free_unknown_particle_sprites(void); +void particle_free_dummy(void); void free_particle_buffers(void); void free_particle_vertices_triangles(void); void free_particle_assets(void); diff --git a/src/racer.c b/src/racer.c index a5a59e8e..031fd22a 100644 --- a/src/racer.c +++ b/src/racer.c @@ -610,10 +610,10 @@ void racer_AI_pathing_inputs(Object *obj, Object_Racer *racer, s32 updateRate) { switch (raceType) { case RACETYPE_CHALLENGE_BATTLE: case RACETYPE_CHALLENGE_BANANAS: - func_8004447C(obj, racer, updateRate); + racer_ai_challenge(obj, racer, updateRate); break; case RACETYPE_CHALLENGE_EGGS: - func_800452A0(obj, racer, updateRate); + racer_ai_eggs(obj, racer, updateRate); break; default: func_80045C48(obj, racer, updateRate); @@ -675,7 +675,7 @@ s32 roll_percent_chance(s32 chance) { } // Handles the opponent A.I. for battle & banana challenges. -void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) { +void racer_ai_challenge(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) { Object *sp74; Object_64 *tempRacer; LevelObjectEntry *sp6C; @@ -1016,7 +1016,11 @@ void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate) { } } -void func_80045128(Object **racerObjs) { +/** + * Manage the global flags for the egg challenge. + * Includes hatch progress, being held by a player, and number of hatched eggs. + */ +void racer_update_eggs(Object **racerObjs) { Object_Racer *racer; s32 i; @@ -1024,15 +1028,24 @@ void func_80045128(Object **racerObjs) { racer = &racerObjs[i]->unk64->racer; gEggChallengeFlags[i] = racer->lap; if (racer->eggHudCounter != 0) { - gEggChallengeFlags[i] |= 0x40; + gEggChallengeFlags[i] |= RACER_EGG_HATCHING; } if (racer->held_obj != NULL) { - gEggChallengeFlags[i] |= 0x80; + gEggChallengeFlags[i] |= RACER_EGG_HELD; } } } -void func_800452A0(Object *obj, Object_Racer *racer, s32 updateRate) { +/** + * A custom AI handler for the egg challenge. + * As a result of the open area design of Fire Mountain, the AI does not use pathing nodes. + * Instead, they use a simple positional targeting system that takes their current priority, + * then moves towards it until that objective is complete. + * They will first search for any eggs in the centre of the arena, then failing that, find one + * from another players nest to steal. + * If they're holding an egg, they'll attempt to take it to their nest. + */ +void racer_ai_eggs(Object *obj, Object_Racer *racer, s32 updateRate) { f32 diffX; f32 diffY; f32 diffZ; @@ -1087,10 +1100,10 @@ void func_800452A0(Object *obj, Object_Racer *racer, s32 updateRate) { flags = 0; bestTick = 0; for (i = 3; i >= 0; i--) { - tickCount = (gEggChallengeFlags[i] & 0xF) * 3; - if (gEggChallengeFlags[i] & 0x40) { + tickCount = (gEggChallengeFlags[i] & RACER_EGG_MASK) * 3; + if (gEggChallengeFlags[i] & RACER_EGG_HATCHING) { tickCount += 2; - } else if (gEggChallengeFlags[i] & 0x80) { + } else if (gEggChallengeFlags[i] & RACER_EGG_HELD) { tickCount += 1; } if (bestTick < tickCount) { @@ -1114,7 +1127,7 @@ void func_800452A0(Object *obj, Object_Racer *racer, s32 updateRate) { } if (bestTick == 2) { for (i = 0; i < 4; i++) { - if (racer->racerIndex != i && gEggChallengeFlags[i] & 0x40) { + if (racer->racerIndex != i && gEggChallengeFlags[i] & RACER_EGG_HATCHING) { racerID = i; } } @@ -1574,7 +1587,7 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r s32 iTemp; // Seems to be reused for some reason s32 var_a3; s32 var_v1; - Unknown80046524 *temp_v0_16; + Object *vehiclePart; s32 var_t0; Object_Boost *asset20; s8 lastWheelSurface; @@ -2250,11 +2263,11 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r if (waterHeight > 40.0f) { racer->unkC4 = 0.11f; } - if (obj->unk60->unk0 == 1) { - temp_v0_16 = (Unknown80046524 *) obj->unk60->unk4[0]; - temp_v0_16->unk0 = (gCurrentStickX * 20) + 0x4000; - temp_v0_16->unk3A++; - temp_v0_16->unk3A &= 1; + if (obj->attachPoints->count == 1) { + vehiclePart = obj->attachPoints->obj[0]; + vehiclePart->segment.trans.rotation.y_rotation = (gCurrentStickX * 20) + 0x4000; + vehiclePart->segment.object.modelIndex++; + vehiclePart->segment.object.modelIndex &= 1; } second_racer_camera_update(obj, racer, CAMERA_HOVERCRAFT, updateRateF); if (playerObjectHasMoved) { @@ -3295,24 +3308,24 @@ void func_80049794(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r mtxf_from_inverse_transform((MtxF *) &sp60, &gCurrentRacerTransform); mtxf_transform_point((MtxF *) &sp60, obj->segment.x_velocity, obj->segment.y_velocity, obj->segment.z_velocity, &racer->lateral_velocity, &racer->unk34, &racer->velocity); - if (obj->unk60 != NULL && obj->unk60->unk0 >= 3) { - temp_v0_obj = obj->unk60->unk4[2]; + if (obj->attachPoints != NULL && obj->attachPoints->count >= 3) { + temp_v0_obj = obj->attachPoints->obj[2]; temp_v0_obj->segment.trans.rotation.y_rotation = 0x4000; temp_v0_obj->segment.object.modelIndex += 1; if (temp_v0_obj->segment.object.modelIndex == temp_v0_obj->segment.header->numberOfModelIds) { temp_v0_obj->segment.object.modelIndex = 0; } } - if (obj->unk60 != NULL && obj->unk60->unk0 >= 3) { + if (obj->attachPoints != NULL && obj->attachPoints->count >= 3) { if (racer->groundedWheels != 0 || spA2 != FALSE) { - temp_v0_obj = obj->unk60->unk4[0]; + temp_v0_obj = obj->attachPoints->obj[0]; if (temp_v0_obj->segment.trans.y_position > 0.0f) { temp_v0_obj->segment.trans.y_position = temp_v0_obj->segment.trans.y_position - 2.0; } else { temp_v0_obj->segment.trans.y_position = 0.0f; } temp_v0_obj->segment.trans.flags &= ~OBJ_FLAGS_INVISIBLE; - temp_v0_obj = obj->unk60->unk4[1]; + temp_v0_obj = obj->attachPoints->obj[1]; if (temp_v0_obj->segment.trans.y_position > 0.0f) { temp_v0_obj->segment.trans.y_position = temp_v0_obj->segment.trans.y_position - 2.0; } else { @@ -3320,13 +3333,13 @@ void func_80049794(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } temp_v0_obj->segment.trans.flags &= ~OBJ_FLAGS_INVISIBLE; } else { - temp_v0_obj = obj->unk60->unk4[0]; + temp_v0_obj = obj->attachPoints->obj[0]; if (temp_v0_obj->segment.trans.y_position < 20.0f) { temp_v0_obj->segment.trans.y_position = temp_v0_obj->segment.trans.y_position + 1.0f; } else { temp_v0_obj->segment.trans.flags |= OBJ_FLAGS_INVISIBLE; } - temp_v0_obj = obj->unk60->unk4[1]; + temp_v0_obj = obj->attachPoints->obj[1]; if (temp_v0_obj->segment.trans.y_position < 20.0f) { temp_v0_obj->segment.trans.y_position = temp_v0_obj->segment.trans.y_position + 1.0f; } else { @@ -3892,10 +3905,10 @@ void func_8004CC20(s32 updateRate, f32 updateRateF, Object *racerObj, Object_Rac mtxf_transform_point(&mtx, racerObj->segment.x_velocity, racerObj->segment.y_velocity, racerObj->segment.z_velocity, &racer->lateral_velocity, &racer->unk34, &racer->velocity); second_racer_camera_update(racerObj, racer, CAMERA_LOOP, updateRateF); - if (racerObj->unk60 != NULL && racer->vehicleIDPrev == VEHICLE_CAR && racerObj->unk60->unk0 >= 4) { - obj = racerObj->unk60->unk4[2]; + if (racerObj->attachPoints != NULL && racer->vehicleIDPrev == VEHICLE_CAR && racerObj->attachPoints->count >= 4) { + obj = racerObj->attachPoints->obj[2]; obj->segment.trans.rotation.y_rotation = 0; - obj = racerObj->unk60->unk4[3]; + obj = racerObj->attachPoints->obj[3]; obj->segment.trans.rotation.y_rotation = 0; } if (objectMoved) { @@ -4063,7 +4076,7 @@ void obj_init_racer(Object *obj, LevelObjectEntry_Racer *racer) { obj->interactObj->y_position = obj->segment.trans.y_position; obj->interactObj->z_position = obj->segment.trans.z_position; tempRacer->groundedWheels = 3; - tempRacer->unk1AA = 1; + tempRacer->racerOrder = 1; tempRacer->racePosition = 1; tempRacer->miscAnimCounter = tempRacer->playerIndex * 5; tempRacer->checkpoint_distance = 1.0f; @@ -5099,7 +5112,7 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR f32 traction; f32 surfaceTraction; f32 *miscAsset; - ObjectTransform *temp_v0; + ObjectTransform *attachmentTrans; f32 topSpeed; UNUSED s32 pad1; UNUSED s32 pad2; @@ -5118,13 +5131,13 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR racer->carBobX = -racer->roll * tempVel; racer->carBobY = -racer->yaw * tempVel; racer->carBobZ = -racer->pitch * tempVel; - if (obj->unk60 != NULL) { - for (i = 0; i < ((unk_Object_60 *) obj->unk60)->count; i++) { + if (obj->attachPoints != NULL) { + for (i = 0; i < obj->attachPoints->count; i++) { tempVel = 1.0f / obj->segment.trans.scale; - temp_v0 = ((unk_Object_60 *) obj->unk60)->transforms[i]; - temp_v0->x_position = (f32) (-racer->carBobX * tempVel); - temp_v0->y_position = (f32) (-racer->carBobY * tempVel); - temp_v0->z_position = (f32) (-racer->carBobZ * tempVel); + attachmentTrans = &obj->attachPoints->obj[i]->segment.trans; + attachmentTrans->x_position = (f32) (-racer->carBobX * tempVel); + attachmentTrans->y_position = (f32) (-racer->carBobY * tempVel); + attachmentTrans->z_position = (f32) (-racer->carBobZ * tempVel); } } } else { @@ -6111,14 +6124,14 @@ void func_80053750(Object *objRacer, Object_Racer *racer, f32 updateRateF) { s32 isNotHardBraking; s32 i; - if (objRacer->unk60 == NULL) { + if (objRacer->attachPoints == NULL) { return; } - temp_v1 = objRacer->unk60->unk0; + temp_v1 = objRacer->attachPoints->count; if (temp_v1 == 2) { - someObj = objRacer->unk60->unk4[0]; + someObj = objRacer->attachPoints->obj[0]; someObj->segment.trans.rotation.y_rotation = 0x4000; - someObj = objRacer->unk60->unk4[1]; + someObj = objRacer->attachPoints->obj[1]; someObj->segment.trans.rotation.y_rotation = 0x4000; } if (temp_v1 >= 4) { @@ -6141,7 +6154,7 @@ void func_80053750(Object *objRacer, Object_Racer *racer, f32 updateRateF) { racer->unkB0 -= 5.0; for (i = 0; i < 4; i++) { if (i < 2 || isNotHardBraking) { - someObj = objRacer->unk60->unk4[i]; + someObj = objRacer->attachPoints->obj[i]; if ((racer->unk1FB != 0 && i >= 3) || racer->unk1FB == 0) { if (someObj->properties.common.unk0 != 0) { someObj->segment.object.modelIndex--; @@ -6162,7 +6175,7 @@ void func_80053750(Object *objRacer, Object_Racer *racer, f32 updateRateF) { racer->unkB0 += 5.0; for (i = 0; i < 4; i++) { if (i < 2 || isNotHardBraking) { - someObj = objRacer->unk60->unk4[i]; + someObj = objRacer->attachPoints->obj[i]; if ((racer->unk1FB != 0 && i >= 3) || racer->unk1FB == 0) { if (someObj->properties.common.unk0 == 0) { someObj->segment.object.modelIndex--; @@ -6182,7 +6195,7 @@ void func_80053750(Object *objRacer, Object_Racer *racer, f32 updateRateF) { flags = 1; if (racer->unk1FB != 0) { for (i = 0; i < 2; i++) { - someObj = objRacer->unk60->unk4[i]; + someObj = objRacer->attachPoints->obj[i]; if (someObj->properties.racer.unk0 != 0) { someObj->segment.object.modelIndex--; if (someObj->segment.object.modelIndex < 0) { @@ -6199,7 +6212,7 @@ void func_80053750(Object *objRacer, Object_Racer *racer, f32 updateRateF) { } temp_f0 = someObj->segment.trans.y_position; // Fake for (i = 0; i < 4; i++) { - someObj = objRacer->unk60->unk4[i]; + someObj = objRacer->attachPoints->obj[i]; if (!(racer->unk1E3 & flags)) { someObj->segment.trans.y_position += ((-10.0f - someObj->segment.trans.y_position) * 0.125); if (racer->waterTimer != 0) { @@ -6213,9 +6226,9 @@ void func_80053750(Object *objRacer, Object_Racer *racer, f32 updateRateF) { } flags <<= 1; } - someObj = objRacer->unk60->unk4[2]; + someObj = objRacer->attachPoints->obj[2]; someObj->segment.trans.rotation.y_rotation = gCurrentStickX * 100; - someObj = objRacer->unk60->unk4[3]; + someObj = objRacer->attachPoints->obj[3]; someObj->segment.trans.rotation.y_rotation = gCurrentStickX * 100; } } diff --git a/src/racer.h b/src/racer.h index 17c53586..2e8c6bc0 100644 --- a/src/racer.h +++ b/src/racer.h @@ -126,6 +126,13 @@ typedef enum TajInteraction { TAJ_TELEPORT, } TajInteraction; +typedef enum RacerEggFlags { + RACER_EGG_NONE, + RACER_EGG_MASK = 0xF, // Bitmask used for the egg HUD fade counting. + RACER_EGG_HATCHING = (1 << 6), // Egg has hatch progress + RACER_EGG_HELD = (1 << 7) // Egg is held by a racer. +} RacerEggFlags; + #define AI_MIN 0 #define AI_MAX 1 #define AI_MIN_STEP 2 @@ -137,17 +144,6 @@ typedef struct AIBehaviourTable { s8 percentages[4][4]; } AIBehaviourTable; -typedef struct Unknown80046524 { - s16 unk0; - u8 pad2[0x38]; - s8 unk3A; -} Unknown80046524; - -typedef struct unk_Object_60 { - s32 count; - ObjectTransform *transforms[1]; -} unk_Object_60; - s32 roll_percent_chance(s32 chance); void apply_plane_tilt_anim(s32 updateRate, Object *obj, Object_Racer *racer); void racer_attack_handler_plane(Object *obj, Object_Racer *racer); @@ -214,7 +210,7 @@ void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate); void handle_racer_items(Object *obj, Object_Racer *racer, s32 updateRate); void drop_bananas(Object *obj, Object_Racer *racer, s32 number); void update_player_racer(Object *obj, s32 updateRate); -void func_80045128(Object **racerObjs); +void racer_update_eggs(Object **racerObjs); void timetrial_ghost_write(Object *obj, s32 updateRate); void func_80046524(s32 updateRate, f32 updateRateF, Object* obj, Object_Racer* racer); void func_80053750(Object *objRacer, Object_Racer *racer, f32 updateRateF); @@ -228,8 +224,8 @@ s32 func_80017248(Object *obj, s32, s32 *, Vec3f *, f32 *, f32 *, s8 *surface); void func_80059208(Object* obj, Object_Racer* racer, s32 updateRate); /* extern */ void func_80049794(s32 updateRate, f32 updateRateF, Object* obj, Object_Racer* racer); /* extern */ void func_8004CC20(s32 updateRate, f32 updateRateF, Object *racerObj, Object_Racer *racer); /* extern */ -void func_8004447C(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate); -void func_800452A0(Object *obj, Object_Racer *racer, s32 updateRate); +void racer_ai_challenge(Object *aiRacerObj, Object_Racer *aiRacer, s32 updateRate); +void racer_ai_eggs(Object *obj, Object_Racer *racer, s32 updateRate); void func_80045C48(Object *obj, Object_Racer *racer, s32 updateRate); void racer_activate_magnet(Object *obj, Object_Racer *racer, s32 updateRate); Object *func_8005698C(Object *racerObj, Object_Racer *racer, f32 *outDistance); diff --git a/tools/python/calc_func_checksums.py b/tools/python/calc_func_checksums.py index dd4ce16f..e529617e 100644 --- a/tools/python/calc_func_checksums.py +++ b/tools/python/calc_func_checksums.py @@ -12,8 +12,8 @@ ROM_FILEPATH = f'build/dkr.{REGION}.{VERSION}.z64' FUNCTIONS_TO_CALC = [ # function checksum variable func size variable - ('func_80019808', 'gFunc80019808Checksum', 'gFunc80019808Length'), - ('render_scene', 'gTractionTableChecksum', 'gTrackRenderFuncLength'), + ('race_check_finish', 'gRaceCheckFinishChecksum', 'gRaceCheckFinishFuncLength'), + ('render_scene', 'gRenderSceneChecksum', 'gRenderSceneFuncLength'), ('obj_loop_goldenballoon', 'gObjLoopGoldenBalloonChecksum', 'gObjLoopGoldenBalloonLength'), ('viewport_rsp_set', 'gViewportFuncChecksum', 'gViewportFuncLength') ] diff --git a/ver/symbols/symbol_addrs.jpn.v79.txt b/ver/symbols/symbol_addrs.jpn.v79.txt index 93727980..6f52bc92 100644 --- a/ver/symbols/symbol_addrs.jpn.v79.txt +++ b/ver/symbols/symbol_addrs.jpn.v79.txt @@ -221,13 +221,13 @@ spawn_object = 0x8000EA54; objFreeAssets = 0x8000F648; light_setup_light_sources = 0x8000F758; init_object_shading = 0x8000F7EC; -func_8000F99C = 0x8000F99C; +obj_init_attachpoint = 0x8000F99C; obj_init_emitter = 0x8000FAC4; init_object_shadow = 0x8000FBCC; init_object_water_effect = 0x8000FC6C; init_object_interaction_data = 0x8000FD20; func_8000FD34 = 0x8000FD34; -func_8000FD54 = 0x8000FD54; +obj_spawn_attachment = 0x8000FD54; free_object = 0x8000FFB8; obj_table_ids = 0x80010018; obj_id_valid = 0x80010028; @@ -290,7 +290,7 @@ func_800185E4 = 0x800185E4; find_taj_object = 0x80018C6C; func_80018CE0 = 0x80018CE0; func_8001955C = 0x8001955C; -func_80019808 = 0x80019808; +race_check_finish = 0x80019808; set_course_finish_flags = 0x8001A7D8; race_finish_adventure = 0x8001A8D4; race_transition_adventure = 0x8001A8F4; @@ -674,9 +674,9 @@ func_80042D20 = 0x80042D20; increment_ai_behaviour_chances = 0x80043ECC; racer_AI_pathing_inputs = 0x80044170; roll_percent_chance = 0x80044450; -func_8004447C = 0x8004447C; -func_80045128 = 0x80045128; -func_800452A0 = 0x800452A0; +racer_ai_challenge = 0x8004447C; +racer_update_eggs = 0x80045128; +racer_ai_eggs = 0x800452A0; func_80045C48 = 0x80045C48; func_80046524 = 0x80046524; racer_attack_handler_hovercraft = 0x80048C7C; @@ -784,16 +784,16 @@ update_rocket = 0x8005F340; // object_models.c .text allocate_object_model_pools = 0x8005F880; object_model_init = 0x8005F9CC; -model_init_type = 0x8005FDA0; +model_instance_init = 0x8005FDA0; free_3d_model = 0x80060010; free_model_data = 0x80060128; func_8006017C = 0x8006024C; func_80060910 = 0x800609E0; func_80060AC8 = 0x80060B98; func_80060C58 = 0x80060D28; -func_80060EA8 = 0x80060F78; -func_800619F4 = 0x80061AC4; -func_80061A00 = 0x80061AD0; +model_calc_normals = 0x80060F78; +model_anim_offset = 0x80061AC4; +model_anim_init = 0x80061AD0; func_80061C0C = 0x80061CDC; // obj_animate.c .text @@ -1435,7 +1435,7 @@ menu_racer_portraits = 0x80094D00; postrace_start = 0x80094D84; postrace_load = 0x80095158; postrace_music_fade = 0x80095310; -func_80094D28 = 0x80095424; +postrace_viewport = 0x80095424; postrace_message = 0x80095D20; menu_postrace = 0x80095E24; postrace_free = 0x80096E8C; @@ -1624,7 +1624,7 @@ rain_render = 0x800AE2BC; // particles.c .text reset_particles = 0x800AE870; reset_particles_with_assets = 0x800AE8A0; -free_unknown_particle_sprites = 0x800AE8D8; +particle_free_dummy = 0x800AE8D8; free_particle_buffers = 0x800AE974; free_particle_vertices_triangles = 0x800AEA38; free_particle_assets = 0x800AEA90; @@ -2182,8 +2182,8 @@ audFrameCt = 0x800DE010; nextDMA = 0x800DE014; curAcmdList = 0x800DE018; gAntiPiracyAudioFreq = 0x800DE01C; -gFunc80019808Checksum = 0x800DE020; -gFunc80019808Length = 0x800DE024; +gRaceCheckFinishChecksum = 0x800DE020; +gRaceCheckFinishFuncLength = 0x800DE024; // audiosfx.c .data gSoundStateLists = 0x800DE040; // size:0xC @@ -2318,8 +2318,8 @@ gWizpigVoiceTable = 0x800DE800; gRocketVoiceTable = 0x800DE820; // object_models.c .data -gTractionTableChecksum = 0x800DE840; -gTrackRenderFuncLength = 0x800DE844; +gRenderSceneChecksum = 0x800DE840; +gRenderSceneFuncLength = 0x800DE844; // al/reverb.c .data alFXEnabled = 0x800DE850; @@ -2855,8 +2855,8 @@ gMaxRectangleParticles = 0x800E4940; gMaxSpriteParticles = 0x800E4944; gMaxLineParticles = 0x800E4948; gMaxPointParticles = 0x800E494C; -D_800E2E60 = 0x800E4950; -D_800E2E64 = 0x800E4954; +gParticleDummys = 0x800E4950; +gParticleDummyCount = 0x800E4954; gParticleCoordListTri = 0x800E4958; gParticleCoordListQuad = 0x800E4964; D_800E2E84 = 0x800E4974; @@ -3617,10 +3617,10 @@ D_8011ADA4 = 0x8011C814; gObjectUpdateRateF = 0x8011C818; gPathUpdateOff = 0x8011C81C; gEventCountdown = 0x8011C820; -D_8011ADB4 = 0x8011C824; +gRaceFinishTriggered = 0x8011C824; gEventStartTimer = 0x8011C828; D_8011ADBC = 0x8011C82C; -D_8011ADC0 = 0x8011C830; +gNumFinishedRacers = 0x8011C830; gFirstTimeFinish = 0x8011C834; D_8011ADC5 = 0x8011C835; gBalloonCutsceneTimer = 0x8011C838; @@ -3923,7 +3923,7 @@ gNumModelIDs = 0x8011F0A0; D_8011D634 = 0x8011F0A4; gAnimationTable = 0x8011F0A8; gObjectAnimationTable = 0x8011F0AC; -D_8011D640 = 0x8011F0B0; +gModelAnimOffsetID = 0x8011F0B0; D_8011D644 = 0x8011F0B4; // main .bss diff --git a/ver/symbols/symbol_addrs.pal.v77.txt b/ver/symbols/symbol_addrs.pal.v77.txt index 3995e73e..14e4feef 100644 --- a/ver/symbols/symbol_addrs.pal.v77.txt +++ b/ver/symbols/symbol_addrs.pal.v77.txt @@ -221,13 +221,13 @@ spawn_object = 0x8000EA54; objFreeAssets = 0x8000F648; light_setup_light_sources = 0x8000F758; init_object_shading = 0x8000F7EC; -func_8000F99C = 0x8000F99C; +obj_init_attachpoint = 0x8000F99C; obj_init_emitter = 0x8000FAC4; init_object_shadow = 0x8000FBCC; init_object_water_effect = 0x8000FC6C; init_object_interaction_data = 0x8000FD20; func_8000FD34 = 0x8000FD34; -func_8000FD54 = 0x8000FD54; +obj_spawn_attachment = 0x8000FD54; free_object = 0x8000FFB8; obj_table_ids = 0x80010018; obj_id_valid = 0x80010028; @@ -290,7 +290,7 @@ func_800185E4 = 0x800185E4; find_taj_object = 0x80018C6C; func_80018CE0 = 0x80018CE0; func_8001955C = 0x8001955C; -func_80019808 = 0x80019808; +race_check_finish = 0x80019808; set_course_finish_flags = 0x8001A7D8; race_finish_adventure = 0x8001A8D4; race_transition_adventure = 0x8001A8F4; @@ -674,9 +674,9 @@ func_80042D20 = 0x80042D20; increment_ai_behaviour_chances = 0x80043ECC; racer_AI_pathing_inputs = 0x80044170; roll_percent_chance = 0x80044450; -func_8004447C = 0x8004447C; -func_80045128 = 0x80045128; -func_800452A0 = 0x800452A0; +racer_ai_challenge = 0x8004447C; +racer_update_eggs = 0x80045128; +racer_ai_eggs = 0x800452A0; func_80045C48 = 0x80045C48; func_80046524 = 0x80046524; racer_attack_handler_hovercraft = 0x80048C7C; @@ -782,16 +782,16 @@ update_rocket = 0x8005F310; // object_models.c .text allocate_object_model_pools = 0x8005F850; object_model_init = 0x8005F99C; -model_init_type = 0x8005FCD0; +model_instance_init = 0x8005FCD0; free_3d_model = 0x8005FF40; free_model_data = 0x80060058; func_8006017C = 0x8006017C; func_80060910 = 0x80060910; func_80060AC8 = 0x80060AC8; func_80060C58 = 0x80060C58; -func_80060EA8 = 0x80060EA8; -func_800619F4 = 0x800619F4; -func_80061A00 = 0x80061A00; +model_calc_normals = 0x80060EA8; +model_anim_offset = 0x800619F4; +model_anim_init = 0x80061A00; func_80061C0C = 0x80061C0C; // obj_animate.c .text @@ -1430,7 +1430,7 @@ menu_racer_portraits = 0x80094698; postrace_start = 0x8009471C; postrace_load = 0x80094AF0; postrace_music_fade = 0x80094CA8; -func_80094D28 = 0x80094DBC; +postrace_viewport = 0x80094DBC; postrace_message = 0x800956B8; menu_postrace = 0x800957BC; postrace_free = 0x80096824; @@ -1613,7 +1613,7 @@ rain_sound = 0x800ADC58; rain_render = 0x800ADD4C; reset_particles = 0x800AE300; reset_particles_with_assets = 0x800AE330; -free_unknown_particle_sprites = 0x800AE368; +particle_free_dummy = 0x800AE368; free_particle_buffers = 0x800AE404; free_particle_vertices_triangles = 0x800AE4C8; free_particle_assets = 0x800AE520; @@ -2090,8 +2090,8 @@ audFrameCt = 0x800DC710; nextDMA = 0x800DC714; curAcmdList = 0x800DC718; gAntiPiracyAudioFreq = 0x800DC71C; -gFunc80019808Checksum = 0x800DC720; -gFunc80019808Length = 0x800DC724; +gRaceCheckFinishChecksum = 0x800DC720; +gRaceCheckFinishFuncLength = 0x800DC724; gSoundStateLists = 0x800DC740; // size:0xC gSoundPlayerPtr = 0x800DC74C; gSoundGlobalVolume = 0x800DC750; @@ -2196,8 +2196,8 @@ gSmokeyVoiceTable = 0x800DCEB0; gBubblerVoiceTable = 0x800DCED0; gWizpigVoiceTable = 0x800DCEF0; gRocketVoiceTable = 0x800DCF10; -gTractionTableChecksum = 0x800DCF30; -gTrackRenderFuncLength = 0x800DCF34; +gRenderSceneChecksum = 0x800DCF30; +gRenderSceneFuncLength = 0x800DCF34; alFXEnabled = 0x800DCF40; gStereoPanMode = 0x800DD0E0; gAntiPiracyViewport = 0x800DD0F0; @@ -2686,8 +2686,8 @@ gMaxRectangleParticles = 0x800E2EE0; gMaxSpriteParticles = 0x800E2EE4; gMaxLineParticles = 0x800E2EE8; gMaxPointParticles = 0x800E2EEC; -D_800E2E60 = 0x800E2EF0; -D_800E2E64 = 0x800E2EF4; +gParticleDummys = 0x800E2EF0; +gParticleDummyCount = 0x800E2EF4; gParticleCoordListTri = 0x800E2EF8; gParticleCoordListQuad = 0x800E2F04; D_800E2E84 = 0x800E2F14; @@ -3355,10 +3355,10 @@ D_8011ADA4 = 0x8011AE34; gObjectUpdateRateF = 0x8011AE38; gPathUpdateOff = 0x8011AE3C; gEventCountdown = 0x8011AE40; -D_8011ADB4 = 0x8011AE44; +gRaceFinishTriggered = 0x8011AE44; gEventStartTimer = 0x8011AE48; D_8011ADBC = 0x8011AE4C; -D_8011ADC0 = 0x8011AE50; +gNumFinishedRacers = 0x8011AE50; gFirstTimeFinish = 0x8011AE54; D_8011ADC5 = 0x8011AE55; gBalloonCutsceneTimer = 0x8011AE58; @@ -3639,7 +3639,7 @@ gNumModelIDs = 0x8011D6C0; D_8011D634 = 0x8011D6C4; gAnimationTable = 0x8011D6C8; gObjectAnimationTable = 0x8011D6CC; -D_8011D640 = 0x8011D6D0; +gModelAnimOffsetID = 0x8011D6D0; D_8011D644 = 0x8011D6D4; gThread1Stack = 0x8011D6E0; gThread3Stack = 0x8011D7E8; diff --git a/ver/symbols/symbol_addrs.pal.v80.txt b/ver/symbols/symbol_addrs.pal.v80.txt index 69e2948f..8f13b656 100644 --- a/ver/symbols/symbol_addrs.pal.v80.txt +++ b/ver/symbols/symbol_addrs.pal.v80.txt @@ -221,13 +221,13 @@ spawn_object = 0x8000EA54; objFreeAssets = 0x8000F648; light_setup_light_sources = 0x8000F758; init_object_shading = 0x8000F7EC; -func_8000F99C = 0x8000F99C; +obj_init_attachpoint = 0x8000F99C; obj_init_emitter = 0x8000FAC4; init_object_shadow = 0x8000FBCC; init_object_water_effect = 0x8000FC6C; init_object_interaction_data = 0x8000FD20; func_8000FD34 = 0x8000FD34; -func_8000FD54 = 0x8000FD54; +obj_spawn_attachment = 0x8000FD54; free_object = 0x8000FFB8; obj_table_ids = 0x80010018; obj_id_valid = 0x80010028; @@ -290,7 +290,7 @@ func_800185E4 = 0x80018618; find_taj_object = 0x80018CA0; func_80018CE0 = 0x80018D14; func_8001955C = 0x80019590; -func_80019808 = 0x8001983C; +race_check_finish = 0x8001983C; set_course_finish_flags = 0x8001A80C; race_finish_adventure = 0x8001A908; race_transition_adventure = 0x8001A928; @@ -662,9 +662,9 @@ func_80042D20 = 0x80042D60; increment_ai_behaviour_chances = 0x80043F0C; racer_AI_pathing_inputs = 0x800441B0; roll_percent_chance = 0x80044490; -func_8004447C = 0x800444BC; -func_80045128 = 0x80045168; -func_800452A0 = 0x800452E0; +racer_ai_challenge = 0x800444BC; +racer_update_eggs = 0x80045168; +racer_ai_eggs = 0x800452E0; func_80045C48 = 0x80045C88; func_80046524 = 0x80046564; racer_attack_handler_hovercraft = 0x80048CBC; @@ -756,16 +756,16 @@ update_wizpig = 0x8005EC30; update_rocket = 0x8005F4B0; allocate_object_model_pools = 0x8005F9F0; object_model_init = 0x8005FB3C; // has a diff from v1 -model_init_type = 0x8005FF10; +model_instance_init = 0x8005FF10; free_3d_model = 0x80060180; free_model_data = 0x80060298; func_8006017C = 0x800603BC; func_80060910 = 0x80060B50; func_80060AC8 = 0x80060D08; func_80060C58 = 0x80060E98; -func_80060EA8 = 0x800610E8; -func_800619F4 = 0x80061C34; -func_80061A00 = 0x80061C40; +model_calc_normals = 0x800610E8; +model_anim_offset = 0x80061C34; +model_anim_init = 0x80061C40; func_80061C0C = 0x80061E4C; obj_animate = 0x80061F70; alCSPNew = 0x800624D0; @@ -1349,7 +1349,7 @@ menu_racer_portraits = 0x80094B9C; postrace_start = 0x80094C20; postrace_load = 0x80094FF4; postrace_music_fade = 0x800951AC; -func_80094D28 = 0x800952C0; +postrace_viewport = 0x800952C0; postrace_message = 0x80095BBC; menu_postrace = 0x80095CC0; postrace_free = 0x80096D28; @@ -1534,7 +1534,7 @@ rain_sound = 0x800AE1B8; rain_render = 0x800AE2AC; reset_particles = 0x800AE860; reset_particles_with_assets = 0x800AE890; -free_unknown_particle_sprites = 0x800AE8C8; +particle_free_dummy = 0x800AE8C8; free_particle_buffers = 0x800AE964; free_particle_vertices_triangles = 0x800AEA28; free_particle_assets = 0x800AEA80; @@ -2017,8 +2017,8 @@ audFrameCt = 0x800DCC80; nextDMA = 0x800DCC84; curAcmdList = 0x800DCC88; gAntiPiracyAudioFreq = 0x800DCC8C; -gFunc80019808Checksum = 0x800DCC90; -gFunc80019808Length = 0x800DCC94; +gRaceCheckFinishChecksum = 0x800DCC90; +gRaceCheckFinishFuncLength = 0x800DCC94; gSoundStateLists = 0x800DCCB0; // size:0xC gSoundPlayerPtr = 0x800DCCBC; gSoundGlobalVolume = 0x800DCCC0; @@ -2123,8 +2123,8 @@ gSmokeyVoiceTable = 0x800DD420; gBubblerVoiceTable = 0x800DD440; gWizpigVoiceTable = 0x800DD460; gRocketVoiceTable = 0x800DD480; -gTractionTableChecksum = 0x800DD4A0; -gTrackRenderFuncLength = 0x800DD4A4; +gRenderSceneChecksum = 0x800DD4A0; +gRenderSceneFuncLength = 0x800DD4A4; alFXEnabled = 0x800DD4B0; gStereoPanMode = 0x800DD650; gAntiPiracyViewport = 0x800DD660; @@ -2615,8 +2615,8 @@ gMaxRectangleParticles = 0x800E3470; gMaxSpriteParticles = 0x800E3474; gMaxLineParticles = 0x800E3478; gMaxPointParticles = 0x800E347C; -D_800E2E60 = 0x800E3480; -D_800E2E64 = 0x800E3484; +gParticleDummys = 0x800E3480; +gParticleDummyCount = 0x800E3484; gParticleCoordListTri = 0x800E3488; gParticleCoordListQuad = 0x800E3494; D_800E2E84 = 0x800E34A4; @@ -3285,10 +3285,10 @@ D_8011ADA4 = 0x8011B3B4; gObjectUpdateRateF = 0x8011B3B8; gPathUpdateOff = 0x8011B3BC; gEventCountdown = 0x8011B3C0; -D_8011ADB4 = 0x8011B3C4; +gRaceFinishTriggered = 0x8011B3C4; gEventStartTimer = 0x8011B3C8; D_8011ADBC = 0x8011B3CC; -D_8011ADC0 = 0x8011B3D0; +gNumFinishedRacers = 0x8011B3D0; gFirstTimeFinish = 0x8011B3D4; D_8011ADC5 = 0x8011B3D5; gBalloonCutsceneTimer = 0x8011B3D8; @@ -3569,7 +3569,7 @@ gNumModelIDs = 0x8011DC40; D_8011D634 = 0x8011DC44; gAnimationTable = 0x8011DC48; gObjectAnimationTable = 0x8011DC4C; -D_8011D640 = 0x8011DC50; +gModelAnimOffsetID = 0x8011DC50; D_8011D644 = 0x8011DC54; gThread1Stack = 0x8011DC60; gThread3Stack = 0x8011DD68; diff --git a/ver/symbols/symbol_addrs.us.v77.txt b/ver/symbols/symbol_addrs.us.v77.txt index a6ad5fe6..c8cfdcfd 100644 --- a/ver/symbols/symbol_addrs.us.v77.txt +++ b/ver/symbols/symbol_addrs.us.v77.txt @@ -221,13 +221,13 @@ spawn_object = 0x8000EA54; objFreeAssets = 0x8000F648; light_setup_light_sources = 0x8000F758; init_object_shading = 0x8000F7EC; -func_8000F99C = 0x8000F99C; +obj_init_attachpoint = 0x8000F99C; obj_init_emitter = 0x8000FAC4; init_object_shadow = 0x8000FBCC; init_object_water_effect = 0x8000FC6C; init_object_interaction_data = 0x8000FD20; func_8000FD34 = 0x8000FD34; -func_8000FD54 = 0x8000FD54; +obj_spawn_attachment = 0x8000FD54; free_object = 0x8000FFB8; obj_table_ids = 0x80010018; obj_id_valid = 0x80010028; @@ -290,7 +290,7 @@ func_800185E4 = 0x800185E4; find_taj_object = 0x80018C6C; func_80018CE0 = 0x80018CE0; func_8001955C = 0x8001955C; -func_80019808 = 0x80019808; +race_check_finish = 0x80019808; set_course_finish_flags = 0x8001A7D8; race_finish_adventure = 0x8001A8D4; race_transition_adventure = 0x8001A8F4; @@ -674,9 +674,9 @@ func_80042D20 = 0x80042D20; increment_ai_behaviour_chances = 0x80043ECC; racer_AI_pathing_inputs = 0x80044170; roll_percent_chance = 0x80044450; -func_8004447C = 0x8004447C; -func_80045128 = 0x80045128; -func_800452A0 = 0x800452A0; +racer_ai_challenge = 0x8004447C; +racer_update_eggs = 0x80045128; +racer_ai_eggs = 0x800452A0; func_80045C48 = 0x80045C48; func_80046524 = 0x80046524; racer_attack_handler_hovercraft = 0x80048C7C; @@ -782,16 +782,16 @@ update_rocket = 0x8005F310; // object_models.c .text allocate_object_model_pools = 0x8005F850; object_model_init = 0x8005F99C; -model_init_type = 0x8005FCD0; +model_instance_init = 0x8005FCD0; free_3d_model = 0x8005FF40; free_model_data = 0x80060058; func_8006017C = 0x8006017C; func_80060910 = 0x80060910; func_80060AC8 = 0x80060AC8; func_80060C58 = 0x80060C58; -func_80060EA8 = 0x80060EA8; -func_800619F4 = 0x800619F4; -func_80061A00 = 0x80061A00; +model_calc_normals = 0x80060EA8; +model_anim_offset = 0x800619F4; +model_anim_init = 0x80061A00; func_80061C0C = 0x80061C0C; // obj_animate.c .text @@ -1430,7 +1430,7 @@ menu_racer_portraits = 0x80094604; postrace_start = 0x80094688; postrace_load = 0x80094A5C; postrace_music_fade = 0x80094C14; -func_80094D28 = 0x80094D28; +postrace_viewport = 0x80094D28; postrace_message = 0x80095624; menu_postrace = 0x80095728; postrace_free = 0x80096790; @@ -1619,7 +1619,7 @@ rain_render = 0x800ADCBC; // particles.c .text reset_particles = 0x800AE270; reset_particles_with_assets = 0x800AE2A0; -free_unknown_particle_sprites = 0x800AE2D8; +particle_free_dummy = 0x800AE2D8; free_particle_buffers = 0x800AE374; free_particle_vertices_triangles = 0x800AE438; free_particle_assets = 0x800AE490; @@ -2177,8 +2177,8 @@ audFrameCt = 0x800DC680; nextDMA = 0x800DC684; curAcmdList = 0x800DC688; gAntiPiracyAudioFreq = 0x800DC68C; -gFunc80019808Checksum = 0x800DC690; -gFunc80019808Length = 0x800DC694; +gRaceCheckFinishChecksum = 0x800DC690; +gRaceCheckFinishFuncLength = 0x800DC694; // audiosfx.c .data gSoundStateLists = 0x800DC6B0; // size:0xC @@ -2313,8 +2313,8 @@ gWizpigVoiceTable = 0x800DCE60; gRocketVoiceTable = 0x800DCE80; // object_models.c .data -gTractionTableChecksum = 0x800DCEA0; -gTrackRenderFuncLength = 0x800DCEA4; +gRenderSceneChecksum = 0x800DCEA0; +gRenderSceneFuncLength = 0x800DCEA4; // al/reverb.c .data alFXEnabled = 0x800DCEB0; @@ -2837,8 +2837,8 @@ gMaxRectangleParticles = 0x800E2E50; gMaxSpriteParticles = 0x800E2E54; gMaxLineParticles = 0x800E2E58; gMaxPointParticles = 0x800E2E5C; -D_800E2E60 = 0x800E2E60; -D_800E2E64 = 0x800E2E64; +gParticleDummys = 0x800E2E60; +gParticleDummyCount = 0x800E2E64; gParticleCoordListTri = 0x800E2E68; gParticleCoordListQuad = 0x800E2E74; D_800E2E84 = 0x800E2E84; @@ -3732,10 +3732,10 @@ D_8011ADA4 = 0x8011ADA4; gObjectUpdateRateF = 0x8011ADA8; gPathUpdateOff = 0x8011ADAC; gEventCountdown = 0x8011ADB0; -D_8011ADB4 = 0x8011ADB4; +gRaceFinishTriggered = 0x8011ADB4; gEventStartTimer = 0x8011ADB8; D_8011ADBC = 0x8011ADBC; -D_8011ADC0 = 0x8011ADC0; +gNumFinishedRacers = 0x8011ADC0; gFirstTimeFinish = 0x8011ADC4; D_8011ADC5 = 0x8011ADC5; gBalloonCutsceneTimer = 0x8011ADC8; @@ -4038,7 +4038,7 @@ gNumModelIDs = 0x8011D630; D_8011D634 = 0x8011D634; gAnimationTable = 0x8011D638; gObjectAnimationTable = 0x8011D63C; -D_8011D640 = 0x8011D640; +gModelAnimOffsetID = 0x8011D640; D_8011D644 = 0x8011D644; // main .bss diff --git a/ver/symbols/symbol_addrs.us.v80.txt b/ver/symbols/symbol_addrs.us.v80.txt index d192daea..58e830c0 100644 --- a/ver/symbols/symbol_addrs.us.v80.txt +++ b/ver/symbols/symbol_addrs.us.v80.txt @@ -221,13 +221,13 @@ spawn_object = 0x8000EA54; objFreeAssets = 0x8000F648; light_setup_light_sources = 0x8000F758; init_object_shading = 0x8000F7EC; -func_8000F99C = 0x8000F99C; +obj_init_attachpoint = 0x8000F99C; obj_init_emitter = 0x8000FAC4; init_object_shadow = 0x8000FBCC; init_object_water_effect = 0x8000FC6C; init_object_interaction_data = 0x8000FD20; func_8000FD34 = 0x8000FD34; -func_8000FD54 = 0x8000FD54; +obj_spawn_attachment = 0x8000FD54; free_object = 0x8000FFB8; obj_table_ids = 0x80010018; obj_id_valid = 0x80010028; @@ -290,7 +290,7 @@ func_800185E4 = 0x80018618; find_taj_object = 0x80018CA0; func_80018CE0 = 0x80018D14; func_8001955C = 0x80019590; -func_80019808 = 0x8001983C; +race_check_finish = 0x8001983C; set_course_finish_flags = 0x8001A80C; race_finish_adventure = 0x8001A908; race_transition_adventure = 0x8001A928; @@ -662,9 +662,9 @@ func_80042D20 = 0x80042D60; increment_ai_behaviour_chances = 0x80043F0C; racer_AI_pathing_inputs = 0x800441B0; roll_percent_chance = 0x80044490; -func_8004447C = 0x800444BC; -func_80045128 = 0x80045168; -func_800452A0 = 0x800452E0; +racer_ai_challenge = 0x800444BC; +racer_update_eggs = 0x80045168; +racer_ai_eggs = 0x800452E0; func_80045C48 = 0x80045C88; func_80046524 = 0x80046564; racer_attack_handler_hovercraft = 0x80048CBC; @@ -756,16 +756,16 @@ update_wizpig = 0x8005EC30; update_rocket = 0x8005F4B0; allocate_object_model_pools = 0x8005F9F0; object_model_init = 0x8005FB3C; // has a diff from v1 -model_init_type = 0x8005FF10; +model_instance_init = 0x8005FF10; free_3d_model = 0x80060180; free_model_data = 0x80060298; func_8006017C = 0x800603BC; func_80060910 = 0x80060B50; func_80060AC8 = 0x80060D08; func_80060C58 = 0x80060E98; -func_80060EA8 = 0x800610E8; -func_800619F4 = 0x80061C34; -func_80061A00 = 0x80061C40; +model_calc_normals = 0x800610E8; +model_anim_offset = 0x80061C34; +model_anim_init = 0x80061C40; func_80061C0C = 0x80061E4C; obj_animate = 0x80061F70; alCSPNew = 0x800624D0; @@ -1349,7 +1349,7 @@ menu_racer_portraits = 0x80094B08; postrace_start = 0x80094B8C; postrace_load = 0x80094F60; postrace_music_fade = 0x80095118; -func_80094D28 = 0x8009522C; +postrace_viewport = 0x8009522C; postrace_message = 0x80095B28; menu_postrace = 0x80095C2C; postrace_free = 0x80096C94; @@ -1533,7 +1533,7 @@ rain_sound = 0x800AE128; rain_render = 0x800AE21C; reset_particles = 0x800AE7D0; reset_particles_with_assets = 0x800AE800; -free_unknown_particle_sprites = 0x800AE838; +particle_free_dummy = 0x800AE838; free_particle_buffers = 0x800AE8D4; free_particle_vertices_triangles = 0x800AE998; free_particle_assets = 0x800AE9F0; @@ -2014,8 +2014,8 @@ audFrameCt = 0x800DCBF0; nextDMA = 0x800DCBF4; curAcmdList = 0x800DCBF8; gAntiPiracyAudioFreq = 0x800DCBFC; -gFunc80019808Checksum = 0x800DCC00; -gFunc80019808Length = 0x800DCC04; +gRaceCheckFinishChecksum = 0x800DCC00; +gRaceCheckFinishFuncLength = 0x800DCC04; gSoundStateLists = 0x800DCC20; // size:0xC gSoundPlayerPtr = 0x800DCC2C; gSoundGlobalVolume = 0x800DCC30; @@ -2120,8 +2120,8 @@ gSmokeyVoiceTable = 0x800DD390; gBubblerVoiceTable = 0x800DD3B0; gWizpigVoiceTable = 0x800DD3D0; gRocketVoiceTable = 0x800DD3F0; -gTractionTableChecksum = 0x800DD410; -gTrackRenderFuncLength = 0x800DD414; +gRenderSceneChecksum = 0x800DD410; +gRenderSceneFuncLength = 0x800DD414; alFXEnabled = 0x800DD420; gStereoPanMode = 0x800DD5C0; gAntiPiracyViewport = 0x800DD5D0; @@ -2612,8 +2612,8 @@ gMaxRectangleParticles = 0x800E33E0; gMaxSpriteParticles = 0x800E33E4; gMaxLineParticles = 0x800E33E8; gMaxPointParticles = 0x800E33EC; -D_800E2E60 = 0x800E33F0; -D_800E2E64 = 0x800E33F4; +gParticleDummys = 0x800E33F0; +gParticleDummyCount = 0x800E33F4; gParticleCoordListTri = 0x800E33F8; gParticleCoordListQuad = 0x800E3404; D_800E2E84 = 0x800E3414; @@ -3281,10 +3281,10 @@ D_8011ADA4 = 0x8011B324; gObjectUpdateRateF = 0x8011B328; gPathUpdateOff = 0x8011B32C; gEventCountdown = 0x8011B330; -D_8011ADB4 = 0x8011B334; +gRaceFinishTriggered = 0x8011B334; gEventStartTimer = 0x8011B338; D_8011ADBC = 0x8011B33C; -D_8011ADC0 = 0x8011B340; +gNumFinishedRacers = 0x8011B340; gFirstTimeFinish = 0x8011B344; D_8011ADC5 = 0x8011B345; gBalloonCutsceneTimer = 0x8011B348; @@ -3565,7 +3565,7 @@ gNumModelIDs = 0x8011DBB0; D_8011D634 = 0x8011DBB4; gAnimationTable = 0x8011DBB8; gObjectAnimationTable = 0x8011DBBC; -D_8011D640 = 0x8011DBC0; +gModelAnimOffsetID = 0x8011DBC0; D_8011D644 = 0x8011DBC4; gThread1Stack = 0x8011DBD0; gThread3Stack = 0x8011DCD8;