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.AutoSearchCheckBox = new System.Windows.Forms.CheckBox();
this.MemDomainLabel = new System.Windows.Forms.Label(); this.MemDomainLabel = new System.Windows.Forms.Label();
this.OutputLabel = new System.Windows.Forms.Label(); this.OutputLabel = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.SearchtoolStrip1.SuspendLayout(); this.SearchtoolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
@ -529,6 +530,7 @@
// CompareToBox // CompareToBox
// //
this.CompareToBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.NumberOfChangesBox);
this.CompareToBox.Controls.Add(this.SpecificAddressBox); this.CompareToBox.Controls.Add(this.SpecificAddressBox);
this.CompareToBox.Controls.Add(this.SpecificValueBox); this.CompareToBox.Controls.Add(this.SpecificValueBox);
@ -743,6 +745,15 @@
this.OutputLabel.TabIndex = 9; this.OutputLabel.TabIndex = 9;
this.OutputLabel.Text = " "; 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 // RamSearch
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -851,5 +862,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.Label MemDomainLabel; private System.Windows.Forms.Label MemDomainLabel;
private System.Windows.Forms.Label OutputLabel; private System.Windows.Forms.Label OutputLabel;
private System.Windows.Forms.Label label1;
} }
} }

View File

@ -24,6 +24,7 @@ namespace BizHawk.MultiClient
//Implement Auto-Search //Implement Auto-Search
//Impelment File handling //Impelment File handling
//Implement Preview search //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"; string systemID = "NULL";
List<Watch> searchList = new List<Watch>(); 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() private bool DoPreviousValue()
{ {
int previous = GetPreviousValue();
switch (GetOperator()) switch (GetOperator())
{ {
case SOperator.LESS: case SOperator.LESS:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value < GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break; break;
case SOperator.GREATER: case SOperator.GREATER:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value > GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break; break;
case SOperator.LESSEQUAL: case SOperator.LESSEQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value <= GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break; break;
case SOperator.GREATEREQUAL: case SOperator.GREATEREQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value >= GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break; break;
case SOperator.EQUAL: case SOperator.EQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value == GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break; break;
case SOperator.NOTEQUAL: case SOperator.NOTEQUAL:
for (int x = 0; x < searchList.Count; x++)
{
if (searchList[x].value != GetPreviousValue(x))
weededList.Add(searchList[x]);
}
break; break;
case SOperator.DIFFBY: 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; break;
} }
return false; return true;
} }
private bool DoSpecificValue() private bool DoSpecificValue()
@ -628,13 +665,7 @@ namespace BizHawk.MultiClient
break; break;
case SOperator.DIFFBY: case SOperator.DIFFBY:
int diff = GetDifferentBy(); int diff = GetDifferentBy();
if (diff < 0) if (diff < 0) return false;
{
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;
}
for (int x = 0; x < searchList.Count; x++) for (int x = 0; x < searchList.Count; x++)
{ {
if (searchList[x].value == value + diff || searchList[x].value == value - diff) if (searchList[x].value == value + diff || searchList[x].value == value - diff)
@ -664,9 +695,15 @@ namespace BizHawk.MultiClient
private int GetDifferentBy() private int GetDifferentBy()
{ {
bool i = InputValidate.IsValidUnsignedNumber(DifferentByBox.Text); bool i = InputValidate.IsValidUnsignedNumber(DifferentByBox.Text);
if (!i) return -1; if (!i)
{
return int.Parse(DifferentByBox.Text.Trim()); 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() private bool DoSpecificAddress()
@ -726,13 +763,7 @@ namespace BizHawk.MultiClient
case SOperator.DIFFBY: case SOperator.DIFFBY:
{ {
int diff = GetDifferentBy(); int diff = GetDifferentBy();
if (diff < 0) if (diff < 0) return false;
{
MessageBox.Show("Missing or invalid Different By value", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error);
DifferentByBox.Focus();
DifferentByBox.SelectAll();
return false;
}
for (int x = 0; x < searchList.Count; x++) for (int x = 0; x < searchList.Count; x++)
{ {
if (searchList[x].address == address + diff || searchList[x].address == address - diff) if (searchList[x].address == address + diff || searchList[x].address == address - diff)
@ -808,13 +839,7 @@ namespace BizHawk.MultiClient
break; break;
case SOperator.DIFFBY: case SOperator.DIFFBY:
int diff = GetDifferentBy(); int diff = GetDifferentBy();
if (diff < 0) if (diff < 0) return false;
{
MessageBox.Show("Missing or invalid Different By value", "Invalid value", MessageBoxButtons.OK, MessageBoxIcon.Error);
DifferentByBox.Focus();
DifferentByBox.SelectAll();
return false;
}
for (int x = 0; x < searchList.Count; x++) for (int x = 0; x < searchList.Count; x++)
{ {
if (searchList[x].address == changes + diff || searchList[x].address == changes - diff) if (searchList[x].address == changes + diff || searchList[x].address == changes - diff)