mirror of
https://github.com/zeldaret/oot
synced 2026-08-22 06:44:46 -04:00
[ntsc-1.2] Decompile fault.c (#2046)
* wip decomp ntsc-1.2 fault.c
* more ntsc-1.2 fault.c
* decompiled fault_v1.c
* name fault_v1 functions, wip
* try to clean up build system (two versions of the fault system coexisting)
* cleanup
* cleanup2
* fix build gc-eu-mq-dbg
* match 2 more, ty anon
* matched
* review
* more review
* fixup spec
* `(uintptr_t)ptr op int` instead of `ptr op (type*)int`
* move fault.h out of global headers, properly include fault.h and versions.h
* compile all fault_*.c files regardless of version by overriding FAULT_VERSION
* n64 FaultMgr.framebuffer s32 -> u16*
* FaultMgr.framebuffer -> FaultMgr.fb
* make gc FaultMgr.fb u16* (yes, thats everything)
* bss
* fix Fault_Printf return type
* noop FaultDrawer_SetFontColor, FaultDrawer_SetCharPad in fault_n64
* fault_color_ stuff is only for fault_gc
* rm empty line in makefile
* I guess `D_80105A90_unknown` is `[sg]TotalAllocFailures`
* bss
* `Fault_WaitInput` -> `Fault_WaitForInput`
* use named fault funcs in pointers array
* FAULT_OOT{N64,GC} -> FAULT_{N64,GC}
* Apply suggestions from code review
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com>
* review, sync fault_{gc,n64}
* Apply `FPCSR_CE` suggestions from code review
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
---------
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com>
This commit is contained in:
@@ -108,7 +108,7 @@ DB80,8001F260,src/code/z_actor
|
||||
9BD80,800AD460,src/code/irqmgr
|
||||
9C3A0,800ADA80,src/code/code_n64dd_800AD410
|
||||
9C450,800ADB30,src/code/code_n64dd_800AD4C0
|
||||
9C540,800ADC20,src/code/fault
|
||||
9C540,800ADC20,src/code/fault_n64
|
||||
9E710,800AFDF0,src/code/kanread
|
||||
9F1F0,800B08D0,src/audio/lib/synthesis
|
||||
A2380,800B3A60,src/audio/lib/heap
|
||||
@@ -276,7 +276,7 @@ EDD90,800FF470,src/code/sys_ucode
|
||||
EDDA0,800FF480,src/code/sys_rumble
|
||||
EDDB0,800FF490,src/code/irqmgr
|
||||
EDDD0,800FF4B0,src/code/code_n64dd_800AD4C0
|
||||
EE280,800FF960,src/code/fault
|
||||
EE280,800FF960,src/code/fault_n64
|
||||
EE300,800FF9E0,src/audio/lib/data
|
||||
F0710,80101DF0,src/audio/lib/synthesis
|
||||
F0740,80101E20,src/audio/lib/load
|
||||
@@ -363,7 +363,7 @@ F7E00,801094E0,src/code/sys_math3d
|
||||
F7E90,80109570,src/code/sys_math_atan
|
||||
F7EA0,80109580,src/code/sys_matrix
|
||||
F7ED0,801095B0,src/code/irqmgr
|
||||
F7EF0,801095D0,src/code/fault
|
||||
F7EF0,801095D0,src/code/fault_n64
|
||||
F8780,80109E60,src/audio/lib/synthesis
|
||||
F87A0,80109E80,src/audio/lib/heap
|
||||
F87D0,80109EB0,src/audio/lib/load
|
||||
@@ -440,7 +440,7 @@ offset,vram,.bss
|
||||
1103F0,80121AD0,src/code/sys_matrix
|
||||
110400,80121AE0,src/code/code_n64dd_800AD410
|
||||
110410,80121AF0,src/code/code_n64dd_800AD4C0
|
||||
110420,80121B00,src/code/fault
|
||||
110420,80121B00,src/code/fault_n64
|
||||
110EF0,801225D0,src/audio/lib/load
|
||||
110FB0,80122690,src/audio/general
|
||||
1111B0,80122890,src/audio/sfx
|
||||
|
||||
|
@@ -2313,40 +2313,40 @@ func_800ADBD0 = 0x800ADBD0; // type:func
|
||||
func_800ADC00 = 0x800ADC00; // type:func
|
||||
func_800ADC08 = 0x800ADC08; // type:func
|
||||
Fault_SleepImpl = 0x800ADC20; // type:func
|
||||
func_800ADC5C_unknown = 0x800ADC5C; // type:func
|
||||
func_800ADCD8_unknown = 0x800ADCD8; // type:func
|
||||
func_800ADD14_unknown = 0x800ADD14; // type:func
|
||||
func_800ADDF0_unknown = 0x800ADDF0; // type:func
|
||||
func_800ADE30_unknown = 0x800ADE30; // type:func
|
||||
func_800ADF4C_unknown = 0x800ADF4C; // type:func
|
||||
func_800ADF90_unknown = 0x800ADF90; // type:func
|
||||
func_800ADFE4_unknown = 0x800ADFE4; // type:func
|
||||
func_800AE020_unknown = 0x800AE020; // type:func
|
||||
func_800AE05C_unknown = 0x800AE05C; // type:func
|
||||
func_800AE064_unknown = 0x800AE064; // type:func
|
||||
func_800AE170_unknown = 0x800AE170; // type:func
|
||||
func_800AE1E0_unknown = 0x800AE1E0; // type:func
|
||||
func_800AE1F8_unknown = 0x800AE1F8; // type:func
|
||||
func_800AE258_unknown = 0x800AE258; // type:func
|
||||
func_800AE2B8_unknown = 0x800AE2B8; // type:func
|
||||
func_800AE35C_unknown = 0x800AE35C; // type:func
|
||||
func_800AE408_unknown = 0x800AE408; // type:func
|
||||
func_800AE4C0_unknown = 0x800AE4C0; // type:func
|
||||
func_800AE558_unknown = 0x800AE558; // type:func
|
||||
func_800AE998_unknown = 0x800AE998; // type:func
|
||||
func_800AEC94_unknown = 0x800AEC94; // type:func
|
||||
func_800AED1C_unknown = 0x800AED1C; // type:func
|
||||
func_800AF0E0_unknown = 0x800AF0E0; // type:func
|
||||
func_800AF1C4_unknown = 0x800AF1C4; // type:func
|
||||
func_800AF304_unknown = 0x800AF304; // type:func
|
||||
func_800AF370_unknown = 0x800AF370; // type:func
|
||||
func_800AF3DC_unknown = 0x800AF3DC; // type:func
|
||||
func_800AF4DC_unknown = 0x800AF4DC; // type:func
|
||||
func_800AF558_unknown = 0x800AF558; // type:func
|
||||
Fault_WaitForInputImpl = 0x800ADC5C; // type:func
|
||||
Fault_WaitForInput = 0x800ADCD8; // type:func
|
||||
Fault_DrawRec = 0x800ADD14; // type:func
|
||||
Fault_DrawRecBlack = 0x800ADDF0; // type:func
|
||||
Fault_DrawCharImpl = 0x800ADE30; // type:func
|
||||
Fault_DrawChar = 0x800ADF4C; // type:func
|
||||
Fault_DrawCornerRec = 0x800ADF90; // type:func
|
||||
Fault_DrawCornerRecRed = 0x800ADFE4; // type:func
|
||||
Fault_DrawCornerRecYellow = 0x800AE020; // type:func
|
||||
func_800AE05C = 0x800AE05C; // type:func
|
||||
Fault_PrintCallbackDraw = 0x800AE064; // type:func
|
||||
Fault_DrawText = 0x800AE170; // type:func
|
||||
Fault_SetCursor = 0x800AE1E0; // type:func
|
||||
func_800AE1F8 = 0x800AE1F8; // type:func
|
||||
Fault_Printf = 0x800AE258; // type:func
|
||||
Fault_PrintFReg = 0x800AE2B8; // type:func
|
||||
Fault_LogFReg = 0x800AE35C; // type:func
|
||||
Fault_PrintFPCSR = 0x800AE408; // type:func
|
||||
Fault_LogFPCSR = 0x800AE4C0; // type:func
|
||||
Fault_PrintThreadContext = 0x800AE558; // type:func
|
||||
Fault_LogThreadContext = 0x800AE998; // type:func
|
||||
Fault_FindFaultedThread = 0x800AEC94; // type:func
|
||||
Fault_WaitForButtonCombo = 0x800AED1C; // type:func
|
||||
func_800AF0E0 = 0x800AF0E0; // type:func
|
||||
Fault_DrawMemDumpContents = 0x800AF1C4; // type:func
|
||||
Fault_DrawMemDumpPC = 0x800AF304; // type:func
|
||||
Fault_DrawMemDumpSP = 0x800AF370; // type:func
|
||||
func_800AF3DC = 0x800AF3DC; // type:func
|
||||
Fault_ResumeThread = 0x800AF4DC; // type:func
|
||||
func_800AF558 = 0x800AF558; // type:func
|
||||
Fault_AddClient = 0x800AF5EC; // type:func
|
||||
Fault_RemoveClient = 0x800AF674; // type:func
|
||||
func_800AF720_unknown = 0x800AF720; // type:func
|
||||
func_800AF7F0_unknown = 0x800AF7F0; // type:func
|
||||
Fault_ProcessClients = 0x800AF720; // type:func
|
||||
Fault_ThreadEntry = 0x800AF7F0; // type:func
|
||||
Fault_SetFrameBuffer = 0x800AFA90; // type:func
|
||||
Fault_Init = 0x800AFABC; // type:func
|
||||
Fault_AddHungupAndCrashImpl = 0x800AFBC4; // type:func
|
||||
|
||||
@@ -22,6 +22,10 @@ _n64ddSegmentRomEnd = 0x00B9DA70;
|
||||
D_801DA410 = 0x801DA410;
|
||||
D_801E8090 = 0x801E8090;
|
||||
D_800FF4B0 = 0x800FF4B0; // size:0xB0 type:n64ddStruct_800FF4B0_pointers
|
||||
gPadMgr = 0x8011DBD0; // size:0x468 type:PadMgr
|
||||
gFaultMgr = 0x80121B60; // size:0x5D8 type:FaultMgr_v1
|
||||
sFaultInputs = 0x80121B00; // size:0x60 type:Input[4]
|
||||
gTotalAllocFailures = 0x80105A90; // size:0x4 type:u32
|
||||
gBitFlags = 0x800F9240; // size:0x80 type:u32[32]
|
||||
gSfxDefaultPos = 0x801049D4; // size:0xC type:Vec3f
|
||||
gSfxDefaultFreqAndVolScale = 0x801049E0; // size:0x4 type:f32
|
||||
|
||||
+7
-4
@@ -25,16 +25,16 @@ def get_c_file(directory):
|
||||
return file
|
||||
|
||||
|
||||
def import_c_file(in_file):
|
||||
def import_c_file(in_file, version):
|
||||
in_file = os.path.relpath(in_file, root_dir)
|
||||
cpp_command = ["gcc", "-E", "-P", "-Iinclude", "-Isrc", "-undef", "-DM2CTX", "-D__sgi", "-D_LANGUAGE_C",
|
||||
cpp_command = ["gcc", "-nostdinc", "-E", "-P", "-Iinclude", "-Iinclude/libc", "-Isrc", f"-Ibuild/{version}", "-I.", f"-Iextracted/{version}", "-undef", "-DM2CTX", "-D__sgi", "-D_LANGUAGE_C",
|
||||
"-DNON_MATCHING", "-D_Static_assert(x, y)=", "-D__attribute__(x)=", in_file]
|
||||
try:
|
||||
return subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8")
|
||||
except subprocess.CalledProcessError:
|
||||
print(
|
||||
"Failed to preprocess input file, when running command:\n"
|
||||
+ cpp_command,
|
||||
+ " ".join(cpp_command),
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
@@ -45,8 +45,11 @@ def main():
|
||||
description="Creates a ctx.c file for mips2c. "
|
||||
"Output will be saved as oot/ctx.c")
|
||||
parser.add_argument('filepath', help="path of c file to be processed")
|
||||
parser.add_argument("-v", "--oot-version", dest="oot_version", required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
version = args.oot_version
|
||||
|
||||
if args.filepath:
|
||||
c_file_path = args.filepath
|
||||
print("Using file: {}".format(c_file_path))
|
||||
@@ -60,7 +63,7 @@ def main():
|
||||
c_file_path = os.path.join(c_dir_path, c_file)
|
||||
print("Using file: {}".format(c_file_path))
|
||||
|
||||
output = import_c_file(c_file_path)
|
||||
output = import_c_file(c_file_path, version)
|
||||
|
||||
with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f:
|
||||
f.write(output)
|
||||
|
||||
Reference in New Issue
Block a user