diff --git a/README.md b/README.md index 1a855e42..c0c61ef8 100644 --- a/README.md +++ b/README.md @@ -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. -As of May 12, 2025, this is our current score: +As of May 13, 2025, this is our current score: -    Decomp progress: 86.98% +    Decomp progress: 87.01%     Documentation progress: 56.95% @@ -117,15 +117,15 @@ s32 is_drumstick_unlocked(void) { ``` -As of May 12, 2025, this is our current score: +As of May 13, 2025, this is our current score: ``` ===================================================================== ADVENTURE ONE (ASM -> C Decompilation) - --------------- 86.98% Complete (88.14% NON_MATCHING) --------------- - # Decompiled functions: 1888 - # GLOBAL_ASM remaining: 63 + --------------- 87.01% Complete (88.17% NON_MATCHING) --------------- + # Decompiled functions: 1889 + # GLOBAL_ASM remaining: 62 # NON_MATCHING functions: 7 - # NON_EQUIVALENT WIP functions: 21 + # NON_EQUIVALENT WIP functions: 20 ---------------------------- Game Status ---------------------------- Balloons: 40/47, Keys: 4/4, Trophies: 4/5 T.T. Amulets: 4/4, Wizpig Amulets: 4/4 diff --git a/src/objects.c b/src/objects.c index 02483201..448942a5 100644 --- a/src/objects.c +++ b/src/objects.c @@ -2433,36 +2433,31 @@ void obj_update(s32 updateRate) { } } -#ifdef NON_EQUIVALENT -void func_80011134(Object *arg0, s32 arg1) { +void func_80011134(Object *obj, s32 updateRate) { + ObjectModel *model; + TriangleBatchInfo *batch; s32 sp5C; - ObjectModel *temp_s3; - TriangleBatchInfo *temp_s4; - TriangleBatchInfo *var_s0; - TextureHeader *var_t5; + TextureHeader *tex; s16 temp_s5; - s32 var_s1; - u8 temp_v0; + s32 batchNumber; + Object_68 *obj68; - temp_s3 = arg0->unk68[arg0->segment.object.modelIndex]->objModel; - temp_s5 = temp_s3->unk50; - temp_s4 = temp_s3->batches; - for (var_s1 = 0; temp_s5 > 0 && var_s1 < temp_s3->numberOfBatches; var_s1++) { - var_s0 = &temp_s4[var_s1]; - if (var_s0->flags & 0x10000) { // Texture is animated - temp_v0 = var_s0->textureIndex; - if (temp_v0 != 0xFF) { - var_t5 = temp_s3->textures[temp_v0].texture; - sp5C = var_s0->unk7 << 6; - tex_animate_texture(var_t5, (u32 *) temp_s4[var_s1].flags, &sp5C, arg1); - var_s0->unk7 = sp5C >> 6; + obj68 = obj->unk68[obj->segment.object.modelIndex]; + model = obj68->objModel; + batch = model->batches; + temp_s5 = model->unk50; + for (batchNumber = 0; temp_s5 > 0 && batchNumber < model->numberOfBatches; batchNumber++) { + if (batch[batchNumber].flags & BATCH_FLAGS_TEXTURE_ANIM) { + if (batch[batchNumber].textureIndex != TEX_INDEX_NO_TEXTURE) { + tex = model->textures[batch[batchNumber].textureIndex].texture; + sp5C = batch[batchNumber].unk7; + sp5C <<= 6; + tex_animate_texture(tex, &batch[batchNumber].flags, &sp5C, updateRate); + batch[batchNumber].unk7 = (sp5C >> 6) & 0xFF; } } } } -#else -#pragma GLOBAL_ASM("asm/nonmatchings/objects/func_80011134.s") -#endif // This is a function for doors void func_80011264(ObjectModel *model, Object *obj) { @@ -2484,7 +2479,7 @@ void func_80011264(ObjectModel *model, Object *obj) { batch = model->batches; while (i < model->numberOfBatches) { - if (batch[i].flags & 0x10000) { + if (batch[i].flags & BATCH_FLAGS_TEXTURE_ANIM) { if (batch[i].textureIndex != TEX_INDEX_NO_TEXTURE) { // Fakematch if (model->textures[batch[i].textureIndex].texture) {} @@ -3325,7 +3320,7 @@ void func_80012F94(Object *obj) { } racerLightTimer *= 4; for (batchNum = 0; batchNum < temp_a1_3->numberOfBatches; batchNum++) { - if ((temp_a1_3->batches[batchNum].flags & 0x810000) == 0x10000) { + if ((temp_a1_3->batches[batchNum].flags & 0x810000) == BATCH_FLAGS_TEXTURE_ANIM) { temp_a1_3->batches[batchNum].unk7 = racerLightTimer; } } diff --git a/src/thread0_epc.c b/src/thread0_epc.c index b8d1a5d4..fe718de1 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -116,7 +116,7 @@ void stop_all_threads_except_main(void) { */ void write_epc_data_to_cpak(void) { OSThread *thread; - UNUSED s16 sp444[0x200]; + s16 sp444[0x200]; u8 sp244[0x200]; u8 sp44[0x200]; s16 *v0; @@ -213,24 +213,25 @@ void update_object_stack_trace(s32 index, s32 value) { s32 get_lockup_status(void) { s32 fileNum; s32 controllerIndex = 0; - u64 sp420[STACKSIZE(STACK_EPCINFO2)]; // Overwrite epcStack? - u64 sp220[STACKSIZE(STACK_EPCINFO1)]; - u8 dataFromControllerPak[_ALIGN128(sizeof(epcInfo))]; + struct { + u8 epcInfo[_ALIGN128(sizeof(epcInfo))]; + u64 epcInfoStack1[STACKSIZE(STACK_EPCINFO1)]; + u64 epcInfoStack2[STACKSIZE(STACK_EPCINFO2)]; + } dataFromControllerPak; if (sLockupStatus != -1) { return sLockupStatus; } else { - sLockupStatus = 0; + sLockupStatus = FALSE; // Looks like it reads EpcInfo data from the controller pak, which is interesting if ((get_si_device_status(controllerIndex) == CONTROLLER_PAK_GOOD) && (get_file_number(controllerIndex, "CORE", "", &fileNum) == CONTROLLER_PAK_GOOD) && - (read_data_from_controller_pak(controllerIndex, fileNum, dataFromControllerPak, - sizeof(sp420) + sizeof(sp220) + sizeof(dataFromControllerPak)) == - CONTROLLER_PAK_GOOD)) { - bcopy(&dataFromControllerPak, &gEpcInfo, sizeof(epcInfo)); - bcopy(&sp220, &gEpcInfoStack1, sizeof(sp220)); - bcopy(&sp420, &gEpcInfoStack2, sizeof(sp420)); - sLockupStatus = 1; + (read_data_from_controller_pak(controllerIndex, fileNum, (u8 *) &dataFromControllerPak, + sizeof(dataFromControllerPak)) == CONTROLLER_PAK_GOOD)) { + bcopy(&dataFromControllerPak.epcInfo, &gEpcInfo, sizeof(epcInfo)); + bcopy(&dataFromControllerPak.epcInfoStack1, &gEpcInfoStack1, sizeof(dataFromControllerPak.epcInfoStack1)); + bcopy(&dataFromControllerPak.epcInfoStack2, &gEpcInfoStack2, sizeof(dataFromControllerPak.epcInfoStack2)); + sLockupStatus = TRUE; } start_reading_controller_data(controllerIndex); if (sLockupStatus) { @@ -291,7 +292,8 @@ void render_epc_lock_up_display(void) { render_printf("\n"); render_printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); } else { - render_printf(" Fault in thread %d\n", epcinfo->thread[GET_REG(t9) * 0]); // fake GET_REG + epcinfo = &gEpcInfo; + render_printf(" Fault in thread %d\n", epcinfo->thread[0]); render_printf(" epc\t\t0x%08x\n", epcinfo->epc); render_printf(" cause\t\t0x%08x\n", epcinfo->cause); render_printf(" sr\t\t0x%08x\n", epcinfo->sr);