TAStudio:

Fixed the Greenzone Integiry Check feature.
Bugfix: Right-click menu didn't show up.
This commit is contained in:
SuuperW 2015-03-10 05:12:13 +00:00
parent e2f79254be
commit 5fd1f6912b
3 changed files with 46 additions and 19 deletions

View File

@ -496,7 +496,7 @@ namespace BizHawk.Client.EmuHawk
| System.Windows.Forms.Keys.I))); | System.Windows.Forms.Keys.I)));
this.GreenZoneIntegrityCheckMenuItem.Size = new System.Drawing.Size(282, 22); this.GreenZoneIntegrityCheckMenuItem.Size = new System.Drawing.Size(282, 22);
this.GreenZoneIntegrityCheckMenuItem.Text = "Greenzone Integrity Check"; 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 // ConfigSubMenu
// //

View File

@ -385,7 +385,7 @@ namespace BizHawk.Client.EmuHawk
} }
else if (e.Button == System.Windows.Forms.MouseButtons.Right) 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; _rightClickControl = (Control.ModifierKeys | Keys.Control) == Control.ModifierKeys;
_rightClickShift = (Control.ModifierKeys | Keys.Shift) == Control.ModifierKeys; _rightClickShift = (Control.ModifierKeys | Keys.Shift) == Control.ModifierKeys;
@ -404,7 +404,6 @@ namespace BizHawk.Client.EmuHawk
_rightClickFrame = frame; _rightClickFrame = frame;
} }
_rightClickLastFrame = -1; _rightClickLastFrame = -1;
_supressContextMenu = true;
// TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here. // TODO: Turn off ChangeLog.IsRecording and handle the GeneralUndo here.
CurrentTasMovie.ChangeLog.BeginNewBatch("Right-Click Edit"); CurrentTasMovie.ChangeLog.BeginNewBatch("Right-Click Edit");
} }
@ -436,7 +435,8 @@ namespace BizHawk.Client.EmuHawk
if (_floatEditRow == -1) if (_floatEditRow == -1)
CurrentTasMovie.ChangeLog.EndBatch(); CurrentTasMovie.ChangeLog.EndBatch();
} }
else if (e.Button == System.Windows.Forms.MouseButtons.Right)
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{ {
if (_rightClickFrame != -1) if (_rightClickFrame != -1)
{ {
@ -532,8 +532,10 @@ namespace BizHawk.Client.EmuHawk
RefreshTasView(); RefreshTasView();
} }
} }
else if (_rightClickFrame != -1) else if (_rightClickFrame != -1)
{ {
_supressContextMenu = true;
if (frame > CurrentTasMovie.InputLogLength - _rightClickInput.Length) if (frame > CurrentTasMovie.InputLogLength - _rightClickInput.Length)
frame = CurrentTasMovie.InputLogLength - _rightClickInput.Length; frame = CurrentTasMovie.InputLogLength - _rightClickInput.Length;
if (_rightClickShift) if (_rightClickShift)
@ -608,6 +610,7 @@ namespace BizHawk.Client.EmuHawk
} }
RefreshTasView(); RefreshTasView();
} }
else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startBoolDrawColumn)) else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startBoolDrawColumn))
{ {
if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue) if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue)
@ -622,6 +625,7 @@ namespace BizHawk.Client.EmuHawk
RefreshTasView(); RefreshTasView();
} }
} }
else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startFloatDrawColumn)) else if (TasView.IsPaintDown && e.NewCell.RowIndex.HasValue && !string.IsNullOrEmpty(_startFloatDrawColumn))
{ {
if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue) if (e.OldCell.RowIndex.HasValue && e.NewCell.RowIndex.HasValue)

View File

@ -558,26 +558,49 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog(); RefreshDialog();
} }
private void GreenZzoneIntegrityCheckMenuItem_Click(object sender, EventArgs e) private void GreenZoneIntegrityCheckMenuItem_Click(object sender, EventArgs e)
{ {
GlobalWin.MainForm.RebootCore(); if (!Emulator.DeterministicEmulation)
GlobalWin.MainForm.FrameAdvance();
var frame = Emulator.Frame;
if (CurrentTasMovie.TasStateManager.HasState(frame))
{ {
var state = (byte[])StatableEmulator.SaveStateBinary().Clone(); 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)
var greenzone = CurrentTasMovie.TasStateManager[frame]; == System.Windows.Forms.DialogResult.No)
if (!state.SequenceEqual(greenzone.Value))
{
MessageBox.Show("bad data at frame: " + frame);
return; 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<byte> stateList = state.ToList();
List<byte> 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"); MessageBox.Show("Integrity Check passed");
} }
private int FirstDifference(List<byte> b1, List<byte> b2)
{
int dummyVar = -1;
return b1.FindIndex(b => { dummyVar++; return b != b2[dummyVar]; });
}
#endregion #endregion
@ -885,10 +908,10 @@ namespace BizHawk.Client.EmuHawk
{ {
if (AskSaveChanges()) if (AskSaveChanges())
{ {
var index = TasView.SelectedRows.First(); int index = TasView.SelectedRows.First();
GoToFrame(index); GoToFrame(index);
var newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie(
index, index,
(byte[])StatableEmulator.SaveStateBinary().Clone()); (byte[])StatableEmulator.SaveStateBinary().Clone());