diff --git a/Makefile b/Makefile index 7716b11546..8a29961ef5 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ TARGET = papermario CPPFLAGS = -fno-builtin -Iinclude -D _LANGUAGE_C -ffreestanding -DF3DEX_GBI_2 ASFLAGS = -EB -march=vr4300 -mtune=vr4300 -Iinclude OLDASFLAGS= -EB -Iinclude -G 0 -CFLAGS = -fno-builtin -O2 -quiet -G 0 -mcpu=vr4300 -mfix4300 -mips3 -mgp32 -mfp32 +CFLAGS = -O2 -quiet -G 0 -mcpu=vr4300 -mfix4300 -mips3 -mgp32 -mfp32 LDFLAGS = -T undefined_syms.txt -T $(LD_SCRIPT) -Map $(BUILD_DIR)/papermario.map --no-check-sections ######################## Targets ############################# diff --git a/asm/nonmatchings/code_ddaf0_len_c50/func_80147414.s b/asm/nonmatchings/code_ddaf0_len_c50/func_80147414.s index f8e5ca5703..76dde18808 100644 --- a/asm/nonmatchings/code_ddaf0_len_c50/func_80147414.s +++ b/asm/nonmatchings/code_ddaf0_len_c50/func_80147414.s @@ -29,151 +29,3 @@ glabel func_80147414 /* 0DDB68 80147468 24A50020 */ addiu $a1, $a1, 0x20 /* 0DDB6C 8014746C 03E00008 */ jr $ra /* 0DDB70 80147470 00000000 */ nop - -/* 0DDB74 80147474 3C028016 */ lui $v0, 0x8016 -/* 0DDB78 80147478 24429D50 */ addiu $v0, $v0, -0x62b0 -/* 0DDB7C 8014747C 00042140 */ sll $a0, $a0, 5 -/* 0DDB80 80147480 00822021 */ addu $a0, $a0, $v0 -/* 0DDB84 80147484 8FA70014 */ lw $a3, 0x14($sp) -/* 0DDB88 80147488 8FA80018 */ lw $t0, 0x18($sp) -/* 0DDB8C 8014748C 9086001C */ lbu $a2, 0x1c($a0) -/* 0DDB90 80147490 8FA90024 */ lw $t1, 0x24($sp) -/* 0DDB94 80147494 14C00005 */ bnez $a2, .L801474AC -/* 0DDB98 80147498 28C20005 */ slti $v0, $a2, 5 -/* 0DDB9C 8014749C 90820000 */ lbu $v0, ($a0) -/* 0DDBA0 801474A0 304200FB */ andi $v0, $v0, 0xfb -/* 0DDBA4 801474A4 A0820000 */ sb $v0, ($a0) -/* 0DDBA8 801474A8 28C20005 */ slti $v0, $a2, 5 -.L801474AC: -/* 0DDBAC 801474AC 10400025 */ beqz $v0, .L80147544 -/* 0DDBB0 801474B0 00000000 */ nop -/* 0DDBB4 801474B4 3C038015 */ lui $v1, 0x8015 -/* 0DDBB8 801474B8 2463F298 */ addiu $v1, $v1, -0xd68 -/* 0DDBBC 801474BC 3C028015 */ lui $v0, 0x8015 -/* 0DDBC0 801474C0 00461021 */ addu $v0, $v0, $a2 -/* 0DDBC4 801474C4 9042F2A0 */ lbu $v0, -0xd60($v0) -/* 0DDBC8 801474C8 00C31821 */ addu $v1, $a2, $v1 -/* 0DDBCC 801474CC ACA20000 */ sw $v0, ($a1) -/* 0DDBD0 801474D0 90620000 */ lbu $v0, ($v1) -/* 0DDBD4 801474D4 3C018015 */ lui $at, 0x8015 -/* 0DDBD8 801474D8 D4221240 */ ldc1 $f2, 0x1240($at) -/* 0DDBDC 801474DC 44820000 */ mtc1 $v0, $f0 -/* 0DDBE0 801474E0 00000000 */ nop -/* 0DDBE4 801474E4 46800020 */ cvt.s.w $f0, $f0 -/* 0DDBE8 801474E8 46000021 */ cvt.d.s $f0, $f0 -/* 0DDBEC 801474EC 46220002 */ mul.d $f0, $f0, $f2 -/* 0DDBF0 801474F0 00000000 */ nop -/* 0DDBF4 801474F4 46200020 */ cvt.s.d $f0, $f0 -/* 0DDBF8 801474F8 E4E00000 */ swc1 $f0, ($a3) -/* 0DDBFC 801474FC 90620000 */ lbu $v0, ($v1) -/* 0DDC00 80147500 44820000 */ mtc1 $v0, $f0 -/* 0DDC04 80147504 00000000 */ nop -/* 0DDC08 80147508 46800020 */ cvt.s.w $f0, $f0 -/* 0DDC0C 8014750C 46000021 */ cvt.d.s $f0, $f0 -/* 0DDC10 80147510 46220002 */ mul.d $f0, $f0, $f2 -/* 0DDC14 80147514 00000000 */ nop -/* 0DDC18 80147518 24030004 */ addiu $v1, $zero, 4 -/* 0DDC1C 8014751C 00661823 */ subu $v1, $v1, $a2 -/* 0DDC20 80147520 00031040 */ sll $v0, $v1, 1 -/* 0DDC24 80147524 00431021 */ addu $v0, $v0, $v1 -/* 0DDC28 80147528 46200020 */ cvt.s.d $f0, $f0 -/* 0DDC2C 8014752C E5000000 */ swc1 $f0, ($t0) -/* 0DDC30 80147530 44820000 */ mtc1 $v0, $f0 -/* 0DDC34 80147534 00000000 */ nop -/* 0DDC38 80147538 46800020 */ cvt.s.w $f0, $f0 -/* 0DDC3C 8014753C 03E00008 */ jr $ra -/* 0DDC40 80147540 E5200000 */ swc1 $f0, ($t1) - -.L80147544: -/* 0DDC44 80147544 3C028015 */ lui $v0, 0x8015 -/* 0DDC48 80147548 9042F2A4 */ lbu $v0, -0xd5c($v0) -/* 0DDC4C 8014754C 3C013F80 */ lui $at, 0x3f80 -/* 0DDC50 80147550 44810000 */ mtc1 $at, $f0 -/* 0DDC54 80147554 ACA20000 */ sw $v0, ($a1) -/* 0DDC58 80147558 E4E00000 */ swc1 $f0, ($a3) -/* 0DDC5C 8014755C E5000000 */ swc1 $f0, ($t0) -/* 0DDC60 80147560 AD200000 */ sw $zero, ($t1) -/* 0DDC64 80147564 90820000 */ lbu $v0, ($a0) -/* 0DDC68 80147568 304200F7 */ andi $v0, $v0, 0xf7 -/* 0DDC6C 8014756C 03E00008 */ jr $ra -/* 0DDC70 80147570 A0820000 */ sb $v0, ($a0) - -/* 0DDC74 80147574 3C028016 */ lui $v0, 0x8016 -/* 0DDC78 80147578 24429D50 */ addiu $v0, $v0, -0x62b0 -/* 0DDC7C 8014757C 00042140 */ sll $a0, $a0, 5 -/* 0DDC80 80147580 00822021 */ addu $a0, $a0, $v0 -/* 0DDC84 80147584 9086001C */ lbu $a2, 0x1c($a0) -/* 0DDC88 80147588 8FA70014 */ lw $a3, 0x14($sp) -/* 0DDC8C 8014758C 8FA80018 */ lw $t0, 0x18($sp) -/* 0DDC90 80147590 8FA90024 */ lw $t1, 0x24($sp) -/* 0DDC94 80147594 28C2000A */ slti $v0, $a2, 0xa -/* 0DDC98 80147598 10400022 */ beqz $v0, .L80147624 -/* 0DDC9C 8014759C 00000000 */ nop -/* 0DDCA0 801475A0 3C038015 */ lui $v1, 0x8015 -/* 0DDCA4 801475A4 2463F2A8 */ addiu $v1, $v1, -0xd58 -/* 0DDCA8 801475A8 3C028015 */ lui $v0, 0x8015 -/* 0DDCAC 801475AC 00461021 */ addu $v0, $v0, $a2 -/* 0DDCB0 801475B0 9042F2B4 */ lbu $v0, -0xd4c($v0) -/* 0DDCB4 801475B4 00C31821 */ addu $v1, $a2, $v1 -/* 0DDCB8 801475B8 ACA20000 */ sw $v0, ($a1) -/* 0DDCBC 801475BC 90620000 */ lbu $v0, ($v1) -/* 0DDCC0 801475C0 3C018015 */ lui $at, 0x8015 -/* 0DDCC4 801475C4 D4221248 */ ldc1 $f2, 0x1248($at) -/* 0DDCC8 801475C8 44820000 */ mtc1 $v0, $f0 -/* 0DDCCC 801475CC 00000000 */ nop -/* 0DDCD0 801475D0 46800020 */ cvt.s.w $f0, $f0 -/* 0DDCD4 801475D4 46000021 */ cvt.d.s $f0, $f0 -/* 0DDCD8 801475D8 46220002 */ mul.d $f0, $f0, $f2 -/* 0DDCDC 801475DC 00000000 */ nop -/* 0DDCE0 801475E0 46200020 */ cvt.s.d $f0, $f0 -/* 0DDCE4 801475E4 E4E00000 */ swc1 $f0, ($a3) -/* 0DDCE8 801475E8 90620000 */ lbu $v0, ($v1) -/* 0DDCEC 801475EC 44820000 */ mtc1 $v0, $f0 -/* 0DDCF0 801475F0 00000000 */ nop -/* 0DDCF4 801475F4 46800020 */ cvt.s.w $f0, $f0 -/* 0DDCF8 801475F8 46000021 */ cvt.d.s $f0, $f0 -/* 0DDCFC 801475FC 46220002 */ mul.d $f0, $f0, $f2 -/* 0DDD00 80147600 00000000 */ nop -/* 0DDD04 80147604 00061023 */ negu $v0, $a2 -/* 0DDD08 80147608 46200020 */ cvt.s.d $f0, $f0 -/* 0DDD0C 8014760C E5000000 */ swc1 $f0, ($t0) -/* 0DDD10 80147610 44820000 */ mtc1 $v0, $f0 -/* 0DDD14 80147614 00000000 */ nop -/* 0DDD18 80147618 46800020 */ cvt.s.w $f0, $f0 -/* 0DDD1C 8014761C 03E00008 */ jr $ra -/* 0DDD20 80147620 E5200000 */ swc1 $f0, ($t1) - -.L80147624: -/* 0DDD24 80147624 3C028015 */ lui $v0, 0x8015 -/* 0DDD28 80147628 9042F2BD */ lbu $v0, -0xd43($v0) -/* 0DDD2C 8014762C ACA20000 */ sw $v0, ($a1) -/* 0DDD30 80147630 ACE00000 */ sw $zero, ($a3) -/* 0DDD34 80147634 AD000000 */ sw $zero, ($t0) -/* 0DDD38 80147638 AD200000 */ sw $zero, ($t1) -/* 0DDD3C 8014763C 90820000 */ lbu $v0, ($a0) -/* 0DDD40 80147640 304200F7 */ andi $v0, $v0, 0xf7 -/* 0DDD44 80147644 34420004 */ ori $v0, $v0, 4 -/* 0DDD48 80147648 03E00008 */ jr $ra -/* 0DDD4C 8014764C A0820000 */ sb $v0, ($a0) - -/* 0DDD50 80147650 3C028016 */ lui $v0, 0x8016 -/* 0DDD54 80147654 24429D50 */ addiu $v0, $v0, -0x62b0 -/* 0DDD58 80147658 00042140 */ sll $a0, $a0, 5 -/* 0DDD5C 8014765C 00822021 */ addu $a0, $a0, $v0 -/* 0DDD60 80147660 9083001C */ lbu $v1, 0x1c($a0) -/* 0DDD64 80147664 8FA50028 */ lw $a1, 0x28($sp) -/* 0DDD68 80147668 2862000A */ slti $v0, $v1, 0xa -/* 0DDD6C 8014766C 10400005 */ beqz $v0, .L80147684 -/* 0DDD70 80147670 240200A0 */ addiu $v0, $zero, 0xa0 -/* 0DDD74 80147674 24620001 */ addiu $v0, $v1, 1 -/* 0DDD78 80147678 00021100 */ sll $v0, $v0, 4 -/* 0DDD7C 8014767C 03E00008 */ jr $ra -/* 0DDD80 80147680 ACA20000 */ sw $v0, ($a1) - -.L80147684: -/* 0DDD84 80147684 ACA20000 */ sw $v0, ($a1) -/* 0DDD88 80147688 90820000 */ lbu $v0, ($a0) -/* 0DDD8C 8014768C 304200F3 */ andi $v0, $v0, 0xf3 -/* 0DDD90 80147690 03E00008 */ jr $ra -/* 0DDD94 80147694 A0820000 */ sb $v0, ($a0) - diff --git a/asm/nonmatchings/code_ddaf0_len_c50/func_80147474.s b/asm/nonmatchings/code_ddaf0_len_c50/func_80147474.s new file mode 100644 index 0000000000..4c48ec102c --- /dev/null +++ b/asm/nonmatchings/code_ddaf0_len_c50/func_80147474.s @@ -0,0 +1,72 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + + +glabel func_80147474 +/* 0DDB74 80147474 3C028016 */ lui $v0, 0x8016 +/* 0DDB78 80147478 24429D50 */ addiu $v0, $v0, -0x62b0 +/* 0DDB7C 8014747C 00042140 */ sll $a0, $a0, 5 +/* 0DDB80 80147480 00822021 */ addu $a0, $a0, $v0 +/* 0DDB84 80147484 8FA70014 */ lw $a3, 0x14($sp) +/* 0DDB88 80147488 8FA80018 */ lw $t0, 0x18($sp) +/* 0DDB8C 8014748C 9086001C */ lbu $a2, 0x1c($a0) +/* 0DDB90 80147490 8FA90024 */ lw $t1, 0x24($sp) +/* 0DDB94 80147494 14C00005 */ bnez $a2, .L801474AC +/* 0DDB98 80147498 28C20005 */ slti $v0, $a2, 5 +/* 0DDB9C 8014749C 90820000 */ lbu $v0, ($a0) +/* 0DDBA0 801474A0 304200FB */ andi $v0, $v0, 0xfb +/* 0DDBA4 801474A4 A0820000 */ sb $v0, ($a0) +/* 0DDBA8 801474A8 28C20005 */ slti $v0, $a2, 5 +.L801474AC: +/* 0DDBAC 801474AC 10400025 */ beqz $v0, .L80147544 +/* 0DDBB0 801474B0 00000000 */ nop +/* 0DDBB4 801474B4 3C038015 */ lui $v1, 0x8015 +/* 0DDBB8 801474B8 2463F298 */ addiu $v1, $v1, -0xd68 +/* 0DDBBC 801474BC 3C028015 */ lui $v0, 0x8015 +/* 0DDBC0 801474C0 00461021 */ addu $v0, $v0, $a2 +/* 0DDBC4 801474C4 9042F2A0 */ lbu $v0, -0xd60($v0) +/* 0DDBC8 801474C8 00C31821 */ addu $v1, $a2, $v1 +/* 0DDBCC 801474CC ACA20000 */ sw $v0, ($a1) +/* 0DDBD0 801474D0 90620000 */ lbu $v0, ($v1) +/* 0DDBD4 801474D4 3C018015 */ lui $at, 0x8015 +/* 0DDBD8 801474D8 D4221240 */ ldc1 $f2, 0x1240($at) +/* 0DDBDC 801474DC 44820000 */ mtc1 $v0, $f0 +/* 0DDBE0 801474E0 00000000 */ nop +/* 0DDBE4 801474E4 46800020 */ cvt.s.w $f0, $f0 +/* 0DDBE8 801474E8 46000021 */ cvt.d.s $f0, $f0 +/* 0DDBEC 801474EC 46220002 */ mul.d $f0, $f0, $f2 +/* 0DDBF0 801474F0 00000000 */ nop +/* 0DDBF4 801474F4 46200020 */ cvt.s.d $f0, $f0 +/* 0DDBF8 801474F8 E4E00000 */ swc1 $f0, ($a3) +/* 0DDBFC 801474FC 90620000 */ lbu $v0, ($v1) +/* 0DDC00 80147500 44820000 */ mtc1 $v0, $f0 +/* 0DDC04 80147504 00000000 */ nop +/* 0DDC08 80147508 46800020 */ cvt.s.w $f0, $f0 +/* 0DDC0C 8014750C 46000021 */ cvt.d.s $f0, $f0 +/* 0DDC10 80147510 46220002 */ mul.d $f0, $f0, $f2 +/* 0DDC14 80147514 00000000 */ nop +/* 0DDC18 80147518 24030004 */ addiu $v1, $zero, 4 +/* 0DDC1C 8014751C 00661823 */ subu $v1, $v1, $a2 +/* 0DDC20 80147520 00031040 */ sll $v0, $v1, 1 +/* 0DDC24 80147524 00431021 */ addu $v0, $v0, $v1 +/* 0DDC28 80147528 46200020 */ cvt.s.d $f0, $f0 +/* 0DDC2C 8014752C E5000000 */ swc1 $f0, ($t0) +/* 0DDC30 80147530 44820000 */ mtc1 $v0, $f0 +/* 0DDC34 80147534 00000000 */ nop +/* 0DDC38 80147538 46800020 */ cvt.s.w $f0, $f0 +/* 0DDC3C 8014753C 03E00008 */ jr $ra +/* 0DDC40 80147540 E5200000 */ swc1 $f0, ($t1) + +.L80147544: +/* 0DDC44 80147544 3C028015 */ lui $v0, 0x8015 +/* 0DDC48 80147548 9042F2A4 */ lbu $v0, -0xd5c($v0) +/* 0DDC4C 8014754C 3C013F80 */ lui $at, 0x3f80 +/* 0DDC50 80147550 44810000 */ mtc1 $at, $f0 +/* 0DDC54 80147554 ACA20000 */ sw $v0, ($a1) +/* 0DDC58 80147558 E4E00000 */ swc1 $f0, ($a3) +/* 0DDC5C 8014755C E5000000 */ swc1 $f0, ($t0) +/* 0DDC60 80147560 AD200000 */ sw $zero, ($t1) +/* 0DDC64 80147564 90820000 */ lbu $v0, ($a0) +/* 0DDC68 80147568 304200F7 */ andi $v0, $v0, 0xf7 +/* 0DDC6C 8014756C 03E00008 */ jr $ra +/* 0DDC70 80147570 A0820000 */ sb $v0, ($a0) \ No newline at end of file diff --git a/asm/nonmatchings/code_ddaf0_len_c50/func_80147574.s b/asm/nonmatchings/code_ddaf0_len_c50/func_80147574.s new file mode 100644 index 0000000000..655dd90699 --- /dev/null +++ b/asm/nonmatchings/code_ddaf0_len_c50/func_80147574.s @@ -0,0 +1,61 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + +glabel func_80147574 +/* 0DDC74 80147574 3C028016 */ lui $v0, 0x8016 +/* 0DDC78 80147578 24429D50 */ addiu $v0, $v0, -0x62b0 +/* 0DDC7C 8014757C 00042140 */ sll $a0, $a0, 5 +/* 0DDC80 80147580 00822021 */ addu $a0, $a0, $v0 +/* 0DDC84 80147584 9086001C */ lbu $a2, 0x1c($a0) +/* 0DDC88 80147588 8FA70014 */ lw $a3, 0x14($sp) +/* 0DDC8C 8014758C 8FA80018 */ lw $t0, 0x18($sp) +/* 0DDC90 80147590 8FA90024 */ lw $t1, 0x24($sp) +/* 0DDC94 80147594 28C2000A */ slti $v0, $a2, 0xa +/* 0DDC98 80147598 10400022 */ beqz $v0, .L80147624 +/* 0DDC9C 8014759C 00000000 */ nop +/* 0DDCA0 801475A0 3C038015 */ lui $v1, 0x8015 +/* 0DDCA4 801475A4 2463F2A8 */ addiu $v1, $v1, -0xd58 +/* 0DDCA8 801475A8 3C028015 */ lui $v0, 0x8015 +/* 0DDCAC 801475AC 00461021 */ addu $v0, $v0, $a2 +/* 0DDCB0 801475B0 9042F2B4 */ lbu $v0, -0xd4c($v0) +/* 0DDCB4 801475B4 00C31821 */ addu $v1, $a2, $v1 +/* 0DDCB8 801475B8 ACA20000 */ sw $v0, ($a1) +/* 0DDCBC 801475BC 90620000 */ lbu $v0, ($v1) +/* 0DDCC0 801475C0 3C018015 */ lui $at, 0x8015 +/* 0DDCC4 801475C4 D4221248 */ ldc1 $f2, 0x1248($at) +/* 0DDCC8 801475C8 44820000 */ mtc1 $v0, $f0 +/* 0DDCCC 801475CC 00000000 */ nop +/* 0DDCD0 801475D0 46800020 */ cvt.s.w $f0, $f0 +/* 0DDCD4 801475D4 46000021 */ cvt.d.s $f0, $f0 +/* 0DDCD8 801475D8 46220002 */ mul.d $f0, $f0, $f2 +/* 0DDCDC 801475DC 00000000 */ nop +/* 0DDCE0 801475E0 46200020 */ cvt.s.d $f0, $f0 +/* 0DDCE4 801475E4 E4E00000 */ swc1 $f0, ($a3) +/* 0DDCE8 801475E8 90620000 */ lbu $v0, ($v1) +/* 0DDCEC 801475EC 44820000 */ mtc1 $v0, $f0 +/* 0DDCF0 801475F0 00000000 */ nop +/* 0DDCF4 801475F4 46800020 */ cvt.s.w $f0, $f0 +/* 0DDCF8 801475F8 46000021 */ cvt.d.s $f0, $f0 +/* 0DDCFC 801475FC 46220002 */ mul.d $f0, $f0, $f2 +/* 0DDD00 80147600 00000000 */ nop +/* 0DDD04 80147604 00061023 */ negu $v0, $a2 +/* 0DDD08 80147608 46200020 */ cvt.s.d $f0, $f0 +/* 0DDD0C 8014760C E5000000 */ swc1 $f0, ($t0) +/* 0DDD10 80147610 44820000 */ mtc1 $v0, $f0 +/* 0DDD14 80147614 00000000 */ nop +/* 0DDD18 80147618 46800020 */ cvt.s.w $f0, $f0 +/* 0DDD1C 8014761C 03E00008 */ jr $ra +/* 0DDD20 80147620 E5200000 */ swc1 $f0, ($t1) + +.L80147624: +/* 0DDD24 80147624 3C028015 */ lui $v0, 0x8015 +/* 0DDD28 80147628 9042F2BD */ lbu $v0, -0xd43($v0) +/* 0DDD2C 8014762C ACA20000 */ sw $v0, ($a1) +/* 0DDD30 80147630 ACE00000 */ sw $zero, ($a3) +/* 0DDD34 80147634 AD000000 */ sw $zero, ($t0) +/* 0DDD38 80147638 AD200000 */ sw $zero, ($t1) +/* 0DDD3C 8014763C 90820000 */ lbu $v0, ($a0) +/* 0DDD40 80147640 304200F7 */ andi $v0, $v0, 0xf7 +/* 0DDD44 80147644 34420004 */ ori $v0, $v0, 4 +/* 0DDD48 80147648 03E00008 */ jr $ra +/* 0DDD4C 8014764C A0820000 */ sb $v0, ($a0) \ No newline at end of file diff --git a/asm/nonmatchings/code_ddaf0_len_c50/func_80147650.s b/asm/nonmatchings/code_ddaf0_len_c50/func_80147650.s new file mode 100644 index 0000000000..6c7bdae395 --- /dev/null +++ b/asm/nonmatchings/code_ddaf0_len_c50/func_80147650.s @@ -0,0 +1,25 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + + +glabel func_80147650 +/* 0DDD50 80147650 3C028016 */ lui $v0, 0x8016 +/* 0DDD54 80147654 24429D50 */ addiu $v0, $v0, -0x62b0 +/* 0DDD58 80147658 00042140 */ sll $a0, $a0, 5 +/* 0DDD5C 8014765C 00822021 */ addu $a0, $a0, $v0 +/* 0DDD60 80147660 9083001C */ lbu $v1, 0x1c($a0) +/* 0DDD64 80147664 8FA50028 */ lw $a1, 0x28($sp) +/* 0DDD68 80147668 2862000A */ slti $v0, $v1, 0xa +/* 0DDD6C 8014766C 10400005 */ beqz $v0, .L80147684 +/* 0DDD70 80147670 240200A0 */ addiu $v0, $zero, 0xa0 +/* 0DDD74 80147674 24620001 */ addiu $v0, $v1, 1 +/* 0DDD78 80147678 00021100 */ sll $v0, $v0, 4 +/* 0DDD7C 8014767C 03E00008 */ jr $ra +/* 0DDD80 80147680 ACA20000 */ sw $v0, ($a1) + +.L80147684: +/* 0DDD84 80147684 ACA20000 */ sw $v0, ($a1) +/* 0DDD88 80147688 90820000 */ lbu $v0, ($a0) +/* 0DDD8C 8014768C 304200F3 */ andi $v0, $v0, 0xf3 +/* 0DDD90 80147690 03E00008 */ jr $ra +/* 0DDD94 80147694 A0820000 */ sb $v0, ($a0) \ No newline at end of file diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AF8C.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AF8C.s index 33d2188d53..cf41509f79 100644 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AF8C.s +++ b/asm/nonmatchings/code_e0b30_len_b80/func_8014AF8C.s @@ -8,11 +8,3 @@ glabel func_8014AF8C /* 0E1694 8014AF94 AC44001C */ sw $a0, 0x1c($v0) /* 0E1698 8014AF98 03E00008 */ jr $ra /* 0E169C 8014AF9C AC450020 */ sw $a1, 0x20($v0) - -/* 0E16A0 8014AFA0 03E00008 */ jr $ra -/* 0E16A4 8014AFA4 00000000 */ nop - -/* 0E16A8 8014AFA8 00000000 */ nop -/* 0E16AC 8014AFAC 00000000 */ nop - - diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AFA0.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AFA0.s new file mode 100644 index 0000000000..1414b36b21 --- /dev/null +++ b/asm/nonmatchings/code_e0b30_len_b80/func_8014AFA0.s @@ -0,0 +1,10 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + + +glabel func_8014AFA0 +/* 0E16A0 8014AFA0 03E00008 */ jr $ra +/* 0E16A4 8014AFA4 00000000 */ nop + +/* 0E16A8 8014AFA8 00000000 */ nop +/* 0E16AC 8014AFAC 00000000 */ nop \ No newline at end of file diff --git a/asm/nonmatchings/os/code_3d2f0_len_10/sqrtf.s b/asm/nonmatchings/os/code_3d2f0_len_10/sqrtf_.s similarity index 94% rename from asm/nonmatchings/os/code_3d2f0_len_10/sqrtf.s rename to asm/nonmatchings/os/code_3d2f0_len_10/sqrtf_.s index 723c0c0d32..52b7b2ec73 100644 --- a/asm/nonmatchings/os/code_3d2f0_len_10/sqrtf.s +++ b/asm/nonmatchings/os/code_3d2f0_len_10/sqrtf_.s @@ -2,7 +2,7 @@ .set noreorder # don't insert nops after branches -glabel sqrtf +glabel sqrtf_ /* 03D2F0 80061EF0 03E00008 */ jr $ra /* 03D2F4 80061EF4 46006004 */ sqrt.s $f0, $f12 diff --git a/diff.py b/diff.py index 013d935948..0e1da09deb 100755 --- a/diff.py +++ b/diff.py @@ -1,48 +1,71 @@ #!/usr/bin/env python3 import sys -import re -import os -import ast -import argparse -import subprocess -import collections -import difflib -import string -import itertools -import threading -import queue -import time - def fail(msg): print(msg, file=sys.stderr) sys.exit(1) - -MISSING_PREREQUISITES = ( - "Missing prerequisite python module {}. " - "Run `python3 -m pip install --user colorama ansiwrap attrs watchdog python-Levenshtein cxxfilt` to install prerequisites (cxxfilt only needed with --source)." -) - -try: - import attr - from colorama import Fore, Style, Back - import ansiwrap - import watchdog -except ModuleNotFoundError as e: - fail(MISSING_PREREQUISITES.format(e.name)) - # Prefer to use diff_settings.py from the current working directory sys.path.insert(0, ".") try: import diff_settings except ModuleNotFoundError: fail("Unable to find diff_settings.py in the same directory.") +sys.path.pop(0) -# ==== CONFIG ==== +# ==== COMMAND-LINE ==== + +try: + import argcomplete # type: ignore +except ModuleNotFoundError: + argcomplete = None +import argparse parser = argparse.ArgumentParser(description="Diff MIPS assembly.") -parser.add_argument("start", help="Function name or address to start diffing from.") + +start_argument = parser.add_argument("start", help="Function name or address to start diffing from.") +if argcomplete: + def complete_symbol(**kwargs): + prefix = kwargs["prefix"] + if prefix == "": + # skip reading the map file, which would + # result in a lot of useless completions + return [] + parsed_args = kwargs["parsed_args"] + config = {} + diff_settings.apply(config, parsed_args) + mapfile = config.get("mapfile") + if not mapfile: + return [] + completes = [] + with open(mapfile) as f: + data = f.read() + # assume symbols are prefixed by a space character + search = f" {prefix}" + pos = data.find(search) + while pos != -1: + # skip the space character in the search string + pos += 1 + # assume symbols are suffixed by either a space + # character or a (unix-style) line return + spacePos = data.find(" ", pos) + lineReturnPos = data.find("\n", pos) + if lineReturnPos == -1: + endPos = spacePos + elif spacePos == -1: + endPos = lineReturnPos + else: + endPos = min(spacePos, lineReturnPos) + if endPos == -1: + match = data[pos:] + pos = -1 + else: + match = data[pos:endPos] + pos = data.find(search, endPos) + completes.append(match) + return completes + start_argument.completer = complete_symbol + parser.add_argument("end", nargs="?", help="Address to end diff at.") parser.add_argument( "-o", @@ -52,6 +75,7 @@ parser.add_argument( ) parser.add_argument( "-e", + "--elf", dest="diff_elf_symbol", help="Diff a given function in two ELFs, one being stripped and the other one non-stripped. Requires objdump from binutils 2.33+.", ) @@ -132,6 +156,14 @@ parser.add_argument( help="Automatically update when source/object files change. " "Recommended in combination with -m.", ) +parser.add_argument( + "-3", + "--threeway", + dest="threeway", + action="store_true", + help="Show a three-way diff between target asm, current asm, and asm " + "prior to -w rebuild. Requires -w.", +) parser.add_argument( "--width", dest="column_width", @@ -146,7 +178,6 @@ parser.add_argument( choices=["levenshtein", "difflib"], help="Diff algorithm to use.", ) - parser.add_argument( "--max-size", "--max-lines", @@ -158,12 +189,44 @@ parser.add_argument( # Project-specific flags, e.g. different versions/make arguments. if hasattr(diff_settings, "add_custom_arguments"): - diff_settings.add_custom_arguments(parser) + diff_settings.add_custom_arguments(parser) # type: ignore + +if argcomplete: + argcomplete.autocomplete(parser) + +# ==== IMPORTS ==== + +import re +import os +import ast +import subprocess +import difflib +import string +import itertools +import threading +import queue +import time +from typing import Any, Dict, List, NamedTuple, Optional, Set, Tuple, Union + + +MISSING_PREREQUISITES = ( + "Missing prerequisite python module {}. " + "Run `python3 -m pip install --user colorama ansiwrap watchdog python-Levenshtein cxxfilt` to install prerequisites (cxxfilt only needed with --source)." +) + +try: + from colorama import Fore, Style, Back # type: ignore + import ansiwrap # type: ignore + import watchdog # type: ignore +except ModuleNotFoundError as e: + fail(MISSING_PREREQUISITES.format(e.name)) + +# ==== CONFIG ==== args = parser.parse_args() # Set imgs, map file and make flags in a project-specific manner. -config = {} +config: Dict[str, Any] = {} diff_settings.apply(config, args) arch = config.get("arch", "mips") @@ -199,13 +262,13 @@ FS_WATCH_EXTENSIONS = [".c", ".h"] if args.algorithm == "levenshtein": try: - import Levenshtein + import Levenshtein # type: ignore except ModuleNotFoundError as e: fail(MISSING_PREREQUISITES.format(e.name)) if args.source: try: - import cxxfilt + import cxxfilt # type: ignore except ModuleNotFoundError as e: fail(MISSING_PREREQUISITES.format(e.name)) @@ -538,22 +601,21 @@ def process_mips_reloc(row, prev): return before + repl + after -def cleanup_whitespace(line): - return "".join(f"{o:<8s}" for o in line.strip().split("\t")) +def pad_mnemonic(line): + if "\t" not in line: + return line + mn, args = line.split("\t", 1) + return f"{mn:<7s} {args}" -Line = collections.namedtuple( - "Line", - [ - "mnemonic", - "diff_row", - "original", - "line_num", - "branch_target", - "source_lines", - "comment", - ], -) +class Line(NamedTuple): + mnemonic: str + diff_row: str + original: str + line_num: str + branch_target: Optional[str] + source_lines: List[str] + comment: Optional[str] def process(lines): @@ -565,6 +627,7 @@ def process(lines): lines.pop() output = [] + stop_after_delay_slot = False for row in lines: if args.diff_obj and (">:" in row or not row): continue @@ -634,18 +697,15 @@ def process(lines): source_lines = [] if args.stop_jrra and mnemonic == "jr" and row_parts[1].strip() == "ra": + stop_after_delay_slot = True + elif stop_after_delay_slot: break - # Cleanup whitespace, after relocation fixups have happened - output = [ - line._replace(original=cleanup_whitespace(line.original)) for line in output - ] - return output def format_single_line_diff(line1, line2, column_width): - return f"{ansi_ljust(line1,column_width)}{ansi_ljust(line2,column_width)}" + return f"{ansi_ljust(line1,column_width)}{line2}" class SymbolColorer: @@ -743,11 +803,27 @@ def diff_sequences(seq1, seq2): return Levenshtein.opcodes(seq1, seq2) -def do_diff(basedump, mydump): - output = [] +class OutputLine: + base: Optional[str] + fmt2: str + key2: str - # TODO: status line? - # output.append(sha1sum(mydump)) + def __init__(self, base: Optional[str], fmt2: str, key2: str) -> None: + self.base = base + self.fmt2 = fmt2 + self.key2 = key2 + + def __eq__(self, other: object) -> bool: + if not isinstance(other, OutputLine): + return NotImplemented + return self.key2 == other.key2 + + def __hash__(self) -> int: + return hash(self.key2) + + +def do_diff(basedump: str, mydump: str) -> List[OutputLine]: + output: List[OutputLine] = [] lines1 = process(basedump.split("\n")) lines2 = process(mydump.split("\n")) @@ -758,8 +834,8 @@ def do_diff(basedump, mydump): sc4 = SymbolColorer(4) sc5 = SymbolColorer(0) sc6 = SymbolColorer(0) - bts1 = set() - bts2 = set() + bts1: Set[str] = set() + bts2: Set[str] = set() if args.show_branches: for (lines, btset, sc) in [ @@ -856,40 +932,36 @@ def do_diff(basedump, mydump): out2 = line2.original elif line1: line_prefix = "<" - line_color1 = line_color2 = sym_color = Fore.RED + line_color1 = sym_color = Fore.RED out1 = line1.original out2 = "" elif line2: line_prefix = ">" - line_color1 = line_color2 = sym_color = Fore.GREEN + line_color2 = sym_color = Fore.GREEN out1 = "" out2 = line2.original - in_arrow1 = " " - in_arrow2 = " " - out_arrow1 = "" - out_arrow2 = "" - - if args.show_branches and line1: - if line1.line_num in bts1: - in_arrow1 = sc5.color_symbol(line1.line_num, "~>") + line_color1 - if line1.branch_target is not None: - out_arrow1 = " " + sc5.color_symbol(line1.branch_target + ":", "~>") - if args.show_branches and line2: - if line2.line_num in bts2: - in_arrow2 = sc6.color_symbol(line2.line_num, "~>") + line_color2 - if line2.branch_target is not None: - out_arrow2 = " " + sc6.color_symbol(line2.branch_target + ":", "~>") - if args.source and line2 and line2.comment: out2 += f" {line2.comment}" - line_num1 = line1.line_num if line1 else "" - line_num2 = line2.line_num if line2 else "" + def format_part(out: str, line: Optional[Line], line_color: str, btset: Set[str], sc: SymbolColorer) -> Optional[str]: + if line is None: + return None + in_arrow = " " + out_arrow = "" + if args.show_branches: + if line.line_num in btset: + in_arrow = sc.color_symbol(line.line_num, "~>") + line_color + if line.branch_target is not None: + out_arrow = " " + sc.color_symbol(line.branch_target + ":", "~>") + out = pad_mnemonic(out) + return f"{line_color}{line.line_num} {in_arrow} {out}{Style.RESET_ALL}{out_arrow}" - out1 = f"{line_color1}{line_num1} {in_arrow1} {out1}{Style.RESET_ALL}{out_arrow1}" - out2 = f"{line_color2}{line_num2} {in_arrow2} {out2}{Style.RESET_ALL}{out_arrow2}" - mid = f"{sym_color}{line_prefix} " + part1 = format_part(out1, line1, line_color1, bts1, sc5) + part2 = format_part(out2, line2, line_color2, bts2, sc6) + key2 = line2.original if line2 else "" + + mid = f"{sym_color}{line_prefix}" if line2: for source_line in line2.source_lines: @@ -907,22 +979,82 @@ def do_diff(basedump, mydump): ) except: pass - output.append( - format_single_line_diff( - "", - f" {color}{source_line}{Style.RESET_ALL}", - args.column_width, - ) - ) + output.append(OutputLine(None, f" {color}{source_line}{Style.RESET_ALL}", source_line)) - output.append(format_single_line_diff(out1, mid + out2, args.column_width)) + fmt2 = mid + " " + (part2 or "") + output.append(OutputLine(part1, fmt2, key2)) - return output[args.skip_lines :] + return output + + +def chunk_diff(diff: List[OutputLine]) -> List[Union[List[OutputLine], OutputLine]]: + cur_right: List[OutputLine] = [] + chunks: List[Union[List[OutputLine], OutputLine]] = [] + for output_line in diff: + if output_line.base is not None: + chunks.append(cur_right) + chunks.append(output_line) + cur_right = [] + else: + cur_right.append(output_line) + chunks.append(cur_right) + return chunks + + +def format_diff(old_diff: List[OutputLine], new_diff: List[OutputLine]) -> Tuple[str, List[str]]: + old_chunks = chunk_diff(old_diff) + new_chunks = chunk_diff(new_diff) + output: List[Tuple[str, OutputLine, OutputLine]] = [] + assert len(old_chunks) == len(new_chunks), "same target" + empty = OutputLine("", "", "") + for old_chunk, new_chunk in zip(old_chunks, new_chunks): + if isinstance(old_chunk, list): + assert isinstance(new_chunk, list) + if not old_chunk and not new_chunk: + # Most of the time lines sync up without insertions/deletions, + # and there's no interdiffing to be done. + continue + differ = difflib.SequenceMatcher(a=old_chunk, b=new_chunk, autojunk=False) + for (tag, i1, i2, j1, j2) in differ.get_opcodes(): + if tag in ["equal", "replace"]: + for i, j in zip(range(i1, i2), range(j1, j2)): + output.append(("", old_chunk[i], new_chunk[j])) + elif tag == "insert": + for j in range(j1, j2): + output.append(("", empty, new_chunk[j])) + else: + for i in range(i1, i2): + output.append(("", old_chunk[i], empty)) + else: + assert isinstance(new_chunk, OutputLine) + # old_chunk.base and new_chunk.base have the same text since + # both diffs are based on the same target, but they might + # differ in color. Use the new version. + output.append((new_chunk.base or "", old_chunk, new_chunk)) + + # TODO: status line, with e.g. approximate permuter score? + width = args.column_width + if args.threeway: + header_line = "TARGET".ljust(width) + " CURRENT".ljust(width) + " PREVIOUS" + diff_lines = [ + ansi_ljust(base, width) + + ansi_ljust(new.fmt2, width) + + (old.fmt2 or "-" if old != new else "") + for (base, old, new) in output + ] + else: + header_line = "" + diff_lines = [ + ansi_ljust(base, width) + new.fmt2 + for (base, old, new) in output + if base or new.key2 + ] + return header_line, diff_lines def debounced_fs_watch(targets, outq, debounce_delay): - import watchdog.events - import watchdog.observers + import watchdog.events # type: ignore + import watchdog.observers # type: ignore class WatchEventHandler(watchdog.events.FileSystemEventHandler): def __init__(self, queue, file_targets): @@ -993,12 +1125,18 @@ class Display: self.basedump = basedump self.mydump = mydump self.emsg = None + self.last_diff_output = None def run_less(self): if self.emsg is not None: output = self.emsg else: - output = "\n".join(do_diff(self.basedump, self.mydump)) + diff_output = do_diff(self.basedump, self.mydump) + last_diff_output = self.last_diff_output or diff_output + self.last_diff_output = diff_output + header, diff_lines = format_diff(last_diff_output, diff_output) + header_lines = [header] if header else [] + output = "\n".join(header_lines + diff_lines[args.skip_lines :]) # Pipe the output through 'tail' and only then to less, to ensure the # write call doesn't block. ('tail' has to buffer all its input before diff --git a/include/common_structs.h b/include/common_structs.h index d5730cd0b5..92cc55695f 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -105,7 +105,7 @@ typedef struct PlayerData { /* 0x00F */ u8 starPieces; /* 0x010 */ s8 starPoints; /* 0x011 */ char unk_11; - /* 0x012 */ u8 currentPartner; + /* 0x012 */ s8 currentPartner; /* 0x013 */ char unk_13; /* 0x014 */ struct PartnerData partners[12]; /* 0x074 */ s16 keyItems[32]; @@ -1362,12 +1362,13 @@ typedef struct PlayerStatus { /* 0x0B8 */ s32 anim; /* 0x0BC */ char unk_BC[2]; /* 0x0BE */ u8 renderMode; - /* 0x0BF */ char unk_BF; + /* 0x0BF */ s8 unk_BF; /* 0x0C0 */ u32* decorationList; /* 0x0C4 */ char unk_C4[4]; /* 0x0C8 */ UNK_PTR unk_C8; /* 0x0CC */ s32 shadowID; - /* 0x0D0 */ char unk_D0[12]; + /* 0x0D0 */ char unk_D0[8]; + /* 0x0D8 */ UNK_PTR** unk_D8; /* 0x0DC */ s32 currentButtons; /* 0x0E0 */ s32 pressedButtons; /* 0x0E4 */ s32 heldButtons; diff --git a/include/functions.h b/include/functions.h index 9f0b5809b1..c895090e69 100644 --- a/include/functions.h +++ b/include/functions.h @@ -16,6 +16,7 @@ f32 set_float_variable(ScriptInstance* script, Bytecode var, f32 value); void set_script_timescale(ScriptInstance* script, f32 timescale); f32 sin_deg(f32 x); f32 cos_deg(f32 x); +s16 round(f32); f32 atan2(f32 startX, f32 startZ, f32 endX, f32 endZ); f32 clamp_angle(f32 theta); s32 func_80055448(s32); diff --git a/include/variables.h b/include/variables.h index fb8ac96bcf..044fc09397 100644 --- a/include/variables.h +++ b/include/variables.h @@ -76,4 +76,7 @@ extern UNK_TYPE D_80147574; extern UNK_TYPE D_80109270; extern UNK_TYPE D_80108558; +extern UNK_TYPE D_8010F250; // play_sound state struct? +extern s8 D_8010EBB0; + #endif diff --git a/src/code_42e0_len_1f60.c b/src/code_42e0_len_1f60.c index dbc3b124de..c583660453 100644 --- a/src/code_42e0_len_1f60.c +++ b/src/code_42e0_len_1f60.c @@ -8,7 +8,7 @@ INCLUDE_ASM("code_42e0_len_1f60", func_80028F8C); INCLUDE_ASM("code_42e0_len_1f60", func_80028FE0); -INCLUDE_API_ASM("code_42e0_len_1f60", length2D); +INCLUDE_ASM("code_42e0_len_1f60", length2D); INCLUDE_ASM("code_42e0_len_1f60", _heap_create); @@ -20,9 +20,9 @@ INCLUDE_ASM("code_42e0_len_1f60", _heap_free); INCLUDE_ASM("code_42e0_len_1f60", _heap_realloc); -INCLUDE_API_ASM("code_42e0_len_1f60", cosine); +INCLUDE_ASM("code_42e0_len_1f60", cosine); -INCLUDE_API_ASM("code_42e0_len_1f60", sign); +INCLUDE_ASM("code_42e0_len_1f60", sign); INCLUDE_ASM("code_42e0_len_1f60", int_to_string); @@ -44,9 +44,9 @@ INCLUDE_ASM("code_42e0_len_1f60", func_80029994); s32 INCLUDE_ASM("code_42e0_len_1f60", rand_int, s32 arg0); -INCLUDE_API_ASM("code_42e0_len_1f60", signF); +INCLUDE_ASM("code_42e0_len_1f60", signF); -INCLUDE_API_ASM("code_42e0_len_1f60", round); +s16 INCLUDE_ASM("code_42e0_len_1f60", round, f32 arg0); f32 INCLUDE_ASM("code_42e0_len_1f60", clamp_angle, f32 theta); diff --git a/src/code_dc470_len_14c0.c b/src/code_dc470_len_14c0.c index fe11dcf49f..10f60a643e 100644 --- a/src/code_dc470_len_14c0.c +++ b/src/code_dc470_len_14c0.c @@ -69,12 +69,10 @@ u16 func_80145E98(s32 arg0, s32 arg1, s32 arg2) { INCLUDE_ASM("code_dc470_len_14c0", func_80145EC0); -INCLUDE_ASM("code_dc470_len_14c0", func_8014720C); -/*void func_8014720C(void) { +void func_8014720C(void) { D_8014F12F = 1; -}*/ +} -INCLUDE_ASM("code_dc470_len_14c0", func_8014721C); -/*void func_8014721C(void) { +void func_8014721C(void) { D_8014F12F = 0; -}*/ +} diff --git a/src/code_dd930_len_1c0.c b/src/code_dd930_len_1c0.c index 002e79c6b2..9060ffbd80 100644 --- a/src/code_dd930_len_1c0.c +++ b/src/code_dd930_len_1c0.c @@ -2,8 +2,8 @@ // TODO: most likely part of the MusicPlayer struct typedef struct { - s16 flags; - s16 state; + s16 fadeFlags; + s16 fadeState; s32 fadeOutTime; s32 fadeInTime; s32 unkC; @@ -19,36 +19,37 @@ void func_80147230(void) { void update_music_players(void) { struct_80147230* temp = &D_8015C7C0; - switch (temp->state) { + switch (temp->fadeState) { case 0: // idle break; - case 1: // fading in - if (temp->flags & 1) { + case 1: // fading out + if (temp->fadeFlags & 1) { s32 phi_v0; if (temp->fadeOutTime < 0xFA) { phi_v0 = func_800554A4(0, temp->fadeOutTime); } else { phi_v0 = func_800554E8(0, temp->fadeOutTime); } + if (phi_v0 != 0) { return; } } - temp->state = 2; + temp->fadeState = 2; break; - case 2: // fading out - if (temp->flags & 1) { + case 2: // fading in + if (temp->fadeFlags & 1) { if (func_800555E4(0) != 0) { return; } - temp->flags &= ~1; + temp->fadeFlags &= ~1; } if (temp->fadeInTime < 0) { - temp->state = 0; + temp->fadeState = 0; } else if (func_80055448(temp->fadeInTime) == 0) { if (func_80055464(0, 0) == 0) { - temp->state = 0; - temp->flags |= 1; + temp->fadeState = 0; + temp->fadeFlags |= 1; } } break; @@ -61,7 +62,7 @@ s32 play_ambient_sounds(s32 fadeInTime, s32 fadeOutTime) { if (!(*gGameStatusPtr)->musicEnabled) { func_800554A4(temp1->fadeInTime, fadeOutTime); - temp1->flags &= ~1; + temp1->fadeFlags &= ~1; return 1; } @@ -71,6 +72,6 @@ s32 play_ambient_sounds(s32 fadeInTime, s32 fadeOutTime) { temp2->fadeInTime = fadeInTime; temp2->fadeOutTime = fadeOutTime; - temp2->state = 1; + temp2->fadeState = 1; return 1; } diff --git a/src/code_ddaf0_len_c50.c b/src/code_ddaf0_len_c50.c index f18b912e7c..b96306a265 100644 --- a/src/code_ddaf0_len_c50.c +++ b/src/code_ddaf0_len_c50.c @@ -1,8 +1,51 @@ #include "common.h" -INCLUDE_ASM("code_ddaf0_len_c50", func_801473F0); +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ s32 unk_08; + /* 0x0C */ char unk_01[0x10]; + /* 0x1C */ u8 unk_1C; +} struct_80159D50; // size = 0x20 + +extern struct_80159D50 D_80159D50[0x40]; + +//INCLUDE_ASM("code_ddaf0_len_c50", func_801473F0); +void func_801473F0(void) { + struct_80159D50 *phi_v1 = &D_80159D50; + s32 i; + + for(i = 0; i < 0x40; i++) { + phi_v1->unk_00 = 0; + phi_v1++; + } +} INCLUDE_ASM("code_ddaf0_len_c50", func_80147414); +/*void func_80147414(void) { + struct_80159D50 *phi_a1 = &D_80159D50[0]; + struct_80159D50 *phi_a0 = &D_80159D50[0]; + s32 i; + + for(i = 0; i < 0x40; i++) + { + if (phi_a1[i].unk_00 != 0) { + if ((phi_a1[i].unk_00 & 0x20) == 0) { + if ((phi_a1[i].unk_00 & 2) != 0) { + phi_a1[i].unk_00 &= ~2; + phi_a0[i].unk_1C = 0; + phi_a0[i].unk_04 = phi_a0[i].unk_08; + } + } + } + } +}*/ + +INCLUDE_ASM("code_ddaf0_len_c50", func_80147474); + +INCLUDE_ASM("code_ddaf0_len_c50", func_80147574); + +INCLUDE_ASM("code_ddaf0_len_c50", func_80147650); INCLUDE_ASM("code_ddaf0_len_c50", func_80147698); diff --git a/src/code_e0b30_len_b80.c b/src/code_e0b30_len_b80.c index 74cc183fb6..9f37c098e1 100644 --- a/src/code_e0b30_len_b80.c +++ b/src/code_e0b30_len_b80.c @@ -37,3 +37,7 @@ INCLUDE_ASM("code_e0b30_len_b80", func_8014AE6C); INCLUDE_ASM("code_e0b30_len_b80", func_8014AEF8); INCLUDE_ASM("code_e0b30_len_b80", func_8014AF8C); + +void func_8014AFA0(void) { + +} diff --git a/src/code_e79b0_len_1920.c b/src/code_e79b0_len_1920.c index 567518e8a6..8172841a25 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -16,15 +16,14 @@ INCLUDE_ASM("code_e79b0_len_1920", start_script_in_group); INCLUDE_ASM("code_e79b0_len_1920", start_child_script); -//INCLUDE_ASM("code_e79b0_len_1920", func_802C39F8); +INCLUDE_ASM("code_e79b0_len_1920", func_802C39F8); extern s32 gStaticScriptCounter; extern s32 D_802D9CA4; extern s32 gNumScripts; extern s32 D_802DAC98; -//INCLUDE_ASM(code_e79b0_len_1920, func_802C39F8); -ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, s32 newState) { +/*ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, s32 newState) { ScriptInstance** curScript = gCurrentScriptListPtr; ScriptInstance* child; ScriptInstance** temp3; @@ -92,9 +91,9 @@ ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, } func_802C3390(child); return child; -} +}*/ -INCLUDE_ASM(code_e79b0_len_1920, func_802C3C10) +INCLUDE_ASM("code_e79b0_len_1920", func_802C3C10); ScriptInstance* restart_script(ScriptInstance* script) { Bytecode* temp; diff --git a/src/code_ef070_len_3400.c b/src/code_ef070_len_3400.c index bd8424d1f0..81e46d0b36 100644 --- a/src/code_ef070_len_3400.c +++ b/src/code_ef070_len_3400.c @@ -57,8 +57,6 @@ ApiStatus func_802CA90C(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_API_ASM("code_ef070_len_3400", func_802CA988); -/* ApiStatus func_802CA988(ScriptInstance* script, s32 isInitialCall) { Bytecode* ptrReadPos = script->ptrReadPos; Bytecode id = get_variable(script, *ptrReadPos++); @@ -67,22 +65,17 @@ ApiStatus func_802CA988(ScriptInstance* script, s32 isInitialCall) { Bytecode outVar3 = *ptrReadPos++; Bytecode outVar4 = *ptrReadPos++; f32 temp1, temp2, temp3; - f32 tempSqrt; (&gCameras[id])->mode = 2; - (&gCameras[id])->unk_1C = -1 * round((&gCameras[id])->currentPitch); - (&gCameras[id])->unk_1E = -1 * (&gCameras[id])->currentBlendedYawNegated; (&gCameras[id])->unk_06 = 0; + (&gCameras[id])->unk_1C = -round((&gCameras[id])->currentPitch); + (&gCameras[id])->unk_1E = -(&gCameras[id])->currentBlendedYawNegated; temp1 = (&gCameras[id])->lookAt_obj[0] - (&gCameras[id])->lookAt_eye[0]; temp2 = (&gCameras[id])->lookAt_obj[1] - (&gCameras[id])->lookAt_eye[1]; temp3 = (&gCameras[id])->lookAt_obj[2] - (&gCameras[id])->lookAt_eye[2]; - tempSqrt = sqrtf((temp1 * temp1) + (temp2 * temp2) + (temp3 * temp3)); - if (tempSqrt != tempSqrt) { - (&gCameras[id])->unk_20 = round(tempSqrt); - } - + (&gCameras[id])->unk_20 = round(sqrtf((temp1 * temp1) + (temp2 * temp2) + (temp3 * temp3))); (&gCameras[id])->unk_22 = 0; (&gCameras[id])->unk_54 = (&gCameras[id])->lookAt_obj[0]; (&gCameras[id])->unk_58 = (&gCameras[id])->lookAt_obj[1]; @@ -94,7 +87,6 @@ ApiStatus func_802CA988(ScriptInstance* script, s32 isInitialCall) { set_variable(script, outVar4, (&gCameras[id])->unk_22); return ApiStatus_DONE2; } -*/ ApiStatus SetCamViewport(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; diff --git a/src/code_f8f60_len_1560.c b/src/code_f8f60_len_1560.c index db765476c6..b2b510b481 100644 --- a/src/code_f8f60_len_1560.c +++ b/src/code_f8f60_len_1560.c @@ -269,18 +269,29 @@ ApiStatus func_802D4D88(ScriptInstance* script, s32 initialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM("code_f8f60_len_1560", setup_path_data); -/*void setup_path_data(s32 numVecs, f32* arg1, struct Vec3f* arg2, struct Vec3f* arg3) { +//INCLUDE_ASM("code_f8f60_len_1560", setup_path_data); + +#define SQ(n) ((n) * (n)) + +void* heap_malloc(s32 size); + +void setup_path_data(s32 numVecs, f32* arg1, struct Vec3f* arg2, struct Vec3f* arg3) { struct Vec3f *temp_s4; f32 *temp_s7; s32 i; + f32 *temp; + f32 new_var; + f32 new_var2; temp_s7 = heap_malloc(numVecs * sizeof(f32)); temp_s4 = heap_malloc(numVecs * sizeof(Vec3f)); arg1[0] = 0.0f; for (i = 1; i < numVecs; i++) { - arg1[i] = (arg1[i - 1] + sqrtf(SQ(arg2[i].x - arg2[i - 1].x) + SQ(arg2[i].y - arg2[i - 1].y) + SQ(arg2[i].z - arg2[i - 1].z))); + f32 temp_x = SQ(arg2[i].x - arg2[i - 1].x); + f32 temp_y = SQ(arg2[i].y - arg2[i - 1].y); + f32 temp_z = SQ(arg2[i].z - arg2[i - 1].z); + arg1[i] = arg1[i - 1] + sqrtf(temp_x + temp_y + temp_z); } for (i = 1; i < numVecs; i++) { @@ -288,49 +299,56 @@ INCLUDE_ASM("code_f8f60_len_1560", setup_path_data); } arg3[0].x = 0; - arg3[0].y = 0; + + arg3[numVecs - 1].z = 0; arg3[0].z = 0; arg3[numVecs - 1].x = 0; + + arg3[0].y = 0; arg3[numVecs - 1].y = 0; - arg3[numVecs - 1].z = 0; for (i = 0; i < (numVecs - 1); i++) { + f32 temp = temp_s7[i]; temp_s7[i] = arg1[i + 1] - arg1[i]; temp_s4[i + 1].x = ((arg2[i + 1].x - arg2[i].x) / temp_s7[i]); - temp_s4[i + 1].y = ((arg2[i + 1].y - arg2[i].y) / temp_s7[i]); - temp_s4[i + 1].z = ((arg2[i + 1].z - arg2[i].z) / temp_s7[i]); + temp_s4[i + 1].y = ((arg2[i + 1].y - arg2[i].y) / temp); + temp_s4[i + 1].z = ((arg2[i + 1].z - arg2[i].z) / temp); } - arg3[0].x = temp_s4[2].x - temp_s4[1].x; - arg3[0].y = temp_s4[2].y - temp_s4[1].y; - arg3[0].z = temp_s4[2].z - temp_s4[1].z; + arg3[1].x = temp_s4[2].x - temp_s4[1].x; + arg3[1].y = temp_s4[2].y - temp_s4[1].y; + arg3[1].z = temp_s4[2].z - temp_s4[1].z; temp_s4[1].x = ((arg1[2] - arg1[0]) * 2); temp_s4[1].y = ((arg1[2] - arg1[0]) * 2); temp_s4[1].z = ((arg1[2] - arg1[0]) * 2); for (i = 1; i < numVecs - 2; i++) { - arg3[i + 1].x = (temp_s4[i + 2].x - temp_s4[i].x) - (arg3[i].x * (temp_s7[i] / temp_s4[i].x)); - arg3[i + 1].y = (temp_s4[i + 2].y - temp_s4[i].y) - (arg3[i].y * (temp_s7[i] / temp_s4[i].y)); - arg3[i + 1].z = (temp_s4[i + 2].z - temp_s4[i].z) - (arg3[i].z * (temp_s7[i] / temp_s4[i].z)); - temp_s4[i].x = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * (temp_s7[i] / temp_s4[i].x)); - temp_s4[i].y = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * (temp_s7[i] / temp_s4[i].y)); - temp_s4[i].z = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * (temp_s7[i] / temp_s4[i].z)); + f32 temp_x = temp_s7[i] / temp_s4[i].x; + f32 temp_y = temp_s7[i] / temp_s4[i].y; + f32 temp_z = temp_s7[i] / temp_s4[i].z; + new_var = arg3[i].x; + arg3[i + 1].x = (temp_s4[i + 2].x - temp_s4[i].x) - (new_var * temp_x); + arg3[i + 1].y = (temp_s4[i + 2].y - temp_s4[i].y) - (new_var * temp_y); + arg3[i + 1].z = (temp_s4[i + 2].z - temp_s4[i].z) - (new_var * temp_z); + temp_s4[i].x = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * temp_x); + temp_s4[i].y = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * temp_y); + temp_s4[i].z = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * temp_z); } arg3[numVecs - 2].x = arg3[numVecs - 2].x - (temp_s7[numVecs - 2] * arg3[numVecs - 1].x); arg3[numVecs - 2].y = arg3[numVecs - 2].y - (temp_s7[numVecs - 2] * arg3[numVecs - 1].y); arg3[numVecs - 2].z = arg3[numVecs - 2].z - (temp_s7[numVecs - 2] * arg3[numVecs - 1].z); - for(i = (numVecs - 2); i > 0; i--) { - arg3[i].x = (arg3[i].x - (temp_s7[0] * arg3[i].x)) / temp_s4[i].x; - arg3[i].y = (arg3[i].y - (temp_s7[0] * arg3[i].y)) / temp_s4[i].y; - arg3[i].z = (arg3[i].z - (temp_s7[0] * arg3[i].z)) / temp_s4[i].z; + for (i = (numVecs - 2); i > 0 ; i--) { + arg3[i].x = (arg3[i].x - (temp_s7[i] * arg3[i + 1].x)) / temp_s4[i].x; + arg3[i].y = (arg3[i].y - (temp_s7[i] * arg3[i + 1].y)) / temp_s4[i].y; + arg3[i].z = (arg3[i].z - (temp_s7[i] * arg3[i].z)) / temp_s4[i].z; } heap_free(temp_s7); heap_free(temp_s4); -}*/ +} INCLUDE_ASM("code_f8f60_len_1560", func_802D5270); diff --git a/src/os/code_3d2f0_len_10.c b/src/os/code_3d2f0_len_10.c index b2ae29f1e4..775067defb 100644 --- a/src/os/code_3d2f0_len_10.c +++ b/src/os/code_3d2f0_len_10.c @@ -1,3 +1,3 @@ #include "common.h" -f32 INCLUDE_ASM("os/code_3d2f0_len_10", sqrtf, f32 value); +f32 INCLUDE_ASM("os/code_3d2f0_len_10", sqrtf_, f32 value); diff --git a/undefined_syms.txt b/undefined_syms.txt index cb9f675e3f..92893707ac 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -12,6 +12,10 @@ gStaticScriptCounter = 0x802D9CA0; D_802D9CA4 = 0x802D9CA4; gGlobalTimeSpace = 0x802D9CA8; D_80147574 = 0x80147574; +D_8010EBB0 = 0x8010EBB0; +D_8010F250 = 0x8010F250; + +D_80159D50 = 0x80159D50; gMapTransitionAlpha = 0x800A0940; D_800E92D8 = 0x800E92D8; @@ -104,6 +108,7 @@ gCurrentDynamicEntityListPtr = 0x80154420; gScriptIdList = 0x802D1898; gScriptIndexList = 0x802DAA98; +sqrtf = 0x80061EF0; func_802A91F8 = 0x802A91F8; func_802A9208 = 0x802A9208; func_802A9228 = 0x802A9228;