public static ZFiles?FromRom(string filename) { var romBytes = ZFiles.LoadRomBytes(filename); //var segments = ZFiles.GetSegments_(romBytes); return(null); }
public static ZFiles GetFiles( IShardedMemory romMemory, uint segmentOffset, int nameOffset) { var segments = ZFiles.GetSegments_(romMemory, segmentOffset, nameOffset); var objects = new List <ZObj>(); var actorCode = new List <ZCodeFiles>(); var scenes = new LinkedList <ZSc>(); var others = new List <ZOtherData>(); foreach (var segment in segments) { var fileName = segment.FileName; var betterFileName = BetterFileNames.Get(fileName); var region = segment.Region; IZFile file; if (fileName.StartsWith("object_")) { region.ShardType = ShardedMemoryType.OBJECT; var obj = new ZObj(region); file = obj; objects.Add(obj); } else if (fileName.StartsWith("ovl_")) { region.ShardType = ShardedMemoryType.CODE; var ovl = new ZCodeFiles(region); file = ovl; actorCode.Add(ovl); } else if (fileName.EndsWith("_scene")) { region.ShardType = ShardedMemoryType.SCENE; var scene = new ZSc(region); file = scene; scenes.AddLast(scene); } else if (fileName.Contains("_room")) { var scene = scenes.Last.Value; region.ShardType = ShardedMemoryType.MAP; var map = new ZMap(region) { Scene = scene }; file = map; var mapCount = scene.Maps?.Length ?? 0; Array.Resize(ref scene.Maps, mapCount + 1); scene.Maps[mapCount] = map; } else { region.ShardType = ShardedMemoryType.OTHER_DATA; var other = new ZOtherData(region); file = other; others.Add(other); } file.FileName = fileName; file.BetterFileName = betterFileName; } return(new ZFiles(objects, actorCode, scenes.ToArray(), others)); }