示例#1
0
文件: TAStudio.cs 项目: m35/BizHawk
        private bool AutoAdjustInput()
        {
            TasMovieRecord lagLog = CurrentTasMovie[Emulator.Frame - 1];             // Minus one because get frame is +1;
            bool           isLag  = Emulator.AsInputPollable().IsLagFrame;

            if (lagLog.WasLagged.HasValue)
            {
                if (lagLog.WasLagged.Value && !isLag)
                {
                    // Deleting this frame requires rewinding a frame.
                    CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, true, $"Bind Input; Delete {Emulator.Frame - 1}");
                    bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording;
                    CurrentTasMovie.ChangeLog.IsRecording = false;

                    CurrentTasMovie.RemoveFrame(Emulator.Frame - 1);
                    CurrentTasMovie.RemoveLagHistory(Emulator.Frame);                     // Removes from WasLag

                    CurrentTasMovie.ChangeLog.IsRecording = wasRecording;
                    GoToFrame(Emulator.Frame - 1);
                    return(true);
                }

                if (!lagLog.WasLagged.Value && isLag)
                {                 // (it shouldn't need to rewind, since the inserted input wasn't polled)
                    CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, false, $"Bind Input; Insert {Emulator.Frame - 1}");
                    bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording;
                    CurrentTasMovie.ChangeLog.IsRecording = false;

                    CurrentTasMovie.InsertInput(Emulator.Frame - 1, CurrentTasMovie.GetInputLogEntry(Emulator.Frame - 2));
                    CurrentTasMovie.InsertLagHistory(Emulator.Frame, true);

                    CurrentTasMovie.ChangeLog.IsRecording = wasRecording;
                    return(true);
                }
            }

            return(false);
        }