Ram Search - implement Previous value searching, but currently the definition of previous value is previous frame

This commit is contained in:
andres.delikat 2011-02-21 01:06:58 +00:00
parent ee30625994
commit 67dac99408
2 changed files with 65 additions and 28 deletions

View File

@ -93,6 +93,7 @@
this.AutoSearchCheckBox = new System.Windows.Forms.CheckBox();
this.MemDomainLabel = new System.Windows.Forms.Label();
this.OutputLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.SearchtoolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
@ -529,6 +530,7 @@
// CompareToBox
//
this.CompareToBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.CompareToBox.Controls.Add(this.label1);
this.CompareToBox.Controls.Add(this.NumberOfChangesBox);
this.CompareToBox.Controls.Add(this.SpecificAddressBox);
this.CompareToBox.Controls.Add(this.SpecificValueBox);
@ -743,6 +745,15 @@
this.OutputLabel.TabIndex = 9;
this.OutputLabel.Text = " ";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(116, 68);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(18, 13);
this.label1.TabIndex = 10;
this.label1.Text = "0x";
//
// RamSearch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -851,5 +862,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.Label MemDomainLabel;
private System.Windows.Forms.Label OutputLabel;
private System.Windows.Forms.Label label1;
}
}

View File

@ -24,6 +24,7 @@ namespace BizHawk.MultiClient
//Implement Auto-Search
//Impelment File handling
//Implement Preview search
//Run Trim() and ToUpper() on specific/number/differentby boxes after user enters data, then don't do that when running the Get function
string systemID = "NULL";
List<Watch> searchList = new List<Watch>();
@ -544,32 +545,68 @@ namespace BizHawk.MultiClient
}
}
private int GetPreviousValue()
private int GetPreviousValue(int pos)
{
return 0;
return searchList[pos].prev; //TODO: return value based on user choice
}
private bool DoPreviousValue()
{
int previous = GetPreviousValue();
switch (GetOperator())
{
case SOperator.LESS:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value < GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break;
case SOperator.GREATER:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value > GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break;
case SOperator.LESSEQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value <= GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break;
case SOperator.GREATEREQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value >= GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break;
case SOperator.EQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value == GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break;
case SOperator.NOTEQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value != GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break;
case SOperator.DIFFBY:
int diff = GetDifferentBy();
if (diff < 0) return false;
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value == GetPreviousValue(x) + diff || searchList[x].value == GetPreviousValue(x) - diff)
weededList.Add(searchList[x]);
}
break;
}
return false;
return true;
}
private bool DoSpecificValue()
@ -628,13 +665,7 @@ namespace BizHawk.MultiClient
break;
case SOperator.DIFFBY:
int diff = GetDifferentBy();
if (diff < 0)
{
MessageBox.Show("Missing or invalid Different By value", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error); //TODO add all this crap to GetDifferentBy since it is the same everywhere it is used
DifferentByBox.Focus();
DifferentByBox.SelectAll();
return false;
}
if (diff < 0) return false;
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value == value + diff || searchList[x].value == value - diff)
@ -664,9 +695,15 @@ namespace BizHawk.MultiClient
private int GetDifferentBy()
{
bool i = InputValidate.IsValidUnsignedNumber(DifferentByBox.Text);
if (!i) return -1;
return int.Parse(DifferentByBox.Text.Trim());
if (!i)
{
MessageBox.Show("Missing or invalid Different By value", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error);
DifferentByBox.Focus();
DifferentByBox.SelectAll();
return -1;
}
else
return int.Parse(DifferentByBox.Text.Trim());
}
private bool DoSpecificAddress()
@ -726,13 +763,7 @@ namespace BizHawk.MultiClient
case SOperator.DIFFBY:
{
int diff = GetDifferentBy();
if (diff < 0)
{
MessageBox.Show("Missing or invalid Different By value", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error);
DifferentByBox.Focus();
DifferentByBox.SelectAll();
return false;
}
if (diff < 0) return false;
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].address == address + diff || searchList[x].address == address - diff)
@ -808,13 +839,7 @@ namespace BizHawk.MultiClient
break;
case SOperator.DIFFBY:
int diff = GetDifferentBy();
if (diff < 0)
{
MessageBox.Show("Missing or invalid Different By value", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error);
DifferentByBox.Focus();
DifferentByBox.SelectAll();
return false;
}
if (diff < 0) return false;
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].address == changes + diff || searchList[x].address == changes - diff)