Beispiel #1
0
        private void AddTasProjLumps(ZipStateSaver bs, bool isBackup = false)
        {
            var settings = JsonConvert.SerializeObject(TasStateManager.Settings);

            bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(settings));
            bs.PutLump(BinaryStateLump.LagLog, tw => LagLog.Save(tw));
            bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));

            if (ClientSettingsForSave != null)
            {
                var clientSettingsJson = ClientSettingsForSave();
                bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
            }

            if (VerificationLog.Any())
            {
                bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(VerificationLog.ToInputLog()));
            }

            if (Branches.Any())
            {
                Branches.Save(bs);
            }

            bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(JsonConvert.SerializeObject(TasSession)));

            if (TasStateManager.Settings.SaveStateHistory && !isBackup)
            {
                bs.PutLump(BinaryStateLump.StateHistory, bw => TasStateManager.Save(bw));
            }
        }
Beispiel #2
0
        protected override void Write(string fn, bool backup = false)
        {
            var file = new FileInfo(fn);

            if (file.Directory != null && !file.Directory.Exists)
            {
                Directory.CreateDirectory(file.Directory.ToString());
            }

            using var bs = new BinaryStateSaver(fn, false);
            bs.PutLump(BinaryStateLump.Movieheader, tw => tw.WriteLine(Header.ToString()));
            bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
            bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
            bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(SyncSettingsJson));
            bs.PutLump(BinaryStateLump.Input, WriteInputLog);

            // TasProj extras
            var settings = JsonConvert.SerializeObject(TasStateManager.Settings);

            bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(settings));

            bs.PutLump(BinaryStateLump.LagLog, tw => LagLog.Save(tw));
            bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));

            if (StartsFromSavestate)
            {
                if (TextSavestate != null)
                {
                    bs.PutLump(BinaryStateLump.CorestateText, (TextWriter tw) => tw.Write(TextSavestate));
                }
                else
                {
                    bs.PutLump(BinaryStateLump.Corestate, (BinaryWriter bw) => bw.Write(BinarySavestate));
                }
            }
            else if (StartsFromSaveRam)
            {
                bs.PutLump(BinaryStateLump.MovieSaveRam, (BinaryWriter bw) => bw.Write(SaveRam));
            }

            if (ClientSettingsForSave != null)
            {
                var clientSettingsJson = ClientSettingsForSave();
                bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
            }

            if (VerificationLog.Any())
            {
                bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(VerificationLog.ToInputLog()));
            }

            if (Branches.Any())
            {
                Branches.Save(bs);
            }

            bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(JsonConvert.SerializeObject(Session)));

            if (TasStateManager.Settings.SaveStateHistory && !backup)
            {
                bs.PutLump(BinaryStateLump.StateHistory, bw => TasStateManager.Save(bw));
            }

            if (!backup)
            {
                Changes = false;
            }
        }
Beispiel #3
0
        protected override void Write(string fn, bool isBackup = false)
        {
            if (Emulator is Emulation.Cores.Nintendo.SubNESHawk.SubNESHawk subNes)
            {
                Header[HeaderKeys.VBlankCount] = subNes.VblankCount.ToString();
            }
            else if (Emulator is Emulation.Cores.Nintendo.Gameboy.Gameboy gameboy)
            {
                Header[HeaderKeys.CycleCount] = gameboy.CycleCount.ToString();
            }
            else if (Emulator is Emulation.Cores.Nintendo.SubGBHawk.SubGBHawk subGb)
            {
                Header[HeaderKeys.CycleCount] = subGb.CycleCount.ToString();
            }

            var file = new FileInfo(fn);

            if (file.Directory != null && !file.Directory.Exists)
            {
                Directory.CreateDirectory(file.Directory.ToString());
            }

            using var bs = new ZipStateSaver(fn, Global.Config.Savestates.MovieCompressionLevel);
            bs.PutLump(BinaryStateLump.Movieheader, tw => tw.WriteLine(Header.ToString()));
            bs.PutLump(BinaryStateLump.Comments, tw => tw.WriteLine(CommentsString()));
            bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
            bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(SyncSettingsJson));
            bs.PutLump(BinaryStateLump.Input, WriteInputLog);

            // TasProj extras
            var settings = JsonConvert.SerializeObject(TasStateManager.Settings);

            bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(settings));

            bs.PutLump(BinaryStateLump.LagLog, tw => LagLog.Save(tw));
            bs.PutLump(BinaryStateLump.Markers, tw => tw.WriteLine(Markers.ToString()));

            if (StartsFromSavestate)
            {
                if (TextSavestate != null)
                {
                    bs.PutLump(BinaryStateLump.CorestateText, (TextWriter tw) => tw.Write(TextSavestate));
                }
                else
                {
                    bs.PutLump(BinaryStateLump.Corestate, (BinaryWriter bw) => bw.Write(BinarySavestate));
                }
            }
            else if (StartsFromSaveRam)
            {
                bs.PutLump(BinaryStateLump.MovieSaveRam, (BinaryWriter bw) => bw.Write(SaveRam));
            }

            if (ClientSettingsForSave != null)
            {
                var clientSettingsJson = ClientSettingsForSave();
                bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
            }

            if (VerificationLog.Any())
            {
                bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(VerificationLog.ToInputLog()));
            }

            if (Branches.Any())
            {
                Branches.Save(bs);
            }

            bs.PutLump(BinaryStateLump.Session, tw => tw.WriteLine(JsonConvert.SerializeObject(TasSession)));

            if (TasStateManager.Settings.SaveStateHistory && !isBackup)
            {
                bs.PutLump(BinaryStateLump.StateHistory, bw => TasStateManager.Save(bw));
            }

            if (!isBackup)
            {
                Changes = false;
            }
        }