From f65c26b900eea925faf47b79dcd32cf11c53e2ab Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Mon, 30 Nov 2020 14:17:51 -0500 Subject: [PATCH] audio WIP --- .../code_2e230_len_2190/func_800533A8.s | 14 - .../code_2e230_len_2190/func_80053AC8.s | 14 - .../code_2e230_len_2190/func_80053AEC.s | 10 - .../code_2e230_len_2190/func_80053F64.s | 12 - src/code_2e230_len_2190.c | 274 +++++++++++++++++- src/code_2e230_len_2190.h | 22 ++ 6 files changed, 285 insertions(+), 61 deletions(-) delete mode 100644 asm/nonmatchings/code_2e230_len_2190/func_800533A8.s delete mode 100644 asm/nonmatchings/code_2e230_len_2190/func_80053AC8.s delete mode 100644 asm/nonmatchings/code_2e230_len_2190/func_80053AEC.s delete mode 100644 asm/nonmatchings/code_2e230_len_2190/func_80053F64.s diff --git a/asm/nonmatchings/code_2e230_len_2190/func_800533A8.s b/asm/nonmatchings/code_2e230_len_2190/func_800533A8.s deleted file mode 100644 index 8047bea254..0000000000 --- a/asm/nonmatchings/code_2e230_len_2190/func_800533A8.s +++ /dev/null @@ -1,14 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_800533A8 -/* 2E7A8 800533A8 24022010 */ addiu $v0, $zero, 0x2010 -/* 2E7AC 800533AC A4820000 */ sh $v0, ($a0) -/* 2E7B0 800533B0 2402007F */ addiu $v0, $zero, 0x7f -/* 2E7B4 800533B4 A0820002 */ sb $v0, 2($a0) -/* 2E7B8 800533B8 24020040 */ addiu $v0, $zero, 0x40 -/* 2E7BC 800533BC A0820003 */ sb $v0, 3($a0) -/* 2E7C0 800533C0 A0800004 */ sb $zero, 4($a0) -/* 2E7C4 800533C4 A0800005 */ sb $zero, 5($a0) -/* 2E7C8 800533C8 03E00008 */ jr $ra -/* 2E7CC 800533CC A0800006 */ sb $zero, 6($a0) diff --git a/asm/nonmatchings/code_2e230_len_2190/func_80053AC8.s b/asm/nonmatchings/code_2e230_len_2190/func_80053AC8.s deleted file mode 100644 index 1d710cf1dc..0000000000 --- a/asm/nonmatchings/code_2e230_len_2190/func_80053AC8.s +++ /dev/null @@ -1,14 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80053AC8 -/* 2EEC8 80053AC8 8482000A */ lh $v0, 0xa($a0) -/* 2EECC 80053ACC 14400005 */ bnez $v0, .L80053AE4 -/* 2EED0 80053AD0 24020001 */ addiu $v0, $zero, 1 -/* 2EED4 80053AD4 94830000 */ lhu $v1, ($a0) -/* 2EED8 80053AD8 A482000A */ sh $v0, 0xa($a0) -/* 2EEDC 80053ADC AC800004 */ sw $zero, 4($a0) -/* 2EEE0 80053AE0 A4830008 */ sh $v1, 8($a0) -.L80053AE4: -/* 2EEE4 80053AE4 03E00008 */ jr $ra -/* 2EEE8 80053AE8 00000000 */ nop diff --git a/asm/nonmatchings/code_2e230_len_2190/func_80053AEC.s b/asm/nonmatchings/code_2e230_len_2190/func_80053AEC.s deleted file mode 100644 index 3f44a2a8a0..0000000000 --- a/asm/nonmatchings/code_2e230_len_2190/func_80053AEC.s +++ /dev/null @@ -1,10 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80053AEC -/* 2EEEC 80053AEC 00051400 */ sll $v0, $a1, 0x10 -/* 2EEF0 80053AF0 AC820010 */ sw $v0, 0x10($a0) -/* 2EEF4 80053AF4 A4850018 */ sh $a1, 0x18($a0) -/* 2EEF8 80053AF8 A480001A */ sh $zero, 0x1a($a0) -/* 2EEFC 80053AFC 03E00008 */ jr $ra -/* 2EF00 80053B00 AC800014 */ sw $zero, 0x14($a0) diff --git a/asm/nonmatchings/code_2e230_len_2190/func_80053F64.s b/asm/nonmatchings/code_2e230_len_2190/func_80053F64.s deleted file mode 100644 index 712603f73d..0000000000 --- a/asm/nonmatchings/code_2e230_len_2190/func_80053F64.s +++ /dev/null @@ -1,12 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80053F64 -/* 2F364 80053F64 14800004 */ bnez $a0, .L80053F78 -/* 2F368 80053F68 0000102D */ daddu $v0, $zero, $zero -/* 2F36C 80053F6C 3C02800A */ lui $v0, %hi(D_8009A5C0) -/* 2F370 80053F70 8C42A5C0 */ lw $v0, %lo(D_8009A5C0)($v0) -/* 2F374 80053F74 8C42006C */ lw $v0, 0x6c($v0) -.L80053F78: -/* 2F378 80053F78 03E00008 */ jr $ra -/* 2F37C 80053F7C 00000000 */ nop diff --git a/src/code_2e230_len_2190.c b/src/code_2e230_len_2190.c index d97c70f1b3..c711636896 100644 --- a/src/code_2e230_len_2190.c +++ b/src/code_2e230_len_2190.c @@ -1,14 +1,250 @@ #include "code_2e230_len_2190.h" +#undef alHeapAlloc + +typedef struct UnkAl0 { + /* 0x00 */ char unk_00[0x18]; + /* 0x18 */ ALHeap* unk_18; +} UnkAl0; + +typedef struct UnkAl6CC { + /* 0x00 */ char unk_00[0x6CC]; +} UnkAl6CC; + +typedef struct UnkAlA9C { + /* 0x00 */ char unk_00[0x4]; + /* 0x04 */ UnkAl6CC* unk_04; + /* 0x08 */ char unk_08[0xA94]; +} UnkAlA9C; + +typedef struct UnkAl48 { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ char unk_08[4]; + /* 0x0C */ u16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ s8 unk_0F; + /* 0x10 */ s8 unk_10; + /* 0x11 */ char unk_11[0x31]; + /* 0x42 */ s8 unk_42; + /* 0x43 */ s8 unk_43; + /* 0x44 */ s8 unk_44; + /* 0x45 */ s8 unk_45; + /* 0x46 */ char unk_46[2]; +} UnkAl48; // size = 0x48 + +typedef struct UnkAl19E0Sub { + /* 0x0 */ s16 unk_0; + /* 0x2 */ s16 unk_2; + /* 0x4 */ s16 unk_4; +} UnkAl19E0Sub; + +typedef struct UnkAl19E0 { + /* 0x0000 */ f32 unk_00; + /* 0x0004 */ s32* unk_04; + /* 0x0008 */ s32* unk_08; + /* 0x000C */ char unk_0C[0x8]; + /* 0x0014 */ alUnk2* unk_14; + /* 0x0018 */ char unk_18[0x24]; + /* 0x003C */ UnkAl19E0Sub* unk_3C; + /* 0x0040 */ s8 unk_40[16]; + /* 0x0050 */ s8 unk_50; + /* 0x0051 */ s8 unk_51; + /* 0x0052 */ s8 unk_52; + /* 0x0053 */ s8 unk_53; + /* 0x0054 */ s32* unk_54; + /* 0x0058 */ s32* unk_58; + /* 0x005C */ s32* unk_5C; + /* 0x0060 */ s32* unk_60; + /* 0x0064 */ s32* unk_64; + /* 0x0068 */ s32* unk_68; + /* 0x006C */ UnkAlA9C* unk_6C; + /* 0x0070 */ s8 unk_70; + /* 0x0071 */ s8 unk_71; + /* 0x0072 */ char unk_72[0x22]; + /* 0x0094 */ s32* unk_94; + /* 0x0098 */ char unk_98[0x8]; + /* 0x00A0 */ s32* unk_A0; + /* 0x00A4 */ s32 unk_A4; + /* 0x00A8 */ s32 unk_A8; + /* 0x00AC */ s32* unk_AC; + /* 0x00B0 */ char unk_B0[0x3C]; + /* 0x00EC */ s32* unk_EC; + /* 0x00F0 */ char unk_F0[0x3FC]; + /* 0x04EC */ s32* unk_4EC; + /* 0x04F0 */ char unk_4F0[0xFC]; + /* 0x05EC */ s32* unk_5EC; + /* 0x05F0 */ char unk_5F0[0x3FC]; + /* 0x09EC */ s32* unk_9EC; + /* 0x09F0 */ char unk_9F0[0x3FC]; + /* 0x0DEC */ s32* unk_DEC; + /* 0x0DF0 */ char unk_DF0[0x3FC]; + /* 0x11EC */ s32* unk_11EC; + /* 0x11F0 */ char unk_11F0[0xFC]; + /* 0x12EC */ s32* unk_12EC; + /* 0x12F0 */ s32* unk_12F0; + /* 0x12F4 */ s32* unk_12F4; + /* 0x12F8 */ s32* unk_12F8; + /* 0x12FC */ s32* unk_12FC; + /* 0x1300 */ s32* unk_1300; + /* 0x1304 */ s32* unk_1304; + /* 0x1308 */ s32* unk_1308; + /* 0x130C */ char unk_130C[0x4]; + /* 0x1310 */ s32** unk_1310; + /* 0x1314 */ char unk_1314[0xC]; + /* 0x1320 */ UnkAl48 unk_1320[24]; +} UnkAl19E0; // size = 0x19E0 + +typedef struct UnkAl834 { + /* 0x00 */ UnkAl19E0* unk_00; + /* 0x04 */ char unk_04[0x830]; +} UnkAl834; + +extern UnkAl0* D_80078E54; +extern UnkAl19E0* D_8009A5C0; +extern UnkAlA9C* D_8009A5CC; +extern UnkAlA9C* D_8009A5FC; +extern UnkAl834* D_8009A628; +extern UnkAl6CC* D_8009A640; +extern UnkAlA9C* D_8009A664; + INCLUDE_ASM(s32, "code_2e230_len_2190", func_80052E30); +void func_800532F4(s32); +void func_80053370(s32); +void func_800533A8(alUnk2*); +void al_LoadINIT(UnkAl19E0*, s32, ALHeap*); +s32 al_CopyFileTableEntry(s16 arg0, s32 arg1, s32* arg2); +void al_LoadPER(UnkAl19E0*, s32*); +void al_LoadPRG(UnkAl19E0*, s32*); +void al_DmaCopy(s32*, s32*, s32); +s32* alHeapAlloc(ALHeap*, s32, s32); + INCLUDE_ASM(s32, "code_2e230_len_2190", func_80052E5C); +/*void func_80052E5C(s32 arg0) { + UnkAl19E0* temp_s4; + s32* temp_v0_2; + ALHeap* alHeap; + s32 i; + s32* subroutine_arg6; + s32* subroutine_arg7; + s32* subroutine_arg8; -INCLUDE_ASM(s32, "code_2e230_len_2190", func_800532F4); + alHeap = D_80078E54->unk_18; + D_8009A5C0 = alHeapAlloc(alHeap, 1, 0x19E0); + temp_s4 = D_8009A5C0; -INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053370); + D_8009A664 = alHeapAlloc(alHeap, 1, 0xA9C); + D_8009A5FC = alHeapAlloc(alHeap, 1, 0xA9C); + D_8009A5CC = alHeapAlloc(alHeap, 1, 0xA9C); + D_8009A640 = alHeapAlloc(alHeap, 1, 0x6CC); + D_8009A628 = alHeapAlloc(alHeap, 1, 0x834); + D_8009A628->unk_00 = D_8009A5C0; + D_8009A664->unk_04 = D_8009A640; -INCLUDE_ASM(s32, "code_2e230_len_2190", func_800533A8); + temp_v0_2 = alHeapAlloc(alHeap, 1, 0x8000); + temp_s4->unk_5C = temp_v0_2[0]; + temp_s4->unk_60 = temp_v0_2[0x1400]; + temp_s4->unk_64 = temp_v0_2[0x1C00]; + temp_s4->unk_68 = temp_v0_2[0x1400]; + + for (i = 0; i < 1; i++) { + temp_s4->unk_6C = alHeapAlloc(alHeap, 1, 0xA9C); + } + + temp_s4->unk_A0 = alHeapAlloc(alHeap, 1, 0x5200); + temp_s4->unk_04 = alHeapAlloc(alHeap, 1, 0x30); + temp_s4->unk_54 = alHeapAlloc(alHeap, 1, 0x360); + temp_s4->unk_58 = alHeapAlloc(alHeap, 1, 0x200); + temp_s4->unk_94 = alHeapAlloc(alHeap, 1, 0x40); + temp_s4->unk_00 = arg0; + func_800532F4(temp_s4->unk_04); + func_80053370(temp_s4->unk_08); + func_800533A8(temp_s4->unk_14); + func_8005610C(); + temp_s4->unk_A4 = 0; + temp_s4->unk_A8 = 0; + + for (i = 0; i < 1; i++) { + temp_s4->unk_70 = 0; + temp_s4->unk_71 = 0; + } + + for (i = 0; i < 4; i++) { + temp_s4->unk_40[i * 4 + 0] = 0; + temp_s4->unk_40[i * 4 + 1] = 0; + } + + for (i = 0; i < 24; i++) { + func_80056EC0(i, 0); + func_80057224(i, temp_s4->unk_04); + temp_s4->unk_1320[i].unk_00 = 0; + temp_s4->unk_1320[i].unk_04 = 0; + temp_s4->unk_1320[i].unk_0C = -1; + temp_s4->unk_1320[i].unk_0E = 0xFF; + temp_s4->unk_1320[i].unk_0F = 0xFF; + temp_s4->unk_1320[i].unk_10 = 0; + temp_s4->unk_1320[i].unk_42 = 0; + temp_s4->unk_1320[i].unk_43 = 0; + temp_s4->unk_1320[i].unk_44 = 0; + temp_s4->unk_1320[i].unk_45 = 0; + } + + al_LoadINIT(temp_s4, 0xF00000, alHeap); + + for (i = 0; i < 3; i++) { + temp_s4->unk_1310[i] = alHeapAlloc(alHeap, 1, 0x840); + } + + func_8004E158(D_8009A664, 1, 0, temp_s4); + func_8004E344(D_8009A664, &subroutine_arg8, 0, 3, 0xFF, 0xFF); + func_8004E158(D_8009A5FC, 2, 2, temp_s4); + func_8004E344(D_8009A5FC, &subroutine_arg8, 2, 0xFF, 0xFF, 0xFF); + func_8004B440(D_8009A640, 4, 1, temp_s4, 0x10); + func_80050B90(D_8009A628, 6, 1, temp_s4); + func_80052614(temp_s4); + al_LoadBKHeaders(temp_s4, alHeap); + if (al_CopyFileTableEntry(temp_s4->unk_3C->unk_0, 0x20, &subroutine_arg6) == 0) { + al_DmaCopy(subroutine_arg6, temp_s4->unk_A0, *subroutine_arg7 & 0xFFFFFF); + } + func_8004B62C(D_8009A640); + if (al_CopyFileTableEntry(temp_s4->unk_3C->unk_2, 0x40, &subroutine_arg6) == 0) { + al_LoadPER(temp_s4, subroutine_arg6); + } + if (al_CopyFileTableEntry(temp_s4->unk_3C->unk_4, 0x40, &subroutine_arg6) == 0) { + al_LoadPRG(temp_s4, subroutine_arg6); + } + + temp_s4->unk_12F0 = temp_s4->unk_5EC; + temp_s4->unk_12F4 = temp_s4->unk_AC; + temp_s4->unk_12F8 = temp_s4->unk_EC; + temp_s4->unk_12FC = temp_s4->unk_9EC; + temp_s4->unk_1300 = temp_s4->unk_DEC; + temp_s4->unk_12EC = temp_s4->unk_4EC; + temp_s4->unk_1304 = temp_s4->unk_11EC; + temp_s4->unk_1308 = temp_s4->unk_4EC; + temp_s4->unk_53 = 0; + temp_s4->unk_52 = 0; + temp_s4->unk_51 = 0; + temp_s4->unk_50 = 0; + + func_80057ED0(0); + func_80055050(alHeap); +}*/ + +INCLUDE_ASM(void, "code_2e230_len_2190", func_800532F4, s32 arg0); + +INCLUDE_ASM(void, "code_2e230_len_2190", func_80053370, s32 arg0); + +//INCLUDE_ASM(s32, "code_2e230_len_2190", func_800533A8); +void func_800533A8(alUnk2* arg0) { + arg0->unk_00 = 8208; + arg0->unk_02 = ~128; + arg0->unk_03 = 64; + arg0->unk_04 = 0; + arg0->unk_05 = 0; + arg0->unk_06 = 0; +} INCLUDE_ASM(s32, "code_2e230_len_2190", func_800533D0); @@ -34,9 +270,20 @@ INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053A28); INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053A98); -INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053AC8); +void func_80053AC8(alUnk1* arg0) { + if (arg0->unk_0A == 0) { + arg0->unk_0A = 1; + arg0->unk_04 = 0; + arg0->unk_08 = arg0->unk_00; + } +} -INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053AEC); +void func_80053AEC(alUnk1* arg0, s16 arg1) { + arg0->unk_10 = arg1 << 16; + arg0->unk_18 = arg1; + arg0->unk_1A = 0; + arg0->unk_14 = 0; +} INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053B04); @@ -52,19 +299,24 @@ INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053CF8); INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053E58); -INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053F64); +s32 func_80053F64(s32 arg0) { + if (arg0 == 0) { + return D_8009A5C0->unk_6C; // 0x6C + } + return 0; +} INCLUDE_ASM(s32, "code_2e230_len_2190", func_80053F80); INCLUDE_ASM(s32, "code_2e230_len_2190", func_80054248); -INCLUDE_ASM(s32, "code_2e230_len_2190", al_LoadINIT); +INCLUDE_ASM(void, "code_2e230_len_2190", al_LoadINIT, UnkAl19E0* arg0, s32 arg1, ALHeap* arg2); -INCLUDE_ASM(s32, "code_2e230_len_2190", al_CopyFileTableEntry); +INCLUDE_ASM(s32, "code_2e230_len_2190", al_CopyFileTableEntry, s16 arg0, s32 arg1, s32* arg2); -INCLUDE_ASM(s32, "code_2e230_len_2190", al_LoadPER); +INCLUDE_ASM(void, "code_2e230_len_2190", al_LoadPER, UnkAl19E0* arg0, s32* arg1); -INCLUDE_ASM(s32, "code_2e230_len_2190", al_LoadPRG); +INCLUDE_ASM(void, "code_2e230_len_2190", al_LoadPRG, UnkAl19E0* arg0, s32* arg1); INCLUDE_ASM(s32, "code_2e230_len_2190", func_8005465C); @@ -86,7 +338,7 @@ INCLUDE_ASM(s32, "code_2e230_len_2190", func_80054D74); INCLUDE_ASM(s32, "code_2e230_len_2190", func_80054DA8); -INCLUDE_ASM(s32, "code_2e230_len_2190", al_DmaCopy); +INCLUDE_ASM(void, "code_2e230_len_2190", al_DmaCopy, s32* arg0, s32* arg1, s32 arg2); INCLUDE_ASM(s32, "code_2e230_len_2190", func_80054E90); diff --git a/src/code_2e230_len_2190.h b/src/code_2e230_len_2190.h index 5b3dc33da0..1198ac2d48 100644 --- a/src/code_2e230_len_2190.h +++ b/src/code_2e230_len_2190.h @@ -12,6 +12,28 @@ typedef struct UnkStructFor80053A18 { /* 0x0C */ s32 unk_0C; } UnkStructFor80053A18; // size unknown +typedef struct alUnk1 { + /* 0x00 */ s16 unk_00; + /* 0x02 */ char unk_02[2]; + /* 0x04 */ s32 unk_04; + /* 0x08 */ s16 unk_08; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ char unk_0C[4]; + /* 0x10 */ s32 unk_10; + /* 0x14 */ s32 unk_14; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; +} alUnk1; + +typedef struct alUnk2 { + /* 0x00 */ s16 unk_00; + /* 0x02 */ u8 unk_02; + /* 0x03 */ s8 unk_03; + /* 0x04 */ s8 unk_04; + /* 0x05 */ s8 unk_05; + /* 0x06 */ s8 unk_06; +} alUnk2; + void func_80053A18(UnkStructFor80053A18* arg0); #endif