From 595058cc89ee1bef9fd270a791422116a9514abe Mon Sep 17 00:00:00 2001 From: Donkey Kong Date: Mon, 29 May 2023 19:07:40 +0930 Subject: [PATCH] 24.5579% --- include/structs.h | 14 ++- progress/progress.boss.csv | 2 +- progress/progress.global_asm.csv | 2 +- progress/progress.race.csv | 8 +- progress/progress.total.csv | 12 +-- progress/progress_boss.svg | 4 +- progress/progress_global_asm.svg | 4 +- progress/progress_race.svg | 6 +- progress/progress_total.svg | 4 +- src/boss/code_0.c | 29 +++--- src/global_asm/code_112080.c | 17 ++-- src/race/code_36B0.c | 160 +++++++++++++++++++++++-------- 12 files changed, 172 insertions(+), 90 deletions(-) diff --git a/include/structs.h b/include/structs.h index 49059c2..2dd0ba6 100644 --- a/include/structs.h +++ b/include/structs.h @@ -528,6 +528,18 @@ typedef struct another_additional_actor_data { u8 unk13; // Used in func_806925AC } AnotherAdditionalActorData; +typedef struct { + u8 unk0[0x27 - 0x0]; + u8 unk27; + u8 unk28[0x36 - 0x28]; + u8 unk36; +} RaaD_unk20_unk4; + +typedef struct { + s32 unk0; + RaaD_unk20_unk4 *unk4; +} RaaD_unk20; + typedef struct race_additional_actor_data { s16 unk0; s16 unk2; // used @@ -542,7 +554,7 @@ typedef struct race_additional_actor_data { u16 unk1C; u8 unk1E; s8 unk1F; - s32 unk20; + RaaD_unk20 *unk20; // Array u8 unk24; u8 unk25; s8 unk26; diff --git a/progress/progress.boss.csv b/progress/progress.boss.csv index 1e0b29e..2a602c0 100644 --- a/progress/progress.boss.csv +++ b/progress/progress.boss.csv @@ -34,7 +34,7 @@ us,.code,func_8002EA14,104,yes us,.code,func_8002C964,2252,no us,.code,func_80028458,32,yes us,.code,func_8002FF74,2324,no -us,.code,func_8002450C,24,no +us,.code,func_8002450C,24,yes us,.code,func_800251A0,380,yes us,.code,func_800292B0,272,yes us,.code,func_80024FA8,504,yes diff --git a/progress/progress.global_asm.csv b/progress/progress.global_asm.csv index dddbd8c..2f76efd 100644 --- a/progress/progress.global_asm.csv +++ b/progress/progress.global_asm.csv @@ -2285,7 +2285,7 @@ us,.code,func_80703AB0,584,no us,.code,func_806CD988,24,yes us,.code,func_8064EC60,264,no us,.code,func_80682DF4,68,no -us,.code,func_8070DB7C,32,no +us,.code,func_8070DB7C,32,yes us,.code,func_806FB418,96,yes us,.code,func_8073C9C0,68,yes us,.code,func_806FB490,644,no diff --git a/progress/progress.race.csv b/progress/progress.race.csv index 9f99f0a..d48dd89 100644 --- a/progress/progress.race.csv +++ b/progress/progress.race.csv @@ -7,7 +7,7 @@ us,.code,func_8002CAC8,292,no us,.code,func_800282D8,252,no us,.code,func_800294A8,740,no us,.code,func_80024634,92,yes -us,.code,func_8002D40C,148,no +us,.code,func_8002D40C,148,yes us,.code,func_8002578C,24,yes us,.code,func_8002F420,112,yes us,.code,func_8002DF38,656,no @@ -34,7 +34,7 @@ us,.code,func_80026354,1996,no us,.code,func_80027C60,136,yes us,.code,func_8002F0AC,468,no us,.code,func_8002DDA0,216,no -us,.code,func_8002D224,156,no +us,.code,func_8002D224,156,yes us,.code,func_8002DB90,148,yes us,.code,func_80028E20,564,no us,.code,func_80027CE8,1024,no @@ -98,7 +98,7 @@ us,.code,func_80026098,328,no us,.code,func_80028440,1680,no us,.code,func_8002D524,520,no us,.code,func_8002ED04,208,yes -us,.code,func_8002BC2C,132,no +us,.code,func_8002BC2C,132,yes us,.code,func_8002E484,448,yes us,.code,func_80025E9C,320,no us,.code,func_80027920,472,no @@ -108,7 +108,7 @@ us,.code,func_8002C76C,860,no us,.code,func_8002DA68,296,yes us,.code,func_800257A4,472,no us,.code,func_8002C2E8,852,no -us,.code,func_8002BCB0,36,no +us,.code,func_8002BCB0,36,yes us,.code,func_8002D778,752,no us,.code,func_8002E644,680,no us,.code,func_8002D4A0,132,yes diff --git a/progress/progress.total.csv b/progress/progress.total.csv index b28c65f..7aada44 100644 --- a/progress/progress.total.csv +++ b/progress/progress.total.csv @@ -2285,7 +2285,7 @@ us,.code,func_80703AB0,584,no us,.code,func_806CD988,24,yes us,.code,func_8064EC60,264,no us,.code,func_80682DF4,68,no -us,.code,func_8070DB7C,32,no +us,.code,func_8070DB7C,32,yes us,.code,func_806FB418,96,yes us,.code,func_8073C9C0,68,yes us,.code,func_806FB490,644,no @@ -3471,7 +3471,7 @@ us,.code,func_8002CAC8,292,no us,.code,func_800282D8,252,no us,.code,func_800294A8,740,no us,.code,func_80024634,92,yes -us,.code,func_8002D40C,148,no +us,.code,func_8002D40C,148,yes us,.code,func_8002578C,24,yes us,.code,func_8002F420,112,yes us,.code,func_8002DF38,656,no @@ -3498,7 +3498,7 @@ us,.code,func_80026354,1996,no us,.code,func_80027C60,136,yes us,.code,func_8002F0AC,468,no us,.code,func_8002DDA0,216,no -us,.code,func_8002D224,156,no +us,.code,func_8002D224,156,yes us,.code,func_8002DB90,148,yes us,.code,func_80028E20,564,no us,.code,func_80027CE8,1024,no @@ -3562,7 +3562,7 @@ us,.code,func_80026098,328,no us,.code,func_80028440,1680,no us,.code,func_8002D524,520,no us,.code,func_8002ED04,208,yes -us,.code,func_8002BC2C,132,no +us,.code,func_8002BC2C,132,yes us,.code,func_8002E484,448,yes us,.code,func_80025E9C,320,no us,.code,func_80027920,472,no @@ -3572,7 +3572,7 @@ us,.code,func_8002C76C,860,no us,.code,func_8002DA68,296,yes us,.code,func_800257A4,472,no us,.code,func_8002C2E8,852,no -us,.code,func_8002BCB0,36,no +us,.code,func_8002BCB0,36,yes us,.code,func_8002D778,752,no us,.code,func_8002E644,680,no us,.code,func_8002D4A0,132,yes @@ -3924,7 +3924,7 @@ us,.code,func_8002EA14,104,yes us,.code,func_8002C964,2252,no us,.code,func_80028458,32,yes us,.code,func_8002FF74,2324,no -us,.code,func_8002450C,24,no +us,.code,func_8002450C,24,yes us,.code,func_800251A0,380,yes us,.code,func_800292B0,272,yes us,.code,func_80024FA8,504,yes diff --git a/progress/progress_boss.svg b/progress/progress_boss.svg index 6913ef9..bb0d7a8 100644 --- a/progress/progress_boss.svg +++ b/progress/progress_boss.svg @@ -17,7 +17,7 @@ boss - 13.4547% - 13.4547% + 13.4881% + 13.4881% diff --git a/progress/progress_global_asm.svg b/progress/progress_global_asm.svg index 3068897..f79a305 100644 --- a/progress/progress_global_asm.svg +++ b/progress/progress_global_asm.svg @@ -17,7 +17,7 @@ global_asm - 25.1231% - 25.1231% + 25.1257% + 25.1257% diff --git a/progress/progress_race.svg b/progress/progress_race.svg index 0debb7e..c30340b 100644 --- a/progress/progress_race.svg +++ b/progress/progress_race.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ race - 14.0244% - 14.0244% + 15.0100% + 15.0100% diff --git a/progress/progress_total.svg b/progress/progress_total.svg index 49d5a70..596aaeb 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -17,7 +17,7 @@ Donkey Kong 64 (US) - 24.5258% - 24.5258% + 24.5579% + 24.5579% diff --git a/src/boss/code_0.c b/src/boss/code_0.c index 47d5744..b37f1cb 100644 --- a/src/boss/code_0.c +++ b/src/boss/code_0.c @@ -2,7 +2,7 @@ #include "functions.h" void func_8072AB74(s32, f32, f32, s32, f32); -s32 func_80024568(s32, s32, f32, f32, f32); +s32 func_80024568(s32, u8, f32, f32, f32); #pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_80024000.s") @@ -111,19 +111,14 @@ void func_8002413C(void) { // Jumptable #pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_80024300.s") -#pragma GLOBAL_ASM("asm/nonmatchings/boss/code_0/func_8002450C.s") +typedef struct { + u8 unk0[0x6 - 0x0]; + u8 unk6[1]; // TODO: How many elements? +} Struct8002450C; -void func_8002450C(u8 *, s32, u8); - -/* -// TODO: t6 t7 regalloc... -void func_8002450C(u8 *arg0, s32 arg1, u8 arg2) { - s32 phi_1; - - phi_1 = *(s32*)(&arg1); - arg0[(u8)(phi_1) + 6] = arg2; +void func_8002450C(Struct8002450C *arg0, u8 arg1, u8 arg2) { + arg0->unk6[arg1] = arg2; } -*/ void func_80024524(u8 arg0, s16 arg1) { AnimationStateUnk1C *temp_v0; @@ -167,16 +162,16 @@ void func_80024FA8(s32 arg0, s32 arg1, s32 arg2, u8 *arg3) { switch (current_actor_pointer->control_state_progress) { case 2: while (arg3[i] != 0xFF) { - func_8002450C(arg1, arg3[i++] & 0xFF, 1); + func_8002450C(arg1, arg3[i++], 1); } current_actor_pointer->control_state_progress = 3; return; case 3: while (arg3[i] != 0xFF) { if ((current_actor_pointer->control_state == 0x27) || (current_actor_pointer->control_state == 0x2E)) { - phi_v0_2 = func_80024568(arg1, arg3[i++] & 0xFF, 50.0f, 70.0f, 90.0f); + phi_v0_2 = func_80024568(arg1, arg3[i++], 50.0f, 70.0f, 90.0f); } else { - phi_v0_2 = func_80024568(arg1, arg3[i++] & 0xFF, 10.0f, 15.0f, 50.0f); + phi_v0_2 = func_80024568(arg1, arg3[i++], 10.0f, 15.0f, 50.0f); } } if (phi_v0_2 != 0) { @@ -194,13 +189,13 @@ void func_800251A0(s32 arg0, s32 arg1, s32 arg2, u8 *arg3) { switch (current_actor_pointer->control_state_progress) { case 2: while (arg3[i] != 0xFF) { - func_8002450C(arg1, arg3[i++] & 0xFF, 3); + func_8002450C(arg1, arg3[i++], 3); } current_actor_pointer->control_state_progress = 3; break; case 3: while (arg3[i] != 0xFF) { - phi_v1 = func_80024568(arg1, arg3[i++] & 0xFF, 10.0f, 20.0f, 30.0f) & 0xFF; + phi_v1 = func_80024568(arg1, arg3[i++], 10.0f, 20.0f, 30.0f) & 0xFF; } if (phi_v1 != 0) { current_actor_pointer->control_state_progress = 4; diff --git a/src/global_asm/code_112080.c b/src/global_asm/code_112080.c index 0e789a4..5455113 100644 --- a/src/global_asm/code_112080.c +++ b/src/global_asm/code_112080.c @@ -249,17 +249,6 @@ void func_8070DA28(AAD_806A4DDC *arg0) { #pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DA74.s") -#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DB7C.s") - -/* -// TODO: Which struct is this? -void func_8070DB7C(void *arg0) { - func_8061134C(arg0->unk4); -} -*/ - -#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DB9C.s") - typedef struct Struct8070DB9C Struct8070DB9C; struct Struct8070DB9C { @@ -271,6 +260,12 @@ struct Struct8070DB9C { Struct8070DB9C *unk8; }; +void func_8070DB7C(Struct8070DB9C *arg0) { + func_8061134C(arg0->unk4); +} + +#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_112080/func_8070DB9C.s") + /* // TODO: Very close void func_8070DB9C(Struct8070DB9C *arg0) { diff --git a/src/race/code_36B0.c b/src/race/code_36B0.c index 323bf0c..ea0fa7d 100644 --- a/src/race/code_36B0.c +++ b/src/race/code_36B0.c @@ -256,14 +256,14 @@ void func_8002B6F4(RaceStruct7 *arg0, s32 arg1) { #pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002B964.s") -void func_80611690(void*); +void func_80611690(RaaD_unk20*); void func_8002BBD0(Actor *arg0, s32 arg1) { RaceAdditionalActorData *sp1C; - void *temp_v0; + RaaD_unk20 *temp_v0; sp1C = arg0->RaaD; - temp_v0 = malloc(arg1 * 8); + temp_v0 = malloc(arg1 * sizeof(RaaD_unk20)); sp1C->unk20 = temp_v0; func_80611690(temp_v0); sp1C->unk1E = arg1; @@ -271,10 +271,79 @@ void func_8002BBD0(Actor *arg0, s32 arg1) { arg0->control_state = 0; } -#pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002BC2C.s") +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s8 unk24; + s8 unk25; + u8 unk26; + u8 unk27; + u8 unk28; + u8 unk29; + u8 unk2A; + u8 unk2B; + s32 unk2C; + s32 unk30; + u8 unk34; + s8 unk35; + u8 unk36; + u8 unk37; + u8 unk38; + u8 unk39; + s16 unk3A; + u16 unk3C; + s8 unk3E[0x45 - 0x3E]; + u8 unk45; + s8 unk46; + u8 unk47; + u32 unk48; +} Struct8002D148_unk4; -// aaD use -#pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002BCB0.s") +typedef struct { + s32 unk0; + Struct8002D148_unk4 *unk4; +} Struct8002D148; + +u16 *func_8002E960(u8); + +void func_8002BC2C(Actor *arg0, s32 arg1, s32 arg2, Struct8002D148_unk4 *arg3) { + u16 *temp_v0_2; + RaceAdditionalActorData *RaaD; + RaaD_unk20 *temp_v0; + + RaaD = arg0->RaaD; + temp_v0 = RaaD->unk20; + temp_v0[arg1].unk0 = arg2; + temp_v0[arg1].unk4 = arg3; + arg3->unk45 = 0; + arg3->unk3A = 0; + arg3->unk37 = 1; + if (arg3->unk27 == 0) { + temp_v0_2 = func_8002E960(RaaD->unk26); + if (temp_v0_2 != NULL) { + arg3->unk3C = *temp_v0_2 - 1; + func_8002F36C(arg3, temp_v0_2); + } + arg3->unk48 = func_806C7C94(arg3->unk28); + } +} + +void func_8002BCB0(Actor *arg0, s32 arg1, s32 *arg2, s32 *arg3) { + RaceAdditionalActorData *aaD; + RaaD_unk20 *temp_t0; + + aaD = arg0->RaaD; + temp_t0 = aaD->unk20; + *arg2 = temp_t0[arg1].unk0; + *arg3 = temp_t0[arg1].unk4; +} #pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002BCD4.s") @@ -348,36 +417,6 @@ s32 func_8070E750(s32, s32, s32); extern s32 D_8002FCD4[]; -typedef struct { - s32 unk0; - s32 unk4; - s32 unk8; - s32 unkC; - s32 unk10; - s32 unk14; - s32 unk18; - s32 unk1C; - s32 unk20; - s8 unk24; - s8 unk25; - s8 unk26; - u8 unk27; - s32 unk28; - s32 unk2C; - s32 unk30; - u8 unk34; - s8 unk35; - u8 unk36; - s8 unk37[0x45 - 0x37]; - u8 unk45; - s8 unk46; -} Struct8002D148_unk4; - -typedef struct { - s32 unk0; - Struct8002D148_unk4 *unk4; -} Struct8002D148; - /* // TODO: Regalloc void func_8002D148(Struct8002D148 *arg0, u8 arg1) { @@ -401,8 +440,22 @@ void func_8002D148(Struct8002D148 *arg0, u8 arg1) { } */ -// RaaD->unk20 struct array use -#pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002D224.s") +void func_8002D148(RaaD_unk20*, u8); + +void func_8002D224(u8 arg0) { + RaaD_unk20 *var_s0; + s32 i; + RaceAdditionalActorData *RaaD; + + RaaD = current_actor_pointer->RaaD; + var_s0 = RaaD->unk20; + current_actor_pointer->control_state = arg0; + for (i = 0; i < RaaD->unk1E; i++) { + if (var_s0[i].unk0 != 0) { + func_8002D148(&var_s0[i], arg0); + } + } +} extern f32 D_800300E8; @@ -436,8 +489,33 @@ extern f32 D_800300F0; // dx dy dz calculation #pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002D360.s") -// RaaD->unk20-> struct array 0x8 big loop -#pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002D40C.s") +void func_8002D40C(void) { + s32 song; + s32 i; + RaceAdditionalActorData *RaaD; + RaaD_unk20_unk4 *temp_v0_2; + RaaD_unk20 *var_a0; + + RaaD = current_actor_pointer->RaaD; + song = 0; + i = RaaD->unk1E - 1; + var_a0 = &RaaD->unk20[i]; + while (song == 0 && i >= 0) { + if (RaaD->unk20[i].unk4->unk27 == 1) { + if (RaaD->unk20[i].unk4->unk36 != 0) { + song = 0x56; + } else { + song = 0x57; + } + } + i--; + var_a0--; + } + if (song == 0) { + song = 0x56; + } + playSong(song, 1.0f); +} void func_8002D4A0(void) { s32 song; @@ -463,6 +541,7 @@ void func_8002D4A0(void) { playSong(song, phi_f0); } +// RaaD 0x20 array #pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002D524.s") void func_8002D72C(Actor *arg0) { @@ -655,6 +734,7 @@ f32 func_8002E1C8(Struct8002E1C8_arg0 *arg0, f32 arg1, Struct8002E1C8_arg2 *arg2 return var_f2; } +// Doable, A178 & A17C stuff though #pragma GLOBAL_ASM("asm/nonmatchings/race/code_36B0/func_8002E2C8.s") void func_8002E464(s32 arg0, Actor *arg1) {