private static int TryDisassemble(DisassemblyOptions opts, Func <RomVersion, string, Func <DisassemblyTask, bool> > getFilter) { string path; if (!RomVersion.TryGet(opts.GameId, opts.VersionId, out RomVersion version)) { Console.WriteLine($"Unrecognized version {opts.GameId} {opts.VersionId}"); return(-1); } if (opts.RomPath != null) { path = opts.RomPath; } else if (!PathUtil.TryGetRomLocation(version, out path)) { Console.WriteLine($"Cannot find path for {opts.GameId} {opts.VersionId}"); return(-1); } Disassemble.MipsToC = opts.MipsToCOutput; Disassemble.GccOutput = Disassemble.MipsToC || !opts.ReadableOutput; Disassemble.PrintRelocations = true; Disassemble.SetGprNames(); Func <DisassemblyTask, bool> filter = getFilter(version, path); if (filter == null) { return(-1); } DisassembleRom(version, path, filter); return(0); }
private static int UpdateRomPath(PathOptions a) { if (!RomVersion.TryGet(a.GameId, a.VersionId, out RomVersion ver)) { Console.WriteLine($"Unrecognized version {a.GameId} {a.VersionId}"); return(-1); } string path = a.RomPath; if (!File.Exists(path)) { Console.WriteLine($"Cannot find file {path}"); return(-1); } PathUtil.SetRomLocation(ver, path); Console.WriteLine($"Path updated! Re-run program to continue"); return(0); }
/* prototype: * adis o stalfo.s 2 ZELOOTMA.z64 */ //80A44CD0 80A46710 //int NAMETABLE_ADD = 0xA771A0; static void Main(string[] a) { PathUtil.Initialize(); if (a.Length == 0) { Console.WriteLine("Help:"); Console.WriteLine("path [gameid] [versionid] [path] //sets a path to a rom"); Console.WriteLine("all [gameid] [versionid] //creates a gcc compatible disassembly of the entire rom"); Console.WriteLine("all_r [gameid] [versionid] //creates a more readable disassembly of the entire rom"); Console.WriteLine("df [gameid] [versionid] [name] //creates a disassembly of a specific overlay file"); //Console.WriteLine("daf [gameid] [versionid] [id] //creates a disassembly of a specific actor file, using the actor"); Console.WriteLine("script [path] //converts elf (.o) files to overlay form, and injects into the rom"); Console.WriteLine("newscript //creates a file called dummy.xml for easy templating"); Console.WriteLine("ovl [vram] [path] //creates an overlay file named [path].ovl from an elf (.o) file"); Console.WriteLine("dcust [pc] [path]"); Console.WriteLine(); Console.WriteLine("Enter a command:"); var read = Console.ReadLine(); a = ParseArguments(read); if (a.Length == 0) { Console.WriteLine("Terminated!"); return; } } if (a[0] == "path" && (a.Length == 3 || a.Length == 4)) { string path = ""; if (!RomVersion.TryGet(a[1], a[2], out RomVersion ver)) { Console.WriteLine($"Unrecognized version {a[1]} {a[2]}"); return; } if (a.Length == 4) { path = a[3]; } else { Console.Write("Enter a path: "); path = Console.ReadLine(); } if (!File.Exists(path)) { Console.WriteLine($"Cannot find file {path}"); return; } PathUtil.SetRomLocation(ver, path); Console.WriteLine($"Path updated! Re-run program to continue"); } else if (a.Length == 3 && a[0] == "all") { if (!RomVersion.TryGet(a[1], a[2], out RomVersion version)) { Console.WriteLine($"Unrecognized version {a[1]} {a[2]}"); return; } if (PathUtil.TryGetRomLocation(version, out string path)) { Disassemble.GccOutput = true; Disassemble.PrintRelocations = true; DisassembleRom(version, path); } } else if (a.Length == 3 && a[0] == "all_r") { if (!RomVersion.TryGet(a[1], a[2], out RomVersion version)) { Console.WriteLine($"Unrecognized version {a[1]} {a[2]}"); return; } if (PathUtil.TryGetRomLocation(version, out string path)) { Disassemble.GccOutput = false; Disassemble.PrintRelocations = true; DisassembleRom(version, path); } } else if (a.Length == 3 && a[0] == "ovl") { if (!int.TryParse(a[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int addr)) { Console.WriteLine("Cannot parse address given"); return; } ElfToOverlay(a[2], addr); } else if (a.Length == 2 && a[0] == "script") { ElfUtil.ProcessInjectScript(a[1]); } else if (a[0] == "newscript") { ElfUtil.CreateDummyScript("dummy.xml"); } else if (a[0] == "df" && a.Length == 4) { if (!RomVersion.TryGet(a[1], a[2], out RomVersion version)) { Console.WriteLine($"Unrecognized version {a[1]} {a[2]}"); return; } OverlayTest(version, a[3]); //ovl_Boss_Fd // "ovl_Fishing"; } else if (a[0] == "elftest") { ElfToOverlayTest(); } }