Пример #1
0
        private void evalButton_Click(object sender, EventArgs e)
        {
            if (rom == null)
            {
                return;
            }
            Scene         scene = null;
            StringBuilder sb    = new StringBuilder();
            Room          room  = null;

            for (int sceneNumber = 0; sceneNumber < rom.Scenes; sceneNumber++)
            {
                scene = null;
                room  = null;

                var sceneFile = rom.Files.GetSceneFile(sceneNumber);
                if (sceneFile == null)
                {
                    sb.AppendLine($"Warning: Scene {sceneNumber} not found");
                    continue;
                }
                try
                {
                    scene = SceneRoomReader.InitializeScene(sceneFile, sceneNumber);
                }
                catch (Exception ex)
                {
                    var va = sceneFile.Record.VirtualAddress;
                    sb.AppendLine($"ParseError: Scene {sceneNumber} {va.Start:X8}-{va.End:X8}");
                    sb.AppendLine(ex.TargetSite.ToString());
                }

                var roomAddrs = scene.Header.GetRoomAddresses();
                for (int i = 0; i < roomAddrs.Count; i++)
                {
                    FileAddress addr     = roomAddrs[i];
                    RomFile     roomFile = null;

                    try
                    {
                        roomFile = rom.Files.GetFile(addr);
                        room     = SceneRoomReader.InitializeRoom(roomFile);
                    }
                    catch //(Exception ex)
                    {
                        if (roomFile == null)
                        {
                            sb.AppendLine($"Exception: Scene {sceneNumber}, room {addr.Start:X8}:{addr.End:X8} not found");
                        }
                        else
                        {
                            sb.AppendLine($"ParseError: Scene {sceneNumber}, room {addr.Start:X8}:{addr.End:X8}");
                            //sb.AppendLine(ex.StackTrace.ToString());
                        }
                    }
                }
            }
            sb.AppendLine("Evaluation Complete");
            outputRichTextBox.Text = sb.ToString();
        }
Пример #2
0
        private void PrintScene(int sceneId, StringBuilder sb)
        {
            Scene       scene = null;
            List <Room> rooms = new List <Room>();

            //try
            //{
            scene = SceneRoomReader.InitializeScene(rom.Files.GetSceneFile(sceneId), sceneId);
            //}
            //catch { }
            if (scene == null)
            {
                sb.AppendFormat("Exception: Scene not found");
                sb.AppendLine();
                return;
            }

            var roomAddrs = scene.Header.GetRoomAddresses();

            for (int i = 0; i < roomAddrs.Count; i++)
            {
                FileAddress addr = roomAddrs[i];

                //if (scene.ID == 6 && rom.Version == ORom.Build.N0)
                //{
                //    rooms.Add(SceneRoomReader.LoadSpiritRoom(addr, i));
                //}
                //else

                try
                {
                    RomFile file = rom.Files.GetFile(addr);
                    rooms.Add(SceneRoomReader.InitializeRoom(file));
                }
                catch
                {
                    sb.AppendLine($"Exception: room {addr.Start:X8} not found");
                }
            }

            sb.Append(SceneRoomReader.ReadScene(scene));
            for (int i = 0; i < rooms.Count; i++)
            {
                sb.AppendLine($"Room {i}");
                sb.Append(SceneRoomReader.ReadRoom(rooms[i]));
            }
        }
Пример #3
0
        public void Script(string path)
        {
            ORom         rom = new ORom(path, ORom.Build.DBGMQ);
            MemoryStream ms  = new MemoryStream(new byte[0x4000000]);

            //clone rom's files by DMA
            foreach (var item in rom.Files)
            {
                var rfile = rom.Files.GetFile(item.VRom);
                CopyToOutputRom(ms, rfile);
            }

            //clone scene and room files

            for (int i = 0; i < rom.Scenes; i++)
            {
                var sceneFile = rom.Files.GetSceneFile(i);
                if (sceneFile == null)
                {
                    continue;
                }
                var sceneFileMeta = SceneRoomReader.InitializeScene(sceneFile, i);
                RemoveActor0001FromFile(ms, sceneFile, sceneFileMeta.Header);
                CopyToOutputRom(ms, sceneFile);

                foreach (var roomAddr in sceneFileMeta.Header.GetRoomAddresses())
                {
                    var roomFile     = rom.Files.GetFile(roomAddr);
                    var roomFileMeta = SceneRoomReader.InitializeRoom(roomFile);
                    RemoveActor0001FromFile(ms, roomFile, roomFileMeta.Header);
                    CopyToOutputRom(ms, roomFile);
                }
            }

            //save
            using (Stream sw = new FileStream("ZeldosBirthday.z64", FileMode.Create))
            {
                ms.Position = 0;
                ms.CopyTo(sw);
            }
            //using (BinaryWriter bw = new BinaryWriter(new StreamWriter()))
        }
Пример #4
0
        public static void AssSkulls(IExperimentFace face, List <string> filePath)
        {
            ORom r = new ORom(filePath[0], ORom.Build.N0);
            List <(FileAddress addr, int scene, int room, Room info)> lookup = new List <(FileAddress addr, int scene, int room, Room info)>();

            for (int sceneId = 0; sceneId < r.Scenes; sceneId++)
            {
                var   sceneFile = r.Files.GetSceneFile(sceneId);
                Scene scene     = SceneRoomReader.InitializeScene(sceneFile, sceneId);
                scene.Header.InitializeAssets(new BinaryReader(sceneFile.Stream));

                int roomId = -1;
                foreach (var roomAddr in scene.Header.GetRoomAddresses())
                {
                    roomId++;
                    var  roomFile = r.Files.GetFile(roomAddr);
                    Room room     = SceneRoomReader.InitializeRoom(roomFile);
                    lookup.Add((roomAddr, sceneId, roomId, room));
                }
            }
            //now for some ass

            StringBuilder sb = new StringBuilder();

            for (int i = ass.GetLowerBound(0); i <= ass.GetUpperBound(0); i++)
            {
                for (int j = ass.GetLowerBound(1); j <= ass.GetUpperBound(1); j++)
                {
                    foreach (var item in ass[i, j])
                    {
                        if (item is ACTOR actor)
                        {
                            var(addr, scene, room, info) = lookup.Where(x => x.addr.Start <= actor.addr && x.addr.End > actor.addr).Single();

                            int setup = 0;
                            if (info.Header.HasAlternateHeaders())
                            {
                                for (int hId = 0; hId < info.Header.Alternate.Headers.Count; hId++)
                                {
                                    var alt = info.Header.Alternate.Headers[hId];
                                    if (alt == null)
                                    {
                                        continue;
                                    }
                                    var actorList = alt[HeaderCommands.ActorList];
                                    if (actorList == null)
                                    {
                                        continue;
                                    }
                                    int            actors      = actorList.Command.Data1;
                                    SegmentAddress loc         = actorList.Command.Data2;
                                    int            actorsStart = addr.Start + loc.Offset;
                                    int            actorsEnd   = addr.End + loc.Offset + (0x10 * actors);

                                    if (actor.addr >= actorsStart && actor.addr < actorsEnd)
                                    {
                                        setup = hId + 1;
                                        break;
                                    }
                                }
                            }

                            sb.AppendLine($"{i}\t{j}\t{scene}\t{room}\t{setup}\t{item.ToString()}");
                        }
                    }
                }
            }

            face.OutputText(sb.ToString());
        }