diff --git a/include/structs.h b/include/structs.h index 7a46a3e..443155c 100644 --- a/include/structs.h +++ b/include/structs.h @@ -318,7 +318,9 @@ typedef struct actor_178 { u8 unkC; u8 unkD; u8 unkE; - u8 unkF[0x5]; + u8 unkF; + u16 unk10; // Used + u16 unk12; // Used u8 unk14; } Actor178; diff --git a/progress/progress.global_asm.csv b/progress/progress.global_asm.csv index 20fa975..4358106 100644 --- a/progress/progress.global_asm.csv +++ b/progress/progress.global_asm.csv @@ -1532,7 +1532,7 @@ us,.code,func_8070CAB4,120,yes us,.code,func_8064D0C4,292,no us,.code,func_806891D8,120,yes us,.code,func_806A7B70,36,yes -us,.code,func_806B54BC,1492,no +us,.code,func_806B54BC,1488,yes us,.code,func_80659574,60,no us,.code,func_806534E0,420,no us,.code,func_80724994,140,no diff --git a/progress/progress.total.csv b/progress/progress.total.csv index 0ac0721..2ebe365 100644 --- a/progress/progress.total.csv +++ b/progress/progress.total.csv @@ -1532,7 +1532,7 @@ us,.code,func_8070CAB4,120,yes us,.code,func_8064D0C4,292,no us,.code,func_806891D8,120,yes us,.code,func_806A7B70,36,yes -us,.code,func_806B54BC,1492,no +us,.code,func_806B54BC,1488,yes us,.code,func_80659574,60,no us,.code,func_806534E0,420,no us,.code,func_80724994,140,no diff --git a/progress/progress_global_asm.svg b/progress/progress_global_asm.svg index 1d871b9..905d977 100644 --- a/progress/progress_global_asm.svg +++ b/progress/progress_global_asm.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ global_asm - 15.9331% - 15.9331% + 16.0543% + 16.0543% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index 31f9871..8e496e0 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -17,7 +17,7 @@ Donkey Kong 64 (US) - 16.4704% - 16.4704% + 16.5610% + 16.5610% \ No newline at end of file diff --git a/src/global_asm/code_12E800.c b/src/global_asm/code_12E800.c index acd3f86..afc80ae 100644 --- a/src/global_asm/code_12E800.c +++ b/src/global_asm/code_12E800.c @@ -16,6 +16,7 @@ s16 func_806CC190(s16, s16, f32); extern f64 D_8075FF38; +// Doable #pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_12E800/func_80729B00.s") void func_80729E6C(void) { diff --git a/src/global_asm/code_B7490.c b/src/global_asm/code_B7490.c index dc033aa..e37061d 100644 --- a/src/global_asm/code_B7490.c +++ b/src/global_asm/code_B7490.c @@ -33,6 +33,8 @@ void func_806B2D5C(void) { #pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B2D64.s") +void func_80729B00(void); // TODO: Move to functions.h + void func_806B3420(void) { f32 dx, dy, dz; s32 temp; @@ -414,4 +416,120 @@ void func_806B52DC(void) { func_806319C4(current_actor_pointer, 0); } -#pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_B7490/func_806B54BC.s") +extern f64 D_8075B718; + +s16 func_80665DE0(f32, f32, f32, f32); +void func_80604CBC(Actor*, s32, s32, s32, s32, s32, f32, s32); +s32 func_806CC10C(s16, s16); +s16 func_806119A0(void); + +typedef struct { + f32 unk0; + f32 unk4; + f32 unk8; + f32 unkC; + s16 unk10; + s16 unk12; + s32 unk14; +} Actor178_806B54BC; + +f32 func_806119FC(void); + +void func_806B54BC(void) { + Actor178_806B54BC *temp_s1; + f32 sp68; + f32 sp64; + f32 sp60; + f32 temp_f4; + s16 temp_s0_3; + s32 temp; + + temp_s1 = current_actor_pointer->unk178; + func_80729B00(); + if ((current_actor_pointer->control_state != 0x40) && (current_actor_pointer->control_state != 0x37) && ((D_807FBB70->unk200 == 9) || (D_807FBB70->unk15 != 0))) { + func_80605314(current_actor_pointer, 0); + func_80614EBC(current_actor_pointer, 0x331); + current_actor_pointer->control_state = 0x37; + current_actor_pointer->control_state_progress = 0; + func_80608528(player_pointer, 0x16, 0xFF, 0x7F, 0x1E); + } + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + D_807FDC98->unk46 |= 0x20; + D_807FDC98->unk46 &= 0xFFF7; + current_actor_pointer->unkB8 = 40.0f; + current_actor_pointer->control_state = 0x23; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->unkEC = ((rand() >> 0xF) % 7) + 0xF; + temp_s1->unk0 = current_actor_pointer->x_position; + temp_s1->unk4 = current_actor_pointer->y_position; + temp_s1->unk8 = current_actor_pointer->z_position; + temp_s1->unk10 = 1; + temp_s1->unkC = current_actor_pointer->y_position; + temp_s1->unk12 = (func_806119A0() & 0xFF) + 0x78; + } + if ((current_actor_pointer->control_state != 0x37) && (current_actor_pointer->unk6E == -1)) { + func_80604CBC(current_actor_pointer, 0x10E, 0, 0, 0, 0xFF, 1.0f, 0); + } + switch (current_actor_pointer->control_state) { + case 0x26: + temp_s1->unk0 = player_pointer->x_position; + temp_s1->unk4 = player_pointer->y_position; + temp_s1->unk8 = player_pointer->z_position; + temp_s1->unk12 = (func_806119A0() & 0xFF) + 0x78; + // fallthrough + case 0x23: + temp = func_80665DE0(current_actor_pointer->x_position, current_actor_pointer->z_position, temp_s1->unk0, temp_s1->unk8) + 0x800; + current_actor_pointer->y_rotation -= func_806CC10C(temp, current_actor_pointer->y_rotation) >> 4; + temp_s1->unk10--; + if (temp_s1->unk10 <= 0) { + func_80724B5C(1, 0, &sp68, &sp64, &sp60); + temp_s1->unk10 = (func_806119A0() & 0x3F) + 0xF; + temp_s0_3 = func_80665DE0(sp68, sp60, temp_s1->unk0, temp_s1->unk8); + temp_s0_3 += ((func_806119A0() & 7) << 8) + 0x400; + temp_f4 = func_806119FC() * D_8075B718; + temp_s1->unk0 = func_80612794(temp_s0_3) * temp_f4 + sp68; + temp_s1->unk4 = temp_s1->unkC; + temp_s1->unk8 = func_80612790(temp_s0_3) * temp_f4 + sp60; + current_actor_pointer->control_state = 0x23; + } + if (current_actor_pointer->control_state == 0x23) { + temp_s1->unk12--; + if (temp_s1->unk12 <= 0) { + temp_s1->unk10 = 0x3C; + current_actor_pointer->control_state = 0x26; + } + } + sp64 = (temp_s1->unk4 - current_actor_pointer->y_position) * 0.0625; + if (sp64 > 8.0) { + sp64 = 8.0f; + } + if (sp64 < -8.0) { + sp64 = -8.0f; + } + current_actor_pointer->x_position += func_80612794(current_actor_pointer->y_rotation) * 8.0; + current_actor_pointer->y_position += sp64; + current_actor_pointer->z_position += func_80612790(current_actor_pointer->y_rotation) * 8.0; + break; + case 0x37: + current_actor_pointer->object_properties_bitfield &= ~0x8000; + current_actor_pointer->shadow_opacity -= 8; + current_actor_pointer->y_position = current_actor_pointer->y_position - 10.0; + if (current_actor_pointer->shadow_opacity < 0) { + current_actor_pointer->shadow_opacity = 0; + current_actor_pointer->control_state = 0x40; + current_actor_pointer->control_state_progress = 0; + current_actor_pointer->noclip_byte = 1; + if (current_map == 0xA7) { + enemies_killed++; + if ((enemies_killed == 5) && (isFlagSet(0x15F, 0) == 0)) { + func_8063DA40(4, 0xA); + } + } + } + break; + default: + func_8072B7CC(0x32F); + break; + } + func_806319C4(current_actor_pointer, 0); +} diff --git a/src/global_asm/code_C1E70.c b/src/global_asm/code_C1E70.c index 27fbaa9..0a74456 100644 --- a/src/global_asm/code_C1E70.c +++ b/src/global_asm/code_C1E70.c @@ -21,12 +21,13 @@ typedef struct { /* void func_806BD170(void) { PadlockAAD *temp_v0; - s8 keyIndex; + s16 keyIndex; s16 sp50; s16 temp_s2; sp50 = -1; - for (keyIndex = 0; keyIndex < 8; keyIndex++) { + keyIndex = 0; + for (; keyIndex < 8; keyIndex++) { // Key[keyIndex] Turned Flag if (!isFlagSet(0x1BC + keyIndex, FLAG_TYPE_PERMANENT)) { // Spawn Padlock @@ -47,8 +48,8 @@ void func_806BD170(void) { D_807FBB44->control_state = 0; temp_v0 = D_807FBB44->additional_actor_data; temp_v0->unk0 = 0; - temp_v0->unk2 = keyIndex; temp_v0->unk4 = current_actor_pointer; + temp_v0->unk2 = keyIndex; // Key Collected Flag if (isFlagSet(D_80744710[keyIndex], FLAG_TYPE_PERMANENT)) { sp50 = keyIndex; @@ -73,10 +74,125 @@ void func_806BD170(void) { // Doable, big, interesting #pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C1E70/func_806BD3E4.s") +extern f32 D_807FC8D4; +extern s16 D_8076A0A6; +extern s32 D_807F5D10; +extern s8 D_807506B4; +extern s8 D_807506A8[]; + +s32 areAllKeysTurnedIn(void); + +typedef struct { + s32 unk0; +} Actor178_806BD3E4; + +/* +// TODO: Close... +void func_806BD3E4(void) { + Actor178_806BD3E4 *sp34; + u8 sp2B; + u16 sp28; + s16 sp26; + f32 dx; + f32 dy; + s16 var_t0; + s16 var_v1; + s8 temp_v0_2; + + var_v1 = D_8076A0A6; + sp34 = current_actor_pointer->unk178; + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + if (areAllKeysTurnedIn() != 0) { + current_actor_pointer->control_state = 0x40; + return; + } + current_actor_pointer->draw_distance = 2000; + current_actor_pointer->object_properties_bitfield |= 0x400; + sp26 = 0; + D_807506B4 = 0; + // Spawn Actor (Squawks) + func_80677FA8(0x73, 0xC4); + func_8067B238(D_807FBB44, current_actor_pointer, current_actor_pointer->animation_state->scale_y); + D_807FBB44->unk64 |= 0x20; + D_807FBB44->object_properties_bitfield |= 0x400; + D_807FBB44->draw_distance = 0x7D0; + sp34->unk0 = D_807FBB44; + D_807FC8D4 = 1000.0f; + func_806BD170(); + current_actor_pointer->control_state = 0; + if (D_80750660 != 0) { + D_80750660 = 0; + } + var_v1 = sp26; + if (isFlagSet(0x1BB, 0) == 0) { + current_actor_pointer->control_state = 1; + } + } + var_t0 = -1; + if (var_v1 != 0) { + var_t0 = 0; + if (!(var_v1 & 1)) { + do { + var_v1 = var_v1 >> 1; + var_t0 += 1; + } while (!(var_v1 & 1)); + } + } + dx = current_actor_pointer->x_position - player_pointer->x_position; + dy = current_actor_pointer->z_position - player_pointer->z_position; + sp28 = 0; + D_807FC8D4 = (dx * dx) + (dy * dy); + switch (current_actor_pointer->control_state) { + case 1: + func_80614EBC(current_actor_pointer, 0x2EF); + current_actor_pointer->control_state = 2; + playCutscene(player_pointer, 2, 1); + break; + case 2: + if (func_80629148(current_actor_pointer, 0x2EF) != 0) { + playSong(0x7D, 1.0f); + func_80614EBC(current_actor_pointer, 0x2F1); + current_actor_pointer->control_state = 3; + current_actor_pointer->control_state_progress = 0; + } + break; + case 3: + if (current_actor_pointer->control_state_progress & 1) { + current_actor_pointer->control_state_progress++; + sp28 = 0x28; + sp2B = 0xF; + } + break; + } + if ((func_8061CB50() == 0) && (current_actor_pointer->animation_state->unk64 != 0x2F0)) { + func_80614EBC(current_actor_pointer, 0x2F0); + } + if (sp28 != 0) { + func_8061F0B0(D_807F5D10, sp2B, sp28); + } + if (var_t0 >= 0) { + temp_v0_2 = D_807506B4 + 1; + if (var_t0 == D_807506A8[D_807506B4]) { + D_807506B4 = temp_v0_2; + if (D_807506A8[D_807506B4] == -1) { + playSound(0x1DA, 0x7FFF, 63.0f, 1.0f, 5, 0); + setFlag(0x28, 1, 1); + setFlag(0x26, 1, 1); + D_807506B4 = -1; + } + } else { + D_807506B4 = 0; + } + } + D_8076A0A6 = 0; + func_806319C4(current_actor_pointer, 0); +} +*/ + // Jumptable #pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C1E70/func_806BD7B0.s") -s32 areAllKeysTurnedIn() { +s32 areAllKeysTurnedIn(void) { s32 key; for (key = 0; key < 8; key++) { if (!isFlagSet(key + 0x1BC, FLAG_TYPE_PERMANENT)) { diff --git a/src/global_asm/code_C8C10.c b/src/global_asm/code_C8C10.c index 31524f6..368d85a 100644 --- a/src/global_asm/code_C8C10.c +++ b/src/global_asm/code_C8C10.c @@ -5,6 +5,105 @@ #pragma GLOBAL_ASM("asm/nonmatchings/global_asm/code_C8C10/func_806C3F10.s") +extern f32 D_8075C260; +extern f32 D_8075C264; +extern f32 D_8075C268; +extern s32 D_807F5D10; + +void func_8061C518(s32, Actor*, s32, s32, s32, s32, s32, s32, s32, s32, f32); +void func_8061C464(s32, Actor *, s32, s16, s32, s32, s32, s32, s32, s32, f32); +void func_806B49B0(u8 arg0, s16 arg1, s16 arg2); + +/* +// TODO: Close... +void func_806C3F10(u8 arg0, u8 arg1, u8 arg2) { + Actor178 *var_v1; + // s16 temp_v0; + s32 var_v0; + + var_v1 = current_actor_pointer->unk178; + if (!(current_actor_pointer->object_properties_bitfield & 0x10)) { + D_807FDC98->unk46 |= 0x20; + if (arg2 != 0) { + playCutscene(current_actor_pointer, arg2, 1); + } else { + func_8061C518(D_807F5D10, current_actor_pointer, 4, 0x800, 0x19, 0, 0xA, 0x14, 0xC, 0, D_8075C260); + } + D_807FDC9C->unk10 = 0x27; + current_actor_pointer->control_state = 0x27; + current_actor_pointer->control_state_progress = 0; + } + var_v1->unk0 = MAX(0, D_807FDC90->unkC - D_807FDC9C->unk6); + // temp_v0 = D_807FDC90->unkC - D_807FDC9C->unk6; + // if (temp_v0 < 0) { + // var_v1->unk0 = 0; + // } else { + // var_v1->unk0 = temp_v0; + // } + switch (current_actor_pointer->control_state) { + case 39: + if ((D_807FDC90->unk1A & 4) && (arg0 == (D_807FDC90->unk25 & 0x7F))) { + if (character_change_array->unk2C0 == 0) { + func_8070D8C0(current_actor_pointer, 0x10, 1, current_actor_pointer); + current_actor_pointer->control_state = 0x29; + current_actor_pointer->control_state_progress = 0; + D_807FDC9C->unk10 = 0x29; + extra_player_info_pointer->unk1F0 |= 0x10000; + func_806EB0C0(0x54, NULL, 0); + D_807FDC90->unk1A |= 0x8000; + } else { + func_8070D8C0(current_actor_pointer, 0x10, 0, current_actor_pointer); + current_actor_pointer->control_state = 0x28; + current_actor_pointer->control_state_progress = 0; + D_807FDC9C->unk10 = 0x28; + if (arg2 == 0) { + func_8061C464(D_807F5D10, current_actor_pointer, 4, 0x800, 0x19, 0, 0xA, 0x14, 0xC, 0x78, D_8075C264); + } + } + } + // fallthrough + case 40: + func_806B49B0(2, 0x23D, 0x23E); + return; + case 38: + case 41: + if (D_807FDC90->unk1A & 0x8000) { + if ((D_807FDC90->unk1A & 4) && (arg1 == (D_807FDC90->unk25 & 0x7F))) { + if (arg2 == 0) { + func_806225C0(D_807F5D10); + } + playCutscene(player_pointer, 3, 5); + current_actor_pointer->control_state = 0x28; + current_actor_pointer->control_state_progress = 0; + D_807FDC9C->unk10 = 0x28; + extra_player_info_pointer->unk1F0 &= 0xFFFEFFFF; + D_807FDC90->unk1A &= 0x7FFF; + } else { + if (arg2 == 0) { + func_8061C464(D_807F5D10, player_pointer, 4, object_timer * 0x14, 0x1E, 0, 0xA, 0x1E, 0xC, 0, D_8075C268); + } + player_pointer->y_rotation = current_actor_pointer->y_rotation; + player_pointer->x_position = current_actor_pointer->x_position; + player_pointer->y_position = current_actor_pointer->y_position - 2.0f; + player_pointer->z_position = current_actor_pointer->z_position; + player_pointer->unk6A &= 0xFFFE; + player_pointer->locked_to_pad = 0; + } + } + if (current_actor_pointer->control_state == 0x26) { + var_v0 = 0x26; + } else { + var_v0 = 2; + } + func_806B49B0(var_v0, 0x23D, 0x23E); + // fallthrough + case 0: + return; + } +} +*/ + + void func_806C43A8() { s32 song = 0; switch(current_map) {