diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 0d8c04d4..e72c91b9 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -29,10 +29,13 @@ toBeSorted/mdl_base.cpp: .text start:0x80006E10 end:0x80006EA8 align:16 .data start:0x804FD0B8 end:0x804FD0C8 -toBeSorted/d_assert.cpp: +toBeSorted/d_exception.cpp: .text start:0x80006EB0 end:0x8000742C align:16 + .rodata start:0x804DBA00 end:0x804DBA18 .data start:0x804FD0C8 end:0x804FD180 + .sdata start:0x80571450 end:0x80571468 .sbss start:0x80574FB0 end:0x80574FB8 + .sdata2 start:0x805769C0 end:0x805769C8 .bss start:0x80580000 end:0x80580038 toBeSorted/d_jstudio.cpp: @@ -232,6 +235,7 @@ d/d_heap.cpp: .ctors start:0x804DB680 end:0x804DB684 .rodata start:0x804DE008 end:0x804DE188 .data start:0x8050D440 end:0x8050D458 + .sdata start:0x80571C58 end:0x80571C60 .sbss start:0x805751A8 end:0x805751D0 .bss start:0x80597740 end:0x80597758 @@ -1778,7 +1782,6 @@ s/s_Crc.cpp: s/s_Assert.cpp: .text start:0x802DE700 end:0x802DE73C align:16 - .sdata start:0x80573F70 end:0x80573F78 .sbss start:0x80575B70 end:0x80575B78 s/s_Math.cpp: @@ -1790,6 +1793,7 @@ s/s_Phase.cpp: s/s_Print.cpp: .text start:0x802DEF80 end:0x802DF0E4 align:16 + .sdata start:0x80573F70 end:0x80573F78 c/c_counter.cpp: .text start:0x802DF0F0 end:0x802DF100 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 29eb77f1..6400bc18 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -144,16 +144,16 @@ fn_80006D60 = .text:0x80006D60; // type:function size:0x60 fn_80006DC0 = .text:0x80006DC0; // type:function size:0x48 fn_80006E10 = .text:0x80006E10; // type:function size:0x3C fn_80006E50 = .text:0x80006E50; // type:function size:0x58 -fn_80006EB0 = .text:0x80006EB0; // type:function size:0xBC -fn_80006F70 = .text:0x80006F70; // type:function size:0x9C -exceptionCallback = .text:0x80007010; // type:function size:0x38 -exceptionUserCallback = .text:0x80007050; // type:function size:0x3C -assertCallback = .text:0x80007090; // type:function size:0x40 -fn_800070D0 = .text:0x800070D0; // type:function size:0x60 -fn_80007130 = .text:0x80007130; // type:function size:0x94 -fn_800071D0 = .text:0x800071D0; // type:function size:0x8C -fn_80007260 = .text:0x80007260; // type:function size:0xE4 -OSPanic = .text:0x80007350; // type:function size:0xDC scope:weak +printGameInfo__Fv = .text:0x80006EB0; // type:function size:0xBC scope:local +waitForButtonSequence__FPv = .text:0x80006F70; // type:function size:0x9C scope:local +preExceptionCallback__Fv = .text:0x80007010; // type:function size:0x38 scope:local +exceptionCallback__FPQ23EGG10CoreStatus = .text:0x80007050; // type:function size:0x3C scope:local +assertCallback__Fv = .text:0x80007090; // type:function size:0x40 scope:local +sAssertCallback__FPv = .text:0x800070D0; // type:function size:0x60 scope:local +mainErrorHandler__FUsP9OSContextUlUl = .text:0x80007130; // type:function size:0x94 scope:local +initErrorHandlers__Fv = .text:0x800071D0; // type:function size:0x8C scope:local +exceptionCreate__FPQ23EGG4Heap = .text:0x80007260; // type:function size:0xE4 +OSPanic = .text:0x80007350; // type:function size:0xDC scope:global getActorNameFromId = .text:0x80007430; // type:function size:0x24 __dt__7mVec3_cFv = .text:0x80007460; // type:function size:0x40 scope:weak JStudioCustsceneCtrnl__ct = .text:0x800074A0; // type:function size:0xC8 @@ -9804,9 +9804,9 @@ fn_801749B0 = .text:0x801749B0; // type:function size:0x8 fn_801749C0 = .text:0x801749C0; // type:function size:0x8 fn_801749D0 = .text:0x801749D0; // type:function size:0x8 fn_801749E0 = .text:0x801749E0; // type:function size:0xA8 -fn_80174A90 = .text:0x80174A90; // type:function size:0xE4 -RevisionInfo = .text:0x80174B80; // type:function size:0x100 -fn_80174C80 = .text:0x80174C80; // type:function size:0x58 +getCopydate__Fv = .text:0x80174A90; // type:function size:0xE4 +getRevisionInfo__Fv = .text:0x80174B80; // type:function size:0x100 +getUrlInfo__Fv = .text:0x80174C80; // type:function size:0x58 fn_80174CE0 = .text:0x80174CE0; // type:function size:0x118 fn_80174E00 = .text:0x80174E00; // type:function size:0xE8 fn_80174EF0 = .text:0x80174EF0; // type:function size:0xD4 @@ -14484,11 +14484,11 @@ doDelete__12dThpPlayer_cFv = .text:0x802733E0; // type:function size:0x38 execute__12dThpPlayer_cFv = .text:0x80273420; // type:function size:0x24 draw__12dThpPlayer_cFv = .text:0x80273450; // type:function size:0x44 __ct__12dThpPlayer_cFv = .text:0x802734A0; // type:function size:0x88 -__dt__14ThpVideoScreenFv = .text:0x80273530; // type:function size:0x58 +__dt__14ThpVideoScreenFv = .text:0x80273530; // type:function size:0x58 scope:weak __dt__12dThpPlayer_cFv = .text:0x80273590; // type:function size:0xA8 reallyCreate__12dThpPlayer_cFUsUs = .text:0x80273640; // type:function size:0x68 drawTHPFrame__FUlUlUlUlUlUl = .text:0x802736B0; // type:function size:0x2C -callback__FPv = .text:0x802736E0; // type:function size:0x24 +callback__FPv = .text:0x802736E0; // type:function size:0x24 scope:local open__12dThpPlayer_cFv = .text:0x80273710; // type:function size:0x44 setupFile__12dThpPlayer_cFPcl = .text:0x80273760; // type:function size:0xD0 reallyExecute__12dThpPlayer_cFv = .text:0x80273830; // type:function size:0x1B0 @@ -17200,9 +17200,9 @@ initializeStateLocalMethod__20sStateMethodUsr_FI_cFv = .text:0x802DE580; // type executeStateLocalMethod__20sStateMethodUsr_FI_cFv = .text:0x802DE5F0; // type:function size:0x4C finalizeStateLocalMethod__20sStateMethodUsr_FI_cFv = .text:0x802DE640; // type:function size:0x54 changeStateLocalMethod__20sStateMethodUsr_FI_cFRC12sStateIDIf_c = .text:0x802DE6A0; // type:function size:0x4C -calcCRC__4sCrcFPCvUl = .text:0x802DE6F0; // type:function size:0x4 -fn_802DE700 = .text:0x802DE700; // type:function size:0x8 -fn_802DE710 = .text:0x802DE710; // type:function size:0x2C +calcCRC32__4sCrcFPCvUl = .text:0x802DE6F0; // type:function size:0x4 +setAssertCallback__7sAssertFPFPv_v = .text:0x802DE700; // type:function size:0x8 +assert__7sAssertFv = .text:0x802DE710; // type:function size:0x2C extrapolate__4sLibFfff = .text:0x802DE740; // type:function size:0x24 addCalc__4sLibFPfffff = .text:0x802DE770; // type:function size:0xC0 addCalcScaledDiff__4sLibFPffff = .text:0x802DE830; // type:function size:0x44 @@ -17226,10 +17226,10 @@ chaseAngle__4sLibFPsss = .text:0x802DEDA0; // type:function size:0x64 chaseAngle2__4sLibFPsss = .text:0x802DEE10; // type:function size:0x98 __ct__8sPhase_cFPPFPv_Q28sPhase_c15METHOD_RESULT_ei = .text:0x802DEEB0; // type:function size:0x14 callMethod__8sPhase_cFPv = .text:0x802DEED0; // type:function size:0xA4 -vprintf_wrap = .text:0x802DEF80; // type:function size:0x8 -OSVReportGhidra = .text:0x802DEF90; // type:function size:0x4C -fn_802DEFE0 = .text:0x802DEFE0; // type:function size:0x80 -OSReport = .text:0x802DF060; // type:function size:0x80 scope:weak +getVprintfFunc__4sLibFv = .text:0x802DEF80; // type:function size:0x8 scope:local +my_vprintf__4sLibFPCcP16__va_list_struct = .text:0x802DEF90; // type:function size:0x4C scope:local +printf__4sLibFPCce = .text:0x802DEFE0; // type:function size:0x80 +OSReport = .text:0x802DF060; // type:function size:0x80 scope:global OSVReport = .text:0x802DF0E0; // type:function size:0x4 scope:global cCounter_c__clear = .text:0x802DF0F0; // type:function size:0x10 __dt__24DynamicModuleControlBaseFv = .text:0x802DF100; // type:function size:0xA0 @@ -27760,7 +27760,7 @@ __init_cpp_exceptions_reference = .ctors:0x804DB640; // type:object size:0x4 sco _dtors = .dtors:0x804DB9E0; // type:label scope:global data:4byte __destroy_global_chain_reference = .dtors:0x804DB9E0; // type:object size:0x4 scope:global __fini_cpp_exceptions_reference = .dtors:0x804DB9E4; // type:object size:0x4 scope:global -lbl_804DBA00 = .rodata:0x804DBA00; // type:object size:0x18 +sButtonSequence = .rodata:0x804DBA00; // type:object size:0x16 scope:local data:2byte ActorLink__NameNodePairs = .rodata:0x804DBA18; // type:object size:0x28 data:4byte lbl_804DBA40 = .rodata:0x804DBA40; // type:object size:0x120 data:2byte sSaveFileName = .rodata:0x804DBB60; // type:object size:0xD scope:local data:string @@ -29273,9 +29273,17 @@ lbl_804FD06C = .data:0x804FD06C; // type:object size:0xC data:string lbl_804FD078 = .data:0x804FD078; // type:object size:0x1C lbl_804FD094 = .data:0x804FD094; // type:object size:0x24 lbl_804FD0B8 = .data:0x804FD0B8; // type:object size:0x10 -lbl_804FD0C8 = .data:0x804FD0C8; // type:object size:0x60 -lbl_804FD128 = .data:0x804FD128; // type:object size:0x18 data:string -lbl_804FD140 = .data:0x804FD140; // type:object size:0x40 +@5819 = .data:0x804FD0C8; // type:object size:0x10 scope:local data:string +...data.0 = .data:0x804FD0C8; // type:label scope:local +@5821 = .data:0x804FD0D8; // type:object size:0x10 scope:local data:string +@5823 = .data:0x804FD0E8; // type:object size:0x10 scope:local data:string +@5825 = .data:0x804FD0F8; // type:object size:0xD scope:local data:string +@5826 = .data:0x804FD108; // type:object size:0xD scope:local data:string +@5827 = .data:0x804FD118; // type:object size:0xD scope:local data:string +@5854 = .data:0x804FD128; // type:object size:0x18 scope:local data:string +@5878 = .data:0x804FD140; // type:object size:0x13 scope:local data:string +@5887 = .data:0x804FD158; // type:object size:0x10 scope:local data:string +@5888 = .data:0x804FD168; // type:object size:0x17 scope:local data:string lbl_804FD180 = .data:0x804FD180; // type:object size:0xC lbl_804FD18C = .data:0x804FD18C; // type:object size:0xC lbl_804FD198 = .data:0x804FD198; // type:object size:0xC @@ -35920,9 +35928,15 @@ __vt__19dAcOswMdlCallback_c = .data:0x80535E38; // type:object size:0x18 @9734 = .data:0x80535F6C; // type:object size:0x17 scope:local data:string __vt__22sFStateID_c<8dAcOsw_c> = .data:0x80535F84; // type:object size:0x34 scope:weak g_profile_THPPLAYER = .data:0x80535FB8; // type:object size:0xC -lbl_80535FC4 = .data:0x80535FC4; // type:object size:0x7C -lbl_80536040 = .data:0x80536040; // type:object size:0x50 -lbl_80536090 = .data:0x80536090; // type:object size:0x10 +...data.0 = .data:0x80535FB8; // type:label scope:local +@10708 = .data:0x80535FC4; // type:object size:0x12 scope:local data:string +@10709 = .data:0x80535FD8; // type:object size:0x12 scope:local data:string +@10710 = .data:0x80535FEC; // type:object size:0x12 scope:local data:string +@10711 = .data:0x80536000; // type:object size:0x11 scope:local data:string +@10712 = .data:0x80536014; // type:object size:0x17 scope:local data:string +@10713 = .data:0x8053602C; // type:object size:0x11 scope:local data:string +__vt__12dThpPlayer_c = .data:0x80536040; // type:object size:0x4C +__vt__14ThpVideoScreen = .data:0x80536090; // type:object size:0x10 g_profile_ALLDIE_TAG = .data:0x805360A0; // type:object size:0x10 TgAlldie__vtable = .data:0x805360B0; // type:object size:0x78 g_profile_VIEW_CLIP_TAG = .data:0x80536128; // type:object size:0x10 @@ -38934,10 +38948,10 @@ jumptable_805713CC = .data:0x805713CC; // type:object size:0x1C scope:local gTRKExceptionStatus = .data:0x80571418; // type:object size:0x10 scope:local data:4byte lbl_80571440 = .sdata:0x80571440; // type:object size:0x8 lbl_80571448 = .sdata:0x80571448; // type:object size:0x8 data:string -lbl_80571450 = .sdata:0x80571450; // type:object size:0x4 -lbl_80571454 = .sdata:0x80571454; // type:object size:0x4 data:string -lbl_80571458 = .sdata:0x80571458; // type:object size:0x8 -lbl_80571460 = .sdata:0x80571460; // type:object size:0x8 +@5820 = .sdata:0x80571450; // type:object size:0x3 scope:local data:string +@5822 = .sdata:0x80571454; // type:object size:0x4 scope:local data:string +@5824 = .sdata:0x80571458; // type:object size:0x5 scope:local data:string +@5855 = .sdata:0x80571460; // type:object size:0x6 scope:local data:string lbl_80571468 = .sdata:0x80571468; // type:object size:0x8 lbl_80571470 = .sdata:0x80571470; // type:object size:0x8 lbl_80571478 = .sdata:0x80571478; // type:object size:0x8 @@ -39234,7 +39248,7 @@ status_1__4dDyl = .sdata:0x80571C40; // type:object size:0x4 data:4byte status_2__4dDyl = .sdata:0x80571C44; // type:object size:0x4 data:4byte lbl_80571C48 = .sdata:0x80571C48; // type:object size:0x8 g_CurrentScreenTo4x3WidthScale__6dGfx_c = .sdata:0x80571C50; // type:object size:0x4 align:4 data:float -lbl_80571C58 = .sdata:0x80571C58; // type:object size:0x8 data:byte +sAssertOnAllocFailure = .sdata:0x80571C58; // type:object size:0x1 scope:local data:byte m_current_ex__Q24dPad4ex_c = .sdata:0x80571C60; // type:object size:0x4 data:4byte lbl_80571C68 = .sdata:0x80571C68; // type:object size:0x8 OBTAINED_ITEM_ID = .sdata:0x80571C70; // type:object size:0x4 data:4byte @@ -40666,7 +40680,7 @@ lbl_80573F54 = .sdata:0x80573F54; // type:object size:0x4 data:4byte lbl_80573F58 = .sdata:0x80573F58; // type:object size:0x8 lbl_80573F60 = .sdata:0x80573F60; // type:object size:0x8 __THPVersion = .sdata:0x80573F68; // type:object size:0x8 data:4byte -lbl_80573F70 = .sdata:0x80573F70; // type:object size:0x8 data:4byte +sPrintfFunc__4sLib = .sdata:0x80573F70; // type:object size:0x4 scope:local data:4byte @4277 = .sdata:0x80573F78; // type:object size:0x5 scope:local data:string @4029 = .sdata:0x80573F80; // type:object size:0x6 scope:local data:string sRelsDir__20DynamicModuleControl = .sdata:0x80573F88; // type:object size:0x4 data:4byte @@ -41280,10 +41294,10 @@ lbl_80574FA4 = .sbss:0x80574FA4; // type:object size:0x4 data:4byte lbl_80574FA8 = .sbss:0x80574FA8; // type:object size:0x1 data:byte lbl_80574FA9 = .sbss:0x80574FA9; // type:object size:0x1 data:byte lbl_80574FAA = .sbss:0x80574FAA; // type:object size:0x6 data:byte -lbl_80574FB0 = .sbss:0x80574FB0; // type:object size:0x4 data:4byte -sAsserted = .sbss:0x80574FB4; // type:object size:0x1 data:byte -lbl_80574FB5 = .sbss:0x80574FB5; // type:object size:0x1 data:byte -ErrorCode = .sbss:0x80574FB6; // type:object size:0x1 data:byte +sButtonSequencePtr = .sbss:0x80574FB0; // type:object size:0x4 scope:local data:4byte +sAsserted = .sbss:0x80574FB4; // type:object size:0x1 scope:local data:byte +@GUARD@exceptionCreate__FPQ23EGG4Heap@mapFile = .sbss:0x80574FB5; // type:object size:0x1 scope:local data:byte +sPanicked = .sbss:0x80574FB6; // type:object size:0x1 scope:local data:byte lbl_80574FB8 = .sbss:0x80574FB8; // type:object size:0x1 data:byte s_$cam = .sbss:0x80574FBC; // type:object size:0x4 data:4byte lbl_80574FC0 = .sbss:0x80574FC0; // type:object size:0x1 data:byte @@ -41882,7 +41896,7 @@ Vdchuff = .sbss:0x80575B20; // type:object size:0x20 data:4byte Udchuff = .sbss:0x80575B40; // type:object size:0x20 data:4byte Ydchuff = .sbss:0x80575B60; // type:object size:0x8 data:4byte sm_numberMemo__10sStateID_c = .sbss:0x80575B68; // type:object size:0x4 data:4byte -lbl_80575B70 = .sbss:0x80575B70; // type:object size:0x8 data:4byte +sAssertCallback__7sAssert = .sbss:0x80575B70; // type:object size:0x4 data:4byte cCounter_c__m_gameFrame = .sbss:0x80575B78; // type:object size:0x4 data:4byte lbl_80575B7C = .sbss:0x80575B7C; // type:object size:0x4 data:4byte mFirst__24DynamicModuleControlBase = .sbss:0x80575B80; // type:object size:0x4 data:4byte @@ -42656,7 +42670,7 @@ g_CurrentSequence = .sbss:0x805769A8; // type:object size:0x4 data:4byte IsTRKConnected = .sbss:0x805769AC; // type:object size:0x4 data:4byte TRK_saved_exceptionID = .sbss:0x805769B0; // type:object size:0x2 scope:local data:2byte bUseSerialIO = .sbss:0x805769B8; // type:object size:0x1 data:byte -lbl_805769C0 = .sdata2:0x805769C0; // type:object size:0x8 data:byte +sErrorCodes = .sdata2:0x805769C0; // type:object size:0x5 scope:local data:byte lbl_805769C8 = .sdata2:0x805769C8; // type:object size:0x4 align:4 data:float lbl_805769CC = .sdata2:0x805769CC; // type:object size:0x4 align:4 data:float lbl_805769D0 = .sdata2:0x805769D0; // type:object size:0x8 align:8 data:double @@ -47656,8 +47670,8 @@ lbl_8057C494 = .sdata2:0x8057C494; // type:object size:0x4 align:4 data:float @9626 = .sdata2:0x8057C4D0; // type:object size:0x4 scope:local align:4 data:float @9633 = .sdata2:0x8057C4D4; // type:object size:0x4 scope:local align:4 data:float @9634 = .sdata2:0x8057C4D8; // type:object size:0x4 scope:local align:4 data:float -lbl_8057C4E0 = .sdata2:0x8057C4E0; // type:object size:0x8 -lbl_8057C4E8 = .sdata2:0x8057C4E8; // type:object size:0x8 align:8 data:double +SPECIAL_TYPES = .sdata2:0x8057C4E0; // type:object size:0x3 scope:local data:string +@10716 = .sdata2:0x8057C4E8; // type:object size:0x8 scope:local align:8 data:double lbl_8057C4F0 = .sdata2:0x8057C4F0; // type:object size:0x4 align:4 data:float lbl_8057C4F4 = .sdata2:0x8057C4F4; // type:object size:0x4 align:4 data:float lbl_8057C4F8 = .sdata2:0x8057C4F8; // type:object size:0x4 align:4 data:float @@ -50397,9 +50411,9 @@ bd_addr_null = .sbss2:0x8057FFB0; // type:object size:0x8 DefaultBlackColor = .sbss2:0x8057FFB8; // type:object size:0x8 scope:local data:2byte sBlack__3EGG = .sbss2:0x8057FFC0; // type:object size:0x4 scope:local data:byte lbl_8057FFC8 = .sbss2:0x8057FFC8; // type:object size:0x4 -lbl_80580000 = .bss:0x80580000; // type:object size:0x14 data:4byte -lbl_80580014 = .bss:0x80580014; // type:object size:0xC -mapFile = .bss:0x80580020; // type:object size:0x18 data:4byte +sSavedErrorHandlers = .bss:0x80580000; // type:object size:0x14 scope:local data:4byte +@5782 = .bss:0x80580014; // type:object size:0xC scope:local +@LOCAL@exceptionCreate__FPQ23EGG4Heap@mapFile = .bss:0x80580020; // type:object size:0x14 scope:local data:4byte lbl_80580038 = .bss:0x80580038; // type:object size:0xC align:4 data:float lbl_80580044 = .bss:0x80580044; // type:object size:0xC align:4 data:float lbl_80580050 = .bss:0x80580050; // type:object size:0xC align:4 data:float diff --git a/configure.py b/configure.py index d2aca699..e504d6a8 100644 --- a/configure.py +++ b/configure.py @@ -392,7 +392,7 @@ config.libs = [ Object(NonMatching, "toBeSorted/unk_sorajima_list.cpp"), Object(NonMatching, "toBeSorted/mpls.cpp"), Object(NonMatching, "toBeSorted/mdl_base.cpp"), - Object(NonMatching, "toBeSorted/d_assert.cpp"), + Object(Matching, "toBeSorted/d_exception.cpp"), Object(NonMatching, "toBeSorted/d_jstudio.cpp"), Object(Matching, "toBeSorted/save_file.cpp"), Object(NonMatching, "toBeSorted/file_manager.cpp"), @@ -917,7 +917,7 @@ config.libs = [ "progress_category": "core", "host": False, "objects": [ - Object(NonMatching, "s/s_Assert.cpp"), + Object(Matching, "s/s_Assert.cpp"), Object(Matching, "s/s_Crc.cpp"), Object(Matching, "s/s_Math.cpp"), Object(Matching, "s/s_FPhase.cpp"), @@ -925,7 +925,7 @@ config.libs = [ Object(Matching, "s/s_StateMethod.cpp"), Object(Matching, "s/s_StateMethodUsr_FI.cpp"), Object(Matching, "s/s_Phase.cpp"), - Object(NonMatching, "s/s_Print.cpp"), + Object(Matching, "s/s_Print.cpp"), ], }, { diff --git a/include/egg/util/eggException.h b/include/egg/util/eggException.h index 6a2cc957..8fa16b85 100644 --- a/include/egg/util/eggException.h +++ b/include/egg/util/eggException.h @@ -37,7 +37,7 @@ public: static void SetPreExceptionCallback(void (*cb)()); static void SetCallbackMode(bool); static void SetCallbackArgs(void *); - nw4r::db::ConsoleHandle GetConsoleHandle(); + static nw4r::db::ConsoleHandle GetConsoleHandle(); }; } // namespace EGG diff --git a/include/m/m_pad.h b/include/m/m_pad.h index 1c0bc9e6..3942e191 100644 --- a/include/m/m_pad.h +++ b/include/m/m_pad.h @@ -24,6 +24,7 @@ enum Button { BUTTON_MINUS = 0x1000, BUTTON_Z = 0x2000, BUTTON_C = 0x4000, + BUTTON_HOME = 0x8000, }; inline EGG::CoreController *getCore(const int i) { diff --git a/include/rvl/AI/ai.h b/include/rvl/AI/ai.h index 3fe542be..7a5be82d 100644 --- a/include/rvl/AI/ai.h +++ b/include/rvl/AI/ai.h @@ -18,6 +18,7 @@ typedef enum { AIDMACallback AIRegisterDMACallback(AIDMACallback callback); void AIInitDMA(void *buffer, u32 length); void AIStartDMA(void); +void AIStopDMA(void); u32 AIGetDMABytesLeft(void); void AISetDSPSampleRate(u32 rate); u32 AIGetDSPSampleRate(void); diff --git a/include/rvl/OS/OSError.h b/include/rvl/OS/OSError.h index 724850a1..0752584d 100644 --- a/include/rvl/OS/OSError.h +++ b/include/rvl/OS/OSError.h @@ -38,7 +38,8 @@ typedef enum { OS_ERR_MAX } OSErrorType; -typedef void (*OSErrorHandler)(u16 error, OSContext *ctx, u32 dsisr, u32 dar); +typedef u16 OSError; +typedef void (*OSErrorHandler)(OSError error, OSContext* context, ...); extern OSErrorHandler __OSErrorTable[OS_ERR_MAX]; extern u32 __OSFpscrEnableBits; diff --git a/include/s/README.txt b/include/s/README.txt index dc469bfe..de767b78 100644 --- a/include/s/README.txt +++ b/include/s/README.txt @@ -30,3 +30,7 @@ Implemented by SS based on NSMBW symbols. Probably missing some parts, sync with ## s_FPhase SS-only. Symbols/names completely made up. + +## s_Assert, s_Print + +SS-only. Symbols/names completely made up. diff --git a/include/s/s_Assert.h b/include/s/s_Assert.h new file mode 100644 index 00000000..40520854 --- /dev/null +++ b/include/s/s_Assert.h @@ -0,0 +1,13 @@ +#ifndef S_ASSERT_H +#define S_ASSERT_H + +namespace sAssert { + +typedef void (*AssertCallback)(void *); + +void setAssertCallback(AssertCallback cb); +void assert(); + +} // namespace sAssert + +#endif diff --git a/include/s/s_Crc.h b/include/s/s_Crc.h index 2e7809a0..ec09ecde 100644 --- a/include/s/s_Crc.h +++ b/include/s/s_Crc.h @@ -5,7 +5,7 @@ namespace sCrc { -u32 calcCRC(const void *ptr, u32 size); +u32 calcCRC32(const void *ptr, u32 size); } // namespace sCrc diff --git a/include/s/s_Print.h b/include/s/s_Print.h new file mode 100644 index 00000000..75992fd4 --- /dev/null +++ b/include/s/s_Print.h @@ -0,0 +1,10 @@ +#ifndef S_PRINT_H +#define S_PRINT_H + +namespace sLib { + +void printf(const char *msg, ...); + +} // namespace sLib + +#endif diff --git a/include/toBeSorted/d_exception.h b/include/toBeSorted/d_exception.h new file mode 100644 index 00000000..a46671a9 --- /dev/null +++ b/include/toBeSorted/d_exception.h @@ -0,0 +1,8 @@ +#ifndef D_EXCEPTION_H +#define D_EXCEPTION_H + +#include "egg/core/eggHeap.h" + +void exceptionCreate(EGG::Heap *heap); + +#endif diff --git a/include/toBeSorted/revision_info.h b/include/toBeSorted/revision_info.h new file mode 100644 index 00000000..58aa98e1 --- /dev/null +++ b/include/toBeSorted/revision_info.h @@ -0,0 +1,8 @@ +#ifndef TOBESORTED_REVISION_INFO_H +#define TOBESORTED_REVISION_INFO_H + +const char *getUrlInfo(); +const char *getRevisionInfo(); +const char *getCopydate(); + +#endif diff --git a/src/d/d_heap.cpp b/src/d/d_heap.cpp index e5b926a3..b3441f0d 100644 --- a/src/d/d_heap.cpp +++ b/src/d/d_heap.cpp @@ -1,7 +1,7 @@ #include "d/d_heap.h" #include "d/d_heap_alloc.h" - +#include "s/s_Assert.h" dHeap dHeap::work1Heap; dHeap dHeap::work2Heap; @@ -14,8 +14,7 @@ dHeap dHeap::fontHeap; dHeap dHeap::HBMHeap; dHeapAllocator dHeapAllocator::sAllocator; -extern u8 lbl_80571C58; -extern "C" void fn_802DE710(); +static bool sAssertOnAllocFailure = true; // TODO TU splits? @@ -23,10 +22,10 @@ void dHeapAllocator::onAlloc(EGG::HeapAllocArg *arg) { if (arg->ptr != nullptr) { return; } - if (lbl_80571C58 == 0) { + if (!sAssertOnAllocFailure) { return; } - fn_802DE710(); + sAssert::assert(); } EGG::ExpHeap *dHeap::init(const char *name, size_t size, EGG::Heap *parent) { @@ -75,7 +74,6 @@ void dHeap::createHBMHeap(size_t size, EGG::Heap *parent) { HBMHeap.init(name, size, parent); } -// TODO this doesn't match (many more stack stores) void dHeapAllocator::initCallbacks() { sAllocator.doInitCallbacks(); } diff --git a/src/nw4r/db/db_exception.cpp b/src/nw4r/db/db_exception.cpp index dccba52e..69f1d567 100644 --- a/src/nw4r/db/db_exception.cpp +++ b/src/nw4r/db/db_exception.cpp @@ -4,6 +4,7 @@ #include "nw4r/db/db_mapFile.h" #include "rvl/GX.h" // IWYU pragma: export #include "rvl/VI.h" // IWYU pragma: export +#include "rvl/OS/OSError.h" #include "string.h" @@ -63,12 +64,13 @@ void Exception_Init() { OSCreateThread(&sException.thread, RunThread_, nullptr, sThreadBuffer + 0x4000, 0x4000, 0, 1); OSInitMessageQueue(&sException.queue, sMessageBuffer, 1); OSResumeThread(&sException.thread); - OSSetErrorHandler(2, ErrorHandler_); - OSSetErrorHandler(3, ErrorHandler_); - OSSetErrorHandler(5, ErrorHandler_); - OSSetErrorHandler(15, ErrorHandler_); + // UB: casting non-variadic function to variadic (and letting OS invoke it) + OSSetErrorHandler(OS_ERR_DSI, (OSErrorHandler)ErrorHandler_); + OSSetErrorHandler(OS_ERR_ISI, (OSErrorHandler)ErrorHandler_); + OSSetErrorHandler(OS_ERR_ALIGNMENT, (OSErrorHandler)ErrorHandler_); + OSSetErrorHandler(OS_ERR_PROTECTION, (OSErrorHandler)ErrorHandler_); __OSFpscrEnableBits = 0; - OSSetErrorHandler(16, nullptr); + OSSetErrorHandler(OS_ERR_FP_EXCEPTION, nullptr); } extern "C" u32 PPCMfmsr(); extern "C" void PPCMtmsr(u32); diff --git a/src/s/s_Assert.cpp b/src/s/s_Assert.cpp new file mode 100644 index 00000000..d39925f7 --- /dev/null +++ b/src/s/s_Assert.cpp @@ -0,0 +1,22 @@ +#include "s/s_Assert.h" + +#include "common.h" + +namespace sAssert { + +typedef void (*AssertCallback)(void *); + +AssertCallback sAssertCallback; + +void setAssertCallback(AssertCallback cb) { + sAssertCallback = cb; +} + +void assert() { + if (sAssertCallback != nullptr) { + (sAssertCallback)(nullptr); + } + while (true) {} +} + +} // namespace sAssert diff --git a/src/s/s_Crc.cpp b/src/s/s_Crc.cpp index 7ba034fb..67e0e226 100644 --- a/src/s/s_Crc.cpp +++ b/src/s/s_Crc.cpp @@ -4,7 +4,7 @@ namespace sCrc { -u32 calcCRC(const void *ptr, u32 size) { +u32 calcCRC32(const void *ptr, u32 size) { return OSCalcCRC32(ptr, size); } diff --git a/src/s/s_Print.cpp b/src/s/s_Print.cpp new file mode 100644 index 00000000..3a94b0cc --- /dev/null +++ b/src/s/s_Print.cpp @@ -0,0 +1,42 @@ +#include "s/s_Print.h" + +#include "rvl/OS/OSError.h" + +#include +#include +#include + +namespace sLib { + +typedef int (*vprintf_sig)(const char *format, va_list args); + +static vprintf_sig sPrintfFunc = &std::vprintf; + +static vprintf_sig getVprintfFunc() { + return sPrintfFunc; +} + +static void my_vprintf(const char *format, va_list args) { + (getVprintfFunc())(format, args); +} + +void printf(const char *msg, ...) { + va_list l; + va_start(l, msg); + vprintf(msg, l); + va_end(l); +} + +} // namespace sLib + +// Overriding the weakly linked OS functions... +void OSReport(const char *msg, ...) { + va_list l; + va_start(l, msg); + OSVReport(msg, l); + va_end(l); +} + +void OSVReport(const char *msg, va_list args) { + sLib::my_vprintf(msg, args); +} diff --git a/src/toBeSorted/d_exception.cpp b/src/toBeSorted/d_exception.cpp new file mode 100644 index 00000000..f6a4384b --- /dev/null +++ b/src/toBeSorted/d_exception.cpp @@ -0,0 +1,172 @@ +#include "toBeSorted/d_exception.h" + +#include "DynamicLink.h" +#include "common.h" +#include "egg/core/eggController.h" +#include "egg/core/eggHeap.h" +#include "egg/prim/eggAssert.h" +#include "egg/util/eggException.h" +#include "m/m_pad.h" +#include "nw4r/db/db_assert.h" +#include "nw4r/db/db_console.h" +#include "nw4r/db/db_exception.h" +#include "rvl/AI/AI.h" +#include "rvl/KPAD/KPAD.h" +#include "rvl/OS/OSError.h" +#include "rvl/OS/OSInterrupt.h" +#include "rvl/WPAD/WPAD.h" +#include "s/s_Assert.h" +#include "toBeSorted/revision_info.h" + +#include + +#define D_INFO_BUILD_TYPE "PRD" + +#define D_INFO_COUNTRY "US" +#define D_INFO_GAME_CODE "SOUE" + +#define D_ASSERT_NUM_ERROR_HANDLERS 5 + +static const u8 sErrorCodes[D_ASSERT_NUM_ERROR_HANDLERS] = { + OS_ERR_DSI, OS_ERR_ISI, OS_ERR_ALIGNMENT, OS_ERR_PROTECTION, OS_ERR_FP_EXCEPTION +}; + +static OSErrorHandler sSavedErrorHandlers[D_ASSERT_NUM_ERROR_HANDLERS] = {}; + +static void printGameInfo() { + nw4r::db::ConsoleHandle c = nw4r::db::Exception_GetConsole(); + nw4r::db::Console_Printf(c, " COUNTRY: %s\n", D_INFO_COUNTRY); + nw4r::db::Console_Printf(c, "BUILD_TYPE: %s\n", D_INFO_BUILD_TYPE); + nw4r::db::Console_Printf(c, " GAME_CODE: %s\n", D_INFO_GAME_CODE); + + nw4r::db::Console_Printf(c, "URL_INFO:%s\n", getUrlInfo()); + nw4r::db::Console_Printf(c, "REV_INFO:%s\n", getRevisionInfo()); + nw4r::db::Console_Printf(c, "COPYDATE:%s\n", getCopydate()); +} + +// Copied from EGG::Exception::ExceptionCallback_ +static void waitForButtonSequence(void *data) { + KPADStatus status; + OSEnableInterrupts(); + if (data != nullptr) { + // Require a specific button sequence to show the exception handler + int u4 = 0; + while (((u16 *)data)[u4] != 0) { + KPADRead(0, &status, 1); + EGG::Exception::ExceptionWaitTime(50); + if (status.trig) { + // Reset the sequence on wrong button press, advance on right button press + u4 = status.trig & (((u16 *)data)[u4]) ? u4 + 1 : 0; + } + } + } +} + +static void preExceptionCallback() { + WPADControlMotor(0, WPAD_MOTOR_STOP); + AIStopDMA(); + WPADSetAcceptConnection(true); + printGameInfo(); +} + +static void exceptionCallback(EGG::CoreStatus *status) { + if ((status->hold & (mPad::BUTTON_MINUS | mPad::BUTTON_PLUS)) == (mPad::BUTTON_MINUS | mPad::BUTTON_PLUS)) { + // When holding Minus and Plus at the same time, go back to the EGG exception handler + EGG::Exception::SetCallbackMode(true); + EGG::Exception::SetUserCallback(nullptr); + } +} + +static void *sButtonSequencePtr = nullptr; + +static void assertCallback() { + WPADControlMotor(0, WPAD_MOTOR_STOP); + AIStopDMA(); + WPADSetAcceptConnection(true); + waitForButtonSequence(sButtonSequencePtr); + printGameInfo(); +} + +static bool sAsserted = false; +static void sAssertCallback(void *) { + OSDisableInterrupts(); + if (sAsserted) { + OSReport("Recursive assertioned.\n"); + while (true) {} + } + sAsserted = true; + EGG::Assert::assert("PANIC", 0, "PANIC"); +} + +static void mainErrorHandler(u16 error, OSContext *ctx, u32 dsisr, u32 dar) { + for (int i = 0; i < D_ASSERT_NUM_ERROR_HANDLERS; i++) { + if (error == sErrorCodes[i] && sSavedErrorHandlers[i] != nullptr) { + (sSavedErrorHandlers[i])(error, ctx, dsisr, dar); + } + } +} + +static void initErrorHandlers() { + for (int i = 0; i < D_ASSERT_NUM_ERROR_HANDLERS; i++) { + // UB: casting non-variadic function to variadic (and letting OS invoke it) + OSErrorHandler oldHandler = OSSetErrorHandler(sErrorCodes[i], (OSErrorHandler)mainErrorHandler); + if (oldHandler != nullptr) { + sSavedErrorHandlers[i] = oldHandler; + } else { + OSSetErrorHandler(sErrorCodes[i], nullptr); + } + } +} + +// HOME, -, +, -, +, 1, 2, 1, 2, A, same as NSMBW +static const u16 sButtonSequence[] = { + mPad::BUTTON_HOME, + mPad::BUTTON_MINUS, + mPad::BUTTON_PLUS, + mPad::BUTTON_MINUS, + mPad::BUTTON_PLUS, + mPad::BUTTON_1, + mPad::BUTTON_2, + mPad::BUTTON_1, + mPad::BUTTON_2, + mPad::BUTTON_A, + 0, +}; + +void exceptionCreate(EGG::Heap *heap) { + EGG::Exception::create(64, 100, 1, heap, 0); + initErrorHandlers(); + + static DbMapFile mapFile; + mapFile.RegisterOnDvd("maps/RVZELDANP.map", nullptr); + nw4r::db::Exception_SetDisplayInfo(0x20 | 0x10 | 0x8 | 0x4 | 0x2 | 0x1); + nw4r::db::Assertion_SetConsole(EGG::Exception::GetConsoleHandle()); + EGG::Exception::SetCallbackArgs((void *)sButtonSequence); + sButtonSequencePtr = (void *)sButtonSequence; + EGG::Exception::SetPreExceptionCallback(preExceptionCallback); + EGG::Exception::SetUserCallback(exceptionCallback); + EGG::Assert::setAssertCallback(assertCallback); + sAssert::setAssertCallback(sAssertCallback); +} + +// Overriding weakly linked OS function +static bool sPanicked = false; +void OSPanic(const char *file, int line, const char *msg, ...) { + OSDisableInterrupts(); + if (sPanicked) { + OSReport("Recursive assertioned.\n"); + while (true) {} + } + sPanicked = true; + + va_list l; + va_start(l, msg); + EGG::Assert::system_halt(file, line, msg, l); + va_end(l); +} + +// Pooled data +void d_exception_unused() { + OSReport("d_Exception.cpp"); + OSReport("Recursive assertioned."); +} diff --git a/src/toBeSorted/file_manager.cpp b/src/toBeSorted/file_manager.cpp index 3f8fdb5e..19a3a055 100644 --- a/src/toBeSorted/file_manager.cpp +++ b/src/toBeSorted/file_manager.cpp @@ -433,7 +433,7 @@ extern "C" void fn_800C01F0(); // todo flag managers return &mFileB; } /* 80011280 */ u32 FileManager::calcFileCRC(const void *data, u32 length) { - return sCrc::calcCRC(data, length); + return sCrc::calcCRC32(data, length); } /* 80011290 */ void FileManager::updateEmptyFiles() { updateEmptyFileFlags();