static void BindSegment(RomVersion version, ORom.FileList fileO, MRom.FileList fileM, ref Ptr ram, ref Ptr rom) { RomFileToken token = RomFileToken.Select(version, fileO, fileM); if (Options.MapfileOptions.CanUseMap(version)) { Segment seg = Options.MapfileOptions.SymbolMap.GetSegment(token.ToString()); if (seg != null) { ram = SPtr.New(seg.Address); rom = SPtr.New(seg.LoadAddress); } else { Console.WriteLine($"Segment {token} not found."); } } else { Addresser.TryGetRam(token, version, out var t1); ram = SPtr.New(t1); Addresser.TryGetRom(token, version, t1, out var t2); rom = SPtr.New(t2); } }
public static string ActorTable(Rom r, bool dumpActorInit = true) { StringBuilder sb = new StringBuilder(); RomFileToken codeFileToken = RomFileToken.Select(r.Version, ORom.FileList.code, MRom.FileList.code); RomFile codeFile = r.Files.GetFile(codeFileToken); BinaryReader codeFileReader = new BinaryReader(codeFile); Addresser.TryGetRam(codeFileToken, r.Version, out N64Ptr codePtr); List <ActorOverlayRecord> records = new List <ActorOverlayRecord>(); for (int i = 0; i < r.Files.Tables.Actors.Records; i++) { records.Add(r.Files.GetActorOverlayRecord(i)); } string header = $"Id,VROM Start,VROM End,VROM Size,VRAM Start,VRAM End,VRAM Size,Actor Init,Alloc"; if (dumpActorInit) { header += ",number,type,room,flags,object_number,instance_size," + "init_func,dest_func,update_func,draw_func"; } sb.AppendLine(header); foreach (var item in records) { string entry = $"{item.Actor:X4}," + $"{item.VRom.Start:X8},{item.VRom.End:X8},{item.VRom.Size:X8}," + $"{item.VRam.Start:X8},{item.VRam.End:X8},{item.VRam.Size:X8}," + $"{item.VRamActorInit}," + $"{item.AllocationType}"; sb.Append(entry); if (dumpActorInit) { ActorInit stats; if (item.VRamActorInit.IsNull()) { stats = new ActorInit(); } else { BinaryReader reader; N64Ptr basePtr; if (item.VRamActorInit < 0x8080_0000) { basePtr = codePtr; reader = codeFileReader; } else { basePtr = item.VRam.Start; var fileRecord = r.Files.GetFileByTable(TableInfo.Type.Actors, item.Actor); reader = new BinaryReader(r.Files.GetFile(fileRecord)); } reader.BaseStream.Position = item.VRamActorInit - basePtr; stats = new ActorInit(reader); } sb.Append($",{stats}"); } sb.AppendLine(); } codeFileReader.Dispose(); return(sb.ToString()); }
internal static void ChangeVersion(RomVersion version, bool setGctx = true) { RomFileToken fileToken; //dma data fileToken = RomFileToken.Select(version, ORom.FileList.dmadata, MRom.FileList.dmadata); Addresser.TryGetRam(fileToken, version, out N64Ptr dmadataStart); Dmadata_Addr = SPtr.New(dmadataStart); //code fileToken = RomFileToken.Select(version, ORom.FileList.code, MRom.FileList.code); Addresser.TryGetRam(fileToken, version, out Code_Addr); Addresser.TryGetRom(fileToken, version, Code_Addr.Offset, out Code_VRom); int temp; //Global Context if (setGctx) { Addresser.TryGetRam(AddressToken.RAM_GLOBAL_CONTEXT, version, out temp); if (version == ORom.Build.IQUEC || version == ORom.Build.IQUET) { GlobalContext = SPtr.New(temp); } else { GlobalContext = SPtr.New(temp).Deref(); } } SetGfxContext(version); //Heap Addresser.TryGetRam(AddressToken.RAM_ARENA_MAIN, version, out temp); Main_Heap_Ptr = SPtr.New(temp).Deref(); Addresser.TryGetRam(AddressToken.RAM_ARENA_SCENES, version, out temp); Scene_Heap_Ptr = SPtr.New(temp).Deref(); Addresser.TryGetRam(AddressToken.RAM_ARENA_DEBUG, version, out temp); if (temp == 0) { Debug_Heap_Ptr = SPtr.New(0); } else { Debug_Heap_Ptr = SPtr.New(temp).Deref(); } Addresser.TryGetOffset(AddressToken.ACTOR_CAT_LL_Start, version, out temp); Actor_Category_Table = GlobalContext.RelOff(temp); //Overlay Tables Addresser.TryGetRam(AddressToken.ActorTable_Start, ORom.FileList.code, version, out Actor_Ovl_Table); Addresser.TryGetRam(AddressToken.PlayerPauseOverlayTable_Start, ORom.FileList.code, version, out Player_Pause_Ovl_Table); Addresser.TryGetRam(AddressToken.ParticleTable_Start, ORom.FileList.code, version, out ParticleEffect_Ovl_Table); Addresser.TryGetRam(AddressToken.ObjectTable_Start, ORom.FileList.code, version, out Object_File_Table); Addresser.TryGetOffset(AddressToken.OBJ_ALLOC_TABLE, version, out temp); Object_Allocation_Table = GlobalContext.RelOff(temp); Addresser.TryGetOffset(AddressToken.ROOM_ALLOC_ADDR, version, out temp); Room_Allocation_Table = GlobalContext.RelOff(temp); Addresser.TryGetRam(AddressToken.SRAM_START, version, out temp); SaveContext = SPtr.New(temp); Addresser.TryGetRam(AddressToken.RAM_SEGMENT_TABLE, version, out temp); Segment_Table = temp; if (Addresser.TryGetRam(AddressToken.SceneTable_Start, version, out temp)) { SceneTable = SPtr.New(temp); } else { SceneTable = null; } if (Addresser.TryGetRam(AddressToken.EntranceIndexTable_Start, version, out temp)) { EntranceTable = SPtr.New(temp); } else { EntranceTable = null; } Addresser.TryGetRam(AddressToken.QUEUE_THREAD, version, out temp); Queue_Thread_Ptr = SPtr.New(temp); Addresser.TryGetRam(AddressToken.STACK_LIST, version, out temp); Stack_List_Ptr = SPtr.New(temp); }