private void StateHistoryIntegrityCheckMenuItem_Click(object sender, EventArgs e)
        {
            if (!Emulator.DeterministicEmulation)
            {
                if (MessageBox.Show("The emulator is not deterministic. It might fail even if the difference isn't enough to cause a desync.\nContinue with check?", "Not Deterministic", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            GoToFrame(0);
            int lastState = 0;
            int goToFrame = CurrentTasMovie.TasStateManager.LastEmulatedFrame;

            do
            {
                Mainform.FrameAdvance();

                if (CurrentTasMovie.TasStateManager.HasState(Emulator.Frame))
                {
                    byte[] state     = (byte[])StatableEmulator.SaveStateBinary().Clone();                 // Why is this cloning it?
                    byte[] greenzone = CurrentTasMovie.TasStateManager[Emulator.Frame].Value;

                    if (!state.SequenceEqual(greenzone))
                    {
                        MessageBox.Show("Bad data between frames " + lastState + " and " + Emulator.Frame);
                        return;
                    }

                    lastState = Emulator.Frame;
                }
            }while (Emulator.Frame < goToFrame);

            MessageBox.Show("Integrity Check passed");
        }
Beispiel #2
0
        // SuuperW: I changed this to public so that it could be used by MarkerControl.cs
        public void GoToFrame(int frame, bool fromLua = false, bool fromRewinding = false)
        {
            // If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate
            // Otherwise, load the latest state (if not already there) and seek while recording.

            WasRecording = CurrentTasMovie.IsRecording || WasRecording;

            if (frame <= CurrentTasMovie.InputLogLength)
            {
                // Get as close as we can then emulate there
                StartAtNearestFrameAndEmulate(frame, fromLua, fromRewinding);

                MaybeFollowCursor();
            }
            else                                 // Emulate to a future frame
            {
                if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame
                {
                    bool wasPaused = Mainform.EmulatorPaused;
                    Mainform.FrameAdvance();
                    if (!wasPaused)
                    {
                        Mainform.UnpauseEmulator();
                    }
                }
                else
                {
                    TastudioPlayMode();

                    // Simply getting the last state doesn't work if that state is the frame.
                    // display isn't saved in the state, need to emulate to frame
                    var lastState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame);
                    if (lastState.Key > Emulator.Frame)
                    {
                        LoadState(lastState);
                    }

                    StartSeeking(frame);
                }
            }

            RefreshDialog();
            UpdateOtherTools();
        }