示例#1
0
        private static void GetActorSymbolNames(DisassemblyTask task, Rom rom, ActorOverlayRecord ovlRec)
        {
            ActorInit actorInfo = new ActorInit();

            if (ovlRec.VRamActorInfo == 0)
            {
                return;
            }

            N64Ptr  startAddr;
            RomFile file;

            if (ovlRec.VRom.Size == 0)
            {
                file = rom.Files.GetFile(ORom.FileList.code);
                Addresser.TryGetRam(ORom.FileList.code, rom.Version, out int code_start);
                startAddr = (code_start | 0x80000000);
            }
            else
            {
                file      = rom.Files.GetFile(ovlRec.VRom);
                startAddr = ovlRec.VRam.Start;
            }

            file.Stream.Position = ovlRec.VRamActorInfo - startAddr;
            actorInfo            = new ActorInit(new BinaryReader(file));

            BindSymbol(ovlRec.VRamActorInfo, Label.Type.VAR, "InitVars");
            BindSymbol(actorInfo.init_func, Label.Type.FUNC, "Init");
            BindSymbol(actorInfo.draw_func, Label.Type.FUNC, "Draw");
            BindSymbol(actorInfo.update_func, Label.Type.FUNC, "Update");
            BindSymbol(actorInfo.dest_func, Label.Type.FUNC, "Destructor");

            void BindSymbol(N64Ptr ptr, Label.Type type, string name)
            {
                if (ptr != 0)
                {
                    var func = new Label(type, ptr, true)
                    {
                        Name = $"{task.Name}_{name}"
                    };
                    task.Functions.Add(func);
                }
            }
        }
        private static void GetActorSymbolNames(DisassemblyTask task, Rom rom, ActorOverlayRecord ovlRec)
        {
            if (ovlRec.VRamActorInit == 0)
            {
                return;
            }

            if (ovlRec.VRom.Size == 0)
            {
                RomFile file = rom.Files.GetFile(ORom.FileList.code);
                Addresser.TryGetRam(ORom.FileList.code, rom.Version, out N64Ptr code_start);
                N64Ptr startAddr = code_start;

                GetActorInfoSymbols(task, startAddr, ovlRec.VRamActorInit, file);
            }
            else
            {
                task.PreparseActions.Add(file => {
                    GetActorInfoSymbols(task, ovlRec.VRam.Start, ovlRec.VRamActorInit, file);
                });
            }
        }