Ram Watch/Search - add System ID to .wch files
This commit is contained in:
parent
7e1ccc4faf
commit
c8d07a5078
|
@ -304,6 +304,7 @@
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="IVideoWriter.cs" />
|
<Compile Include="IVideoWriter.cs" />
|
||||||
|
<Compile Include="tools\WatchCommon.cs" />
|
||||||
<Compile Include="WavWriter.cs" />
|
<Compile Include="WavWriter.cs" />
|
||||||
<EmbeddedResource Include="config\GifAnimator.resx">
|
<EmbeddedResource Include="config\GifAnimator.resx">
|
||||||
<DependentUpon>GifAnimator.cs</DependentUpon>
|
<DependentUpon>GifAnimator.cs</DependentUpon>
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
this.LessThanRadio = new System.Windows.Forms.RadioButton();
|
this.LessThanRadio = new System.Windows.Forms.RadioButton();
|
||||||
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.MessageLabel = new System.Windows.Forms.Label();
|
||||||
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
||||||
this.viewInHexEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.viewInHexEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.SearchtoolStrip1.SuspendLayout();
|
this.SearchtoolStrip1.SuspendLayout();
|
||||||
|
@ -1191,13 +1191,13 @@
|
||||||
//
|
//
|
||||||
// OutputLabel
|
// OutputLabel
|
||||||
//
|
//
|
||||||
this.OutputLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
this.MessageLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
this.OutputLabel.AutoSize = true;
|
this.MessageLabel.AutoSize = true;
|
||||||
this.OutputLabel.Location = new System.Drawing.Point(9, 434);
|
this.MessageLabel.Location = new System.Drawing.Point(9, 434);
|
||||||
this.OutputLabel.Name = "OutputLabel";
|
this.MessageLabel.Name = "OutputLabel";
|
||||||
this.OutputLabel.Size = new System.Drawing.Size(85, 13);
|
this.MessageLabel.Size = new System.Drawing.Size(85, 13);
|
||||||
this.OutputLabel.TabIndex = 9;
|
this.MessageLabel.TabIndex = 9;
|
||||||
this.OutputLabel.Text = " ";
|
this.MessageLabel.Text = " ";
|
||||||
//
|
//
|
||||||
// viewInHexEditorToolStripMenuItem
|
// viewInHexEditorToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
@ -1215,7 +1215,7 @@
|
||||||
this.Controls.Add(this.toolStrip2);
|
this.Controls.Add(this.toolStrip2);
|
||||||
this.Controls.Add(this.SearchtoolStrip1);
|
this.Controls.Add(this.SearchtoolStrip1);
|
||||||
this.Controls.Add(this.toolStrip1);
|
this.Controls.Add(this.toolStrip1);
|
||||||
this.Controls.Add(this.OutputLabel);
|
this.Controls.Add(this.MessageLabel);
|
||||||
this.Controls.Add(this.MemDomainLabel);
|
this.Controls.Add(this.MemDomainLabel);
|
||||||
this.Controls.Add(this.ComparisonBox);
|
this.Controls.Add(this.ComparisonBox);
|
||||||
this.Controls.Add(this.AutoSearchCheckBox);
|
this.Controls.Add(this.AutoSearchCheckBox);
|
||||||
|
@ -1307,7 +1307,7 @@
|
||||||
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
|
||||||
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 MessageLabel;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem recentToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem recentToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem;
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace BizHawk.MultiClient
|
||||||
int defaultValueWidth;
|
int defaultValueWidth;
|
||||||
int defaultPrevWidth;
|
int defaultPrevWidth;
|
||||||
int defaultChangesWidth;
|
int defaultChangesWidth;
|
||||||
string currentSearchFile = "";
|
string currentFile = "";
|
||||||
string addressFormatStr = "{0:X4} ";
|
string addressFormatStr = "{0:X4} ";
|
||||||
bool sortReverse;
|
bool sortReverse;
|
||||||
string sortedCol;
|
string sortedCol;
|
||||||
|
@ -427,7 +427,7 @@ namespace BizHawk.MultiClient
|
||||||
ExludeRamWatchList();
|
ExludeRamWatchList();
|
||||||
MakePreviousList();
|
MakePreviousList();
|
||||||
SetSpecificValueBoxMaxLength();
|
SetSpecificValueBoxMaxLength();
|
||||||
OutputLabel.Text = "New search started";
|
MessageLabel.Text = "New search started";
|
||||||
sortReverse = false;
|
sortReverse = false;
|
||||||
sortedCol = "";
|
sortedCol = "";
|
||||||
DisplaySearchList();
|
DisplaySearchList();
|
||||||
|
@ -505,7 +505,7 @@ namespace BizHawk.MultiClient
|
||||||
if (indexes.Count > 0)
|
if (indexes.Count > 0)
|
||||||
{
|
{
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
OutputLabel.Text = MakeAddressString(indexes.Count) + " removed";
|
MessageLabel.Text = MakeAddressString(indexes.Count) + " removed";
|
||||||
for (int x = 0; x < indexes.Count; x++)
|
for (int x = 0; x < indexes.Count; x++)
|
||||||
{
|
{
|
||||||
searchList.Remove(searchList[indexes[x] - x]);
|
searchList.Remove(searchList[indexes[x] - x]);
|
||||||
|
@ -536,7 +536,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
if (undoList.Count > 0)
|
if (undoList.Count > 0)
|
||||||
{
|
{
|
||||||
OutputLabel.Text = MakeAddressString(undoList.Count - searchList.Count) + " restored";
|
MessageLabel.Text = MakeAddressString(undoList.Count - searchList.Count) + " restored";
|
||||||
redoList = new List<Watch>(searchList);
|
redoList = new List<Watch>(searchList);
|
||||||
searchList = new List<Watch>(undoList);
|
searchList = new List<Watch>(undoList);
|
||||||
prevList = new List<Watch>(undoList);
|
prevList = new List<Watch>(undoList);
|
||||||
|
@ -564,7 +564,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
if (redoList.Count > 0)
|
if (redoList.Count > 0)
|
||||||
{
|
{
|
||||||
OutputLabel.Text = MakeAddressString(searchList.Count - redoList.Count) + " removed";
|
MessageLabel.Text = MakeAddressString(searchList.Count - redoList.Count) + " removed";
|
||||||
undoList = new List<Watch>(searchList);
|
undoList = new List<Watch>(searchList);
|
||||||
searchList = new List<Watch>(redoList);
|
searchList = new List<Watch>(redoList);
|
||||||
prevList = new List<Watch>(redoList);
|
prevList = new List<Watch>(redoList);
|
||||||
|
@ -654,7 +654,7 @@ namespace BizHawk.MultiClient
|
||||||
for (int x = 0; x < searchList.Count; x++)
|
for (int x = 0; x < searchList.Count; x++)
|
||||||
searchList[x].changecount = 0;
|
searchList[x].changecount = 0;
|
||||||
DisplaySearchList();
|
DisplaySearchList();
|
||||||
OutputLabel.Text = "Change counts cleared";
|
MessageLabel.Text = "Change counts cleared";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearChangeCountstoolStripButton_Click(object sender, EventArgs e)
|
private void ClearChangeCountstoolStripButton_Click(object sender, EventArgs e)
|
||||||
|
@ -690,13 +690,13 @@ namespace BizHawk.MultiClient
|
||||||
if (GenerateWeedOutList())
|
if (GenerateWeedOutList())
|
||||||
{
|
{
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
OutputLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " removed";
|
MessageLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " removed";
|
||||||
ReplaceSearchListWithWeedOutList();
|
ReplaceSearchListWithWeedOutList();
|
||||||
if (Global.Config.RamSearchPreviousAs != 1) MakePreviousList(); //1 = Original value
|
if (Global.Config.RamSearchPreviousAs != 1) MakePreviousList(); //1 = Original value
|
||||||
DisplaySearchList();
|
DisplaySearchList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
OutputLabel.Text = "Search failed.";
|
MessageLabel.Text = "Search failed.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripButton1_Click(object sender, EventArgs e)
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
||||||
|
@ -1282,69 +1282,18 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private bool SaveSearchFile(string path)
|
private bool SaveSearchFile(string path)
|
||||||
{
|
{
|
||||||
var file = new FileInfo(path);
|
return WatchCommon.SaveWchFile(path, Domain.Name, searchList);
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(path))
|
|
||||||
{
|
|
||||||
string str = "Domain " + Domain.Name + "\n";
|
|
||||||
|
|
||||||
for (int x = 0; x < searchList.Count; x++)
|
|
||||||
{
|
|
||||||
str += string.Format("{0:X4}", searchList[x].address) + "\t";
|
|
||||||
str += searchList[x].GetTypeByChar().ToString() + "\t";
|
|
||||||
str += searchList[x].GetSignedByChar().ToString() + "\t";
|
|
||||||
|
|
||||||
if (searchList[x].bigendian == true)
|
|
||||||
str += "1\t";
|
|
||||||
else
|
|
||||||
str += "0\t";
|
|
||||||
|
|
||||||
str += searchList[x].notes + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.WriteLine(str);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private FileInfo GetSaveFileFromUser()
|
|
||||||
{
|
|
||||||
var sfd = new SaveFileDialog();
|
|
||||||
if (currentSearchFile.Length > 0)
|
|
||||||
{
|
|
||||||
sfd.FileName = Path.GetFileNameWithoutExtension(currentSearchFile);
|
|
||||||
sfd.InitialDirectory = Path.GetDirectoryName(currentSearchFile);
|
|
||||||
}
|
|
||||||
else if (!(Global.Emulator is NullEmulator))
|
|
||||||
{
|
|
||||||
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
|
||||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sfd.FileName = "NULL";
|
|
||||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
|
||||||
}
|
|
||||||
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
|
||||||
sfd.RestoreDirectory = true;
|
|
||||||
Global.Sound.StopSound();
|
|
||||||
var result = sfd.ShowDialog();
|
|
||||||
Global.Sound.StartSound();
|
|
||||||
if (result != DialogResult.OK)
|
|
||||||
return null;
|
|
||||||
var file = new FileInfo(sfd.FileName);
|
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveAs()
|
public void SaveAs()
|
||||||
{
|
{
|
||||||
var file = GetSaveFileFromUser();
|
var file = WatchCommon.GetSaveFileFromUser(currentFile);
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
SaveSearchFile(file.FullName);
|
SaveSearchFile(file.FullName);
|
||||||
currentSearchFile = file.FullName;
|
currentFile = file.FullName;
|
||||||
OutputLabel.Text = Path.GetFileName(currentSearchFile) + " saved.";
|
MessageLabel.Text = Path.GetFileName(currentFile) + " saved.";
|
||||||
Global.Config.RecentSearches.Add(currentSearchFile);
|
Global.Config.RecentSearches.Add(currentFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1360,106 +1309,27 @@ namespace BizHawk.MultiClient
|
||||||
DisplaySearchList();
|
DisplaySearchList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int HowMany(string str, char c)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
for (int x = 0; x < str.Length; x++)
|
|
||||||
{
|
|
||||||
if (str[x] == c)
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int GetDomainPos(string name)
|
|
||||||
{
|
|
||||||
//Attempts to find the memory domain by name, if it fails, it defaults to index 0
|
|
||||||
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
|
|
||||||
{
|
|
||||||
if (Global.Emulator.MemoryDomains[x].Name == name)
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadSearchFile(string path, bool append, bool truncate, List<Watch> list)
|
bool LoadSearchFile(string path, bool append, bool truncate, List<Watch> list)
|
||||||
{
|
{
|
||||||
int y, z;
|
string domain = "";
|
||||||
var file = new FileInfo(path);
|
bool result = WatchCommon.LoadWatchFile(path, append, list, out domain);
|
||||||
if (file.Exists == false) return false;
|
|
||||||
|
|
||||||
using (StreamReader sr = file.OpenText())
|
if (result)
|
||||||
{
|
{
|
||||||
if (!append && !truncate)
|
|
||||||
currentSearchFile = path;
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
string s = "";
|
|
||||||
string temp = "";
|
|
||||||
|
|
||||||
if (!append)
|
if (!append)
|
||||||
{
|
{
|
||||||
list.Clear(); //Wipe existing list and read from file
|
currentFile = path;
|
||||||
prevList.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((s = sr.ReadLine()) != null)
|
MessageLabel.Text = Path.GetFileNameWithoutExtension(path);
|
||||||
{
|
SetTotal();
|
||||||
//parse each line and add to watchList
|
Global.Config.RecentSearches.Add(path);
|
||||||
|
SetMemoryDomain(WatchCommon.GetDomainPos(domain));
|
||||||
|
return true;
|
||||||
|
|
||||||
//.wch files from other emulators start with a number representing the number of watch, that line can be discarded here
|
|
||||||
//Any properly formatted line couldn't possibly be this short anyway, this also takes care of any garbage lines that might be in a file
|
|
||||||
if (s.Length < 5) continue;
|
|
||||||
|
|
||||||
if (s.Substring(0, 6) == "Domain")
|
|
||||||
SetMemoryDomain(GetDomainPos(s.Substring(7, s.Length - 7)));
|
|
||||||
|
|
||||||
z = HowMany(s, '\t');
|
|
||||||
if (z == 5)
|
|
||||||
{
|
|
||||||
//If 5, then this is a .wch file format made from another emulator, the first column (watch position) is not needed here
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //5 digit value representing the watch position number
|
|
||||||
}
|
|
||||||
else if (z != 4)
|
|
||||||
continue; //If not 4, something is wrong with this line, ignore it
|
|
||||||
count++;
|
|
||||||
Watch w = new Watch();
|
|
||||||
|
|
||||||
temp = s.Substring(0, s.IndexOf('\t'));
|
|
||||||
w.address = int.Parse(temp, NumberStyles.HexNumber);
|
|
||||||
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //Type
|
|
||||||
w.SetTypeByChar(s[0]);
|
|
||||||
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //Signed
|
|
||||||
w.SetSignedByChar(s[0]);
|
|
||||||
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //Endian
|
|
||||||
y = Int16.Parse(s[0].ToString());
|
|
||||||
if (y == 0)
|
|
||||||
w.bigendian = false;
|
|
||||||
else
|
|
||||||
w.bigendian = true;
|
|
||||||
|
|
||||||
//w.notes = s.Substring(2, s.Length - 2); //User notes
|
|
||||||
|
|
||||||
list.Add(w);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!append && !truncate)
|
|
||||||
{
|
|
||||||
Global.Config.RecentSearches.Add(file.FullName);
|
|
||||||
OutputLabel.Text = Path.GetFileName(file.FullName);
|
|
||||||
//Update the number of watches
|
|
||||||
SetTotal();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
|
@ -1520,13 +1390,13 @@ namespace BizHawk.MultiClient
|
||||||
private FileInfo GetFileFromUser()
|
private FileInfo GetFileFromUser()
|
||||||
{
|
{
|
||||||
var ofd = new OpenFileDialog();
|
var ofd = new OpenFileDialog();
|
||||||
if (currentSearchFile.Length > 0)
|
if (currentFile.Length > 0)
|
||||||
ofd.FileName = Path.GetFileNameWithoutExtension(currentSearchFile);
|
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
||||||
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
||||||
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
||||||
ofd.RestoreDirectory = true;
|
ofd.RestoreDirectory = true;
|
||||||
if (currentSearchFile.Length > 0)
|
if (currentFile.Length > 0)
|
||||||
ofd.FileName = Path.GetFileNameWithoutExtension(currentSearchFile);
|
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
||||||
Global.Sound.StopSound();
|
Global.Sound.StopSound();
|
||||||
var result = ofd.ShowDialog();
|
var result = ofd.ShowDialog();
|
||||||
Global.Sound.StartSound();
|
Global.Sound.StartSound();
|
||||||
|
@ -1575,10 +1445,10 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.Compare(currentSearchFile, "") == 0)
|
if (string.Compare(currentFile, "") == 0)
|
||||||
SaveAs();
|
SaveAs();
|
||||||
else
|
else
|
||||||
SaveSearchFile(currentSearchFile);
|
SaveSearchFile(currentFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSelectedToRamWatchToolStripMenuItem_Click(object sender, EventArgs e)
|
private void addSelectedToRamWatchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -1766,7 +1636,7 @@ namespace BizHawk.MultiClient
|
||||||
weededList.Add(searchList[x]);
|
weededList.Add(searchList[x]);
|
||||||
}
|
}
|
||||||
SaveUndo();
|
SaveUndo();
|
||||||
OutputLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " removed";
|
MessageLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " removed";
|
||||||
ReplaceSearchListWithWeedOutList();
|
ReplaceSearchListWithWeedOutList();
|
||||||
if (Global.Config.RamSearchPreviousAs != 1) MakePreviousList(); //1 = Original value
|
if (Global.Config.RamSearchPreviousAs != 1) MakePreviousList(); //1 = Original value
|
||||||
DisplaySearchList();
|
DisplaySearchList();
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace BizHawk.MultiClient
|
||||||
string systemID = "NULL";
|
string systemID = "NULL";
|
||||||
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
|
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
|
||||||
List<Watch> watchList = new List<Watch>();
|
List<Watch> watchList = new List<Watch>();
|
||||||
string currentWatchFile = "";
|
string currentFile = "";
|
||||||
bool changes = false;
|
bool changes = false;
|
||||||
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
|
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
|
||||||
string addressFormatStr = "{0:X4} ";
|
string addressFormatStr = "{0:X4} ";
|
||||||
|
@ -44,8 +44,8 @@ namespace BizHawk.MultiClient
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
if (!this.IsHandleCreated || this.IsDisposed) return;
|
if (!this.IsHandleCreated || this.IsDisposed) return;
|
||||||
if (currentWatchFile.Length > 0)
|
if (currentFile.Length > 0)
|
||||||
LoadWatchFile(currentWatchFile, false);
|
LoadWatchFile(currentFile, false);
|
||||||
else
|
else
|
||||||
NewWatchList(true);
|
NewWatchList(true);
|
||||||
}
|
}
|
||||||
|
@ -228,17 +228,6 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int HowMany(string str, char c)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
for (int x = 0; x < str.Length; x++)
|
|
||||||
{
|
|
||||||
if (str[x] == c)
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AskSave()
|
public bool AskSave()
|
||||||
{
|
{
|
||||||
if (changes)
|
if (changes)
|
||||||
|
@ -248,12 +237,12 @@ namespace BizHawk.MultiClient
|
||||||
Global.Sound.StartSound();
|
Global.Sound.StartSound();
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
if (string.Compare(currentWatchFile, "") == 0)
|
if (string.Compare(currentFile, "") == 0)
|
||||||
{
|
{
|
||||||
SaveAs();
|
SaveAs();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SaveWatchFile(currentWatchFile);
|
SaveWatchFile(currentFile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (result == DialogResult.No)
|
else if (result == DialogResult.No)
|
||||||
|
@ -292,7 +281,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
watchList.Clear();
|
watchList.Clear();
|
||||||
DisplayWatchList();
|
DisplayWatchList();
|
||||||
currentWatchFile = "";
|
currentFile = "";
|
||||||
changes = false;
|
changes = false;
|
||||||
MessageLabel.Text = "";
|
MessageLabel.Text = "";
|
||||||
sortReverse = false;
|
sortReverse = false;
|
||||||
|
@ -302,116 +291,30 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private bool SaveWatchFile(string path)
|
private bool SaveWatchFile(string path)
|
||||||
{
|
{
|
||||||
var file = new FileInfo(path);
|
return WatchCommon.SaveWchFile(path, Domain.Name, watchList);
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(path))
|
|
||||||
{
|
|
||||||
string str = "Domain " + Domain.Name + "\n";
|
|
||||||
|
|
||||||
for (int x = 0; x < watchList.Count; x++)
|
|
||||||
{
|
|
||||||
str += string.Format("{0:X4}", watchList[x].address) + "\t";
|
|
||||||
str += watchList[x].GetTypeByChar().ToString() + "\t";
|
|
||||||
str += watchList[x].GetSignedByChar().ToString() + "\t";
|
|
||||||
|
|
||||||
if (watchList[x].bigendian == true)
|
|
||||||
str += "1\t";
|
|
||||||
else
|
|
||||||
str += "0\t";
|
|
||||||
|
|
||||||
str += watchList[x].notes + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.WriteLine(str);
|
|
||||||
}
|
|
||||||
changes = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int GetDomainPos(string name)
|
|
||||||
{
|
|
||||||
//Attempts to find the memory domain by name, if it fails, it defaults to index 0
|
|
||||||
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
|
|
||||||
{
|
|
||||||
if (Global.Emulator.MemoryDomains[x].Name == name)
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool LoadWatchFile(string path, bool append)
|
public bool LoadWatchFile(string path, bool append)
|
||||||
{
|
{
|
||||||
int y, z;
|
string domain = "";
|
||||||
var file = new FileInfo(path);
|
bool result = WatchCommon.LoadWatchFile(path, append, watchList, out domain);
|
||||||
if (file.Exists == false) return false;
|
|
||||||
|
|
||||||
using (StreamReader sr = file.OpenText())
|
if (result)
|
||||||
{
|
{
|
||||||
if (!append)
|
if (!append)
|
||||||
currentWatchFile = path;
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
string s = "";
|
|
||||||
string temp = "";
|
|
||||||
|
|
||||||
if (append == false)
|
|
||||||
watchList.Clear(); //Wipe existing list and read from file
|
|
||||||
|
|
||||||
while ((s = sr.ReadLine()) != null)
|
|
||||||
{
|
{
|
||||||
//parse each line and add to watchList
|
currentFile = path;
|
||||||
|
|
||||||
//.wch files from other emulators start with a number representing the number of watch, that line can be discarded here
|
|
||||||
//Any properly formatted line couldn't possibly be this short anyway, this also takes care of any garbage lines that might be in a file
|
|
||||||
if (s.Length < 5) continue;
|
|
||||||
|
|
||||||
if (s.Substring(0, 6) == "Domain")
|
|
||||||
SetMemoryDomain(GetDomainPos(s.Substring(7, s.Length - 7)));
|
|
||||||
|
|
||||||
z = HowMany(s, '\t');
|
|
||||||
if (z == 5)
|
|
||||||
{
|
|
||||||
//If 5, then this is a .wch file format made from another emulator, the first column (watch position) is not needed here
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //5 digit value representing the watch position number
|
|
||||||
}
|
|
||||||
else if (z != 4)
|
|
||||||
continue; //If not 4, something is wrong with this line, ignore it
|
|
||||||
count++;
|
|
||||||
Watch w = new Watch();
|
|
||||||
|
|
||||||
temp = s.Substring(0, s.IndexOf('\t'));
|
|
||||||
w.address = int.Parse(temp, NumberStyles.HexNumber);
|
|
||||||
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //Type
|
|
||||||
w.SetTypeByChar(s[0]);
|
|
||||||
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //Signed
|
|
||||||
w.SetSignedByChar(s[0]);
|
|
||||||
|
|
||||||
y = s.IndexOf('\t') + 1;
|
|
||||||
s = s.Substring(y, s.Length - y); //Endian
|
|
||||||
y = Int16.Parse(s[0].ToString());
|
|
||||||
if (y == 0)
|
|
||||||
w.bigendian = false;
|
|
||||||
else
|
|
||||||
w.bigendian = true;
|
|
||||||
|
|
||||||
w.notes = s.Substring(2, s.Length - 2); //User notes
|
|
||||||
|
|
||||||
watchList.Add(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.Config.RecentWatches.Add(file.FullName);
|
|
||||||
changes = false;
|
changes = false;
|
||||||
MessageLabel.Text = Path.GetFileName(file.FullName);
|
MessageLabel.Text = Path.GetFileNameWithoutExtension(path);
|
||||||
//Update the number of watches
|
WatchCountLabel.Text = watchList.Count.ToString() + " watches";
|
||||||
WatchCountLabel.Text = count.ToString() + " watches";
|
Global.Config.RecentWatches.Add(path);
|
||||||
}
|
SetMemoryDomain(WatchCommon.GetDomainPos(domain));
|
||||||
|
return true;
|
||||||
|
|
||||||
return true;
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point GetPromptPoint()
|
private Point GetPromptPoint()
|
||||||
|
@ -444,7 +347,7 @@ namespace BizHawk.MultiClient
|
||||||
void Changes()
|
void Changes()
|
||||||
{
|
{
|
||||||
changes = true;
|
changes = true;
|
||||||
MessageLabel.Text = Path.GetFileName(currentWatchFile) + " *";
|
MessageLabel.Text = Path.GetFileName(currentFile) + " *";
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditWatchObject(int pos)
|
void EditWatchObject(int pos)
|
||||||
|
@ -592,8 +495,8 @@ namespace BizHawk.MultiClient
|
||||||
private FileInfo GetFileFromUser()
|
private FileInfo GetFileFromUser()
|
||||||
{
|
{
|
||||||
var ofd = new OpenFileDialog();
|
var ofd = new OpenFileDialog();
|
||||||
if (currentWatchFile.Length > 0)
|
if (currentFile.Length > 0)
|
||||||
ofd.FileName = Path.GetFileNameWithoutExtension(currentWatchFile);
|
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
||||||
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
||||||
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
||||||
ofd.RestoreDirectory = true;
|
ofd.RestoreDirectory = true;
|
||||||
|
@ -629,54 +532,25 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.Compare(currentWatchFile, "") == 0)
|
if (string.Compare(currentFile, "") == 0)
|
||||||
{
|
{
|
||||||
SaveAs();
|
SaveAs();
|
||||||
}
|
}
|
||||||
else if (changes)
|
else if (changes)
|
||||||
{
|
{
|
||||||
SaveWatchFile(currentWatchFile);
|
SaveWatchFile(currentFile);
|
||||||
MessageLabel.Text = Path.GetFileName(currentWatchFile) + " saved.";
|
MessageLabel.Text = Path.GetFileName(currentFile) + " saved.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileInfo GetSaveFileFromUser()
|
|
||||||
{
|
|
||||||
var sfd = new SaveFileDialog();
|
|
||||||
if (currentWatchFile.Length > 0)
|
|
||||||
{
|
|
||||||
sfd.FileName = Path.GetFileNameWithoutExtension(currentWatchFile);
|
|
||||||
sfd.InitialDirectory = Path.GetDirectoryName(currentWatchFile);
|
|
||||||
}
|
|
||||||
else if (!(Global.Emulator is NullEmulator))
|
|
||||||
{
|
|
||||||
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
|
||||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sfd.FileName = "NULL";
|
|
||||||
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
|
||||||
}
|
|
||||||
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
|
||||||
sfd.RestoreDirectory = true;
|
|
||||||
Global.Sound.StopSound();
|
|
||||||
var result = sfd.ShowDialog();
|
|
||||||
Global.Sound.StartSound();
|
|
||||||
if (result != DialogResult.OK)
|
|
||||||
return null;
|
|
||||||
var file = new FileInfo(sfd.FileName);
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveAs()
|
private void SaveAs()
|
||||||
{
|
{
|
||||||
var file = GetSaveFileFromUser();
|
var file = WatchCommon.GetSaveFileFromUser(currentFile);
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
SaveWatchFile(file.FullName);
|
SaveWatchFile(file.FullName);
|
||||||
currentWatchFile = file.FullName;
|
currentFile = file.FullName;
|
||||||
MessageLabel.Text = Path.GetFileName(currentWatchFile) + " saved.";
|
MessageLabel.Text = Path.GetFileName(currentFile) + " saved.";
|
||||||
Global.Config.RecentWatches.Add(file.FullName);
|
Global.Config.RecentWatches.Add(file.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -852,9 +726,9 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private void saveToolStripButton_Click(object sender, EventArgs e)
|
private void saveToolStripButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (changes && currentWatchFile.Length > 0)
|
if (changes && currentFile.Length > 0)
|
||||||
{
|
{
|
||||||
SaveWatchFile(currentWatchFile);
|
SaveWatchFile(currentFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace BizHawk.MultiClient
|
||||||
|
{
|
||||||
|
public static class WatchCommon
|
||||||
|
{
|
||||||
|
public static bool SaveWchFile(string path, string domain_name, List<Watch> watchList)
|
||||||
|
{
|
||||||
|
var file = new FileInfo(path);
|
||||||
|
|
||||||
|
using (StreamWriter sw = new StreamWriter(path))
|
||||||
|
{
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
str.Append("Domain " + domain_name + "\n");
|
||||||
|
str.Append("SystemID " + Global.Emulator.SystemId + "\n");
|
||||||
|
|
||||||
|
for (int x = 0; x < watchList.Count; x++)
|
||||||
|
{
|
||||||
|
str.Append(string.Format("{0:X4}", watchList[x].address) + "\t");
|
||||||
|
str.Append(watchList[x].GetTypeByChar().ToString() + "\t");
|
||||||
|
str.Append(watchList[x].GetSignedByChar().ToString() + "\t");
|
||||||
|
|
||||||
|
if (watchList[x].bigendian == true)
|
||||||
|
str.Append("1\t");
|
||||||
|
else
|
||||||
|
str.Append("0\t");
|
||||||
|
|
||||||
|
str.Append(watchList[x].notes + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.WriteLine(str.ToString());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool LoadWatchFile(string path, bool append, List<Watch> watchList, out string domain)
|
||||||
|
{
|
||||||
|
domain = "";
|
||||||
|
int y, z;
|
||||||
|
var file = new FileInfo(path);
|
||||||
|
if (file.Exists == false) return false;
|
||||||
|
|
||||||
|
using (StreamReader sr = file.OpenText())
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
string s = "";
|
||||||
|
string temp = "";
|
||||||
|
|
||||||
|
if (append == false)
|
||||||
|
watchList.Clear(); //Wipe existing list and read from file
|
||||||
|
|
||||||
|
while ((s = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
//parse each line and add to watchList
|
||||||
|
|
||||||
|
//.wch files from other emulators start with a number representing the number of watch, that line can be discarded here
|
||||||
|
//Any properly formatted line couldn't possibly be this short anyway, this also takes care of any garbage lines that might be in a file
|
||||||
|
if (s.Length < 5) continue;
|
||||||
|
|
||||||
|
if (s.Substring(0, 6) == "Domain")
|
||||||
|
domain = s.Substring(7, s.Length - 7);
|
||||||
|
|
||||||
|
z = HowMany(s, '\t');
|
||||||
|
if (z == 5)
|
||||||
|
{
|
||||||
|
//If 5, then this is a .wch file format made from another emulator, the first column (watch position) is not needed here
|
||||||
|
y = s.IndexOf('\t') + 1;
|
||||||
|
s = s.Substring(y, s.Length - y); //5 digit value representing the watch position number
|
||||||
|
}
|
||||||
|
else if (z != 4)
|
||||||
|
continue; //If not 4, something is wrong with this line, ignore it
|
||||||
|
count++;
|
||||||
|
Watch w = new Watch();
|
||||||
|
|
||||||
|
temp = s.Substring(0, s.IndexOf('\t'));
|
||||||
|
w.address = int.Parse(temp, NumberStyles.HexNumber);
|
||||||
|
|
||||||
|
y = s.IndexOf('\t') + 1;
|
||||||
|
s = s.Substring(y, s.Length - y); //Type
|
||||||
|
w.SetTypeByChar(s[0]);
|
||||||
|
|
||||||
|
y = s.IndexOf('\t') + 1;
|
||||||
|
s = s.Substring(y, s.Length - y); //Signed
|
||||||
|
w.SetSignedByChar(s[0]);
|
||||||
|
|
||||||
|
y = s.IndexOf('\t') + 1;
|
||||||
|
s = s.Substring(y, s.Length - y); //Endian
|
||||||
|
y = Int16.Parse(s[0].ToString());
|
||||||
|
if (y == 0)
|
||||||
|
w.bigendian = false;
|
||||||
|
else
|
||||||
|
w.bigendian = true;
|
||||||
|
|
||||||
|
w.notes = s.Substring(2, s.Length - 2); //User notes
|
||||||
|
|
||||||
|
watchList.Add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int HowMany(string str, char c)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int x = 0; x < str.Length; x++)
|
||||||
|
{
|
||||||
|
if (str[x] == c)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetDomainPos(string name)
|
||||||
|
{
|
||||||
|
//Attempts to find the memory domain by name, if it fails, it defaults to index 0
|
||||||
|
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
|
||||||
|
{
|
||||||
|
if (Global.Emulator.MemoryDomains[x].Name == name)
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileInfo GetSaveFileFromUser(string currentFile)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog();
|
||||||
|
if (currentFile.Length > 0)
|
||||||
|
{
|
||||||
|
sfd.FileName = Path.GetFileNameWithoutExtension(currentFile);
|
||||||
|
sfd.InitialDirectory = Path.GetDirectoryName(currentFile);
|
||||||
|
}
|
||||||
|
else if (!(Global.Emulator is NullEmulator))
|
||||||
|
{
|
||||||
|
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
||||||
|
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sfd.FileName = "NULL";
|
||||||
|
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
|
||||||
|
}
|
||||||
|
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
|
||||||
|
sfd.RestoreDirectory = true;
|
||||||
|
Global.Sound.StopSound();
|
||||||
|
var result = sfd.ShowDialog();
|
||||||
|
Global.Sound.StartSound();
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return null;
|
||||||
|
var file = new FileInfo(sfd.FileName);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue