diff --git a/asm/bss_MainSeg_2.s b/asm/bss_libultra.s similarity index 100% rename from asm/bss_MainSeg_2.s rename to asm/bss_libultra.s diff --git a/asm/audio/synthesis.s b/asm/non_matchings/audio/synthesis.s similarity index 86% rename from asm/audio/synthesis.s rename to asm/non_matchings/audio/synthesis.s index 44cf1fb92..c897a5294 100644 --- a/asm/audio/synthesis.s +++ b/asm/non_matchings/audio/synthesis.s @@ -1,276 +1,4 @@ -# Mario Kart 64 (U) disassembly and split file -# generated by n64split v0.4a - N64 ROM splitter - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - -.section .text, "ax" - -glabel func_800B6BF0 -/* 0B77F0 800B6BF0 00067140 */ sll $t6, $a2, 5 -/* 0B77F4 800B6BF4 01C67021 */ addu $t6, $t6, $a2 -/* 0B77F8 800B6BF8 3C0F803B */ lui $t7, %hi(D_803AF790) # $t7, 0x803b -/* 0B77FC 800B6BFC 25EFF790 */ addiu $t7, %lo(D_803AF790) # addiu $t7, $t7, -0x870 -/* 0B7800 800B6C00 000E70C0 */ sll $t6, $t6, 3 -/* 0B7804 800B6C04 01CF3821 */ addu $a3, $t6, $t7 -/* 0B7808 800B6C08 90F80004 */ lbu $t8, 4($a3) -/* 0B780C 800B6C0C 27BDFFC0 */ addiu $sp, $sp, -0x40 -/* 0B7810 800B6C10 24010001 */ li $at, 1 -/* 0B7814 800B6C14 AFBF0014 */ sw $ra, 0x14($sp) -/* 0B7818 800B6C18 AFA40040 */ sw $a0, 0x40($sp) -/* 0B781C 800B6C1C 13010062 */ beq $t8, $at, .L800B6DA8 -/* 0B7820 800B6C20 AFA50044 */ sw $a1, 0x44($sp) -/* 0B7824 800B6C24 90F90002 */ lbu $t9, 2($a3) -/* 0B7828 800B6C28 00056080 */ sll $t4, $a1, 2 -/* 0B782C 800B6C2C 01856021 */ addu $t4, $t4, $a1 -/* 0B7830 800B6C30 5720005E */ bnel $t9, $zero, .L800B6DAC -/* 0B7834 800B6C34 90E90004 */ lbu $t1, 4($a3) -/* 0B7838 800B6C38 90E80003 */ lbu $t0, 3($a3) -/* 0B783C 800B6C3C 000C6080 */ sll $t4, $t4, 2 -/* 0B7840 800B6C40 24050300 */ li $a1, 768 -/* 0B7844 800B6C44 00084880 */ sll $t1, $t0, 2 -/* 0B7848 800B6C48 01284823 */ subu $t1, $t1, $t0 -/* 0B784C 800B6C4C 000948C0 */ sll $t1, $t1, 3 -/* 0B7850 800B6C50 01284821 */ addu $t1, $t1, $t0 -/* 0B7854 800B6C54 00094880 */ sll $t1, $t1, 2 -/* 0B7858 800B6C58 00E95021 */ addu $t2, $a3, $t1 -/* 0B785C 800B6C5C 014C3021 */ addu $a2, $t2, $t4 -/* 0B7860 800B6C60 24C60030 */ addiu $a2, $a2, 0x30 -/* 0B7864 800B6C64 8CC40004 */ lw $a0, 4($a2) -/* 0B7868 800B6C68 AFA70018 */ sw $a3, 0x18($sp) -/* 0B786C 800B6C6C 0C0336E0 */ jal osInvalDCache -/* 0B7870 800B6C70 AFA6003C */ sw $a2, 0x3c($sp) -/* 0B7874 800B6C74 8FA6003C */ lw $a2, 0x3c($sp) -/* 0B7878 800B6C78 8FA70018 */ lw $a3, 0x18($sp) -/* 0B787C 800B6C7C 00002825 */ move $a1, $zero -/* 0B7880 800B6C80 84CD0010 */ lh $t5, 0x10($a2) -/* 0B7884 800B6C84 00002025 */ move $a0, $zero -/* 0B7888 800B6C88 05A10003 */ bgez $t5, .L800B6C98 -/* 0B788C 800B6C8C 000D7043 */ sra $t6, $t5, 1 -/* 0B7890 800B6C90 25A10001 */ addiu $at, $t5, 1 -/* 0B7894 800B6C94 00017043 */ sra $t6, $at, 1 -.L800B6C98: -/* 0B7898 800B6C98 59C00023 */ blezl $t6, .L800B6D28 -/* 0B789C 800B6C9C 84CE0012 */ lh $t6, 0x12($a2) -/* 0B78A0 800B6CA0 00001025 */ move $v0, $zero -/* 0B78A4 800B6CA4 8CCF0004 */ lw $t7, 4($a2) -.L800B6CA8: -/* 0B78A8 800B6CA8 8CC9000C */ lw $t1, 0xc($a2) -/* 0B78AC 800B6CAC 8CE80018 */ lw $t0, 0x18($a3) -/* 0B78B0 800B6CB0 00051840 */ sll $v1, $a1, 1 -/* 0B78B4 800B6CB4 01E3C021 */ addu $t8, $t7, $v1 -/* 0B78B8 800B6CB8 87190000 */ lh $t9, ($t8) -/* 0B78BC 800B6CBC 00095840 */ sll $t3, $t1, 1 -/* 0B78C0 800B6CC0 010B5021 */ addu $t2, $t0, $t3 -/* 0B78C4 800B6CC4 01426021 */ addu $t4, $t2, $v0 -/* 0B78C8 800B6CC8 A5990000 */ sh $t9, ($t4) -/* 0B78CC 800B6CCC 8CCD0008 */ lw $t5, 8($a2) -/* 0B78D0 800B6CD0 8CC9000C */ lw $t1, 0xc($a2) -/* 0B78D4 800B6CD4 8CF8001C */ lw $t8, 0x1c($a3) -/* 0B78D8 800B6CD8 01A37021 */ addu $t6, $t5, $v1 -/* 0B78DC 800B6CDC 85CF0000 */ lh $t7, ($t6) -/* 0B78E0 800B6CE0 00094040 */ sll $t0, $t1, 1 -/* 0B78E4 800B6CE4 03085821 */ addu $t3, $t8, $t0 -/* 0B78E8 800B6CE8 01625021 */ addu $t2, $t3, $v0 -/* 0B78EC 800B6CEC A54F0000 */ sh $t7, ($t2) -/* 0B78F0 800B6CF0 84CC0010 */ lh $t4, 0x10($a2) -/* 0B78F4 800B6CF4 90F90004 */ lbu $t9, 4($a3) -/* 0B78F8 800B6CF8 24840001 */ addiu $a0, $a0, 1 -/* 0B78FC 800B6CFC 24420002 */ addiu $v0, $v0, 2 -/* 0B7900 800B6D00 00B92821 */ addu $a1, $a1, $t9 -/* 0B7904 800B6D04 05810003 */ bgez $t4, .L800B6D14 -/* 0B7908 800B6D08 000C6843 */ sra $t5, $t4, 1 -/* 0B790C 800B6D0C 25810001 */ addiu $at, $t4, 1 -/* 0B7910 800B6D10 00016843 */ sra $t5, $at, 1 -.L800B6D14: -/* 0B7914 800B6D14 008D082A */ slt $at, $a0, $t5 -/* 0B7918 800B6D18 5420FFE3 */ bnel $at, $zero, .L800B6CA8 -/* 0B791C 800B6D1C 8CCF0004 */ lw $t7, 4($a2) -/* 0B7920 800B6D20 00002025 */ move $a0, $zero -/* 0B7924 800B6D24 84CE0012 */ lh $t6, 0x12($a2) -.L800B6D28: -/* 0B7928 800B6D28 05C10003 */ bgez $t6, .L800B6D38 -/* 0B792C 800B6D2C 000E4843 */ sra $t1, $t6, 1 -/* 0B7930 800B6D30 25C10001 */ addiu $at, $t6, 1 -/* 0B7934 800B6D34 00014843 */ sra $t1, $at, 1 -.L800B6D38: -/* 0B7938 800B6D38 5920001C */ blezl $t1, .L800B6DAC -/* 0B793C 800B6D3C 90E90004 */ lbu $t1, 4($a3) -/* 0B7940 800B6D40 00001025 */ move $v0, $zero -/* 0B7944 800B6D44 8CD80004 */ lw $t8, 4($a2) -.L800B6D48: -/* 0B7948 800B6D48 00051840 */ sll $v1, $a1, 1 -/* 0B794C 800B6D4C 8CEF0018 */ lw $t7, 0x18($a3) -/* 0B7950 800B6D50 03034021 */ addu $t0, $t8, $v1 -/* 0B7954 800B6D54 850B0000 */ lh $t3, ($t0) -/* 0B7958 800B6D58 01E25021 */ addu $t2, $t7, $v0 -/* 0B795C 800B6D5C 24840001 */ addiu $a0, $a0, 1 -/* 0B7960 800B6D60 A54B0000 */ sh $t3, ($t2) -/* 0B7964 800B6D64 8CD90008 */ lw $t9, 8($a2) -/* 0B7968 800B6D68 8CEE001C */ lw $t6, 0x1c($a3) -/* 0B796C 800B6D6C 03236021 */ addu $t4, $t9, $v1 -/* 0B7970 800B6D70 858D0000 */ lh $t5, ($t4) -/* 0B7974 800B6D74 01C24821 */ addu $t1, $t6, $v0 -/* 0B7978 800B6D78 24420002 */ addiu $v0, $v0, 2 -/* 0B797C 800B6D7C A52D0000 */ sh $t5, ($t1) -/* 0B7980 800B6D80 84C80012 */ lh $t0, 0x12($a2) -/* 0B7984 800B6D84 90F80004 */ lbu $t8, 4($a3) -/* 0B7988 800B6D88 00B82821 */ addu $a1, $a1, $t8 -/* 0B798C 800B6D8C 05010003 */ bgez $t0, .L800B6D9C -/* 0B7990 800B6D90 00087843 */ sra $t7, $t0, 1 -/* 0B7994 800B6D94 25010001 */ addiu $at, $t0, 1 -/* 0B7998 800B6D98 00017843 */ sra $t7, $at, 1 -.L800B6D9C: -/* 0B799C 800B6D9C 008F082A */ slt $at, $a0, $t7 -/* 0B79A0 800B6DA0 5420FFE9 */ bnel $at, $zero, .L800B6D48 -/* 0B79A4 800B6DA4 8CD80004 */ lw $t8, 4($a2) -.L800B6DA8: -/* 0B79A8 800B6DA8 90E90004 */ lbu $t1, 4($a3) -.L800B6DAC: -/* 0B79AC 800B6DAC 8FAD0040 */ lw $t5, 0x40($sp) -/* 0B79B0 800B6DB0 90EB0003 */ lbu $t3, 3($a3) -/* 0B79B4 800B6DB4 8FAC0044 */ lw $t4, 0x44($sp) -/* 0B79B8 800B6DB8 01A9001A */ div $zero, $t5, $t1 -/* 0B79BC 800B6DBC 000B5080 */ sll $t2, $t3, 2 -/* 0B79C0 800B6DC0 8CF8000C */ lw $t8, 0xc($a3) -/* 0B79C4 800B6DC4 014B5023 */ subu $t2, $t2, $t3 -/* 0B79C8 800B6DC8 8CEF0014 */ lw $t7, 0x14($a3) -/* 0B79CC 800B6DCC 000A50C0 */ sll $t2, $t2, 3 -/* 0B79D0 800B6DD0 00001012 */ mflo $v0 -/* 0B79D4 800B6DD4 014B5021 */ addu $t2, $t2, $t3 -/* 0B79D8 800B6DD8 000C7080 */ sll $t6, $t4, 2 -/* 0B79DC 800B6DDC 000A5080 */ sll $t2, $t2, 2 -/* 0B79E0 800B6DE0 01CC7021 */ addu $t6, $t6, $t4 -/* 0B79E4 800B6DE4 03024021 */ addu $t0, $t8, $v0 -/* 0B79E8 800B6DE8 000E7080 */ sll $t6, $t6, 2 -/* 0B79EC 800B6DEC 00EAC821 */ addu $t9, $a3, $t2 -/* 0B79F0 800B6DF0 010F1823 */ subu $v1, $t0, $t7 -/* 0B79F4 800B6DF4 032E3021 */ addu $a2, $t9, $t6 -/* 0B79F8 800B6DF8 24C60030 */ addiu $a2, $a2, 0x30 -/* 0B79FC 800B6DFC 15200002 */ bnez $t1, .L800B6E08 -/* 0B7A00 800B6E00 00000000 */ nop -/* 0B7A04 800B6E04 0007000D */ break 7 -.L800B6E08: -/* 0B7A08 800B6E08 2401FFFF */ li $at, -1 -/* 0B7A0C 800B6E0C 15210004 */ bne $t1, $at, .L800B6E20 -/* 0B7A10 800B6E10 3C018000 */ lui $at, 0x8000 -/* 0B7A14 800B6E14 15A10002 */ bne $t5, $at, .L800B6E20 -/* 0B7A18 800B6E18 00000000 */ nop -/* 0B7A1C 800B6E1C 0006000D */ break 6 -.L800B6E20: -/* 0B7A20 800B6E20 00437023 */ subu $t6, $v0, $v1 -/* 0B7A24 800B6E24 0461000A */ bgez $v1, .L800B6E50 -/* 0B7A28 800B6E28 00034840 */ sll $t1, $v1, 1 -/* 0B7A2C 800B6E2C 00025840 */ sll $t3, $v0, 1 -/* 0B7A30 800B6E30 A4CB0010 */ sh $t3, 0x10($a2) -/* 0B7A34 800B6E34 A4C00012 */ sh $zero, 0x12($a2) -/* 0B7A38 800B6E38 8CEA000C */ lw $t2, 0xc($a3) -/* 0B7A3C 800B6E3C ACCA000C */ sw $t2, 0xc($a2) -/* 0B7A40 800B6E40 8CEC000C */ lw $t4, 0xc($a3) -/* 0B7A44 800B6E44 0182C821 */ addu $t9, $t4, $v0 -/* 0B7A48 800B6E48 10000007 */ b .L800B6E68 -/* 0B7A4C 800B6E4C ACF9000C */ sw $t9, 0xc($a3) -.L800B6E50: -/* 0B7A50 800B6E50 000E6840 */ sll $t5, $t6, 1 -/* 0B7A54 800B6E54 A4CD0010 */ sh $t5, 0x10($a2) -/* 0B7A58 800B6E58 A4C90012 */ sh $t1, 0x12($a2) -/* 0B7A5C 800B6E5C 8CF8000C */ lw $t8, 0xc($a3) -/* 0B7A60 800B6E60 ACD8000C */ sw $t8, 0xc($a2) -/* 0B7A64 800B6E64 ACE3000C */ sw $v1, 0xc($a3) -.L800B6E68: -/* 0B7A68 800B6E68 A4C20000 */ sh $v0, ($a2) -/* 0B7A6C 800B6E6C 8FA80040 */ lw $t0, 0x40($sp) -/* 0B7A70 800B6E70 A4C80002 */ sh $t0, 2($a2) -/* 0B7A74 800B6E74 8FBF0014 */ lw $ra, 0x14($sp) -/* 0B7A78 800B6E78 27BD0040 */ addiu $sp, $sp, 0x40 -/* 0B7A7C 800B6E7C 03E00008 */ jr $ra -/* 0B7A80 800B6E80 00000000 */ nop - -glabel func_800B6E84 -/* 0B7A84 800B6E84 00074103 */ sra $t0, $a3, 4 -/* 0B7A88 800B6E88 AFA50004 */ sw $a1, 4($sp) -/* 0B7A8C 800B6E8C 00A07025 */ move $t6, $a1 -/* 0B7A90 800B6E90 311800FF */ andi $t8, $t0, 0xff -/* 0B7A94 800B6E94 01C02825 */ move $a1, $t6 -/* 0B7A98 800B6E98 AFA60008 */ sw $a2, 8($sp) -/* 0B7A9C 800B6E9C 30CFFFFF */ andi $t7, $a2, 0xffff -/* 0B7AA0 800B6EA0 0018CC00 */ sll $t9, $t8, 0x10 -/* 0B7AA4 800B6EA4 3C011400 */ lui $at, 0x1400 -/* 0B7AA8 800B6EA8 01E03025 */ move $a2, $t7 -/* 0B7AAC 800B6EAC 03214025 */ or $t0, $t9, $at -/* 0B7AB0 800B6EB0 31CEFFFF */ andi $t6, $t6, 0xffff -/* 0B7AB4 800B6EB4 010E7825 */ or $t7, $t0, $t6 -/* 0B7AB8 800B6EB8 AC8F0000 */ sw $t7, ($a0) -/* 0B7ABC 800B6EBC 8FB80010 */ lw $t8, 0x10($sp) -/* 0B7AC0 800B6EC0 3C0D803B */ lui $t5, %hi(D_803AF790) # $t5, 0x803b -/* 0B7AC4 800B6EC4 25ADF790 */ addiu $t5, %lo(D_803AF790) # addiu $t5, $t5, -0x870 -/* 0B7AC8 800B6EC8 0018C940 */ sll $t9, $t8, 5 -/* 0B7ACC 800B6ECC 0338C821 */ addu $t9, $t9, $t8 -/* 0B7AD0 800B6ED0 0019C8C0 */ sll $t9, $t9, 3 -/* 0B7AD4 800B6ED4 032D4821 */ addu $t1, $t9, $t5 -/* 0B7AD8 800B6ED8 8D2E0018 */ lw $t6, 0x18($t1) -/* 0B7ADC 800B6EDC 00065040 */ sll $t2, $a2, 1 -/* 0B7AE0 800B6EE0 3C0C8000 */ lui $t4, 0x8000 -/* 0B7AE4 800B6EE4 24B90180 */ addiu $t9, $a1, 0x180 -/* 0B7AE8 800B6EE8 01CA7821 */ addu $t7, $t6, $t2 -/* 0B7AEC 800B6EEC 01ECC021 */ addu $t8, $t7, $t4 -/* 0B7AF0 800B6EF0 332DFFFF */ andi $t5, $t9, 0xffff -/* 0B7AF4 800B6EF4 AC980004 */ sw $t8, 4($a0) -/* 0B7AF8 800B6EF8 248B0008 */ addiu $t3, $a0, 8 -/* 0B7AFC 800B6EFC 010D7025 */ or $t6, $t0, $t5 -/* 0B7B00 800B6F00 AD6E0000 */ sw $t6, ($t3) -/* 0B7B04 800B6F04 8D2F001C */ lw $t7, 0x1c($t1) -/* 0B7B08 800B6F08 25620008 */ addiu $v0, $t3, 8 -/* 0B7B0C 800B6F0C 01EAC021 */ addu $t8, $t7, $t2 -/* 0B7B10 800B6F10 030CC821 */ addu $t9, $t8, $t4 -/* 0B7B14 800B6F14 03E00008 */ jr $ra -/* 0B7B18 800B6F18 AD790004 */ sw $t9, 4($t3) - -glabel func_800B6F1C -/* 0B7B1C 800B6F1C 00074103 */ sra $t0, $a3, 4 -/* 0B7B20 800B6F20 AFA50004 */ sw $a1, 4($sp) -/* 0B7B24 800B6F24 00A07025 */ move $t6, $a1 -/* 0B7B28 800B6F28 311800FF */ andi $t8, $t0, 0xff -/* 0B7B2C 800B6F2C 01C02825 */ move $a1, $t6 -/* 0B7B30 800B6F30 AFA60008 */ sw $a2, 8($sp) -/* 0B7B34 800B6F34 30CFFFFF */ andi $t7, $a2, 0xffff -/* 0B7B38 800B6F38 0018CC00 */ sll $t9, $t8, 0x10 -/* 0B7B3C 800B6F3C 3C011500 */ lui $at, 0x1500 -/* 0B7B40 800B6F40 01E03025 */ move $a2, $t7 -/* 0B7B44 800B6F44 03214025 */ or $t0, $t9, $at -/* 0B7B48 800B6F48 31CEFFFF */ andi $t6, $t6, 0xffff -/* 0B7B4C 800B6F4C 010E7825 */ or $t7, $t0, $t6 -/* 0B7B50 800B6F50 AC8F0000 */ sw $t7, ($a0) -/* 0B7B54 800B6F54 8FB80010 */ lw $t8, 0x10($sp) -/* 0B7B58 800B6F58 3C0D803B */ lui $t5, %hi(D_803AF790) # $t5, 0x803b -/* 0B7B5C 800B6F5C 25ADF790 */ addiu $t5, %lo(D_803AF790) # addiu $t5, $t5, -0x870 -/* 0B7B60 800B6F60 0018C940 */ sll $t9, $t8, 5 -/* 0B7B64 800B6F64 0338C821 */ addu $t9, $t9, $t8 -/* 0B7B68 800B6F68 0019C8C0 */ sll $t9, $t9, 3 -/* 0B7B6C 800B6F6C 032D4821 */ addu $t1, $t9, $t5 -/* 0B7B70 800B6F70 8D2E0018 */ lw $t6, 0x18($t1) -/* 0B7B74 800B6F74 00065040 */ sll $t2, $a2, 1 -/* 0B7B78 800B6F78 3C0C8000 */ lui $t4, 0x8000 -/* 0B7B7C 800B6F7C 24B90180 */ addiu $t9, $a1, 0x180 -/* 0B7B80 800B6F80 01CA7821 */ addu $t7, $t6, $t2 -/* 0B7B84 800B6F84 01ECC021 */ addu $t8, $t7, $t4 -/* 0B7B88 800B6F88 332DFFFF */ andi $t5, $t9, 0xffff -/* 0B7B8C 800B6F8C AC980004 */ sw $t8, 4($a0) -/* 0B7B90 800B6F90 248B0008 */ addiu $t3, $a0, 8 -/* 0B7B94 800B6F94 010D7025 */ or $t6, $t0, $t5 -/* 0B7B98 800B6F98 AD6E0000 */ sw $t6, ($t3) -/* 0B7B9C 800B6F9C 8D2F001C */ lw $t7, 0x1c($t1) -/* 0B7BA0 800B6FA0 25620008 */ addiu $v0, $t3, 8 -/* 0B7BA4 800B6FA4 01EAC021 */ addu $t8, $t7, $t2 -/* 0B7BA8 800B6FA8 030CC821 */ addu $t9, $t8, $t4 -/* 0B7BAC 800B6FAC 03E00008 */ jr $ra -/* 0B7BB0 800B6FB0 AD790004 */ sw $t9, 4($t3) - -glabel func_800B6FB4 +glabel synthesis_load_note_subs_eu /* 0B7BB4 800B6FB4 3C06803B */ lui $a2, %hi(D_803B7088) # $a2, 0x803b /* 0B7BB8 800B6FB8 24C67088 */ addiu $a2, %lo(D_803B7088) # addiu $a2, $a2, 0x7088 /* 0B7BBC 800B6FBC 84CE000C */ lh $t6, 0xc($a2) @@ -279,8 +7,8 @@ glabel func_800B6FB4 /* 0B7BC8 800B6FC8 004E082A */ slt $at, $v0, $t6 /* 0B7BCC 800B6FCC 10200017 */ beqz $at, .L800B702C /* 0B7BD0 800B6FD0 3C07803B */ lui $a3, %hi(D_803B70B0) # $a3, 0x803b -/* 0B7BD4 800B6FD4 3C05803B */ lui $a1, %hi(D_803AFBC4) # $a1, 0x803b -/* 0B7BD8 800B6FD8 24A5FBC4 */ addiu $a1, %lo(D_803AFBC4) # addiu $a1, $a1, -0x43c +/* 0B7BD4 800B6FD4 3C05803B */ lui $a1, %hi(gNoteSubsEu) # $a1, 0x803b +/* 0B7BD8 800B6FD8 24A5FBC4 */ addiu $a1, %lo(gNoteSubsEu) # addiu $a1, $a1, -0x43c /* 0B7BDC 800B6FDC 24E770B0 */ addiu $a3, %lo(D_803B70B0) # addiu $a3, $a3, 0x70b0 /* 0B7BE0 800B6FE0 8CF80000 */ lw $t8, ($a3) .L800B6FE4: @@ -314,10 +42,10 @@ glabel func_800B7034 /* 0B7C44 800B7044 00001025 */ move $v0, $zero /* 0B7C48 800B7048 18600026 */ blez $v1, .L800B70E4 /* 0B7C4C 800B704C 00002825 */ move $a1, $zero -/* 0B7C50 800B7050 3C0A803B */ lui $t2, %hi(D_803AFBC4) # $t2, 0x803b +/* 0B7C50 800B7050 3C0A803B */ lui $t2, %hi(gNoteSubsEu) # $t2, 0x803b /* 0B7C54 800B7054 3C09803B */ lui $t1, %hi(D_803B1508) # $t1, 0x803b /* 0B7C58 800B7058 25291508 */ addiu $t1, %lo(D_803B1508) # addiu $t1, $t1, 0x1508 -/* 0B7C5C 800B705C 254AFBC4 */ addiu $t2, %lo(D_803AFBC4) # addiu $t2, $t2, -0x43c +/* 0B7C5C 800B705C 254AFBC4 */ addiu $t2, %lo(gNoteSubsEu) # addiu $t2, $t2, -0x43c .L800B7060: /* 0B7C60 800B7060 00670019 */ multu $v1, $a3 /* 0B7C64 800B7064 8D2E0000 */ lw $t6, ($t1) @@ -433,22 +161,22 @@ glabel func_800B70EC /* 0B7DEC 800B71EC 00609825 */ move $s3, $v1 /* 0B7DF0 800B71F0 86B3000E */ lh $s3, 0xe($s5) .L800B71F4: -/* 0B7DF4 800B71F4 3C02803B */ lui $v0, %hi(D_803AFBC3) # $v0, 0x803b -/* 0B7DF8 800B71F8 8042FBC3 */ lb $v0, %lo(D_803AFBC3)($v0) +/* 0B7DF4 800B71F4 3C02803B */ lui $v0, %hi(gNumSynthesisReverbs) # $v0, 0x803b +/* 0B7DF8 800B71F8 8042FBC3 */ lb $v0, %lo(gNumSynthesisReverbs)($v0) /* 0B7DFC 800B71FC 58400012 */ blezl $v0, .L800B7248 /* 0B7E00 800B7200 02E02025 */ move $a0, $s7 -/* 0B7E04 800B7204 3C10803B */ lui $s0, %hi(D_803AF790) # $s0, 0x803b -/* 0B7E08 800B7208 2610F790 */ addiu $s0, %lo(D_803AF790) # addiu $s0, $s0, -0x870 +/* 0B7E04 800B7204 3C10803B */ lui $s0, %hi(gSynthesisReverbs) # $s0, 0x803b +/* 0B7E08 800B7208 2610F790 */ addiu $s0, %lo(gSynthesisReverbs) # addiu $s0, $s0, -0x870 .L800B720C: /* 0B7E0C 800B720C 92190001 */ lbu $t9, 1($s0) /* 0B7E10 800B7210 02602025 */ move $a0, $s3 /* 0B7E14 800B7214 02542823 */ subu $a1, $s2, $s4 /* 0B7E18 800B7218 53200007 */ beql $t9, $zero, .L800B7238 /* 0B7E1C 800B721C 26310001 */ addiu $s1, $s1, 1 -/* 0B7E20 800B7220 0C02DAFC */ jal func_800B6BF0 +/* 0B7E20 800B7220 0C02DAFC */ jal prepare_reverb_ring_buffer /* 0B7E24 800B7224 02203025 */ move $a2, $s1 -/* 0B7E28 800B7228 3C02803B */ lui $v0, %hi(D_803AFBC3) # $v0, 0x803b -/* 0B7E2C 800B722C 8042FBC3 */ lb $v0, %lo(D_803AFBC3)($v0) +/* 0B7E28 800B7228 3C02803B */ lui $v0, %hi(gNumSynthesisReverbs) # $v0, 0x803b +/* 0B7E2C 800B722C 8042FBC3 */ lb $v0, %lo(gNumSynthesisReverbs)($v0) /* 0B7E30 800B7230 86B2000C */ lh $s2, 0xc($s5) /* 0B7E34 800B7234 26310001 */ addiu $s1, $s1, 1 .L800B7238: @@ -468,10 +196,10 @@ glabel func_800B70EC /* 0B7E68 800B7268 1E80FFC4 */ bgtz $s4, .L800B717C /* 0B7E6C 800B726C 02E8B821 */ addu $s7, $s7, $t0 .L800B7270: -/* 0B7E70 800B7270 3C02803B */ lui $v0, %hi(D_803AFBC3) # $v0, 0x803b -/* 0B7E74 800B7274 8042FBC3 */ lb $v0, %lo(D_803AFBC3)($v0) -/* 0B7E78 800B7278 3C09803B */ lui $t1, %hi(D_803AF790) # 0x803b -/* 0B7E7C 800B727C 2530F790 */ addiu $s0, $t1, %lo(D_803AF790) # -0x870 +/* 0B7E70 800B7270 3C02803B */ lui $v0, %hi(gNumSynthesisReverbs) # $v0, 0x803b +/* 0B7E74 800B7274 8042FBC3 */ lb $v0, %lo(gNumSynthesisReverbs)($v0) +/* 0B7E78 800B7278 3C09803B */ lui $t1, %hi(gSynthesisReverbs) # 0x803b +/* 0B7E7C 800B727C 2530F790 */ addiu $s0, $t1, %lo(gSynthesisReverbs) # -0x870 /* 0B7E80 800B7280 1840000E */ blez $v0, .L800B72BC /* 0B7E84 800B7284 00025140 */ sll $t2, $v0, 5 /* 0B7E88 800B7288 01425021 */ addu $t2, $t2, $v0 @@ -516,8 +244,8 @@ glabel func_800B7304 /* 0B7F10 800B7310 00117403 */ sra $t6, $s1, 0x10 /* 0B7F14 800B7314 000EC940 */ sll $t9, $t6, 5 /* 0B7F18 800B7318 032EC821 */ addu $t9, $t9, $t6 -/* 0B7F1C 800B731C 3C0D803B */ lui $t5, %hi(D_803AF790) # $t5, 0x803b -/* 0B7F20 800B7320 25ADF790 */ addiu $t5, %lo(D_803AF790) # addiu $t5, $t5, -0x870 +/* 0B7F1C 800B731C 3C0D803B */ lui $t5, %hi(gSynthesisReverbs) # $t5, 0x803b +/* 0B7F20 800B7320 25ADF790 */ addiu $t5, %lo(gSynthesisReverbs) # addiu $t5, $t5, -0x870 /* 0B7F24 800B7324 0019C8C0 */ sll $t9, $t9, 3 /* 0B7F28 800B7328 01C08825 */ move $s1, $t6 /* 0B7F2C 800B732C 032D1821 */ addu $v1, $t9, $t5 @@ -555,7 +283,7 @@ glabel func_800B7304 /* 0B7FAC 800B73AC AFA30028 */ sw $v1, 0x28($sp) /* 0B7FB0 800B73B0 AFB10010 */ sw $s1, 0x10($sp) /* 0B7FB4 800B73B4 02002025 */ move $a0, $s0 -/* 0B7FB8 800B73B8 0C02DBA1 */ jal func_800B6E84 +/* 0B7FB8 800B73B8 0C02DBA1 */ jal synthesis_load_reverb_ring_buffer /* 0B7FBC 800B73BC 24050840 */ li $a1, 2112 /* 0B7FC0 800B73C0 8FA80054 */ lw $t0, 0x54($sp) /* 0B7FC4 800B73C4 00408025 */ move $s0, $v0 @@ -570,7 +298,7 @@ glabel func_800B7304 /* 0B7FE8 800B73E8 AFB10010 */ sw $s1, 0x10($sp) /* 0B7FEC 800B73EC 24A50840 */ addiu $a1, $a1, 0x840 /* 0B7FF0 800B73F0 30B8FFFF */ andi $t8, $a1, 0xffff -/* 0B7FF4 800B73F4 0C02DBA1 */ jal func_800B6E84 +/* 0B7FF4 800B73F4 0C02DBA1 */ jal synthesis_load_reverb_ring_buffer /* 0B7FF8 800B73F8 03002825 */ move $a1, $t8 /* 0B7FFC 800B73FC 8FA30028 */ lw $v1, 0x28($sp) /* 0B8000 800B7400 3C190C30 */ lui $t9, (0x0C307FFF >> 16) # lui $t9, 0xc30 @@ -623,7 +351,7 @@ glabel func_800B7304 /* 0B80B0 800B74B0 00583023 */ subu $a2, $v0, $t8 /* 0B80B4 800B74B4 30D9FFFF */ andi $t9, $a2, 0xffff /* 0B80B8 800B74B8 03203025 */ move $a2, $t9 -/* 0B80BC 800B74BC 0C02DBA1 */ jal func_800B6E84 +/* 0B80BC 800B74BC 0C02DBA1 */ jal synthesis_load_reverb_ring_buffer /* 0B80C0 800B74C0 24070180 */ li $a3, 384 /* 0B80C4 800B74C4 8FA80054 */ lw $t0, 0x54($sp) /* 0B80C8 800B74C8 00408025 */ move $s0, $v0 @@ -641,7 +369,7 @@ glabel func_800B7304 /* 0B80F8 800B74F8 00003025 */ move $a2, $zero /* 0B80FC 800B74FC AFB10010 */ sw $s1, 0x10($sp) /* 0B8100 800B7500 AFA30028 */ sw $v1, 0x28($sp) -/* 0B8104 800B7504 0C02DBA1 */ jal func_800B6E84 +/* 0B8104 800B7504 0C02DBA1 */ jal synthesis_load_reverb_ring_buffer /* 0B8108 800B7508 A7A90052 */ sh $t1, 0x52($sp) /* 0B810C 800B750C 8FA30028 */ lw $v1, 0x28($sp) /* 0B8110 800B7510 87A90052 */ lh $t1, 0x52($sp) @@ -723,8 +451,8 @@ glabel func_800B7630 /* 0B8230 800B7630 27BDFFD8 */ addiu $sp, $sp, -0x28 /* 0B8234 800B7634 AFA5002C */ sw $a1, 0x2c($sp) /* 0B8238 800B7638 87B8002E */ lh $t8, 0x2e($sp) -/* 0B823C 800B763C 3C08803B */ lui $t0, %hi(D_803AF790) # $t0, 0x803b -/* 0B8240 800B7640 2508F790 */ addiu $t0, %lo(D_803AF790) # addiu $t0, $t0, -0x870 +/* 0B823C 800B763C 3C08803B */ lui $t0, %hi(gSynthesisReverbs) # $t0, 0x803b +/* 0B8240 800B7640 2508F790 */ addiu $t0, %lo(gSynthesisReverbs) # addiu $t0, $t0, -0x870 /* 0B8244 800B7644 0018C940 */ sll $t9, $t8, 5 /* 0B8248 800B7648 0338C821 */ addu $t9, $t9, $t8 /* 0B824C 800B764C 0019C8C0 */ sll $t9, $t9, 3 @@ -801,8 +529,8 @@ glabel func_800B7630 glabel func_800B775C /* 0B835C 800B775C 27BDFF40 */ addiu $sp, $sp, -0xc0 -/* 0B8360 800B7760 3C0A803B */ lui $t2, %hi(D_803AFBC3) # $t2, 0x803b -/* 0B8364 800B7764 254AFBC3 */ addiu $t2, %lo(D_803AFBC3) # addiu $t2, $t2, -0x43d +/* 0B8360 800B7760 3C0A803B */ lui $t2, %hi(gNumSynthesisReverbs) # $t2, 0x803b +/* 0B8364 800B7764 254AFBC3 */ addiu $t2, %lo(gNumSynthesisReverbs) # addiu $t2, $t2, -0x43d /* 0B8368 800B7768 81490000 */ lb $t1, ($t2) /* 0B836C 800B776C AFB5003C */ sw $s5, 0x3c($sp) /* 0B8370 800B7770 AFB40038 */ sw $s4, 0x38($sp) @@ -826,8 +554,8 @@ glabel func_800B775C /* 0B83B8 800B77B8 18800016 */ blez $a0, .L800B7814 /* 0B83BC 800B77BC 00000000 */ nop /* 0B83C0 800B77C0 00870019 */ multu $a0, $a3 -/* 0B83C4 800B77C4 3C0E803B */ lui $t6, %hi(D_803AFBC4) # $t6, 0x803b -/* 0B83C8 800B77C8 8DCEFBC4 */ lw $t6, %lo(D_803AFBC4)($t6) +/* 0B83C4 800B77C4 3C0E803B */ lui $t6, %hi(gNoteSubsEu) # $t6, 0x803b +/* 0B83C8 800B77C8 8DCEFBC4 */ lw $t6, %lo(gNoteSubsEu)($t6) /* 0B83CC 800B77CC 27A50084 */ addiu $a1, $sp, 0x84 /* 0B83D0 800B77D0 00007812 */ mflo $t7 /* 0B83D4 800B77D4 000FC100 */ sll $t8, $t7, 4 @@ -861,8 +589,8 @@ glabel func_800B775C /* 0B8430 800B7830 1880001A */ blez $a0, .L800B789C /* 0B8434 800B7834 00008825 */ move $s1, $zero /* 0B8438 800B7838 00950019 */ multu $a0, $s5 -/* 0B843C 800B783C 3C08803B */ lui $t0, %hi(D_803AFBC4) # $t0, 0x803b -/* 0B8440 800B7840 8D08FBC4 */ lw $t0, %lo(D_803AFBC4)($t0) +/* 0B843C 800B783C 3C08803B */ lui $t0, %hi(gNoteSubsEu) # $t0, 0x803b +/* 0B8440 800B7840 8D08FBC4 */ lw $t0, %lo(gNoteSubsEu)($t0) /* 0B8444 800B7844 00001812 */ mflo $v1 /* 0B8448 800B7848 00000000 */ nop /* 0B844C 800B784C 00000000 */ nop @@ -903,8 +631,8 @@ glabel func_800B775C /* 0B84C8 800B78C8 5880001D */ blezl $a0, .L800B7940 /* 0B84CC 800B78CC 02801025 */ move $v0, $s4 /* 0B84D0 800B78D0 00950019 */ multu $a0, $s5 -/* 0B84D4 800B78D4 3C08803B */ lui $t0, %hi(D_803AFBC4) # $t0, 0x803b -/* 0B84D8 800B78D8 8D08FBC4 */ lw $t0, %lo(D_803AFBC4)($t0) +/* 0B84D4 800B78D4 3C08803B */ lui $t0, %hi(gNoteSubsEu) # $t0, 0x803b +/* 0B84D8 800B78D8 8D08FBC4 */ lw $t0, %lo(gNoteSubsEu)($t0) /* 0B84DC 800B78DC 00001812 */ mflo $v1 /* 0B84E0 800B78E0 00000000 */ nop /* 0B84E4 800B78E4 00000000 */ nop @@ -944,24 +672,24 @@ glabel func_800B775C /* 0B855C 800B795C 26940008 */ addiu $s4, $s4, 8 /* 0B8560 800B7960 19E00055 */ blez $t7, .L800B7AB8 /* 0B8564 800B7964 27DE1508 */ addiu $fp, %lo(D_803B1508) # addiu $fp, $fp, 0x1508 -/* 0B8568 800B7968 3C16803B */ lui $s6, %hi(D_803AFBC4) # $s6, 0x803b -/* 0B856C 800B796C 26D6FBC4 */ addiu $s6, %lo(D_803AFBC4) # addiu $s6, $s6, -0x43c +/* 0B8568 800B7968 3C16803B */ lui $s6, %hi(gNoteSubsEu) # $s6, 0x803b +/* 0B856C 800B796C 26D6FBC4 */ addiu $s6, %lo(gNoteSubsEu) # addiu $s6, $s6, -0x43c /* 0B8570 800B7970 241700C0 */ li $s7, 192 /* 0B8574 800B7974 00137140 */ sll $t6, $s3, 5 .L800B7978: /* 0B8578 800B7978 01D37021 */ addu $t6, $t6, $s3 -/* 0B857C 800B797C 3C18803B */ lui $t8, %hi(D_803AF790) # $t8, 0x803b -/* 0B8580 800B7980 2718F790 */ addiu $t8, %lo(D_803AF790) # addiu $t8, $t8, -0x870 +/* 0B857C 800B797C 3C18803B */ lui $t8, %hi(gSynthesisReverbs) # $t8, 0x803b +/* 0B8580 800B7980 2718F790 */ addiu $t8, %lo(gSynthesisReverbs) # addiu $t8, $t8, -0x870 /* 0B8584 800B7984 000E70C0 */ sll $t6, $t6, 3 /* 0B8588 800B7988 01D8C821 */ addu $t9, $t6, $t8 /* 0B858C 800B798C AFB90064 */ sw $t9, 0x64($sp) /* 0B8590 800B7990 932B0001 */ lbu $t3, 1($t9) -/* 0B8594 800B7994 3C01803B */ lui $at, %hi(D_803AFBC2) # $at, 0x803b +/* 0B8594 800B7994 3C01803B */ lui $at, %hi(gUseReverb) # $at, 0x803b /* 0B8598 800B7998 02802025 */ move $a0, $s4 /* 0B859C 800B799C 000B6600 */ sll $t4, $t3, 0x18 /* 0B85A0 800B79A0 000C6E03 */ sra $t5, $t4, 0x18 /* 0B85A4 800B79A4 11A0000A */ beqz $t5, .L800B79D0 -/* 0B85A8 800B79A8 A02BFBC2 */ sb $t3, %lo(D_803AFBC2)($at) +/* 0B85A8 800B79A8 A02BFBC2 */ sb $t3, %lo(gUseReverb)($at) /* 0B85AC 800B79AC 00133400 */ sll $a2, $s3, 0x10 /* 0B85B0 800B79B0 00153C00 */ sll $a3, $s5, 0x10 /* 0B85B4 800B79B4 00077403 */ sra $t6, $a3, 0x10 @@ -1026,8 +754,8 @@ glabel func_800B775C /* 0B8690 800B7A90 01603025 */ move $a2, $t3 /* 0B8694 800B7A94 0040A025 */ move $s4, $v0 .L800B7A98: -/* 0B8698 800B7A98 3C0F803B */ lui $t7, %hi(D_803AFBC3) # $t7, 0x803b -/* 0B869C 800B7A9C 81EFFBC3 */ lb $t7, %lo(D_803AFBC3)($t7) +/* 0B8698 800B7A98 3C0F803B */ lui $t7, %hi(gNumSynthesisReverbs) # $t7, 0x803b +/* 0B869C 800B7A9C 81EFFBC3 */ lb $t7, %lo(gNumSynthesisReverbs)($t7) /* 0B86A0 800B7AA0 26730001 */ addiu $s3, $s3, 1 /* 0B86A4 800B7AA4 00136400 */ sll $t4, $s3, 0x10 /* 0B86A8 800B7AA8 000C9C03 */ sra $s3, $t4, 0x10 @@ -1035,11 +763,11 @@ glabel func_800B775C /* 0B86B0 800B7AB0 5420FFB1 */ bnel $at, $zero, .L800B7978 /* 0B86B4 800B7AB4 00137140 */ sll $t6, $s3, 5 .L800B7AB8: -/* 0B86B8 800B7AB8 3C16803B */ lui $s6, %hi(D_803AFBC4) # $s6, 0x803b +/* 0B86B8 800B7AB8 3C16803B */ lui $s6, %hi(gNoteSubsEu) # $s6, 0x803b /* 0B86BC 800B7ABC 3C1E803B */ lui $fp, %hi(D_803B1508) # $fp, 0x803b /* 0B86C0 800B7AC0 0232082A */ slt $at, $s1, $s2 /* 0B86C4 800B7AC4 27DE1508 */ addiu $fp, %lo(D_803B1508) # addiu $fp, $fp, 0x1508 -/* 0B86C8 800B7AC8 26D6FBC4 */ addiu $s6, %lo(D_803AFBC4) # addiu $s6, $s6, -0x43c +/* 0B86C8 800B7AC8 26D6FBC4 */ addiu $s6, %lo(gNoteSubsEu) # addiu $s6, $s6, -0x43c /* 0B86CC 800B7ACC 10200030 */ beqz $at, .L800B7B90 /* 0B86D0 800B7AD0 241700C0 */ li $s7, 192 /* 0B86D4 800B7AD4 27AE0084 */ addiu $t6, $sp, 0x84 @@ -1578,7 +1306,7 @@ glabel func_800B7C30 /* 0B8EA0 800B82A0 A23800B0 */ sb $t8, 0xb0($s1) /* 0B8EA4 800B82A4 AFAD00E4 */ sw $t5, 0xe4($sp) /* 0B8EA8 800B82A8 8FA50140 */ lw $a1, 0x140($sp) -/* 0B8EAC 800B82AC 0C02DBED */ jal func_800B6FB4 +/* 0B8EAC 800B82AC 0C02DBED */ jal synthesis_load_note_subs_eu /* 0B8EB0 800B82B0 8FA40158 */ lw $a0, 0x158($sp) /* 0B8EB4 800B82B4 1000000D */ b .L800B82EC /* 0B8EB8 800B82B8 8FAD00E4 */ lw $t5, 0xe4($sp) diff --git a/asm/non_matchings/audio/wip.s b/asm/non_matchings/audio/wip.s new file mode 100644 index 000000000..f502b858b --- /dev/null +++ b/asm/non_matchings/audio/wip.s @@ -0,0 +1,79 @@ +glabel synthesis_load_reverb_ring_buffer +/* 0B7A84 800B6E84 00074103 */ sra $t0, $a3, 4 +/* 0B7A88 800B6E88 AFA50004 */ sw $a1, 4($sp) +/* 0B7A8C 800B6E8C 00A07025 */ move $t6, $a1 +/* 0B7A90 800B6E90 311800FF */ andi $t8, $t0, 0xff +/* 0B7A94 800B6E94 01C02825 */ move $a1, $t6 +/* 0B7A98 800B6E98 AFA60008 */ sw $a2, 8($sp) +/* 0B7A9C 800B6E9C 30CFFFFF */ andi $t7, $a2, 0xffff +/* 0B7AA0 800B6EA0 0018CC00 */ sll $t9, $t8, 0x10 +/* 0B7AA4 800B6EA4 3C011400 */ lui $at, 0x1400 +/* 0B7AA8 800B6EA8 01E03025 */ move $a2, $t7 +/* 0B7AAC 800B6EAC 03214025 */ or $t0, $t9, $at +/* 0B7AB0 800B6EB0 31CEFFFF */ andi $t6, $t6, 0xffff +/* 0B7AB4 800B6EB4 010E7825 */ or $t7, $t0, $t6 +/* 0B7AB8 800B6EB8 AC8F0000 */ sw $t7, ($a0) +/* 0B7ABC 800B6EBC 8FB80010 */ lw $t8, 0x10($sp) +/* 0B7AC0 800B6EC0 3C0D803B */ lui $t5, %hi(gSynthesisReverbs) # $t5, 0x803b +/* 0B7AC4 800B6EC4 25ADF790 */ addiu $t5, %lo(gSynthesisReverbs) # addiu $t5, $t5, -0x870 +/* 0B7AC8 800B6EC8 0018C940 */ sll $t9, $t8, 5 +/* 0B7ACC 800B6ECC 0338C821 */ addu $t9, $t9, $t8 +/* 0B7AD0 800B6ED0 0019C8C0 */ sll $t9, $t9, 3 +/* 0B7AD4 800B6ED4 032D4821 */ addu $t1, $t9, $t5 +/* 0B7AD8 800B6ED8 8D2E0018 */ lw $t6, 0x18($t1) +/* 0B7ADC 800B6EDC 00065040 */ sll $t2, $a2, 1 +/* 0B7AE0 800B6EE0 3C0C8000 */ lui $t4, 0x8000 +/* 0B7AE4 800B6EE4 24B90180 */ addiu $t9, $a1, 0x180 +/* 0B7AE8 800B6EE8 01CA7821 */ addu $t7, $t6, $t2 +/* 0B7AEC 800B6EEC 01ECC021 */ addu $t8, $t7, $t4 +/* 0B7AF0 800B6EF0 332DFFFF */ andi $t5, $t9, 0xffff +/* 0B7AF4 800B6EF4 AC980004 */ sw $t8, 4($a0) +/* 0B7AF8 800B6EF8 248B0008 */ addiu $t3, $a0, 8 +/* 0B7AFC 800B6EFC 010D7025 */ or $t6, $t0, $t5 +/* 0B7B00 800B6F00 AD6E0000 */ sw $t6, ($t3) +/* 0B7B04 800B6F04 8D2F001C */ lw $t7, 0x1c($t1) +/* 0B7B08 800B6F08 25620008 */ addiu $v0, $t3, 8 +/* 0B7B0C 800B6F0C 01EAC021 */ addu $t8, $t7, $t2 +/* 0B7B10 800B6F10 030CC821 */ addu $t9, $t8, $t4 +/* 0B7B14 800B6F14 03E00008 */ jr $ra +/* 0B7B18 800B6F18 AD790004 */ sw $t9, 4($t3) + +glabel func_800B6F1C +/* 0B7B1C 800B6F1C 00074103 */ sra $t0, $a3, 4 +/* 0B7B20 800B6F20 AFA50004 */ sw $a1, 4($sp) +/* 0B7B24 800B6F24 00A07025 */ move $t6, $a1 +/* 0B7B28 800B6F28 311800FF */ andi $t8, $t0, 0xff +/* 0B7B2C 800B6F2C 01C02825 */ move $a1, $t6 +/* 0B7B30 800B6F30 AFA60008 */ sw $a2, 8($sp) +/* 0B7B34 800B6F34 30CFFFFF */ andi $t7, $a2, 0xffff +/* 0B7B38 800B6F38 0018CC00 */ sll $t9, $t8, 0x10 +/* 0B7B3C 800B6F3C 3C011500 */ lui $at, 0x1500 +/* 0B7B40 800B6F40 01E03025 */ move $a2, $t7 +/* 0B7B44 800B6F44 03214025 */ or $t0, $t9, $at +/* 0B7B48 800B6F48 31CEFFFF */ andi $t6, $t6, 0xffff +/* 0B7B4C 800B6F4C 010E7825 */ or $t7, $t0, $t6 +/* 0B7B50 800B6F50 AC8F0000 */ sw $t7, ($a0) +/* 0B7B54 800B6F54 8FB80010 */ lw $t8, 0x10($sp) +/* 0B7B58 800B6F58 3C0D803B */ lui $t5, %hi(gSynthesisReverbs) # $t5, 0x803b +/* 0B7B5C 800B6F5C 25ADF790 */ addiu $t5, %lo(gSynthesisReverbs) # addiu $t5, $t5, -0x870 +/* 0B7B60 800B6F60 0018C940 */ sll $t9, $t8, 5 +/* 0B7B64 800B6F64 0338C821 */ addu $t9, $t9, $t8 +/* 0B7B68 800B6F68 0019C8C0 */ sll $t9, $t9, 3 +/* 0B7B6C 800B6F6C 032D4821 */ addu $t1, $t9, $t5 +/* 0B7B70 800B6F70 8D2E0018 */ lw $t6, 0x18($t1) +/* 0B7B74 800B6F74 00065040 */ sll $t2, $a2, 1 +/* 0B7B78 800B6F78 3C0C8000 */ lui $t4, 0x8000 +/* 0B7B7C 800B6F7C 24B90180 */ addiu $t9, $a1, 0x180 +/* 0B7B80 800B6F80 01CA7821 */ addu $t7, $t6, $t2 +/* 0B7B84 800B6F84 01ECC021 */ addu $t8, $t7, $t4 +/* 0B7B88 800B6F88 332DFFFF */ andi $t5, $t9, 0xffff +/* 0B7B8C 800B6F8C AC980004 */ sw $t8, 4($a0) +/* 0B7B90 800B6F90 248B0008 */ addiu $t3, $a0, 8 +/* 0B7B94 800B6F94 010D7025 */ or $t6, $t0, $t5 +/* 0B7B98 800B6F98 AD6E0000 */ sw $t6, ($t3) +/* 0B7B9C 800B6F9C 8D2F001C */ lw $t7, 0x1c($t1) +/* 0B7BA0 800B6FA0 25620008 */ addiu $v0, $t3, 8 +/* 0B7BA4 800B6FA4 01EAC021 */ addu $t8, $t7, $t2 +/* 0B7BA8 800B6FA8 030CC821 */ addu $t9, $t8, $t4 +/* 0B7BAC 800B6FAC 03E00008 */ jr $ra +/* 0B7BB0 800B6FB0 AD790004 */ sw $t9, 4($t3) diff --git a/include/segments.h b/include/segments.h index 005ca89b2..8a17bb051 100644 --- a/include/segments.h +++ b/include/segments.h @@ -6,5 +6,6 @@ #define SEG_8028DF00 0x8028DF00 #define SEG_802BA370 0x802BA370 #define SEG_FRAMEBUFFERS 0x802BA290 +#define SEG_AUDIO 0x803AF790 #endif diff --git a/mk64.ld b/mk64.ld index 8a18715b1..3b3d63ea2 100644 --- a/mk64.ld +++ b/mk64.ld @@ -88,7 +88,7 @@ SECTIONS BUILD_DIR/src/code_8008C1D0.o(.text); BUILD_DIR/asm/code_80091750.o(.text); BUILD_DIR/src/code_800AF9B0.o(.text); - BUILD_DIR/asm/audio/synthesis.o(.text); + BUILD_DIR/src/synthesis.o(.text); BUILD_DIR/asm/audio/heap.o(.text); BUILD_DIR/asm/audio/load.o(.text); BUILD_DIR/asm/audio/playback.o(.text); @@ -262,7 +262,7 @@ SECTIONS BUILD_DIR/asm/bss_80005FD0.o(.bss); BUILD_DIR/asm/bss_MainSeg.o(.bss); BUILD_DIR/src/os/osCreateViManager.o(.bss); - BUILD_DIR/asm/bss_MainSeg_2.o(.bss); + BUILD_DIR/asm/bss_libultra.o(.bss); BUILD_DIR/src/os/osTimer.o(.bss); BUILD_DIR/src/os/__osPiCreateAccessQueue.o(.bss); BUILD_DIR/src/os/__osSiCreateAccessQueue.o(.bss); @@ -315,6 +315,14 @@ SECTIONS _code_8028DF00SegmentNoloadSizeHi = _code_8028DF00SegmentNoloadSize >> 16; _code_8028DF00SegmentNoloadSizeLo = _code_8028DF00SegmentNoloadSize & 0xFFFF; + . = SEG_AUDIO; + BEGIN_NOLOAD(audio) + { + BUILD_DIR/src/synthesis.o(.bss*); + } + END_NOLOAD(audio) + + /* 0x80280000 123640-12AAE0 [74A0] */ BEGIN_SEG(code_80280000, SEG_80280000) { diff --git a/src/internal.h b/src/internal.h new file mode 100644 index 000000000..460b07771 --- /dev/null +++ b/src/internal.h @@ -0,0 +1,565 @@ +#ifndef AUDIO_INTERNAL_H +#define AUDIO_INTERNAL_H + +#include + +#include "types.h" + + +// sm64 build defines +#define IS_BIG_ENDIAN 1 +// sm64 build defines + + +#define SEQUENCE_PLAYERS 4 +#define SEQUENCE_CHANNELS 48 +#define SEQUENCE_LAYERS 64 + +#define LAYERS_MAX 4 +#define CHANNELS_MAX 16 + +#define NO_LAYER ((struct SequenceChannelLayer *)(-1)) + +#define MUTE_BEHAVIOR_STOP_SCRIPT 0x80 // stop processing sequence/channel scripts +#define MUTE_BEHAVIOR_STOP_NOTES 0x40 // prevent further notes from playing +#define MUTE_BEHAVIOR_SOFTEN 0x20 // lower volume, by default to half + +#define SEQUENCE_PLAYER_STATE_0 0 +#define SEQUENCE_PLAYER_STATE_FADE_OUT 1 +#define SEQUENCE_PLAYER_STATE_2 2 +#define SEQUENCE_PLAYER_STATE_3 3 +#define SEQUENCE_PLAYER_STATE_4 4 + +#define NOTE_PRIORITY_DISABLED 0 +#define NOTE_PRIORITY_STOPPING 1 +#define NOTE_PRIORITY_MIN 2 +#define NOTE_PRIORITY_DEFAULT 3 + +#define TATUMS_PER_BEAT 48 + +// abi.h contains more details about the ADPCM and S8 codecs, "skip" skips codec processing +#define CODEC_ADPCM 0 +#define CODEC_S8 1 +#define CODEC_SKIP 2 + +#define TEMPO_SCALE TATUMS_PER_BEAT + +// TODO: US_FLOAT should probably be renamed to JP_DOUBLE since eu seems to use floats too +#define US_FLOAT(x) x ## f + +// Convert u8 or u16 to f32. +#define FLOAT_CAST(x) (f32) (s32) (x) + +// No-op printf macro which leaves string literals in rodata in IDO. IDO +// doesn't support variadic macros, so instead we let the parameter list +// expand to a no-op comma expression. Another possibility is that it might +// have expanded to something with "if (0)". See also goddard/gd_main.h. +// On US/JP, -sopt optimizes away these except for external.c. +#ifdef __sgi +#define stubbed_printf +#else +#define stubbed_printf(...) +#endif + +#define eu_stubbed_printf_0(msg) stubbed_printf(msg) +#define eu_stubbed_printf_1(msg, a) stubbed_printf(msg, a) +#define eu_stubbed_printf_2(msg, a, b) stubbed_printf(msg, a, b) +#define eu_stubbed_printf_3(msg, a, b, c) stubbed_printf(msg, a, b, c) + +struct NotePool; + +struct AudioListItem { + // A node in a circularly linked list. Each node is either a head or an item: + // - Items can be either detached (prev = NULL), or attached to a list. + // 'value' points to something of interest. + // - List heads are always attached; if a list is empty, its head points + // to itself. 'count' contains the size of the list. + // If the list holds notes, 'pool' points back to the pool where it lives. + // Otherwise, that member is NULL. + struct AudioListItem *prev; + struct AudioListItem *next; + union { + void *value; // either Note* or SequenceChannelLayer* + s32 count; + } u; + struct NotePool *pool; +}; // size = 0x10 + +struct NotePool { + struct AudioListItem disabled; + struct AudioListItem decaying; + struct AudioListItem releasing; + struct AudioListItem active; +}; + +struct VibratoState { + /*0x00, 0x00*/ struct SequenceChannel *seqChannel; + /*0x04, 0x04*/ u32 time; + /* , 0x08*/ s16 *curve; + /* , 0x0C*/ f32 extent; + /* , 0x10*/ f32 rate; + /* , 0x14*/ u8 active; + /*0x12, 0x16*/ u16 rateChangeTimer; + /*0x14, 0x18*/ u16 extentChangeTimer; + /*0x16, 0x1A*/ u16 delay; +}; // size = 0x18, 0x1C on EU + +// Pitch sliding by up to one octave in the positive direction. Negative +// direction is "supported" by setting extent to be negative. The code +// extrapolates exponentially in the wrong direction in that case, but that +// doesn't prevent seqplayer from doing it, AFAICT. +struct Portamento { + u8 mode; // bit 0x80 denotes something; the rest are an index 0-5 + f32 cur; + f32 speed; + f32 extent; +}; // size = 0x10 + +struct AdsrEnvelope { + s16 delay; + s16 arg; +}; // size = 0x4 + +struct AdpcmLoop { + u32 start; + u32 end; + u32 count; + u32 pad; + s16 state[16]; // only exists if count != 0. 8-byte aligned +}; + +struct AdpcmBook { + s32 order; + s32 npredictors; + s16 book[1]; // size 8 * order * npredictors. 8-byte aligned +}; + +struct AudioBankSample { + u8 unused; + u8 loaded; + u8 *sampleAddr; + struct AdpcmLoop *loop; + struct AdpcmBook *book; +}; + +struct AudioBankSound { + struct AudioBankSample *sample; + f32 tuning; // frequency scale factor +}; // size = 0x8 + +struct Instrument { + /*0x00*/ u8 loaded; + /*0x01*/ u8 normalRangeLo; + /*0x02*/ u8 normalRangeHi; + /*0x03*/ u8 releaseRate; + /*0x04*/ struct AdsrEnvelope *envelope; + /*0x08*/ struct AudioBankSound lowNotesSound; + /*0x10*/ struct AudioBankSound normalNotesSound; + /*0x18*/ struct AudioBankSound highNotesSound; +}; // size = 0x20 + +struct Drum { + u8 releaseRate; + u8 pan; + u8 loaded; + struct AudioBankSound sound; + struct AdsrEnvelope *envelope; +}; + +struct AudioBank { + struct Drum **drums; + struct Instrument *instruments[1]; +}; // dynamic size + +struct CtlEntry { + u8 unused; + u8 numInstruments; + u8 numDrums; + struct Instrument **instruments; + struct Drum **drums; +}; // size = 0xC + +struct M64ScriptState { + u8 *pc; + u8 *stack[4]; + u8 remLoopIters[4]; + u8 depth; +}; // size = 0x1C + +// Also known as a Group, according to debug strings. +struct SequencePlayer { + /*0x000, 0x000, 0x000*/ u8 enabled : 1; + /*0x000, 0x000*/ u8 finished : 1; // never read + /*0x000, 0x000*/ u8 muted : 1; + /*0x000, 0x000*/ u8 seqDmaInProgress : 1; + /*0x000, 0x000*/ u8 bankDmaInProgress : 1; + /* 0x000*/ u8 recalculateVolume : 1; + /*0x002, 0x001, 0x001*/ u8 state; + /*0x003, 0x002*/ u8 noteAllocPolicy; + /*0x004, 0x003*/ u8 muteBehavior; + /*0x005, 0x004*/ u8 seqId; + /*0x006, 0x005*/ u8 defaultBank[1]; // must be an array to get a comparison + // to match; other u8's might also be part of that array + /*0x007, 0x006*/ u8 loadingBankId; + /* , 0x007, 0x007*/ s8 seqVariationEu[1]; + /*0x00A, 0x008*/ u16 tempo; // beats per minute in JP, tatums per minute in US/EU + /*0x00C, 0x00A*/ u16 tempoAcc; + /*0x010, 0x00C, 0x00E*/ s16 transposition; + /*0x012, 0x00E, 0x010*/ u16 delay; + /*0x00E, 0x010, 0x012*/ u16 fadeRemainingFrames; + /* , 0x012, 0x014*/ u16 fadeTimerUnkEu; + /*0x014, 0x014*/ u8 *seqData; // buffer of some sort + /*0x018, 0x018, 0x1C*/ f32 fadeVolume; // set to 1.0f + /*0x01C, 0x01C*/ f32 fadeVelocity; // set to 0.0f + /*0x020, 0x020, 0x024*/ f32 volume; // set to 0.0f + /*0x024, 0x024*/ f32 muteVolumeScale; // set to 0.5f + /* , 0x028, 0x02C*/ f32 fadeVolumeScale; + /* , 0x02C*/ f32 appliedFadeVolume; + /*0x02C, 0x030, 0x034*/ struct SequenceChannel *channels[CHANNELS_MAX]; + /*0x06C, 0x070*/ struct M64ScriptState scriptState; + /*0x088, 0x08C*/ u8 *shortNoteVelocityTable; + /*0x08C, 0x090*/ u8 *shortNoteDurationTable; + /*0x090, 0x094*/ struct NotePool notePool; + /*0x0D0, 0x0D4*/ OSMesgQueue seqDmaMesgQueue; + /*0x0E8, 0x0EC*/ OSMesg seqDmaMesg; + /*0x0EC, 0x0F0*/ OSIoMesg seqDmaIoMesg; + /*0x100, 0x108*/ OSMesgQueue bankDmaMesgQueue; + /*0x118, 0x120*/ OSMesg bankDmaMesg; + /*0x11C, 0x124*/ OSIoMesg bankDmaIoMesg; + /*0x130, 0x13C*/ u8 *bankDmaCurrMemAddr; + /*0x138, 0x140*/ uintptr_t bankDmaCurrDevAddr; + /*0x13C, 0x144*/ ssize_t bankDmaRemaining; +}; // size = 0x140, 0x148 on EU, 0x14C on SH + +struct AdsrSettings { + u8 releaseRate; + u8 sustain; + struct AdsrEnvelope *envelope; +}; // size = 0x8 + +struct AdsrState { + /*0x00, 0x00*/ u8 action; + /*0x01, 0x01*/ u8 state; + /*0x08, 0x02*/ s16 envIndex; + /*0x0A, 0x04*/ s16 delay; + /* , 0x08*/ f32 sustain; + /* , 0x0C*/ f32 velocity; + /* , 0x10*/ f32 fadeOutVel; + /* , 0x14*/ f32 current; + /* , 0x18*/ f32 target; + s32 pad1C; + /*0x1C, 0x20*/ struct AdsrEnvelope *envelope; +}; // size = 0x20, 0x24 in EU + +struct ReverbBitsData { + /* 0x00 */ u8 bit0 : 1; + /* 0x00 */ u8 bit1 : 1; + /* 0x00 */ u8 bit2 : 1; + /* 0x00 */ u8 usesHeadsetPanEffects : 1; + /* 0x00 */ u8 stereoHeadsetEffects : 2; + /* 0x00 */ u8 strongRight : 1; + /* 0x00 */ u8 strongLeft : 1; +}; + +union ReverbBits { + /* 0x00 */ struct ReverbBitsData s; + /* 0x00 */ u8 asByte; +}; +struct ReverbInfo { + u8 reverbVol; + u8 synthesisVolume; // UQ4.4, although 0 <= x < 1 is rounded up to 1 + u8 pan; + union ReverbBits reverbBits; + f32 freqScale; + f32 velocity; + s32 unused; + s16 *filter; +}; + +struct NoteAttributes { + u8 reverbVol; + u8 pan; + f32 freqScale; + f32 velocity; +}; // size = 0x10 + +// Also known as a SubTrack, according to debug strings. +// Confusingly, a SubTrack is a container of Tracks. +struct SequenceChannel { + /* U/J, EU, SH */ + /*0x00, 0x00*/ u8 enabled : 1; + /*0x00, 0x00*/ u8 finished : 1; + /*0x00, 0x00*/ u8 stopScript : 1; + /*0x00, 0x00*/ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething + /*0x00, 0x00*/ u8 hasInstrument : 1; + /*0x00, 0x00*/ u8 stereoHeadsetEffects : 1; + /*0x00, ????*/ u8 largeNotes : 1; // notes specify duration and velocity + /*0x00, ????*/ u8 unused : 1; // never read, set to 0 + /* , 0x01*/ union { + struct { + u8 freqScale : 1; + u8 volume : 1; + u8 pan : 1; + } as_bitfields; + u8 as_u8; + } changes; + /*0x01, 0x02*/ u8 noteAllocPolicy; + /*0x02, 0x03, 0x03*/ u8 muteBehavior; + /*0x03, 0x04, 0x04*/ u8 reverbVol; // until EU: Q1.7, after EU: UQ0.8 + /*0x04, ????*/ u8 notePriority; // 0-3 + /*0x05, 0x06*/ u8 bankId; + /* , 0x07*/ u8 reverbIndex; + /* , 0x08, 0x09*/ u8 bookOffset; + /* , 0x09*/ u8 newPan; + /* , 0x0A*/ u8 panChannelWeight; // proportion of pan that comes from the channel (0..128) + /*0x08, 0x0C, 0x0E*/ u16 vibratoRateStart; // initially 0x800 + /*0x0A, 0x0E, 0x10*/ u16 vibratoExtentStart; + /*0x0C, 0x10, 0x12*/ u16 vibratoRateTarget; // initially 0x800 + /*0x0E, 0x12, 0x14*/ u16 vibratoExtentTarget; + /*0x10, 0x14, 0x16*/ u16 vibratoRateChangeDelay; + /*0x12, 0x16, 0x18*/ u16 vibratoExtentChangeDelay; + /*0x14, 0x18, 0x1A*/ u16 vibratoDelay; + /*0x16, 0x1A, 0x1C*/ u16 delay; + /*0x18, 0x1C, 0x1E*/ s16 instOrWave; // either 0 (none), instrument index + 1, or + // 0x80..0x83 for sawtooth/triangle/sine/square waves. + /*0x1A, 0x1E, 0x20*/ s16 transposition; + /*0x1C, 0x20, 0x24*/ f32 volumeScale; + /*0x20, 0x24, 0x28*/ f32 volume; + /* , 0x28*/ s32 pan; + /* , 0x2C*/ f32 appliedVolume; + /*0x2C, 0x30*/ f32 freqScale; + /*0x30, 0x34*/ u8 (*dynTable)[][2]; + /*0x34, ????*/ struct Note *noteUnused; // never read + /*0x38, ????*/ struct SequenceChannelLayer *layerUnused; // never read + /*0x3C, 0x40*/ struct Instrument *instrument; + /*0x40, 0x44*/ struct SequencePlayer *seqPlayer; + /*0x44, 0x48*/ struct SequenceChannelLayer *layers[LAYERS_MAX]; + /*0x54, 0x58 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib. For player 2, + // [0] contains enabled, [4] contains sound ID, [5] contains reverb adjustment + /*0x5C, 0x60*/ struct M64ScriptState scriptState; + /*0x78, 0x7C*/ struct AdsrSettings adsr; + /*0x80, 0x84*/ struct NotePool notePool; +}; // size = 0xC0, 0xC4 in EU, 0xD0 in SH + +// Also known as a Track, according to debug strings. +struct SequenceChannelLayer { + /* U/J, EU, SH */ + /*0x00, 0x00*/ u8 enabled : 1; + /*0x00, 0x00*/ u8 finished : 1; + /*0x00, 0x00*/ u8 stopSomething : 1; // ? + /*0x00, 0x00*/ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound + /* , 0x00*/ u8 unusedEu0b8 : 1; + /* , 0x00*/ u8 notePropertiesNeedInit : 1; + /* , 0x00*/ u8 ignoreDrumPan : 1; + /* , 0x01, 0x02*/ u8 instOrWave; + /*0x01, 0x02, 0x03*/ u8 status; // 0x03 in SH + /*0x02, 0x03*/ u8 noteDuration; // set to 0x80 + /*0x03, 0x04*/ u8 portamentoTargetNote; + /* , 0x05*/ u8 pan; // 0..128 + /* , 0x06, 0x07*/ u8 notePan; + /*0x04, 0x08*/ struct Portamento portamento; + /*0x14, 0x18*/ struct AdsrSettings adsr; + /*0x1C, 0x20*/ u16 portamentoTime; + /*0x1E, 0x22*/ s16 transposition; // #semitones added to play commands + // (m64 instruction encoding only allows referring to the limited range + // 0..0x3f; this makes 0x40..0x7f accessible as well) + /*0x20, 0x24, 0x24*/ f32 freqScale; + /*0x24, 0x28, 0x2C*/ f32 velocitySquare; + /*0x2C, 0x2C, 0x30*/ f32 noteVelocity; + /*0x34, 0x30, 0x34*/ f32 noteFreqScale; + /*0x38, 0x34*/ s16 shortNoteDefaultPlayPercentage; + /*0x3A, 0x36*/ s16 playPercentage; // it's not really a percentage... + /*0x3C, 0x38*/ s16 delay; + /*0x3E, 0x3A*/ s16 duration; + /*0x40, 0x3C*/ s16 delayUnused; // set to 'delay', never read + /*0x44, 0x40, 0x44*/ struct Note *note; + /*0x48, 0x44*/ struct Instrument *instrument; + /*0x4C, 0x48*/ struct AudioBankSound *sound; + /*0x50, 0x4C, 0x50*/ struct SequenceChannel *seqChannel; + /*0x54, 0x50*/ struct M64ScriptState scriptState; + /*0x70, 0x6C*/ struct AudioListItem listItem; + u8 pad2[4]; +}; // size = 0x80 + +struct NoteSynthesisState { + /*0x00*/ u8 restart; + /*0x01*/ u8 sampleDmaIndex; + /*0x02*/ u8 prevHeadsetPanRight; + /*0x03*/ u8 prevHeadsetPanLeft; + /*0x04, 0x06*/ u16 samplePosFrac; + /*0x08*/ s32 samplePosInt; + /*0x0C*/ struct NoteSynthesisBuffers *synthesisBuffers; + /*0x10*/ s16 curVolLeft; // UQ0.16 (EU Q1.15) + /*0x12*/ s16 curVolRight; // UQ0.16 (EU Q1.15) +}; + +struct NotePlaybackState { + /* U/J, EU, SH */ + /*0x04, 0x00, 0x00*/ u8 priority; + /* 0x01, 0x01*/ u8 waveId; + /* 0x02, 0x02*/ u8 sampleCountIndex; + /*0x08, 0x04, 0x06*/ s16 adsrVolScale; + /*0x18, 0x08, 0x08*/ f32 portamentoFreqScale; + /*0x1C, 0x0C, 0x0C*/ f32 vibratoFreqScale; + /*0x28, 0x10, */ struct SequenceChannelLayer *prevParentLayer; + /*0x2C, 0x14, 0x14*/ struct SequenceChannelLayer *parentLayer; + /*0x30, 0x18, 0x18*/ struct SequenceChannelLayer *wantedParentLayer; + /* , 0x1C, 0x1C*/ struct NoteAttributes attributes; + /*0x54, 0x28, 0x2C*/ struct AdsrState adsr; + /*0x74, 0x4C, */ struct Portamento portamento; + /*0x84, 0x5C, */ struct VibratoState vibratoState; +}; +struct NoteSubEu { + /*0x00*/ volatile u8 enabled : 1; + /*0x00*/ u8 needsInit : 1; + /*0x00*/ u8 finished : 1; + /*0x00*/ u8 envMixerNeedsInit : 1; + /*0x00*/ u8 stereoStrongRight : 1; + /*0x00*/ u8 stereoStrongLeft : 1; + /*0x00*/ u8 stereoHeadsetEffects : 1; + /*0x00*/ u8 usesHeadsetPanEffects : 1; + /*0x01*/ u8 reverbIndex : 3; + /*0x01*/ u8 bookOffset : 3; + /*0x01*/ u8 isSyntheticWave : 1; + /*0x01*/ u8 hasTwoAdpcmParts : 1; + /*0x02*/ u8 bankId; + /*0x03*/ u8 headsetPanRight; + /*0x04*/ u8 headsetPanLeft; + /*0x05*/ u8 reverbVol; // UQ0.7 (EU Q1.7) + /*0x06*/ u16 targetVolLeft; // UQ0.12 (EU UQ0.10) + /*0x08*/ u16 targetVolRight; // UQ0.12 (EU UQ0.10) + /*0x0A*/ u16 resamplingRateFixedPoint; // stored as signed but loaded as u16 + /*0x0C*/ union { + s16 *samples; + struct AudioBankSound *audioBankSound; + } sound; +}; +struct Note { + /* U/J, EU, SH */ + /*0xA4, 0x00, 0x00*/ struct AudioListItem listItem; + /* 0x10, 0x10*/ struct NoteSynthesisState synthesisState; + // The next members are actually part of a struct (NotePlaybackState), but + // that results in messy US/EU ifdefs. Instead we cast to a struct pointer + // when needed... This breaks alignment on non-N64 platforms, which we hack + // around by skipping the padding in that case. + // TODO: use macros or something instead. +#ifdef TARGET_N64 + u8 pad0[12]; +#endif + + /*0x04, 0x30, 0x30*/ u8 priority; + /* 0x31, 0x31*/ u8 waveId; + /* 0x32, 0x32*/ u8 sampleCountIndex; + /*0x08, 0x34, 0x36*/ s16 adsrVolScale; + /*0x18, 0x38, */ f32 portamentoFreqScale; + /*0x1C, 0x3C, */ f32 vibratoFreqScale; + /*0x28, 0x40, */ struct SequenceChannelLayer *prevParentLayer; + /*0x2C, 0x44, 0x44*/ struct SequenceChannelLayer *parentLayer; + /*0x30, 0x48, 0x48*/ struct SequenceChannelLayer *wantedParentLayer; + /* , 0x4C, 0x4C*/ struct NoteAttributes attributes; + /*0x54, 0x58, 0x5C*/ struct AdsrState adsr; + /*0x74, 0x7C*/ struct Portamento portamento; + /*0x84, 0x8C*/ struct VibratoState vibratoState; + u8 pad3[8]; + /* , 0xB0, 0xB4*/ struct NoteSubEu noteSubEu; +}; // size = 0xC0, known to be 0xC8 on SH + +struct NoteSynthesisBuffers { + s16 adpcmdecState[0x10]; + s16 finalResampleState[0x10]; + s16 mixEnvelopeState[0x28]; + s16 panResampleState[0x10]; + s16 panSamplesBuffer[0x20]; + s16 dummyResampleState[0x10]; +}; + +struct ReverbSettingsEU { + u8 downsampleRate; + u8 windowSize; // To be multiplied by 64 + u16 gain; +}; + +struct AudioSessionSettingsEU { + /* 0x00 */ u32 frequency; + /* 0x04 */ u8 unk1; // always 1 + /* 0x05 */ u8 maxSimultaneousNotes; + /* 0x06 */ u8 numReverbs; // always 1 + /* 0x07 */ u8 unk2; // always 0 + /* 0x08 */ struct ReverbSettingsEU *reverbSettings; + /* 0x0C */ u16 volume; + /* 0x0E */ u16 unk3; // always 0 + /* 0x10 */ u32 persistentSeqMem; + /* 0x14 */ u32 persistentBankMem; + /* 0x18, 0x1C */ u32 temporarySeqMem; + /* 0x1C, 0x20 */ u32 temporaryBankMem; +}; // 0x30 on shindou + +struct AudioSessionSettings { + /*0x00*/ u32 frequency; + /*0x04*/ u8 maxSimultaneousNotes; + /*0x05*/ u8 reverbDownsampleRate; // always 1 + /*0x06*/ u16 reverbWindowSize; + /*0x08*/ u16 reverbGain; + /*0x0A*/ u16 volume; + /*0x0C*/ u32 persistentSeqMem; + /*0x10*/ u32 persistentBankMem; + /*0x14*/ u32 temporarySeqMem; + /*0x18*/ u32 temporaryBankMem; +}; // size = 0x1C + +struct AudioBufferParametersEU { + /*0x00*/ s16 presetUnk4; // audio frames per vsync? + /*0x02*/ u16 frequency; + /*0x04*/ u16 aiFrequency; // ?16 + /*0x06*/ s16 samplesPerFrameTarget; + /*0x08*/ s16 maxAiBufferLength; + /*0x0A*/ s16 minAiBufferLength; + /*0x0C*/ s16 updatesPerFrame; + /*0x0E*/ s16 samplesPerUpdate; + /*0x10*/ s16 samplesPerUpdateMax; + /*0x12*/ s16 samplesPerUpdateMin; + /*0x14*/ f32 resampleRate; // contains 32000.0f / frequency + /*0x18*/ f32 updatesPerFrameInv; // 1.0f / updatesPerFrame + /*0x1C*/ f32 unkUpdatesPerFrameScaled; // 3.0f / (1280.0f * updatesPerFrame) +}; + +struct EuAudioCmd { + union { +#if IS_BIG_ENDIAN + struct { + u8 op; + u8 arg1; + u8 arg2; + u8 arg3; + } s; +#else + struct { + u8 arg3; + u8 arg2; + u8 arg1; + u8 op; + } s; +#endif + s32 first; + } u; + union { + s32 as_s32; + u32 as_u32; + f32 as_f32; +#if IS_BIG_ENDIAN + u8 as_u8; + s8 as_s8; +#else + struct { + u8 pad0[3]; + u8 as_u8; + }; + struct { + u8 pad1[3]; + s8 as_s8; + }; +#endif + } u2; +}; + +#endif // AUDIO_INTERNAL_H diff --git a/src/synthesis.c b/src/synthesis.c new file mode 100644 index 000000000..f27995494 --- /dev/null +++ b/src/synthesis.c @@ -0,0 +1,197 @@ +#include +#include +#include "synthesis.h" +//#include "heap.h" +//#include "data.h" +//#include "load.h" +//#include "seqplayer.h" +#include "internal.h" +//#include "external.h" + + +#define DMEM_ADDR_TEMP 0x0 +#define DMEM_ADDR_RESAMPLED 0x20 +#define DMEM_ADDR_RESAMPLED2 0x160 +#define DMEM_ADDR_UNCOMPRESSED_NOTE 0x180 +#define DMEM_ADDR_NOTE_PAN_TEMP 0x200 +#define DMEM_ADDR_STEREO_STRONG_TEMP_DRY 0x200 +#define DMEM_ADDR_STEREO_STRONG_TEMP_WET 0x340 +#define DMEM_ADDR_COMPRESSED_ADPCM_DATA 0x3f0 +#define DMEM_ADDR_LEFT_CH 0x4c0 +#define DMEM_ADDR_RIGHT_CH 0x600 +#define DMEM_ADDR_WET_LEFT_CH 0x740 +#define DMEM_ADDR_WET_RIGHT_CH 0x880 + +#define aSetLoadBufferPair(pkt, c, off) \ + aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_LEFT_CH, 0, DEFAULT_LEN_1CH - c); \ + aLoadBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.left + (off))); \ + aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_RIGHT_CH, 0, DEFAULT_LEN_1CH - c); \ + aLoadBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off))) + +#define aSetSaveBufferPair(pkt, c, d, off) \ + aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_LEFT_CH, d); \ + aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.left + (off))); \ + aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_RIGHT_CH, d); \ + aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off))); + +#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1)) + +struct VolumeChange { + u16 sourceLeft; + u16 sourceRight; + u16 targetLeft; + u16 targetRight; +}; + +u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex); +u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, u64 *cmd); +u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad); +u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags); +u64 *process_envelope(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags); +u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight); + +struct SynthesisReverb gSynthesisReverbs[4]; +u8 sAudioSynthesisPad[0x10]; +s16 gVolume; +s8 gUseReverb; +s8 gNumSynthesisReverbs; +struct NoteSubEu *gNoteSubsEu; + +extern struct Note *D_803B7088; +extern s32 D_803B70B0; + +f32 gLeftVolRampings[3][1024]; +f32 gRightVolRampings[3][1024]; +f32 *gCurrentLeftVolRamping; // Points to any of the three left buffers above +f32 *gCurrentRightVolRamping; // Points to any of the three right buffers above + +u8 audioString1[] = "pitch %x: delaybytes %d : olddelay %d\n"; +u8 audioString2[] = "cont %x: delaybytes %d : olddelay %d\n"; + +// Equivalent functionality as the US/JP version, +// just that the reverb structure is chosen from an array with index +void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex) { + struct ReverbRingBufferItem *item; + struct SynthesisReverb *reverb = &gSynthesisReverbs[reverbIndex]; + s32 srcPos; + s32 dstPos; + s32 nSamples; + s32 excessiveSamples; + s32 UNUSED pad[3]; + if (reverb->downsampleRate != 1) { + if (reverb->framesLeftToIgnore == 0) { + // Now that the RSP has finished, downsample the samples produced two frames ago by skipping + // samples. + item = &reverb->items[reverb->curFrame][updateIndex]; + + // Touches both left and right since they are adjacent in memory + osInvalDCache(item->toDownsampleLeft, 0x300); + + for (srcPos = 0, dstPos = 0; dstPos < item->lengthA / 2; + srcPos += reverb->downsampleRate, dstPos++) { + reverb->ringBuffer.left[item->startPos + dstPos] = + item->toDownsampleLeft[srcPos]; + reverb->ringBuffer.right[item->startPos + dstPos] = + item->toDownsampleRight[srcPos]; + } + for (dstPos = 0; dstPos < item->lengthB / 2; srcPos += reverb->downsampleRate, dstPos++) { + reverb->ringBuffer.left[dstPos] = item->toDownsampleLeft[srcPos]; + reverb->ringBuffer.right[dstPos] = item->toDownsampleRight[srcPos]; + } + } + } + + item = &reverb->items[reverb->curFrame][updateIndex]; + nSamples = chunkLen / reverb->downsampleRate; + excessiveSamples = (nSamples + reverb->nextRingBufferPos) - reverb->bufSizePerChannel; + if (excessiveSamples < 0) { + // There is space in the ring buffer before it wraps around + item->lengthA = nSamples * 2; + item->lengthB = 0; + item->startPos = (s32) reverb->nextRingBufferPos; + reverb->nextRingBufferPos += nSamples; + } else { + // Ring buffer wrapped around + item->lengthA = (nSamples - excessiveSamples) * 2; + item->lengthB = excessiveSamples * 2; + item->startPos = reverb->nextRingBufferPos; + reverb->nextRingBufferPos = excessiveSamples; + } + // These fields are never read later + item->numSamplesAfterDownsampling = nSamples; + item->chunkLen = chunkLen; +} +/* sm64 +u64 *synthesis_load_reverb_ring_buffer(u64 *cmd, u16 addr, u16 srcOffset, s32 len, s32 reverbIndex) { + aSetBuffer(cmd++, 0, addr, 0, len&0xFF<<0x10); + aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.left[srcOffset])); + + aSetBuffer(cmd++, 0, addr + DEFAULT_LEN_1CH, 0, len&0xFF<<0x10); + aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.right[srcOffset])); + + return cmd; +} +*/ +/* mk64 +void *synthesis_load_reverb_ring_buffer(void *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + s32 temp_t0; + s32 temp_t2; + void *temp_t1; + void *temp_t3; + + temp_t0 = (((arg3 >> 4) & 0xFF) << 0x10) | 0x14000000; + arg0->unk0 = (s32) (temp_t0 | (arg1 & 0xFFFF)); + temp_t1 = (arg4 * 0x108) + &gSynthesisReverbs; + temp_t2 = (arg2 & 0xFFFF) * 2; + arg0->unk4 = (s32) (temp_t1->unk18 + temp_t2 + 0x80000000); + temp_t3 = arg0 + 8; + temp_t3->unk0 = (s32) (temp_t0 | ((arg1 + 0x180) & 0xFFFF)); + temp_t3->unk4 = (s32) (temp_t1->unk1C + temp_t2 + 0x80000000); + return temp_t3 + 8; +} +*/ +// includes 2 funcs +GLOBAL_ASM("asm/non_matchings/audio/wip.s") + +/* sm64 +void synthesis_load_note_subs_eu(s32 updateIndex) { + struct NoteSubEu *src; + struct NoteSubEu *dest; + s32 i; + + for (i = 0; i < D_803B70B0; i++) { + src = &D_803B7088[i].noteSubEu; + dest = &gNoteSubsEu[D_803B70B0 * updateIndex + i]; + if (src->enabled) { + *dest = *src; + src->needsInit = FALSE; + } else { + dest->enabled = FALSE; + } + } +} +// mk64 m2c (with minor edits) struct access appears quite different. +void func_800B6FB4(s32 arg0, s32 arg1) { + s32 *dest; + s32 temp_v0; + s32 temp_v0_2; + s32 phi_v0; + + temp_v0 = arg0 + 1; + if (i = 0; temp_v0 < (s32) D_803B7088.unkC; i++) { + phi_v0 = temp_v0; + + for(i = 0; temp_v0_2 < (s32) D_803B7088.unkC; i++) { + dest = &gNoteSubsEu[D_803B70B0 * phi_v0 + (arg1 * 0x10)]; + if ((*dest * 2) >= 0) { + temp_v0_2 = phi_v0 + 1; + *dest = (s8) ((u8) *dest & 0xFF7F); + phi_v0 = temp_v0_2; + + } + } + } +} +*/ + +GLOBAL_ASM("asm/non_matchings/audio/synthesis.s") diff --git a/src/synthesis.h b/src/synthesis.h new file mode 100644 index 000000000..106d8ff23 --- /dev/null +++ b/src/synthesis.h @@ -0,0 +1,60 @@ +#ifndef AUDIO_SYNTHESIS_H +#define AUDIO_SYNTHESIS_H + +//#include "internal.h" + +#define VERSION_EU + +#define DEFAULT_LEN_1CH 0x140 +#define DEFAULT_LEN_2CH 0x280 + +#define MAX_UPDATES_PER_FRAME 5 + +struct ReverbRingBufferItem { + s16 numSamplesAfterDownsampling; + s16 chunkLen; // never read + s16 *toDownsampleLeft; + s16 *toDownsampleRight; // data pointed to by left and right are adjacent in memory + s32 startPos; // start pos in ring buffer + s16 lengthA; // first length in ring buffer (from startPos, at most until end) + s16 lengthB; // second length in ring buffer (from pos 0) +}; // size = 0x14 + +struct SynthesisReverb { + /*0x00, 0x00, 0x00*/ u8 resampleFlags; + /*0x01, 0x01, 0x01*/ u8 useReverb; + /*0x02, 0x02, 0x02*/ u8 framesLeftToIgnore; + /*0x03, 0x03, 0x03*/ u8 curFrame; + /* 0x04, 0x04*/ u8 downsampleRate; + /* 0x06, 0x06*/ u16 windowSize; // same as bufSizePerChannel + /*0x04, 0x08, 0x0A*/ u16 reverbGain; + /*0x06, 0x0A, 0x0C*/ u16 resampleRate; + /*0x08, 0x0C, 0x14*/ s32 nextRingBufferPos; + /*0x0C, 0x10, 0x18*/ s32 unkC; // never read + /*0x10, 0x14, 0x1C*/ s32 bufSizePerChannel; + struct { + s16 *left; + s16 *right; + } ringBuffer; + /*0x1C, 0x20, 0x28*/ s16 *resampleStateLeft; + /*0x20, 0x24, 0x2C*/ s16 *resampleStateRight; + /*0x24, 0x28, 0x30*/ s16 *unk24; // never read + /*0x28, 0x2C, 0x34*/ s16 *unk28; // never read + /*0x2C, 0x30, 0x38*/ struct ReverbRingBufferItem items[2][MAX_UPDATES_PER_FRAME]; + // Only used in sh: + /* 0x100*/ s16 *unk100; + /* 0x104*/ s16 *unk104; + /* 0x108*/ s16 *unk108; + /* 0x10C*/ s16 *unk10C; +}; // 0xCC <= size <= 0x10 +extern struct SynthesisReverb gSynthesisReverbs[4]; +extern s8 gNumSynthesisReverbs; +extern struct NoteSubEu *gNoteSubsEu; +extern f32 gLeftVolRampings[3][1024]; +extern f32 gRightVolRampings[3][1024]; +extern f32 *gCurrentLeftVolRamping; // Points to any of the three left buffers above +extern f32 *gCurrentRightVolRamping; // Points to any of the three right buffers above + +u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen); + +#endif // AUDIO_SYNTHESIS_H