Ram Watch - more progress on Open Watch function, reads .wch files in the format of other emulators. Currently the results are garbled, need to fix bugs

This commit is contained in:
andres.delikat 2011-01-19 02:49:47 +00:00
parent c3ef10f815
commit 49ea0515d8
3 changed files with 83 additions and 20 deletions

View File

@ -51,13 +51,13 @@
this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.WatchListView = new System.Windows.Forms.ListView();
this.Address = new System.Windows.Forms.ColumnHeader();
this.Value = new System.Windows.Forms.ColumnHeader();
this.Notes = new System.Windows.Forms.ColumnHeader();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.Address = new System.Windows.Forms.ColumnHeader();
this.Value = new System.Windows.Forms.ColumnHeader();
this.Notes = new System.Windows.Forms.ColumnHeader();
this.listBox1 = new System.Windows.Forms.ListBox();
this.menuStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
@ -246,6 +246,19 @@
this.WatchListView.TabIndex = 1;
this.WatchListView.UseCompatibleStateImageBehavior = false;
//
// Address
//
this.Address.Text = "Address";
//
// Value
//
this.Value.Text = "Value";
this.Value.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// Notes
//
this.Notes.Text = "Notes";
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -285,25 +298,12 @@
this.toolStripButton3.Size = new System.Drawing.Size(23, 22);
this.toolStripButton3.Text = "toolStripButton3";
//
// Address
//
this.Address.Text = "Address";
//
// Value
//
this.Value.Text = "Value";
this.Value.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// Notes
//
this.Notes.Text = "Notes";
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(311, 88);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 95);
this.listBox1.Size = new System.Drawing.Size(120, 355);
this.listBox1.TabIndex = 3;
//
// RamWatch

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
namespace BizHawk.MultiClient
{
@ -14,6 +15,7 @@ namespace BizHawk.MultiClient
{
//TODO: Recent files & autoload
//Keep track of changes to watch list in order to prompt the user to save changes
//TODO: implement separator feature
List<Watch> watchList = new List<Watch>();
@ -22,6 +24,7 @@ namespace BizHawk.MultiClient
InitializeComponent();
}
//Debug
void TempDisplayWatchInTempList(Watch watch)
{
string temp = watch.address + " " + watch.value + " " + watch.notes;
@ -41,6 +44,7 @@ namespace BizHawk.MultiClient
bool LoadWatchFile(string path)
{
int y, z;
var file = new FileInfo(path);
if (file.Exists == false) return false;
@ -57,11 +61,11 @@ namespace BizHawk.MultiClient
//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;
int z = HowMany(s, '\t');
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
int y = s.IndexOf('\t') + 1;
y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y - 1); //5 digit value representing the watch position number
}
else if (z != 4)
@ -70,9 +74,31 @@ namespace BizHawk.MultiClient
Watch w = new Watch();
temp = s.Substring(0, s.IndexOf('\t'));
w.address = int.Parse(temp, NumberStyles.HexNumber);
//w.address = int.Parse(temp);
y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y - 1); //Type
w.SetTypeByChar(s[0]);
y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y - 1); //Signed
w.SetSignedByChar(s[0]);
y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y - 1); //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);
//Debug
for (int x = 0; x < watchList.Count; x++)
TempDisplayWatchInTempList(watchList[x]);
}
}
@ -207,6 +233,7 @@ namespace BizHawk.MultiClient
item1 = new ListViewItem(watch1.notes, 0);
WatchListView.Items.Add(item1);
//Debug
for (int x = 0; x < watchList.Count; x++)
TempDisplayWatchInTempList(watchList[x]);
}

View File

@ -34,5 +34,41 @@ namespace BizHawk.MultiClient
public asigned signed { get; set; } //Signed/Unsigned?
public bool bigendian { get; set; }
public string notes { get; set; } //User notes
public bool SetTypeByChar(char c) //b = byte, w = word, d = dword
{
switch (c)
{
case 'b':
type = atype.BYTE;
return true;
case 'w':
type = atype.WORD;
return true;
case 'd':
type = atype.DWORD;
return true;
default:
return false;
}
}
public bool SetSignedByChar(char c) //s = signed, u = unsigned, h = hex
{
switch (c)
{
case 's':
signed = asigned.SIGNED;
return true;
case 'u':
signed = asigned.UNSIGNED;
return true;
case 'h':
signed = asigned.HEX;
return true;
default:
return false;
}
}
}
}