Esempio n. 1
0
        private static void DisassembleTasks(RomVersion ver, List <DisassemblyTask> taskList, Func <FileAddress, Stream> getFile)
        {
            var folder = GetFolder(ver);

            Console.CursorVisible = false;
            foreach (var task in taskList)
            {
                string filename = $"{folder}/{task.Name}.txt";
                Console.Write($"\r{filename.PadRight(Console.BufferWidth)}");


                var file = getFile(task.VRom);

                foreach (var action in task.PreparseActions)
                {
                    action(file);
                }

                foreach (var item in task.Functions)
                {
                    Disassemble.AddFunction(item);
                }

                using var br = new BinaryReader(file);
                Disassemble.FirstParse(br, task);

                using var sw = File.CreateText(filename);
                Disassemble.Task(sw, br, task);
            }
            Console.CursorVisible = true;
        }
Esempio n. 2
0
        static void OverlayTest(RomVersion ver, string testOvl)
        {
            PathUtil.TryGetRomLocation(ver, out string path);
            Rom rom   = Rom.New(path, ver);
            var tasks = DisassemblyTask.CreateTaskList(rom);

            Disassemble.PrintRelocations = true;
            Disassemble.GccOutput        = true;

            var task = tasks.SingleOrDefault(x => x.Name == testOvl || x.Name == $"ovl_{testOvl}");

            if (task == null)
            {
                Console.WriteLine("Cannot find overlay");
                return;
            }
            //var taskbss = tasks.Where(x => x.Sections["bss"]?.Size > 0).ToList();

            var reader = new BinaryReader(rom.Files.GetFile(task.VRom));

            //using (StreamWriter sw = new StreamWriter("__test.txt"))
            //{
            //    foreach (var rel in task.Map.Relocations.Where(x => x.SectionId == Overlay.RelocationWord.Section.text))
            //    {
            //        reader.BaseStream.Position = rel.Offset;
            //        sw.WriteLine($"{rel.Offset:X6}: {rel.RelocType}  {GetOP(reader.ReadBigInt32())}");
            //    }
            //}

            using (StreamWriter sw = new StreamWriter($"__{testOvl}.txt"))
            {
                BinaryReader br = new BinaryReader(rom.Files.GetFile(task.VRom));
                Disassemble.FirstParse(br, task);
                if (Disassemble.GccOutput)
                {
                    sw.WriteLine("#include <mips.h>");
                    sw.WriteLine(".set noreorder");
                    sw.WriteLine(".set noat");
                    sw.WriteLine();
                }
                Disassemble.Task(sw, br, task);
            }

            using (StreamWriter sw = new StreamWriter($"__{testOvl}_f.txt"))
            {
                foreach (var item in Disassemble.Symbols.OrderBy(x => x.Key))
                {
                    sw.WriteLine($"{item.Value.ToString()} = 0x{item.Key}");
                }
            }
        }
Esempio n. 3
0
        static void MMDebugTest()
        {
            RomVersion ver = MRom.Build.DBG;

            PathUtil.TryGetRomLocation(ver, out string path);
            Rom             rom  = new MRom(path, ver);
            DisassemblyTask task = null;

            Disassemble.PrintRelocations = true;

            using StreamWriter sw = File.CreateText("__code.txt");
            using BinaryReader br = new BinaryReader(rom.Files.GetFile(task.VRom));
            Disassemble.FirstParse(br, task);
            Disassemble.Task(sw, br, task);
        }
Esempio n. 4
0
        private static void GetSymbols(List <DisassemblyTask> tasks, RomVersion ver, Func <FileAddress, Stream> getFile)
        {
            foreach (var task in tasks)
            {
                BinaryReader FileReader = new BinaryReader(getFile(task.VRom));

                foreach (var item in task.Functions)
                {
                    Disassemble.AddFunction(item);
                }

                //Get a list of function names
                Disassemble.FirstParse(FileReader, task);
            }
        }