From 08529a62330e287489974ce5e3240f1c1b5d12c1 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sun, 17 Oct 2021 23:07:01 -0400 Subject: [PATCH 01/41] I believe epcInfo is just __OSThreadContext, and I've cleaned up some naming and another func --- asm/non_matchings/thread0_epc/func_800B6F50.s | 4 +- .../thread0_epc/render_epc_lock_up_display.s | 148 +++++++++--------- .../thread0_epc/{thread0.s => thread0_Main.s} | 2 +- src/thread0_epc.c | 82 +++++----- src/thread0_epc.h | 2 +- 5 files changed, 121 insertions(+), 117 deletions(-) rename asm/non_matchings/thread0_epc/{thread0.s => thread0_Main.s} (99%) diff --git a/asm/non_matchings/thread0_epc/func_800B6F50.s b/asm/non_matchings/thread0_epc/func_800B6F50.s index 381a5b76..54d85ef3 100644 --- a/asm/non_matchings/thread0_epc/func_800B6F50.s +++ b/asm/non_matchings/thread0_epc/func_800B6F50.s @@ -4,10 +4,10 @@ glabel func_800B6F50 /* 0B7B58 800B6F58 AFBF001C */ sw $ra, 0x1c($sp) /* 0B7B5C 800B6F5C 25CE95E0 */ addiu $t6, %lo(D_801295E0) # addiu $t6, $t6, -0x6a20 /* 0B7B60 800B6F60 3C048013 */ lui $a0, %hi(D_801295E0) # $a0, 0x8013 -/* 0B7B64 800B6F64 3C06800B */ lui $a2, %hi(thread0) # $a2, 0x800b +/* 0B7B64 800B6F64 3C06800B */ lui $a2, %hi(thread0_Main) # $a2, 0x800b /* 0B7B68 800B6F68 240F00FF */ li $t7, 255 /* 0B7B6C 800B6F6C AFAF0014 */ sw $t7, 0x14($sp) -/* 0B7B70 800B6F70 24C66FC4 */ addiu $a2, %lo(thread0) # addiu $a2, $a2, 0x6fc4 +/* 0B7B70 800B6F70 24C66FC4 */ addiu $a2, %lo(thread0_Main) # addiu $a2, $a2, 0x6fc4 /* 0B7B74 800B6F74 248495E0 */ addiu $a0, %lo(D_801295E0) # addiu $a0, $a0, -0x6a20 /* 0B7B78 800B6F78 AFAE0010 */ sw $t6, 0x10($sp) /* 0B7B7C 800B6F7C 00002825 */ move $a1, $zero diff --git a/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s b/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s index a66d70a5..f1c321e4 100644 --- a/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s +++ b/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s @@ -116,9 +116,9 @@ glabel render_epc_lock_up_display /* 0B8494 800B7894 00000000 */ nop glabel L800B7898 /* 0B8498 800B7898 444AF800 */ cfc1 $t2, $31 -/* 0B849C 800B789C 3C038013 */ lui $v1, %hi(gEpcInfo) # $v1, 0x8013 +/* 0B849C 800B789C 3C038013 */ lui $v1, %hi(gThread0Context) # $v1, 0x8013 /* 0B84A0 800B78A0 35410003 */ ori $at, $t2, 3 -/* 0B84A4 800B78A4 24639800 */ addiu $v1, %lo(gEpcInfo) # addiu $v1, $v1, -0x6800 +/* 0B84A4 800B78A4 24639800 */ addiu $v1, %lo(gThread0Context) # addiu $v1, $v1, -0x6800 /* 0B84A8 800B78A8 38210002 */ xori $at, $at, 2 /* 0B84AC 800B78AC 44C1F800 */ ctc1 $at, $31 /* 0B84B0 800B78B0 C4640130 */ lwc1 $f4, 0x130($v1) @@ -150,15 +150,15 @@ glabel L800B7898 /* 0B8518 800B7918 44D9F800 */ ctc1 $t9, $31 /* 0B851C 800B791C 15C1002F */ bne $t6, $at, .L800B79DC /* 0B8520 800B7920 AC580008 */ sw $t8, 8($v0) -/* 0B8524 800B7924 3C058013 */ lui $a1, %hi(gEpcInfo+0x11C) # $a1, 0x8013 -/* 0B8528 800B7928 8CA5991C */ lw $a1, %lo(gEpcInfo+0x11C)($a1) +/* 0B8524 800B7924 3C058013 */ lui $a1, %hi(gThread0Context+0x11C) # $a1, 0x8013 +/* 0B8528 800B7928 8CA5991C */ lw $a1, %lo(gThread0Context+0x11C)($a1) /* 0B852C 800B792C 3C04800F */ lui $a0, %hi(D_800E8F18) # $a0, 0x800f /* 0B8530 800B7930 0C02D7B7 */ jal render_printf /* 0B8534 800B7934 24848F18 */ addiu $a0, %lo(D_800E8F18) # addiu $a0, $a0, -0x70e8 -/* 0B8538 800B7938 3C098013 */ lui $t1, %hi(gEpcInfo+0x3C) # $t1, 0x8013 -/* 0B853C 800B793C 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x44) # $t3, 0x8013 -/* 0B8540 800B7940 8D669844 */ lw $a2, %lo(gEpcInfo+0x44)($t3) -/* 0B8544 800B7944 8D25983C */ lw $a1, %lo(gEpcInfo+0x3C)($t1) +/* 0B8538 800B7938 3C098013 */ lui $t1, %hi(gThread0Context+0x3C) # $t1, 0x8013 +/* 0B853C 800B793C 3C0B8013 */ lui $t3, %hi(gThread0Context+0x44) # $t3, 0x8013 +/* 0B8540 800B7940 8D669844 */ lw $a2, %lo(gThread0Context+0x44)($t3) +/* 0B8544 800B7944 8D25983C */ lw $a1, %lo(gThread0Context+0x3C)($t1) /* 0B8548 800B7948 3C04800F */ lui $a0, %hi(D_800E8F28) # $a0, 0x800f /* 0B854C 800B794C 0C02D7B7 */ jal render_printf /* 0B8550 800B7950 24848F28 */ addiu $a0, %lo(D_800E8F28) # addiu $a0, $a0, -0x70d8 @@ -204,23 +204,23 @@ glabel L800B7898 /* 0B85E0 800B79E0 8C650014 */ lw $a1, 0x14($v1) /* 0B85E4 800B79E4 0C02D7B7 */ jal render_printf /* 0B85E8 800B79E8 24848F6C */ addiu $a0, %lo(D_800E8F6C) # addiu $a0, $a0, -0x7094 -/* 0B85EC 800B79EC 3C058013 */ lui $a1, %hi(gEpcInfo+0x11C) # $a1, 0x8013 -/* 0B85F0 800B79F0 8CA5991C */ lw $a1, %lo(gEpcInfo+0x11C)($a1) +/* 0B85EC 800B79EC 3C058013 */ lui $a1, %hi(gThread0Context+0x11C) # $a1, 0x8013 +/* 0B85F0 800B79F0 8CA5991C */ lw $a1, %lo(gThread0Context+0x11C)($a1) /* 0B85F4 800B79F4 3C04800F */ lui $a0, %hi(D_800E8F84) # $a0, 0x800f /* 0B85F8 800B79F8 0C02D7B7 */ jal render_printf /* 0B85FC 800B79FC 24848F84 */ addiu $a0, %lo(D_800E8F84) # addiu $a0, $a0, -0x707c -/* 0B8600 800B7A00 3C058013 */ lui $a1, %hi(gEpcInfo+0x120) # $a1, 0x8013 -/* 0B8604 800B7A04 8CA59920 */ lw $a1, %lo(gEpcInfo+0x120)($a1) +/* 0B8600 800B7A00 3C058013 */ lui $a1, %hi(gThread0Context+0x120) # $a1, 0x8013 +/* 0B8604 800B7A04 8CA59920 */ lw $a1, %lo(gThread0Context+0x120)($a1) /* 0B8608 800B7A08 3C04800F */ lui $a0, %hi(D_800E8F94) # $a0, 0x800f /* 0B860C 800B7A0C 0C02D7B7 */ jal render_printf /* 0B8610 800B7A10 24848F94 */ addiu $a0, %lo(D_800E8F94) # addiu $a0, $a0, -0x706c -/* 0B8614 800B7A14 3C058013 */ lui $a1, %hi(gEpcInfo+0x118) # $a1, 0x8013 -/* 0B8618 800B7A18 8CA59918 */ lw $a1, %lo(gEpcInfo+0x118)($a1) +/* 0B8614 800B7A14 3C058013 */ lui $a1, %hi(gThread0Context+0x118) # $a1, 0x8013 +/* 0B8618 800B7A18 8CA59918 */ lw $a1, %lo(gThread0Context+0x118)($a1) /* 0B861C 800B7A1C 3C04800F */ lui $a0, %hi(D_800E8FA4) # $a0, 0x800f /* 0B8620 800B7A20 0C02D7B7 */ jal render_printf /* 0B8624 800B7A24 24848FA4 */ addiu $a0, %lo(D_800E8FA4) # addiu $a0, $a0, -0x705c -/* 0B8628 800B7A28 3C058013 */ lui $a1, %hi(gEpcInfo+0x124) # $a1, 0x8013 -/* 0B862C 800B7A2C 8CA59924 */ lw $a1, %lo(gEpcInfo+0x124)($a1) +/* 0B8628 800B7A28 3C058013 */ lui $a1, %hi(gThread0Context+0x124) # $a1, 0x8013 +/* 0B862C 800B7A2C 8CA59924 */ lw $a1, %lo(gThread0Context+0x124)($a1) /* 0B8630 800B7A30 3C04800F */ lui $a0, %hi(D_800E8FB4) # $a0, 0x800f /* 0B8634 800B7A34 0C02D7B7 */ jal render_printf /* 0B8638 800B7A38 24848FB4 */ addiu $a0, %lo(D_800E8FB4) # addiu $a0, $a0, -0x704c @@ -256,91 +256,91 @@ glabel L800B7898 /* 0B86A4 800B7AA4 3C04800F */ lui $a0, %hi(D_800E8FDC) # $a0, 0x800f /* 0B86A8 800B7AA8 0C02D7B7 */ jal render_printf /* 0B86AC 800B7AAC 24848FDC */ addiu $a0, %lo(D_800E8FDC) # addiu $a0, $a0, -0x7024 -/* 0B86B0 800B7AB0 3C198013 */ lui $t9, %hi(gEpcInfo+0x24) # $t9, 0x8013 -/* 0B86B4 800B7AB4 3C0F8013 */ lui $t7, %hi(gEpcInfo+0x2C) # $t7, 0x8013 -/* 0B86B8 800B7AB8 3C098013 */ lui $t1, %hi(gEpcInfo+0x34) # $t1, 0x8013 -/* 0B86BC 800B7ABC 8D279834 */ lw $a3, %lo(gEpcInfo+0x34)($t1) -/* 0B86C0 800B7AC0 8DE6982C */ lw $a2, %lo(gEpcInfo+0x2C)($t7) -/* 0B86C4 800B7AC4 8F259824 */ lw $a1, %lo(gEpcInfo+0x24)($t9) +/* 0B86B0 800B7AB0 3C198013 */ lui $t9, %hi(gThread0Context+0x24) # $t9, 0x8013 +/* 0B86B4 800B7AB4 3C0F8013 */ lui $t7, %hi(gThread0Context+0x2C) # $t7, 0x8013 +/* 0B86B8 800B7AB8 3C098013 */ lui $t1, %hi(gThread0Context+0x34) # $t1, 0x8013 +/* 0B86BC 800B7ABC 8D279834 */ lw $a3, %lo(gThread0Context+0x34)($t1) +/* 0B86C0 800B7AC0 8DE6982C */ lw $a2, %lo(gThread0Context+0x2C)($t7) +/* 0B86C4 800B7AC4 8F259824 */ lw $a1, %lo(gThread0Context+0x24)($t9) /* 0B86C8 800B7AC8 3C04800F */ lui $a0, %hi(D_800E8FE0) # $a0, 0x800f /* 0B86CC 800B7ACC 0C02D7B7 */ jal render_printf /* 0B86D0 800B7AD0 24848FE0 */ addiu $a0, %lo(D_800E8FE0) # addiu $a0, $a0, -0x7020 -/* 0B86D4 800B7AD4 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x3C) # $t3, 0x8013 -/* 0B86D8 800B7AD8 3C0D8013 */ lui $t5, %hi(gEpcInfo+0x44) # $t5, 0x8013 -/* 0B86DC 800B7ADC 3C198013 */ lui $t9, %hi(gEpcInfo+0x4C) # $t9, 0x8013 -/* 0B86E0 800B7AE0 8F27984C */ lw $a3, %lo(gEpcInfo+0x4C)($t9) -/* 0B86E4 800B7AE4 8DA69844 */ lw $a2, %lo(gEpcInfo+0x44)($t5) -/* 0B86E8 800B7AE8 8D65983C */ lw $a1, %lo(gEpcInfo+0x3C)($t3) +/* 0B86D4 800B7AD4 3C0B8013 */ lui $t3, %hi(gThread0Context+0x3C) # $t3, 0x8013 +/* 0B86D8 800B7AD8 3C0D8013 */ lui $t5, %hi(gThread0Context+0x44) # $t5, 0x8013 +/* 0B86DC 800B7ADC 3C198013 */ lui $t9, %hi(gThread0Context+0x4C) # $t9, 0x8013 +/* 0B86E0 800B7AE0 8F27984C */ lw $a3, %lo(gThread0Context+0x4C)($t9) +/* 0B86E4 800B7AE4 8DA69844 */ lw $a2, %lo(gThread0Context+0x44)($t5) +/* 0B86E8 800B7AE8 8D65983C */ lw $a1, %lo(gThread0Context+0x3C)($t3) /* 0B86EC 800B7AEC 3C04800F */ lui $a0, %hi(D_800E9000) # $a0, 0x800f /* 0B86F0 800B7AF0 0C02D7B7 */ jal render_printf /* 0B86F4 800B7AF4 24849000 */ addiu $a0, %lo(D_800E9000) # addiu $a0, $a0, -0x7000 -/* 0B86F8 800B7AF8 3C0F8013 */ lui $t7, %hi(gEpcInfo+0x54) # $t7, 0x8013 -/* 0B86FC 800B7AFC 3C098013 */ lui $t1, %hi(gEpcInfo+0x5C) # $t1, 0x8013 -/* 0B8700 800B7B00 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x64) # $t3, 0x8013 -/* 0B8704 800B7B04 8D679864 */ lw $a3, %lo(gEpcInfo+0x64)($t3) -/* 0B8708 800B7B08 8D26985C */ lw $a2, %lo(gEpcInfo+0x5C)($t1) -/* 0B870C 800B7B0C 8DE59854 */ lw $a1, %lo(gEpcInfo+0x54)($t7) +/* 0B86F8 800B7AF8 3C0F8013 */ lui $t7, %hi(gThread0Context+0x54) # $t7, 0x8013 +/* 0B86FC 800B7AFC 3C098013 */ lui $t1, %hi(gThread0Context+0x5C) # $t1, 0x8013 +/* 0B8700 800B7B00 3C0B8013 */ lui $t3, %hi(gThread0Context+0x64) # $t3, 0x8013 +/* 0B8704 800B7B04 8D679864 */ lw $a3, %lo(gThread0Context+0x64)($t3) +/* 0B8708 800B7B08 8D26985C */ lw $a2, %lo(gThread0Context+0x5C)($t1) +/* 0B870C 800B7B0C 8DE59854 */ lw $a1, %lo(gThread0Context+0x54)($t7) /* 0B8710 800B7B10 3C04800F */ lui $a0, %hi(D_800E9020) # $a0, 0x800f /* 0B8714 800B7B14 0C02D7B7 */ jal render_printf /* 0B8718 800B7B18 24849020 */ addiu $a0, %lo(D_800E9020) # addiu $a0, $a0, -0x6fe0 -/* 0B871C 800B7B1C 3C0D8013 */ lui $t5, %hi(gEpcInfo+0x6C) # $t5, 0x8013 -/* 0B8720 800B7B20 3C198013 */ lui $t9, %hi(gEpcInfo+0x74) # $t9, 0x8013 -/* 0B8724 800B7B24 3C0F8013 */ lui $t7, %hi(gEpcInfo+0x7C) # $t7, 0x8013 -/* 0B8728 800B7B28 8DE7987C */ lw $a3, %lo(gEpcInfo+0x7C)($t7) -/* 0B872C 800B7B2C 8F269874 */ lw $a2, %lo(gEpcInfo+0x74)($t9) -/* 0B8730 800B7B30 8DA5986C */ lw $a1, %lo(gEpcInfo+0x6C)($t5) +/* 0B871C 800B7B1C 3C0D8013 */ lui $t5, %hi(gThread0Context+0x6C) # $t5, 0x8013 +/* 0B8720 800B7B20 3C198013 */ lui $t9, %hi(gThread0Context+0x74) # $t9, 0x8013 +/* 0B8724 800B7B24 3C0F8013 */ lui $t7, %hi(gThread0Context+0x7C) # $t7, 0x8013 +/* 0B8728 800B7B28 8DE7987C */ lw $a3, %lo(gThread0Context+0x7C)($t7) +/* 0B872C 800B7B2C 8F269874 */ lw $a2, %lo(gThread0Context+0x74)($t9) +/* 0B8730 800B7B30 8DA5986C */ lw $a1, %lo(gThread0Context+0x6C)($t5) /* 0B8734 800B7B34 3C04800F */ lui $a0, %hi(D_800E9040) # $a0, 0x800f /* 0B8738 800B7B38 0C02D7B7 */ jal render_printf /* 0B873C 800B7B3C 24849040 */ addiu $a0, %lo(D_800E9040) # addiu $a0, $a0, -0x6fc0 -/* 0B8740 800B7B40 3C098013 */ lui $t1, %hi(gEpcInfo+0x84) # $t1, 0x8013 -/* 0B8744 800B7B44 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x8C) # $t3, 0x8013 -/* 0B8748 800B7B48 3C0D8013 */ lui $t5, %hi(gEpcInfo+0x94) # $t5, 0x8013 -/* 0B874C 800B7B4C 8DA79894 */ lw $a3, %lo(gEpcInfo+0x94)($t5) -/* 0B8750 800B7B50 8D66988C */ lw $a2, %lo(gEpcInfo+0x8C)($t3) -/* 0B8754 800B7B54 8D259884 */ lw $a1, %lo(gEpcInfo+0x84)($t1) +/* 0B8740 800B7B40 3C098013 */ lui $t1, %hi(gThread0Context+0x84) # $t1, 0x8013 +/* 0B8744 800B7B44 3C0B8013 */ lui $t3, %hi(gThread0Context+0x8C) # $t3, 0x8013 +/* 0B8748 800B7B48 3C0D8013 */ lui $t5, %hi(gThread0Context+0x94) # $t5, 0x8013 +/* 0B874C 800B7B4C 8DA79894 */ lw $a3, %lo(gThread0Context+0x94)($t5) +/* 0B8750 800B7B50 8D66988C */ lw $a2, %lo(gThread0Context+0x8C)($t3) +/* 0B8754 800B7B54 8D259884 */ lw $a1, %lo(gThread0Context+0x84)($t1) /* 0B8758 800B7B58 3C04800F */ lui $a0, %hi(D_800E9060) # $a0, 0x800f /* 0B875C 800B7B5C 0C02D7B7 */ jal render_printf /* 0B8760 800B7B60 24849060 */ addiu $a0, %lo(D_800E9060) # addiu $a0, $a0, -0x6fa0 -/* 0B8764 800B7B64 3C198013 */ lui $t9, %hi(gEpcInfo+0x9C) # $t9, 0x8013 -/* 0B8768 800B7B68 3C0F8013 */ lui $t7, %hi(gEpcInfo+0xA4) # $t7, 0x8013 -/* 0B876C 800B7B6C 3C098013 */ lui $t1, %hi(gEpcInfo+0xAC) # $t1, 0x8013 -/* 0B8770 800B7B70 8D2798AC */ lw $a3, %lo(gEpcInfo+0xAC)($t1) -/* 0B8774 800B7B74 8DE698A4 */ lw $a2, %lo(gEpcInfo+0xA4)($t7) -/* 0B8778 800B7B78 8F25989C */ lw $a1, %lo(gEpcInfo+0x9C)($t9) +/* 0B8764 800B7B64 3C198013 */ lui $t9, %hi(gThread0Context+0x9C) # $t9, 0x8013 +/* 0B8768 800B7B68 3C0F8013 */ lui $t7, %hi(gThread0Context+0xA4) # $t7, 0x8013 +/* 0B876C 800B7B6C 3C098013 */ lui $t1, %hi(gThread0Context+0xAC) # $t1, 0x8013 +/* 0B8770 800B7B70 8D2798AC */ lw $a3, %lo(gThread0Context+0xAC)($t1) +/* 0B8774 800B7B74 8DE698A4 */ lw $a2, %lo(gThread0Context+0xA4)($t7) +/* 0B8778 800B7B78 8F25989C */ lw $a1, %lo(gThread0Context+0x9C)($t9) /* 0B877C 800B7B7C 3C04800F */ lui $a0, %hi(D_800E9080) # $a0, 0x800f /* 0B8780 800B7B80 0C02D7B7 */ jal render_printf /* 0B8784 800B7B84 24849080 */ addiu $a0, %lo(D_800E9080) # addiu $a0, $a0, -0x6f80 -/* 0B8788 800B7B88 3C0B8013 */ lui $t3, %hi(gEpcInfo+0xB4) # $t3, 0x8013 -/* 0B878C 800B7B8C 3C0D8013 */ lui $t5, %hi(gEpcInfo+0xBC) # $t5, 0x8013 -/* 0B8790 800B7B90 3C198013 */ lui $t9, %hi(gEpcInfo+0xC4) # $t9, 0x8013 -/* 0B8794 800B7B94 8F2798C4 */ lw $a3, %lo(gEpcInfo+0xC4)($t9) -/* 0B8798 800B7B98 8DA698BC */ lw $a2, %lo(gEpcInfo+0xBC)($t5) -/* 0B879C 800B7B9C 8D6598B4 */ lw $a1, %lo(gEpcInfo+0xB4)($t3) +/* 0B8788 800B7B88 3C0B8013 */ lui $t3, %hi(gThread0Context+0xB4) # $t3, 0x8013 +/* 0B878C 800B7B8C 3C0D8013 */ lui $t5, %hi(gThread0Context+0xBC) # $t5, 0x8013 +/* 0B8790 800B7B90 3C198013 */ lui $t9, %hi(gThread0Context+0xC4) # $t9, 0x8013 +/* 0B8794 800B7B94 8F2798C4 */ lw $a3, %lo(gThread0Context+0xC4)($t9) +/* 0B8798 800B7B98 8DA698BC */ lw $a2, %lo(gThread0Context+0xBC)($t5) +/* 0B879C 800B7B9C 8D6598B4 */ lw $a1, %lo(gThread0Context+0xB4)($t3) /* 0B87A0 800B7BA0 3C04800F */ lui $a0, %hi(D_800E90A0) # $a0, 0x800f /* 0B87A4 800B7BA4 0C02D7B7 */ jal render_printf /* 0B87A8 800B7BA8 248490A0 */ addiu $a0, %lo(D_800E90A0) # addiu $a0, $a0, -0x6f60 -/* 0B87AC 800B7BAC 3C0F8013 */ lui $t7, %hi(gEpcInfo+0xCC) # $t7, 0x8013 -/* 0B87B0 800B7BB0 3C098013 */ lui $t1, %hi(gEpcInfo+0xD4) # $t1, 0x8013 -/* 0B87B4 800B7BB4 3C0B8013 */ lui $t3, %hi(gEpcInfo+0xDC) # $t3, 0x8013 -/* 0B87B8 800B7BB8 8D6798DC */ lw $a3, %lo(gEpcInfo+0xDC)($t3) -/* 0B87BC 800B7BBC 8D2698D4 */ lw $a2, %lo(gEpcInfo+0xD4)($t1) -/* 0B87C0 800B7BC0 8DE598CC */ lw $a1, %lo(gEpcInfo+0xCC)($t7) +/* 0B87AC 800B7BAC 3C0F8013 */ lui $t7, %hi(gThread0Context+0xCC) # $t7, 0x8013 +/* 0B87B0 800B7BB0 3C098013 */ lui $t1, %hi(gThread0Context+0xD4) # $t1, 0x8013 +/* 0B87B4 800B7BB4 3C0B8013 */ lui $t3, %hi(gThread0Context+0xDC) # $t3, 0x8013 +/* 0B87B8 800B7BB8 8D6798DC */ lw $a3, %lo(gThread0Context+0xDC)($t3) +/* 0B87BC 800B7BBC 8D2698D4 */ lw $a2, %lo(gThread0Context+0xD4)($t1) +/* 0B87C0 800B7BC0 8DE598CC */ lw $a1, %lo(gThread0Context+0xCC)($t7) /* 0B87C4 800B7BC4 3C04800F */ lui $a0, %hi(D_800E90C0) # $a0, 0x800f /* 0B87C8 800B7BC8 0C02D7B7 */ jal render_printf /* 0B87CC 800B7BCC 248490C0 */ addiu $a0, %lo(D_800E90C0) # addiu $a0, $a0, -0x6f40 -/* 0B87D0 800B7BD0 3C0D8013 */ lui $t5, %hi(gEpcInfo+0xE4) # $t5, 0x8013 -/* 0B87D4 800B7BD4 3C198013 */ lui $t9, %hi(gEpcInfo+0xEC) # $t9, 0x8013 -/* 0B87D8 800B7BD8 3C0F8013 */ lui $t7, %hi(gEpcInfo+0xF4) # $t7, 0x8013 -/* 0B87DC 800B7BDC 8DE798F4 */ lw $a3, %lo(gEpcInfo+0xF4)($t7) -/* 0B87E0 800B7BE0 8F2698EC */ lw $a2, %lo(gEpcInfo+0xEC)($t9) -/* 0B87E4 800B7BE4 8DA598E4 */ lw $a1, %lo(gEpcInfo+0xE4)($t5) +/* 0B87D0 800B7BD0 3C0D8013 */ lui $t5, %hi(gThread0Context+0xE4) # $t5, 0x8013 +/* 0B87D4 800B7BD4 3C198013 */ lui $t9, %hi(gThread0Context+0xEC) # $t9, 0x8013 +/* 0B87D8 800B7BD8 3C0F8013 */ lui $t7, %hi(gThread0Context+0xF4) # $t7, 0x8013 +/* 0B87DC 800B7BDC 8DE798F4 */ lw $a3, %lo(gThread0Context+0xF4)($t7) +/* 0B87E0 800B7BE0 8F2698EC */ lw $a2, %lo(gThread0Context+0xEC)($t9) +/* 0B87E4 800B7BE4 8DA598E4 */ lw $a1, %lo(gThread0Context+0xE4)($t5) /* 0B87E8 800B7BE8 3C04800F */ lui $a0, %hi(D_800E90E0) # $a0, 0x800f /* 0B87EC 800B7BEC 0C02D7B7 */ jal render_printf /* 0B87F0 800B7BF0 248490E0 */ addiu $a0, %lo(D_800E90E0) # addiu $a0, $a0, -0x6f20 -/* 0B87F4 800B7BF4 3C098013 */ lui $t1, %hi(gEpcInfo+0xFC) # $t1, 0x8013 -/* 0B87F8 800B7BF8 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x104) # $t3, 0x8013 -/* 0B87FC 800B7BFC 8D669904 */ lw $a2, %lo(gEpcInfo+0x104)($t3) -/* 0B8800 800B7C00 8D2598FC */ lw $a1, %lo(gEpcInfo+0xFC)($t1) +/* 0B87F4 800B7BF4 3C098013 */ lui $t1, %hi(gThread0Context+0xFC) # $t1, 0x8013 +/* 0B87F8 800B7BF8 3C0B8013 */ lui $t3, %hi(gThread0Context+0x104) # $t3, 0x8013 +/* 0B87FC 800B7BFC 8D669904 */ lw $a2, %lo(gThread0Context+0x104)($t3) +/* 0B8800 800B7C00 8D2598FC */ lw $a1, %lo(gThread0Context+0xFC)($t1) /* 0B8804 800B7C04 3C04800F */ lui $a0, %hi(D_800E9100) # $a0, 0x800f /* 0B8808 800B7C08 0C02D7B7 */ jal render_printf /* 0B880C 800B7C0C 24849100 */ addiu $a0, %lo(D_800E9100) # addiu $a0, $a0, -0x6f00 diff --git a/asm/non_matchings/thread0_epc/thread0.s b/asm/non_matchings/thread0_epc/thread0_Main.s similarity index 99% rename from asm/non_matchings/thread0_epc/thread0.s rename to asm/non_matchings/thread0_epc/thread0_Main.s index e6ff5a83..43d31a87 100644 --- a/asm/non_matchings/thread0_epc/thread0.s +++ b/asm/non_matchings/thread0_epc/thread0_Main.s @@ -1,4 +1,4 @@ -glabel thread0 +glabel thread0_Main /* 0B7BC4 800B6FC4 27BDFFC8 */ addiu $sp, $sp, -0x38 /* 0B7BC8 800B6FC8 AFB40028 */ sw $s4, 0x28($sp) /* 0B7BCC 800B6FCC 3C148013 */ lui $s4, %hi(D_80129790) # $s4, 0x8013 diff --git a/src/thread0_epc.c b/src/thread0_epc.c index 7a5e4e3f..592249bb 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -8,6 +8,7 @@ #include "controller_pak.h" #include "printf.h" #include "unknown_00BC20.h" +#include "controller.h" /************ .rodata ************/ @@ -37,7 +38,8 @@ char *D_800E302C[3] = { /************ .bss ************/ -epcInfo gEpcInfo; +__OSThreadContext gThread0Context; //Was epcInfo +s32 D_80129990[8]; s32 D_801299B0[64]; extern s32 D_80129BB0[256]; @@ -100,7 +102,7 @@ void func_800B6F50(void) { // Almost matching, just have an issue with argument 4. // The -O2 compiler is too smart. :( - osCreateThread(&D_801295E0, 0, &thread0, 0, &D_801295E0, 255); + osCreateThread(&D_801295E0, 0, thread0_Main, 0, &D_801295E0, 255); osStartThread(&D_801295E0); @@ -113,7 +115,7 @@ GLOBAL_ASM("asm/non_matchings/thread0_epc/func_800B6F50.s") #endif #ifdef NON_MATCHING -void thread0(s32 arg0) { // Has regalloc issues +void thread0_Main(s32 arg0) { // Has regalloc issues s32 sp34; s32 s0 = 0; @@ -140,7 +142,7 @@ void thread0(s32 arg0) { // Has regalloc issues } } #else -GLOBAL_ASM("asm/non_matchings/thread0_epc/thread0.s") +GLOBAL_ASM("asm/non_matchings/thread0_epc/thread0_Main.s") #endif void func_800B70D0(void) { @@ -214,26 +216,28 @@ void func_800B76B8(s32 arg0, s32 arg1) { //Called as a check to see if render_epc_lock_up_display should be called. s32 func_800B76DC(void) { s32 fileNum; - u8 sp820[4]; // Unused? - s16 sp420[0x200]; - u8 sp220[0x200]; - u8 sp1D0[0x50]; // Unused? - epcInfo dataFromControllerPak; + s32 controllerIndex = 0; + u8 *sp420[256]; + u8 *sp220[128]; + u8 *dataFromControllerPak[128]; if (D_800E3020 != -1) { return D_800E3020; } else { D_800E3020 = 0; - if ((func_800758DC(0) == 0) && (func_800764E8(0, &D_800E8EF4, &D_800E8EFC, &fileNum) == 0) - && (read_data_from_controller_pak(0, fileNum, &dataFromControllerPak, 0x800) == 0)) { - bcopy(&dataFromControllerPak, &gEpcInfo, 0x1B0); - bcopy(&sp220, &D_801299B0, 0x200); - bcopy(&sp420, &D_80129BB0, 0x400); + if ((func_800758DC(controllerIndex) == 0) && //Rumble pack check? + (func_800764E8(controllerIndex, &D_800E8EF4, &D_800E8EFC, &fileNum) == 0) && + (read_data_from_controller_pak(controllerIndex, fileNum, &dataFromControllerPak, + sizeof(dataFromControllerPak) * MAXCONTROLLERS) == 0)) + { + bcopy(&dataFromControllerPak, &gThread0Context, sizeof(dataFromControllerPak) - 80); //Why less 80 (0x50)? + bcopy(&sp220, &D_801299B0, sizeof(sp220)); + bcopy(&sp420, &D_80129BB0, sizeof(sp420)); D_800E3020 = 1; } - func_80075AEC(0); + func_80075AEC(controllerIndex); if (D_800E3020 != 0) { - func_800762C8(0, fileNum); + func_800762C8(controllerIndex, fileNum); } return D_800E3020; } @@ -266,15 +270,15 @@ void render_epc_lock_up_display(void) { switch (D_800E3024) { case 0: - D_80129FB0[0] = gEpcInfo.unk130; - D_80129FB0[1] = gEpcInfo.unk134; - D_80129FB0[2] = gEpcInfo.unk138; - if (gEpcInfo.cause != -1) { - render_printf(" Fault in thread %d\n", gEpcInfo.thread); - render_printf(" epc\t\t0x%08x\n", gEpcInfo.epc); - render_printf(" cause\t\t0x%08x\n", gEpcInfo.cause); - render_printf(" sr\t\t0x%08x\n", gEpcInfo.sr); - render_printf(" badvaddr\t0x%08x\n", gEpcInfo.badvaddr); + D_80129FB0[0] = gThread0Context.unk130; + D_80129FB0[1] = gThread0Context.unk134; + D_80129FB0[2] = gThread0Context.unk138; + if (gThread0Context.cause != -1) { + render_printf(" Fault in thread %d\n", gThread0Context.thread); + render_printf(" epc\t\t0x%08x\n", gThread0Context.epc); + render_printf(" cause\t\t0x%08x\n", gThread0Context.cause); + render_printf(" sr\t\t0x%08x\n", gThread0Context.sr); + render_printf(" badvaddr\t0x%08x\n", gThread0Context.badvaddr); for(i = 0; i < 3; i++) { if (D_80129FB0[i] != -1) { if (s3 == 0) { @@ -285,19 +289,19 @@ void render_epc_lock_up_display(void) { } } render_printf("\n"); - render_printf(" at 0x%08x v0 0x%08x v1 0x%08x\n", gEpcInfo.at, gEpcInfo.v0, gEpcInfo.v1); - render_printf(" a0 0x%08x a1 0x%08x a2 0x%08x\n", gEpcInfo.a0, gEpcInfo.a1, gEpcInfo.a2); - render_printf(" a3 0x%08x t0 0x%08x t1 0x%08x\n", gEpcInfo.a3, gEpcInfo.t0, gEpcInfo.t1); - render_printf(" t2 0x%08x t3 0x%08x t4 0x%08x\n", gEpcInfo.t2, gEpcInfo.t3, gEpcInfo.t4); - render_printf(" t5 0x%08x t6 0x%08x t7 0x%08x\n", gEpcInfo.t5, gEpcInfo.t6, gEpcInfo.t7); - render_printf(" s0 0x%08x s1 0x%08x s2 0x%08x\n", gEpcInfo.s0, gEpcInfo.s1, gEpcInfo.s2); - render_printf(" s3 0x%08x s4 0x%08x s5 0x%08x\n", gEpcInfo.s3, gEpcInfo.s4, gEpcInfo.s5); - render_printf(" s6 0x%08x s7 0x%08x t8 0x%08x\n", gEpcInfo.s6, gEpcInfo.s7, gEpcInfo.t8); - render_printf(" t9 0x%08x gp 0x%08x sp 0x%08x\n", gEpcInfo.t9, gEpcInfo.gp, gEpcInfo.sp); - render_printf(" s8 0x%08x ra 0x%08x\n\n", gEpcInfo.s8, gEpcInfo.ra); - } else { // gEpcInfo.cause == -1 - render_printf(" epc\t\t0x%08x\n", gEpcInfo.epc); - render_printf(" cause\t\tmmAlloc(%d,0x%8x)\n", gEpcInfo.a0, gEpcInfo.a1); + render_printf(" at 0x%08x v0 0x%08x v1 0x%08x\n", gThread0Context.at, gThread0Context.v0, gThread0Context.v1); + render_printf(" a0 0x%08x a1 0x%08x a2 0x%08x\n", gThread0Context.a0, gThread0Context.a1, gThread0Context.a2); + render_printf(" a3 0x%08x t0 0x%08x t1 0x%08x\n", gThread0Context.a3, gThread0Context.t0, gThread0Context.t1); + render_printf(" t2 0x%08x t3 0x%08x t4 0x%08x\n", gThread0Context.t2, gThread0Context.t3, gThread0Context.t4); + render_printf(" t5 0x%08x t6 0x%08x t7 0x%08x\n", gThread0Context.t5, gThread0Context.t6, gThread0Context.t7); + render_printf(" s0 0x%08x s1 0x%08x s2 0x%08x\n", gThread0Context.s0, gThread0Context.s1, gThread0Context.s2); + render_printf(" s3 0x%08x s4 0x%08x s5 0x%08x\n", gThread0Context.s3, gThread0Context.s4, gThread0Context.s5); + render_printf(" s6 0x%08x s7 0x%08x t8 0x%08x\n", gThread0Context.s6, gThread0Context.s7, gThread0Context.t8); + render_printf(" t9 0x%08x gp 0x%08x sp 0x%08x\n", gThread0Context.t9, gThread0Context.gp, gThread0Context.sp); + render_printf(" s8 0x%08x ra 0x%08x\n\n", gThread0Context.s8, gThread0Context.ra); + } else { // gThread0Context.cause == -1 + render_printf(" epc\t\t0x%08x\n", gThread0Context.epc); + render_printf(" cause\t\tmmAlloc(%d,0x%8x)\n", gThread0Context.a0, gThread0Context.a1); for(i = 0; i < 3; i++) { if (D_80129FB0[i] != -1) { if (s3 == 0) { @@ -309,7 +313,7 @@ void render_epc_lock_up_display(void) { } render_printf("\n"); render_printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - render_printf(" s8 0x%08x ra 0x%08x\n\n", gEpcInfo.s8, gEpcInfo.ra); + render_printf(" s8 0x%08x ra 0x%08x\n\n", gThread0Context.s8, gThread0Context.ra); render_printf("\n"); } break; diff --git a/src/thread0_epc.h b/src/thread0_epc.h index 7ffa3b72..b7a46294 100644 --- a/src/thread0_epc.h +++ b/src/thread0_epc.h @@ -81,7 +81,7 @@ s32 func_800B76DC(void); void func_800B77D4(s32 arg0); void func_800B6F50(void); // Non Matching -void thread0(s32 arg0); // Non Matching +void thread0_Main(s32 arg0); // Non Matching void func_800B7460(s32 *epc, s32 size, s32 mask); // Non Matching void render_epc_lock_up_display(void); // Non Matching void func_800B71B0(void); // Non Matching From 09672099819e5490e9776dd279ae28192f46be4f Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sun, 17 Oct 2021 23:12:41 -0400 Subject: [PATCH 02/41] I was wrong, it's distinct from __OSThreadContext --- .../thread0_epc/render_epc_lock_up_display.s | 148 +++++++++--------- src/thread0_epc.c | 51 +++--- 2 files changed, 99 insertions(+), 100 deletions(-) diff --git a/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s b/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s index f1c321e4..a66d70a5 100644 --- a/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s +++ b/asm/non_matchings/thread0_epc/render_epc_lock_up_display.s @@ -116,9 +116,9 @@ glabel render_epc_lock_up_display /* 0B8494 800B7894 00000000 */ nop glabel L800B7898 /* 0B8498 800B7898 444AF800 */ cfc1 $t2, $31 -/* 0B849C 800B789C 3C038013 */ lui $v1, %hi(gThread0Context) # $v1, 0x8013 +/* 0B849C 800B789C 3C038013 */ lui $v1, %hi(gEpcInfo) # $v1, 0x8013 /* 0B84A0 800B78A0 35410003 */ ori $at, $t2, 3 -/* 0B84A4 800B78A4 24639800 */ addiu $v1, %lo(gThread0Context) # addiu $v1, $v1, -0x6800 +/* 0B84A4 800B78A4 24639800 */ addiu $v1, %lo(gEpcInfo) # addiu $v1, $v1, -0x6800 /* 0B84A8 800B78A8 38210002 */ xori $at, $at, 2 /* 0B84AC 800B78AC 44C1F800 */ ctc1 $at, $31 /* 0B84B0 800B78B0 C4640130 */ lwc1 $f4, 0x130($v1) @@ -150,15 +150,15 @@ glabel L800B7898 /* 0B8518 800B7918 44D9F800 */ ctc1 $t9, $31 /* 0B851C 800B791C 15C1002F */ bne $t6, $at, .L800B79DC /* 0B8520 800B7920 AC580008 */ sw $t8, 8($v0) -/* 0B8524 800B7924 3C058013 */ lui $a1, %hi(gThread0Context+0x11C) # $a1, 0x8013 -/* 0B8528 800B7928 8CA5991C */ lw $a1, %lo(gThread0Context+0x11C)($a1) +/* 0B8524 800B7924 3C058013 */ lui $a1, %hi(gEpcInfo+0x11C) # $a1, 0x8013 +/* 0B8528 800B7928 8CA5991C */ lw $a1, %lo(gEpcInfo+0x11C)($a1) /* 0B852C 800B792C 3C04800F */ lui $a0, %hi(D_800E8F18) # $a0, 0x800f /* 0B8530 800B7930 0C02D7B7 */ jal render_printf /* 0B8534 800B7934 24848F18 */ addiu $a0, %lo(D_800E8F18) # addiu $a0, $a0, -0x70e8 -/* 0B8538 800B7938 3C098013 */ lui $t1, %hi(gThread0Context+0x3C) # $t1, 0x8013 -/* 0B853C 800B793C 3C0B8013 */ lui $t3, %hi(gThread0Context+0x44) # $t3, 0x8013 -/* 0B8540 800B7940 8D669844 */ lw $a2, %lo(gThread0Context+0x44)($t3) -/* 0B8544 800B7944 8D25983C */ lw $a1, %lo(gThread0Context+0x3C)($t1) +/* 0B8538 800B7938 3C098013 */ lui $t1, %hi(gEpcInfo+0x3C) # $t1, 0x8013 +/* 0B853C 800B793C 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x44) # $t3, 0x8013 +/* 0B8540 800B7940 8D669844 */ lw $a2, %lo(gEpcInfo+0x44)($t3) +/* 0B8544 800B7944 8D25983C */ lw $a1, %lo(gEpcInfo+0x3C)($t1) /* 0B8548 800B7948 3C04800F */ lui $a0, %hi(D_800E8F28) # $a0, 0x800f /* 0B854C 800B794C 0C02D7B7 */ jal render_printf /* 0B8550 800B7950 24848F28 */ addiu $a0, %lo(D_800E8F28) # addiu $a0, $a0, -0x70d8 @@ -204,23 +204,23 @@ glabel L800B7898 /* 0B85E0 800B79E0 8C650014 */ lw $a1, 0x14($v1) /* 0B85E4 800B79E4 0C02D7B7 */ jal render_printf /* 0B85E8 800B79E8 24848F6C */ addiu $a0, %lo(D_800E8F6C) # addiu $a0, $a0, -0x7094 -/* 0B85EC 800B79EC 3C058013 */ lui $a1, %hi(gThread0Context+0x11C) # $a1, 0x8013 -/* 0B85F0 800B79F0 8CA5991C */ lw $a1, %lo(gThread0Context+0x11C)($a1) +/* 0B85EC 800B79EC 3C058013 */ lui $a1, %hi(gEpcInfo+0x11C) # $a1, 0x8013 +/* 0B85F0 800B79F0 8CA5991C */ lw $a1, %lo(gEpcInfo+0x11C)($a1) /* 0B85F4 800B79F4 3C04800F */ lui $a0, %hi(D_800E8F84) # $a0, 0x800f /* 0B85F8 800B79F8 0C02D7B7 */ jal render_printf /* 0B85FC 800B79FC 24848F84 */ addiu $a0, %lo(D_800E8F84) # addiu $a0, $a0, -0x707c -/* 0B8600 800B7A00 3C058013 */ lui $a1, %hi(gThread0Context+0x120) # $a1, 0x8013 -/* 0B8604 800B7A04 8CA59920 */ lw $a1, %lo(gThread0Context+0x120)($a1) +/* 0B8600 800B7A00 3C058013 */ lui $a1, %hi(gEpcInfo+0x120) # $a1, 0x8013 +/* 0B8604 800B7A04 8CA59920 */ lw $a1, %lo(gEpcInfo+0x120)($a1) /* 0B8608 800B7A08 3C04800F */ lui $a0, %hi(D_800E8F94) # $a0, 0x800f /* 0B860C 800B7A0C 0C02D7B7 */ jal render_printf /* 0B8610 800B7A10 24848F94 */ addiu $a0, %lo(D_800E8F94) # addiu $a0, $a0, -0x706c -/* 0B8614 800B7A14 3C058013 */ lui $a1, %hi(gThread0Context+0x118) # $a1, 0x8013 -/* 0B8618 800B7A18 8CA59918 */ lw $a1, %lo(gThread0Context+0x118)($a1) +/* 0B8614 800B7A14 3C058013 */ lui $a1, %hi(gEpcInfo+0x118) # $a1, 0x8013 +/* 0B8618 800B7A18 8CA59918 */ lw $a1, %lo(gEpcInfo+0x118)($a1) /* 0B861C 800B7A1C 3C04800F */ lui $a0, %hi(D_800E8FA4) # $a0, 0x800f /* 0B8620 800B7A20 0C02D7B7 */ jal render_printf /* 0B8624 800B7A24 24848FA4 */ addiu $a0, %lo(D_800E8FA4) # addiu $a0, $a0, -0x705c -/* 0B8628 800B7A28 3C058013 */ lui $a1, %hi(gThread0Context+0x124) # $a1, 0x8013 -/* 0B862C 800B7A2C 8CA59924 */ lw $a1, %lo(gThread0Context+0x124)($a1) +/* 0B8628 800B7A28 3C058013 */ lui $a1, %hi(gEpcInfo+0x124) # $a1, 0x8013 +/* 0B862C 800B7A2C 8CA59924 */ lw $a1, %lo(gEpcInfo+0x124)($a1) /* 0B8630 800B7A30 3C04800F */ lui $a0, %hi(D_800E8FB4) # $a0, 0x800f /* 0B8634 800B7A34 0C02D7B7 */ jal render_printf /* 0B8638 800B7A38 24848FB4 */ addiu $a0, %lo(D_800E8FB4) # addiu $a0, $a0, -0x704c @@ -256,91 +256,91 @@ glabel L800B7898 /* 0B86A4 800B7AA4 3C04800F */ lui $a0, %hi(D_800E8FDC) # $a0, 0x800f /* 0B86A8 800B7AA8 0C02D7B7 */ jal render_printf /* 0B86AC 800B7AAC 24848FDC */ addiu $a0, %lo(D_800E8FDC) # addiu $a0, $a0, -0x7024 -/* 0B86B0 800B7AB0 3C198013 */ lui $t9, %hi(gThread0Context+0x24) # $t9, 0x8013 -/* 0B86B4 800B7AB4 3C0F8013 */ lui $t7, %hi(gThread0Context+0x2C) # $t7, 0x8013 -/* 0B86B8 800B7AB8 3C098013 */ lui $t1, %hi(gThread0Context+0x34) # $t1, 0x8013 -/* 0B86BC 800B7ABC 8D279834 */ lw $a3, %lo(gThread0Context+0x34)($t1) -/* 0B86C0 800B7AC0 8DE6982C */ lw $a2, %lo(gThread0Context+0x2C)($t7) -/* 0B86C4 800B7AC4 8F259824 */ lw $a1, %lo(gThread0Context+0x24)($t9) +/* 0B86B0 800B7AB0 3C198013 */ lui $t9, %hi(gEpcInfo+0x24) # $t9, 0x8013 +/* 0B86B4 800B7AB4 3C0F8013 */ lui $t7, %hi(gEpcInfo+0x2C) # $t7, 0x8013 +/* 0B86B8 800B7AB8 3C098013 */ lui $t1, %hi(gEpcInfo+0x34) # $t1, 0x8013 +/* 0B86BC 800B7ABC 8D279834 */ lw $a3, %lo(gEpcInfo+0x34)($t1) +/* 0B86C0 800B7AC0 8DE6982C */ lw $a2, %lo(gEpcInfo+0x2C)($t7) +/* 0B86C4 800B7AC4 8F259824 */ lw $a1, %lo(gEpcInfo+0x24)($t9) /* 0B86C8 800B7AC8 3C04800F */ lui $a0, %hi(D_800E8FE0) # $a0, 0x800f /* 0B86CC 800B7ACC 0C02D7B7 */ jal render_printf /* 0B86D0 800B7AD0 24848FE0 */ addiu $a0, %lo(D_800E8FE0) # addiu $a0, $a0, -0x7020 -/* 0B86D4 800B7AD4 3C0B8013 */ lui $t3, %hi(gThread0Context+0x3C) # $t3, 0x8013 -/* 0B86D8 800B7AD8 3C0D8013 */ lui $t5, %hi(gThread0Context+0x44) # $t5, 0x8013 -/* 0B86DC 800B7ADC 3C198013 */ lui $t9, %hi(gThread0Context+0x4C) # $t9, 0x8013 -/* 0B86E0 800B7AE0 8F27984C */ lw $a3, %lo(gThread0Context+0x4C)($t9) -/* 0B86E4 800B7AE4 8DA69844 */ lw $a2, %lo(gThread0Context+0x44)($t5) -/* 0B86E8 800B7AE8 8D65983C */ lw $a1, %lo(gThread0Context+0x3C)($t3) +/* 0B86D4 800B7AD4 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x3C) # $t3, 0x8013 +/* 0B86D8 800B7AD8 3C0D8013 */ lui $t5, %hi(gEpcInfo+0x44) # $t5, 0x8013 +/* 0B86DC 800B7ADC 3C198013 */ lui $t9, %hi(gEpcInfo+0x4C) # $t9, 0x8013 +/* 0B86E0 800B7AE0 8F27984C */ lw $a3, %lo(gEpcInfo+0x4C)($t9) +/* 0B86E4 800B7AE4 8DA69844 */ lw $a2, %lo(gEpcInfo+0x44)($t5) +/* 0B86E8 800B7AE8 8D65983C */ lw $a1, %lo(gEpcInfo+0x3C)($t3) /* 0B86EC 800B7AEC 3C04800F */ lui $a0, %hi(D_800E9000) # $a0, 0x800f /* 0B86F0 800B7AF0 0C02D7B7 */ jal render_printf /* 0B86F4 800B7AF4 24849000 */ addiu $a0, %lo(D_800E9000) # addiu $a0, $a0, -0x7000 -/* 0B86F8 800B7AF8 3C0F8013 */ lui $t7, %hi(gThread0Context+0x54) # $t7, 0x8013 -/* 0B86FC 800B7AFC 3C098013 */ lui $t1, %hi(gThread0Context+0x5C) # $t1, 0x8013 -/* 0B8700 800B7B00 3C0B8013 */ lui $t3, %hi(gThread0Context+0x64) # $t3, 0x8013 -/* 0B8704 800B7B04 8D679864 */ lw $a3, %lo(gThread0Context+0x64)($t3) -/* 0B8708 800B7B08 8D26985C */ lw $a2, %lo(gThread0Context+0x5C)($t1) -/* 0B870C 800B7B0C 8DE59854 */ lw $a1, %lo(gThread0Context+0x54)($t7) +/* 0B86F8 800B7AF8 3C0F8013 */ lui $t7, %hi(gEpcInfo+0x54) # $t7, 0x8013 +/* 0B86FC 800B7AFC 3C098013 */ lui $t1, %hi(gEpcInfo+0x5C) # $t1, 0x8013 +/* 0B8700 800B7B00 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x64) # $t3, 0x8013 +/* 0B8704 800B7B04 8D679864 */ lw $a3, %lo(gEpcInfo+0x64)($t3) +/* 0B8708 800B7B08 8D26985C */ lw $a2, %lo(gEpcInfo+0x5C)($t1) +/* 0B870C 800B7B0C 8DE59854 */ lw $a1, %lo(gEpcInfo+0x54)($t7) /* 0B8710 800B7B10 3C04800F */ lui $a0, %hi(D_800E9020) # $a0, 0x800f /* 0B8714 800B7B14 0C02D7B7 */ jal render_printf /* 0B8718 800B7B18 24849020 */ addiu $a0, %lo(D_800E9020) # addiu $a0, $a0, -0x6fe0 -/* 0B871C 800B7B1C 3C0D8013 */ lui $t5, %hi(gThread0Context+0x6C) # $t5, 0x8013 -/* 0B8720 800B7B20 3C198013 */ lui $t9, %hi(gThread0Context+0x74) # $t9, 0x8013 -/* 0B8724 800B7B24 3C0F8013 */ lui $t7, %hi(gThread0Context+0x7C) # $t7, 0x8013 -/* 0B8728 800B7B28 8DE7987C */ lw $a3, %lo(gThread0Context+0x7C)($t7) -/* 0B872C 800B7B2C 8F269874 */ lw $a2, %lo(gThread0Context+0x74)($t9) -/* 0B8730 800B7B30 8DA5986C */ lw $a1, %lo(gThread0Context+0x6C)($t5) +/* 0B871C 800B7B1C 3C0D8013 */ lui $t5, %hi(gEpcInfo+0x6C) # $t5, 0x8013 +/* 0B8720 800B7B20 3C198013 */ lui $t9, %hi(gEpcInfo+0x74) # $t9, 0x8013 +/* 0B8724 800B7B24 3C0F8013 */ lui $t7, %hi(gEpcInfo+0x7C) # $t7, 0x8013 +/* 0B8728 800B7B28 8DE7987C */ lw $a3, %lo(gEpcInfo+0x7C)($t7) +/* 0B872C 800B7B2C 8F269874 */ lw $a2, %lo(gEpcInfo+0x74)($t9) +/* 0B8730 800B7B30 8DA5986C */ lw $a1, %lo(gEpcInfo+0x6C)($t5) /* 0B8734 800B7B34 3C04800F */ lui $a0, %hi(D_800E9040) # $a0, 0x800f /* 0B8738 800B7B38 0C02D7B7 */ jal render_printf /* 0B873C 800B7B3C 24849040 */ addiu $a0, %lo(D_800E9040) # addiu $a0, $a0, -0x6fc0 -/* 0B8740 800B7B40 3C098013 */ lui $t1, %hi(gThread0Context+0x84) # $t1, 0x8013 -/* 0B8744 800B7B44 3C0B8013 */ lui $t3, %hi(gThread0Context+0x8C) # $t3, 0x8013 -/* 0B8748 800B7B48 3C0D8013 */ lui $t5, %hi(gThread0Context+0x94) # $t5, 0x8013 -/* 0B874C 800B7B4C 8DA79894 */ lw $a3, %lo(gThread0Context+0x94)($t5) -/* 0B8750 800B7B50 8D66988C */ lw $a2, %lo(gThread0Context+0x8C)($t3) -/* 0B8754 800B7B54 8D259884 */ lw $a1, %lo(gThread0Context+0x84)($t1) +/* 0B8740 800B7B40 3C098013 */ lui $t1, %hi(gEpcInfo+0x84) # $t1, 0x8013 +/* 0B8744 800B7B44 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x8C) # $t3, 0x8013 +/* 0B8748 800B7B48 3C0D8013 */ lui $t5, %hi(gEpcInfo+0x94) # $t5, 0x8013 +/* 0B874C 800B7B4C 8DA79894 */ lw $a3, %lo(gEpcInfo+0x94)($t5) +/* 0B8750 800B7B50 8D66988C */ lw $a2, %lo(gEpcInfo+0x8C)($t3) +/* 0B8754 800B7B54 8D259884 */ lw $a1, %lo(gEpcInfo+0x84)($t1) /* 0B8758 800B7B58 3C04800F */ lui $a0, %hi(D_800E9060) # $a0, 0x800f /* 0B875C 800B7B5C 0C02D7B7 */ jal render_printf /* 0B8760 800B7B60 24849060 */ addiu $a0, %lo(D_800E9060) # addiu $a0, $a0, -0x6fa0 -/* 0B8764 800B7B64 3C198013 */ lui $t9, %hi(gThread0Context+0x9C) # $t9, 0x8013 -/* 0B8768 800B7B68 3C0F8013 */ lui $t7, %hi(gThread0Context+0xA4) # $t7, 0x8013 -/* 0B876C 800B7B6C 3C098013 */ lui $t1, %hi(gThread0Context+0xAC) # $t1, 0x8013 -/* 0B8770 800B7B70 8D2798AC */ lw $a3, %lo(gThread0Context+0xAC)($t1) -/* 0B8774 800B7B74 8DE698A4 */ lw $a2, %lo(gThread0Context+0xA4)($t7) -/* 0B8778 800B7B78 8F25989C */ lw $a1, %lo(gThread0Context+0x9C)($t9) +/* 0B8764 800B7B64 3C198013 */ lui $t9, %hi(gEpcInfo+0x9C) # $t9, 0x8013 +/* 0B8768 800B7B68 3C0F8013 */ lui $t7, %hi(gEpcInfo+0xA4) # $t7, 0x8013 +/* 0B876C 800B7B6C 3C098013 */ lui $t1, %hi(gEpcInfo+0xAC) # $t1, 0x8013 +/* 0B8770 800B7B70 8D2798AC */ lw $a3, %lo(gEpcInfo+0xAC)($t1) +/* 0B8774 800B7B74 8DE698A4 */ lw $a2, %lo(gEpcInfo+0xA4)($t7) +/* 0B8778 800B7B78 8F25989C */ lw $a1, %lo(gEpcInfo+0x9C)($t9) /* 0B877C 800B7B7C 3C04800F */ lui $a0, %hi(D_800E9080) # $a0, 0x800f /* 0B8780 800B7B80 0C02D7B7 */ jal render_printf /* 0B8784 800B7B84 24849080 */ addiu $a0, %lo(D_800E9080) # addiu $a0, $a0, -0x6f80 -/* 0B8788 800B7B88 3C0B8013 */ lui $t3, %hi(gThread0Context+0xB4) # $t3, 0x8013 -/* 0B878C 800B7B8C 3C0D8013 */ lui $t5, %hi(gThread0Context+0xBC) # $t5, 0x8013 -/* 0B8790 800B7B90 3C198013 */ lui $t9, %hi(gThread0Context+0xC4) # $t9, 0x8013 -/* 0B8794 800B7B94 8F2798C4 */ lw $a3, %lo(gThread0Context+0xC4)($t9) -/* 0B8798 800B7B98 8DA698BC */ lw $a2, %lo(gThread0Context+0xBC)($t5) -/* 0B879C 800B7B9C 8D6598B4 */ lw $a1, %lo(gThread0Context+0xB4)($t3) +/* 0B8788 800B7B88 3C0B8013 */ lui $t3, %hi(gEpcInfo+0xB4) # $t3, 0x8013 +/* 0B878C 800B7B8C 3C0D8013 */ lui $t5, %hi(gEpcInfo+0xBC) # $t5, 0x8013 +/* 0B8790 800B7B90 3C198013 */ lui $t9, %hi(gEpcInfo+0xC4) # $t9, 0x8013 +/* 0B8794 800B7B94 8F2798C4 */ lw $a3, %lo(gEpcInfo+0xC4)($t9) +/* 0B8798 800B7B98 8DA698BC */ lw $a2, %lo(gEpcInfo+0xBC)($t5) +/* 0B879C 800B7B9C 8D6598B4 */ lw $a1, %lo(gEpcInfo+0xB4)($t3) /* 0B87A0 800B7BA0 3C04800F */ lui $a0, %hi(D_800E90A0) # $a0, 0x800f /* 0B87A4 800B7BA4 0C02D7B7 */ jal render_printf /* 0B87A8 800B7BA8 248490A0 */ addiu $a0, %lo(D_800E90A0) # addiu $a0, $a0, -0x6f60 -/* 0B87AC 800B7BAC 3C0F8013 */ lui $t7, %hi(gThread0Context+0xCC) # $t7, 0x8013 -/* 0B87B0 800B7BB0 3C098013 */ lui $t1, %hi(gThread0Context+0xD4) # $t1, 0x8013 -/* 0B87B4 800B7BB4 3C0B8013 */ lui $t3, %hi(gThread0Context+0xDC) # $t3, 0x8013 -/* 0B87B8 800B7BB8 8D6798DC */ lw $a3, %lo(gThread0Context+0xDC)($t3) -/* 0B87BC 800B7BBC 8D2698D4 */ lw $a2, %lo(gThread0Context+0xD4)($t1) -/* 0B87C0 800B7BC0 8DE598CC */ lw $a1, %lo(gThread0Context+0xCC)($t7) +/* 0B87AC 800B7BAC 3C0F8013 */ lui $t7, %hi(gEpcInfo+0xCC) # $t7, 0x8013 +/* 0B87B0 800B7BB0 3C098013 */ lui $t1, %hi(gEpcInfo+0xD4) # $t1, 0x8013 +/* 0B87B4 800B7BB4 3C0B8013 */ lui $t3, %hi(gEpcInfo+0xDC) # $t3, 0x8013 +/* 0B87B8 800B7BB8 8D6798DC */ lw $a3, %lo(gEpcInfo+0xDC)($t3) +/* 0B87BC 800B7BBC 8D2698D4 */ lw $a2, %lo(gEpcInfo+0xD4)($t1) +/* 0B87C0 800B7BC0 8DE598CC */ lw $a1, %lo(gEpcInfo+0xCC)($t7) /* 0B87C4 800B7BC4 3C04800F */ lui $a0, %hi(D_800E90C0) # $a0, 0x800f /* 0B87C8 800B7BC8 0C02D7B7 */ jal render_printf /* 0B87CC 800B7BCC 248490C0 */ addiu $a0, %lo(D_800E90C0) # addiu $a0, $a0, -0x6f40 -/* 0B87D0 800B7BD0 3C0D8013 */ lui $t5, %hi(gThread0Context+0xE4) # $t5, 0x8013 -/* 0B87D4 800B7BD4 3C198013 */ lui $t9, %hi(gThread0Context+0xEC) # $t9, 0x8013 -/* 0B87D8 800B7BD8 3C0F8013 */ lui $t7, %hi(gThread0Context+0xF4) # $t7, 0x8013 -/* 0B87DC 800B7BDC 8DE798F4 */ lw $a3, %lo(gThread0Context+0xF4)($t7) -/* 0B87E0 800B7BE0 8F2698EC */ lw $a2, %lo(gThread0Context+0xEC)($t9) -/* 0B87E4 800B7BE4 8DA598E4 */ lw $a1, %lo(gThread0Context+0xE4)($t5) +/* 0B87D0 800B7BD0 3C0D8013 */ lui $t5, %hi(gEpcInfo+0xE4) # $t5, 0x8013 +/* 0B87D4 800B7BD4 3C198013 */ lui $t9, %hi(gEpcInfo+0xEC) # $t9, 0x8013 +/* 0B87D8 800B7BD8 3C0F8013 */ lui $t7, %hi(gEpcInfo+0xF4) # $t7, 0x8013 +/* 0B87DC 800B7BDC 8DE798F4 */ lw $a3, %lo(gEpcInfo+0xF4)($t7) +/* 0B87E0 800B7BE0 8F2698EC */ lw $a2, %lo(gEpcInfo+0xEC)($t9) +/* 0B87E4 800B7BE4 8DA598E4 */ lw $a1, %lo(gEpcInfo+0xE4)($t5) /* 0B87E8 800B7BE8 3C04800F */ lui $a0, %hi(D_800E90E0) # $a0, 0x800f /* 0B87EC 800B7BEC 0C02D7B7 */ jal render_printf /* 0B87F0 800B7BF0 248490E0 */ addiu $a0, %lo(D_800E90E0) # addiu $a0, $a0, -0x6f20 -/* 0B87F4 800B7BF4 3C098013 */ lui $t1, %hi(gThread0Context+0xFC) # $t1, 0x8013 -/* 0B87F8 800B7BF8 3C0B8013 */ lui $t3, %hi(gThread0Context+0x104) # $t3, 0x8013 -/* 0B87FC 800B7BFC 8D669904 */ lw $a2, %lo(gThread0Context+0x104)($t3) -/* 0B8800 800B7C00 8D2598FC */ lw $a1, %lo(gThread0Context+0xFC)($t1) +/* 0B87F4 800B7BF4 3C098013 */ lui $t1, %hi(gEpcInfo+0xFC) # $t1, 0x8013 +/* 0B87F8 800B7BF8 3C0B8013 */ lui $t3, %hi(gEpcInfo+0x104) # $t3, 0x8013 +/* 0B87FC 800B7BFC 8D669904 */ lw $a2, %lo(gEpcInfo+0x104)($t3) +/* 0B8800 800B7C00 8D2598FC */ lw $a1, %lo(gEpcInfo+0xFC)($t1) /* 0B8804 800B7C04 3C04800F */ lui $a0, %hi(D_800E9100) # $a0, 0x800f /* 0B8808 800B7C08 0C02D7B7 */ jal render_printf /* 0B880C 800B7C0C 24849100 */ addiu $a0, %lo(D_800E9100) # addiu $a0, $a0, -0x6f00 diff --git a/src/thread0_epc.c b/src/thread0_epc.c index 592249bb..5e04cf0c 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -38,8 +38,7 @@ char *D_800E302C[3] = { /************ .bss ************/ -__OSThreadContext gThread0Context; //Was epcInfo -s32 D_80129990[8]; +epcInfo gEpcInfo; //Very similar to __OSThreadContext s32 D_801299B0[64]; extern s32 D_80129BB0[256]; @@ -230,7 +229,7 @@ s32 func_800B76DC(void) { (read_data_from_controller_pak(controllerIndex, fileNum, &dataFromControllerPak, sizeof(dataFromControllerPak) * MAXCONTROLLERS) == 0)) { - bcopy(&dataFromControllerPak, &gThread0Context, sizeof(dataFromControllerPak) - 80); //Why less 80 (0x50)? + bcopy(&dataFromControllerPak, &gEpcInfo, sizeof(dataFromControllerPak) - 80); //Why less 80 (0x50)? bcopy(&sp220, &D_801299B0, sizeof(sp220)); bcopy(&sp420, &D_80129BB0, sizeof(sp420)); D_800E3020 = 1; @@ -270,15 +269,15 @@ void render_epc_lock_up_display(void) { switch (D_800E3024) { case 0: - D_80129FB0[0] = gThread0Context.unk130; - D_80129FB0[1] = gThread0Context.unk134; - D_80129FB0[2] = gThread0Context.unk138; - if (gThread0Context.cause != -1) { - render_printf(" Fault in thread %d\n", gThread0Context.thread); - render_printf(" epc\t\t0x%08x\n", gThread0Context.epc); - render_printf(" cause\t\t0x%08x\n", gThread0Context.cause); - render_printf(" sr\t\t0x%08x\n", gThread0Context.sr); - render_printf(" badvaddr\t0x%08x\n", gThread0Context.badvaddr); + D_80129FB0[0] = gEpcInfo.unk130; + D_80129FB0[1] = gEpcInfo.unk134; + D_80129FB0[2] = gEpcInfo.unk138; + if (gEpcInfo.cause != -1) { + render_printf(" Fault in thread %d\n", gEpcInfo.thread); + render_printf(" epc\t\t0x%08x\n", gEpcInfo.epc); + render_printf(" cause\t\t0x%08x\n", gEpcInfo.cause); + render_printf(" sr\t\t0x%08x\n", gEpcInfo.sr); + render_printf(" badvaddr\t0x%08x\n", gEpcInfo.badvaddr); for(i = 0; i < 3; i++) { if (D_80129FB0[i] != -1) { if (s3 == 0) { @@ -289,19 +288,19 @@ void render_epc_lock_up_display(void) { } } render_printf("\n"); - render_printf(" at 0x%08x v0 0x%08x v1 0x%08x\n", gThread0Context.at, gThread0Context.v0, gThread0Context.v1); - render_printf(" a0 0x%08x a1 0x%08x a2 0x%08x\n", gThread0Context.a0, gThread0Context.a1, gThread0Context.a2); - render_printf(" a3 0x%08x t0 0x%08x t1 0x%08x\n", gThread0Context.a3, gThread0Context.t0, gThread0Context.t1); - render_printf(" t2 0x%08x t3 0x%08x t4 0x%08x\n", gThread0Context.t2, gThread0Context.t3, gThread0Context.t4); - render_printf(" t5 0x%08x t6 0x%08x t7 0x%08x\n", gThread0Context.t5, gThread0Context.t6, gThread0Context.t7); - render_printf(" s0 0x%08x s1 0x%08x s2 0x%08x\n", gThread0Context.s0, gThread0Context.s1, gThread0Context.s2); - render_printf(" s3 0x%08x s4 0x%08x s5 0x%08x\n", gThread0Context.s3, gThread0Context.s4, gThread0Context.s5); - render_printf(" s6 0x%08x s7 0x%08x t8 0x%08x\n", gThread0Context.s6, gThread0Context.s7, gThread0Context.t8); - render_printf(" t9 0x%08x gp 0x%08x sp 0x%08x\n", gThread0Context.t9, gThread0Context.gp, gThread0Context.sp); - render_printf(" s8 0x%08x ra 0x%08x\n\n", gThread0Context.s8, gThread0Context.ra); - } else { // gThread0Context.cause == -1 - render_printf(" epc\t\t0x%08x\n", gThread0Context.epc); - render_printf(" cause\t\tmmAlloc(%d,0x%8x)\n", gThread0Context.a0, gThread0Context.a1); + render_printf(" at 0x%08x v0 0x%08x v1 0x%08x\n", gEpcInfo.at, gEpcInfo.v0, gEpcInfo.v1); + render_printf(" a0 0x%08x a1 0x%08x a2 0x%08x\n", gEpcInfo.a0, gEpcInfo.a1, gEpcInfo.a2); + render_printf(" a3 0x%08x t0 0x%08x t1 0x%08x\n", gEpcInfo.a3, gEpcInfo.t0, gEpcInfo.t1); + render_printf(" t2 0x%08x t3 0x%08x t4 0x%08x\n", gEpcInfo.t2, gEpcInfo.t3, gEpcInfo.t4); + render_printf(" t5 0x%08x t6 0x%08x t7 0x%08x\n", gEpcInfo.t5, gEpcInfo.t6, gEpcInfo.t7); + render_printf(" s0 0x%08x s1 0x%08x s2 0x%08x\n", gEpcInfo.s0, gEpcInfo.s1, gEpcInfo.s2); + render_printf(" s3 0x%08x s4 0x%08x s5 0x%08x\n", gEpcInfo.s3, gEpcInfo.s4, gEpcInfo.s5); + render_printf(" s6 0x%08x s7 0x%08x t8 0x%08x\n", gEpcInfo.s6, gEpcInfo.s7, gEpcInfo.t8); + render_printf(" t9 0x%08x gp 0x%08x sp 0x%08x\n", gEpcInfo.t9, gEpcInfo.gp, gEpcInfo.sp); + render_printf(" s8 0x%08x ra 0x%08x\n\n", gEpcInfo.s8, gEpcInfo.ra); + } else { // gEpcInfo.cause == -1 + render_printf(" epc\t\t0x%08x\n", gEpcInfo.epc); + render_printf(" cause\t\tmmAlloc(%d,0x%8x)\n", gEpcInfo.a0, gEpcInfo.a1); for(i = 0; i < 3; i++) { if (D_80129FB0[i] != -1) { if (s3 == 0) { @@ -313,7 +312,7 @@ void render_epc_lock_up_display(void) { } render_printf("\n"); render_printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - render_printf(" s8 0x%08x ra 0x%08x\n\n", gThread0Context.s8, gThread0Context.ra); + render_printf(" s8 0x%08x ra 0x%08x\n\n", gEpcInfo.s8, gEpcInfo.ra); render_printf("\n"); } break; From 84fda38879319e90ca3675cf0dd12706aecdefdb Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Wed, 20 Oct 2021 14:36:39 -0400 Subject: [PATCH 03/41] Match an unsused printf function, and almost match render_printf --- asm/non_matchings/printf/func_800B4A14.s | 13 -------- src/particles.c | 6 +++- src/printf.c | 38 +++++++++++++++++------- 3 files changed, 33 insertions(+), 24 deletions(-) delete mode 100644 asm/non_matchings/printf/func_800B4A14.s diff --git a/asm/non_matchings/printf/func_800B4A14.s b/asm/non_matchings/printf/func_800B4A14.s deleted file mode 100644 index 6b50dcf3..00000000 --- a/asm/non_matchings/printf/func_800B4A14.s +++ /dev/null @@ -1,13 +0,0 @@ -glabel func_800B4A14 -/* 0B5614 800B4A14 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0B5618 800B4A18 AFBF0014 */ sw $ra, 0x14($sp) -/* 0B561C 800B4A1C AFA60028 */ sw $a2, 0x28($sp) -/* 0B5620 800B4A20 AFA50024 */ sw $a1, 0x24($sp) -/* 0B5624 800B4A24 AFA7002C */ sw $a3, 0x2c($sp) -/* 0B5628 800B4A28 0C02D290 */ jal sprintf -/* 0B562C 800B4A2C 27A60028 */ addiu $a2, $sp, 0x28 -/* 0B5630 800B4A30 8FBF0014 */ lw $ra, 0x14($sp) -/* 0B5634 800B4A34 27BD0020 */ addiu $sp, $sp, 0x20 -/* 0B5638 800B4A38 03E00008 */ jr $ra -/* 0B563C 800B4A3C 00000000 */ nop - diff --git a/src/particles.c b/src/particles.c index ee50ae88..0d15c031 100644 --- a/src/particles.c +++ b/src/particles.c @@ -172,7 +172,11 @@ s32 D_80127CCC; s16 D_80127CD0; s16 D_80127CD2; s32 D_80127CD4; -s32 D_80127CD8[576]; +s8 D_80127CD8; +s8 D_80127CD9; +s8 D_80127CDA; +s8 D_80127CDB; +s32 D_80127CDC[574]; s32 D_801285D8[1026]; s32 D_801295E0[108]; s32 D_80129790[6]; diff --git a/src/printf.c b/src/printf.c index b885fe4b..53e00fe5 100644 --- a/src/printf.c +++ b/src/printf.c @@ -6,6 +6,9 @@ #include "macros.h" #include "f3ddkr.h" #include "thread0_epc.h" +#include "stdarg.h" +#include "textures_sprites.h" +#include "stdio.h" /************ .data ************/ @@ -61,7 +64,7 @@ const char D_800E8C64[] = "*** diPrintf Error *** ---> Out of string space. (Pri extern s32 D_80127CA0; extern s32 D_80127CA4; extern s32 D_80127CA8; -extern u8 D_80127CD8[576]; +extern u8 D_80127CD8; extern u8 *D_801285D8; /******************************/ @@ -81,15 +84,12 @@ void func_800B4A08(s32 arg0) { D_800E2EF0 = arg0; } -#ifdef NON_MATCHING -// Unused. -// Regalloc issues. I can't get sprintf to work properly. -void func_800B4A14(char *arg0, s32 arg1, s32 arg2, s32 arg3) { - sprintf(arg0, &arg2); +void func_800B4A14(char *s, char *format, ...) { + va_list args; + va_start(args, format); + sprintf(s, format, args); + va_end(args); } -#else -GLOBAL_ASM("asm/non_matchings/printf/func_800B4A14.s") -#endif GLOBAL_ASM("asm/non_matchings/printf/sprintf.s") @@ -97,10 +97,28 @@ void func_800B5E88(void) { D_80127CA0 = load_texture(0); D_80127CA4 = load_texture(1); D_80127CA8 = load_texture(2); - D_801285D8 = &D_80127CD8[0]; + D_801285D8 = &D_80127CD8; } +#if 0 +s32 render_printf(const char *format, ...) { + s32 written; + va_list args; + va_start(args, format); + if ((D_801285D8 - &D_80127CD8) >= 0x801) { + return -1; + } + func_800B4A08(1); + written = sprintf(D_801285D8, format, args); + func_800B4A08(0); + if (written > 0) { + D_801285D8 = &D_801285D8[written] + 1; + } + return 0; +} +#else GLOBAL_ASM("asm/non_matchings/printf/render_printf.s") +#endif GLOBAL_ASM("asm/non_matchings/printf/func_800B5F78.s") void set_render_printf_color(u8 red, u8 green, u8 blue, u8 alpha) { From f5392ac5109f8328c690441a38296d5bd7e96e0a Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Wed, 20 Oct 2021 14:47:31 -0400 Subject: [PATCH 04/41] Identify some global variables, and give them a more descriptive name --- asm/non_matchings/printf/func_800B69FC.s | 12 ++++----- src/particles.c | 34 ++++++++++++------------ src/particles.h | 2 +- src/printf.c | 12 ++++----- src/textures_sprites.h | 2 +- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/asm/non_matchings/printf/func_800B69FC.s b/asm/non_matchings/printf/func_800B69FC.s index 078ecc2f..2b419fb9 100644 --- a/asm/non_matchings/printf/func_800B69FC.s +++ b/asm/non_matchings/printf/func_800B69FC.s @@ -10,13 +10,13 @@ glabel func_800B69FC /* 0B761C 800B6A1C 8DEF7CB8 */ lw $t7, %lo(D_80127CB8)($t7) /* 0B7620 800B6A20 3C19FD70 */ lui $t9, 0xfd70 /* 0B7624 800B6A24 11E00037 */ beqz $t7, .L800B6B04 -/* 0B7628 800B6A28 3C0C8012 */ lui $t4, %hi(D_80127CA0) # $t4, 0x8012 +/* 0B7628 800B6A28 3C0C8012 */ lui $t4, %hi(gTexture0) # $t4, 0x8012 /* 0B762C 800B6A2C 8C820000 */ lw $v0, ($a0) /* 0B7630 800B6A30 3C018000 */ lui $at, (0x80000020 >> 16) # lui $at, 0x8000 /* 0B7634 800B6A34 24580008 */ addiu $t8, $v0, 8 /* 0B7638 800B6A38 AC980000 */ sw $t8, ($a0) /* 0B763C 800B6A3C AC590000 */ sw $t9, ($v0) -/* 0B7640 800B6A40 8D8C7CA0 */ lw $t4, %lo(D_80127CA0)($t4) +/* 0B7640 800B6A40 8D8C7CA0 */ lw $t4, %lo(gTexture0)($t4) /* 0B7644 800B6A44 34210020 */ ori $at, (0x80000020 & 0xFFFF) # ori $at, $at, 0x20 /* 0B7648 800B6A48 01816821 */ addu $t5, $t4, $at /* 0B764C 800B6A4C AC4D0004 */ sw $t5, 4($v0) @@ -82,13 +82,13 @@ glabel func_800B69FC /* 0B7730 800B6B30 8DAD7CB8 */ lw $t5, %lo(D_80127CB8)($t5) /* 0B7734 800B6B34 3C0FFD70 */ lui $t7, 0xfd70 /* 0B7738 800B6B38 11A00037 */ beqz $t5, .L800B6C18 -/* 0B773C 800B6B3C 3C188012 */ lui $t8, %hi(D_80127CA4) # $t8, 0x8012 +/* 0B773C 800B6B3C 3C188012 */ lui $t8, %hi(gTexture1) # $t8, 0x8012 /* 0B7740 800B6B40 8C820000 */ lw $v0, ($a0) /* 0B7744 800B6B44 3C018000 */ lui $at, (0x80000020 >> 16) # lui $at, 0x8000 /* 0B7748 800B6B48 244E0008 */ addiu $t6, $v0, 8 /* 0B774C 800B6B4C AC8E0000 */ sw $t6, ($a0) /* 0B7750 800B6B50 AC4F0000 */ sw $t7, ($v0) -/* 0B7754 800B6B54 8F187CA4 */ lw $t8, %lo(D_80127CA4)($t8) +/* 0B7754 800B6B54 8F187CA4 */ lw $t8, %lo(gTexture1)($t8) /* 0B7758 800B6B58 34210020 */ ori $at, (0x80000020 & 0xFFFF) # ori $at, $at, 0x20 /* 0B775C 800B6B5C 0301C821 */ addu $t9, $t8, $at /* 0B7760 800B6B60 AC590004 */ sw $t9, 4($v0) @@ -155,13 +155,13 @@ glabel func_800B69FC /* 0B7848 800B6C48 8F397CB8 */ lw $t9, %lo(D_80127CB8)($t9) /* 0B784C 800B6C4C 3C0DFD70 */ lui $t5, 0xfd70 /* 0B7850 800B6C50 13200037 */ beqz $t9, .L800B6D30 -/* 0B7854 800B6C54 3C0E8012 */ lui $t6, %hi(D_80127CA8) # $t6, 0x8012 +/* 0B7854 800B6C54 3C0E8012 */ lui $t6, %hi(gTexture2) # $t6, 0x8012 /* 0B7858 800B6C58 8C820000 */ lw $v0, ($a0) /* 0B785C 800B6C5C 3C018000 */ lui $at, (0x80000020 >> 16) # lui $at, 0x8000 /* 0B7860 800B6C60 244C0008 */ addiu $t4, $v0, 8 /* 0B7864 800B6C64 AC8C0000 */ sw $t4, ($a0) /* 0B7868 800B6C68 AC4D0000 */ sw $t5, ($v0) -/* 0B786C 800B6C6C 8DCE7CA8 */ lw $t6, %lo(D_80127CA8)($t6) +/* 0B786C 800B6C6C 8DCE7CA8 */ lw $t6, %lo(gTexture2)($t6) /* 0B7870 800B6C70 34210020 */ ori $at, (0x80000020 & 0xFFFF) # ori $at, $at, 0x20 /* 0B7874 800B6C74 01C17821 */ addu $t7, $t6, $at /* 0B7878 800B6C78 AC4F0004 */ sw $t7, 4($v0) diff --git a/src/particles.c b/src/particles.c index 0d15c031..b1a99e39 100644 --- a/src/particles.c +++ b/src/particles.c @@ -155,9 +155,9 @@ s32 D_800E2EEC = 0x100; s32 D_80127C80; s32 D_80127C84; s32 D_80127C88[6]; -s32 D_80127CA0; -s32 D_80127CA4; -s32 D_80127CA8; +TextureHeader *gTexture0; +TextureHeader *gTexture1; +TextureHeader *gTexture2; s16 D_80127CAC; s16 D_80127CAE; s16 D_80127CB0; @@ -498,9 +498,9 @@ void func_800AF29C(unk800AF29C *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s1 if (flags & 0x4000) { arg0->unk4 = 0x4000; arg0->unk6 = 0; - arg0->unkC_4000.unkC = 0.0f; - arg0->unkC_4000.unk10 = 0.0f; - arg0->unkC_4000.unk14 = 0.0f; + arg0->unkB.unkC_4000.unkC = 0.0f; + arg0->unkB.unkC_4000.unk10 = 0.0f; + arg0->unkB.unkC_4000.unk14 = 0.0f; } else if (flags & 0x400) { arg0->unk6 = 0; arg0->unk4 = 0x400; @@ -510,19 +510,19 @@ void func_800AF29C(unk800AF29C *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s1 } else { arg0->unk7 = 0xFF; } - arg0->unkC_400.unkC = (s32*)allocate_from_main_pool_safe(arg0->unk7 * 4, 0x80808080); - arg0->unkC_400.unk10 = temp_v1->unk14; - arg0->unkC_400.unk12 = temp_v1->unk16; - arg0->unkC_400.unk14 = temp_v1->unk22; - arg0->unkC_400.unk16 = temp_v1->unk24; + arg0->unkB.unkC_400.unkC = (s32*)allocate_from_main_pool_safe(arg0->unk7 * 4, 0x80808080); + arg0->unkB.unkC_400.unk10 = temp_v1->unk14; + arg0->unkB.unkC_400.unk12 = temp_v1->unk16; + arg0->unkB.unkC_400.unk14 = temp_v1->unk22; + arg0->unkB.unkC_400.unk16 = temp_v1->unk24; } else { arg0->unk4 = 0; - arg0->unkC.unkC = temp_v1->unk14; - arg0->unkC.unkE = temp_v1->unk16; - arg0->unkC.unk10 = temp_v1->unk18; - arg0->unkC.unk12 = temp_v1->unk22; - arg0->unkC.unk14 = temp_v1->unk24; - arg0->unkC.unk16 = temp_v1->unk26; + arg0->unkB.unkC.unkC = temp_v1->unk14; + arg0->unkB.unkC.unkE = temp_v1->unk16; + arg0->unkB.unkC.unk10 = temp_v1->unk18; + arg0->unkB.unkC.unk12 = temp_v1->unk22; + arg0->unkB.unkC.unk14 = temp_v1->unk24; + arg0->unkB.unkC.unk16 = temp_v1->unk26; } } diff --git a/src/particles.h b/src/particles.h index d95201b2..93bf4f82 100644 --- a/src/particles.h +++ b/src/particles.h @@ -59,7 +59,7 @@ typedef struct unk800AF29C { unk800AF29C_C_4000 unkC_4000; unk800AF29C_C_400 unkC_400; unk800AF29C_C unkC; - }; + } unkB; s16 unk18; s16 unk1A; s16 unk1C; diff --git a/src/printf.c b/src/printf.c index 53e00fe5..ca146036 100644 --- a/src/printf.c +++ b/src/printf.c @@ -61,9 +61,9 @@ const char D_800E8C64[] = "*** diPrintf Error *** ---> Out of string space. (Pri /************ .bss ************/ -extern s32 D_80127CA0; -extern s32 D_80127CA4; -extern s32 D_80127CA8; +extern TextureHeader *gTexture0; +extern TextureHeader *gTexture1; +extern TextureHeader *gTexture2; extern u8 D_80127CD8; extern u8 *D_801285D8; @@ -94,9 +94,9 @@ void func_800B4A14(char *s, char *format, ...) { GLOBAL_ASM("asm/non_matchings/printf/sprintf.s") void func_800B5E88(void) { - D_80127CA0 = load_texture(0); - D_80127CA4 = load_texture(1); - D_80127CA8 = load_texture(2); + gTexture0 = load_texture(0); + gTexture1 = load_texture(1); + gTexture2 = load_texture(2); D_801285D8 = &D_80127CD8; } diff --git a/src/textures_sprites.h b/src/textures_sprites.h index 0113bb38..737b2e4c 100644 --- a/src/textures_sprites.h +++ b/src/textures_sprites.h @@ -81,7 +81,7 @@ void func_8007F1E8(unk8007F1E8 *arg0); void init_pulsating_light_data(PulsatingLightData *data); void update_pulsating_light_data(PulsatingLightData *data, s32 timeDelta); -//TextureHeader *load_texture(s32 arg0); // Non Matching +TextureHeader *load_texture(s32 arg0); // Non Matching void free_texture(TextureHeader *tex); // Non Matching TextureHeader *func_8007B380(s32 arg0); // Non Matching void func_8007B4E8(s32, s32, s32, s32); // Non Matching From a8118b571b07f1cfb4a68f9bcf5f306b4370cc22 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Wed, 20 Oct 2021 21:42:42 -0400 Subject: [PATCH 05/41] Match osPfsAllocateFile from libreultra --- .../unknown_0D1C40/__osClearPage.s | 57 ---- .../unknown_0D1C40/__osPfsDeclearPage.s | 167 --------- .../unknown_0D1C40/osPfsAllocateFile.s | 318 ------------------ lib/src/os/osVirtualToPhysical.c | 6 +- lib/src/os/pfsallocatefile.c | 184 ++++++++++ lib/src/os/unknown_0D1C40.c | 9 - 6 files changed, 186 insertions(+), 555 deletions(-) delete mode 100644 lib/asm/non_matchings/unknown_0D1C40/__osClearPage.s delete mode 100644 lib/asm/non_matchings/unknown_0D1C40/__osPfsDeclearPage.s delete mode 100644 lib/asm/non_matchings/unknown_0D1C40/osPfsAllocateFile.s create mode 100644 lib/src/os/pfsallocatefile.c delete mode 100644 lib/src/os/unknown_0D1C40.c diff --git a/lib/asm/non_matchings/unknown_0D1C40/__osClearPage.s b/lib/asm/non_matchings/unknown_0D1C40/__osClearPage.s deleted file mode 100644 index a8ba8e78..00000000 --- a/lib/asm/non_matchings/unknown_0D1C40/__osClearPage.s +++ /dev/null @@ -1,57 +0,0 @@ -glabel __osClearPage -/* 0D2328 800D1728 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0D232C 800D172C AFA40028 */ sw $a0, 0x28($sp) -/* 0D2330 800D1730 AFA70034 */ sw $a3, 0x34($sp) -/* 0D2334 800D1734 93AE0037 */ lbu $t6, 0x37($sp) -/* 0D2338 800D1738 8FAF0028 */ lw $t7, 0x28($sp) -/* 0D233C 800D173C AFBF001C */ sw $ra, 0x1c($sp) -/* 0D2340 800D1740 AFA5002C */ sw $a1, 0x2c($sp) -/* 0D2344 800D1744 AFA60030 */ sw $a2, 0x30($sp) -/* 0D2348 800D1748 AFA00020 */ sw $zero, 0x20($sp) -/* 0D234C 800D174C A1EE0065 */ sb $t6, 0x65($t7) -/* 0D2350 800D1750 0C0357F7 */ jal __osPfsSelectBank -/* 0D2354 800D1754 8FA40028 */ lw $a0, 0x28($sp) -/* 0D2358 800D1758 AFA20020 */ sw $v0, 0x20($sp) -/* 0D235C 800D175C 8FB80020 */ lw $t8, 0x20($sp) -/* 0D2360 800D1760 13000003 */ beqz $t8, .L800D1770 -/* 0D2364 800D1764 00000000 */ nop -/* 0D2368 800D1768 1000001B */ b .L800D17D8 -/* 0D236C 800D176C 03001025 */ move $v0, $t8 -.L800D1770: -/* 0D2370 800D1770 AFA00024 */ sw $zero, 0x24($sp) -.L800D1774: -/* 0D2374 800D1774 8FB90028 */ lw $t9, 0x28($sp) -/* 0D2378 800D1778 8FA8002C */ lw $t0, 0x2c($sp) -/* 0D237C 800D177C 8FAA0024 */ lw $t2, 0x24($sp) -/* 0D2380 800D1780 8F240004 */ lw $a0, 4($t9) -/* 0D2384 800D1784 8F250008 */ lw $a1, 8($t9) -/* 0D2388 800D1788 000848C0 */ sll $t1, $t0, 3 -/* 0D238C 800D178C AFA00010 */ sw $zero, 0x10($sp) -/* 0D2390 800D1790 8FA70030 */ lw $a3, 0x30($sp) -/* 0D2394 800D1794 0C03363C */ jal __osContRamWrite -/* 0D2398 800D1798 012A3021 */ addu $a2, $t1, $t2 -/* 0D239C 800D179C AFA20020 */ sw $v0, 0x20($sp) -/* 0D23A0 800D17A0 8FAB0020 */ lw $t3, 0x20($sp) -/* 0D23A4 800D17A4 15600006 */ bnez $t3, .L800D17C0 -/* 0D23A8 800D17A8 00000000 */ nop -/* 0D23AC 800D17AC 8FAC0024 */ lw $t4, 0x24($sp) -/* 0D23B0 800D17B0 258D0001 */ addiu $t5, $t4, 1 -/* 0D23B4 800D17B4 29A10008 */ slti $at, $t5, 8 -/* 0D23B8 800D17B8 1420FFEE */ bnez $at, .L800D1774 -/* 0D23BC 800D17BC AFAD0024 */ sw $t5, 0x24($sp) -.L800D17C0: -/* 0D23C0 800D17C0 8FAE0028 */ lw $t6, 0x28($sp) -/* 0D23C4 800D17C4 A1C00065 */ sb $zero, 0x65($t6) -/* 0D23C8 800D17C8 0C0357F7 */ jal __osPfsSelectBank -/* 0D23CC 800D17CC 8FA40028 */ lw $a0, 0x28($sp) -/* 0D23D0 800D17D0 AFA20020 */ sw $v0, 0x20($sp) -/* 0D23D4 800D17D4 8FA20020 */ lw $v0, 0x20($sp) -.L800D17D8: -/* 0D23D8 800D17D8 8FBF001C */ lw $ra, 0x1c($sp) -/* 0D23DC 800D17DC 27BD0028 */ addiu $sp, $sp, 0x28 -/* 0D23E0 800D17E0 03E00008 */ jr $ra -/* 0D23E4 800D17E4 00000000 */ nop - -/* 0D23E8 800D17E8 00000000 */ nop -/* 0D23EC 800D17EC 00000000 */ nop - diff --git a/lib/asm/non_matchings/unknown_0D1C40/__osPfsDeclearPage.s b/lib/asm/non_matchings/unknown_0D1C40/__osPfsDeclearPage.s deleted file mode 100644 index eb8ca2e1..00000000 --- a/lib/asm/non_matchings/unknown_0D1C40/__osPfsDeclearPage.s +++ /dev/null @@ -1,167 +0,0 @@ -glabel __osPfsDeclearPage -/* 0D20C4 800D14C4 27BDFFB0 */ addiu $sp, $sp, -0x50 -/* 0D20C8 800D14C8 93AE0063 */ lbu $t6, 0x63($sp) -/* 0D20CC 800D14CC AFBF0014 */ sw $ra, 0x14($sp) -/* 0D20D0 800D14D0 AFA40050 */ sw $a0, 0x50($sp) -/* 0D20D4 800D14D4 AFA50054 */ sw $a1, 0x54($sp) -/* 0D20D8 800D14D8 AFA60058 */ sw $a2, 0x58($sp) -/* 0D20DC 800D14DC AFA7005C */ sw $a3, 0x5c($sp) -/* 0D20E0 800D14E0 19C00004 */ blez $t6, .L800D14F4 -/* 0D20E4 800D14E4 AFA0001C */ sw $zero, 0x1c($sp) -/* 0D20E8 800D14E8 240F0001 */ li $t7, 1 -/* 0D20EC 800D14EC 10000004 */ b .L800D1500 -/* 0D20F0 800D14F0 AFAF0018 */ sw $t7, 0x18($sp) -.L800D14F4: -/* 0D20F4 800D14F4 8FB80050 */ lw $t8, 0x50($sp) -/* 0D20F8 800D14F8 8F190060 */ lw $t9, 0x60($t8) -/* 0D20FC 800D14FC AFB90018 */ sw $t9, 0x18($sp) -.L800D1500: -/* 0D2100 800D1500 8FA80018 */ lw $t0, 0x18($sp) -/* 0D2104 800D1504 29010080 */ slti $at, $t0, 0x80 -/* 0D2108 800D1508 1020000E */ beqz $at, .L800D1544 -/* 0D210C 800D150C AFA8004C */ sw $t0, 0x4c($sp) -.L800D1510: -/* 0D2110 800D1510 8FAA004C */ lw $t2, 0x4c($sp) -/* 0D2114 800D1514 8FA90054 */ lw $t1, 0x54($sp) -/* 0D2118 800D1518 24010003 */ li $at, 3 -/* 0D211C 800D151C 000A5840 */ sll $t3, $t2, 1 -/* 0D2120 800D1520 012B6021 */ addu $t4, $t1, $t3 -/* 0D2124 800D1524 958D0000 */ lhu $t5, ($t4) -/* 0D2128 800D1528 11A10006 */ beq $t5, $at, .L800D1544 -/* 0D212C 800D152C 00000000 */ nop -/* 0D2130 800D1530 8FAE004C */ lw $t6, 0x4c($sp) -/* 0D2134 800D1534 25CF0001 */ addiu $t7, $t6, 1 -/* 0D2138 800D1538 29E10080 */ slti $at, $t7, 0x80 -/* 0D213C 800D153C 1420FFF4 */ bnez $at, .L800D1510 -/* 0D2140 800D1540 AFAF004C */ sw $t7, 0x4c($sp) -.L800D1544: -/* 0D2144 800D1544 8FB8004C */ lw $t8, 0x4c($sp) -/* 0D2148 800D1548 24010080 */ li $at, 128 -/* 0D214C 800D154C 17010006 */ bne $t8, $at, .L800D1568 -/* 0D2150 800D1550 00000000 */ nop -/* 0D2154 800D1554 8FA8005C */ lw $t0, 0x5c($sp) -/* 0D2158 800D1558 2419FFFF */ li $t9, -1 -/* 0D215C 800D155C AD190000 */ sw $t9, ($t0) -/* 0D2160 800D1560 1000006D */ b .L800D1718 -/* 0D2164 800D1564 8FA2001C */ lw $v0, 0x1c($sp) -.L800D1568: -/* 0D2168 800D1568 AFA00020 */ sw $zero, 0x20($sp) -.L800D156C: -/* 0D216C 800D156C 8FAA0020 */ lw $t2, 0x20($sp) -/* 0D2170 800D1570 03AA4821 */ addu $t1, $sp, $t2 -/* 0D2174 800D1574 A1200024 */ sb $zero, 0x24($t1) -/* 0D2178 800D1578 8FAB0020 */ lw $t3, 0x20($sp) -/* 0D217C 800D157C 256C0001 */ addiu $t4, $t3, 1 -/* 0D2180 800D1580 29810020 */ slti $at, $t4, 0x20 -/* 0D2184 800D1584 1420FFF9 */ bnez $at, .L800D156C -/* 0D2188 800D1588 AFAC0020 */ sw $t4, 0x20($sp) -/* 0D218C 800D158C 8FAD004C */ lw $t5, 0x4c($sp) -/* 0D2190 800D1590 8FAF0064 */ lw $t7, 0x64($sp) -/* 0D2194 800D1594 240E0001 */ li $t6, 1 -/* 0D2198 800D1598 AFAD0048 */ sw $t5, 0x48($sp) -/* 0D219C 800D159C ADEE0000 */ sw $t6, ($t7) -/* 0D21A0 800D15A0 8FB8004C */ lw $t8, 0x4c($sp) -/* 0D21A4 800D15A4 8FAA0064 */ lw $t2, 0x64($sp) -/* 0D21A8 800D15A8 8FA80058 */ lw $t0, 0x58($sp) -/* 0D21AC 800D15AC 27190001 */ addiu $t9, $t8, 1 -/* 0D21B0 800D15B0 AFB9004C */ sw $t9, 0x4c($sp) -/* 0D21B4 800D15B4 AFB80044 */ sw $t8, 0x44($sp) -/* 0D21B8 800D15B8 8D490000 */ lw $t1, ($t2) -/* 0D21BC 800D15BC 0128082A */ slt $at, $t1, $t0 -/* 0D21C0 800D15C0 10200034 */ beqz $at, .L800D1694 -/* 0D21C4 800D15C4 2B210080 */ slti $at, $t9, 0x80 -/* 0D21C8 800D15C8 10200032 */ beqz $at, .L800D1694 -/* 0D21CC 800D15CC 00000000 */ nop -.L800D15D0: -/* 0D21D0 800D15D0 8FAC004C */ lw $t4, 0x4c($sp) -/* 0D21D4 800D15D4 8FAB0054 */ lw $t3, 0x54($sp) -/* 0D21D8 800D15D8 24010003 */ li $at, 3 -/* 0D21DC 800D15DC 000C6840 */ sll $t5, $t4, 1 -/* 0D21E0 800D15E0 016D7021 */ addu $t6, $t3, $t5 -/* 0D21E4 800D15E4 95CF0000 */ lhu $t7, ($t6) -/* 0D21E8 800D15E8 15E1001D */ bne $t7, $at, .L800D1660 -/* 0D21EC 800D15EC 00000000 */ nop -/* 0D21F0 800D15F0 8FAA0044 */ lw $t2, 0x44($sp) -/* 0D21F4 800D15F4 93B80063 */ lbu $t8, 0x63($sp) -/* 0D21F8 800D15F8 27A60024 */ addiu $a2, $sp, 0x24 -/* 0D21FC 800D15FC 000A4040 */ sll $t0, $t2, 1 -/* 0D2200 800D1600 01684821 */ addu $t1, $t3, $t0 -/* 0D2204 800D1604 A1380000 */ sb $t8, ($t1) -/* 0D2208 800D1608 8FAD0044 */ lw $t5, 0x44($sp) -/* 0D220C 800D160C 8FAC0054 */ lw $t4, 0x54($sp) -/* 0D2210 800D1610 8FB9004C */ lw $t9, 0x4c($sp) -/* 0D2214 800D1614 000D7040 */ sll $t6, $t5, 1 -/* 0D2218 800D1618 018E7821 */ addu $t7, $t4, $t6 -/* 0D221C 800D161C A1F90001 */ sb $t9, 1($t7) -/* 0D2220 800D1620 93A70063 */ lbu $a3, 0x63($sp) -/* 0D2224 800D1624 8FA50044 */ lw $a1, 0x44($sp) -/* 0D2228 800D1628 0C0345CA */ jal __osClearPage -/* 0D222C 800D162C 8FA40050 */ lw $a0, 0x50($sp) -/* 0D2230 800D1630 AFA2001C */ sw $v0, 0x1c($sp) -/* 0D2234 800D1634 8FAA001C */ lw $t2, 0x1c($sp) -/* 0D2238 800D1638 11400003 */ beqz $t2, .L800D1648 -/* 0D223C 800D163C 00000000 */ nop -/* 0D2240 800D1640 10000035 */ b .L800D1718 -/* 0D2244 800D1644 01401025 */ move $v0, $t2 -.L800D1648: -/* 0D2248 800D1648 8FAB004C */ lw $t3, 0x4c($sp) -/* 0D224C 800D164C 8FA80064 */ lw $t0, 0x64($sp) -/* 0D2250 800D1650 AFAB0044 */ sw $t3, 0x44($sp) -/* 0D2254 800D1654 8D180000 */ lw $t8, ($t0) -/* 0D2258 800D1658 27090001 */ addiu $t1, $t8, 1 -/* 0D225C 800D165C AD090000 */ sw $t1, ($t0) -.L800D1660: -/* 0D2260 800D1660 8FAD004C */ lw $t5, 0x4c($sp) -/* 0D2264 800D1664 8FB90064 */ lw $t9, 0x64($sp) -/* 0D2268 800D1668 8FAE0058 */ lw $t6, 0x58($sp) -/* 0D226C 800D166C 25AC0001 */ addiu $t4, $t5, 1 -/* 0D2270 800D1670 AFAC004C */ sw $t4, 0x4c($sp) -/* 0D2274 800D1674 8F2F0000 */ lw $t7, ($t9) -/* 0D2278 800D1678 01EE082A */ slt $at, $t7, $t6 -/* 0D227C 800D167C 10200005 */ beqz $at, .L800D1694 -/* 0D2280 800D1680 00000000 */ nop -/* 0D2284 800D1684 8FAA004C */ lw $t2, 0x4c($sp) -/* 0D2288 800D1688 29410080 */ slti $at, $t2, 0x80 -/* 0D228C 800D168C 1420FFD0 */ bnez $at, .L800D15D0 -/* 0D2290 800D1690 00000000 */ nop -.L800D1694: -/* 0D2294 800D1694 8FAB0048 */ lw $t3, 0x48($sp) -/* 0D2298 800D1698 8FB8005C */ lw $t8, 0x5c($sp) -/* 0D229C 800D169C 24010080 */ li $at, 128 -/* 0D22A0 800D16A0 AF0B0000 */ sw $t3, ($t8) -/* 0D22A4 800D16A4 8FA9004C */ lw $t1, 0x4c($sp) -/* 0D22A8 800D16A8 1521000C */ bne $t1, $at, .L800D16DC -/* 0D22AC 800D16AC 00000000 */ nop -/* 0D22B0 800D16B0 8FAD0064 */ lw $t5, 0x64($sp) -/* 0D22B4 800D16B4 8FA80058 */ lw $t0, 0x58($sp) -/* 0D22B8 800D16B8 8DAC0000 */ lw $t4, ($t5) -/* 0D22BC 800D16BC 0188082A */ slt $at, $t4, $t0 -/* 0D22C0 800D16C0 10200006 */ beqz $at, .L800D16DC -/* 0D22C4 800D16C4 00000000 */ nop -/* 0D22C8 800D16C8 8FB90044 */ lw $t9, 0x44($sp) -/* 0D22CC 800D16CC 8FAE0068 */ lw $t6, 0x68($sp) -/* 0D22D0 800D16D0 ADD90000 */ sw $t9, ($t6) -/* 0D22D4 800D16D4 10000010 */ b .L800D1718 -/* 0D22D8 800D16D8 8FA2001C */ lw $v0, 0x1c($sp) -.L800D16DC: -/* 0D22DC 800D16DC 8FAB0044 */ lw $t3, 0x44($sp) -/* 0D22E0 800D16E0 8FAA0054 */ lw $t2, 0x54($sp) -/* 0D22E4 800D16E4 240F0001 */ li $t7, 1 -/* 0D22E8 800D16E8 000BC040 */ sll $t8, $t3, 1 -/* 0D22EC 800D16EC 01584821 */ addu $t1, $t2, $t8 -/* 0D22F0 800D16F0 A52F0000 */ sh $t7, ($t1) -/* 0D22F4 800D16F4 93A70063 */ lbu $a3, 0x63($sp) -/* 0D22F8 800D16F8 8FA50044 */ lw $a1, 0x44($sp) -/* 0D22FC 800D16FC 8FA40050 */ lw $a0, 0x50($sp) -/* 0D2300 800D1700 0C0345CA */ jal __osClearPage -/* 0D2304 800D1704 27A60024 */ addiu $a2, $sp, 0x24 -/* 0D2308 800D1708 8FAD0068 */ lw $t5, 0x68($sp) -/* 0D230C 800D170C AFA2001C */ sw $v0, 0x1c($sp) -/* 0D2310 800D1710 ADA00000 */ sw $zero, ($t5) -/* 0D2314 800D1714 8FA2001C */ lw $v0, 0x1c($sp) -.L800D1718: -/* 0D2318 800D1718 8FBF0014 */ lw $ra, 0x14($sp) -/* 0D231C 800D171C 27BD0050 */ addiu $sp, $sp, 0x50 -/* 0D2320 800D1720 03E00008 */ jr $ra -/* 0D2324 800D1724 00000000 */ nop - diff --git a/lib/asm/non_matchings/unknown_0D1C40/osPfsAllocateFile.s b/lib/asm/non_matchings/unknown_0D1C40/osPfsAllocateFile.s deleted file mode 100644 index 92c55a91..00000000 --- a/lib/asm/non_matchings/unknown_0D1C40/osPfsAllocateFile.s +++ /dev/null @@ -1,318 +0,0 @@ -glabel osPfsAllocateFile -/* 0D1C40 800D1040 27BDFD88 */ addiu $sp, $sp, -0x278 -/* 0D1C44 800D1044 AFA5027C */ sw $a1, 0x27c($sp) -/* 0D1C48 800D1048 97AE027E */ lhu $t6, 0x27e($sp) -/* 0D1C4C 800D104C AFBF0024 */ sw $ra, 0x24($sp) -/* 0D1C50 800D1050 AFA40278 */ sw $a0, 0x278($sp) -/* 0D1C54 800D1054 AFA60280 */ sw $a2, 0x280($sp) -/* 0D1C58 800D1058 AFA70284 */ sw $a3, 0x284($sp) -/* 0D1C5C 800D105C AFA00268 */ sw $zero, 0x268($sp) -/* 0D1C60 800D1060 AFA00260 */ sw $zero, 0x260($sp) -/* 0D1C64 800D1064 A3A0003A */ sb $zero, 0x3a($sp) -/* 0D1C68 800D1068 11C00004 */ beqz $t6, .L800D107C -/* 0D1C6C 800D106C AFA00034 */ sw $zero, 0x34($sp) -/* 0D1C70 800D1070 8FAF0280 */ lw $t7, 0x280($sp) -/* 0D1C74 800D1074 15E00003 */ bnez $t7, .L800D1084 -/* 0D1C78 800D1078 00000000 */ nop -.L800D107C: -/* 0D1C7C 800D107C 1000010D */ b .L800D14B4 -/* 0D1C80 800D1080 24020005 */ li $v0, 5 -.L800D1084: -/* 0D1C84 800D1084 8FB8028C */ lw $t8, 0x28c($sp) -/* 0D1C88 800D1088 8FA90278 */ lw $t1, 0x278($sp) -/* 0D1C8C 800D108C 271900FF */ addiu $t9, $t8, 0xff -/* 0D1C90 800D1090 07210003 */ bgez $t9, .L800D10A0 -/* 0D1C94 800D1094 00194203 */ sra $t0, $t9, 8 -/* 0D1C98 800D1098 272100FF */ addiu $at, $t9, 0xff -/* 0D1C9C 800D109C 00014203 */ sra $t0, $at, 8 -.L800D10A0: -/* 0D1CA0 800D10A0 AFA8025C */ sw $t0, 0x25c($sp) -/* 0D1CA4 800D10A4 8D2A0000 */ lw $t2, ($t1) -/* 0D1CA8 800D10A8 314B0001 */ andi $t3, $t2, 1 -/* 0D1CAC 800D10AC 15600003 */ bnez $t3, .L800D10BC -/* 0D1CB0 800D10B0 00000000 */ nop -/* 0D1CB4 800D10B4 100000FF */ b .L800D14B4 -/* 0D1CB8 800D10B8 24020005 */ li $v0, 5 -.L800D10BC: -/* 0D1CBC 800D10BC 0C0356F0 */ jal __osCheckId -/* 0D1CC0 800D10C0 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1CC4 800D10C4 24010002 */ li $at, 2 -/* 0D1CC8 800D10C8 14410003 */ bne $v0, $at, .L800D10D8 -/* 0D1CCC 800D10CC 00000000 */ nop -/* 0D1CD0 800D10D0 100000F8 */ b .L800D14B4 -/* 0D1CD4 800D10D4 24020002 */ li $v0, 2 -.L800D10D8: -/* 0D1CD8 800D10D8 8FAC0288 */ lw $t4, 0x288($sp) -/* 0D1CDC 800D10DC 8FAD0290 */ lw $t5, 0x290($sp) -/* 0D1CE0 800D10E0 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1CE4 800D10E4 97A5027E */ lhu $a1, 0x27e($sp) -/* 0D1CE8 800D10E8 8FA60280 */ lw $a2, 0x280($sp) -/* 0D1CEC 800D10EC 8FA70284 */ lw $a3, 0x284($sp) -/* 0D1CF0 800D10F0 AFAC0010 */ sw $t4, 0x10($sp) -/* 0D1CF4 800D10F4 0C0343A0 */ jal osPfsFindFile -/* 0D1CF8 800D10F8 AFAD0014 */ sw $t5, 0x14($sp) -/* 0D1CFC 800D10FC AFA20260 */ sw $v0, 0x260($sp) -/* 0D1D00 800D1100 8FAE0260 */ lw $t6, 0x260($sp) -/* 0D1D04 800D1104 11C00005 */ beqz $t6, .L800D111C -/* 0D1D08 800D1108 24010005 */ li $at, 5 -/* 0D1D0C 800D110C 11C10003 */ beq $t6, $at, .L800D111C -/* 0D1D10 800D1110 00000000 */ nop -/* 0D1D14 800D1114 100000E7 */ b .L800D14B4 -/* 0D1D18 800D1118 01C01025 */ move $v0, $t6 -.L800D111C: -/* 0D1D1C 800D111C 8FAF0290 */ lw $t7, 0x290($sp) -/* 0D1D20 800D1120 2401FFFF */ li $at, -1 -/* 0D1D24 800D1124 8DF80000 */ lw $t8, ($t7) -/* 0D1D28 800D1128 13010003 */ beq $t8, $at, .L800D1138 -/* 0D1D2C 800D112C 00000000 */ nop -/* 0D1D30 800D1130 100000E0 */ b .L800D14B4 -/* 0D1D34 800D1134 24020009 */ li $v0, 9 -.L800D1138: -/* 0D1D38 800D1138 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1D3C 800D113C 0C033CF8 */ jal osPfsFreeBlocks -/* 0D1D40 800D1140 27A50030 */ addiu $a1, $sp, 0x30 -/* 0D1D44 800D1144 8FB9028C */ lw $t9, 0x28c($sp) -/* 0D1D48 800D1148 8FA80030 */ lw $t0, 0x30($sp) -/* 0D1D4C 800D114C AFA20260 */ sw $v0, 0x260($sp) -/* 0D1D50 800D1150 0119082A */ slt $at, $t0, $t9 -/* 0D1D54 800D1154 10200003 */ beqz $at, .L800D1164 -/* 0D1D58 800D1158 00000000 */ nop -/* 0D1D5C 800D115C 100000D5 */ b .L800D14B4 -/* 0D1D60 800D1160 24020007 */ li $v0, 7 -.L800D1164: -/* 0D1D64 800D1164 8FA9025C */ lw $t1, 0x25c($sp) -/* 0D1D68 800D1168 112000D1 */ beqz $t1, .L800D14B0 -/* 0D1D6C 800D116C 00000000 */ nop -/* 0D1D70 800D1170 8FAA0290 */ lw $t2, 0x290($sp) -/* 0D1D74 800D1174 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1D78 800D1178 00002825 */ move $a1, $zero -/* 0D1D7C 800D117C 00003025 */ move $a2, $zero -/* 0D1D80 800D1180 00003825 */ move $a3, $zero -/* 0D1D84 800D1184 AFA00010 */ sw $zero, 0x10($sp) -/* 0D1D88 800D1188 0C0343A0 */ jal osPfsFindFile -/* 0D1D8C 800D118C AFAA0014 */ sw $t2, 0x14($sp) -/* 0D1D90 800D1190 AFA20260 */ sw $v0, 0x260($sp) -/* 0D1D94 800D1194 8FAB0260 */ lw $t3, 0x260($sp) -/* 0D1D98 800D1198 11600005 */ beqz $t3, .L800D11B0 -/* 0D1D9C 800D119C 24010005 */ li $at, 5 -/* 0D1DA0 800D11A0 11610003 */ beq $t3, $at, .L800D11B0 -/* 0D1DA4 800D11A4 00000000 */ nop -/* 0D1DA8 800D11A8 100000C2 */ b .L800D14B4 -/* 0D1DAC 800D11AC 01601025 */ move $v0, $t3 -.L800D11B0: -/* 0D1DB0 800D11B0 8FAC0290 */ lw $t4, 0x290($sp) -/* 0D1DB4 800D11B4 2401FFFF */ li $at, -1 -/* 0D1DB8 800D11B8 8D8D0000 */ lw $t5, ($t4) -/* 0D1DBC 800D11BC 15A10003 */ bne $t5, $at, .L800D11CC -/* 0D1DC0 800D11C0 00000000 */ nop -/* 0D1DC4 800D11C4 100000BB */ b .L800D14B4 -/* 0D1DC8 800D11C8 24020008 */ li $v0, 8 -.L800D11CC: -/* 0D1DCC 800D11CC 8FAE0278 */ lw $t6, 0x278($sp) -/* 0D1DD0 800D11D0 A3A0003B */ sb $zero, 0x3b($sp) -/* 0D1DD4 800D11D4 91CF0064 */ lbu $t7, 0x64($t6) -/* 0D1DD8 800D11D8 19E00062 */ blez $t7, .L800D1364 -/* 0D1DDC 800D11DC 00000000 */ nop -.L800D11E0: -/* 0D1DE0 800D11E0 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1DE4 800D11E4 27A5015C */ addiu $a1, $sp, 0x15c -/* 0D1DE8 800D11E8 00003025 */ move $a2, $zero -/* 0D1DEC 800D11EC 0C03572F */ jal __osPfsRWInode -/* 0D1DF0 800D11F0 93A7003B */ lbu $a3, 0x3b($sp) -/* 0D1DF4 800D11F4 AFA20260 */ sw $v0, 0x260($sp) -/* 0D1DF8 800D11F8 8FB80260 */ lw $t8, 0x260($sp) -/* 0D1DFC 800D11FC 13000003 */ beqz $t8, .L800D120C -/* 0D1E00 800D1200 00000000 */ nop -/* 0D1E04 800D1204 100000AB */ b .L800D14B4 -/* 0D1E08 800D1208 03001025 */ move $v0, $t8 -.L800D120C: -/* 0D1E0C 800D120C 93B9003B */ lbu $t9, 0x3b($sp) -/* 0D1E10 800D1210 27A80270 */ addiu $t0, $sp, 0x270 -/* 0D1E14 800D1214 27A9026C */ addiu $t1, $sp, 0x26c -/* 0D1E18 800D1218 AFA90018 */ sw $t1, 0x18($sp) -/* 0D1E1C 800D121C AFA80014 */ sw $t0, 0x14($sp) -/* 0D1E20 800D1220 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1E24 800D1224 27A5015C */ addiu $a1, $sp, 0x15c -/* 0D1E28 800D1228 8FA6025C */ lw $a2, 0x25c($sp) -/* 0D1E2C 800D122C 27A70274 */ addiu $a3, $sp, 0x274 -/* 0D1E30 800D1230 0C034531 */ jal __osPfsDeclearPage -/* 0D1E34 800D1234 AFB90010 */ sw $t9, 0x10($sp) -/* 0D1E38 800D1238 AFA20260 */ sw $v0, 0x260($sp) -/* 0D1E3C 800D123C 8FAA0260 */ lw $t2, 0x260($sp) -/* 0D1E40 800D1240 11400003 */ beqz $t2, .L800D1250 -/* 0D1E44 800D1244 00000000 */ nop -/* 0D1E48 800D1248 1000009A */ b .L800D14B4 -/* 0D1E4C 800D124C 01401025 */ move $v0, $t2 -.L800D1250: -/* 0D1E50 800D1250 8FAB0274 */ lw $t3, 0x274($sp) -/* 0D1E54 800D1254 2401FFFF */ li $at, -1 -/* 0D1E58 800D1258 11610039 */ beq $t3, $at, .L800D1340 -/* 0D1E5C 800D125C 00000000 */ nop -/* 0D1E60 800D1260 8FAC0034 */ lw $t4, 0x34($sp) -/* 0D1E64 800D1264 15800005 */ bnez $t4, .L800D127C -/* 0D1E68 800D1268 00000000 */ nop -/* 0D1E6C 800D126C 93AD003B */ lbu $t5, 0x3b($sp) -/* 0D1E70 800D1270 A3AB002D */ sb $t3, 0x2d($sp) -/* 0D1E74 800D1274 10000016 */ b .L800D12D0 -/* 0D1E78 800D1278 A3AD002C */ sb $t5, 0x2c($sp) -.L800D127C: -/* 0D1E7C 800D127C 8FAF0268 */ lw $t7, 0x268($sp) -/* 0D1E80 800D1280 93AE003B */ lbu $t6, 0x3b($sp) -/* 0D1E84 800D1284 27A5005C */ addiu $a1, $sp, 0x5c -/* 0D1E88 800D1288 000FC040 */ sll $t8, $t7, 1 -/* 0D1E8C 800D128C 03B8C821 */ addu $t9, $sp, $t8 -/* 0D1E90 800D1290 A32E005C */ sb $t6, 0x5c($t9) -/* 0D1E94 800D1294 8FA90268 */ lw $t1, 0x268($sp) -/* 0D1E98 800D1298 8FA80274 */ lw $t0, 0x274($sp) -/* 0D1E9C 800D129C 24060001 */ li $a2, 1 -/* 0D1EA0 800D12A0 00095040 */ sll $t2, $t1, 1 -/* 0D1EA4 800D12A4 03AA6021 */ addu $t4, $sp, $t2 -/* 0D1EA8 800D12A8 A188005D */ sb $t0, 0x5d($t4) -/* 0D1EAC 800D12AC 93A7003A */ lbu $a3, 0x3a($sp) -/* 0D1EB0 800D12B0 0C03572F */ jal __osPfsRWInode -/* 0D1EB4 800D12B4 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1EB8 800D12B8 AFA20260 */ sw $v0, 0x260($sp) -/* 0D1EBC 800D12BC 8FAB0260 */ lw $t3, 0x260($sp) -/* 0D1EC0 800D12C0 11600003 */ beqz $t3, .L800D12D0 -/* 0D1EC4 800D12C4 00000000 */ nop -/* 0D1EC8 800D12C8 1000007A */ b .L800D14B4 -/* 0D1ECC 800D12CC 01601025 */ move $v0, $t3 -.L800D12D0: -/* 0D1ED0 800D12D0 AFA00264 */ sw $zero, 0x264($sp) -.L800D12D4: -/* 0D1ED4 800D12D4 8FAD0264 */ lw $t5, 0x264($sp) -/* 0D1ED8 800D12D8 000D7840 */ sll $t7, $t5, 1 -/* 0D1EDC 800D12DC 03AF7021 */ addu $t6, $sp, $t7 -/* 0D1EE0 800D12E0 95CE015C */ lhu $t6, 0x15c($t6) -/* 0D1EE4 800D12E4 03AFC021 */ addu $t8, $sp, $t7 -/* 0D1EE8 800D12E8 A70E005C */ sh $t6, 0x5c($t8) -/* 0D1EEC 800D12EC 8FB90264 */ lw $t9, 0x264($sp) -/* 0D1EF0 800D12F0 27290001 */ addiu $t1, $t9, 1 -/* 0D1EF4 800D12F4 29210080 */ slti $at, $t1, 0x80 -/* 0D1EF8 800D12F8 1420FFF6 */ bnez $at, .L800D12D4 -/* 0D1EFC 800D12FC AFA90264 */ sw $t1, 0x264($sp) -/* 0D1F00 800D1300 8FAC0034 */ lw $t4, 0x34($sp) -/* 0D1F04 800D1304 8FAD025C */ lw $t5, 0x25c($sp) -/* 0D1F08 800D1308 8FAE0270 */ lw $t6, 0x270($sp) -/* 0D1F0C 800D130C 8FA8026C */ lw $t0, 0x26c($sp) -/* 0D1F10 800D1310 93AA003B */ lbu $t2, 0x3b($sp) -/* 0D1F14 800D1314 258B0001 */ addiu $t3, $t4, 1 -/* 0D1F18 800D1318 01CD082A */ slt $at, $t6, $t5 -/* 0D1F1C 800D131C AFAB0034 */ sw $t3, 0x34($sp) -/* 0D1F20 800D1320 AFA80268 */ sw $t0, 0x268($sp) -/* 0D1F24 800D1324 10200004 */ beqz $at, .L800D1338 -/* 0D1F28 800D1328 A3AA003A */ sb $t2, 0x3a($sp) -/* 0D1F2C 800D132C 01AE7823 */ subu $t7, $t5, $t6 -/* 0D1F30 800D1330 10000003 */ b .L800D1340 -/* 0D1F34 800D1334 AFAF025C */ sw $t7, 0x25c($sp) -.L800D1338: -/* 0D1F38 800D1338 1000000A */ b .L800D1364 -/* 0D1F3C 800D133C AFA0025C */ sw $zero, 0x25c($sp) -.L800D1340: -/* 0D1F40 800D1340 93B8003B */ lbu $t8, 0x3b($sp) -/* 0D1F44 800D1344 8FA80278 */ lw $t0, 0x278($sp) -/* 0D1F48 800D1348 27190001 */ addiu $t9, $t8, 1 -/* 0D1F4C 800D134C A3B9003B */ sb $t9, 0x3b($sp) -/* 0D1F50 800D1350 910A0064 */ lbu $t2, 0x64($t0) -/* 0D1F54 800D1354 332900FF */ andi $t1, $t9, 0xff -/* 0D1F58 800D1358 012A082A */ slt $at, $t1, $t2 -/* 0D1F5C 800D135C 1420FFA0 */ bnez $at, .L800D11E0 -/* 0D1F60 800D1360 00000000 */ nop -.L800D1364: -/* 0D1F64 800D1364 8FAC025C */ lw $t4, 0x25c($sp) -/* 0D1F68 800D1368 1D800005 */ bgtz $t4, .L800D1380 -/* 0D1F6C 800D136C 00000000 */ nop -/* 0D1F70 800D1370 8FAB0274 */ lw $t3, 0x274($sp) -/* 0D1F74 800D1374 2401FFFF */ li $at, -1 -/* 0D1F78 800D1378 15610003 */ bne $t3, $at, .L800D1388 -/* 0D1F7C 800D137C 00000000 */ nop -.L800D1380: -/* 0D1F80 800D1380 1000004C */ b .L800D14B4 -/* 0D1F84 800D1384 24020003 */ li $v0, 3 -.L800D1388: -/* 0D1F88 800D1388 8FAE0268 */ lw $t6, 0x268($sp) -/* 0D1F8C 800D138C 93AD003B */ lbu $t5, 0x3b($sp) -/* 0D1F90 800D1390 27A5005C */ addiu $a1, $sp, 0x5c -/* 0D1F94 800D1394 000E7840 */ sll $t7, $t6, 1 -/* 0D1F98 800D1398 03AFC021 */ addu $t8, $sp, $t7 -/* 0D1F9C 800D139C A30D005C */ sb $t5, 0x5c($t8) -/* 0D1FA0 800D13A0 8FA80268 */ lw $t0, 0x268($sp) -/* 0D1FA4 800D13A4 8FB90274 */ lw $t9, 0x274($sp) -/* 0D1FA8 800D13A8 24060001 */ li $a2, 1 -/* 0D1FAC 800D13AC 00084840 */ sll $t1, $t0, 1 -/* 0D1FB0 800D13B0 03A95021 */ addu $t2, $sp, $t1 -/* 0D1FB4 800D13B4 A159005D */ sb $t9, 0x5d($t2) -/* 0D1FB8 800D13B8 93A7003A */ lbu $a3, 0x3a($sp) -/* 0D1FBC 800D13BC 0C03572F */ jal __osPfsRWInode -/* 0D1FC0 800D13C0 8FA40278 */ lw $a0, 0x278($sp) -/* 0D1FC4 800D13C4 AFA20260 */ sw $v0, 0x260($sp) -/* 0D1FC8 800D13C8 8FAC0260 */ lw $t4, 0x260($sp) -/* 0D1FCC 800D13CC 11800003 */ beqz $t4, .L800D13DC -/* 0D1FD0 800D13D0 00000000 */ nop -/* 0D1FD4 800D13D4 10000037 */ b .L800D14B4 -/* 0D1FD8 800D13D8 01801025 */ move $v0, $t4 -.L800D13DC: -/* 0D1FDC 800D13DC 97AB002C */ lhu $t3, 0x2c($sp) -/* 0D1FE0 800D13E0 97AE027E */ lhu $t6, 0x27e($sp) -/* 0D1FE4 800D13E4 8FAD0280 */ lw $t5, 0x280($sp) -/* 0D1FE8 800D13E8 A7A00046 */ sh $zero, 0x46($sp) -/* 0D1FEC 800D13EC AFA00264 */ sw $zero, 0x264($sp) -/* 0D1FF0 800D13F0 A7AB0042 */ sh $t3, 0x42($sp) -/* 0D1FF4 800D13F4 A7AE0040 */ sh $t6, 0x40($sp) -/* 0D1FF8 800D13F8 AFAD003C */ sw $t5, 0x3c($sp) -.L800D13FC: -/* 0D1FFC 800D13FC 8FAF0284 */ lw $t7, 0x284($sp) -/* 0D2000 800D1400 8FA80264 */ lw $t0, 0x264($sp) -/* 0D2004 800D1404 91F80000 */ lbu $t8, ($t7) -/* 0D2008 800D1408 03A8C821 */ addu $t9, $sp, $t0 -/* 0D200C 800D140C A338004C */ sb $t8, 0x4c($t9) -/* 0D2010 800D1410 8FAC0264 */ lw $t4, 0x264($sp) -/* 0D2014 800D1414 8FA90284 */ lw $t1, 0x284($sp) -/* 0D2018 800D1418 258B0001 */ addiu $t3, $t4, 1 -/* 0D201C 800D141C 29610010 */ slti $at, $t3, 0x10 -/* 0D2020 800D1420 252A0001 */ addiu $t2, $t1, 1 -/* 0D2024 800D1424 AFAB0264 */ sw $t3, 0x264($sp) -/* 0D2028 800D1428 1420FFF4 */ bnez $at, .L800D13FC -/* 0D202C 800D142C AFAA0284 */ sw $t2, 0x284($sp) -/* 0D2030 800D1430 AFA00264 */ sw $zero, 0x264($sp) -.L800D1434: -/* 0D2034 800D1434 8FAE0288 */ lw $t6, 0x288($sp) -/* 0D2038 800D1438 8FAF0264 */ lw $t7, 0x264($sp) -/* 0D203C 800D143C 91CD0000 */ lbu $t5, ($t6) -/* 0D2040 800D1440 03AFC021 */ addu $t8, $sp, $t7 -/* 0D2044 800D1444 A30D0048 */ sb $t5, 0x48($t8) -/* 0D2048 800D1448 8FA90264 */ lw $t1, 0x264($sp) -/* 0D204C 800D144C 8FA80288 */ lw $t0, 0x288($sp) -/* 0D2050 800D1450 252A0001 */ addiu $t2, $t1, 1 -/* 0D2054 800D1454 29410004 */ slti $at, $t2, 4 -/* 0D2058 800D1458 25190001 */ addiu $t9, $t0, 1 -/* 0D205C 800D145C AFAA0264 */ sw $t2, 0x264($sp) -/* 0D2060 800D1460 1420FFF4 */ bnez $at, .L800D1434 -/* 0D2064 800D1464 AFB90288 */ sw $t9, 0x288($sp) -/* 0D2068 800D1468 8FAC0278 */ lw $t4, 0x278($sp) -/* 0D206C 800D146C 8FAB0290 */ lw $t3, 0x290($sp) -/* 0D2070 800D1470 27A7003C */ addiu $a3, $sp, 0x3c -/* 0D2074 800D1474 8D8D005C */ lw $t5, 0x5c($t4) -/* 0D2078 800D1478 8D6E0000 */ lw $t6, ($t3) -/* 0D207C 800D147C 8D840004 */ lw $a0, 4($t4) -/* 0D2080 800D1480 8D850008 */ lw $a1, 8($t4) -/* 0D2084 800D1484 AFA00010 */ sw $zero, 0x10($sp) -/* 0D2088 800D1488 0C03363C */ jal __osContRamWrite -/* 0D208C 800D148C 01CD3021 */ addu $a2, $t6, $t5 -/* 0D2090 800D1490 AFA20260 */ sw $v0, 0x260($sp) -/* 0D2094 800D1494 8FAF0260 */ lw $t7, 0x260($sp) -/* 0D2098 800D1498 11E00003 */ beqz $t7, .L800D14A8 -/* 0D209C 800D149C 00000000 */ nop -/* 0D20A0 800D14A0 10000004 */ b .L800D14B4 -/* 0D20A4 800D14A4 01E01025 */ move $v0, $t7 -.L800D14A8: -/* 0D20A8 800D14A8 10000002 */ b .L800D14B4 -/* 0D20AC 800D14AC 8FA20260 */ lw $v0, 0x260($sp) -.L800D14B0: -/* 0D20B0 800D14B0 24020005 */ li $v0, 5 -.L800D14B4: -/* 0D20B4 800D14B4 8FBF0024 */ lw $ra, 0x24($sp) -/* 0D20B8 800D14B8 27BD0278 */ addiu $sp, $sp, 0x278 -/* 0D20BC 800D14BC 03E00008 */ jr $ra -/* 0D20C0 800D14C0 00000000 */ nop - diff --git a/lib/src/os/osVirtualToPhysical.c b/lib/src/os/osVirtualToPhysical.c index 468de672..24844b0b 100644 --- a/lib/src/os/osVirtualToPhysical.c +++ b/lib/src/os/osVirtualToPhysical.c @@ -8,11 +8,9 @@ u32 osVirtualToPhysical(void *addr) { if (IS_KSEG0(addr)) { return K0_TO_PHYS(addr); - } - else if (IS_KSEG1(addr)) { + } else if (IS_KSEG1(addr)) { return K1_TO_PHYS(addr); - } - else { + } else { return __osProbeTLB(addr); } } diff --git a/lib/src/os/pfsallocatefile.c b/lib/src/os/pfsallocatefile.c new file mode 100644 index 00000000..a5e4147a --- /dev/null +++ b/lib/src/os/pfsallocatefile.c @@ -0,0 +1,184 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D1040 */ + +#include "types.h" +#include "controller.h" + +static s32 __osClearPage(OSPfs *pfs, int page_no, u8 *data, u8 bank); +s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, int file_size_in_bytes, s32 *file_no) +{ + int start_page; + int decleared; + int last_page; + int old_last_page; + int j; + s32 ret; + int file_size_in_pages; + __OSInode inode; + __OSInode backup_inode; + __OSDir dir; + u8 bank; + u8 old_bank; + int firsttime; + s32 bytes; + __OSInodeUnit fpage; + + old_last_page = 0; + ret = 0; + old_bank = 0; + firsttime = 0; + + if (company_code == 0 || game_code == 0) + return PFS_ERR_INVALID; + + file_size_in_pages = (file_size_in_bytes + 255) / (BLOCKSIZE * PFS_ONE_PAGE); + if ((pfs->status & PFS_INITIALIZED) == FALSE) + return PFS_ERR_INVALID; + + PFS_CHECK_ID; + + ret = osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, file_no); + if (ret != 0 && ret != PFS_ERR_INVALID) + return ret; + + if (*file_no != -1) + return PFS_ERR_EXIST; + + ret = osPfsFreeBlocks(pfs, &bytes); + if (file_size_in_bytes > bytes) + return PFS_DATA_FULL; + + if (file_size_in_pages != 0) + { + ret = osPfsFindFile(pfs, 0, 0, NULL, NULL, file_no); + if (ret != 0 && ret != PFS_ERR_INVALID) + return ret; + if (*file_no == -1) + return PFS_DIR_FULL; + + for (bank = 0; bank < pfs->banks; bank++) + { + ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); + ERRCK(__osPfsDeclearPage(pfs, &inode, file_size_in_pages, &start_page, bank, &decleared, &last_page)); + if (start_page != -1) + { + if (firsttime == 0) + { + fpage.inode_t.page = start_page; + fpage.inode_t.bank = bank; + } + else + { + backup_inode.inode_page[old_last_page].inode_t.bank = bank; + backup_inode.inode_page[old_last_page].inode_t.page = start_page; + ERRCK(__osPfsRWInode(pfs, &backup_inode, OS_WRITE, old_bank)); + } + + for (j = 0; j < ARRLEN(inode.inode_page); j++) + backup_inode.inode_page[j].ipage = inode.inode_page[j].ipage; + old_last_page = last_page; + old_bank = bank; + firsttime++; + if (file_size_in_pages > decleared) + file_size_in_pages = file_size_in_pages - decleared; + else + { + file_size_in_pages = 0; + break; + } + } + } + if (file_size_in_pages > 0 || start_page == -1) + return PFS_ERR_INCONSISTENT; + + backup_inode.inode_page[old_last_page].inode_t.bank = bank; + backup_inode.inode_page[old_last_page].inode_t.page = start_page; + ERRCK(__osPfsRWInode(pfs, &backup_inode, OS_WRITE, old_bank)); + dir.start_page = fpage; + dir.company_code = company_code; + dir.game_code = game_code; + dir.data_sum = 0; + for (j = 0; j < ARRLEN(dir.game_name); j++) + dir.game_name[j] = *game_name++; + for (j = 0; j < ARRLEN(dir.ext_name); j++) + dir.ext_name[j] = *ext_name++; + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, *file_no + pfs->dir_table, (u8*)&dir, FALSE)); + return ret; + } + return PFS_ERR_INVALID; +} + +s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page) +{ + int j; + int spage; + int old_page; + u8 tmp_data[BLOCKSIZE]; + int i; + s32 ret; + int offset; + + ret = 0; + if (bank > 0) + offset = 1; + else + offset = pfs->inode_start_page; + for (j = offset; j < ARRLEN(inode->inode_page); j++) + { + if (inode->inode_page[j].ipage == 3) + break; + } + if (j == ARRLEN(inode->inode_page)) + { + *first_page = -1; + return ret; + } + for (i = 0; i < ARRLEN(tmp_data); i++) + tmp_data[i] = 0; + spage = j; + *decleared = 1; + old_page = j++; + while (file_size_in_pages > *decleared && j < ARRLEN(inode->inode_page)) + { + if (inode->inode_page[j].ipage == 3) + { + inode->inode_page[old_page].inode_t.bank = bank; + inode->inode_page[old_page].inode_t.page = j; + ERRCK(__osClearPage(pfs, old_page, (u8*)tmp_data, bank)); + old_page = j; + (*decleared)++; + } + j++; + } + *first_page = spage; + if (j == ARRLEN(inode->inode_page)) + { + if (file_size_in_pages > *decleared) + { + *last_page = old_page; + return ret; + } + } + inode->inode_page[old_page].ipage = 1; + ret = __osClearPage(pfs, old_page, (u8*)tmp_data, bank); + *last_page = 0; + return ret; +} + +static s32 __osClearPage(OSPfs *pfs, int page_no, u8 *data, u8 bank) +{ + int i; + s32 ret; + ret = 0; + pfs->activebank = bank; + ERRCK(__osPfsSelectBank(pfs)); + for (i = 0; i < PFS_ONE_PAGE; i++) + { + ret = __osContRamWrite(pfs->queue, pfs->channel, page_no * PFS_ONE_PAGE + i, data, FALSE); + if (ret != 0) + break; + } + pfs->activebank = 0; + ret = __osPfsSelectBank(pfs); + return ret; +} diff --git a/lib/src/os/unknown_0D1C40.c b/lib/src/os/unknown_0D1C40.c deleted file mode 100644 index 005deba2..00000000 --- a/lib/src/os/unknown_0D1C40.c +++ /dev/null @@ -1,9 +0,0 @@ -/* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800D1040 */ - -#include "types.h" -#include "macros.h" - -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1C40/osPfsAllocateFile.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1C40/__osPfsDeclearPage.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1C40/__osClearPage.s") From c0f4b7488318224eb57327e345354ef7ac17aea0 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Wed, 20 Oct 2021 21:46:15 -0400 Subject: [PATCH 06/41] osPfsFileState matched from libreultra --- .../unknown_0D1180/osPfsFileState.s | 209 ------------------ lib/src/os/unknown_0D1180.c | 58 ++++- 2 files changed, 57 insertions(+), 210 deletions(-) delete mode 100644 lib/asm/non_matchings/unknown_0D1180/osPfsFileState.s diff --git a/lib/asm/non_matchings/unknown_0D1180/osPfsFileState.s b/lib/asm/non_matchings/unknown_0D1180/osPfsFileState.s deleted file mode 100644 index 77254a68..00000000 --- a/lib/asm/non_matchings/unknown_0D1180/osPfsFileState.s +++ /dev/null @@ -1,209 +0,0 @@ -glabel osPfsFileState -/* 0D1180 800D0580 27BDFEB0 */ addiu $sp, $sp, -0x150 -/* 0D1184 800D0584 AFA40150 */ sw $a0, 0x150($sp) -/* 0D1188 800D0588 8FAF0150 */ lw $t7, 0x150($sp) -/* 0D118C 800D058C AFA50154 */ sw $a1, 0x154($sp) -/* 0D1190 800D0590 AFBF0014 */ sw $ra, 0x14($sp) -/* 0D1194 800D0594 AFA60158 */ sw $a2, 0x158($sp) -/* 0D1198 800D0598 8FAE0154 */ lw $t6, 0x154($sp) -/* 0D119C 800D059C 8DF80050 */ lw $t8, 0x50($t7) -/* 0D11A0 800D05A0 01D8082A */ slt $at, $t6, $t8 -/* 0D11A4 800D05A4 10200003 */ beqz $at, .L800D05B4 -/* 0D11A8 800D05A8 00000000 */ nop -/* 0D11AC 800D05AC 05C10003 */ bgez $t6, .L800D05BC -/* 0D11B0 800D05B0 00000000 */ nop -.L800D05B4: -/* 0D11B4 800D05B4 100000AA */ b .L800D0860 -/* 0D11B8 800D05B8 24020005 */ li $v0, 5 -.L800D05BC: -/* 0D11BC 800D05BC 8FB90150 */ lw $t9, 0x150($sp) -/* 0D11C0 800D05C0 8F280000 */ lw $t0, ($t9) -/* 0D11C4 800D05C4 31090001 */ andi $t1, $t0, 1 -/* 0D11C8 800D05C8 15200003 */ bnez $t1, .L800D05D8 -/* 0D11CC 800D05CC 00000000 */ nop -/* 0D11D0 800D05D0 100000A3 */ b .L800D0860 -/* 0D11D4 800D05D4 24020005 */ li $v0, 5 -.L800D05D8: -/* 0D11D8 800D05D8 0C0356F0 */ jal __osCheckId -/* 0D11DC 800D05DC 8FA40150 */ lw $a0, 0x150($sp) -/* 0D11E0 800D05E0 24010002 */ li $at, 2 -/* 0D11E4 800D05E4 14410003 */ bne $v0, $at, .L800D05F4 -/* 0D11E8 800D05E8 00000000 */ nop -/* 0D11EC 800D05EC 1000009C */ b .L800D0860 -/* 0D11F0 800D05F0 24020002 */ li $v0, 2 -.L800D05F4: -/* 0D11F4 800D05F4 8FAA0150 */ lw $t2, 0x150($sp) -/* 0D11F8 800D05F8 914B0065 */ lbu $t3, 0x65($t2) -/* 0D11FC 800D05FC 1160000A */ beqz $t3, .L800D0628 -/* 0D1200 800D0600 00000000 */ nop -/* 0D1204 800D0604 A1400065 */ sb $zero, 0x65($t2) -/* 0D1208 800D0608 0C0357F7 */ jal __osPfsSelectBank -/* 0D120C 800D060C 8FA40150 */ lw $a0, 0x150($sp) -/* 0D1210 800D0610 AFA2014C */ sw $v0, 0x14c($sp) -/* 0D1214 800D0614 8FAC014C */ lw $t4, 0x14c($sp) -/* 0D1218 800D0618 11800003 */ beqz $t4, .L800D0628 -/* 0D121C 800D061C 00000000 */ nop -/* 0D1220 800D0620 1000008F */ b .L800D0860 -/* 0D1224 800D0624 01801025 */ move $v0, $t4 -.L800D0628: -/* 0D1228 800D0628 8FAD0150 */ lw $t5, 0x150($sp) -/* 0D122C 800D062C 8FB80154 */ lw $t8, 0x154($sp) -/* 0D1230 800D0630 27A70028 */ addiu $a3, $sp, 0x28 -/* 0D1234 800D0634 8DAF005C */ lw $t7, 0x5c($t5) -/* 0D1238 800D0638 8DA40004 */ lw $a0, 4($t5) -/* 0D123C 800D063C 8DA50008 */ lw $a1, 8($t5) -/* 0D1240 800D0640 0C033728 */ jal __osContRamRead -/* 0D1244 800D0644 01F83021 */ addu $a2, $t7, $t8 -/* 0D1248 800D0648 AFA2014C */ sw $v0, 0x14c($sp) -/* 0D124C 800D064C 8FAE014C */ lw $t6, 0x14c($sp) -/* 0D1250 800D0650 11C00003 */ beqz $t6, .L800D0660 -/* 0D1254 800D0654 00000000 */ nop -/* 0D1258 800D0658 10000081 */ b .L800D0860 -/* 0D125C 800D065C 01C01025 */ move $v0, $t6 -.L800D0660: -/* 0D1260 800D0660 97B9002C */ lhu $t9, 0x2c($sp) -/* 0D1264 800D0664 13200004 */ beqz $t9, .L800D0678 -/* 0D1268 800D0668 00000000 */ nop -/* 0D126C 800D066C 8FA80028 */ lw $t0, 0x28($sp) -/* 0D1270 800D0670 15000003 */ bnez $t0, .L800D0680 -/* 0D1274 800D0674 00000000 */ nop -.L800D0678: -/* 0D1278 800D0678 10000079 */ b .L800D0860 -/* 0D127C 800D067C 24020005 */ li $v0, 5 -.L800D0680: -/* 0D1280 800D0680 8FAB0150 */ lw $t3, 0x150($sp) -/* 0D1284 800D0684 97A9002E */ lhu $t1, 0x2e($sp) -/* 0D1288 800D0688 8D6A0060 */ lw $t2, 0x60($t3) -/* 0D128C 800D068C 012A082A */ slt $at, $t1, $t2 -/* 0D1290 800D0690 10200003 */ beqz $at, .L800D06A0 -/* 0D1294 800D0694 00000000 */ nop -/* 0D1298 800D0698 10000071 */ b .L800D0860 -/* 0D129C 800D069C 24020003 */ li $v0, 3 -.L800D06A0: -/* 0D12A0 800D06A0 93AC002F */ lbu $t4, 0x2f($sp) -/* 0D12A4 800D06A4 93AD002E */ lbu $t5, 0x2e($sp) -/* 0D12A8 800D06A8 8FAF0150 */ lw $t7, 0x150($sp) -/* 0D12AC 800D06AC AFA00148 */ sw $zero, 0x148($sp) -/* 0D12B0 800D06B0 A3AC001E */ sb $t4, 0x1e($sp) -/* 0D12B4 800D06B4 A3AD001F */ sb $t5, 0x1f($sp) -/* 0D12B8 800D06B8 91F80064 */ lbu $t8, 0x64($t7) -/* 0D12BC 800D06BC 01B8082A */ slt $at, $t5, $t8 -/* 0D12C0 800D06C0 1020003E */ beqz $at, .L800D07BC -/* 0D12C4 800D06C4 00000000 */ nop -.L800D06C8: -/* 0D12C8 800D06C8 8FA40150 */ lw $a0, 0x150($sp) -/* 0D12CC 800D06CC 27A50048 */ addiu $a1, $sp, 0x48 -/* 0D12D0 800D06D0 00003025 */ move $a2, $zero -/* 0D12D4 800D06D4 0C03572F */ jal __osPfsRWInode -/* 0D12D8 800D06D8 93A7001F */ lbu $a3, 0x1f($sp) -/* 0D12DC 800D06DC AFA2014C */ sw $v0, 0x14c($sp) -/* 0D12E0 800D06E0 8FAE014C */ lw $t6, 0x14c($sp) -/* 0D12E4 800D06E4 11C00003 */ beqz $t6, .L800D06F4 -/* 0D12E8 800D06E8 00000000 */ nop -/* 0D12EC 800D06EC 1000005C */ b .L800D0860 -/* 0D12F0 800D06F0 01C01025 */ move $v0, $t6 -.L800D06F4: -/* 0D12F4 800D06F4 93A8001E */ lbu $t0, 0x1e($sp) -/* 0D12F8 800D06F8 27A90048 */ addiu $t1, $sp, 0x48 -/* 0D12FC 800D06FC 27B90024 */ addiu $t9, $sp, 0x24 -/* 0D1300 800D0700 00085840 */ sll $t3, $t0, 1 -/* 0D1304 800D0704 01695021 */ addu $t2, $t3, $t1 -/* 0D1308 800D0708 95410000 */ lhu $at, ($t2) -/* 0D130C 800D070C A7210000 */ sh $at, ($t9) -/* 0D1310 800D0710 8FAD0148 */ lw $t5, 0x148($sp) -/* 0D1314 800D0714 8FA80150 */ lw $t0, 0x150($sp) -/* 0D1318 800D0718 97AE0024 */ lhu $t6, 0x24($sp) -/* 0D131C 800D071C 25B80001 */ addiu $t8, $t5, 1 -/* 0D1320 800D0720 AFB80148 */ sw $t8, 0x148($sp) -/* 0D1324 800D0724 8D0B0060 */ lw $t3, 0x60($t0) -/* 0D1328 800D0728 01CB082A */ slt $at, $t6, $t3 -/* 0D132C 800D072C 14200019 */ bnez $at, .L800D0794 -/* 0D1330 800D0730 00000000 */ nop -.L800D0734: -/* 0D1334 800D0734 8FA90148 */ lw $t1, 0x148($sp) -/* 0D1338 800D0738 93AA0025 */ lbu $t2, 0x25($sp) -/* 0D133C 800D073C 27AD0048 */ addiu $t5, $sp, 0x48 -/* 0D1340 800D0740 252C0001 */ addiu $t4, $t1, 1 -/* 0D1344 800D0744 000A7840 */ sll $t7, $t2, 1 -/* 0D1348 800D0748 AFAC0148 */ sw $t4, 0x148($sp) -/* 0D134C 800D074C 01EDC021 */ addu $t8, $t7, $t5 -/* 0D1350 800D0750 97010000 */ lhu $at, ($t8) -/* 0D1354 800D0754 27B90024 */ addiu $t9, $sp, 0x24 -/* 0D1358 800D0758 A7210000 */ sh $at, ($t9) -/* 0D135C 800D075C 93AC001F */ lbu $t4, 0x1f($sp) -/* 0D1360 800D0760 93A90024 */ lbu $t1, 0x24($sp) -/* 0D1364 800D0764 112C0005 */ beq $t1, $t4, .L800D077C -/* 0D1368 800D0768 00000000 */ nop -/* 0D136C 800D076C 93AA0025 */ lbu $t2, 0x25($sp) -/* 0D1370 800D0770 A3A9001F */ sb $t1, 0x1f($sp) -/* 0D1374 800D0774 10000007 */ b .L800D0794 -/* 0D1378 800D0778 A3AA001E */ sb $t2, 0x1e($sp) -.L800D077C: -/* 0D137C 800D077C 8FAD0150 */ lw $t5, 0x150($sp) -/* 0D1380 800D0780 97AF0024 */ lhu $t7, 0x24($sp) -/* 0D1384 800D0784 8DAE0060 */ lw $t6, 0x60($t5) -/* 0D1388 800D0788 01EE082A */ slt $at, $t7, $t6 -/* 0D138C 800D078C 1020FFE9 */ beqz $at, .L800D0734 -/* 0D1390 800D0790 00000000 */ nop -.L800D0794: -/* 0D1394 800D0794 97A80024 */ lhu $t0, 0x24($sp) -/* 0D1398 800D0798 24010001 */ li $at, 1 -/* 0D139C 800D079C 11010007 */ beq $t0, $at, .L800D07BC -/* 0D13A0 800D07A0 00000000 */ nop -/* 0D13A4 800D07A4 8FB80150 */ lw $t8, 0x150($sp) -/* 0D13A8 800D07A8 93B9001F */ lbu $t9, 0x1f($sp) -/* 0D13AC 800D07AC 930B0064 */ lbu $t3, 0x64($t8) -/* 0D13B0 800D07B0 032B082A */ slt $at, $t9, $t3 -/* 0D13B4 800D07B4 1420FFC4 */ bnez $at, .L800D06C8 -/* 0D13B8 800D07B8 00000000 */ nop -.L800D07BC: -/* 0D13BC 800D07BC 97AC0024 */ lhu $t4, 0x24($sp) -/* 0D13C0 800D07C0 24010001 */ li $at, 1 -/* 0D13C4 800D07C4 11810003 */ beq $t4, $at, .L800D07D4 -/* 0D13C8 800D07C8 00000000 */ nop -/* 0D13CC 800D07CC 10000024 */ b .L800D0860 -/* 0D13D0 800D07D0 24020003 */ li $v0, 3 -.L800D07D4: -/* 0D13D4 800D07D4 8FA90148 */ lw $t1, 0x148($sp) -/* 0D13D8 800D07D8 8FAD0158 */ lw $t5, 0x158($sp) -/* 0D13DC 800D07DC 00095200 */ sll $t2, $t1, 8 -/* 0D13E0 800D07E0 ADAA0000 */ sw $t2, ($t5) -/* 0D13E4 800D07E4 8FAE0158 */ lw $t6, 0x158($sp) -/* 0D13E8 800D07E8 97AF002C */ lhu $t7, 0x2c($sp) -/* 0D13EC 800D07EC A5CF0008 */ sh $t7, 8($t6) -/* 0D13F0 800D07F0 8FB80158 */ lw $t8, 0x158($sp) -/* 0D13F4 800D07F4 8FA80028 */ lw $t0, 0x28($sp) -/* 0D13F8 800D07F8 AF080004 */ sw $t0, 4($t8) -/* 0D13FC 800D07FC AFA00020 */ sw $zero, 0x20($sp) -.L800D0800: -/* 0D1400 800D0800 8FB90020 */ lw $t9, 0x20($sp) -/* 0D1404 800D0804 8FAC0158 */ lw $t4, 0x158($sp) -/* 0D1408 800D0808 03B95821 */ addu $t3, $sp, $t9 -/* 0D140C 800D080C 916B0038 */ lbu $t3, 0x38($t3) -/* 0D1410 800D0810 01994821 */ addu $t1, $t4, $t9 -/* 0D1414 800D0814 A12B000E */ sb $t3, 0xe($t1) -/* 0D1418 800D0818 8FAA0020 */ lw $t2, 0x20($sp) -/* 0D141C 800D081C 254D0001 */ addiu $t5, $t2, 1 -/* 0D1420 800D0820 29A10010 */ slti $at, $t5, 0x10 -/* 0D1424 800D0824 1420FFF6 */ bnez $at, .L800D0800 -/* 0D1428 800D0828 AFAD0020 */ sw $t5, 0x20($sp) -/* 0D142C 800D082C AFA00020 */ sw $zero, 0x20($sp) -.L800D0830: -/* 0D1430 800D0830 8FAF0020 */ lw $t7, 0x20($sp) -/* 0D1434 800D0834 8FA80158 */ lw $t0, 0x158($sp) -/* 0D1438 800D0838 03AF7021 */ addu $t6, $sp, $t7 -/* 0D143C 800D083C 91CE0034 */ lbu $t6, 0x34($t6) -/* 0D1440 800D0840 010FC021 */ addu $t8, $t0, $t7 -/* 0D1444 800D0844 A30E000A */ sb $t6, 0xa($t8) -/* 0D1448 800D0848 8FAC0020 */ lw $t4, 0x20($sp) -/* 0D144C 800D084C 25990001 */ addiu $t9, $t4, 1 -/* 0D1450 800D0850 2B210004 */ slti $at, $t9, 4 -/* 0D1454 800D0854 1420FFF6 */ bnez $at, .L800D0830 -/* 0D1458 800D0858 AFB90020 */ sw $t9, 0x20($sp) -/* 0D145C 800D085C 00001025 */ move $v0, $zero -.L800D0860: -/* 0D1460 800D0860 8FBF0014 */ lw $ra, 0x14($sp) -/* 0D1464 800D0864 27BD0150 */ addiu $sp, $sp, 0x150 -/* 0D1468 800D0868 03E00008 */ jr $ra -/* 0D146C 800D086C 00000000 */ nop - diff --git a/lib/src/os/unknown_0D1180.c b/lib/src/os/unknown_0D1180.c index 14356582..70bdad7e 100644 --- a/lib/src/os/unknown_0D1180.c +++ b/lib/src/os/unknown_0D1180.c @@ -3,8 +3,64 @@ #include "types.h" #include "macros.h" +#include "libultra_internal.h" +#include "controller.h" -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1180/osPfsFileState.s") +s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state) +{ + s32 ret; + int pages; + __OSInode inode; + __OSDir dir; + __OSInodeUnit next_page; + int j; + u8 bank; + u8 start_page; + if (file_no >= pfs->dir_size || file_no < 0) + return PFS_ERR_INVALID; + PFS_CHECK_STATUS; + PFS_CHECK_ID; + SET_ACTIVEBANK_TO_ZERO; + + ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir)); + if (dir.company_code == 0 || dir.game_code == 0) + return PFS_ERR_INVALID; + if (dir.start_page.ipage < pfs->inode_start_page) + return PFS_ERR_INCONSISTENT; + pages = 0; + start_page = dir.start_page.inode_t.page; + bank = dir.start_page.inode_t.bank; + while (bank < pfs->banks) + { + ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); + next_page = inode.inode_page[start_page]; + pages++; + while (next_page.ipage >= pfs->inode_start_page) + { + pages++; + next_page = inode.inode_page[next_page.inode_t.page]; + if (next_page.inode_t.bank != bank) + { + bank = next_page.inode_t.bank; + start_page = next_page.inode_t.page; + break; + } + } + if (next_page.ipage == 1) + break; + } + if (next_page.ipage != 1) + return PFS_ERR_INCONSISTENT; + + state->file_size = pages << PFS_ONE_PAGE; + state->company_code = dir.company_code; + state->game_code = dir.game_code; + for (j = 0; j < ARRLEN(state->game_name); j++) + state->game_name[j] = dir.game_name[j]; + for (j = 0; j < ARRLEN(state->ext_name); j++) + state->ext_name[j] = dir.ext_name[j]; + return 0; +} GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1180/osPfsDeleteFile.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1180/__osPfsReleasePages.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1180/__osBlockSum.s") From 8eabd39ad60d7908057c812de625aeab6030b4ce Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 07:59:35 -0400 Subject: [PATCH 07/41] Match osPfsDeleteFile from libreultra --- .../unknown_0D1180/__osBlockSum.s | 69 ------ .../unknown_0D1180/__osPfsReleasePages.s | 157 -------------- .../unknown_0D1180/osPfsDeleteFile.s | 203 ------------------ lib/src/os/osPfsDeleteFile.c | 134 ++++++++++++ .../os/{unknown_0D1180.c => osPfsFileState.c} | 3 - 5 files changed, 134 insertions(+), 432 deletions(-) delete mode 100644 lib/asm/non_matchings/unknown_0D1180/__osBlockSum.s delete mode 100644 lib/asm/non_matchings/unknown_0D1180/__osPfsReleasePages.s delete mode 100644 lib/asm/non_matchings/unknown_0D1180/osPfsDeleteFile.s create mode 100644 lib/src/os/osPfsDeleteFile.c rename lib/src/os/{unknown_0D1180.c => osPfsFileState.c} (90%) diff --git a/lib/asm/non_matchings/unknown_0D1180/__osBlockSum.s b/lib/asm/non_matchings/unknown_0D1180/__osBlockSum.s deleted file mode 100644 index 8de87cc4..00000000 --- a/lib/asm/non_matchings/unknown_0D1180/__osBlockSum.s +++ /dev/null @@ -1,69 +0,0 @@ -glabel __osBlockSum -/* 0D1988 800D0D88 27BDFFC0 */ addiu $sp, $sp, -0x40 -/* 0D198C 800D0D8C AFA40040 */ sw $a0, 0x40($sp) -/* 0D1990 800D0D90 AFA7004C */ sw $a3, 0x4c($sp) -/* 0D1994 800D0D94 93AE004F */ lbu $t6, 0x4f($sp) -/* 0D1998 800D0D98 8FAF0040 */ lw $t7, 0x40($sp) -/* 0D199C 800D0D9C AFBF0014 */ sw $ra, 0x14($sp) -/* 0D19A0 800D0DA0 AFA50044 */ sw $a1, 0x44($sp) -/* 0D19A4 800D0DA4 AFA60048 */ sw $a2, 0x48($sp) -/* 0D19A8 800D0DA8 AFA00038 */ sw $zero, 0x38($sp) -/* 0D19AC 800D0DAC A1EE0065 */ sb $t6, 0x65($t7) -/* 0D19B0 800D0DB0 0C0357F7 */ jal __osPfsSelectBank -/* 0D19B4 800D0DB4 8FA40040 */ lw $a0, 0x40($sp) -/* 0D19B8 800D0DB8 AFA20038 */ sw $v0, 0x38($sp) -/* 0D19BC 800D0DBC 8FB80038 */ lw $t8, 0x38($sp) -/* 0D19C0 800D0DC0 13000003 */ beqz $t8, .L800D0DD0 -/* 0D19C4 800D0DC4 00000000 */ nop -/* 0D19C8 800D0DC8 10000027 */ b .L800D0E68 -/* 0D19CC 800D0DCC 03001025 */ move $v0, $t8 -.L800D0DD0: -/* 0D19D0 800D0DD0 AFA0003C */ sw $zero, 0x3c($sp) -.L800D0DD4: -/* 0D19D4 800D0DD4 93A80047 */ lbu $t0, 0x47($sp) -/* 0D19D8 800D0DD8 8FB90040 */ lw $t9, 0x40($sp) -/* 0D19DC 800D0DDC 8FAA003C */ lw $t2, 0x3c($sp) -/* 0D19E0 800D0DE0 000848C0 */ sll $t1, $t0, 3 -/* 0D19E4 800D0DE4 27A70018 */ addiu $a3, $sp, 0x18 -/* 0D19E8 800D0DE8 8F240004 */ lw $a0, 4($t9) -/* 0D19EC 800D0DEC 8F250008 */ lw $a1, 8($t9) -/* 0D19F0 800D0DF0 0C033728 */ jal __osContRamRead -/* 0D19F4 800D0DF4 012A3021 */ addu $a2, $t1, $t2 -/* 0D19F8 800D0DF8 AFA20038 */ sw $v0, 0x38($sp) -/* 0D19FC 800D0DFC 8FAB0038 */ lw $t3, 0x38($sp) -/* 0D1A00 800D0E00 11600007 */ beqz $t3, .L800D0E20 -/* 0D1A04 800D0E04 00000000 */ nop -/* 0D1A08 800D0E08 8FAC0040 */ lw $t4, 0x40($sp) -/* 0D1A0C 800D0E0C A1800065 */ sb $zero, 0x65($t4) -/* 0D1A10 800D0E10 0C0357F7 */ jal __osPfsSelectBank -/* 0D1A14 800D0E14 8FA40040 */ lw $a0, 0x40($sp) -/* 0D1A18 800D0E18 10000013 */ b .L800D0E68 -/* 0D1A1C 800D0E1C 8FA20038 */ lw $v0, 0x38($sp) -.L800D0E20: -/* 0D1A20 800D0E20 27A40018 */ addiu $a0, $sp, 0x18 -/* 0D1A24 800D0E24 0C0354BC */ jal __osSumcalc -/* 0D1A28 800D0E28 24050020 */ li $a1, 32 -/* 0D1A2C 800D0E2C 8FAD0048 */ lw $t5, 0x48($sp) -/* 0D1A30 800D0E30 95AE0000 */ lhu $t6, ($t5) -/* 0D1A34 800D0E34 004E7821 */ addu $t7, $v0, $t6 -/* 0D1A38 800D0E38 A5AF0000 */ sh $t7, ($t5) -/* 0D1A3C 800D0E3C 8FB8003C */ lw $t8, 0x3c($sp) -/* 0D1A40 800D0E40 27190001 */ addiu $t9, $t8, 1 -/* 0D1A44 800D0E44 2B210008 */ slti $at, $t9, 8 -/* 0D1A48 800D0E48 1420FFE2 */ bnez $at, .L800D0DD4 -/* 0D1A4C 800D0E4C AFB9003C */ sw $t9, 0x3c($sp) -/* 0D1A50 800D0E50 8FA80040 */ lw $t0, 0x40($sp) -/* 0D1A54 800D0E54 A1000065 */ sb $zero, 0x65($t0) -/* 0D1A58 800D0E58 0C0357F7 */ jal __osPfsSelectBank -/* 0D1A5C 800D0E5C 8FA40040 */ lw $a0, 0x40($sp) -/* 0D1A60 800D0E60 AFA20038 */ sw $v0, 0x38($sp) -/* 0D1A64 800D0E64 8FA20038 */ lw $v0, 0x38($sp) -.L800D0E68: -/* 0D1A68 800D0E68 8FBF0014 */ lw $ra, 0x14($sp) -/* 0D1A6C 800D0E6C 27BD0040 */ addiu $sp, $sp, 0x40 -/* 0D1A70 800D0E70 03E00008 */ jr $ra -/* 0D1A74 800D0E74 00000000 */ nop - -/* 0D1A78 800D0E78 00000000 */ nop -/* 0D1A7C 800D0E7C 00000000 */ nop - diff --git a/lib/asm/non_matchings/unknown_0D1180/__osPfsReleasePages.s b/lib/asm/non_matchings/unknown_0D1180/__osPfsReleasePages.s deleted file mode 100644 index 3dd1ffbc..00000000 --- a/lib/asm/non_matchings/unknown_0D1180/__osPfsReleasePages.s +++ /dev/null @@ -1,157 +0,0 @@ -glabel __osPfsReleasePages -/* 0D1750 800D0B50 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0D1754 800D0B54 AFA60030 */ sw $a2, 0x30($sp) -/* 0D1758 800D0B58 93B80033 */ lbu $t8, 0x33($sp) -/* 0D175C 800D0B5C AFA5002C */ sw $a1, 0x2c($sp) -/* 0D1760 800D0B60 8FAF002C */ lw $t7, 0x2c($sp) -/* 0D1764 800D0B64 0018C840 */ sll $t9, $t8, 1 -/* 0D1768 800D0B68 AFBF0014 */ sw $ra, 0x14($sp) -/* 0D176C 800D0B6C AFA40028 */ sw $a0, 0x28($sp) -/* 0D1770 800D0B70 AFA70034 */ sw $a3, 0x34($sp) -/* 0D1774 800D0B74 AFA0001C */ sw $zero, 0x1c($sp) -/* 0D1778 800D0B78 01F94021 */ addu $t0, $t7, $t9 -/* 0D177C 800D0B7C 95010000 */ lhu $at, ($t0) -/* 0D1780 800D0B80 27AE0024 */ addiu $t6, $sp, 0x24 -/* 0D1784 800D0B84 A5C10000 */ sh $at, ($t6) -/* 0D1788 800D0B88 97AC0024 */ lhu $t4, 0x24($sp) -/* 0D178C 800D0B8C 24010001 */ li $at, 1 -/* 0D1790 800D0B90 1181000B */ beq $t4, $at, .L800D0BC0 -/* 0D1794 800D0B94 00000000 */ nop -/* 0D1798 800D0B98 93AD0024 */ lbu $t5, 0x24($sp) -/* 0D179C 800D0B9C 19A00004 */ blez $t5, .L800D0BB0 -/* 0D17A0 800D0BA0 00000000 */ nop -/* 0D17A4 800D0BA4 24180001 */ li $t8, 1 -/* 0D17A8 800D0BA8 1000000E */ b .L800D0BE4 -/* 0D17AC 800D0BAC AFB80018 */ sw $t8, 0x18($sp) -.L800D0BB0: -/* 0D17B0 800D0BB0 8FAF0028 */ lw $t7, 0x28($sp) -/* 0D17B4 800D0BB4 8DF90060 */ lw $t9, 0x60($t7) -/* 0D17B8 800D0BB8 1000000A */ b .L800D0BE4 -/* 0D17BC 800D0BBC AFB90018 */ sw $t9, 0x18($sp) -.L800D0BC0: -/* 0D17C0 800D0BC0 93AA003B */ lbu $t2, 0x3b($sp) -/* 0D17C4 800D0BC4 19400004 */ blez $t2, .L800D0BD8 -/* 0D17C8 800D0BC8 00000000 */ nop -/* 0D17CC 800D0BCC 24090001 */ li $t1, 1 -/* 0D17D0 800D0BD0 10000004 */ b .L800D0BE4 -/* 0D17D4 800D0BD4 AFA90018 */ sw $t1, 0x18($sp) -.L800D0BD8: -/* 0D17D8 800D0BD8 8FAE0028 */ lw $t6, 0x28($sp) -/* 0D17DC 800D0BDC 8DC80060 */ lw $t0, 0x60($t6) -/* 0D17E0 800D0BE0 AFA80018 */ sw $t0, 0x18($sp) -.L800D0BE4: -/* 0D17E4 800D0BE4 93AB0025 */ lbu $t3, 0x25($sp) -/* 0D17E8 800D0BE8 8FAC0018 */ lw $t4, 0x18($sp) -/* 0D17EC 800D0BEC 016C082A */ slt $at, $t3, $t4 -/* 0D17F0 800D0BF0 10200007 */ beqz $at, .L800D0C10 -/* 0D17F4 800D0BF4 00000000 */ nop -/* 0D17F8 800D0BF8 97AD0024 */ lhu $t5, 0x24($sp) -/* 0D17FC 800D0BFC 24010001 */ li $at, 1 -/* 0D1800 800D0C00 11A10003 */ beq $t5, $at, .L800D0C10 -/* 0D1804 800D0C04 00000000 */ nop -/* 0D1808 800D0C08 1000005B */ b .L800D0D78 -/* 0D180C 800D0C0C 24020003 */ li $v0, 3 -.L800D0C10: -/* 0D1810 800D0C10 27AF0024 */ addiu $t7, $sp, 0x24 -/* 0D1814 800D0C14 95E10000 */ lhu $at, ($t7) -/* 0D1818 800D0C18 8FB8003C */ lw $t8, 0x3c($sp) -/* 0D181C 800D0C1C A7010000 */ sh $at, ($t8) -/* 0D1820 800D0C20 8FA90040 */ lw $t1, 0x40($sp) -/* 0D1824 800D0C24 24010001 */ li $at, 1 -/* 0D1828 800D0C28 15210007 */ bne $t1, $at, .L800D0C48 -/* 0D182C 800D0C2C 00000000 */ nop -/* 0D1830 800D0C30 93AB0033 */ lbu $t3, 0x33($sp) -/* 0D1834 800D0C34 8FA8002C */ lw $t0, 0x2c($sp) -/* 0D1838 800D0C38 240E0003 */ li $t6, 3 -/* 0D183C 800D0C3C 000B6040 */ sll $t4, $t3, 1 -/* 0D1840 800D0C40 010C6821 */ addu $t5, $t0, $t4 -/* 0D1844 800D0C44 A5AE0000 */ sh $t6, ($t5) -.L800D0C48: -/* 0D1848 800D0C48 8FA40028 */ lw $a0, 0x28($sp) -/* 0D184C 800D0C4C 93A50033 */ lbu $a1, 0x33($sp) -/* 0D1850 800D0C50 8FA60034 */ lw $a2, 0x34($sp) -/* 0D1854 800D0C54 0C034362 */ jal __osBlockSum -/* 0D1858 800D0C58 93A7003B */ lbu $a3, 0x3b($sp) -/* 0D185C 800D0C5C AFA2001C */ sw $v0, 0x1c($sp) -/* 0D1860 800D0C60 8FB9001C */ lw $t9, 0x1c($sp) -/* 0D1864 800D0C64 13200003 */ beqz $t9, .L800D0C74 -/* 0D1868 800D0C68 00000000 */ nop -/* 0D186C 800D0C6C 10000042 */ b .L800D0D78 -/* 0D1870 800D0C70 03201025 */ move $v0, $t9 -.L800D0C74: -/* 0D1874 800D0C74 97B80024 */ lhu $t8, 0x24($sp) -/* 0D1878 800D0C78 24010001 */ li $at, 1 -/* 0D187C 800D0C7C 17010003 */ bne $t8, $at, .L800D0C8C -/* 0D1880 800D0C80 00000000 */ nop -/* 0D1884 800D0C84 1000003C */ b .L800D0D78 -/* 0D1888 800D0C88 00001025 */ move $v0, $zero -.L800D0C8C: -/* 0D188C 800D0C8C 8FAA0028 */ lw $t2, 0x28($sp) -/* 0D1890 800D0C90 97AF0024 */ lhu $t7, 0x24($sp) -/* 0D1894 800D0C94 8D490060 */ lw $t1, 0x60($t2) -/* 0D1898 800D0C98 01E9082A */ slt $at, $t7, $t1 -/* 0D189C 800D0C9C 14200025 */ bnez $at, .L800D0D34 -/* 0D18A0 800D0CA0 00000000 */ nop -.L800D0CA4: -/* 0D18A4 800D0CA4 93AE0025 */ lbu $t6, 0x25($sp) -/* 0D18A8 800D0CA8 97AB0024 */ lhu $t3, 0x24($sp) -/* 0D18AC 800D0CAC 8FAC002C */ lw $t4, 0x2c($sp) -/* 0D18B0 800D0CB0 000E6840 */ sll $t5, $t6, 1 -/* 0D18B4 800D0CB4 A7AB0020 */ sh $t3, 0x20($sp) -/* 0D18B8 800D0CB8 018DC821 */ addu $t9, $t4, $t5 -/* 0D18BC 800D0CBC 97210000 */ lhu $at, ($t9) -/* 0D18C0 800D0CC0 27A80024 */ addiu $t0, $sp, 0x24 -/* 0D18C4 800D0CC4 240F0003 */ li $t7, 3 -/* 0D18C8 800D0CC8 A5010000 */ sh $at, ($t0) -/* 0D18CC 800D0CCC 93AB0021 */ lbu $t3, 0x21($sp) -/* 0D18D0 800D0CD0 8FA9002C */ lw $t1, 0x2c($sp) -/* 0D18D4 800D0CD4 000B7040 */ sll $t6, $t3, 1 -/* 0D18D8 800D0CD8 012E6021 */ addu $t4, $t1, $t6 -/* 0D18DC 800D0CDC A58F0000 */ sh $t7, ($t4) -/* 0D18E0 800D0CE0 93A7003B */ lbu $a3, 0x3b($sp) -/* 0D18E4 800D0CE4 8FA60034 */ lw $a2, 0x34($sp) -/* 0D18E8 800D0CE8 93A50021 */ lbu $a1, 0x21($sp) -/* 0D18EC 800D0CEC 0C034362 */ jal __osBlockSum -/* 0D18F0 800D0CF0 8FA40028 */ lw $a0, 0x28($sp) -/* 0D18F4 800D0CF4 AFA2001C */ sw $v0, 0x1c($sp) -/* 0D18F8 800D0CF8 8FAD001C */ lw $t5, 0x1c($sp) -/* 0D18FC 800D0CFC 11A00003 */ beqz $t5, .L800D0D0C -/* 0D1900 800D0D00 00000000 */ nop -/* 0D1904 800D0D04 1000001C */ b .L800D0D78 -/* 0D1908 800D0D08 01A01025 */ move $v0, $t5 -.L800D0D0C: -/* 0D190C 800D0D0C 93B80024 */ lbu $t8, 0x24($sp) -/* 0D1910 800D0D10 93A8003B */ lbu $t0, 0x3b($sp) -/* 0D1914 800D0D14 17080007 */ bne $t8, $t0, .L800D0D34 -/* 0D1918 800D0D18 00000000 */ nop -/* 0D191C 800D0D1C 8FAA0028 */ lw $t2, 0x28($sp) -/* 0D1920 800D0D20 97B90024 */ lhu $t9, 0x24($sp) -/* 0D1924 800D0D24 8D4B0060 */ lw $t3, 0x60($t2) -/* 0D1928 800D0D28 032B082A */ slt $at, $t9, $t3 -/* 0D192C 800D0D2C 1020FFDD */ beqz $at, .L800D0CA4 -/* 0D1930 800D0D30 00000000 */ nop -.L800D0D34: -/* 0D1934 800D0D34 8FAE0028 */ lw $t6, 0x28($sp) -/* 0D1938 800D0D38 97A90024 */ lhu $t1, 0x24($sp) -/* 0D193C 800D0D3C 8DCF0060 */ lw $t7, 0x60($t6) -/* 0D1940 800D0D40 012F082A */ slt $at, $t1, $t7 -/* 0D1944 800D0D44 14200007 */ bnez $at, .L800D0D64 -/* 0D1948 800D0D48 00000000 */ nop -/* 0D194C 800D0D4C 93B80025 */ lbu $t8, 0x25($sp) -/* 0D1950 800D0D50 8FAD002C */ lw $t5, 0x2c($sp) -/* 0D1954 800D0D54 240C0003 */ li $t4, 3 -/* 0D1958 800D0D58 00184040 */ sll $t0, $t8, 1 -/* 0D195C 800D0D5C 01A85021 */ addu $t2, $t5, $t0 -/* 0D1960 800D0D60 A54C0000 */ sh $t4, ($t2) -.L800D0D64: -/* 0D1964 800D0D64 27AB0024 */ addiu $t3, $sp, 0x24 -/* 0D1968 800D0D68 95610000 */ lhu $at, ($t3) -/* 0D196C 800D0D6C 8FB9003C */ lw $t9, 0x3c($sp) -/* 0D1970 800D0D70 00001025 */ move $v0, $zero -/* 0D1974 800D0D74 A7210000 */ sh $at, ($t9) -.L800D0D78: -/* 0D1978 800D0D78 8FBF0014 */ lw $ra, 0x14($sp) -/* 0D197C 800D0D7C 27BD0028 */ addiu $sp, $sp, 0x28 -/* 0D1980 800D0D80 03E00008 */ jr $ra -/* 0D1984 800D0D84 00000000 */ nop - diff --git a/lib/asm/non_matchings/unknown_0D1180/osPfsDeleteFile.s b/lib/asm/non_matchings/unknown_0D1180/osPfsDeleteFile.s deleted file mode 100644 index 1358dc2b..00000000 --- a/lib/asm/non_matchings/unknown_0D1180/osPfsDeleteFile.s +++ /dev/null @@ -1,203 +0,0 @@ -glabel osPfsDeleteFile -/* 0D1470 800D0870 27BDFEA0 */ addiu $sp, $sp, -0x160 -/* 0D1474 800D0874 AFA50164 */ sw $a1, 0x164($sp) -/* 0D1478 800D0878 97AE0166 */ lhu $t6, 0x166($sp) -/* 0D147C 800D087C AFBF0024 */ sw $ra, 0x24($sp) -/* 0D1480 800D0880 AFA40160 */ sw $a0, 0x160($sp) -/* 0D1484 800D0884 AFA60168 */ sw $a2, 0x168($sp) -/* 0D1488 800D0888 AFA7016C */ sw $a3, 0x16c($sp) -/* 0D148C 800D088C 11C00004 */ beqz $t6, .L800D08A0 -/* 0D1490 800D0890 A7A00032 */ sh $zero, 0x32($sp) -/* 0D1494 800D0894 8FAF0168 */ lw $t7, 0x168($sp) -/* 0D1498 800D0898 15E00003 */ bnez $t7, .L800D08A8 -/* 0D149C 800D089C 00000000 */ nop -.L800D08A0: -/* 0D14A0 800D08A0 100000A7 */ b .L800D0B40 -/* 0D14A4 800D08A4 24020005 */ li $v0, 5 -.L800D08A8: -/* 0D14A8 800D08A8 8FB80160 */ lw $t8, 0x160($sp) -/* 0D14AC 800D08AC 8F190000 */ lw $t9, ($t8) -/* 0D14B0 800D08B0 33280001 */ andi $t0, $t9, 1 -/* 0D14B4 800D08B4 15000003 */ bnez $t0, .L800D08C4 -/* 0D14B8 800D08B8 00000000 */ nop -/* 0D14BC 800D08BC 100000A0 */ b .L800D0B40 -/* 0D14C0 800D08C0 24020005 */ li $v0, 5 -.L800D08C4: -/* 0D14C4 800D08C4 0C0356F0 */ jal __osCheckId -/* 0D14C8 800D08C8 8FA40160 */ lw $a0, 0x160($sp) -/* 0D14CC 800D08CC 24010002 */ li $at, 2 -/* 0D14D0 800D08D0 14410003 */ bne $v0, $at, .L800D08E0 -/* 0D14D4 800D08D4 00000000 */ nop -/* 0D14D8 800D08D8 10000099 */ b .L800D0B40 -/* 0D14DC 800D08DC 24020002 */ li $v0, 2 -.L800D08E0: -/* 0D14E0 800D08E0 8FA90160 */ lw $t1, 0x160($sp) -/* 0D14E4 800D08E4 912A0065 */ lbu $t2, 0x65($t1) -/* 0D14E8 800D08E8 1140000A */ beqz $t2, .L800D0914 -/* 0D14EC 800D08EC 00000000 */ nop -/* 0D14F0 800D08F0 A1200065 */ sb $zero, 0x65($t1) -/* 0D14F4 800D08F4 0C0357F7 */ jal __osPfsSelectBank -/* 0D14F8 800D08F8 8FA40160 */ lw $a0, 0x160($sp) -/* 0D14FC 800D08FC AFA20154 */ sw $v0, 0x154($sp) -/* 0D1500 800D0900 8FAB0154 */ lw $t3, 0x154($sp) -/* 0D1504 800D0904 11600003 */ beqz $t3, .L800D0914 -/* 0D1508 800D0908 00000000 */ nop -/* 0D150C 800D090C 1000008C */ b .L800D0B40 -/* 0D1510 800D0910 01601025 */ move $v0, $t3 -.L800D0914: -/* 0D1514 800D0914 8FAC0170 */ lw $t4, 0x170($sp) -/* 0D1518 800D0918 27AD015C */ addiu $t5, $sp, 0x15c -/* 0D151C 800D091C AFAD0014 */ sw $t5, 0x14($sp) -/* 0D1520 800D0920 8FA40160 */ lw $a0, 0x160($sp) -/* 0D1524 800D0924 97A50166 */ lhu $a1, 0x166($sp) -/* 0D1528 800D0928 8FA60168 */ lw $a2, 0x168($sp) -/* 0D152C 800D092C 8FA7016C */ lw $a3, 0x16c($sp) -/* 0D1530 800D0930 0C0343A0 */ jal osPfsFindFile -/* 0D1534 800D0934 AFAC0010 */ sw $t4, 0x10($sp) -/* 0D1538 800D0938 AFA20154 */ sw $v0, 0x154($sp) -/* 0D153C 800D093C 8FAE0154 */ lw $t6, 0x154($sp) -/* 0D1540 800D0940 11C00003 */ beqz $t6, .L800D0950 -/* 0D1544 800D0944 00000000 */ nop -/* 0D1548 800D0948 1000007D */ b .L800D0B40 -/* 0D154C 800D094C 01C01025 */ move $v0, $t6 -.L800D0950: -/* 0D1550 800D0950 8FAF015C */ lw $t7, 0x15c($sp) -/* 0D1554 800D0954 2401FFFF */ li $at, -1 -/* 0D1558 800D0958 15E10003 */ bne $t7, $at, .L800D0968 -/* 0D155C 800D095C 00000000 */ nop -/* 0D1560 800D0960 10000077 */ b .L800D0B40 -/* 0D1564 800D0964 24020005 */ li $v0, 5 -.L800D0968: -/* 0D1568 800D0968 8FB80160 */ lw $t8, 0x160($sp) -/* 0D156C 800D096C 8FA8015C */ lw $t0, 0x15c($sp) -/* 0D1570 800D0970 27A70034 */ addiu $a3, $sp, 0x34 -/* 0D1574 800D0974 8F19005C */ lw $t9, 0x5c($t8) -/* 0D1578 800D0978 8F040004 */ lw $a0, 4($t8) -/* 0D157C 800D097C 8F050008 */ lw $a1, 8($t8) -/* 0D1580 800D0980 0C033728 */ jal __osContRamRead -/* 0D1584 800D0984 03283021 */ addu $a2, $t9, $t0 -/* 0D1588 800D0988 AFA20154 */ sw $v0, 0x154($sp) -/* 0D158C 800D098C 8FAA0154 */ lw $t2, 0x154($sp) -/* 0D1590 800D0990 11400003 */ beqz $t2, .L800D09A0 -/* 0D1594 800D0994 00000000 */ nop -/* 0D1598 800D0998 10000069 */ b .L800D0B40 -/* 0D159C 800D099C 01401025 */ move $v0, $t2 -.L800D09A0: -/* 0D15A0 800D09A0 93A9003B */ lbu $t1, 0x3b($sp) -/* 0D15A4 800D09A4 93AB003A */ lbu $t3, 0x3a($sp) -/* 0D15A8 800D09A8 8FAC0160 */ lw $t4, 0x160($sp) -/* 0D15AC 800D09AC A3A9002F */ sb $t1, 0x2f($sp) -/* 0D15B0 800D09B0 A3AB002E */ sb $t3, 0x2e($sp) -/* 0D15B4 800D09B4 918D0064 */ lbu $t5, 0x64($t4) -/* 0D15B8 800D09B8 016D082A */ slt $at, $t3, $t5 -/* 0D15BC 800D09BC 10200036 */ beqz $at, .L800D0A98 -/* 0D15C0 800D09C0 00000000 */ nop -.L800D09C4: -/* 0D15C4 800D09C4 8FA40160 */ lw $a0, 0x160($sp) -/* 0D15C8 800D09C8 27A50054 */ addiu $a1, $sp, 0x54 -/* 0D15CC 800D09CC 00003025 */ move $a2, $zero -/* 0D15D0 800D09D0 0C03572F */ jal __osPfsRWInode -/* 0D15D4 800D09D4 93A7002E */ lbu $a3, 0x2e($sp) -/* 0D15D8 800D09D8 AFA20154 */ sw $v0, 0x154($sp) -/* 0D15DC 800D09DC 8FAE0154 */ lw $t6, 0x154($sp) -/* 0D15E0 800D09E0 11C00003 */ beqz $t6, .L800D09F0 -/* 0D15E4 800D09E4 00000000 */ nop -/* 0D15E8 800D09E8 10000055 */ b .L800D0B40 -/* 0D15EC 800D09EC 01C01025 */ move $v0, $t6 -.L800D09F0: -/* 0D15F0 800D09F0 93AF002E */ lbu $t7, 0x2e($sp) -/* 0D15F4 800D09F4 27B80030 */ addiu $t8, $sp, 0x30 -/* 0D15F8 800D09F8 24190001 */ li $t9, 1 -/* 0D15FC 800D09FC AFB90018 */ sw $t9, 0x18($sp) -/* 0D1600 800D0A00 AFB80014 */ sw $t8, 0x14($sp) -/* 0D1604 800D0A04 8FA40160 */ lw $a0, 0x160($sp) -/* 0D1608 800D0A08 27A50054 */ addiu $a1, $sp, 0x54 -/* 0D160C 800D0A0C 93A6002F */ lbu $a2, 0x2f($sp) -/* 0D1610 800D0A10 27A70032 */ addiu $a3, $sp, 0x32 -/* 0D1614 800D0A14 0C0342D4 */ jal __osPfsReleasePages -/* 0D1618 800D0A18 AFAF0010 */ sw $t7, 0x10($sp) -/* 0D161C 800D0A1C AFA20154 */ sw $v0, 0x154($sp) -/* 0D1620 800D0A20 8FA80154 */ lw $t0, 0x154($sp) -/* 0D1624 800D0A24 11000003 */ beqz $t0, .L800D0A34 -/* 0D1628 800D0A28 00000000 */ nop -/* 0D162C 800D0A2C 10000044 */ b .L800D0B40 -/* 0D1630 800D0A30 01001025 */ move $v0, $t0 -.L800D0A34: -/* 0D1634 800D0A34 8FA40160 */ lw $a0, 0x160($sp) -/* 0D1638 800D0A38 27A50054 */ addiu $a1, $sp, 0x54 -/* 0D163C 800D0A3C 24060001 */ li $a2, 1 -/* 0D1640 800D0A40 0C03572F */ jal __osPfsRWInode -/* 0D1644 800D0A44 93A7002E */ lbu $a3, 0x2e($sp) -/* 0D1648 800D0A48 AFA20154 */ sw $v0, 0x154($sp) -/* 0D164C 800D0A4C 8FAA0154 */ lw $t2, 0x154($sp) -/* 0D1650 800D0A50 11400003 */ beqz $t2, .L800D0A60 -/* 0D1654 800D0A54 00000000 */ nop -/* 0D1658 800D0A58 10000039 */ b .L800D0B40 -/* 0D165C 800D0A5C 01401025 */ move $v0, $t2 -.L800D0A60: -/* 0D1660 800D0A60 97A90030 */ lhu $t1, 0x30($sp) -/* 0D1664 800D0A64 24010001 */ li $at, 1 -/* 0D1668 800D0A68 1121000B */ beq $t1, $at, .L800D0A98 -/* 0D166C 800D0A6C 00000000 */ nop -/* 0D1670 800D0A70 93AC0030 */ lbu $t4, 0x30($sp) -/* 0D1674 800D0A74 93AB0031 */ lbu $t3, 0x31($sp) -/* 0D1678 800D0A78 8FAE0160 */ lw $t6, 0x160($sp) -/* 0D167C 800D0A7C A3AC002E */ sb $t4, 0x2e($sp) -/* 0D1680 800D0A80 A3AB002F */ sb $t3, 0x2f($sp) -/* 0D1684 800D0A84 93AD002E */ lbu $t5, 0x2e($sp) -/* 0D1688 800D0A88 91CF0064 */ lbu $t7, 0x64($t6) -/* 0D168C 800D0A8C 01AF082A */ slt $at, $t5, $t7 -/* 0D1690 800D0A90 1420FFCC */ bnez $at, .L800D09C4 -/* 0D1694 800D0A94 00000000 */ nop -.L800D0A98: -/* 0D1698 800D0A98 8FB90160 */ lw $t9, 0x160($sp) -/* 0D169C 800D0A9C 93B8002E */ lbu $t8, 0x2e($sp) -/* 0D16A0 800D0AA0 93280064 */ lbu $t0, 0x64($t9) -/* 0D16A4 800D0AA4 0308082A */ slt $at, $t8, $t0 -/* 0D16A8 800D0AA8 14200003 */ bnez $at, .L800D0AB8 -/* 0D16AC 800D0AAC 00000000 */ nop -/* 0D16B0 800D0AB0 10000023 */ b .L800D0B40 -/* 0D16B4 800D0AB4 24020003 */ li $v0, 3 -.L800D0AB8: -/* 0D16B8 800D0AB8 AFA00034 */ sw $zero, 0x34($sp) -/* 0D16BC 800D0ABC A7A00038 */ sh $zero, 0x38($sp) -/* 0D16C0 800D0AC0 A7A0003A */ sh $zero, 0x3a($sp) -/* 0D16C4 800D0AC4 A7A0003E */ sh $zero, 0x3e($sp) -/* 0D16C8 800D0AC8 AFA00158 */ sw $zero, 0x158($sp) -.L800D0ACC: -/* 0D16CC 800D0ACC 8FAA0158 */ lw $t2, 0x158($sp) -/* 0D16D0 800D0AD0 03AA4821 */ addu $t1, $sp, $t2 -/* 0D16D4 800D0AD4 A1200044 */ sb $zero, 0x44($t1) -/* 0D16D8 800D0AD8 8FAC0158 */ lw $t4, 0x158($sp) -/* 0D16DC 800D0ADC 258B0001 */ addiu $t3, $t4, 1 -/* 0D16E0 800D0AE0 29610010 */ slti $at, $t3, 0x10 -/* 0D16E4 800D0AE4 1420FFF9 */ bnez $at, .L800D0ACC -/* 0D16E8 800D0AE8 AFAB0158 */ sw $t3, 0x158($sp) -/* 0D16EC 800D0AEC AFA00158 */ sw $zero, 0x158($sp) -.L800D0AF0: -/* 0D16F0 800D0AF0 8FAE0158 */ lw $t6, 0x158($sp) -/* 0D16F4 800D0AF4 03AE6821 */ addu $t5, $sp, $t6 -/* 0D16F8 800D0AF8 A1A00040 */ sb $zero, 0x40($t5) -/* 0D16FC 800D0AFC 8FAF0158 */ lw $t7, 0x158($sp) -/* 0D1700 800D0B00 25F90001 */ addiu $t9, $t7, 1 -/* 0D1704 800D0B04 2B210004 */ slti $at, $t9, 4 -/* 0D1708 800D0B08 1420FFF9 */ bnez $at, .L800D0AF0 -/* 0D170C 800D0B0C AFB90158 */ sw $t9, 0x158($sp) -/* 0D1710 800D0B10 8FB80160 */ lw $t8, 0x160($sp) -/* 0D1714 800D0B14 A3A0003C */ sb $zero, 0x3c($sp) -/* 0D1718 800D0B18 8FAA015C */ lw $t2, 0x15c($sp) -/* 0D171C 800D0B1C 8F08005C */ lw $t0, 0x5c($t8) -/* 0D1720 800D0B20 8F050008 */ lw $a1, 8($t8) -/* 0D1724 800D0B24 8F040004 */ lw $a0, 4($t8) -/* 0D1728 800D0B28 AFA00010 */ sw $zero, 0x10($sp) -/* 0D172C 800D0B2C 27A70034 */ addiu $a3, $sp, 0x34 -/* 0D1730 800D0B30 0C03363C */ jal __osContRamWrite -/* 0D1734 800D0B34 010A3021 */ addu $a2, $t0, $t2 -/* 0D1738 800D0B38 AFA20154 */ sw $v0, 0x154($sp) -/* 0D173C 800D0B3C 8FA20154 */ lw $v0, 0x154($sp) -.L800D0B40: -/* 0D1740 800D0B40 8FBF0024 */ lw $ra, 0x24($sp) -/* 0D1744 800D0B44 27BD0160 */ addiu $sp, $sp, 0x160 -/* 0D1748 800D0B48 03E00008 */ jr $ra -/* 0D174C 800D0B4C 00000000 */ nop - diff --git a/lib/src/os/osPfsDeleteFile.c b/lib/src/os/osPfsDeleteFile.c new file mode 100644 index 00000000..49e28cf3 --- /dev/null +++ b/lib/src/os/osPfsDeleteFile.c @@ -0,0 +1,134 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D0870 */ + +#include "libultra_internal.h" +#include "controller.h" + +s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, + u8 *ext_name) +{ + + s32 file_no; + int k; + s32 ret; + __OSInode inode; + __OSDir dir; + u16 sum; + __OSInodeUnit last_page; + u8 startpage; + u8 bank; + sum = 0; + if (company_code == 0 || game_code == 0) + return PFS_ERR_INVALID; + PFS_CHECK_STATUS; + PFS_CHECK_ID; + SET_ACTIVEBANK_TO_ZERO; + ERRCK(osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, &file_no)); + + if (file_no == -1) + return PFS_ERR_INVALID; + ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir)); + + startpage = dir.start_page.inode_t.page; + + for (bank = dir.start_page.inode_t.bank; bank < pfs->banks;) + { + ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); + ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, 1)); //TODO: magic constant + ERRCK(__osPfsRWInode(pfs, &inode, OS_WRITE, bank)); + if (last_page.ipage == 1) + break; + bank = last_page.inode_t.bank; + startpage = last_page.inode_t.page; + } + + if (bank >= pfs->banks) + return PFS_ERR_INCONSISTENT; + + dir.game_code = 0; + dir.company_code = 0; + dir.start_page.ipage = 0; + dir.data_sum = 0; + for (k = 0; k < ARRLEN(dir.game_name); k++) + { + dir.game_name[k] = 0; + } + for (k = 0; k < ARRLEN(dir.ext_name); k++) + { + dir.ext_name[k] = 0; + } + dir.status = DIR_STATUS_EMPTY; + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, FALSE); + + return ret; +} +s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag) +{ + __OSInodeUnit next_page; + __OSInodeUnit old_page; + s32 ret; + int offset; + ret = 0; + next_page = inode->inode_page[start_page]; + if (next_page.ipage != 1) + { + if (next_page.inode_t.bank > 0) + offset = 1; + else + offset = pfs->inode_start_page; + } + else + { + if (bank > 0) + offset = 1; + else + offset = pfs->inode_start_page; + } + if (next_page.inode_t.page < offset && next_page.ipage != 1) + return PFS_ERR_INCONSISTENT; + *last_page = next_page; + if (flag == 1) //TODO: magic number + inode->inode_page[start_page].ipage = PFS_PAGE_NOT_USED; + + ERRCK(__osBlockSum(pfs, start_page, sum, bank)); + if (next_page.ipage == 1) + return 0; + while (next_page.ipage >= pfs->inode_start_page) + { + old_page = next_page; + next_page = inode->inode_page[next_page.inode_t.page]; + inode->inode_page[old_page.inode_t.page].ipage = PFS_PAGE_NOT_USED; + + ERRCK(__osBlockSum(pfs, old_page.inode_t.page, sum, bank)); + if (next_page.inode_t.bank != bank) + break; + } + //Removed the second check from libreultra to match + if (next_page.ipage >= pfs->inode_start_page /* && next_page.inode_t.bank == bank */) + inode->inode_page[next_page.inode_t.page].ipage = PFS_PAGE_NOT_USED; + *last_page = next_page; + return 0; +} +s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank) +{ + int i; + s32 ret; + u8 data[32]; + ret = 0; + pfs->activebank = bank; + ERRCK(__osPfsSelectBank(pfs)); + for (i = 0; i < PFS_ONE_PAGE; i++) + { + ret = __osContRamRead(pfs->queue, pfs->channel, page_no * PFS_ONE_PAGE + i, data); + if (ret != 0) + { + pfs->activebank = 0; + __osPfsSelectBank(pfs); + return ret; + } + *sum = *sum + __osSumcalc(data, sizeof(data)); + } + pfs->activebank = 0; + ret = __osPfsSelectBank(pfs); + return ret; +} diff --git a/lib/src/os/unknown_0D1180.c b/lib/src/os/osPfsFileState.c similarity index 90% rename from lib/src/os/unknown_0D1180.c rename to lib/src/os/osPfsFileState.c index 70bdad7e..7bb32b4a 100644 --- a/lib/src/os/unknown_0D1180.c +++ b/lib/src/os/osPfsFileState.c @@ -61,6 +61,3 @@ s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state) state->ext_name[j] = dir.ext_name[j]; return 0; } -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1180/osPfsDeleteFile.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1180/__osPfsReleasePages.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D1180/__osBlockSum.s") From 2ccd255e79b9d814219d168fb9e9ce36df1914b3 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 08:24:13 -0400 Subject: [PATCH 08/41] Moved some files around into their own place with better names from libreultra --- include/PR/sptask.h | 12 ++++++ lib/src/os/osPfsDeleteFile.c | 2 +- lib/src/os/osPfsFileState.c | 4 +- lib/src/os/osSpTaskYielded.c | 28 +++++++++++++ lib/src/os/osViGetCurrentFramebuffer.c | 15 +++++++ lib/src/os/osViGetNextFramebuffer.c | 15 +++++++ lib/src/os/siacs.c | 2 +- lib/src/os/{unknown_0D29F0.c => sptask.c} | 49 ++--------------------- 8 files changed, 77 insertions(+), 50 deletions(-) create mode 100644 lib/src/os/osSpTaskYielded.c create mode 100644 lib/src/os/osViGetCurrentFramebuffer.c create mode 100644 lib/src/os/osViGetNextFramebuffer.c rename lib/src/os/{unknown_0D29F0.c => sptask.c} (60%) diff --git a/include/PR/sptask.h b/include/PR/sptask.h index 8f23c1b2..63333b40 100644 --- a/include/PR/sptask.h +++ b/include/PR/sptask.h @@ -15,6 +15,18 @@ #endif #define OS_YIELD_AUDIO_SIZE 0x400 +/* + * Task Flags field + */ +#define OS_TASK_YIELDED 0x0001 +#define OS_TASK_DP_WAIT 0x0002 +#define OS_TASK_LOADABLE 0x0004 +#define OS_TASK_SP_ONLY 0x0008 +#define OS_TASK_USR0 0x0010 +#define OS_TASK_USR1 0x0020 +#define OS_TASK_USR2 0x0040 +#define OS_TASK_USR3 0x0080 + /* Flags */ #define M_TASK_FLAG0 1 #define M_TASK_FLAG1 2 diff --git a/lib/src/os/osPfsDeleteFile.c b/lib/src/os/osPfsDeleteFile.c index 49e28cf3..016ce87d 100644 --- a/lib/src/os/osPfsDeleteFile.c +++ b/lib/src/os/osPfsDeleteFile.c @@ -36,7 +36,7 @@ s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, 1)); //TODO: magic constant ERRCK(__osPfsRWInode(pfs, &inode, OS_WRITE, bank)); - if (last_page.ipage == 1) + if (last_page.ipage == PFS_EOF) break; bank = last_page.inode_t.bank; startpage = last_page.inode_t.page; diff --git a/lib/src/os/osPfsFileState.c b/lib/src/os/osPfsFileState.c index 7bb32b4a..960eae70 100644 --- a/lib/src/os/osPfsFileState.c +++ b/lib/src/os/osPfsFileState.c @@ -46,10 +46,10 @@ s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state) break; } } - if (next_page.ipage == 1) + if (next_page.ipage == PFS_EOF) break; } - if (next_page.ipage != 1) + if (next_page.ipage != PFS_EOF) return PFS_ERR_INCONSISTENT; state->file_size = pages << PFS_ONE_PAGE; diff --git a/lib/src/os/osSpTaskYielded.c b/lib/src/os/osSpTaskYielded.c new file mode 100644 index 00000000..d8f3105a --- /dev/null +++ b/lib/src/os/osSpTaskYielded.c @@ -0,0 +1,28 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D1DF0 */ + +#include "libultra_internal.h" +#include "viint.h" +#include "PR/sptask.h" + +__OSViContext vi[2] = {0}; +__OSViContext *__osViCurr = &vi[0]; +__OSViContext *__osViNext = &vi[1]; + +//TODO: This should be defined above osInitialize +s32 osViClock = VI_NTSC_CLOCK; + +OSYieldResult osSpTaskYielded(OSTask *tp) { + u32 status; + OSYieldResult result; + status = __osSpGetStatus(); + if (status & SP_STATUS_YIELDED) + result = OS_TASK_YIELDED; + else + result = 0; + if (status & SP_STATUS_YIELD) { + tp->t.flags |= result; + tp->t.flags &= ~(OS_TASK_DP_WAIT); + } + return result; +} diff --git a/lib/src/os/osViGetCurrentFramebuffer.c b/lib/src/os/osViGetCurrentFramebuffer.c new file mode 100644 index 00000000..9929a6d8 --- /dev/null +++ b/lib/src/os/osViGetCurrentFramebuffer.c @@ -0,0 +1,15 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D1E70 */ + +#include "libultra_internal.h" +#include "viint.h" + +void *osViGetCurrentFramebuffer(void){ + register u32 saveMask; + void *framep; + + saveMask = __osDisableInt(); + framep = __osViCurr->framep; + __osRestoreInt(saveMask); + return framep; +} diff --git a/lib/src/os/osViGetNextFramebuffer.c b/lib/src/os/osViGetNextFramebuffer.c new file mode 100644 index 00000000..a2419c6c --- /dev/null +++ b/lib/src/os/osViGetNextFramebuffer.c @@ -0,0 +1,15 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D1EB0 */ + +#include "libultra_internal.h" +#include "viint.h" + +void *osViGetNextFramebuffer(void){ + register u32 saveMask; + void *framep; + + saveMask = __osDisableInt(); + framep = __osViNext->framep; + __osRestoreInt(saveMask); + return framep; +} diff --git a/lib/src/os/siacs.c b/lib/src/os/siacs.c index 813c45c3..0f71a037 100644 --- a/lib/src/os/siacs.c +++ b/lib/src/os/siacs.c @@ -22,7 +22,7 @@ s32 viCounterMsg[6]; u16 retrace; //Used in viMgrMain, but it's supposed to be static in that function u16 D_8012D192; s32 D_8012D194[2]; -OSTask tmp_task; +OSTask tmp_task; //Supposed to be statically declared in sptask.c #define PI_Q_BUF_LEN 1 OSMesg piAccessBuf[PI_Q_BUF_LEN]; //Should be static, but this works for now s32 __osPiAccessQueue[6]; diff --git a/lib/src/os/unknown_0D29F0.c b/lib/src/os/sptask.c similarity index 60% rename from lib/src/os/unknown_0D29F0.c rename to lib/src/os/sptask.c index 5e7f4a42..61523176 100644 --- a/lib/src/os/unknown_0D29F0.c +++ b/lib/src/os/sptask.c @@ -1,52 +1,9 @@ /* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800D1DF0 */ +/* RAM_POS: 0x800D1EF0 */ #include "libultra_internal.h" #include "viint.h" - -__OSViContext vi[2] = {0}; -__OSViContext *__osViCurr = &vi[0]; -__OSViContext *__osViNext = &vi[1]; - -//TODO: This should be defined above osInitialize -#define OS_TASK_YIELDED 0x0001 -#define OS_TASK_DP_WAIT 0x0002 -s32 osViClock = VI_NTSC_CLOCK; - -OSYieldResult osSpTaskYielded(OSTask *tp) { - u32 status; - OSYieldResult result; - status = __osSpGetStatus(); - if (status & SP_STATUS_YIELDED) - result = OS_TASK_YIELDED; - else - result = 0; - if (status & SP_STATUS_YIELD) { - tp->t.flags |= result; - tp->t.flags &= ~(OS_TASK_DP_WAIT); - } - return result; -} - -void *osViGetCurrentFramebuffer(void){ - register u32 saveMask; - void *framep; - - saveMask = __osDisableInt(); - framep = __osViCurr->framep; - __osRestoreInt(saveMask); - return framep; -} - -void *osViGetNextFramebuffer(void){ - register u32 saveMask; - void *framep; - - saveMask = __osDisableInt(); - framep = __osViNext->framep; - __osRestoreInt(saveMask); - return framep; -} +#include "PR/sptask.h" #define _osVirtualToPhysical(ptr) \ if (ptr != NULL) { \ @@ -54,7 +11,7 @@ void *osViGetNextFramebuffer(void){ } extern OSTask tmp_task; -OSTask *_VirtualToPhysicalTask(OSTask *intp) { +static OSTask *_VirtualToPhysicalTask(OSTask *intp) { OSTask *tp; tp = &tmp_task; bcopy(intp, tp, sizeof(OSTask)); From 9200805699b387f7620aafe9c6e41d401135d6f1 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 08:52:04 -0400 Subject: [PATCH 09/41] __osSiDeviceBusy from libreultra --- lib/src/os/si.c | 12 ++++++++++++ lib/src/os/unknown_0D5EC0.c | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 lib/src/os/si.c diff --git a/lib/src/os/si.c b/lib/src/os/si.c new file mode 100644 index 00000000..2d627a7f --- /dev/null +++ b/lib/src/os/si.c @@ -0,0 +1,12 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D52C0 */ + +#include "libultra_internal.h" +#include "siint.h" + +int __osSiDeviceBusy() { + register u32 stat = IO_READ(SI_STATUS_REG); + if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) + return 1; + return 0; +} diff --git a/lib/src/os/unknown_0D5EC0.c b/lib/src/os/unknown_0D5EC0.c index 34e43d5b..00860e71 100644 --- a/lib/src/os/unknown_0D5EC0.c +++ b/lib/src/os/unknown_0D5EC0.c @@ -1,11 +1,10 @@ /* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800D52C0 */ +/* RAM_POS: 0x800D52EC */ #include "macros.h" #include "libultra_internal.h" #include "viint.h" -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSiDeviceBusy.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSumcalc.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osIdCheckSum.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osRepairPackId.s") From 4c5c7cb4f2e41bc510d8d637dde1d4d15ed3e189 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 08:54:31 -0400 Subject: [PATCH 10/41] Split files up more --- lib/src/os/{unknown_0D5EC0.c => contpfs.c} | 5 ----- lib/src/os/dp.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) rename lib/src/os/{unknown_0D5EC0.c => contpfs.c} (83%) create mode 100644 lib/src/os/dp.c diff --git a/lib/src/os/unknown_0D5EC0.c b/lib/src/os/contpfs.c similarity index 83% rename from lib/src/os/unknown_0D5EC0.c rename to lib/src/os/contpfs.c index 00860e71..df2ee653 100644 --- a/lib/src/os/unknown_0D5EC0.c +++ b/lib/src/os/contpfs.c @@ -13,8 +13,3 @@ GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osGetId.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osCheckId.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osPfsRWInode.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osPfsSelectBank.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osDpDeviceBusy.s") - -__OSViContext *__osViGetCurrentContext(void){ - return __osViCurr; -} diff --git a/lib/src/os/dp.c b/lib/src/os/dp.c new file mode 100644 index 00000000..54ac9a8d --- /dev/null +++ b/lib/src/os/dp.c @@ -0,0 +1,12 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D6050 */ + +#include "macros.h" +#include "libultra_internal.h" +#include "viint.h" + +GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osDpDeviceBusy.s") + +__OSViContext *__osViGetCurrentContext(void){ + return __osViCurr; +} From 24c78c8919372f20af6a02fa5e768e30af9dd6fc Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 08:56:10 -0400 Subject: [PATCH 11/41] __osDpDeviceBusy from libreultra --- lib/src/os/__osViGetCurrentContext.c | 9 +++++++++ lib/src/os/dp.c | 11 ++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 lib/src/os/__osViGetCurrentContext.c diff --git a/lib/src/os/__osViGetCurrentContext.c b/lib/src/os/__osViGetCurrentContext.c new file mode 100644 index 00000000..fa33239a --- /dev/null +++ b/lib/src/os/__osViGetCurrentContext.c @@ -0,0 +1,9 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800D6080 */ + +#include "libultra_internal.h" +#include "viint.h" + +__OSViContext *__osViGetCurrentContext(void){ + return __osViCurr; +} diff --git a/lib/src/os/dp.c b/lib/src/os/dp.c index 54ac9a8d..803e5f49 100644 --- a/lib/src/os/dp.c +++ b/lib/src/os/dp.c @@ -3,10 +3,11 @@ #include "macros.h" #include "libultra_internal.h" -#include "viint.h" -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osDpDeviceBusy.s") - -__OSViContext *__osViGetCurrentContext(void){ - return __osViCurr; +int __osDpDeviceBusy(void) { + register u32 stat; + stat = IO_READ(DPC_STATUS_REG); + if (stat & DPC_STATUS_DMA_BUSY) + return 1; + return 0; } From 4c11579938d768ce51598268ccf2116721c06c95 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 09:01:37 -0400 Subject: [PATCH 12/41] Match contpfs from libreultra --- include/PR/pfs.h | 21 +-- lib/src/os/contpfs.c | 306 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 307 insertions(+), 20 deletions(-) diff --git a/include/PR/pfs.h b/include/PR/pfs.h index 68c16aba..4bf0b9ab 100644 --- a/include/PR/pfs.h +++ b/include/PR/pfs.h @@ -116,16 +116,17 @@ typedef struct { u8 game_name[PFS_FILE_NAME_LEN]; } __OSDir; -typedef struct { - u32 repaired; - u32 random; - u64 serialMid; - u64 serialLow; - u16 deviceid; - u8 banks; - u8 version; - u16 checksum; - u16 invertedChecksum; +typedef struct +{ + /* 0x0 */ u32 repaired; + /* 0x4 */ u32 random; + /* 0x8 */ u64 serial_mid; + /* 0x10 */ u64 serial_low; + /* 0x18 */ u16 deviceid; + /* 0x1A */ u8 banks; + /* 0x1B */ u8 version; + /* 0x1C */ u16 checksum; + /* 0x1E */ u16 inverted_checksum; } __OSPackId; typedef struct { diff --git a/lib/src/os/contpfs.c b/lib/src/os/contpfs.c index df2ee653..592e5ab8 100644 --- a/lib/src/os/contpfs.c +++ b/lib/src/os/contpfs.c @@ -1,15 +1,301 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800D52EC */ - #include "macros.h" #include "libultra_internal.h" -#include "viint.h" +#include "controller.h" -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osSumcalc.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osIdCheckSum.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osRepairPackId.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osCheckPackId.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osGetId.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osCheckId.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osPfsRWInode.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3020/__osPfsSelectBank.s") +u16 __osSumcalc(u8 *ptr, int length) +{ + int i; + u32 sum; + u8 *tmp; + + sum = 0; + tmp = ptr; + for (i = 0; i < length; i++) + { + sum += *tmp++; + sum &= 0xffff; + } + return sum; +} +s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum) +{ + u16 data; + u32 j; + data = 0; + *icsum = 0; + *csum = *icsum; + for (j = 0; j < 28; j += 2) + { + //feels like this should be a compiler optimization not manual.. + //but it doesn't match and I'm pretty sure this is just -O1 + data = *(u16 *)((u8 *)ptr + j); + //data = ptr[j] + *csum += data; + *icsum += ~data; + } + return 0; +} +s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) +{ + + s32 ret; + u8 temp[32]; + u8 comp[32]; + u8 mask; + int i; + int j; + u16 index[4]; + + ret = 0; + mask = 0; + SET_ACTIVEBANK_TO_ZERO; + newid->repaired = -1; + newid->random = osGetCount(); + newid->serial_mid = badid->serial_mid; + newid->serial_low = badid->serial_low; + for (j = 0; j < PFS_MAX_BANKS;) + { + pfs->activebank = j; + ERRCK(__osPfsSelectBank(pfs)) + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&temp)); //TODO: fix magic number + temp[0] = j | 0x80; + for (i = 1; i < ARRLEN(temp); i++) + { + + temp[i] = ~temp[i]; + } + + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, 0, (u8*)temp, FALSE)); //oddr 0, don't force + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&comp)); + + for (i = 0; i < ARRLEN(temp); i++) + { + if (comp[i] != temp[i]) + break; + } + if (i != ARRLEN(temp)) + break; + if (j > 0) + { + pfs->activebank = 0; + ERRCK(__osPfsSelectBank(pfs)); + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)temp)); + if (temp[0] != 128) + break; //TODO: remove magic constant + } + j++; + } + pfs->activebank = 0; + ERRCK(__osPfsSelectBank(pfs)); + if (j > 0) + mask = 1; + else + mask = 0; + newid->deviceid = (badid->deviceid & (u16)~1) | mask; + newid->banks = j; + newid->version = badid->version; + __osIdCheckSum((u16*)newid, &newid->checksum, &newid->inverted_checksum); + index[0] = PFS_ID_0AREA; + index[1] = PFS_ID_1AREA; + index[2] = PFS_ID_2AREA; + index[3] = PFS_ID_3AREA; + for (i = 0; i < ARRLEN(index); i++) + { + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, TRUE)); + } + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp)); + for (i = 0; i < ARRLEN(temp); i++) + { + if (temp[i] != ((u8 *)newid)[i]) + return PFS_ERR_ID_FATAL; + } + return 0; +} + +s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp) +{ + u16 index[4]; + s32 ret; + u16 sum; + u16 isum; + int i; + int j; + + ret = 0; + SET_ACTIVEBANK_TO_ZERO; + index[0] = 1; + index[1] = 3; + index[2] = 4; + index[3] = 6; + for (i = 1; i < ARRLEN(index); i++) + { + ERRCK(__osContRamRead(pfs->queue, pfs->channel, index[i], (u8*)temp)); + __osIdCheckSum((u16 *)temp, &sum, &isum); + if (temp->checksum == sum && temp->inverted_checksum == isum) + break; + } + if (i == ARRLEN(index)) + return PFS_ERR_ID_FATAL; + + for (j = 0; j < ARRLEN(index); j++) + { + if (j != i) + { + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)temp, TRUE)); + } + } + return 0; +} + +s32 __osGetId(OSPfs *pfs) +{ + int k; + u16 sum; + u16 isum; + u8 temp[32]; + __OSPackId newid; + s32 ret; + __OSPackId *id; + + SET_ACTIVEBANK_TO_ZERO; + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp)); + __osIdCheckSum((u16*)temp, &sum, &isum); + id = (__OSPackId*)temp; + if (id->checksum != sum || id->inverted_checksum != isum) + { + ret = __osCheckPackId(pfs, id); + if (ret == PFS_ERR_ID_FATAL) + { + ERRCK(__osRepairPackId(pfs, id, &newid)); + id = &newid; + } + else if (ret != 0) + { + return ret; + } + } + if ((id->deviceid & 1) == 0) //TODO: remove magic constant + { + ERRCK(__osRepairPackId(pfs, id, &newid)); + id = &newid; + if ((id->deviceid & 1) == 0) + return PFS_ERR_DEVICE; + } + for (k = 0; k < ARRLEN(pfs->id); k++) + { + pfs->id[k] = ((u8 *)id)[k]; + } + pfs->version = id->version; + pfs->banks = id->banks; + pfs->inode_start_page = pfs->banks * 2 + 3; //TODO: loads of magic constants.. + pfs->dir_size = 16; + pfs->inode_table = 8; + pfs->minode_table = pfs->banks * PFS_ONE_PAGE + 8; + pfs->dir_table = pfs->minode_table + pfs->banks * PFS_ONE_PAGE; + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 7, pfs->label)); + return 0; +} + +s32 __osCheckId(OSPfs *pfs) +{ + int k; + u8 temp[32]; + s32 ret; + + SET_ACTIVEBANK_TO_ZERO; + ret = __osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp); + if (ret != 0) + { + if (ret != 2) + return ret; + else + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp)); + } + + for (k = 0; k < ARRLEN(temp); k++) + { + if (pfs->id[k] != temp[k]) + return PFS_ERR_NEW_PACK; + } + + return 0; +} + +s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) +{ + u8 sum; + int j; + s32 ret; + int offset; + u8 *addr; + + SET_ACTIVEBANK_TO_ZERO; + + if (bank > 0) + offset = 1; + else + offset = pfs->inode_start_page; + + if (flag == PFS_WRITE) + inode->inode_page[0].inode_t.page = __osSumcalc((u8*)&inode->inode_page[offset], (-offset) * 2 + 256); + + for (j = 0; j < 8; j++) + { + addr = ((u8 *)inode->inode_page + j * 32); //TODO: don't like this =/ //maybe &inode->inode_table[j*PFS_ONE_PAGE].ipage or something + if (flag == PFS_WRITE) + { + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * 8 + j, addr, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * 8 + j, addr, FALSE); + } + else + { + ret = __osContRamRead(pfs->queue, pfs->channel, pfs->inode_table + bank * 8 + j, addr); + } + if (ret != 0) + return ret; + } + if (flag == PFS_READ) + { + sum = __osSumcalc((u8*)&inode->inode_page[offset], (-offset) * 2 + 256); + if (sum != inode->inode_page[0].inode_t.page) + { + for (j = 0; j < PFS_ONE_PAGE; j++) + { + addr = ((u8 *)inode->inode_page + j * 32); + ret = __osContRamRead(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr); + } + if (sum != inode->inode_page[0].inode_t.page) + return PFS_ERR_INCONSISTENT; + for (j = 0; j < PFS_ONE_PAGE; j++) + { + addr = ((u8 *)inode->inode_page + j * 32); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); + } + } + else + { + for (j = 0; j < PFS_ONE_PAGE; j++) + { + addr = ((u8 *)inode->inode_page + j * 32); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); + } + } + } + return 0; +} + +s32 __osPfsSelectBank(OSPfs *pfs) +{ + u8 temp[BLOCKSIZE]; + int i; + s32 ret; + ret = 0; + for (i = 0; i < ARRLEN(temp); i++) + { + temp[i] = pfs->activebank; + } + ret = __osContRamWrite(pfs->queue, pfs->channel, 1024, (u8*)temp, FALSE); + return ret; +} From 633933960a124d0baf373cc02931614dbbc970d1 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 10:38:00 -0400 Subject: [PATCH 13/41] Fixed Makefiles clean_lib and clean_src options --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index cb479815..cd4d228c 100755 --- a/Makefile +++ b/Makefile @@ -309,14 +309,14 @@ else endif clean_lib: -ifneq ($(wildcard $(BUILD_DIR)/lib/.*),) - rm -r $(BUILD_DIR)/lib/src/*.o +ifneq ($(wildcard $(BUILD_DIR)/lib/.*),) + rm -r $(BUILD_DIR)/lib/src/*/*.o else @echo "build lib directory has already been deleted." endif clean_src: clean_lib -ifneq ($(wildcard ./build/src/.*),) +ifneq ($(wildcard $(BUILD_DIR)/src/.*),) rm -r $(BUILD_DIR)/src/*.o else @echo "/build/lib directory has already been deleted." From d9c00c1827a459fdff028e8fcc93cab10e6f6977 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 10:38:55 -0400 Subject: [PATCH 14/41] Stole NaN code from SM64 that seems like a better match --- lib/src/os/piacs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/src/os/piacs.c b/lib/src/os/piacs.c index b28bcef3..34b49c3a 100644 --- a/lib/src/os/piacs.c +++ b/lib/src/os/piacs.c @@ -98,6 +98,4 @@ const char _Genld_0_string[] = "0"; const double _Ldtob_1e8[] = {1.0e8}; //sinf and cosf - supposed to be defined by libm_vals.s -const int __libm_qnan_f[] = { - 0x7F810000, 0x00000000 -}; +const fu __libm_qnan_f = { 0x7f810000 }; From acebbfef39508640795b0a151646f653eb915ae1 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 11:11:25 -0400 Subject: [PATCH 15/41] Add coloring to the Make process to make it easier to distiinguish warnings for each file. Stolen from sm64. Also fixed some easy warnings by using this. --- Makefile | 31 +++++++++++++++++++++++++++++-- lib/src/al/alCSPGetChlVol.c | 2 +- lib/src/al/alCSPSetVol.c | 1 - lib/src/al/alHeapDBAlloc.c | 2 -- lib/src/al/alSeqpGetChlFXMix.c | 2 +- src/unknown_0348C0.c | 2 +- src/unknown_0348C0.h | 4 ++-- src/unknown_05F0C0.h | 2 +- src/unknown_05FF10.h | 2 +- 9 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index cd4d228c..f0a2382a 100755 --- a/Makefile +++ b/Makefile @@ -19,6 +19,15 @@ ifeq ($(NON_MATCHING),1) DEFINES += NON_MATCHING=1 endif +# Whether to hide commands or not +VERBOSE ?= 0 +ifeq ($(VERBOSE),0) + V := @ +endif + +# Whether to colorize build messages +COLOR ?= 1 + ############################ Setup ########################### # Don't do setup checks if cleaning. @@ -41,6 +50,22 @@ ifeq ($(DUMMY),FAIL) $(error Failed to build tools) endif +PRINT = printf + +ifeq ($(COLOR),1) +NO_COL := \033[0m +RED := \033[0;31m +GREEN := \033[0;32m +BLUE := \033[0;34m +YELLOW := \033[0;33m +BLINK := \033[33;5m +endif + +# Common build print status function +define print + @$(PRINT) "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)\n" +endef + ########## Recomp ########## RECOMP_PROJECT := ./tools/ido-static-recomp/ @@ -410,10 +435,12 @@ $(UCODE_OUT_DIR)/%.bin: $(UCODE_IN_DIR)/%.bin ############################### $(BUILD_DIR)/%.o: %.s | $(ALL_ASSETS_BUILT) - $(AS) $(ASFLAGS) -o $@ $< + $(call print,Compiling:,$<,$@) + $(V)$(AS) $(ASFLAGS) -o $@ $< $(BUILD_DIR)/%.o: %.c | $(ALL_ASSETS_BUILT) - $(CC) $(CFLAGS) -o $@ $< + $(call print,Compiling:,$<,$@) + $(V)$(CC) $(CFLAGS) -o $@ $< $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) | $(ALL_ASSETS_BUILT) $(CPP) $(VERSION_CFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF $@.d -o $@ $< diff --git a/lib/src/al/alCSPGetChlVol.c b/lib/src/al/alCSPGetChlVol.c index d385d0b4..4d7dbc18 100644 --- a/lib/src/al/alCSPGetChlVol.c +++ b/lib/src/al/alCSPGetChlVol.c @@ -5,4 +5,4 @@ u8 alCSPGetChlVol(ALCSPlayer *seqp, u8 chan) { return seqp->chanState[chan].vol; -} \ No newline at end of file +} diff --git a/lib/src/al/alCSPSetVol.c b/lib/src/al/alCSPSetVol.c index 9910a3aa..d704d962 100644 --- a/lib/src/al/alCSPSetVol.c +++ b/lib/src/al/alCSPSetVol.c @@ -11,4 +11,3 @@ void alCSPSetVol(ALCSPlayer *seqp, s16 vol) { alEvtqPostEvent(&seqp->evtq, &evt, 0); } - diff --git a/lib/src/al/alHeapDBAlloc.c b/lib/src/al/alHeapDBAlloc.c index 10bee9bb..b842ff64 100644 --- a/lib/src/al/alHeapDBAlloc.c +++ b/lib/src/al/alHeapDBAlloc.c @@ -17,5 +17,3 @@ void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size) { return ptr; } - - diff --git a/lib/src/al/alSeqpGetChlFXMix.c b/lib/src/al/alSeqpGetChlFXMix.c index 6243101b..e26daa7d 100644 --- a/lib/src/al/alSeqpGetChlFXMix.c +++ b/lib/src/al/alSeqpGetChlFXMix.c @@ -5,4 +5,4 @@ u8 alSeqpGetChlFXMix(ALSeqPlayer *seqp, u8 chan) { return seqp->chanState[chan].fxmix; -} \ No newline at end of file +} diff --git a/src/unknown_0348C0.c b/src/unknown_0348C0.c index 926c4f8a..be94816f 100644 --- a/src/unknown_0348C0.c +++ b/src/unknown_0348C0.c @@ -1292,7 +1292,7 @@ void func_8003FEF4(Object *arg0, LevelObjectEntry8003FEF4 *arg1) { obj64->unk2 = arg1->unkA; obj64->unkC = arg1->unkC; obj64->unkD = arg1->unkD; - obj64->unk8_word = 0; + obj64->unk_union.unk8_word = 0; obj64->unk4 = arg1->unkE; obj64->unk11 = arg1->unk12; obj64->unk10 = arg1->unk11; diff --git a/src/unknown_0348C0.h b/src/unknown_0348C0.h index 1eb0676a..51552de9 100644 --- a/src/unknown_0348C0.h +++ b/src/unknown_0348C0.h @@ -287,9 +287,9 @@ typedef struct Object_64_8003FEF4 { u8 unk9; u8 unkA; u8 padB; - }; + } unk_struct; s32 unk8_word; - }; + } unk_union; u8 unkC; u8 unkD; u8 unkE; diff --git a/src/unknown_05F0C0.h b/src/unknown_05F0C0.h index c1913d7c..d5e327ee 100644 --- a/src/unknown_05F0C0.h +++ b/src/unknown_05F0C0.h @@ -5,4 +5,4 @@ extern s16 D_800DCE40[16]; -#endif \ No newline at end of file +#endif diff --git a/src/unknown_05FF10.h b/src/unknown_05FF10.h index 3b36db7c..68cefc97 100644 --- a/src/unknown_05FF10.h +++ b/src/unknown_05FF10.h @@ -5,4 +5,4 @@ extern s16 D_800DCE80[14]; -#endif \ No newline at end of file +#endif From ddf9d36863c8696f105ad79956bd96a56b8560f3 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 11:47:22 -0400 Subject: [PATCH 16/41] Added coloring to the Makefile throughout most of it's build. --- Makefile | 137 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 54 deletions(-) diff --git a/Makefile b/Makefile index f0a2382a..66be6dc6 100755 --- a/Makefile +++ b/Makefile @@ -348,7 +348,8 @@ else endif $(BUILD_DIR): - mkdir -p $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(LIB_DIRS) $(ASM_DIRS) $(SRC_DIRS) $(ASSETS_DIRS)) + @$(PRINT) "$(GREEN)Making Build Directory: $(BLUE)$@ $(NO_COL)\n" + $(V)mkdir -p $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(LIB_DIRS) $(ASM_DIRS) $(SRC_DIRS) $(ASSETS_DIRS)) # Helps fix an issue with parallel jobs. $(ALL_ASSETS_BUILT): | $(BUILD_DIR) @@ -360,82 +361,106 @@ dont_remove_asset_files: $(ALL_ASSETS_BUILT) # All assets should output a .bin file -$(AUDIO_OUT_DIR)/%.bin: $(AUDIO_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(AUDIO_OUT_DIR)/%.bin: $(AUDIO_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(BIN_OUT_DIR)/%.bin: $(BIN_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(BIN_OUT_DIR)/%.bin: $(BIN_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(FONTS_OUT_DIR)/%.bin: $(FONTS_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(FONTS_OUT_DIR)/%.bin: $(FONTS_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(IDS_OUT_DIR)/%.bin: $(IDS_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(IDS_OUT_DIR)/%.bin: $(IDS_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(LEVEL_HEADERS_OUT_DIR)/%.bin: $(LEVEL_HEADERS_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(LEVEL_HEADERS_OUT_DIR)/%.bin: $(LEVEL_HEADERS_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(LEVEL_MODELS_OUT_DIR)/%.bin: $(LEVEL_MODELS_IN_DIR)/%.cbin - $(COMPRESS) $^ $@ +$(LEVEL_MODELS_OUT_DIR)/%.bin: $(LEVEL_MODELS_IN_DIR)/%.cbin + $(call print,Compressing:,$<,$@) + $(V)$(COMPRESS) $^ $@ -$(LEVEL_NAMES_OUT_DIR)/%.bin: $(LEVEL_NAMES_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(LEVEL_NAMES_OUT_DIR)/%.bin: $(LEVEL_NAMES_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(LEVEL_OBJMAPS_OUT_DIR)/%.bin: $(LEVEL_OBJMAPS_IN_DIR)/%.cbin - $(COMPRESS) $^ $@ +$(LEVEL_OBJMAPS_OUT_DIR)/%.bin: $(LEVEL_OBJMAPS_IN_DIR)/%.cbin + $(call print,Compressing:,$<,$@) + $(V)$(COMPRESS) $^ $@ -$(MISC_OUT_DIR)/%.bin: $(MISC_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(MISC_OUT_DIR)/%.bin: $(MISC_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(OBJECTS_OUT_DIR)/%.bin: $(OBJECTS_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(OBJECTS_OUT_DIR)/%.bin: $(OBJECTS_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(OBJECT_ANIMS_OUT_DIR)/%.bin: $(OBJECT_ANIMS_IN_DIR)/%.cbin - $(COMPRESS) $^ $@ +$(OBJECT_ANIMS_OUT_DIR)/%.bin: $(OBJECT_ANIMS_IN_DIR)/%.cbin + $(call print,Compressing:,$<,$@) + $(V)$(COMPRESS) $^ $@ -$(OBJECT_HEADERS_OUT_DIR)/%.bin: $(OBJECT_HEADERS_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(OBJECT_HEADERS_OUT_DIR)/%.bin: $(OBJECT_HEADERS_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(OBJECT_MODELS_OUT_DIR)/%.bin: $(OBJECT_MODELS_IN_DIR)/%.cbin - $(COMPRESS) $^ $@ +$(OBJECT_MODELS_OUT_DIR)/%.bin: $(OBJECT_MODELS_IN_DIR)/%.cbin + $(call print,Compressing:,$<,$@) + $(V)$(COMPRESS) $^ $@ -$(PART_BEHAVIORS_OUT_DIR)/%.bin: $(PART_BEHAVIORS_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(PART_BEHAVIORS_OUT_DIR)/%.bin: $(PART_BEHAVIORS_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(PART_PARTICLES_OUT_DIR)/%.bin: $(PART_PARTICLES_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(PART_PARTICLES_OUT_DIR)/%.bin: $(PART_PARTICLES_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(SPRITES_OUT_DIR)/%.bin: $(SPRITES_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(SPRITES_OUT_DIR)/%.bin: $(SPRITES_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(TEXT_GAME_OUT_DIR)/%.bin: $(TEXT_GAME_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(TEXT_GAME_OUT_DIR)/%.bin: $(TEXT_GAME_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(TEXT_MENU_OUT_DIR)/%.bin: $(TEXT_MENU_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(TEXT_MENU_OUT_DIR)/%.bin: $(TEXT_MENU_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ $(TEXTURES_2D_OUT_DIR)/%.bin: $(TEXTURES_2D_IN_DIR)/%.png - $(TEXBUILDER) $^ $@ + $(call print,Building Texture:,$<,$@) + $(V)$(TEXBUILDER) $^ $@ $(TEXTURES_3D_OUT_DIR)/%.bin: $(TEXTURES_3D_IN_DIR)/%.png - $(TEXBUILDER) $^ $@ + $(call print,Building Texture:,$<,$@) + $(V)$(TEXBUILDER) $^ $@ -$(TEXT_MENU_OUT_DIR)/%.bin: $(TEXT_MENU_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(TEXT_MENU_OUT_DIR)/%.bin: $(TEXT_MENU_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(TT_GHOSTS_OUT_DIR)/%.bin: $(TT_GHOSTS_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(TT_GHOSTS_OUT_DIR)/%.bin: $(TT_GHOSTS_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(UNKNOWN_0_OUT_DIR)/%.bin: $(UNKNOWN_0_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(UNKNOWN_0_OUT_DIR)/%.bin: $(UNKNOWN_0_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ -$(UCODE_OUT_DIR)/%.bin: $(UCODE_IN_DIR)/%.bin - $(ASSETS_COPY) $^ $@ +$(UCODE_OUT_DIR)/%.bin: $(UCODE_IN_DIR)/%.bin + $(call print,Copying:,$<,$@) + $(V)$(ASSETS_COPY) $^ $@ ############################### $(BUILD_DIR)/%.o: %.s | $(ALL_ASSETS_BUILT) - $(call print,Compiling:,$<,$@) + $(call print,Assembling:,$<,$@) $(V)$(AS) $(ASFLAGS) -o $@ $< $(BUILD_DIR)/%.o: %.c | $(ALL_ASSETS_BUILT) @@ -443,18 +468,22 @@ $(BUILD_DIR)/%.o: %.c | $(ALL_ASSETS_BUILT) $(V)$(CC) $(CFLAGS) -o $@ $< $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) | $(ALL_ASSETS_BUILT) - $(CPP) $(VERSION_CFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF $@.d -o $@ $< + $(call print,Preprocessing linker script:,$<,$@) + $(V)$(CPP) $(VERSION_CFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF $@.d -o $@ $< $(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) | $(ALL_ASSETS_BUILT) - $(LD) $(LDFLAGS) -o $@ $(O_FILES) $(LIBS) + @$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n" + $(V)$(LD) $(LDFLAGS) -o $@ $(O_FILES) $(LIBS) $(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf | $(ALL_ASSETS_BUILT) - $(OBJCOPY) $< $@ -O binary + $(call print,Making .bin:,$<,$@) + $(V)$(OBJCOPY) $< $@ -O binary $(BUILD_DIR)/$(TARGET).z64: $(BUILD_DIR)/$(TARGET).bin | $(ALL_ASSETS_BUILT) - cp $< $@ - $(FIXCHECKSUMS) - $(N64CRC) $@ + $(call print,Making final z64 ROM:,$<,$@) + $(V)cp $< $@ + $(V)$(FIXCHECKSUMS) + $(V)$(N64CRC) $@ ifeq ($(NON_MATCHING),0) sha1sum -c sha1/dkr.$(VERSION).sha1 else From 6ca793fcc340cf3c3b63a48836080211f64c711a Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 12:54:54 -0400 Subject: [PATCH 17/41] Fix warning the same way libreultra defined the vars --- lib/src/os/__osViSwapContext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/os/__osViSwapContext.c b/lib/src/os/__osViSwapContext.c index a58302a6..cc2153af 100644 --- a/lib/src/os/__osViSwapContext.c +++ b/lib/src/os/__osViSwapContext.c @@ -13,8 +13,8 @@ struct __osThreadTail } __osThreadTail; struct __osThreadTail __osThreadTail = {0, -1}; -OSThread *__osRunQueue = &__osThreadTail.next; -OSThread *__osActiveQueue = &__osThreadTail.next; +OSThread *__osRunQueue = (OSThread *)&__osThreadTail; +OSThread *__osActiveQueue = (OSThread *)&__osThreadTail; extern OSThread *__osRunningThread = NULL; extern OSThread *__osFaultedThread = NULL; From e3ef4bd3cc2cc620f932634efbd121aa0bafa604 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 14:14:55 -0400 Subject: [PATCH 18/41] Matched osInitialize using libreultra/sm64 and a little grunt work --- Makefile | 2 +- .../unknown_0CCF90/osInitialize.s | 180 ------------------ .../unknown_0D5390/__osSetHWIntrRoutine.s | 22 --- .../unknown_0D5390/osPiRawWriteIo.s | 28 --- .../{unknown_0C7340.c => __osLeoInterrupt.c} | 4 +- lib/src/os/osInitialize.c | 57 +++--- .../os/{osPiRawWriteIo.c => osPiRawReadIo.c} | 2 +- undefined_syms.txt | 2 +- 8 files changed, 29 insertions(+), 268 deletions(-) delete mode 100644 lib/asm/non_matchings/unknown_0CCF90/osInitialize.s delete mode 100644 lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s delete mode 100644 lib/asm/non_matchings/unknown_0D5390/osPiRawWriteIo.s rename lib/src/os/{unknown_0C7340.c => __osLeoInterrupt.c} (66%) rename lib/src/os/{osPiRawWriteIo.c => osPiRawReadIo.c} (86%) diff --git a/Makefile b/Makefile index 66be6dc6..72ba3028 100755 --- a/Makefile +++ b/Makefile @@ -472,7 +472,7 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) | $(ALL_ASSETS_BUILT) $(V)$(CPP) $(VERSION_CFLAGS) -DBUILD_DIR=$(BUILD_DIR) -MMD -MP -MT $@ -MF $@.d -o $@ $< $(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) | $(ALL_ASSETS_BUILT) - @$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n" + @$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n" $(V)$(LD) $(LDFLAGS) -o $@ $(O_FILES) $(LIBS) $(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf | $(ALL_ASSETS_BUILT) diff --git a/lib/asm/non_matchings/unknown_0CCF90/osInitialize.s b/lib/asm/non_matchings/unknown_0CCF90/osInitialize.s deleted file mode 100644 index b53100c1..00000000 --- a/lib/asm/non_matchings/unknown_0CCF90/osInitialize.s +++ /dev/null @@ -1,180 +0,0 @@ -glabel osInitialize -/* 0CD1A0 800CC5A0 27BDFFC0 */ addiu $sp, $sp, -0x40 -/* 0CD1A4 800CC5A4 AFBF001C */ sw $ra, 0x1c($sp) -/* 0CD1A8 800CC5A8 240E0001 */ li $t6, 1 -/* 0CD1AC 800CC5AC 3C018013 */ lui $at, %hi(gThread30Stack) # $at, 0x8013 -/* 0CD1B0 800CC5B0 AFB00018 */ sw $s0, 0x18($sp) -/* 0CD1B4 800CC5B4 AFA00038 */ sw $zero, 0x38($sp) -/* 0CD1B8 800CC5B8 0C03515C */ jal __osGetSR -/* 0CD1BC 800CC5BC AC2ECCC0 */ sw $t6, %lo(gThread30Stack)($at) -/* 0CD1C0 800CC5C0 00408025 */ move $s0, $v0 -/* 0CD1C4 800CC5C4 3C012000 */ lui $at, 0x2000 -/* 0CD1C8 800CC5C8 0C035158 */ jal __osSetSR -/* 0CD1CC 800CC5CC 02012025 */ or $a0, $s0, $at -/* 0CD1D0 800CC5D0 3C040100 */ lui $a0, (0x01000800 >> 16) # lui $a0, 0x100 -/* 0CD1D4 800CC5D4 0C035160 */ jal __osSetFpcCsr -/* 0CD1D8 800CC5D8 34840800 */ ori $a0, (0x01000800 & 0xFFFF) # ori $a0, $a0, 0x800 -/* 0CD1DC 800CC5DC 3C041FC0 */ lui $a0, (0x1FC007FC >> 16) # lui $a0, 0x1fc0 -/* 0CD1E0 800CC5E0 348407FC */ ori $a0, (0x1FC007FC & 0xFFFF) # ori $a0, $a0, 0x7fc -/* 0CD1E4 800CC5E4 0C035164 */ jal __osSiRawReadIo -/* 0CD1E8 800CC5E8 27A5003C */ addiu $a1, $sp, 0x3c -/* 0CD1EC 800CC5EC 10400007 */ beqz $v0, .L800CC60C -/* 0CD1F0 800CC5F0 00000000 */ nop -.L800CC5F4: -/* 0CD1F4 800CC5F4 3C041FC0 */ lui $a0, (0x1FC007FC >> 16) # lui $a0, 0x1fc0 -/* 0CD1F8 800CC5F8 348407FC */ ori $a0, (0x1FC007FC & 0xFFFF) # ori $a0, $a0, 0x7fc -/* 0CD1FC 800CC5FC 0C035164 */ jal __osSiRawReadIo -/* 0CD200 800CC600 27A5003C */ addiu $a1, $sp, 0x3c -/* 0CD204 800CC604 1440FFFB */ bnez $v0, .L800CC5F4 -/* 0CD208 800CC608 00000000 */ nop -.L800CC60C: -/* 0CD20C 800CC60C 8FA5003C */ lw $a1, 0x3c($sp) -/* 0CD210 800CC610 3C041FC0 */ lui $a0, (0x1FC007FC >> 16) # lui $a0, 0x1fc0 -/* 0CD214 800CC614 348407FC */ ori $a0, (0x1FC007FC & 0xFFFF) # ori $a0, $a0, 0x7fc -/* 0CD218 800CC618 34AF0008 */ ori $t7, $a1, 8 -/* 0CD21C 800CC61C 0C035178 */ jal __osSiRawWriteIo -/* 0CD220 800CC620 01E02825 */ move $a1, $t7 -/* 0CD224 800CC624 10400009 */ beqz $v0, .L800CC64C -/* 0CD228 800CC628 00000000 */ nop -.L800CC62C: -/* 0CD22C 800CC62C 8FA5003C */ lw $a1, 0x3c($sp) -/* 0CD230 800CC630 3C041FC0 */ lui $a0, (0x1FC007FC >> 16) # lui $a0, 0x1fc0 -/* 0CD234 800CC634 348407FC */ ori $a0, (0x1FC007FC & 0xFFFF) # ori $a0, $a0, 0x7fc -/* 0CD238 800CC638 34B80008 */ ori $t8, $a1, 8 -/* 0CD23C 800CC63C 0C035178 */ jal __osSiRawWriteIo -/* 0CD240 800CC640 03002825 */ move $a1, $t8 -/* 0CD244 800CC644 1440FFF9 */ bnez $v0, .L800CC62C -/* 0CD248 800CC648 00000000 */ nop -.L800CC64C: -/* 0CD24C 800CC64C 3C08800D */ lui $t0, %hi(__osExceptionPreamble) # $t0, 0x800d -/* 0CD250 800CC650 25082CB0 */ addiu $t0, %lo(__osExceptionPreamble) # addiu $t0, $t0, 0x2cb0 -/* 0CD254 800CC654 8D010000 */ lw $at, ($t0) -/* 0CD258 800CC658 3C198000 */ lui $t9, 0x8000 -/* 0CD25C 800CC65C 3C0D800D */ lui $t5, %hi(__osExceptionPreamble) # $t5, 0x800d -/* 0CD260 800CC660 AF210000 */ sw $at, ($t9) -/* 0CD264 800CC664 8D0B0004 */ lw $t3, 4($t0) -/* 0CD268 800CC668 25AD2CB0 */ addiu $t5, %lo(__osExceptionPreamble) # addiu $t5, $t5, 0x2cb0 -/* 0CD26C 800CC66C 3C0C8000 */ lui $t4, 0x8000 -/* 0CD270 800CC670 AF2B0004 */ sw $t3, 4($t9) -/* 0CD274 800CC674 8D010008 */ lw $at, 8($t0) -/* 0CD278 800CC678 358C0080 */ ori $t4, (0x80000080 & 0xFFFF) # ori $t4, $t4, 0x80 -/* 0CD27C 800CC67C 3C09800D */ lui $t1, %hi(__osExceptionPreamble) # $t1, 0x800d -/* 0CD280 800CC680 AF210008 */ sw $at, 8($t9) -/* 0CD284 800CC684 8D0B000C */ lw $t3, 0xc($t0) -/* 0CD288 800CC688 25292CB0 */ addiu $t1, %lo(__osExceptionPreamble) # addiu $t1, $t1, 0x2cb0 -/* 0CD28C 800CC68C 3C0A8000 */ lui $t2, 0x8000 -/* 0CD290 800CC690 AF2B000C */ sw $t3, 0xc($t9) -/* 0CD294 800CC694 8DA10000 */ lw $at, ($t5) -/* 0CD298 800CC698 354A0100 */ ori $t2, (0x80000100 & 0xFFFF) # ori $t2, $t2, 0x100 -/* 0CD29C 800CC69C 3C0E800D */ lui $t6, %hi(__osExceptionPreamble) # $t6, 0x800d -/* 0CD2A0 800CC6A0 AD810000 */ sw $at, ($t4) -/* 0CD2A4 800CC6A4 8DB80004 */ lw $t8, 4($t5) -/* 0CD2A8 800CC6A8 25CE2CB0 */ addiu $t6, %lo(__osExceptionPreamble) # addiu $t6, $t6, 0x2cb0 -/* 0CD2AC 800CC6AC 3C0F8000 */ lui $t7, 0x8000 -/* 0CD2B0 800CC6B0 AD980004 */ sw $t8, 4($t4) -/* 0CD2B4 800CC6B4 8DA10008 */ lw $at, 8($t5) -/* 0CD2B8 800CC6B8 35EF0180 */ ori $t7, (0x80000180 & 0xFFFF) # ori $t7, $t7, 0x180 -/* 0CD2BC 800CC6BC 3C048000 */ lui $a0, 0x8000 -/* 0CD2C0 800CC6C0 AD810008 */ sw $at, 8($t4) -/* 0CD2C4 800CC6C4 8DB8000C */ lw $t8, 0xc($t5) -/* 0CD2C8 800CC6C8 24050190 */ li $a1, 400 -/* 0CD2CC 800CC6CC AD98000C */ sw $t8, 0xc($t4) -/* 0CD2D0 800CC6D0 8D210000 */ lw $at, ($t1) -/* 0CD2D4 800CC6D4 AD410000 */ sw $at, ($t2) -/* 0CD2D8 800CC6D8 8D2B0004 */ lw $t3, 4($t1) -/* 0CD2DC 800CC6DC AD4B0004 */ sw $t3, 4($t2) -/* 0CD2E0 800CC6E0 8D210008 */ lw $at, 8($t1) -/* 0CD2E4 800CC6E4 AD410008 */ sw $at, 8($t2) -/* 0CD2E8 800CC6E8 8D2B000C */ lw $t3, 0xc($t1) -/* 0CD2EC 800CC6EC AD4B000C */ sw $t3, 0xc($t2) -/* 0CD2F0 800CC6F0 8DC10000 */ lw $at, ($t6) -/* 0CD2F4 800CC6F4 ADE10000 */ sw $at, ($t7) -/* 0CD2F8 800CC6F8 8DD80004 */ lw $t8, 4($t6) -/* 0CD2FC 800CC6FC ADF80004 */ sw $t8, 4($t7) -/* 0CD300 800CC700 8DC10008 */ lw $at, 8($t6) -/* 0CD304 800CC704 ADE10008 */ sw $at, 8($t7) -/* 0CD308 800CC708 8DD8000C */ lw $t8, 0xc($t6) -/* 0CD30C 800CC70C 0C03518C */ jal osWritebackDCache -/* 0CD310 800CC710 ADF8000C */ sw $t8, 0xC($t7) -/* 0CD314 800CC714 3C048000 */ lui $a0, 0x8000 -/* 0CD318 800CC718 0C0351AC */ jal osInvalICache -/* 0CD31C 800CC71C 24050190 */ li $a1, 400 -/* 0CD320 800CC720 0C0351CC */ jal osMapTLBRdb -/* 0CD324 800CC724 00000000 */ nop -/* 0CD328 800CC728 24040004 */ li $a0, 4 -/* 0CD32C 800CC72C 0C0351E4 */ jal osPiRawWriteIo -/* 0CD330 800CC730 27A50038 */ addiu $a1, $sp, 0x38 -/* 0CD334 800CC734 8FA80038 */ lw $t0, 0x38($sp) -/* 0CD338 800CC738 2401FFF0 */ li $at, -16 -/* 0CD33C 800CC73C 0101C824 */ and $t9, $t0, $at -/* 0CD340 800CC740 13200006 */ beqz $t9, .L800CC75C -/* 0CD344 800CC744 AFB90038 */ sw $t9, 0x38($sp) -/* 0CD348 800CC748 3C01800E */ lui $at, %hi(osClockRate) # $at, 0x800e -/* 0CD34C 800CC74C 03205825 */ move $t3, $t9 -/* 0CD350 800CC750 240A0000 */ li $t2, 0 -/* 0CD354 800CC754 AC2A38A0 */ sw $t2, %lo(osClockRate)($at) -/* 0CD358 800CC758 AC2B38A4 */ sw $t3, %lo(osClockRate+4)($at) -.L800CC75C: -/* 0CD35C 800CC75C 3C04800E */ lui $a0, %hi(osClockRate) # $a0, 0x800e -/* 0CD360 800CC760 3C05800E */ lui $a1, %hi(osClockRate+4) # $a1, 0x800e -/* 0CD364 800CC764 8CA538A4 */ lw $a1, %lo(osClockRate+4)($a1) -/* 0CD368 800CC768 8C8438A0 */ lw $a0, %lo(osClockRate)($a0) -/* 0CD36C 800CC76C 24060000 */ li $a2, 0 -/* 0CD370 800CC770 0C033AF2 */ jal __ll_mul -/* 0CD374 800CC774 24070003 */ li $a3, 3 -/* 0CD378 800CC778 AFA20020 */ sw $v0, 0x20($sp) -/* 0CD37C 800CC77C AFA30024 */ sw $v1, 0x24($sp) -/* 0CD380 800CC780 8FA50024 */ lw $a1, 0x24($sp) -/* 0CD384 800CC784 8FA40020 */ lw $a0, 0x20($sp) -/* 0CD388 800CC788 24060000 */ li $a2, 0 -/* 0CD38C 800CC78C 0C033AB2 */ jal __ull_div -/* 0CD390 800CC790 24070004 */ li $a3, 4 -/* 0CD394 800CC794 3C098000 */ lui $t1, %hi(osResetType) # $t1, 0x8000 -/* 0CD398 800CC798 8D29030C */ lw $t1, %lo(osResetType)($t1) -/* 0CD39C 800CC79C 3C01800E */ lui $at, %hi(osClockRate) # $at, 0x800e -/* 0CD3A0 800CC7A0 AC2238A0 */ sw $v0, %lo(osClockRate)($at) -/* 0CD3A4 800CC7A4 15200005 */ bnez $t1, .L800CC7BC -/* 0CD3A8 800CC7A8 AC2338A4 */ sw $v1, %lo(osClockRate+4)($at) -/* 0CD3AC 800CC7AC 3C048000 */ lui $a0, %hi(osAppNMIBuffer) # $a0, 0x8000 -/* 0CD3B0 800CC7B0 2484031C */ addiu $a0, %lo(osAppNMIBuffer) # addiu $a0, $a0, 0x31c -/* 0CD3B4 800CC7B4 0C034138 */ jal bzero -/* 0CD3B8 800CC7B8 24050040 */ li $a1, 64 -.L800CC7BC: -/* 0CD3BC 800CC7BC 3C0DA460 */ lui $t5, %hi(PI_STATUS_REG) # $t5, 0xa460 -/* 0CD3C0 800CC7C0 8DAC0010 */ lw $t4, %lo(PI_STATUS_REG)($t5) -/* 0CD3C4 800CC7C4 318F0003 */ andi $t7, $t4, 3 -/* 0CD3C8 800CC7C8 11E00008 */ beqz $t7, .L800CC7EC -/* 0CD3CC 800CC7CC AFAC0030 */ sw $t4, 0x30($sp) -.L800CC7D0: -/* 0CD3D0 800CC7D0 3C0EA460 */ lui $t6, %hi(PI_STATUS_REG) # $t6, 0xa460 -/* 0CD3D4 800CC7D4 8DD80010 */ lw $t8, %lo(PI_STATUS_REG)($t6) -/* 0CD3D8 800CC7D8 AFB80030 */ sw $t8, 0x30($sp) -/* 0CD3DC 800CC7DC 8FA80030 */ lw $t0, 0x30($sp) -/* 0CD3E0 800CC7E0 31190003 */ andi $t9, $t0, 3 -/* 0CD3E4 800CC7E4 1720FFFA */ bnez $t9, .L800CC7D0 -/* 0CD3E8 800CC7E8 00000000 */ nop -.L800CC7EC: -/* 0CD3EC 800CC7EC 3C0AA500 */ lui $t2, %hi(LEO_STATUS) # $t2, 0xa500 -/* 0CD3F0 800CC7F0 8D4B0508 */ lw $t3, %lo(LEO_STATUS)($t2) -/* 0CD3F4 800CC7F4 3169FFFF */ andi $t1, $t3, 0xffff -/* 0CD3F8 800CC7F8 1520000A */ bnez $t1, .L800CC824 -/* 0CD3FC 800CC7FC AFAB0034 */ sw $t3, 0x34($sp) -/* 0CD400 800CC800 240D0001 */ li $t5, 1 -/* 0CD404 800CC804 3C01800E */ lui $at, %hi(D_800E38B0) # $at, 0x800e -/* 0CD408 800CC808 3C05800C */ lui $a1, %hi(func_800C7340) # $a1, 0x800c -/* 0CD40C 800CC80C AC2D38B0 */ sw $t5, %lo(D_800E38B0)($at) -/* 0CD410 800CC810 24A57340 */ addiu $a1, %lo(func_800C7340) # addiu $a1, $a1, 0x7340 -/* 0CD414 800CC814 0C0351FC */ jal __osSetHWIntrRoutine -/* 0CD418 800CC818 24040001 */ li $a0, 1 -/* 0CD41C 800CC81C 10000003 */ b .L800CC82C -/* 0CD420 800CC820 00000000 */ nop -.L800CC824: -/* 0CD424 800CC824 3C01800E */ lui $at, %hi(D_800E38B0) # $at, 0x800e -/* 0CD428 800CC828 AC2038B0 */ sw $zero, %lo(D_800E38B0)($at) -.L800CC82C: -/* 0CD42C 800CC82C 8FBF001C */ lw $ra, 0x1c($sp) -/* 0CD430 800CC830 8FB00018 */ lw $s0, 0x18($sp) -/* 0CD434 800CC834 27BD0040 */ addiu $sp, $sp, 0x40 -/* 0CD438 800CC838 03E00008 */ jr $ra -/* 0CD43C 800CC83C 00000000 */ nop - diff --git a/lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s b/lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s deleted file mode 100644 index dd6fbaca..00000000 --- a/lib/asm/non_matchings/unknown_0D5390/__osSetHWIntrRoutine.s +++ /dev/null @@ -1,22 +0,0 @@ -glabel __osSetHWIntrRoutine -/* 0D53F0 800D47F0 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0D53F4 800D47F4 AFBF001C */ sw $ra, 0x1c($sp) -/* 0D53F8 800D47F8 AFA40028 */ sw $a0, 0x28($sp) -/* 0D53FC 800D47FC AFA5002C */ sw $a1, 0x2c($sp) -/* 0D5400 800D4800 0C034958 */ jal __osDisableInt -/* 0D5404 800D4804 AFB00018 */ sw $s0, 0x18($sp) -/* 0D5408 800D4808 8FAF0028 */ lw $t7, 0x28($sp) -/* 0D540C 800D480C 8FAE002C */ lw $t6, 0x2c($sp) -/* 0D5410 800D4810 3C01800E */ lui $at, %hi(__osHwIntTable) # $at, 0x800e -/* 0D5414 800D4814 000FC080 */ sll $t8, $t7, 2 -/* 0D5418 800D4818 00408025 */ move $s0, $v0 -/* 0D541C 800D481C 00380821 */ addu $at, $at, $t8 -/* 0D5420 800D4820 02002025 */ move $a0, $s0 -/* 0D5424 800D4824 0C034960 */ jal __osRestoreInt -/* 0D5428 800D4828 AC2E48A0 */ sw $t6, %lo(__osHwIntTable)($at) -/* 0D542C 800D482C 8FBF001C */ lw $ra, 0x1c($sp) -/* 0D5430 800D4830 8FB00018 */ lw $s0, 0x18($sp) -/* 0D5434 800D4834 27BD0028 */ addiu $sp, $sp, 0x28 -/* 0D5438 800D4838 03E00008 */ jr $ra -/* 0D543C 800D483C 00000000 */ nop - diff --git a/lib/asm/non_matchings/unknown_0D5390/osPiRawWriteIo.s b/lib/asm/non_matchings/unknown_0D5390/osPiRawWriteIo.s deleted file mode 100644 index 283eccdb..00000000 --- a/lib/asm/non_matchings/unknown_0D5390/osPiRawWriteIo.s +++ /dev/null @@ -1,28 +0,0 @@ -glabel osPiRawWriteIo -/* 0D5390 800D4790 3C0EA460 */ lui $t6, %hi(PI_STATUS_REG) # $t6, 0xa460 -/* 0D5394 800D4794 8DC60010 */ lw $a2, %lo(PI_STATUS_REG)($t6) -/* 0D5398 800D4798 27BDFFF8 */ addiu $sp, $sp, -8 -/* 0D539C 800D479C 30CF0003 */ andi $t7, $a2, 3 -/* 0D53A0 800D47A0 11E00006 */ beqz $t7, .L800D47BC -/* 0D53A4 800D47A4 00000000 */ nop -.L800D47A8: -/* 0D53A8 800D47A8 3C18A460 */ lui $t8, %hi(PI_STATUS_REG) # $t8, 0xa460 -/* 0D53AC 800D47AC 8F060010 */ lw $a2, %lo(PI_STATUS_REG)($t8) -/* 0D53B0 800D47B0 30D90003 */ andi $t9, $a2, 3 -/* 0D53B4 800D47B4 1720FFFC */ bnez $t9, .L800D47A8 -/* 0D53B8 800D47B8 00000000 */ nop -.L800D47BC: -/* 0D53BC 800D47BC 3C088000 */ lui $t0, %hi(osRomBase) # $t0, 0x8000 -/* 0D53C0 800D47C0 8D080308 */ lw $t0, %lo(osRomBase)($t0) -/* 0D53C4 800D47C4 3C01A000 */ lui $at, 0xa000 -/* 0D53C8 800D47C8 00001025 */ move $v0, $zero -/* 0D53CC 800D47CC 01044825 */ or $t1, $t0, $a0 -/* 0D53D0 800D47D0 01215025 */ or $t2, $t1, $at -/* 0D53D4 800D47D4 8D4B0000 */ lw $t3, ($t2) -/* 0D53D8 800D47D8 27BD0008 */ addiu $sp, $sp, 8 -/* 0D53DC 800D47DC 03E00008 */ jr $ra -/* 0D53E0 800D47E0 ACAB0000 */ sw $t3, ($a1) - -/* 0D53E4 800D47E4 00000000 */ nop -/* 0D53E8 800D47E8 00000000 */ nop -/* 0D53EC 800D47EC 00000000 */ nop diff --git a/lib/src/os/unknown_0C7340.c b/lib/src/os/__osLeoInterrupt.c similarity index 66% rename from lib/src/os/unknown_0C7340.c rename to lib/src/os/__osLeoInterrupt.c index e8c8ccde..2df540e4 100644 --- a/lib/src/os/unknown_0C7340.c +++ b/lib/src/os/__osLeoInterrupt.c @@ -3,7 +3,7 @@ #include "types.h" -//Called only in osInitialize -s32 func_800C7340(void) { +//This has been blanked out for some reason +s32 __osLeoInterrupt(void) { return 0; } diff --git a/lib/src/os/osInitialize.c b/lib/src/os/osInitialize.c index aaec2656..a3d330ec 100644 --- a/lib/src/os/osInitialize.c +++ b/lib/src/os/osInitialize.c @@ -1,10 +1,9 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800CC5A0 */ -#include "types.h" -#include "macros.h" -#include "ultra64.h" +#include "libultra_internal.h" #include "viint.h" +#include "piint.h" typedef struct { @@ -18,28 +17,26 @@ extern __osExceptionVector __osExceptionPreamble; OSTime osClockRate = OS_CLOCK_RATE; u32 __osShutdown = 0; u32 __OSGlobalIntMask = OS_IM_ALL; -s32 D_800E38B0 = 0; // 64DD flag? (Hints from SM64 code) +s32 gLeoFound = FALSE; +s32 __osLeoInterrupt(void); -#if 0 -//Declaring this variable breaks things right away extern s32 osViClock; //This is defined in another file somehow -u32 __osFinalrom; -void osInitialize() -{ +extern s32 gThread30Stack; //TODO: This should be __osFinalrom. Is this reused? +//u32 __osFinalrom; +void osInitialize() { u32 pifdata; u32 clock = 0; - __osFinalrom = TRUE; + u32 leostatus; + u32 pistatus; + //__osFinalrom = TRUE; + gThread30Stack = TRUE; //TODO: This should be __osFinalrom. Is this reused? __osSetSR(__osGetSR() | SR_CU1); //enable fpu __osSetFpcCsr(FPCSR_FS | FPCSR_EV); //flush denorm to zero, enable invalid operation while (__osSiRawReadIo(PIF_RAM_END - 3, &pifdata)) //last byte of joychannel ram - { - ; - } + {;} while (__osSiRawWriteIo(PIF_RAM_END - 3, pifdata | 8)) - { - ; //todo: magic contant - } + {;} //todo: magic contant *(__osExceptionVector *)UT_VEC = __osExceptionPreamble; *(__osExceptionVector *)XUT_VEC = __osExceptionPreamble; *(__osExceptionVector *)ECC_VEC = __osExceptionPreamble; @@ -49,27 +46,21 @@ void osInitialize() osMapTLBRdb(); osPiRawReadIo(4, &clock); //TODO: remove magic constant; clock &= ~0xf; //clear lower 4 bits - if (clock != 0) - { + if (clock != 0) { osClockRate = clock; } osClockRate = osClockRate * 3 / 4; - if (osResetType == 0 /*cold reset */) - { + if (osResetType == 0 /*cold reset */) { bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer)); } - if (osTvType == OS_TV_TYPE_PAL) { - osViClock = VI_PAL_CLOCK; - } - else if (osTvType == OS_TV_TYPE_MPAL) - { - osViClock = VI_MPAL_CLOCK; - } - else - { - osViClock = VI_NTSC_CLOCK; + pistatus = IO_READ(PI_STATUS_REG); + while (pistatus & PI_STATUS_ERROR) { + pistatus = IO_READ(PI_STATUS_REG); + }; + if (!((leostatus = IO_READ(LEO_STATUS)) & LEO_STATUS_PRESENCE_MASK)) { + gLeoFound = TRUE; + __osSetHWIntrRoutine(1, __osLeoInterrupt); + } else { + gLeoFound = FALSE; } } -#else -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CCF90/osInitialize.s") -#endif diff --git a/lib/src/os/osPiRawWriteIo.c b/lib/src/os/osPiRawReadIo.c similarity index 86% rename from lib/src/os/osPiRawWriteIo.c rename to lib/src/os/osPiRawReadIo.c index 553f8ad5..c49e8ef9 100644 --- a/lib/src/os/osPiRawWriteIo.c +++ b/lib/src/os/osPiRawReadIo.c @@ -5,7 +5,7 @@ #include "libultra_internal.h" #include "piint.h" -s32 osPiRawWriteIo(u32 devAddr, u32 *data) { +s32 osPiRawReadIo(u32 devAddr, u32 *data) { register u32 stat; WAIT_ON_IOBUSY(stat); *data = IO_READ((u32)osRomBase | devAddr); diff --git a/undefined_syms.txt b/undefined_syms.txt index 1336ed6c..ff366c8d 100755 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2,7 +2,7 @@ osTvType = 0x80000300; osRomBase = 0x80000308; osResetType = 0x8000030C; osCicId = 0x80000310; -osAppNMIBuffer = 0x8000031C; +osAppNmiBuffer = 0x8000031C; D_A0000200 = 0xA0000200; D_A0000284 = 0xA0000284; From 1a7268516f4b6192e4681eec823759e0969f8e76 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 15:23:26 -0400 Subject: [PATCH 19/41] Match vi.c --- .../non_matchings/unknown_0D3160/__osViInit.s | 91 -------------- lib/src/os/osInitialize.c | 2 +- lib/src/os/osPiStartDma.c | 2 +- lib/src/os/osTimer.c | 6 +- lib/src/os/siacs.c | 2 +- lib/src/os/vi.c | 35 +++++- lib/src/os/vitbl.c | 115 +++++++++++++++--- src/video.c | 6 +- src/video.h | 2 +- 9 files changed, 142 insertions(+), 119 deletions(-) delete mode 100644 lib/asm/non_matchings/unknown_0D3160/__osViInit.s diff --git a/lib/asm/non_matchings/unknown_0D3160/__osViInit.s b/lib/asm/non_matchings/unknown_0D3160/__osViInit.s deleted file mode 100644 index e2a221a7..00000000 --- a/lib/asm/non_matchings/unknown_0D3160/__osViInit.s +++ /dev/null @@ -1,91 +0,0 @@ -glabel __osViInit -/* 0D3710 800D2B10 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0D3714 800D2B14 AFBF0014 */ sw $ra, 0x14($sp) -/* 0D3718 800D2B18 3C04800E */ lui $a0, %hi(vi) # $a0, 0x800e -/* 0D371C 800D2B1C 24844810 */ addiu $a0, %lo(vi) # addiu $a0, $a0, 0x4810 -/* 0D3720 800D2B20 0C034138 */ jal bzero -/* 0D3724 800D2B24 24050060 */ li $a1, 96 -/* 0D3728 800D2B28 3C0E800E */ lui $t6, %hi(vi) # $t6, 0x800e -/* 0D372C 800D2B2C 25CE4810 */ addiu $t6, %lo(vi) # addiu $t6, $t6, 0x4810 -/* 0D3730 800D2B30 3C01800E */ lui $at, %hi(__osViCurr) # $at, 0x800e -/* 0D3734 800D2B34 AC2E4870 */ sw $t6, %lo(__osViCurr)($at) -/* 0D3738 800D2B38 3C01800E */ lui $at, %hi(__osViNext) # $at, 0x800e -/* 0D373C 800D2B3C 25CF0030 */ addiu $t7, $t6, 0x30 -/* 0D3740 800D2B40 AC2F4874 */ sw $t7, %lo(__osViNext)($at) -/* 0D3744 800D2B44 24180001 */ li $t8, 1 -/* 0D3748 800D2B48 A5D80032 */ sh $t8, 0x32($t6) -/* 0D374C 800D2B4C 3C08800E */ lui $t0, %hi(__osViCurr) # $t0, 0x800e -/* 0D3750 800D2B50 8D084870 */ lw $t0, %lo(__osViCurr)($t0) -/* 0D3754 800D2B54 24190001 */ li $t9, 1 -/* 0D3758 800D2B58 3C098000 */ lui $t1, %hi(osTvType) # $t1, 0x8000 -/* 0D375C 800D2B5C A5190002 */ sh $t9, 2($t0) -/* 0D3760 800D2B60 8D290300 */ lw $t1, %lo(osTvType)($t1) -/* 0D3764 800D2B64 1520000B */ bnez $t1, .L800D2B94 -/* 0D3768 800D2B68 00000000 */ nop -/* 0D376C 800D2B6C 3C0B800E */ lui $t3, %hi(__osViNext) # $t3, 0x800e -/* 0D3770 800D2B70 8D6B4874 */ lw $t3, %lo(__osViNext)($t3) -/* 0D3774 800D2B74 3C0A800E */ lui $t2, %hi(D_800E4760) # $t2, 0x800e -/* 0D3778 800D2B78 254A4760 */ addiu $t2, %lo(D_800E4760) # addiu $t2, $t2, 0x4760 -/* 0D377C 800D2B7C 3C0C02F5 */ lui $t4, (0x02F5B2D2 >> 16) # lui $t4, 0x2f5 -/* 0D3780 800D2B80 358CB2D2 */ ori $t4, (0x02F5B2D2 & 0xFFFF) # ori $t4, $t4, 0xb2d2 -/* 0D3784 800D2B84 3C01800E */ lui $at, %hi(osViClock) # $at, 0x800e -/* 0D3788 800D2B88 AD6A0008 */ sw $t2, 8($t3) -/* 0D378C 800D2B8C 10000019 */ b .L800D2BF4 -/* 0D3790 800D2B90 AC2C4878 */ sw $t4, %lo(osViClock)($at) -.L800D2B94: -/* 0D3794 800D2B94 3C0D8000 */ lui $t5, %hi(osTvType) # $t5, 0x8000 -/* 0D3798 800D2B98 8DAD0300 */ lw $t5, %lo(osTvType)($t5) -/* 0D379C 800D2B9C 24010002 */ li $at, 2 -/* 0D37A0 800D2BA0 15A1000B */ bne $t5, $at, .L800D2BD0 -/* 0D37A4 800D2BA4 00000000 */ nop -/* 0D37A8 800D2BA8 3C18800E */ lui $t8, %hi(__osViNext) # $t8, 0x800e -/* 0D37AC 800D2BAC 8F184874 */ lw $t8, %lo(__osViNext)($t8) -/* 0D37B0 800D2BB0 3C0F800E */ lui $t7, %hi(D_800E47B0) # $t7, 0x800e -/* 0D37B4 800D2BB4 25EF47B0 */ addiu $t7, %lo(D_800E47B0) # addiu $t7, $t7, 0x47b0 -/* 0D37B8 800D2BB8 3C0E02E6 */ lui $t6, (0x02E6025C >> 16) # lui $t6, 0x2e6 -/* 0D37BC 800D2BBC 35CE025C */ ori $t6, (0x02E6025C & 0xFFFF) # ori $t6, $t6, 0x25c -/* 0D37C0 800D2BC0 3C01800E */ lui $at, %hi(osViClock) # $at, 0x800e -/* 0D37C4 800D2BC4 AF0F0008 */ sw $t7, 8($t8) -/* 0D37C8 800D2BC8 1000000A */ b .L800D2BF4 -/* 0D37CC 800D2BCC AC2E4878 */ sw $t6, %lo(osViClock)($at) -.L800D2BD0: -/* 0D37D0 800D2BD0 3C08800E */ lui $t0, %hi(__osViNext) # $t0, 0x800e -/* 0D37D4 800D2BD4 8D084874 */ lw $t0, %lo(__osViNext)($t0) -/* 0D37D8 800D2BD8 3C19800E */ lui $t9, %hi(D_800E4710) # $t9, 0x800e -/* 0D37DC 800D2BDC 27394710 */ addiu $t9, %lo(D_800E4710) # addiu $t9, $t9, 0x4710 -/* 0D37E0 800D2BE0 3C0902E6 */ lui $t1, (0x02E6D354 >> 16) # lui $t1, 0x2e6 -/* 0D37E4 800D2BE4 3529D354 */ ori $t1, (0x02E6D354 & 0xFFFF) # ori $t1, $t1, 0xd354 -/* 0D37E8 800D2BE8 3C01800E */ lui $at, %hi(osViClock) # $at, 0x800e -/* 0D37EC 800D2BEC AD190008 */ sw $t9, 8($t0) -/* 0D37F0 800D2BF0 AC294878 */ sw $t1, %lo(osViClock)($at) -.L800D2BF4: -/* 0D37F4 800D2BF4 3C0B800E */ lui $t3, %hi(__osViNext) # $t3, 0x800e -/* 0D37F8 800D2BF8 8D6B4874 */ lw $t3, %lo(__osViNext)($t3) -/* 0D37FC 800D2BFC 240A0020 */ li $t2, 32 -/* 0D3800 800D2C00 3C0C800E */ lui $t4, %hi(__osViNext) # $t4, 0x800e -/* 0D3804 800D2C04 A56A0000 */ sh $t2, ($t3) -/* 0D3808 800D2C08 8D8C4874 */ lw $t4, %lo(__osViNext)($t4) -/* 0D380C 800D2C0C 3C18A440 */ lui $t8, %hi(VI_CURRENT_REG) # $t8, 0xa440 -/* 0D3810 800D2C10 8D8D0008 */ lw $t5, 8($t4) -/* 0D3814 800D2C14 8DAF0004 */ lw $t7, 4($t5) -/* 0D3818 800D2C18 AD8F000C */ sw $t7, 0xc($t4) -/* 0D381C 800D2C1C 8F0E0010 */ lw $t6, %lo(VI_CURRENT_REG)($t8) -/* 0D3820 800D2C20 2DC1000B */ sltiu $at, $t6, 0xb -/* 0D3824 800D2C24 14200006 */ bnez $at, .L800D2C40 -/* 0D3828 800D2C28 00000000 */ nop -.L800D2C2C: -/* 0D382C 800D2C2C 3C19A440 */ lui $t9, %hi(VI_CURRENT_REG) # $t9, 0xa440 -/* 0D3830 800D2C30 8F280010 */ lw $t0, %lo(VI_CURRENT_REG)($t9) -/* 0D3834 800D2C34 2D01000B */ sltiu $at, $t0, 0xb -/* 0D3838 800D2C38 1020FFFC */ beqz $at, .L800D2C2C -/* 0D383C 800D2C3C 00000000 */ nop -.L800D2C40: -/* 0D3840 800D2C40 3C09A440 */ lui $t1, 0xa440 -/* 0D3844 800D2C44 0C035824 */ jal __osViSwapContext -/* 0D3848 800D2C48 AD200000 */ sw $zero, ($t1) -/* 0D384C 800D2C4C 8FBF0014 */ lw $ra, 0x14($sp) -/* 0D3850 800D2C50 27BD0018 */ addiu $sp, $sp, 0x18 -/* 0D3854 800D2C54 03E00008 */ jr $ra -/* 0D3858 800D2C58 00000000 */ nop - -/* 0D385C 800D2C5C 00000000 */ nop diff --git a/lib/src/os/osInitialize.c b/lib/src/os/osInitialize.c index a3d330ec..3dc39e5c 100644 --- a/lib/src/os/osInitialize.c +++ b/lib/src/os/osInitialize.c @@ -46,7 +46,7 @@ void osInitialize() { osMapTLBRdb(); osPiRawReadIo(4, &clock); //TODO: remove magic constant; clock &= ~0xf; //clear lower 4 bits - if (clock != 0) { + if (clock) { osClockRate = clock; } osClockRate = osClockRate * 3 / 4; diff --git a/lib/src/os/osPiStartDma.c b/lib/src/os/osPiStartDma.c index 63c354c4..7d13adcb 100644 --- a/lib/src/os/osPiStartDma.c +++ b/lib/src/os/osPiStartDma.c @@ -3,7 +3,7 @@ #include "libultra_internal.h" -extern OSDevMgr __osPiDevMgr; //__osPiDevMgr; +extern OSDevMgr __osPiDevMgr; s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) { register s32 ret; diff --git a/lib/src/os/osTimer.c b/lib/src/os/osTimer.c index 77d6e70d..7eaa0272 100644 --- a/lib/src/os/osTimer.c +++ b/lib/src/os/osTimer.c @@ -4,8 +4,8 @@ #include "macros.h" #include "libultra_internal.h" -extern OSTimer D_8012D200; -OSTimer *__osTimerList = &D_8012D200; +extern OSTimer __osBaseTimer; +OSTimer *__osTimerList = &__osBaseTimer; extern OSTime __osCurrentTime; extern u32 __osBaseCounter; @@ -16,7 +16,7 @@ extern u32 __osTimerCounter; OSTime __osInsertTimer(OSTimer *t); #ifdef NON_MATCHING -//Seems to be a mistmatch based on where __osCurrentTime is defined. +//Seems to be a mismatch based on where __osCurrentTime is defined. //Scratch proving that: https://decomp.me/scratch/OB3iP void __osTimerServicesInit(void) { __osCurrentTime = 0; diff --git a/lib/src/os/siacs.c b/lib/src/os/siacs.c index 0f71a037..407e1f6a 100644 --- a/lib/src/os/siacs.c +++ b/lib/src/os/siacs.c @@ -26,7 +26,7 @@ OSTask tmp_task; //Supposed to be statically declared in sptask.c #define PI_Q_BUF_LEN 1 OSMesg piAccessBuf[PI_Q_BUF_LEN]; //Should be static, but this works for now s32 __osPiAccessQueue[6]; -OSTimer D_8012D200; +OSTimer __osBaseTimer; OSTime __osCurrentTime; s32 __osBaseCounter; s32 __osViIntrCount; diff --git a/lib/src/os/vi.c b/lib/src/os/vi.c index 6f0f1550..8210ab19 100644 --- a/lib/src/os/vi.c +++ b/lib/src/os/vi.c @@ -1,8 +1,37 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800D2B10 */ -#include "types.h" -#include "macros.h" #include "libultra_internal.h" +#include "viint.h" +#include "video.h" -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D3160/__osViInit.s") +extern OSViMode osViModeNtscLan1; +extern OSViMode osViModePalLan1; +extern OSViMode osViModeMpalLan1; +extern __OSViContext vi[2]; +extern __OSViContext *__osViCurr; +extern __OSViContext *__osViNext; +extern s32 osViClock; + +void __osViInit(void) { + bzero(vi, sizeof(vi)); + __osViCurr = &vi[0]; + __osViNext = &vi[1]; + __osViNext->retraceCount = 1; + __osViCurr->retraceCount = 1; + if (osTvType == OS_TV_TYPE_PAL) { + __osViNext->modep = &osViModePalLan1; + osViClock = VI_PAL_CLOCK; + } else if (osTvType == OS_TV_TYPE_MPAL) { + __osViNext->modep = &osViModeMpalLan1; + osViClock = VI_MPAL_CLOCK; + } else { + __osViNext->modep = &osViModeNtscLan1; + osViClock = VI_NTSC_CLOCK; + } + __osViNext->state = VI_STATE_BLACK; + __osViNext->control = __osViNext->modep->comRegs.ctrl; + while (IO_READ(VI_CURRENT_REG) > 10); //wait for vsync? + IO_WRITE(VI_CONTROL_REG, 0); //pixel size blank (no data, no sync) + __osViSwapContext(); +} diff --git a/lib/src/os/vitbl.c b/lib/src/os/vitbl.c index a21a3f0c..421c33df 100644 --- a/lib/src/os/vitbl.c +++ b/lib/src/os/vitbl.c @@ -1571,29 +1571,114 @@ s32 D_800E46C0[20] = { 0x00000400, 0x002501FF, 0x000E0204, 0x00000002 }; -s32 D_800E4710[20] = { - 0x02000000, 0x0000311E, 0x00000140, 0x03E52239, - 0x0000020D, 0x00000C15, 0x0C150C15, 0x006C02EC, - 0x00000200, 0x00000000, 0x00000280, 0x00000400, - 0x002501FF, 0x000E0204, 0x00000002, 0x00000280, - 0x00000400, 0x002501FF, 0x000E0204, 0x00000002 -}; +OSViMode osViModeNtscLan1 = { + OS_VI_NTSC_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | + VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | 0x3000, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + {// fldRegs + { + //[0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + //[1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }}}; -s32 D_800E4760[20] = { +s32 osViModePalLan1[20] = { 0x10000000, 0x0000311E, 0x00000140, 0x0404233A, 0x00000271, 0x00150C69, 0x0C6F0C6E, 0x00800300, 0x00000200, 0x00000000, 0x00000280, 0x00000400, 0x005F0239, 0x0009026B, 0x00000002, 0x00000280, 0x00000400, 0x005F0239, 0x0009026B, 0x00000002 }; +/* +//TODO: Figure out why this doesn't match from libreultra +OSViMode osViModePalLan1 = { + OS_VI_PAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | + VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | 0x3000, // ctrl + WIDTH(320), // width + BURST(58, 30, 4, 69), // burst + VSYNC(625), // vSync + HSYNC(3177, 23), // hSync + LEAP(3183, 3181), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + {// fldRegs + { + //[0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + //[1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }}}; +*/ -s32 D_800E47B0[20] = { - 0x1E000000, 0x0000311E, 0x00000140, 0x04651E39, - 0x0000020D, 0x00040C11, 0x0C190C1A, 0x006C02EC, - 0x00000200, 0x00000000, 0x00000280, 0x00000400, - 0x002501FF, 0x000E0204, 0x00000002, 0x00000280, - 0x00000400, 0x002501FF, 0x000E0204, 0x00000002 -}; +OSViMode osViModeMpalLan1 = { + OS_VI_MPAL_LAN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | + VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | 0x3000, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + {// fldRegs + { + //[0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + //[1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }}}; // This needs to be moved. u32 __osPiAccessQueueEnabled = 0; diff --git a/src/video.c b/src/video.c index 177b8bd4..2fc74ffa 100644 --- a/src/video.c +++ b/src/video.c @@ -161,11 +161,11 @@ void init_vi_settings(void) { break; case 3: stubbed_printf("640 by 240 Anti-aliased, Non interlaced.\n"); - tvViMode = &D_800E4710; + tvViMode = &osViModeNtscLan1; if (osTvType == TV_TYPE_PAL) { - tvViMode = &D_800E4760; + tvViMode = &osViModePalLan1; } else if (osTvType == TV_TYPE_MPAL) { - tvViMode = &D_800E47B0; + tvViMode = &osViModeMpalLan1; } memory_copy(tvViMode, &D_80126260, sizeof(OSViMode)); D_80126260.comRegs.width = 0x280; diff --git a/src/video.h b/src/video.h index 0d0dbcd8..1dbe52d2 100644 --- a/src/video.h +++ b/src/video.h @@ -38,7 +38,7 @@ extern u16 *gVideoDepthBuffer; extern s32 D_800DE774; extern s8 D_800DE778; -extern OSViMode D_800E4620, D_800E4670, D_800E46C0, D_800E4760, D_800E4710, D_800E47B0; +extern OSViMode D_800E4620, D_800E4670, D_800E46C0, osViModePalLan1, osViModeNtscLan1, osViModeMpalLan1; /* Size: 0x08 bytes */ typedef struct VideoModeResolution { From f2c1e90b0da0b47f5bfb66f0eb471d9dc009f0e4 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 15:41:28 -0400 Subject: [PATCH 20/41] Use a NON_MATCHING ifdef for osViModePalLan1 --- lib/src/os/vitbl.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/src/os/vitbl.c b/lib/src/os/vitbl.c index 421c33df..053ee083 100644 --- a/lib/src/os/vitbl.c +++ b/lib/src/os/vitbl.c @@ -1604,15 +1604,8 @@ OSViMode osViModeNtscLan1 = { VINTR(2), // vIntr }}}; -s32 osViModePalLan1[20] = { - 0x10000000, 0x0000311E, 0x00000140, 0x0404233A, - 0x00000271, 0x00150C69, 0x0C6F0C6E, 0x00800300, - 0x00000200, 0x00000000, 0x00000280, 0x00000400, - 0x005F0239, 0x0009026B, 0x00000002, 0x00000280, - 0x00000400, 0x005F0239, 0x0009026B, 0x00000002 -}; -/* //TODO: Figure out why this doesn't match from libreultra +#ifdef NON_MATCHING OSViMode osViModePalLan1 = { OS_VI_PAL_LAN1, // type { @@ -1645,7 +1638,15 @@ OSViMode osViModePalLan1 = { BURST(107, 2, 9, 0), // vBurst VINTR(2), // vIntr }}}; -*/ +#else +s32 osViModePalLan1[20] = { + 0x10000000, 0x0000311E, 0x00000140, 0x0404233A, + 0x00000271, 0x00150C69, 0x0C6F0C6E, 0x00800300, + 0x00000200, 0x00000000, 0x00000280, 0x00000400, + 0x005F0239, 0x0009026B, 0x00000002, 0x00000280, + 0x00000400, 0x005F0239, 0x0009026B, 0x00000002 +}; +#endif OSViMode osViModeMpalLan1 = { OS_VI_MPAL_LAN1, // type From b873d1acd78ec99fecd78211f4b22da7a1c414b0 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 15:50:06 -0400 Subject: [PATCH 21/41] Get a better match for osViModePalLan1 --- lib/src/os/vitbl.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/src/os/vitbl.c b/lib/src/os/vitbl.c index 053ee083..901a0a9f 100644 --- a/lib/src/os/vitbl.c +++ b/lib/src/os/vitbl.c @@ -1604,8 +1604,7 @@ OSViMode osViModeNtscLan1 = { VINTR(2), // vIntr }}}; -//TODO: Figure out why this doesn't match from libreultra -#ifdef NON_MATCHING +//TODO: Figure out the BURST/HSYNC/LEAP values OSViMode osViModePalLan1 = { OS_VI_PAL_LAN1, // type { @@ -1613,10 +1612,13 @@ OSViMode osViModePalLan1 = { VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | 0x3000, // ctrl WIDTH(320), // width - BURST(58, 30, 4, 69), // burst + //BURST(58, 30, 4, 69), // burst + 67380026, VSYNC(625), // vSync - HSYNC(3177, 23), // hSync - LEAP(3183, 3181), // leap + //HSYNC(3177, 23), // hSync + 1379433, + //LEAP(3183, 3181), // leap + 208604270, HSTART(128, 768), // hStart SCALE(2, 0), // xScale VCURRENT(0), // vCurrent @@ -1638,15 +1640,6 @@ OSViMode osViModePalLan1 = { BURST(107, 2, 9, 0), // vBurst VINTR(2), // vIntr }}}; -#else -s32 osViModePalLan1[20] = { - 0x10000000, 0x0000311E, 0x00000140, 0x0404233A, - 0x00000271, 0x00150C69, 0x0C6F0C6E, 0x00800300, - 0x00000200, 0x00000000, 0x00000280, 0x00000400, - 0x005F0239, 0x0009026B, 0x00000002, 0x00000280, - 0x00000400, 0x005F0239, 0x0009026B, 0x00000002 -}; -#endif OSViMode osViModeMpalLan1 = { OS_VI_MPAL_LAN1, // type From 2780d354fcf9e18badbca6d20b77731b1b757868 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 19:21:28 -0400 Subject: [PATCH 22/41] Figured out the osViModePalLan1 values --- lib/src/os/vitbl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/os/vitbl.c b/lib/src/os/vitbl.c index 901a0a9f..6b639fda 100644 --- a/lib/src/os/vitbl.c +++ b/lib/src/os/vitbl.c @@ -1604,7 +1604,6 @@ OSViMode osViModeNtscLan1 = { VINTR(2), // vIntr }}}; -//TODO: Figure out the BURST/HSYNC/LEAP values OSViMode osViModePalLan1 = { OS_VI_PAL_LAN1, // type { @@ -1612,13 +1611,10 @@ OSViMode osViModePalLan1 = { VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 | 0x3000, // ctrl WIDTH(320), // width - //BURST(58, 30, 4, 69), // burst - 67380026, + BURST(58, 35, 4, 64), // burst VSYNC(625), // vSync - //HSYNC(3177, 23), // hSync - 1379433, - //LEAP(3183, 3181), // leap - 208604270, + HSYNC(3177, 21), // hSync + LEAP(3183, 3182), // leap HSTART(128, 768), // hStart SCALE(2, 0), // xScale VCURRENT(0), // vCurrent From 0056860f6511544938234007d1fdafa82764e9a2 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 20:08:32 -0400 Subject: [PATCH 23/41] Decomp some OSViMode structs --- include/PR/os_vi.h | 41 ++++++++----- lib/src/os/vitbl.c | 146 ++++++++++++++++++++++++++++++++++----------- src/video.c | 20 +++---- src/video.h | 2 +- 4 files changed, 147 insertions(+), 62 deletions(-) diff --git a/include/PR/os_vi.h b/include/PR/os_vi.h index a579248d..77d5e756 100644 --- a/include/PR/os_vi.h +++ b/include/PR/os_vi.h @@ -4,22 +4,33 @@ /* Ultra64 Video Interface */ -/* Special Features */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 +/* + * Video Interface (VI) special features + */ +#define OS_VI_GAMMA_ON 0x0001 +#define OS_VI_GAMMA_OFF 0x0002 +#define OS_VI_GAMMA_DITHER_ON 0x0004 +#define OS_VI_GAMMA_DITHER_OFF 0x0008 +#define OS_VI_DIVOT_ON 0x0010 +#define OS_VI_DIVOT_OFF 0x0020 +#define OS_VI_DITHER_FILTER_ON 0x0040 +#define OS_VI_DITHER_FILTER_OFF 0x0080 -#define OS_VI_GAMMA 0x08 -#define OS_VI_GAMMA_DITHER 0x04 -#define OS_VI_DIVOT 0x10 -#define OS_VI_DITHER_FILTER 0x10000 -#define OS_VI_UNK200 0x200 -#define OS_VI_UNK100 0x100 +/* + * Video Interface (VI) mode attribute bit + */ +#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ +#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ +#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ +#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ +#define OS_VI_BIT_ANTIALIAS 0x0010 +#define OS_VI_BIT_POINTSAMPLE 0x0020 +#define OS_VI_BIT_16PIXEL 0x0040 +#define OS_VI_BIT_32PIXEL 0x0080 +#define OS_VI_BIT_LORES 0x0100 +#define OS_VI_BIT_HIRES 0x0200 +#define OS_VI_BIT_NTSC 0x0400 +#define OS_VI_BIT_PAL 0x0800 /* Types */ diff --git a/lib/src/os/vitbl.c b/lib/src/os/vitbl.c index 6b639fda..115c4f63 100644 --- a/lib/src/os/vitbl.c +++ b/lib/src/os/vitbl.c @@ -57,30 +57,30 @@ /* * Video Interface (VI) special features */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 +#define OS_VI_GAMMA_ON 0x0001 +#define OS_VI_GAMMA_OFF 0x0002 #define OS_VI_GAMMA_DITHER_ON 0x0004 #define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 +#define OS_VI_DIVOT_ON 0x0010 +#define OS_VI_DIVOT_OFF 0x0020 #define OS_VI_DITHER_FILTER_ON 0x0040 #define OS_VI_DITHER_FILTER_OFF 0x0080 /* * Video Interface (VI) mode attribute bit */ -#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ -#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ +#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ +#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ #define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ #define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ -#define OS_VI_BIT_ANTIALIAS 0x0010 -#define OS_VI_BIT_POINTSAMPLE 0x0020 -#define OS_VI_BIT_16PIXEL 0x0040 -#define OS_VI_BIT_32PIXEL 0x0080 -#define OS_VI_BIT_LORES 0x0100 -#define OS_VI_BIT_HIRES 0x0200 -#define OS_VI_BIT_NTSC 0x0400 -#define OS_VI_BIT_PAL 0x0800 +#define OS_VI_BIT_ANTIALIAS 0x0010 +#define OS_VI_BIT_POINTSAMPLE 0x0020 +#define OS_VI_BIT_16PIXEL 0x0040 +#define OS_VI_BIT_32PIXEL 0x0080 +#define OS_VI_BIT_LORES 0x0100 +#define OS_VI_BIT_HIRES 0x0200 +#define OS_VI_BIT_NTSC 0x0400 +#define OS_VI_BIT_PAL 0x0800 OSViMode osViModeTable[42] = { {OS_VI_NTSC_LPN1, //type @@ -1546,30 +1546,104 @@ OSViMode osViModeTable[42] = { }}}, }; -// TODO: Convert the following arrays into OSViMode structs. -s32 D_800E4620[20] = { - 0x00000000, 0x0000320E, 0x00000140, 0x03E52239, - 0x0000020D, 0x00000C15, 0x0C150C15, 0x006C02EC, - 0x00000200, 0x00000000, 0x00000280, 0x00000400, - 0x002501FF, 0x000E0204, 0x00000002, 0x00000280, - 0x00000400, 0x002501FF, 0x000E0204, 0x00000002 -}; +OSViMode osViModeNtscLpn1 = { + OS_VI_NTSC_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | + VI_CTRL_ANTIALIAS_MODE_2 | 0x3000, // ctrl + WIDTH(320), // width + BURST(57, 34, 5, 62), // burst + VSYNC(525), // vSync + HSYNC(3093, 0), // hSync + LEAP(3093, 3093), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + {// fldRegs + { + //[0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + //[1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }}}; -s32 D_800E4670[20] = { - 0x0E000000, 0x0000320E, 0x00000140, 0x0404233A, - 0x00000271, 0x00150C69, 0x0C6F0C6E, 0x00800300, - 0x00000200, 0x00000000, 0x00000280, 0x00000400, - 0x005F0239, 0x0009026B, 0x00000002, 0x00000280, - 0x00000400, 0x005F0239, 0x0009026B, 0x00000002 -}; +OSViMode osViModePalLpn1 = { + OS_VI_PAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | + VI_CTRL_ANTIALIAS_MODE_2 | 0x3000, // ctrl + WIDTH(320), // width + BURST(58, 35, 4, 64), // burst + VSYNC(625), // vSync + HSYNC(3177, 21), // hSync + LEAP(3183, 3182), // leap + HSTART(128, 768), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + {// fldRegs + { + //[0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }, + { + //[1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(95, 569), // vStart + BURST(107, 2, 9, 0), // vBurst + VINTR(2), // vIntr + }}}; -s32 D_800E46C0[20] = { - 0x1C000000, 0x0000320E, 0x00000140, 0x04651E39, - 0x0000020D, 0x00040C11, 0x0C190C1A, 0x006C02EC, - 0x00000200, 0x00000000, 0x00000280, 0x00000400, - 0x002501FF, 0x000E0204, 0x00000002, 0x00000280, - 0x00000400, 0x002501FF, 0x000E0204, 0x00000002 -}; +OSViMode osViModeMpalLpn1 = { + OS_VI_MPAL_LPN1, // type + { + // comRegs + VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | + VI_CTRL_ANTIALIAS_MODE_2 | 0x3000, // ctrl + WIDTH(320), // width + BURST(57, 30, 5, 70), // burst + VSYNC(525), // vSync + HSYNC(3089, 4), // hSync + LEAP(3097, 3098), // leap + HSTART(108, 748), // hStart + SCALE(2, 0), // xScale + VCURRENT(0), // vCurrent + }, + {// fldRegs + { + //[0] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }, + { + //[1] + ORIGIN(640), // origin + SCALE(1, 0), // yScale + HSTART(37, 511), // vStart + BURST(4, 2, 14, 0), // vBurst + VINTR(2), // vIntr + }}}; OSViMode osViModeNtscLan1 = { OS_VI_NTSC_LAN1, // type diff --git a/src/video.c b/src/video.c index 2fc74ffa..4eb3c8d6 100644 --- a/src/video.c +++ b/src/video.c @@ -128,28 +128,28 @@ void init_vi_settings(void) { break; case 1: stubbed_printf("320 by 240 Anti-aliased, Non interlaced.\n"); - tvViMode = &D_800E4620; + tvViMode = &osViModeNtscLpn1; if (osTvType == TV_TYPE_PAL) { - tvViMode = &D_800E4670; + tvViMode = &osViModePalLpn1; } else if (osTvType == TV_TYPE_MPAL) { - tvViMode = &D_800E46C0; + tvViMode = &osViModeMpalLpn1; } memory_copy(tvViMode, &D_80126260, sizeof(OSViMode)); if (osTvType == TV_TYPE_PAL) { - D_80126260.fldRegs[0].vStart -= 0x180000; - D_80126260.fldRegs[1].vStart -= 0x180000; - D_80126260.fldRegs[0].vStart += 24; - D_80126260.fldRegs[1].vStart += 24; + D_80126260.fldRegs[0].vStart -= 0x180000; //0x18 << 16 + D_80126260.fldRegs[1].vStart -= 0x180000; //0x18 << 16 + D_80126260.fldRegs[0].vStart += 0x18; + D_80126260.fldRegs[1].vStart += 0x18; } osViSetMode(&D_80126260); break; case 2: stubbed_printf("640 by 240 Point sampled, Non interlaced.\n"); - tvViMode = &D_800E4620; + tvViMode = &osViModeNtscLpn1; if (osTvType == TV_TYPE_PAL) { - tvViMode = &D_800E4670; + tvViMode = &osViModePalLpn1; } else if (osTvType == TV_TYPE_MPAL) { - tvViMode = &D_800E46C0; + tvViMode = &osViModeMpalLpn1; } memory_copy(tvViMode, &D_80126260, sizeof(OSViMode)); diff --git a/src/video.h b/src/video.h index 1dbe52d2..d184cdbd 100644 --- a/src/video.h +++ b/src/video.h @@ -38,7 +38,7 @@ extern u16 *gVideoDepthBuffer; extern s32 D_800DE774; extern s8 D_800DE778; -extern OSViMode D_800E4620, D_800E4670, D_800E46C0, osViModePalLan1, osViModeNtscLan1, osViModeMpalLan1; +extern OSViMode osViModeNtscLpn1, osViModePalLpn1, osViModeMpalLpn1, osViModePalLan1, osViModeNtscLan1, osViModeMpalLan1; /* Size: 0x08 bytes */ typedef struct VideoModeResolution { From f2ec5d4d45cf744cc78b5f759bafc6e1ba873ea5 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 20:49:42 -0400 Subject: [PATCH 24/41] Identify and document some stuff in init_vi_settings --- src/video.c | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/video.c b/src/video.c index 4eb3c8d6..5feded75 100644 --- a/src/video.c +++ b/src/video.c @@ -2,6 +2,7 @@ /* RAM_POS: 0x8007A310 */ #include "video.h" +#include "viint.h" /************ .data ************/ @@ -32,7 +33,7 @@ f32 gVideoHeightRatio; s32 D_8012617C; OSMesg D_80126180[8]; OSMesgQueue D_801261A0[8]; -OSViMode D_80126260; +OSViMode gTvViMode; s32 gVideoFbWidths[2]; s32 gVideoFbHeights[2]; u16 *gVideoFramebuffers[2]; @@ -127,6 +128,10 @@ void init_vi_settings(void) { osViSetMode(&osViModeTable[viModeTableIndex]); break; case 1: + //@bug: The video mode being set here is Point sampled + //but the printf implies it was intended to be Anti-aliased. + //By my understanding, this is the case we will always hit in code, + //So maybe it was swapped out late in development? stubbed_printf("320 by 240 Anti-aliased, Non interlaced.\n"); tvViMode = &osViModeNtscLpn1; if (osTvType == TV_TYPE_PAL) { @@ -134,14 +139,15 @@ void init_vi_settings(void) { } else if (osTvType == TV_TYPE_MPAL) { tvViMode = &osViModeMpalLpn1; } - memory_copy(tvViMode, &D_80126260, sizeof(OSViMode)); + memory_copy(tvViMode, &gTvViMode, sizeof(OSViMode)); if (osTvType == TV_TYPE_PAL) { - D_80126260.fldRegs[0].vStart -= 0x180000; //0x18 << 16 - D_80126260.fldRegs[1].vStart -= 0x180000; //0x18 << 16 - D_80126260.fldRegs[0].vStart += 0x18; - D_80126260.fldRegs[1].vStart += 0x18; + //TODO: Figure out what the 0x18 is for + gTvViMode.fldRegs[0].vStart -= (0x18 << 16); + gTvViMode.fldRegs[1].vStart -= (0x18 << 16); + gTvViMode.fldRegs[0].vStart += 0x18; + gTvViMode.fldRegs[1].vStart += 0x18; } - osViSetMode(&D_80126260); + osViSetMode(&gTvViMode); break; case 2: stubbed_printf("640 by 240 Point sampled, Non interlaced.\n"); @@ -152,12 +158,12 @@ void init_vi_settings(void) { tvViMode = &osViModeMpalLpn1; } - memory_copy(tvViMode, &D_80126260, sizeof(OSViMode)); - D_80126260.comRegs.width = 0x280; - D_80126260.comRegs.xScale = 0x400; - D_80126260.fldRegs[0].origin = 0x500; - D_80126260.fldRegs[1].origin = 0x500; - osViSetMode(&D_80126260); + memory_copy(tvViMode, &gTvViMode, sizeof(OSViMode)); + gTvViMode.comRegs.width = WIDTH(640); + gTvViMode.comRegs.xScale = SCALE(1, 0); + gTvViMode.fldRegs[0].origin = ORIGIN(1280); + gTvViMode.fldRegs[1].origin = ORIGIN(1280); + osViSetMode(&gTvViMode); break; case 3: stubbed_printf("640 by 240 Anti-aliased, Non interlaced.\n"); @@ -167,28 +173,28 @@ void init_vi_settings(void) { } else if (osTvType == TV_TYPE_MPAL) { tvViMode = &osViModeMpalLan1; } - memory_copy(tvViMode, &D_80126260, sizeof(OSViMode)); - D_80126260.comRegs.width = 0x280; - D_80126260.comRegs.xScale = 0x400; - D_80126260.fldRegs[0].origin = 0x500; - D_80126260.fldRegs[1].origin = 0x500; - osViSetMode(&D_80126260); + memory_copy(tvViMode, &gTvViMode, sizeof(OSViMode)); + gTvViMode.comRegs.width = WIDTH(640); + gTvViMode.comRegs.xScale = SCALE(1, 0); + gTvViMode.fldRegs[0].origin = ORIGIN(1280); + gTvViMode.fldRegs[1].origin = ORIGIN(1280); + osViSetMode(&gTvViMode); break; case 4: stubbed_printf("640 by 480 Point sampled, Interlaced.\n"); - osViSetMode(&osViModeTable[viModeTableIndex + 8]); + osViSetMode(&osViModeTable[viModeTableIndex + OS_VI_NTSC_HPN1]); break; case 5: stubbed_printf("640 by 480 Anti-aliased, Interlaced.\n"); - osViSetMode(&osViModeTable[viModeTableIndex + 10]); + osViSetMode(&osViModeTable[viModeTableIndex + OS_VI_NTSC_HAN1]); break; case 6: stubbed_printf("640 by 480 Point sampled, Interlaced, De-flickered.\n"); - osViSetMode(&osViModeTable[viModeTableIndex + 9]); + osViSetMode(&osViModeTable[viModeTableIndex + OS_VI_NTSC_HPF1]); break; case 7: stubbed_printf("640 by 480 Anti-aliased, Interlaced, De-flickered.\n"); - osViSetMode(&osViModeTable[viModeTableIndex + 11]); + osViSetMode(&osViModeTable[viModeTableIndex + OS_VI_NTSC_HAF1]); break; } osViSetSpecialFeatures(OS_VI_DIVOT_ON); From 438426784bddc61fe565f8666f54f6cd4e85dbe6 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 22:03:22 -0400 Subject: [PATCH 25/41] Fix some warnings, and update mips to c tool --- mips_to_c.sh | 2 +- src/video.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mips_to_c.sh b/mips_to_c.sh index 17f5913d..cb067e3c 100755 --- a/mips_to_c.sh +++ b/mips_to_c.sh @@ -1,4 +1,4 @@ #!/bin/sh ASMFILE=$(find . -type f -name "*$1.s") -python3 ../mips_to_c/mips_to_c.py --context ctx.c -f $1 $ASMFILE > $1.c \ No newline at end of file +python3 ../mips_to_c/mips_to_c.py --compiler ido --pointer-style right --context ctx.c -f $1 $ASMFILE > $1.c \ No newline at end of file diff --git a/src/video.c b/src/video.c index 5feded75..0048b7a3 100644 --- a/src/video.c +++ b/src/video.c @@ -139,13 +139,13 @@ void init_vi_settings(void) { } else if (osTvType == TV_TYPE_MPAL) { tvViMode = &osViModeMpalLpn1; } - memory_copy(tvViMode, &gTvViMode, sizeof(OSViMode)); + memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); if (osTvType == TV_TYPE_PAL) { - //TODO: Figure out what the 0x18 is for - gTvViMode.fldRegs[0].vStart -= (0x18 << 16); - gTvViMode.fldRegs[1].vStart -= (0x18 << 16); - gTvViMode.fldRegs[0].vStart += 0x18; - gTvViMode.fldRegs[1].vStart += 0x18; + //A simple osViExtendVStart to add an additional 24 scanlines? + gTvViMode.fldRegs[0].vStart -= (24 << 16); + gTvViMode.fldRegs[1].vStart -= (24 << 16); + gTvViMode.fldRegs[0].vStart += 24; + gTvViMode.fldRegs[1].vStart += 24; } osViSetMode(&gTvViMode); break; @@ -158,7 +158,7 @@ void init_vi_settings(void) { tvViMode = &osViModeMpalLpn1; } - memory_copy(tvViMode, &gTvViMode, sizeof(OSViMode)); + memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); gTvViMode.comRegs.width = WIDTH(640); gTvViMode.comRegs.xScale = SCALE(1, 0); gTvViMode.fldRegs[0].origin = ORIGIN(1280); @@ -173,7 +173,7 @@ void init_vi_settings(void) { } else if (osTvType == TV_TYPE_MPAL) { tvViMode = &osViModeMpalLan1; } - memory_copy(tvViMode, &gTvViMode, sizeof(OSViMode)); + memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); gTvViMode.comRegs.width = WIDTH(640); gTvViMode.comRegs.xScale = SCALE(1, 0); gTvViMode.fldRegs[0].origin = ORIGIN(1280); @@ -204,7 +204,7 @@ void init_vi_settings(void) { void init_framebuffer(s32 index) { if (gVideoFramebuffers[index] != 0) { - func_80071538(gVideoFramebuffers[index]); + func_80071538((u8 *)gVideoFramebuffers[index]); free_from_memory_pool(gVideoFramebuffers[index]); } gVideoFbWidths[index] = gVideoModeResolutions[gVideoModeIndex & 7].width; From fd5535d88f396035945994791e71de8edd6f11ce Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 21 Oct 2021 22:43:20 -0400 Subject: [PATCH 26/41] Maybe went overboard with make colours, but it's all colourful now! --- Makefile | 2 +- tools/n64crc.c | 41 +++++++++++++++++++++++-------------- tools/python/generate_ld.py | 4 ++-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 72ba3028..fea23ee5 100755 --- a/Makefile +++ b/Makefile @@ -485,7 +485,7 @@ $(BUILD_DIR)/$(TARGET).z64: $(BUILD_DIR)/$(TARGET).bin | $(ALL_ASSETS_BUILT) $(V)$(FIXCHECKSUMS) $(V)$(N64CRC) $@ ifeq ($(NON_MATCHING),0) - sha1sum -c sha1/dkr.$(VERSION).sha1 + $(V)sha1sum -c --quiet sha1/dkr.$(VERSION).sha1 else @echo "Build complete!" endif diff --git a/tools/n64crc.c b/tools/n64crc.c index a3dc6ce8..39cd69cd 100755 --- a/tools/n64crc.c +++ b/tools/n64crc.c @@ -26,6 +26,13 @@ #include #include + +#define NO_COL "\x1B[0m" +#define RED "\x1B[31m" +#define GREEN "\x1B[32m" +#define BLUE "\x1B[34m" +#define YELLOW "\x1B[33m" + #define ROL(i, b) (((i) << (b)) | ((i) >> (32 - (b)))) #define BYTES2LONG(b) ( (b)[0] << 24 | \ (b)[1] << 16 | \ @@ -191,34 +198,38 @@ int main(int argc, char **argv) { //Check CIC BootChip cic = N64GetCIC(buffer); - printf("BootChip: "); - printf((cic ? "CIC-NUS-%d\n" : "Unknown\n"), cic); + printf(GREEN "BootChip: " NO_COL); + printf((cic ? YELLOW "CIC-NUS-%d\n" NO_COL : RED "Unknown\n" NO_COL), cic); //Calculate CRC if (N64CalcCRC(crc, buffer)) { - printf("Unable to calculate CRC\n"); + printf(RED "Unable to calculate CRC\n" NO_COL); } else { - printf("CRC 1: 0x%08X ", BYTES2LONG(&buffer[N64_CRC1])); - printf("Calculated: 0x%08X ", crc[0]); - if (crc[0] == BYTES2LONG(&buffer[N64_CRC1])) - printf("(Good)\n"); - else{ + printf(GREEN "CRC 1: %s0x%08X " NO_COL, YELLOW, BYTES2LONG(&buffer[N64_CRC1])); + if (crc[0] == BYTES2LONG(&buffer[N64_CRC1])) { + printf(GREEN "Calculated: %s0x%08X " NO_COL, YELLOW, crc[0]); + printf(BLUE "(Good)\n" NO_COL); + } + else { + printf(GREEN "Calculated: %s0x%08X " NO_COL, RED, crc[0]); Write32(buffer, N64_CRC1, crc[0]); fseek(fin, N64_CRC1, SEEK_SET); fwrite(&buffer[N64_CRC1], 1, 4, fin); - printf("(Bad, fixed)\n"); + printf(RED "(Bad, fixed)\n" NO_COL); } - printf("CRC 2: 0x%08X ", BYTES2LONG(&buffer[N64_CRC2])); - printf("Calculated: 0x%08X ", crc[1]); - if (crc[1] == BYTES2LONG(&buffer[N64_CRC2])) - printf("(Good)\n"); - else{ + printf(GREEN "CRC 2: %s0x%08X " NO_COL, YELLOW, BYTES2LONG(&buffer[N64_CRC2])); + if (crc[1] == BYTES2LONG(&buffer[N64_CRC2])) { + printf(GREEN "Calculated: %s0x%08X " NO_COL, YELLOW, crc[1]); + printf(BLUE "(Good)\n" NO_COL); + } + else { + printf(GREEN "Calculated: %s0x%08X " NO_COL, RED, crc[1]); Write32(buffer, N64_CRC2, crc[1]); fseek(fin, N64_CRC2, SEEK_SET); fwrite(&buffer[N64_CRC2], 1, 4, fin); - printf("(Bad, fixed)\n"); + printf(RED "(Bad, fixed)\n" NO_COL); } } diff --git a/tools/python/generate_ld.py b/tools/python/generate_ld.py index 9a4430b1..e27fc40f 100644 --- a/tools/python/generate_ld.py +++ b/tools/python/generate_ld.py @@ -36,7 +36,7 @@ BSS_LIB_ORDER_FILES = [ class GenerateLD: def __init__(self, file): - print('Generating linker file...') + print('\x1B[32mGenerating linker file: \x1B[0m', end='') self.assets = GenerateAssets(ROOT_DIR, VERSION) self.files = self.get_code_files() self.indentLevel = 0 @@ -47,7 +47,7 @@ class GenerateLD: self.gen_line('OUTPUT_ARCH (mips)') self.gen_newline() self.gen_sections() - print('New linker file created!') + print('\x1B[33m New linker file created!\x1B[0m') def gen_sections(self): self.gen_line('SECTIONS') From 9f2131929ca62768cf81a3128b0cd69ad9cfe757 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Fri, 22 Oct 2021 10:24:42 -0400 Subject: [PATCH 27/41] Updated the printf statements to be a little more proper format for the colours, and fixed a couple of warnings while I was at it. --- tools/n64crc.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/n64crc.c b/tools/n64crc.c index 39cd69cd..c8a5c6cb 100755 --- a/tools/n64crc.c +++ b/tools/n64crc.c @@ -198,38 +198,38 @@ int main(int argc, char **argv) { //Check CIC BootChip cic = N64GetCIC(buffer); - printf(GREEN "BootChip: " NO_COL); + printf("%sBootChip:%s ",GREEN, NO_COL); printf((cic ? YELLOW "CIC-NUS-%d\n" NO_COL : RED "Unknown\n" NO_COL), cic); //Calculate CRC if (N64CalcCRC(crc, buffer)) { - printf(RED "Unable to calculate CRC\n" NO_COL); + printf("%sUnable to calculate CRC%s\n",RED, NO_COL); } else { - printf(GREEN "CRC 1: %s0x%08X " NO_COL, YELLOW, BYTES2LONG(&buffer[N64_CRC1])); - if (crc[0] == BYTES2LONG(&buffer[N64_CRC1])) { - printf(GREEN "Calculated: %s0x%08X " NO_COL, YELLOW, crc[0]); - printf(BLUE "(Good)\n" NO_COL); + printf("%sCRC 1: %s0x%08X%s ", GREEN, BLUE, BYTES2LONG(&buffer[N64_CRC1]), NO_COL); + if (crc[0] == (unsigned int) BYTES2LONG(&buffer[N64_CRC1])) { + printf("%sCalculated: %s0x%08X%s ",GREEN, YELLOW, crc[0], NO_COL); + printf("%s(Good)%s\n",GREEN, NO_COL); } else { - printf(GREEN "Calculated: %s0x%08X " NO_COL, RED, crc[0]); + printf("%sCalculated: %s0x%08X%s ",GREEN, RED, crc[0], NO_COL); Write32(buffer, N64_CRC1, crc[0]); fseek(fin, N64_CRC1, SEEK_SET); fwrite(&buffer[N64_CRC1], 1, 4, fin); - printf(RED "(Bad, fixed)\n" NO_COL); + printf("%s(Bad, fixed)%s\n",RED, NO_COL); } - printf(GREEN "CRC 2: %s0x%08X " NO_COL, YELLOW, BYTES2LONG(&buffer[N64_CRC2])); - if (crc[1] == BYTES2LONG(&buffer[N64_CRC2])) { - printf(GREEN "Calculated: %s0x%08X " NO_COL, YELLOW, crc[1]); - printf(BLUE "(Good)\n" NO_COL); + printf("%sCRC 2: %s0x%08X%s ",GREEN, BLUE, BYTES2LONG(&buffer[N64_CRC2]), NO_COL); + if (crc[1] == (unsigned int) BYTES2LONG(&buffer[N64_CRC2])) { + printf("%sCalculated: %s0x%08X%s ",GREEN, YELLOW, crc[1], NO_COL); + printf("%s(Good)%s\n", GREEN, NO_COL); } else { printf(GREEN "Calculated: %s0x%08X " NO_COL, RED, crc[1]); Write32(buffer, N64_CRC2, crc[1]); fseek(fin, N64_CRC2, SEEK_SET); fwrite(&buffer[N64_CRC2], 1, 4, fin); - printf(RED "(Bad, fixed)\n" NO_COL); + printf("%s(Bad, fixed)%s\n", RED, NO_COL); } } From 98f7cc7b239c3927195844779d9bd66f5d34cb29 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Fri, 22 Oct 2021 10:29:34 -0400 Subject: [PATCH 28/41] Updaed colours again. I'm being picky --- tools/n64crc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/n64crc.c b/tools/n64crc.c index c8a5c6cb..d0baab46 100755 --- a/tools/n64crc.c +++ b/tools/n64crc.c @@ -206,20 +206,20 @@ int main(int argc, char **argv) { printf("%sUnable to calculate CRC%s\n",RED, NO_COL); } else { - printf("%sCRC 1: %s0x%08X%s ", GREEN, BLUE, BYTES2LONG(&buffer[N64_CRC1]), NO_COL); + printf("%sCRC 1: %s0x%08X%s ", GREEN, YELLOW, BYTES2LONG(&buffer[N64_CRC1]), NO_COL); if (crc[0] == (unsigned int) BYTES2LONG(&buffer[N64_CRC1])) { printf("%sCalculated: %s0x%08X%s ",GREEN, YELLOW, crc[0], NO_COL); printf("%s(Good)%s\n",GREEN, NO_COL); } else { - printf("%sCalculated: %s0x%08X%s ",GREEN, RED, crc[0], NO_COL); + printf("%sCalculated: %s0x%08X%s ",GREEN, RED, crc[0], NO_COL); Write32(buffer, N64_CRC1, crc[0]); fseek(fin, N64_CRC1, SEEK_SET); fwrite(&buffer[N64_CRC1], 1, 4, fin); printf("%s(Bad, fixed)%s\n",RED, NO_COL); } - printf("%sCRC 2: %s0x%08X%s ",GREEN, BLUE, BYTES2LONG(&buffer[N64_CRC2]), NO_COL); + printf("%sCRC 2: %s0x%08X%s ",GREEN, YELLOW, BYTES2LONG(&buffer[N64_CRC2]), NO_COL); if (crc[1] == (unsigned int) BYTES2LONG(&buffer[N64_CRC2])) { printf("%sCalculated: %s0x%08X%s ",GREEN, YELLOW, crc[1], NO_COL); printf("%s(Good)%s\n", GREEN, NO_COL); From 6cd9ff34c03f85bf4718ef04c3b48d5ed98faa18 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Fri, 22 Oct 2021 11:19:32 -0400 Subject: [PATCH 29/41] More cic colour work --- tools/n64crc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/n64crc.c b/tools/n64crc.c index d0baab46..630ad55a 100755 --- a/tools/n64crc.c +++ b/tools/n64crc.c @@ -199,7 +199,10 @@ int main(int argc, char **argv) { //Check CIC BootChip cic = N64GetCIC(buffer); printf("%sBootChip:%s ",GREEN, NO_COL); - printf((cic ? YELLOW "CIC-NUS-%d\n" NO_COL : RED "Unknown\n" NO_COL), cic); + if (cic) + printf("%sCIC-NUS-%d%s\n",YELLOW, cic, NO_COL); + else + printf("%sUnknown%s\n", RED, NO_COL); //Calculate CRC if (N64CalcCRC(crc, buffer)) { @@ -208,24 +211,24 @@ int main(int argc, char **argv) { else { printf("%sCRC 1: %s0x%08X%s ", GREEN, YELLOW, BYTES2LONG(&buffer[N64_CRC1]), NO_COL); if (crc[0] == (unsigned int) BYTES2LONG(&buffer[N64_CRC1])) { - printf("%sCalculated: %s0x%08X%s ",GREEN, YELLOW, crc[0], NO_COL); + printf("%sCalculated: %s0x%08X%s ", GREEN, YELLOW, crc[0], NO_COL); printf("%s(Good)%s\n",GREEN, NO_COL); } else { - printf("%sCalculated: %s0x%08X%s ",GREEN, RED, crc[0], NO_COL); + printf("%sCalculated: %s0x%08X%s ", GREEN, RED, crc[0], NO_COL); Write32(buffer, N64_CRC1, crc[0]); fseek(fin, N64_CRC1, SEEK_SET); fwrite(&buffer[N64_CRC1], 1, 4, fin); printf("%s(Bad, fixed)%s\n",RED, NO_COL); } - printf("%sCRC 2: %s0x%08X%s ",GREEN, YELLOW, BYTES2LONG(&buffer[N64_CRC2]), NO_COL); + printf("%sCRC 2: %s0x%08X%s ", GREEN, YELLOW, BYTES2LONG(&buffer[N64_CRC2]), NO_COL); if (crc[1] == (unsigned int) BYTES2LONG(&buffer[N64_CRC2])) { - printf("%sCalculated: %s0x%08X%s ",GREEN, YELLOW, crc[1], NO_COL); + printf("%sCalculated: %s0x%08X%s ", GREEN, YELLOW, crc[1], NO_COL); printf("%s(Good)%s\n", GREEN, NO_COL); } else { - printf(GREEN "Calculated: %s0x%08X " NO_COL, RED, crc[1]); + printf("%sCalculated: %s0x%08X%s ", GREEN, RED, crc[1], NO_COL); Write32(buffer, N64_CRC2, crc[1]); fseek(fin, N64_CRC2, SEEK_SET); fwrite(&buffer[N64_CRC2], 1, 4, fin); From 7e717dae5ed131fb9a0e30066116365376b6ed55 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sat, 23 Oct 2021 20:53:03 -0400 Subject: [PATCH 30/41] Match memory_copy, and fix some warnings --- asm/non_matchings/video/memory_copy.s | 35 --------------------------- include/PR/os_message.h | 1 + lib/src/mips1/al/alSynAllocFX.c | 16 ++++++++---- src/video.c | 31 ++++++++++-------------- src/video.h | 2 +- 5 files changed, 26 insertions(+), 59 deletions(-) delete mode 100644 asm/non_matchings/video/memory_copy.s diff --git a/asm/non_matchings/video/memory_copy.s b/asm/non_matchings/video/memory_copy.s deleted file mode 100644 index 47845cff..00000000 --- a/asm/non_matchings/video/memory_copy.s +++ /dev/null @@ -1,35 +0,0 @@ -glabel memory_copy -/* 07B7FC 8007ABFC 18C00018 */ blez $a2, .L8007AC60 -/* 07B800 8007AC00 00001025 */ move $v0, $zero -/* 07B804 8007AC04 30C70003 */ andi $a3, $a2, 3 -/* 07B808 8007AC08 10E00009 */ beqz $a3, .L8007AC30 -/* 07B80C 8007AC0C 00E01825 */ move $v1, $a3 -.L8007AC10: -/* 07B810 8007AC10 908E0000 */ lbu $t6, ($a0) -/* 07B814 8007AC14 24420001 */ addiu $v0, $v0, 1 -/* 07B818 8007AC18 24A50001 */ addiu $a1, $a1, 1 -/* 07B81C 8007AC1C 24840001 */ addiu $a0, $a0, 1 -/* 07B820 8007AC20 1462FFFB */ bne $v1, $v0, .L8007AC10 -/* 07B824 8007AC24 A0AEFFFF */ sb $t6, -1($a1) -/* 07B828 8007AC28 1046000D */ beq $v0, $a2, .L8007AC60 -/* 07B82C 8007AC2C 00000000 */ nop -.L8007AC30: -/* 07B830 8007AC30 908F0000 */ lbu $t7, ($a0) -/* 07B834 8007AC34 24420004 */ addiu $v0, $v0, 4 -/* 07B838 8007AC38 A0AF0000 */ sb $t7, ($a1) -/* 07B83C 8007AC3C 90980001 */ lbu $t8, 1($a0) -/* 07B840 8007AC40 24A50004 */ addiu $a1, $a1, 4 -/* 07B844 8007AC44 A0B8FFFD */ sb $t8, -3($a1) -/* 07B848 8007AC48 90990002 */ lbu $t9, 2($a0) -/* 07B84C 8007AC4C 24840004 */ addiu $a0, $a0, 4 -/* 07B850 8007AC50 A0B9FFFE */ sb $t9, -2($a1) -/* 07B854 8007AC54 9088FFFF */ lbu $t0, -1($a0) -/* 07B858 8007AC58 1446FFF5 */ bne $v0, $a2, .L8007AC30 -/* 07B85C 8007AC5C A0A8FFFF */ sb $t0, -1($a1) -.L8007AC60: -/* 07B860 8007AC60 03E00008 */ jr $ra -/* 07B864 8007AC64 00000000 */ nop - -/* 07B868 8007AC68 00000000 */ nop -/* 07B86C 8007AC6C 00000000 */ nop - diff --git a/include/PR/os_message.h b/include/PR/os_message.h index 706306d7..6e07dfa4 100644 --- a/include/PR/os_message.h +++ b/include/PR/os_message.h @@ -55,6 +55,7 @@ typedef void * OSMesg; * Structure for message queue */ typedef struct OSMesgQueue_s { + //24 bytes? OSThread *mtqueue; /* Queue to store threads blocked on empty mailboxes (receive) */ OSThread *fullqueue; /* Queue to store threads blocked diff --git a/lib/src/mips1/al/alSynAllocFX.c b/lib/src/mips1/al/alSynAllocFX.c index ff42dc1a..2f4d1622 100644 --- a/lib/src/mips1/al/alSynAllocFX.c +++ b/lib/src/mips1/al/alSynAllocFX.c @@ -6,13 +6,19 @@ #include "audio_internal.h" #ifdef NON_MATCHING +void alFxNew(ALFx *r, ALSynConfig *c, ALHeap *hp); +s32 alFxParam(void *filter, s32 paramID, void *param); +s32 alMainBusParam(void *filter, s32 paramID, void *param); // This is very close to matching. -ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, s32 *arg2) { - alFxNew(&s->auxBus[bus].fx[0], arg2, bus); - alFxParam(&s->auxBus[bus].fx[0], AL_FILTER_SET_SOURCE, &s->auxBus[bus]); - alMainBusParam(s->mainBus, AL_FILTER_ADD_SOURCE, &s->auxBus[bus].fx[0]); +ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp) +{ + alFxNew(&s->auxBus[bus].fx[0], c, hp); + alFxParam(&s->auxBus[bus].fx[0], AL_FILTER_SET_SOURCE, + &s->auxBus[bus]); + alMainBusParam(s->mainBus, AL_FILTER_ADD_SOURCE,&s->auxBus[bus].fx[0]); + return (ALFxRef)(&s->auxBus[bus].fx[0]); } #else GLOBAL_ASM("lib/asm/non_matchings/alSynAllocFX/alSynAllocFX.s") -#endif \ No newline at end of file +#endif diff --git a/src/video.c b/src/video.c index 0048b7a3..52b1f958 100644 --- a/src/video.c +++ b/src/video.c @@ -31,8 +31,10 @@ s32 gVideoRefreshRate; f32 gVideoAspectRatio; f32 gVideoHeightRatio; s32 D_8012617C; -OSMesg D_80126180[8]; -OSMesgQueue D_801261A0[8]; +OSMesg D_80126180; +s32 D_80126188[6]; //Padding? +OSMesgQueue D_801261A0; +s32 D_801261B8[41]; //Padding? OSViMode gTvViMode; s32 gVideoFbWidths[2]; s32 gVideoFbHeights[2]; @@ -49,10 +51,9 @@ s32 D_801262E8[8]; u8 D_80126308; u8 D_80126309; s32 D_8012630C; -OSScClient *D_80126310; +OSScClient D_80126310; /******************************/ - void init_video(s32 videoModeIndex, OSSched *sc) { if (osTvType == TV_TYPE_PAL) { gVideoRefreshRate = REFRESH_50HZ; @@ -142,10 +143,10 @@ void init_vi_settings(void) { memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); if (osTvType == TV_TYPE_PAL) { //A simple osViExtendVStart to add an additional 24 scanlines? - gTvViMode.fldRegs[0].vStart -= (24 << 16); - gTvViMode.fldRegs[1].vStart -= (24 << 16); - gTvViMode.fldRegs[0].vStart += 24; - gTvViMode.fldRegs[1].vStart += 24; + gTvViMode.fldRegs[0].vStart -= (PAL_HEIGHT_DIFFERENCE << 16); + gTvViMode.fldRegs[1].vStart -= (PAL_HEIGHT_DIFFERENCE << 16); + gTvViMode.fldRegs[0].vStart += PAL_HEIGHT_DIFFERENCE; + gTvViMode.fldRegs[1].vStart += PAL_HEIGHT_DIFFERENCE; } osViSetMode(&gTvViMode); break; @@ -296,16 +297,10 @@ void swap_framebuffers(void) { gVideoCurrDepthBuffer = gVideoDepthBuffer; } -#ifdef NON_MATCHING -// regalloc issues -void memory_copy(u8 *src, u8 *dst, s32 numBytes) { +void memory_copy(u8 *src, u8 *dest, s32 len) { s32 i; - for(i = 0; i < numBytes; i++){ - dst[i] = src[i]; + + for(i = 0; i < len; i++) { + *dest++ = *src++; } } -#else -GLOBAL_ASM("asm/non_matchings/video/memory_copy.s") -#endif - - diff --git a/src/video.h b/src/video.h index d184cdbd..bf9a448a 100644 --- a/src/video.h +++ b/src/video.h @@ -63,7 +63,7 @@ s32 func_8007AB34(void); void swap_framebuffers(void); //Non Matching -void memory_copy(u8 *src, u8 *dst, s32 numBytes); +void memory_copy(u8 *src, u8 *dest, s32 len); s32 func_8007A98C(s32 arg0); #endif From 187cde7c1c3a8e6df592d400e9baa6ab71511719 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sat, 23 Oct 2021 21:10:20 -0400 Subject: [PATCH 31/41] Better variables --- src/video.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/video.c b/src/video.c index 52b1f958..3d45f57b 100644 --- a/src/video.c +++ b/src/video.c @@ -31,10 +31,8 @@ s32 gVideoRefreshRate; f32 gVideoAspectRatio; f32 gVideoHeightRatio; s32 D_8012617C; -OSMesg D_80126180; -s32 D_80126188[6]; //Padding? -OSMesgQueue D_801261A0; -s32 D_801261B8[41]; //Padding? +OSMesg D_80126180[8]; +OSMesgQueue D_801261A0[8]; OSViMode gTvViMode; s32 gVideoFbWidths[2]; s32 gVideoFbHeights[2]; @@ -84,11 +82,11 @@ void init_video(s32 videoModeIndex, OSSched *sc) { init_framebuffer(1); gVideoCurrFbIndex = 1; swap_framebuffers(); - osCreateMesgQueue(&D_801261A0, &D_80126180, 8); - osScAddClient(sc, &D_80126310, &D_801261A0, 2); + osCreateMesgQueue((OSMesgQueue *)&D_801261A0, (OSMesg *)&D_80126180, 8); + osScAddClient(sc, &D_80126310, (OSMesgQueue *)&D_801261A0, 2); init_vi_settings(); D_801262D0 = 12; - osViBlack(1); + osViBlack(TRUE); D_80126308 = 0; D_801262E4 = 3; } @@ -242,7 +240,7 @@ s32 func_8007A98C(s32 arg0) { if (D_801262D0 != 0) { D_801262D0--; if (D_801262D0 == 0) { - osViBlack(0); + osViBlack(FALSE); } } if (arg0 != 8) { From 2671406cd0bc29a2f2c9d25030cf79b6c1126c9e Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sun, 24 Oct 2021 21:27:24 -0400 Subject: [PATCH 32/41] Update diff.py, and the permuter settings --- src/object_models.c | 2 +- tools/permuter_settings.toml | 2 +- tools/python/diff.py | 40 ++++++++++++++++++++++++++++-------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/object_models.c b/src/object_models.c index 44fb3913..90a1220d 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -10,7 +10,7 @@ /************ .data ************/ -s32 D_800DCEA0 = 116315; +s32 D_800DCEA0 = 116315; //func_80024D54 checksum s32 D_800DCEA4 = 1980; /*******************************/ diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index 860e1502..d01b1d9e 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -4,4 +4,4 @@ "_SHIFTL" = "unsigned int" [decompme.compilers] -"tools/ido5.3_recomp/cc" = "ido5.3" +"tools/ido-static-recomp/build5.3/out/cc" = "ido5.3" diff --git a/tools/python/diff.py b/tools/python/diff.py index 2f601806..22dff4eb 100644 --- a/tools/python/diff.py +++ b/tools/python/diff.py @@ -488,7 +488,11 @@ def get_objdump_executable(objdump_executable: Optional[str]) -> str: if objdump_executable is not None: return objdump_executable - objdump_candidates = ["mips-linux-gnu-objdump", "mips64-elf-objdump", "mips-elf-objdump"] + objdump_candidates = [ + "mips-linux-gnu-objdump", + "mips64-elf-objdump", + "mips-elf-objdump", + ] for objdump_cand in objdump_candidates: try: subprocess.check_call( @@ -636,6 +640,7 @@ class Text: class TableMetadata: headers: Tuple[Text, ...] current_score: int + max_score: int previous_score: Optional[int] @@ -828,6 +833,7 @@ class JsonFormatter(Formatter): for h, name in zip(meta.headers, ("base", "current", "previous")) } output["current_score"] = meta.current_score + output["max_score"] = meta.max_score if meta.previous_score is not None: output["previous_score"] = meta.previous_score output_rows: List[Dict[str, Any]] = [] @@ -1423,7 +1429,7 @@ class ArchSettings: branch_likely_instructions: Set[str] = field(default_factory=set) difference_normalizer: Type[DifferenceNormalizer] = DifferenceNormalizer big_endian: Optional[bool] = True - + delay_slot_instructions: Set[str] = field(default_factory=set) MIPS_BRANCH_LIKELY_INSTRUCTIONS = { "beql", @@ -1481,7 +1487,6 @@ ARM32_BRANCH_INSTRUCTIONS = { } AARCH64_BRANCH_INSTRUCTIONS = { - "bl", "b", "b.eq", "b.ne", @@ -1535,7 +1540,7 @@ MIPS_SETTINGS = ArchSettings( re_int=re.compile(r"[0-9]+"), re_comment=re.compile(r"<.*?>"), re_reg=re.compile( - r"\$?\b(a[0-3]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|k[01]|fp|ra|zero)\b" + r"\$?\b(a[0-7]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|kt?[01]|fp|ra|zero)\b" ), re_sprel=re.compile(r"(?<=,)([0-9]+|0x[0-9a-f]+)\(sp\)"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), @@ -1544,6 +1549,7 @@ MIPS_SETTINGS = ArchSettings( branch_likely_instructions=MIPS_BRANCH_LIKELY_INSTRUCTIONS, branch_instructions=MIPS_BRANCH_INSTRUCTIONS, instructions_with_address_immediates=MIPS_BRANCH_INSTRUCTIONS.union({"jal", "j"}), + delay_slot_instructions=MIPS_BRANCH_INSTRUCTIONS.union({"j", "jal", "jr", "jalr"}), ) MIPSEL_SETTINGS = replace(MIPS_SETTINGS, name="mipsel", big_endian=False) @@ -1579,7 +1585,7 @@ AARCH64_SETTINGS = ArchSettings( re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(? Tuple[str, str, str]: def process_mips_reloc(row: str, prev: str, arch: ArchSettings) -> str: + if "R_MIPS_NONE" in row: + # GNU as emits no-op relocations immediately after real ones when + # assembling with -mabi=64. Return without trying to parse 'imm' as an + # integer. + return prev before, imm, after = parse_relocated_line(prev) repl = row.split()[-1] if imm != "0": @@ -2115,8 +2126,15 @@ class OutputLine: class Diff: lines: List[OutputLine] score: int + max_score: int +def trim_nops(lines: List[Line], arch: ArchSettings) -> List[Line]: + lines = lines[:] + while lines and lines[-1].mnemonic == "nop" and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions): + lines.pop() + return lines + def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: if config.show_source: import cxxfilt @@ -2144,8 +2162,12 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: btset.add(bt) sc(str(bt)) + lines1 = trim_nops(lines1, arch) + lines2 = trim_nops(lines2, arch) + diffed_lines = diff_lines(lines1, lines2, config.algorithm) score = score_diff_lines(diffed_lines, config) + max_score = len(lines1) * config.penalty_deletion line_num_base = -1 line_num_offset = 0 @@ -2376,7 +2398,8 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: ) ) - return Diff(lines=output, score=score) + output = output[config.skip_lines :] + return Diff(lines=output, score=score, max_score=max_score) def chunk_diff_lines( @@ -2452,6 +2475,7 @@ def align_diffs( Text(f"{padding}PREVIOUS ({old_diff.score})"), ), current_score=new_diff.score, + max_score=new_diff.max_score, previous_score=old_diff.score, ) old_chunks = chunk_diff_lines(old_diff.lines) @@ -2495,6 +2519,7 @@ def align_diffs( Text(f"{padding}CURRENT ({new_diff.score})"), ), current_score=new_diff.score, + max_score=new_diff.max_score, previous_score=None, ) diff_lines = [(line, line) for line in new_diff.lines] @@ -2609,10 +2634,9 @@ class Display: self.last_diff_output = diff_output meta, diff_lines = align_diffs(last_diff_output, diff_output, self.config) - diff_lines = diff_lines[self.config.skip_lines :] output = self.config.formatter.table(meta, diff_lines) refresh_key = ( - [[col.key2 for col in x[1:]] for x in diff_lines], + [line.key2 for line in diff_output.lines], diff_output.score, ) return (output, refresh_key) From a3f1ed5821f85573cef57a15f3a29afc6680caad Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sun, 24 Oct 2021 22:09:53 -0400 Subject: [PATCH 33/41] Match func_800AD40C --- .gitignore | 1 + .../unknown_09F8F0/func_800AD40C.s | 47 ------------------- src/unknown_008C40.h | 1 + src/unknown_0ABDF0.c | 14 +++--- src/unknown_0ABDF0.h | 1 + 5 files changed, 9 insertions(+), 55 deletions(-) delete mode 100644 asm/non_matchings/unknown_09F8F0/func_800AD40C.s diff --git a/.gitignore b/.gitignore index f1901f2f..8ee542b7 100755 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ dkr.ld # CTX files for mips2c should be ignored as we generate those ctx.c ctx_includes.c +ctx.c.m2c # Misc stuff that should be ignored. .*/ diff --git a/asm/non_matchings/unknown_09F8F0/func_800AD40C.s b/asm/non_matchings/unknown_09F8F0/func_800AD40C.s deleted file mode 100644 index 56252cb2..00000000 --- a/asm/non_matchings/unknown_09F8F0/func_800AD40C.s +++ /dev/null @@ -1,47 +0,0 @@ -glabel func_800AD40C -/* 0AE00C 800AD40C 3C0E800E */ lui $t6, %hi(D_800E2C5C) # $t6, 0x800e -/* 0AE010 800AD410 8DCE2C5C */ lw $t6, %lo(D_800E2C5C)($t6) -/* 0AE014 800AD414 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0AE018 800AD418 11C00020 */ beqz $t6, .L800AD49C -/* 0AE01C 800AD41C AFBF001C */ sw $ra, 0x1c($sp) -/* 0AE020 800AD420 0C019884 */ jal get_viewport_count -/* 0AE024 800AD424 00000000 */ nop -/* 0AE028 800AD428 1440001C */ bnez $v0, .L800AD49C -/* 0AE02C 800AD42C 00002025 */ move $a0, $zero -/* 0AE030 800AD430 3C02800E */ lui $v0, %hi(D_800E2C60) # $v0, 0x800e -/* 0AE034 800AD434 8C422C60 */ lw $v0, %lo(D_800E2C60)($v0) -/* 0AE038 800AD438 240A000F */ li $t2, 15 -/* 0AE03C 800AD43C 00020823 */ negu $at, $v0 -/* 0AE040 800AD440 00011880 */ sll $v1, $at, 2 -/* 0AE044 800AD444 00611821 */ addu $v1, $v1, $at -/* 0AE048 800AD448 00031880 */ sll $v1, $v1, 2 -/* 0AE04C 800AD44C 00014080 */ sll $t0, $at, 2 -/* 0AE050 800AD450 00611823 */ subu $v1, $v1, $at -/* 0AE054 800AD454 01014021 */ addu $t0, $t0, $at -/* 0AE058 800AD458 00031840 */ sll $v1, $v1, 1 -/* 0AE05C 800AD45C 00084080 */ sll $t0, $t0, 2 -/* 0AE060 800AD460 00037C03 */ sra $t7, $v1, 0x10 -/* 0AE064 800AD464 0008C403 */ sra $t8, $t0, 0x10 -/* 0AE068 800AD468 25E303FA */ addiu $v1, $t7, 0x3fa -/* 0AE06C 800AD46C 270803FF */ addiu $t0, $t8, 0x3ff -/* 0AE070 800AD470 00083400 */ sll $a2, $t0, 0x10 -/* 0AE074 800AD474 00032C00 */ sll $a1, $v1, 0x10 -/* 0AE078 800AD478 0005CC03 */ sra $t9, $a1, 0x10 -/* 0AE07C 800AD47C 00064C03 */ sra $t1, $a2, 0x10 -/* 0AE080 800AD480 240B0024 */ li $t3, 36 -/* 0AE084 800AD484 AFAB0014 */ sw $t3, 0x14($sp) -/* 0AE088 800AD488 01203025 */ move $a2, $t1 -/* 0AE08C 800AD48C 03202825 */ move $a1, $t9 -/* 0AE090 800AD490 AFAA0010 */ sw $t2, 0x10($sp) -/* 0AE094 800AD494 0C00C199 */ jal func_80030664 -/* 0AE098 800AD498 2407001C */ li $a3, 28 -.L800AD49C: -/* 0AE09C 800AD49C 8FBF001C */ lw $ra, 0x1c($sp) -/* 0AE0A0 800AD4A0 27BD0020 */ addiu $sp, $sp, 0x20 -/* 0AE0A4 800AD4A4 03E00008 */ jr $ra -/* 0AE0A8 800AD4A8 00000000 */ nop - -/* 0AE0AC 800AD4AC 3C01800E */ lui $at, %hi(D_800E2C6C) # $at, 0x800e -/* 0AE0B0 800AD4B0 03E00008 */ jr $ra -/* 0AE0B4 800AD4B4 AC242C6C */ sw $a0, %lo(D_800E2C6C)($at) - diff --git a/src/unknown_008C40.h b/src/unknown_008C40.h index cca7f10e..98955b84 100644 --- a/src/unknown_008C40.h +++ b/src/unknown_008C40.h @@ -5,6 +5,7 @@ void func_80008168(void); +void func_800096F8(s32); // Non Matching void func_80009558(u16, f32 x, f32 y, f32 z, s32, s32 *); // Non Matching void func_80009968(f32, f32, f32, u8, u8, s32); // Non Matching void func_800096D8(s32, f32, f32, f32); // Non Matching diff --git a/src/unknown_0ABDF0.c b/src/unknown_0ABDF0.c index 76fe4df7..9aaf92bb 100644 --- a/src/unknown_0ABDF0.c +++ b/src/unknown_0ABDF0.c @@ -8,6 +8,8 @@ #include "f3ddkr.h" #include "PR/libultra.h" #include "camera.h" +#include "unknown_0255E0.h" +#include "unknown_008C40.h" /************ .data ************/ @@ -233,13 +235,12 @@ void func_800AD2C4(s32 arg0, s32 arg1, f32 arg2) { D_800E2C70 = (D_800E2C74 - D_800E2C6C) / D_800E2C78; } -#ifdef NON_MATCHING void func_800AD40C(void) { - s16 a, b; + s32 a, b; if (D_800E2C5C && !get_viewport_count()) { - a = ((-D_800E2C60 * 38) >> 16) + 1018; - b = ((-D_800E2C60 * 20) >> 16) + 1023; - func_80030664(0, a, b, 28, 15, 36); + a = ((D_800E2C60 * -38) >> 16) + 0x3FA; + b = ((D_800E2C60 * -20) >> 16) + 0x3FF; + func_80030664(0, a, b, 0x1CU, 0xFU, 0x24U); } } @@ -247,9 +248,6 @@ void func_800AD40C(void) { void func_800AD4AC(s32 arg0) { D_800E2C6C = arg0; } -#else -GLOBAL_ASM("asm/non_matchings/unknown_09F8F0/func_800AD40C.s") -#endif GLOBAL_ASM("asm/non_matchings/unknown_09F8F0/func_800AD4B8.s") GLOBAL_ASM("asm/non_matchings/unknown_09F8F0/func_800AD658.s") diff --git a/src/unknown_0ABDF0.h b/src/unknown_0ABDF0.h index 1b8cc70f..e1d883c7 100644 --- a/src/unknown_0ABDF0.h +++ b/src/unknown_0ABDF0.h @@ -68,5 +68,6 @@ void func_800AC880(s32 arg0); void func_800ACF60(Object *arg0); void func_800AD220(void); void func_800AD2C4(s32 arg0, s32 arg1, f32 arg2); +void func_800AD40C(void); #endif From b3173b9b87f8f3be80985de8da2dcb8249bd5ad4 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sun, 24 Oct 2021 22:26:13 -0400 Subject: [PATCH 34/41] Match func_800096F8 --- .../unknown_005740/func_800096F8.s | 26 ------------------- src/unknown_008C40.c | 20 +++++++++++++- src/unknown_008C40.h | 4 +-- 3 files changed, 21 insertions(+), 29 deletions(-) delete mode 100644 asm/non_matchings/unknown_005740/func_800096F8.s diff --git a/asm/non_matchings/unknown_005740/func_800096F8.s b/asm/non_matchings/unknown_005740/func_800096F8.s deleted file mode 100644 index 985145fa..00000000 --- a/asm/non_matchings/unknown_005740/func_800096F8.s +++ /dev/null @@ -1,26 +0,0 @@ -glabel func_800096F8 -/* 00A2F8 800096F8 3C028012 */ lui $v0, %hi(D_80119C44) # $v0, 0x8012 -/* 00A2FC 800096FC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 00A300 80009700 8C429C44 */ lw $v0, %lo(D_80119C44)($v0) -/* 00A304 80009704 AFBF0014 */ sw $ra, 0x14($sp) -/* 00A308 80009708 00002825 */ move $a1, $zero -/* 00A30C 8000970C 24030028 */ li $v1, 40 -.L80009710: -/* 00A310 80009710 8C4E0000 */ lw $t6, ($v0) -/* 00A314 80009714 00000000 */ nop -/* 00A318 80009718 148E0005 */ bne $a0, $t6, .L80009730 -/* 00A31C 8000971C 00000000 */ nop -/* 00A320 80009720 0C0028BA */ jal func_8000A2E8 -/* 00A324 80009724 00A02025 */ move $a0, $a1 -/* 00A328 80009728 10000005 */ b .L80009740 -/* 00A32C 8000972C 8FBF0014 */ lw $ra, 0x14($sp) -.L80009730: -/* 00A330 80009730 24A50001 */ addiu $a1, $a1, 1 -/* 00A334 80009734 14A3FFF6 */ bne $a1, $v1, .L80009710 -/* 00A338 80009738 24420004 */ addiu $v0, $v0, 4 -/* 00A33C 8000973C 8FBF0014 */ lw $ra, 0x14($sp) -.L80009740: -/* 00A340 80009740 27BD0018 */ addiu $sp, $sp, 0x18 -/* 00A344 80009744 03E00008 */ jr $ra -/* 00A348 80009748 00000000 */ nop - diff --git a/src/unknown_008C40.c b/src/unknown_008C40.c index eb349e09..e205194a 100644 --- a/src/unknown_008C40.c +++ b/src/unknown_008C40.c @@ -48,7 +48,25 @@ GLOBAL_ASM("asm/non_matchings/unknown_005740/func_800092A8.s") GLOBAL_ASM("asm/non_matchings/unknown_005740/func_80009558.s") GLOBAL_ASM("asm/non_matchings/unknown_005740/func_800095E8.s") GLOBAL_ASM("asm/non_matchings/unknown_005740/func_800096D8.s") -GLOBAL_ASM("asm/non_matchings/unknown_005740/func_800096F8.s") +void func_800096F8(s32 arg0) { + s32 temp_a1; + s32* phi_v0; + s32 phi_a1; + + phi_v0 = D_80119C44; + phi_a1 = 0; + while (1) { + if (arg0 == *phi_v0) { + func_8000A2E8(phi_a1); + return; + } + phi_v0++; + phi_a1++; + if (phi_a1 == 0x28) { + return; + } + } +} GLOBAL_ASM("asm/non_matchings/unknown_005740/func_8000974C.s") GLOBAL_ASM("asm/non_matchings/unknown_005740/func_800098A4.s") GLOBAL_ASM("asm/non_matchings/unknown_005740/func_80009968.s") diff --git a/src/unknown_008C40.h b/src/unknown_008C40.h index 98955b84..5bd9c30b 100644 --- a/src/unknown_008C40.h +++ b/src/unknown_008C40.h @@ -2,10 +2,10 @@ #define _UNKNOWN_008C40_H_ #include "types.h" - +extern s32 *D_80119C44; void func_80008168(void); +void func_800096F8(s32); -void func_800096F8(s32); // Non Matching void func_80009558(u16, f32 x, f32 y, f32 z, s32, s32 *); // Non Matching void func_80009968(f32, f32, f32, u8, u8, s32); // Non Matching void func_800096D8(s32, f32, f32, f32); // Non Matching From 0856d96a4ea0f36099996d175d8250f0f22be7af Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Sun, 24 Oct 2021 22:32:32 -0400 Subject: [PATCH 35/41] BEtter match --- src/unknown_008C40.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/unknown_008C40.c b/src/unknown_008C40.c index e205194a..411972d7 100644 --- a/src/unknown_008C40.c +++ b/src/unknown_008C40.c @@ -49,22 +49,14 @@ GLOBAL_ASM("asm/non_matchings/unknown_005740/func_80009558.s") GLOBAL_ASM("asm/non_matchings/unknown_005740/func_800095E8.s") GLOBAL_ASM("asm/non_matchings/unknown_005740/func_800096D8.s") void func_800096F8(s32 arg0) { - s32 temp_a1; - s32* phi_v0; - s32 phi_a1; - - phi_v0 = D_80119C44; - phi_a1 = 0; - while (1) { - if (arg0 == *phi_v0) { - func_8000A2E8(phi_a1); - return; - } - phi_v0++; - phi_a1++; - if (phi_a1 == 0x28) { - return; + s32 i; + s32 *v0 = D_80119C44; + for (i = 0; i < 40; i++) { + if (arg0 == *v0) { + func_8000A2E8(i); + break; } + v0++; } } GLOBAL_ASM("asm/non_matchings/unknown_005740/func_8000974C.s") From 71cf2f8b6182cf024b21510156a2e58a4ea5b4b2 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Mon, 25 Oct 2021 22:23:02 -0400 Subject: [PATCH 36/41] Found a medicore match for func_800A1428 --- .../unknown_09F8F0/func_800A26C8.s | 49 ------------------- include/structs.h | 4 +- src/unknown_09F8F0.c | 20 +++++++- src/unknown_09F8F0.h | 6 +++ 4 files changed, 27 insertions(+), 52 deletions(-) delete mode 100644 asm/non_matchings/unknown_09F8F0/func_800A26C8.s diff --git a/asm/non_matchings/unknown_09F8F0/func_800A26C8.s b/asm/non_matchings/unknown_09F8F0/func_800A26C8.s deleted file mode 100644 index 352eaf03..00000000 --- a/asm/non_matchings/unknown_09F8F0/func_800A26C8.s +++ /dev/null @@ -1,49 +0,0 @@ -glabel func_800A26C8 -/* 0A32C8 800A26C8 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0A32CC 800A26CC AFBF0014 */ sw $ra, 0x14($sp) -/* 0A32D0 800A26D0 AFA40020 */ sw $a0, 0x20($sp) -/* 0A32D4 800A26D4 0C019884 */ jal get_viewport_count -/* 0A32D8 800A26D8 AFA50024 */ sw $a1, 0x24($sp) -/* 0A32DC 800A26DC 14400024 */ bnez $v0, .L800A2770 -/* 0A32E0 800A26E0 8FBF0014 */ lw $ra, 0x14($sp) -/* 0A32E4 800A26E4 8FAE0020 */ lw $t6, 0x20($sp) -/* 0A32E8 800A26E8 24040001 */ li $a0, 1 -/* 0A32EC 800A26EC 8DCF0064 */ lw $t7, 0x64($t6) -/* 0A32F0 800A26F0 0C01A142 */ jal func_80068508 -/* 0A32F4 800A26F4 AFAF001C */ sw $t7, 0x1c($sp) -/* 0A32F8 800A26F8 8FA4001C */ lw $a0, 0x1c($sp) -/* 0A32FC 800A26FC 0C029C63 */ jal func_800A718C -/* 0A3300 800A2700 00000000 */ nop -/* 0A3304 800A2704 8FA40020 */ lw $a0, 0x20($sp) -/* 0A3308 800A2708 8FA50024 */ lw $a1, 0x24($sp) -/* 0A330C 800A270C 0C028E21 */ jal func_800A3884 -/* 0A3310 800A2710 00000000 */ nop -/* 0A3314 800A2714 0C027B20 */ jal is_in_two_player_adventure -/* 0A3318 800A2718 00000000 */ nop -/* 0A331C 800A271C 10400011 */ beqz $v0, .L800A2764 -/* 0A3320 800A2720 3C078012 */ lui $a3, %hi(D_80126CDC) # $a3, 0x8012 -/* 0A3324 800A2724 8CE76CDC */ lw $a3, %lo(D_80126CDC)($a3) -/* 0A3328 800A2728 00000000 */ nop -/* 0A332C 800A272C 24E70720 */ addiu $a3, $a3, 0x720 -/* 0A3330 800A2730 0C01BAA4 */ jal get_settings -/* 0A3334 800A2734 AFA70018 */ sw $a3, 0x18($sp) -/* 0A3338 800A2738 80580071 */ lb $t8, 0x71($v0) -/* 0A333C 800A273C 8FA70018 */ lw $a3, 0x18($sp) -/* 0A3340 800A2740 3C048012 */ lui $a0, %hi(D_80126CFC) # $a0, 0x8012 -/* 0A3344 800A2744 3C058012 */ lui $a1, %hi(D_80126D00) # $a1, 0x8012 -/* 0A3348 800A2748 3C068012 */ lui $a2, %hi(D_80126D04) # $a2, 0x8012 -/* 0A334C 800A274C 27190038 */ addiu $t9, $t8, 0x38 -/* 0A3350 800A2750 24C66D04 */ addiu $a2, %lo(D_80126D04) # addiu $a2, $a2, 0x6d04 -/* 0A3354 800A2754 24A56D00 */ addiu $a1, %lo(D_80126D00) # addiu $a1, $a1, 0x6d00 -/* 0A3358 800A2758 24846CFC */ addiu $a0, %lo(D_80126CFC) # addiu $a0, $a0, 0x6cfc -/* 0A335C 800A275C 0C02A980 */ jal func_800AA600 -/* 0A3360 800A2760 A4F90006 */ sh $t9, 6($a3) -.L800A2764: -/* 0A3364 800A2764 0C01A142 */ jal func_80068508 -/* 0A3368 800A2768 00002025 */ move $a0, $zero -/* 0A336C 800A276C 8FBF0014 */ lw $ra, 0x14($sp) -.L800A2770: -/* 0A3370 800A2770 27BD0020 */ addiu $sp, $sp, 0x20 -/* 0A3374 800A2774 03E00008 */ jr $ra -/* 0A3378 800A2778 00000000 */ nop - diff --git a/include/structs.h b/include/structs.h index 0656cd19..f19d4c1a 100644 --- a/include/structs.h +++ b/include/structs.h @@ -100,9 +100,9 @@ typedef struct DrawTexture { typedef struct Racer { /* 0x00 */ u32 trophy_points; /* 0x04 */ s8 best_times; - /* 0x05 */ u8 character; + /* 0x05 */ s8 character; /* 0x06 */ s8 starting_position; - /* 0x07 */ char unk7; + /* 0x07 */ s8 unk7; /* 0x08 */ u16 placements[4]; /* 0x10 */ u16 course_time; /* 0x12 */ u16 lap_times[3]; diff --git a/src/unknown_09F8F0.c b/src/unknown_09F8F0.c index f67a0df0..f65bc2b2 100644 --- a/src/unknown_09F8F0.c +++ b/src/unknown_09F8F0.c @@ -7,6 +7,7 @@ #include "structs.h" #include "f3ddkr.h" #include "camera.h" +#include "unknown_06B2B0.h" extern u32 osTvType; @@ -353,7 +354,24 @@ void func_800A263C(s32 arg0, unk800A0DC0 *arg1, s32 arg2) { func_80068508(0); } -GLOBAL_ASM("asm/non_matchings/unknown_09F8F0/func_800A26C8.s") +void func_800A26C8(Object *arg0, s32 arg1) { + Object_64 *sp1C; + unk800A26C8 *temp_a3; + + if (get_viewport_count() == 0) { + sp1C = arg0->unk64; + func_80068508(1); + func_800A718C(sp1C); + func_800A3884(arg0, arg1); + if (is_in_two_player_adventure()) { + temp_a3 = D_80126CDC + 1; + temp_a3->unk6 = (get_settings()->racers[1].character + 0x38); + func_800AA600(&D_80126CFC, &D_80126D00, &D_80126D04, temp_a3); + } + func_80068508(0); + } +} + GLOBAL_ASM("asm/non_matchings/unknown_09F8F0/func_800A277C.s") GLOBAL_ASM("asm/non_matchings/unknown_09F8F0/func_800A36CC.s") diff --git a/src/unknown_09F8F0.h b/src/unknown_09F8F0.h index 8c1c60c1..d3b2b73d 100644 --- a/src/unknown_09F8F0.h +++ b/src/unknown_09F8F0.h @@ -9,6 +9,8 @@ typedef struct { u16 unk4C4; u8 unk4C6[0x1B4]; s8 unk67A; + s8 unk67B[0xA4]; + s8 unk720; } unk80126CDC; typedef struct { @@ -49,6 +51,10 @@ typedef struct { unk800A0DC0_2 *unk64; } unk800A0DC0; +typedef struct { + u8 pad[0x5]; + s16 unk6; +} unk800A26C8; u8 func_800A0190(void); void func_800A0B74(void); From 8c0c1e2b2177f6473f1734936236dafb6dfff52c Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Mon, 25 Oct 2021 22:29:21 -0400 Subject: [PATCH 37/41] Slightly better var names --- src/unknown_09F8F0.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/unknown_09F8F0.c b/src/unknown_09F8F0.c index f65bc2b2..ec10c913 100644 --- a/src/unknown_09F8F0.c +++ b/src/unknown_09F8F0.c @@ -354,15 +354,15 @@ void func_800A263C(s32 arg0, unk800A0DC0 *arg1, s32 arg2) { func_80068508(0); } -void func_800A26C8(Object *arg0, s32 arg1) { - Object_64 *sp1C; +void func_800A26C8(Object *obj, s32 arg1) { + Object_64 *obj64; unk800A26C8 *temp_a3; if (get_viewport_count() == 0) { - sp1C = arg0->unk64; + obj64 = obj->unk64; func_80068508(1); - func_800A718C(sp1C); - func_800A3884(arg0, arg1); + func_800A718C(obj64); + func_800A3884(obj, arg1); if (is_in_two_player_adventure()) { temp_a3 = D_80126CDC + 1; temp_a3->unk6 = (get_settings()->racers[1].character + 0x38); From 95ad10a2b31f70d6a607a288a7925d8005791af4 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Mon, 25 Oct 2021 22:38:31 -0400 Subject: [PATCH 38/41] Update score --- README.md | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 8bcf9655..46554e7c 100755 --- a/README.md +++ b/README.md @@ -113,30 +113,31 @@ s32 is_drumstick_unlocked(void) { } ``` -As of October 15th 2021, this is our current score: +As of October 25th 2021, this is our current score: ``` - =================================================================== - ADVENTURE ONE (ASM -> C Decompilation) - ------------------------- 17.77% Complete ------------------------- - # Decompiled functions: 972 - # GLOBAL_ASM remaining: 786 - # NON_MATCHING functions: 104 - --------------------------- Game Status --------------------------- - Balloons: 9/47, Keys: 1/4, Trophies: 0/5 - T.T. Amulets: 1/4, Wizpig Amulets: 0/4 - ------------------------------------------------------------------- - We are collecting silver coins in Fossil Canyon. (6/8 silver coins) - =================================================================== - ADVENTURE TWO (Cleanup & Documentation) - ------------------------- 0.80% Complete ------------------------- - # Documented functions: 65 - # Undocumented remaining: 1693 - --------------------------- Game Status --------------------------- - Balloons: 0/47, Keys: 0/4, Trophies: 0/5 - T.T. Amulets: 0/4, Wizpig Amulets: 0/4 - ------------------------------------------------------------------- - We are collecting the first balloon on Timber's Island. - =================================================================== + ================================================================== + ADVENTURE ONE (ASM -> C Decompilation) + ------------------------ 18.87% Complete ------------------------- + # Decompiled functions: 996 + # GLOBAL_ASM remaining: 760 + # NON_MATCHING functions: 101 + -------------------------- Game Status --------------------------- + Balloons: 10/47, Keys: 1/4, Trophies: 0/5 + T.T. Amulets: 1/4, Wizpig Amulets: 0/4 + ------------------------------------------------------------------ + We are collecting silver coins in Jungle Falls. (4/8 silver coins) + ================================================================== + ADVENTURE TWO (Cleanup & Documentation) + ------------------------ 0.80% Complete ------------------------- + # Documented functions: 65 + # Undocumented remaining: 1691 + -------------------------- Game Status --------------------------- + Balloons: 0/47, Keys: 0/4, Trophies: 0/5 + T.T. Amulets: 0/4, Wizpig Amulets: 0/4 + ------------------------------------------------------------------ + We are collecting the first balloon on Timber's Island. + ================================================================== + ``` From 967b2a0a3265c3134695d8e3ddeb3c001cec9726 Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Tue, 26 Oct 2021 07:38:30 -0400 Subject: [PATCH 39/41] Fix warnings for func_800A26C8 --- src/unknown_09F8F0.c | 4 ++-- src/unknown_09F8F0.h | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/unknown_09F8F0.c b/src/unknown_09F8F0.c index ec10c913..3f3dc492 100644 --- a/src/unknown_09F8F0.c +++ b/src/unknown_09F8F0.c @@ -356,7 +356,7 @@ void func_800A263C(s32 arg0, unk800A0DC0 *arg1, s32 arg2) { void func_800A26C8(Object *obj, s32 arg1) { Object_64 *obj64; - unk800A26C8 *temp_a3; + unk80126CDC *temp_a3; if (get_viewport_count() == 0) { obj64 = obj->unk64; @@ -364,7 +364,7 @@ void func_800A26C8(Object *obj, s32 arg1) { func_800A718C(obj64); func_800A3884(obj, arg1); if (is_in_two_player_adventure()) { - temp_a3 = D_80126CDC + 1; + temp_a3 = &D_80126CDC[1]; temp_a3->unk6 = (get_settings()->racers[1].character + 0x38); func_800AA600(&D_80126CFC, &D_80126D00, &D_80126D04, temp_a3); } diff --git a/src/unknown_09F8F0.h b/src/unknown_09F8F0.h index d3b2b73d..17e6d981 100644 --- a/src/unknown_09F8F0.h +++ b/src/unknown_09F8F0.h @@ -5,7 +5,9 @@ #include "structs.h" typedef struct { - u8 unk0[0x4C4]; + u8 unk0[0x6]; + s16 unk6; + u8 unk8[0x4BC]; u16 unk4C4; u8 unk4C6[0x1B4]; s8 unk67A; @@ -51,11 +53,6 @@ typedef struct { unk800A0DC0_2 *unk64; } unk800A0DC0; -typedef struct { - u8 pad[0x5]; - s16 unk6; -} unk800A26C8; - u8 func_800A0190(void); void func_800A0B74(void); void func_800A0DC0(s32 arg0, unk800A0DC0 *arg1, s32 arg2); From 8fdf8449d31f1026f085afdfd6e52c1df66882ff Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Tue, 26 Oct 2021 14:08:52 -0400 Subject: [PATCH 40/41] Add a fancy ascii art OK to make --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fea23ee5..b3c9f321 100755 --- a/Makefile +++ b/Makefile @@ -485,9 +485,12 @@ $(BUILD_DIR)/$(TARGET).z64: $(BUILD_DIR)/$(TARGET).bin | $(ALL_ASSETS_BUILT) $(V)$(FIXCHECKSUMS) $(V)$(N64CRC) $@ ifeq ($(NON_MATCHING),0) - $(V)sha1sum -c --quiet sha1/dkr.$(VERSION).sha1 + @(sha1sum -c --quiet sha1/dkr.$(VERSION).sha1 \ + && $(PRINT) "$(BLUE)$@$(NO_COL)\ + : $(GREEN)OK$(NO_COL)\n") + @$(PRINT) "$(YELLOW) __\n .\`_ _\`.\n| | \`| | |\n| |_|._| |\n \`. __ .\'$(NO_COL)\n\n" else - @echo "Build complete!" + @$(PRINT) "$(GREEN)Build Complete!$(NO_COL)\n" endif $(BUILD_DIR)/$(TARGET).hex: $(BUILD_DIR)/$(TARGET).z64 From 5256433f97966c15424de619757a8302edd1955f Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Tue, 26 Oct 2021 15:20:05 -0400 Subject: [PATCH 41/41] Add newlines to fix warnings --- lib/src/mips1/al/alSynStartVoiceParams.h | 2 +- src/unknown_05DCD0.h | 2 +- src/unknown_05F690.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/mips1/al/alSynStartVoiceParams.h b/lib/src/mips1/al/alSynStartVoiceParams.h index ea8a1370..bf8ad32b 100644 --- a/lib/src/mips1/al/alSynStartVoiceParams.h +++ b/lib/src/mips1/al/alSynStartVoiceParams.h @@ -14,4 +14,4 @@ enum StereoPanMode { void set_stereo_pan_mode(s32 panMode); s32 modify_panning(s32 pan); -#endif \ No newline at end of file +#endif diff --git a/src/unknown_05DCD0.h b/src/unknown_05DCD0.h index faa71f5f..40159fbf 100644 --- a/src/unknown_05DCD0.h +++ b/src/unknown_05DCD0.h @@ -6,4 +6,4 @@ extern s16 D_800DCE00[16]; extern s16 D_800DCE20[16]; -#endif \ No newline at end of file +#endif diff --git a/src/unknown_05F690.h b/src/unknown_05F690.h index 9b0d4e8c..e40a4f59 100644 --- a/src/unknown_05F690.h +++ b/src/unknown_05F690.h @@ -5,4 +5,4 @@ extern s16 D_800DCE60[14]; -#endif \ No newline at end of file +#endif