示例#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));
            }
        }
示例#2
0
        protected override void Write(string fn)
        {
            _totalProgress = 0;

            var file = new FileInfo(fn);

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

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

                // TasProj extras
                bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(StateManager.Settings.ToString()));
                ReportProgress(PROGRESS_STEP);
                if (StateManager.Settings.SaveStateHistory)
                {
                    bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => StateManager.Save(bw));
                }
                ReportProgress(PROGRESS_STEP);

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

                if (StartsFromSavestate)
                {
                    if (TextSavestate != null)
                    {
                        bs.PutLump(BinaryStateLump.CorestateText, (TextWriter tw) => tw.Write(TextSavestate));
                    }
                    else
                    {
                        bs.PutLump(BinaryStateLump.Corestate, (BinaryWriter bw) => bw.Write(BinarySavestate));
                    }
                }
                ReportProgress(PROGRESS_STEP);
                if (ClientSettingsForSave != null)
                {
                    var clientSettingsJson = ClientSettingsForSave();
                    bs.PutLump(BinaryStateLump.ClientSettings, (TextWriter tw) => tw.Write(clientSettingsJson));
                }
                ReportProgress(PROGRESS_STEP);

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

            Changes = false;
        }
示例#3
0
        protected override void Write(string fn, bool backup = false)
        {
            var file = new FileInfo(fn);

            if (!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, tw => WriteInputLog(tw));

                // TasProj extras
                bs.PutLump(BinaryStateLump.StateHistorySettings, tw => tw.WriteLine(StateManager.Settings.ToString()));

                bs.PutLump(BinaryStateLump.LagLog, (BinaryWriter bw) => LagLog.Save(bw));
                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(InputLogToString(VerificationLog)));
                }

                if (Branches.Any())
                {
                    Branches.Save(bs);
                    if (StateManager.Settings.BranchStatesInTasproj)
                    {
                        bs.PutLump(BinaryStateLump.BranchStateHistory, (BinaryWriter bw) => StateManager.SaveBranchStates(bw));
                    }
                }

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

                if (StateManager.Settings.SaveStateHistory)
                {
                    bs.PutLump(BinaryStateLump.StateHistory, (BinaryWriter bw) => StateManager.Save(bw));
                }
            }

            if (!backup)
            {
                Changes = false;
            }
        }
示例#4
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;
            }
        }