diff --git a/asm/Kyoto/Basics/RAssertDolphin.s b/asm/Kyoto/Basics/RAssertDolphin.s index 39061b4f..5b641490 100644 --- a/asm/Kyoto/Basics/RAssertDolphin.s +++ b/asm/Kyoto/Basics/RAssertDolphin.s @@ -3,7 +3,7 @@ .section .bss .balign 8 -.lcomm lbl_804797A0, 0x400, 4 +.lcomm rs_debugger_buffer, 0x400, 4 .section .sbss, "wa" .balign 8 @@ -11,8 +11,8 @@ .global lbl_805A9248 lbl_805A9248: .skip 0x4 -.global lbl_805A924C -lbl_805A924C: +.global rs_debugger_buffer_size +rs_debugger_buffer_size: .skip 0x4 .section .text, "ax" @@ -38,10 +38,10 @@ lbl_802D6868: /* 802D6868 002D37C8 3B E1 03 58 */ addi r31, r1, 0x358 /* 802D686C 002D37CC 39 81 00 08 */ addi r12, r1, 8 /* 802D6870 002D37D0 3F C0 01 00 */ lis r30, 0x100 -/* 802D6874 002D37D4 3D 60 80 48 */ lis r11, lbl_804797A0@ha +/* 802D6874 002D37D4 3D 60 80 48 */ lis r11, rs_debugger_buffer@ha /* 802D6878 002D37D8 90 81 00 0C */ stw r4, 0xc(r1) /* 802D687C 002D37DC 3B A1 00 68 */ addi r29, r1, 0x68 -/* 802D6880 002D37E0 38 0B 97 A0 */ addi r0, r11, lbl_804797A0@l +/* 802D6880 002D37E0 38 0B 97 A0 */ addi r0, r11, rs_debugger_buffer@l /* 802D6884 002D37E4 7C 64 1B 78 */ mr r4, r3 /* 802D6888 002D37E8 90 61 00 08 */ stw r3, 8(r1) /* 802D688C 002D37EC 7C 03 03 78 */ mr r3, r0 @@ -56,7 +56,7 @@ lbl_802D6868: /* 802D68B0 002D3810 93 E1 00 6C */ stw r31, 0x6c(r1) /* 802D68B4 002D3814 91 81 00 70 */ stw r12, 0x70(r1) /* 802D68B8 002D3818 48 0B 75 05 */ bl vsprintf -/* 802D68BC 002D381C 90 6D A6 8C */ stw r3, lbl_805A924C@sda21(r13) +/* 802D68BC 002D381C 90 6D A6 8C */ stw r3, rs_debugger_buffer_size@sda21(r13) /* 802D68C0 002D3820 38 61 00 78 */ addi r3, r1, 0x78 /* 802D68C4 002D3824 48 0A 8B C1 */ bl OSSaveContext /* 802D68C8 002D3828 3C 60 D1 DD */ lis r3, 0xD1DD0D1E@ha @@ -64,7 +64,7 @@ lbl_802D6868: /* 802D68D0 002D3830 38 C3 0D 1E */ addi r6, r3, 0xD1DD0D1E@l /* 802D68D4 002D3834 38 60 00 FF */ li r3, 0xff /* 802D68D8 002D3838 38 A0 00 00 */ li r5, 0 -/* 802D68DC 002D383C 48 00 00 7D */ bl ErrorHandler +/* 802D68DC 002D383C 48 00 00 7D */ bl ErrorHandler__FUsP9OSContextii /* 802D68E0 002D3840 80 01 03 54 */ lwz r0, 0x354(r1) /* 802D68E4 002D3844 83 E1 03 4C */ lwz r31, 0x34c(r1) /* 802D68E8 002D3848 83 C1 03 48 */ lwz r30, 0x348(r1) @@ -73,26 +73,26 @@ lbl_802D6868: /* 802D68F4 002D3854 38 21 03 50 */ addi r1, r1, 0x350 /* 802D68F8 002D3858 4E 80 00 20 */ blr -.global SetErrorHandlers -SetErrorHandlers: +.global SetErrorHandlers__Fv +SetErrorHandlers__Fv: /* 802D68FC 002D385C 94 21 FF F0 */ stwu r1, -0x10(r1) /* 802D6900 002D3860 7C 08 02 A6 */ mflr r0 -/* 802D6904 002D3864 3C 80 80 2D */ lis r4, ErrorHandler@ha +/* 802D6904 002D3864 3C 80 80 2D */ lis r4, ErrorHandler__FUsP9OSContextii@ha /* 802D6908 002D3868 38 60 00 02 */ li r3, 2 /* 802D690C 002D386C 90 01 00 14 */ stw r0, 0x14(r1) -/* 802D6910 002D3870 38 84 69 58 */ addi r4, r4, ErrorHandler@l +/* 802D6910 002D3870 38 84 69 58 */ addi r4, r4, ErrorHandler__FUsP9OSContextii@l /* 802D6914 002D3874 48 0A 92 45 */ bl OSSetErrorHandler -/* 802D6918 002D3878 3C 80 80 2D */ lis r4, ErrorHandler@ha +/* 802D6918 002D3878 3C 80 80 2D */ lis r4, ErrorHandler__FUsP9OSContextii@ha /* 802D691C 002D387C 38 60 00 03 */ li r3, 3 -/* 802D6920 002D3880 38 84 69 58 */ addi r4, r4, ErrorHandler@l +/* 802D6920 002D3880 38 84 69 58 */ addi r4, r4, ErrorHandler__FUsP9OSContextii@l /* 802D6924 002D3884 48 0A 92 35 */ bl OSSetErrorHandler -/* 802D6928 002D3888 3C 80 80 2D */ lis r4, ErrorHandler@ha +/* 802D6928 002D3888 3C 80 80 2D */ lis r4, ErrorHandler__FUsP9OSContextii@ha /* 802D692C 002D388C 38 60 00 05 */ li r3, 5 -/* 802D6930 002D3890 38 84 69 58 */ addi r4, r4, ErrorHandler@l +/* 802D6930 002D3890 38 84 69 58 */ addi r4, r4, ErrorHandler__FUsP9OSContextii@l /* 802D6934 002D3894 48 0A 92 25 */ bl OSSetErrorHandler -/* 802D6938 002D3898 3C 80 80 2D */ lis r4, ErrorHandler@ha +/* 802D6938 002D3898 3C 80 80 2D */ lis r4, ErrorHandler__FUsP9OSContextii@ha /* 802D693C 002D389C 38 60 00 0F */ li r3, 0xf -/* 802D6940 002D38A0 38 84 69 58 */ addi r4, r4, ErrorHandler@l +/* 802D6940 002D38A0 38 84 69 58 */ addi r4, r4, ErrorHandler__FUsP9OSContextii@l /* 802D6944 002D38A4 48 0A 92 15 */ bl OSSetErrorHandler /* 802D6948 002D38A8 80 01 00 14 */ lwz r0, 0x14(r1) /* 802D694C 002D38AC 7C 08 03 A6 */ mtlr r0 @@ -101,8 +101,8 @@ SetErrorHandlers: .if version >= 1 -.global ErrorHandler -ErrorHandler: +.global ErrorHandler__FUsP9OSContextii +ErrorHandler__FUsP9OSContextii: /* 802D6A04 002D3964 94 21 FC C0 */ stwu r1, -0x340(r1) /* 802D6A08 002D3968 7C 08 02 A6 */ mflr r0 /* 802D6A0C 002D396C 90 01 03 44 */ stw r0, 0x344(r1) @@ -243,12 +243,12 @@ lbl_802D6B8C: /* 802D6C08 002D3B68 38 63 00 FB */ addi r3, r3, 0xfb /* 802D6C0C 002D3B6C 4C C6 31 82 */ crclr 6 /* 802D6C10 002D3B70 48 0A 8F 79 */ bl OSReport -/* 802D6C14 002D3B74 83 0D A6 8C */ lwz r24, lbl_805A924C@sda21(r13) +/* 802D6C14 002D3B74 83 0D A6 8C */ lwz r24, rs_debugger_buffer_size@sda21(r13) /* 802D6C18 002D3B78 2C 18 00 00 */ cmpwi r24, 0x0 /* 802D6C1C 002D3B7C 41 82 00 2C */ beq lbl_802D6C48 -/* 802D6C20 002D3B80 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6C20 002D3B80 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6C24 002D3B84 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6C28 002D3B88 38 04 99 80 */ addi r0, r4, lbl_804797A0@l +/* 802D6C28 002D3B88 38 04 99 80 */ addi r0, r4, rs_debugger_buffer@l /* 802D6C2C 002D3B8C 38 83 6C 98 */ addi r4, r3, lbl_803D6AB8@l /* 802D6C30 002D3B90 7C 60 C2 14 */ add r3, r0, r24 /* 802D6C34 002D3B94 38 84 01 2A */ addi r4, r4, 0x12a @@ -258,29 +258,29 @@ lbl_802D6B8C: /* 802D6C44 002D3BA4 48 00 00 28 */ b lbl_802D6C6C lbl_802D6C48: /* 802D6C48 002D3BA8 3C 80 80 3D */ lis r4, lbl_803D6AB8@ha -/* 802D6C4C 002D3BAC 3C 60 80 48 */ lis r3, lbl_804797A0@ha +/* 802D6C4C 002D3BAC 3C 60 80 48 */ lis r3, rs_debugger_buffer@ha /* 802D6C50 002D3BB0 38 84 6C 98 */ addi r4, r4, lbl_803D6AB8@l /* 802D6C54 002D3BB4 7F E5 FB 78 */ mr r5, r31 -/* 802D6C58 002D3BB8 38 63 99 80 */ addi r3, r3, lbl_804797A0@l +/* 802D6C58 002D3BB8 38 63 99 80 */ addi r3, r3, rs_debugger_buffer@l /* 802D6C5C 002D3BBC 38 84 01 39 */ addi r4, r4, 0x139 /* 802D6C60 002D3BC0 4C C6 31 82 */ crclr 6 /* 802D6C64 002D3BC4 48 0B 72 55 */ bl sprintf /* 802D6C68 002D3BC8 7F 18 1A 14 */ add r24, r24, r3 lbl_802D6C6C: -/* 802D6C6C 002D3BCC 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6C6C 002D3BCC 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6C70 002D3BD0 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6C74 002D3BD4 38 04 99 80 */ addi r0, r4, lbl_804797A0@l +/* 802D6C74 002D3BD4 38 04 99 80 */ addi r0, r4, rs_debugger_buffer@l /* 802D6C78 002D3BD8 80 A2 82 88 */ lwz r5, lbl_805A9FA8@sda21(r2) /* 802D6C7C 002D3BDC 38 83 6C 98 */ addi r4, r3, lbl_803D6AB8@l /* 802D6C80 002D3BE0 7C 60 C2 14 */ add r3, r0, r24 /* 802D6C84 002D3BE4 38 84 00 25 */ addi r4, r4, 0x25 /* 802D6C88 002D3BE8 4C C6 31 82 */ crclr 6 /* 802D6C8C 002D3BEC 48 0B 72 2D */ bl sprintf -/* 802D6C90 002D3BF0 3C A0 80 48 */ lis r5, lbl_804797A0@ha +/* 802D6C90 002D3BF0 3C A0 80 48 */ lis r5, rs_debugger_buffer@ha /* 802D6C94 002D3BF4 3C 80 80 3D */ lis r4, lbl_803D6AB8@ha /* 802D6C98 002D3BF8 38 84 6C 98 */ addi r4, r4, lbl_803D6AB8@l /* 802D6C9C 002D3BFC 7F D8 1A 14 */ add r30, r24, r3 -/* 802D6CA0 002D3C00 38 05 99 80 */ addi r0, r5, lbl_804797A0@l +/* 802D6CA0 002D3C00 38 05 99 80 */ addi r0, r5, rs_debugger_buffer@l /* 802D6CA4 002D3C04 80 BB 01 98 */ lwz r5, 0x198(r27) /* 802D6CA8 002D3C08 7F A6 EB 78 */ mr r6, r29 /* 802D6CAC 002D3C0C 38 84 01 54 */ addi r4, r4, 0x154 @@ -291,9 +291,9 @@ lbl_802D6C6C: /* 802D6CC0 002D3C20 7F DE 1A 14 */ add r30, r30, r3 /* 802D6CC4 002D3C24 28 00 00 0F */ cmplwi r0, 0xf /* 802D6CC8 002D3C28 40 82 00 2C */ bne lbl_802D6CF4 -/* 802D6CCC 002D3C2C 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6CCC 002D3C2C 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6CD0 002D3C30 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6CD4 002D3C34 38 04 99 80 */ addi r0, r4, lbl_804797A0@l +/* 802D6CD4 002D3C34 38 04 99 80 */ addi r0, r4, rs_debugger_buffer@l /* 802D6CD8 002D3C38 7F 85 E3 78 */ mr r5, r28 /* 802D6CDC 002D3C3C 38 83 6C 98 */ addi r4, r3, lbl_803D6AB8@l /* 802D6CE0 002D3C40 7C 60 F2 14 */ add r3, r0, r30 @@ -302,9 +302,9 @@ lbl_802D6C6C: /* 802D6CEC 002D3C4C 48 0B 71 CD */ bl sprintf /* 802D6CF0 002D3C50 7F DE 1A 14 */ add r30, r30, r3 lbl_802D6CF4: -/* 802D6CF4 002D3C54 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6CF4 002D3C54 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6CF8 002D3C58 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6CFC 002D3C5C 38 04 99 80 */ addi r0, r4, lbl_804797A0@l +/* 802D6CFC 002D3C5C 38 04 99 80 */ addi r0, r4, rs_debugger_buffer@l /* 802D6D00 002D3C60 38 83 6C 98 */ addi r4, r3, lbl_803D6AB8@l /* 802D6D04 002D3C64 7C 60 F2 14 */ add r3, r0, r30 /* 802D6D08 002D3C68 38 84 01 74 */ addi r4, r4, 0x174 @@ -318,11 +318,11 @@ lbl_802D6CF4: /* 802D6D28 002D3C88 48 0A 8E 61 */ bl OSReport /* 802D6D2C 002D3C8C 3C A0 80 00 */ lis r5, 0x80000400@ha /* 802D6D30 002D3C90 3C 80 80 3D */ lis r4, lbl_803D6AB8@ha -/* 802D6D34 002D3C94 3C 60 80 48 */ lis r3, lbl_804797A0@ha +/* 802D6D34 002D3C94 3C 60 80 48 */ lis r3, rs_debugger_buffer@ha /* 802D6D38 002D3C98 83 FB 00 04 */ lwz r31, 0x4(r27) /* 802D6D3C 002D3C9C 3B 05 04 00 */ addi r24, r5, 0x80000400@l /* 802D6D40 002D3CA0 3B 84 6C 98 */ addi r28, r4, lbl_803D6AB8@l -/* 802D6D44 002D3CA4 3B 43 99 80 */ addi r26, r3, lbl_804797A0@l +/* 802D6D44 002D3CA4 3B 43 99 80 */ addi r26, r3, rs_debugger_buffer@l /* 802D6D48 002D3CA8 3A E0 00 00 */ li r23, 0x0 /* 802D6D4C 002D3CAC 3F 20 81 80 */ lis r25, 0x8180 /* 802D6D50 002D3CB0 48 00 00 94 */ b lbl_802D6DE4 @@ -353,9 +353,9 @@ lbl_802D6DA0: /* 802D6DAC 002D3D0C 38 63 01 D0 */ addi r3, r3, 0x1d0 /* 802D6DB0 002D3D10 4C C6 31 82 */ crclr 6 /* 802D6DB4 002D3D14 48 0A 8D D5 */ bl OSReport -/* 802D6DB8 002D3D18 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6DB8 002D3D18 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6DBC 002D3D1C 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6DC0 002D3D20 38 04 99 80 */ addi r0, r4, lbl_804797A0@l +/* 802D6DC0 002D3D20 38 04 99 80 */ addi r0, r4, rs_debugger_buffer@l /* 802D6DC4 002D3D24 7F E5 FB 78 */ mr r5, r31 /* 802D6DC8 002D3D28 38 83 6C 98 */ addi r4, r3, lbl_803D6AB8@l /* 802D6DCC 002D3D2C 7C 60 F2 14 */ add r3, r0, r30 @@ -386,9 +386,9 @@ lbl_802D6E04: /* 802D6E24 002D3D84 28 00 00 00 */ cmplwi r0, 0x0 /* 802D6E28 002D3D88 40 82 00 28 */ bne lbl_802D6E50 /* 802D6E2C 002D3D8C 80 82 C5 80 */ lwz r4, lbl_805AE2A0@sda21(r2) -/* 802D6E30 002D3D90 3C 60 80 48 */ lis r3, lbl_804797A0@ha +/* 802D6E30 002D3D90 3C 60 80 48 */ lis r3, rs_debugger_buffer@ha /* 802D6E34 002D3D94 80 02 C5 84 */ lwz r0, lbl_805AE2A4@sda21(r2) -/* 802D6E38 002D3D98 38 A3 99 80 */ addi r5, r3, lbl_804797A0@l +/* 802D6E38 002D3D98 38 A3 99 80 */ addi r5, r3, rs_debugger_buffer@l /* 802D6E3C 002D3D9C 90 81 00 08 */ stw r4, 0x8(r1) /* 802D6E40 002D3DA0 38 61 00 0C */ addi r3, r1, 0xc /* 802D6E44 002D3DA4 38 81 00 08 */ addi r4, r1, 0x8 @@ -403,8 +403,8 @@ lbl_802D6E50: .else -.global ErrorHandler -ErrorHandler: +.global ErrorHandler__FUsP9OSContextii +ErrorHandler__FUsP9OSContextii: /* 802D6958 002D38B8 94 21 FF 90 */ stwu r1, -0x70(r1) /* 802D695C 002D38BC 7C 08 02 A6 */ mflr r0 /* 802D6960 002D38C0 90 01 00 74 */ stw r0, 0x74(r1) @@ -530,12 +530,12 @@ lbl_802D6AAC: /* 802D6B28 002D3A88 38 63 00 FB */ addi r3, r3, 0xfb /* 802D6B2C 002D3A8C 4C C6 31 82 */ crclr 6 /* 802D6B30 002D3A90 48 0A 8E 7D */ bl OSReport -/* 802D6B34 002D3A94 83 0D A6 8C */ lwz r24, lbl_805A924C@sda21(r13) +/* 802D6B34 002D3A94 83 0D A6 8C */ lwz r24, rs_debugger_buffer_size@sda21(r13) /* 802D6B38 002D3A98 2C 18 00 00 */ cmpwi r24, 0 /* 802D6B3C 002D3A9C 41 82 00 2C */ beq lbl_802D6B68 -/* 802D6B40 002D3AA0 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6B40 002D3AA0 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6B44 002D3AA4 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6B48 002D3AA8 38 04 97 A0 */ addi r0, r4, lbl_804797A0@l +/* 802D6B48 002D3AA8 38 04 97 A0 */ addi r0, r4, rs_debugger_buffer@l /* 802D6B4C 002D3AAC 38 83 6A B8 */ addi r4, r3, lbl_803D6AB8@l /* 802D6B50 002D3AB0 7C 60 C2 14 */ add r3, r0, r24 /* 802D6B54 002D3AB4 38 84 01 2A */ addi r4, r4, 0x12a @@ -545,29 +545,29 @@ lbl_802D6AAC: /* 802D6B64 002D3AC4 48 00 00 28 */ b lbl_802D6B8C lbl_802D6B68: /* 802D6B68 002D3AC8 3C 80 80 3D */ lis r4, lbl_803D6AB8@ha -/* 802D6B6C 002D3ACC 3C 60 80 48 */ lis r3, lbl_804797A0@ha +/* 802D6B6C 002D3ACC 3C 60 80 48 */ lis r3, rs_debugger_buffer@ha /* 802D6B70 002D3AD0 38 84 6A B8 */ addi r4, r4, lbl_803D6AB8@l /* 802D6B74 002D3AD4 7F E5 FB 78 */ mr r5, r31 -/* 802D6B78 002D3AD8 38 63 97 A0 */ addi r3, r3, lbl_804797A0@l +/* 802D6B78 002D3AD8 38 63 97 A0 */ addi r3, r3, rs_debugger_buffer@l /* 802D6B7C 002D3ADC 38 84 01 39 */ addi r4, r4, 0x139 /* 802D6B80 002D3AE0 4C C6 31 82 */ crclr 6 /* 802D6B84 002D3AE4 48 0B 71 59 */ bl sprintf /* 802D6B88 002D3AE8 7F 18 1A 14 */ add r24, r24, r3 lbl_802D6B8C: -/* 802D6B8C 002D3AEC 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6B8C 002D3AEC 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6B90 002D3AF0 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6B94 002D3AF4 38 04 97 A0 */ addi r0, r4, lbl_804797A0@l +/* 802D6B94 002D3AF4 38 04 97 A0 */ addi r0, r4, rs_debugger_buffer@l /* 802D6B98 002D3AF8 80 A2 82 88 */ lwz r5, lbl_805A9FA8@sda21(r2) /* 802D6B9C 002D3AFC 38 83 6A B8 */ addi r4, r3, lbl_803D6AB8@l /* 802D6BA0 002D3B00 7C 60 C2 14 */ add r3, r0, r24 /* 802D6BA4 002D3B04 38 84 00 25 */ addi r4, r4, 0x25 /* 802D6BA8 002D3B08 4C C6 31 82 */ crclr 6 /* 802D6BAC 002D3B0C 48 0B 71 31 */ bl sprintf -/* 802D6BB0 002D3B10 3C A0 80 48 */ lis r5, lbl_804797A0@ha +/* 802D6BB0 002D3B10 3C A0 80 48 */ lis r5, rs_debugger_buffer@ha /* 802D6BB4 002D3B14 3C 80 80 3D */ lis r4, lbl_803D6AB8@ha /* 802D6BB8 002D3B18 38 84 6A B8 */ addi r4, r4, lbl_803D6AB8@l /* 802D6BBC 002D3B1C 7F D8 1A 14 */ add r30, r24, r3 -/* 802D6BC0 002D3B20 38 05 97 A0 */ addi r0, r5, lbl_804797A0@l +/* 802D6BC0 002D3B20 38 05 97 A0 */ addi r0, r5, rs_debugger_buffer@l /* 802D6BC4 002D3B24 80 BB 01 98 */ lwz r5, 0x198(r27) /* 802D6BC8 002D3B28 7F A6 EB 78 */ mr r6, r29 /* 802D6BCC 002D3B2C 38 84 01 54 */ addi r4, r4, 0x154 @@ -578,9 +578,9 @@ lbl_802D6B8C: /* 802D6BE0 002D3B40 7F DE 1A 14 */ add r30, r30, r3 /* 802D6BE4 002D3B44 28 00 00 0F */ cmplwi r0, 0xf /* 802D6BE8 002D3B48 40 82 00 2C */ bne lbl_802D6C14 -/* 802D6BEC 002D3B4C 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6BEC 002D3B4C 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6BF0 002D3B50 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6BF4 002D3B54 38 04 97 A0 */ addi r0, r4, lbl_804797A0@l +/* 802D6BF4 002D3B54 38 04 97 A0 */ addi r0, r4, rs_debugger_buffer@l /* 802D6BF8 002D3B58 7F 85 E3 78 */ mr r5, r28 /* 802D6BFC 002D3B5C 38 83 6A B8 */ addi r4, r3, lbl_803D6AB8@l /* 802D6C00 002D3B60 7C 60 F2 14 */ add r3, r0, r30 @@ -589,9 +589,9 @@ lbl_802D6B8C: /* 802D6C0C 002D3B6C 48 0B 70 D1 */ bl sprintf /* 802D6C10 002D3B70 7F DE 1A 14 */ add r30, r30, r3 lbl_802D6C14: -/* 802D6C14 002D3B74 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6C14 002D3B74 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6C18 002D3B78 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6C1C 002D3B7C 38 04 97 A0 */ addi r0, r4, lbl_804797A0@l +/* 802D6C1C 002D3B7C 38 04 97 A0 */ addi r0, r4, rs_debugger_buffer@l /* 802D6C20 002D3B80 38 83 6A B8 */ addi r4, r3, lbl_803D6AB8@l /* 802D6C24 002D3B84 7C 60 F2 14 */ add r3, r0, r30 /* 802D6C28 002D3B88 38 84 01 74 */ addi r4, r4, 0x174 @@ -605,11 +605,11 @@ lbl_802D6C14: /* 802D6C48 002D3BA8 48 0A 8D 65 */ bl OSReport /* 802D6C4C 002D3BAC 3C A0 80 00 */ lis r5, 0x80000400@ha /* 802D6C50 002D3BB0 3C 80 80 3D */ lis r4, lbl_803D6AB8@ha -/* 802D6C54 002D3BB4 3C 60 80 48 */ lis r3, lbl_804797A0@ha +/* 802D6C54 002D3BB4 3C 60 80 48 */ lis r3, rs_debugger_buffer@ha /* 802D6C58 002D3BB8 83 FB 00 04 */ lwz r31, 4(r27) /* 802D6C5C 002D3BBC 3B 05 04 00 */ addi r24, r5, 0x80000400@l /* 802D6C60 002D3BC0 3B 84 6A B8 */ addi r28, r4, lbl_803D6AB8@l -/* 802D6C64 002D3BC4 3B 43 97 A0 */ addi r26, r3, lbl_804797A0@l +/* 802D6C64 002D3BC4 3B 43 97 A0 */ addi r26, r3, rs_debugger_buffer@l /* 802D6C68 002D3BC8 3A E0 00 00 */ li r23, 0 /* 802D6C6C 002D3BCC 3F 20 81 80 */ lis r25, 0x8180 /* 802D6C70 002D3BD0 48 00 00 94 */ b lbl_802D6D04 @@ -640,9 +640,9 @@ lbl_802D6CC0: /* 802D6CCC 002D3C2C 38 63 01 D0 */ addi r3, r3, 0x1d0 /* 802D6CD0 002D3C30 4C C6 31 82 */ crclr 6 /* 802D6CD4 002D3C34 48 0A 8C D9 */ bl OSReport -/* 802D6CD8 002D3C38 3C 80 80 48 */ lis r4, lbl_804797A0@ha +/* 802D6CD8 002D3C38 3C 80 80 48 */ lis r4, rs_debugger_buffer@ha /* 802D6CDC 002D3C3C 3C 60 80 3D */ lis r3, lbl_803D6AB8@ha -/* 802D6CE0 002D3C40 38 04 97 A0 */ addi r0, r4, lbl_804797A0@l +/* 802D6CE0 002D3C40 38 04 97 A0 */ addi r0, r4, rs_debugger_buffer@l /* 802D6CE4 002D3C44 7F E5 FB 78 */ mr r5, r31 /* 802D6CE8 002D3C48 38 83 6A B8 */ addi r4, r3, lbl_803D6AB8@l /* 802D6CEC 002D3C4C 7C 60 F2 14 */ add r3, r0, r30 @@ -673,9 +673,9 @@ lbl_802D6D24: /* 802D6D44 002D3CA4 28 00 00 00 */ cmplwi r0, 0 /* 802D6D48 002D3CA8 40 82 00 28 */ bne lbl_802D6D70 /* 802D6D4C 002D3CAC 80 82 C5 80 */ lwz r4, lbl_805AE2A0@sda21(r2) -/* 802D6D50 002D3CB0 3C 60 80 48 */ lis r3, lbl_804797A0@ha +/* 802D6D50 002D3CB0 3C 60 80 48 */ lis r3, rs_debugger_buffer@ha /* 802D6D54 002D3CB4 80 02 C5 84 */ lwz r0, lbl_805AE2A4@sda21(r2) -/* 802D6D58 002D3CB8 38 A3 97 A0 */ addi r5, r3, lbl_804797A0@l +/* 802D6D58 002D3CB8 38 A3 97 A0 */ addi r5, r3, rs_debugger_buffer@l /* 802D6D5C 002D3CBC 90 81 00 08 */ stw r4, 8(r1) /* 802D6D60 002D3CC0 38 61 00 0C */ addi r3, r1, 0xc /* 802D6D64 002D3CC4 38 81 00 08 */ addi r4, r1, 8 diff --git a/asm/MetroidPrime/main.s b/asm/MetroidPrime/main.s index 8ef09c36..3df1f283 100644 --- a/asm/MetroidPrime/main.s +++ b/asm/MetroidPrime/main.s @@ -7251,7 +7251,7 @@ main: /* 80008524 00005484 38 60 00 01 */ li r3, 1 /* 80008528 00005488 48 36 C8 A5 */ bl DVDSetAutoFatalMessaging .endif -/* 8000852C 0000548C 48 2C E3 D1 */ bl SetErrorHandlers +/* 8000852C 0000548C 48 2C E3 D1 */ bl SetErrorHandlers__Fv /* 80008530 00005490 3C 60 80 45 */ lis r3, sMainSpace@ha /* 80008534 00005494 37 E3 75 60 */ addic. r31, r3, sMainSpace@l /* 80008538 00005498 41 82 00 10 */ beq lbl_80008548 diff --git a/include/Kyoto/Basics/RAssertDolphin.hpp b/include/Kyoto/Basics/RAssertDolphin.hpp new file mode 100644 index 00000000..b50d6d0d --- /dev/null +++ b/include/Kyoto/Basics/RAssertDolphin.hpp @@ -0,0 +1,12 @@ +#ifndef _RASSERTDOLPHIN_HPP +#define _RASSERTDOLPHIN_HPP + +#include "types.h" + +#include "dolphin/os.h" + +void rs_debugger_printf(const char* format, ...); +void ErrorHandler(OSError code, OSContext* context, int, int); +void SetErrorHandlers(); + +#endif diff --git a/include/dolphin/os.h b/include/dolphin/os.h index 738b8199..42104505 100644 --- a/include/dolphin/os.h +++ b/include/dolphin/os.h @@ -2,6 +2,7 @@ #define _DOLPHIN_OS_H #include +#include #ifdef __cplusplus extern "C" { @@ -64,6 +65,7 @@ OSTime OSGetTime(); OSTick OSGetTick(); void OSReport(const char* msg, ...); void OSPanic(const char* file, int line, const char* msg, ...); +void OSFatal(GXColor fg, GXColor bg, const char* msg); #ifdef __cplusplus } @@ -72,6 +74,7 @@ void OSPanic(const char* file, int line, const char* msg, ...); #include #include #include +#include #include #include #include diff --git a/include/dolphin/os/OSContext.h b/include/dolphin/os/OSContext.h index 56235e88..922a33fa 100644 --- a/include/dolphin/os/OSContext.h +++ b/include/dolphin/os/OSContext.h @@ -31,6 +31,10 @@ typedef struct OSContext { } OSContext; +void OSSaveContext(OSContext* context); +void OSClearContext(OSContext* context); +void OSSetCurrentContext(OSContext* context); + #ifdef __cplusplus } #endif diff --git a/include/dolphin/os/OSError.h b/include/dolphin/os/OSError.h new file mode 100644 index 00000000..3ad1a936 --- /dev/null +++ b/include/dolphin/os/OSError.h @@ -0,0 +1,19 @@ +#ifndef __OSERROR_H__ +#define __OSERROR_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef u16 OSError; +typedef void OSErrorHandler(OSError, OSContext* context, ...); + +void OSSetErrorHandler(OSError code, OSErrorHandler* handler); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/Kyoto/Basics/RAssertDolphin.cpp b/src/Kyoto/Basics/RAssertDolphin.cpp new file mode 100644 index 00000000..a07c37aa --- /dev/null +++ b/src/Kyoto/Basics/RAssertDolphin.cpp @@ -0,0 +1,128 @@ + +#include "Kyoto/Basics/RAssertDolphin.hpp" + +#include "dolphin/ai.h" +#include "dolphin/os/OSMemory.h" +#include "dolphin/pad.h" +#include "dolphin/vi.h" +#include + +static const char* buildTime = "Build v1.088 10/29/2002 2:21:25"; +static char rs_debugger_buffer[1024]; +static int rs_debugger_buffer_size; +static char DAT_805a9248; + +void rs_debugger_printf(const char* format, ...) { + va_list arg; + + va_start(arg, format); + rs_debugger_buffer_size = vsprintf(rs_debugger_buffer, format, arg); + va_end(arg); + + OSContext context; + OSSaveContext(&context); + ErrorHandler(0xff, &context, 0, 0xd1dd0d1e); +} + +void ErrorHandler(OSError code, OSContext* context, int arg1, int arg2) { + uint loopExitCriteria; + OSContext newContext; + PADStatus pads[4]; + uint local_60; + + if (code != 15 || ((arg1 & 0x10) == 0 && (arg2 < 0x1800001))) { + OSProtectRange(3, 0, 0, 3); + loopExitCriteria = 0; + PADControlMotor(0, 0); + VISetBlack(1); + VIFlush(); + while (loopExitCriteria < 4) { + PADRead(pads); + if (pads[1].err == 0) { + local_60 = 0x2010408; + if ((pads[1].button & 0xc10) == 0xc10) { + if ((pads[1].button & 0xf) != 0) { + if (pads[1].button & loopExitCriteria == 0) { // TODO: wrong logic with loopExitCriteria + if ((loopExitCriteria != 0) && + pads[1].button == 0) { // TODO: wrong logic with pads[1].button + loopExitCriteria = 0; + } + } else { + loopExitCriteria += 1; + } + } + } else { + loopExitCriteria = 0; + } + } + } + VISetBlack(0); + VIFlush(); + OSReport("Unhandled exception %d - Production\n", code); + OSReport("%s\n", buildTime); + OSReport("------------------------- Context 0x%08x -------------------------\n", context); + + int i = 0; + do { + OSReport("r%-2d = 0x%08x (%14d) r%-2d = 0x%08x (%14d)\n", i, context->gpr[i], + context->gpr[i], i + 0x10, context->gpr[i + 0x10], context->gpr[i + 0x10]); + i += 1; + } while (i < 0x10); + + OSReport("LR = 0x%08x CR = 0x%08x\n", context->lr, context->cr); + OSReport("SRR0 = 0x%08x SRR1 = 0x%08x\n", context->srr0, context->srr1); + OSReport("DSISR= 0x%08x DAR = 0x%08x\n", arg1, arg2); + + if (rs_debugger_buffer_size == 0) { + i = sprintf(rs_debugger_buffer, "Exception %d - Production\n", code); + } else { + i = sprintf(rs_debugger_buffer + rs_debugger_buffer_size, " - Production\n"); + } + int j = sprintf(rs_debugger_buffer + rs_debugger_buffer_size + i, "%s\n", buildTime); + int bufferIndex = rs_debugger_buffer_size + i + j; + bufferIndex += + sprintf(rs_debugger_buffer + bufferIndex, "IP: 0x%8.8x Mem: 0x%8.8x", context->srr0, arg2); + if (code == 0xf) { + bufferIndex += sprintf(rs_debugger_buffer + bufferIndex, " - %d", arg1); + } + bufferIndex += sprintf(rs_debugger_buffer + bufferIndex, "\n\n"); + + OSReport("\nAddress: Back Chain LR Save\n"); + + u32 stackPtr = context->gpr[1]; + bool check; + i = 0; + while (true) { + if (((stackPtr == NULL) || (stackPtr == 0xffffffff)) || (check = 0xf < i, i += 1, check)) { + break; + } + if ((stackPtr < 0x80000401) || (0x817fffff < stackPtr)) { + OSReport("0x%08x: BAD PTR\n", stackPtr); + sprintf(rs_debugger_buffer + j, "0x%08x: BAD PTR\n", stackPtr); + break; + } + u32* asPtr = (u32*)stackPtr; + + OSReport("0x%08x: 0x%08x 0x%08x\n", stackPtr, *asPtr, asPtr[1]); + bufferIndex += + sprintf(rs_debugger_buffer + j, "0x%08x: 0x%08x 0x%08x\n", stackPtr, *asPtr, asPtr[1]); + stackPtr = *asPtr; + } + OSReport("\nInstruction at 0x%x (read from SRR0) attempted to access invalid address 0x%x " + "(read from DAR)\n", + context->srr0, arg2); + + if (DAT_805a9248 == '\0') { + GXColor fg; // = &DAT_80000000; + GXColor bg; // = 0xffffff00; + OSFatal(fg, bg, rs_debugger_buffer); + } + } +} + +void SetErrorHandlers() { + OSSetErrorHandler(2, (OSErrorHandler*) ErrorHandler); + OSSetErrorHandler(3, (OSErrorHandler*) ErrorHandler); + OSSetErrorHandler(5, (OSErrorHandler*) ErrorHandler); + OSSetErrorHandler(15, (OSErrorHandler*) ErrorHandler); +} \ No newline at end of file diff --git a/src/MetroidPrime/main.cpp b/src/MetroidPrime/main.cpp index d7beb543..62a0972a 100644 --- a/src/MetroidPrime/main.cpp +++ b/src/MetroidPrime/main.cpp @@ -19,6 +19,7 @@ #include "Kyoto/Audio/CSfxManager.hpp" #include "Kyoto/Audio/CStreamAudioManager.hpp" #include "Kyoto/Basics/CBasics.hpp" +#include "Kyoto/Basics/RAssertDolphin.hpp" #include "Kyoto/CARAMManager.hpp" #include "Kyoto/CARAMToken.hpp" #include "Kyoto/CFrameDelayedKiller.hpp" @@ -53,8 +54,6 @@ extern "C" { void sub_8036ccfc(); // part of CMain but lazy void nullsub_2(CMain*); -// RAssertDolphin -void SetErrorHandlers(); } CResFactory* gpResourceFactory;