diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs index 8c955ee542..ebfb1c56e2 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs @@ -496,7 +496,7 @@ namespace BizHawk.Client.EmuHawk | System.Windows.Forms.Keys.I))); this.GreenZoneIntegrityCheckMenuItem.Size = new System.Drawing.Size(282, 22); this.GreenZoneIntegrityCheckMenuItem.Text = "Greenzone Integrity Check"; - this.GreenZoneIntegrityCheckMenuItem.Click += new System.EventHandler(this.GreenZzoneIntegrityCheckMenuItem_Click); + this.GreenZoneIntegrityCheckMenuItem.Click += new System.EventHandler(this.GreenZoneIntegrityCheckMenuItem_Click); // // ConfigSubMenu // diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 3cd80e71b9..cc87cf8e97 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -385,7 +385,7 @@ namespace BizHawk.Client.EmuHawk } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { - if (TasView.CurrentCell.Column.Name == FrameColumnName) + if (TasView.CurrentCell.Column.Name == FrameColumnName && frame < CurrentTasMovie.InputLogLength) { _rightClickControl = (Control.ModifierKeys | Keys.Control) == Control.ModifierKeys; _rightClickShift = (Control.ModifierKeys | Keys.Shift) == Control.ModifierKeys; @@ -404,7 +404,6 @@ namespace BizHawk.Client.EmuHawk _rightClickFrame = frame; } _rightClickLastFrame = -1; - _supressContextMenu = true; // TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here. CurrentTasMovie.ChangeLog.BeginNewBatch("Right-Click Edit"); } @@ -436,7 +435,8 @@ namespace BizHawk.Client.EmuHawk if (_floatEditRow == -1) CurrentTasMovie.ChangeLog.EndBatch(); } - else if (e.Button == System.Windows.Forms.MouseButtons.Right) + + if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (_rightClickFrame != -1) { @@ -532,8 +532,10 @@ namespace BizHawk.Client.EmuHawk RefreshTasView(); } } + else if (_rightClickFrame != -1) { + _supressContextMenu = true; if (frame > CurrentTasMovie.InputLogLength - _rightClickInput.Length) frame = CurrentTasMovie.InputLogLength - _rightClickInput.Length; if (_rightClickShift) @@ -608,6 +610,7 @@ namespace BizHawk.Client.EmuHawk } RefreshTasView(); } + else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startBoolDrawColumn)) { if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue) @@ -622,6 +625,7 @@ namespace BizHawk.Client.EmuHawk RefreshTasView(); } } + else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startFloatDrawColumn)) { if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index c367f7c550..05f6b571f3 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -558,26 +558,49 @@ namespace BizHawk.Client.EmuHawk RefreshDialog(); } - private void GreenZzoneIntegrityCheckMenuItem_Click(object sender, EventArgs e) + private void GreenZoneIntegrityCheckMenuItem_Click(object sender, EventArgs e) { - GlobalWin.MainForm.RebootCore(); - GlobalWin.MainForm.FrameAdvance(); - var frame = Emulator.Frame; - - if (CurrentTasMovie.TasStateManager.HasState(frame)) + if (!Emulator.DeterministicEmulation) { - var state = (byte[])StatableEmulator.SaveStateBinary().Clone(); - var greenzone = CurrentTasMovie.TasStateManager[frame]; - - if (!state.SequenceEqual(greenzone.Value)) - { - MessageBox.Show("bad data at frame: " + frame); + if (MessageBox.Show("The emulator is not deterministic. It will likely fail, even if the difference isn't enough to cause a desync.\nContinue with check?", "Not Deterministic", MessageBoxButtons.YesNo) + == System.Windows.Forms.DialogResult.No) return; - } } + GoToFrame(0); + int lastState = 0; + do + { + GlobalWin.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)) + { + List stateList = state.ToList(); + List greenList = greenzone.ToList(); + int diffAt = FirstDifference(stateList, greenList); + stateList.RemoveRange(0, diffAt); + greenList.RemoveRange(0, diffAt); + + MessageBox.Show("Bad data between frames " + lastState + " and " + Emulator.Frame); + return; + } + + lastState = Emulator.Frame; + } + } while (Global.Emulator.Frame < CurrentTasMovie.InputLogLength - 1); + MessageBox.Show("Integrity Check passed"); } + private int FirstDifference(List b1, List b2) + { + int dummyVar = -1; + return b1.FindIndex(b => { dummyVar++; return b != b2[dummyVar]; }); + } #endregion @@ -885,10 +908,10 @@ namespace BizHawk.Client.EmuHawk { if (AskSaveChanges()) { - var index = TasView.SelectedRows.First(); + int index = TasView.SelectedRows.First(); GoToFrame(index); - var newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( + TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( index, (byte[])StatableEmulator.SaveStateBinary().Clone());