Column sorting (and reverse sorting) for Ram Search & Ram Watch

This commit is contained in:
andres.delikat 2011-06-19 19:10:01 +00:00
parent fc48e0e4f7
commit 5e27953db0
6 changed files with 3618 additions and 3414 deletions

View File

@ -10,203 +10,203 @@ using System.IO;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public partial class PlayMovie : Form public partial class PlayMovie : Form
{ {
//TODO: after browse & update, focus on the movie just added, and show stats //TODO: after browse & update, focus on the movie just added, and show stats
//This is a modal dialog, implement it as modeless //This is a modal dialog, implement it as modeless
// Option to include subdirectories // Option to include subdirectories
// Option to include savestate files (that have an input log) // Option to include savestate files (that have an input log)
//Clicking column headers should sort info //Clicking column headers should sort info
//AddMovieToList should check for duplicates and not add them //AddMovieToList should check for duplicates and not add them
List<Movie> MovieList = new List<Movie>(); List<Movie> MovieList = new List<Movie>();
bool sortReverse; bool sortReverse;
string sortedCol; string sortedCol;
public PlayMovie() public PlayMovie()
{ {
InitializeComponent(); InitializeComponent();
MovieView.QueryItemText += new QueryItemTextHandler(MovieView_QueryItemText); MovieView.QueryItemText += new QueryItemTextHandler(MovieView_QueryItemText);
MovieView.QueryItemBkColor += new QueryItemBkColorHandler(MovieView_QueryItemBkColor); MovieView.QueryItemBkColor += new QueryItemBkColorHandler(MovieView_QueryItemBkColor);
MovieView.VirtualMode = true; MovieView.VirtualMode = true;
sortReverse = false; sortReverse = false;
sortedCol = ""; sortedCol = "";
} }
void MovieView_QueryItemText(int index, int column, out string text) void MovieView_QueryItemText(int index, int column, out string text)
{ {
text = ""; text = "";
if (column == 0) //File if (column == 0) //File
text = Path.GetFileName(MovieList[index].GetFilePath()); text = Path.GetFileName(MovieList[index].GetFilePath());
if (column == 1) //System if (column == 1) //System
text = MovieList[index].GetSysID(); text = MovieList[index].GetSysID();
if (column == 2) //Game if (column == 2) //Game
text = MovieList[index].GetGameName(); text = MovieList[index].GetGameName();
if (column == 3) //Time if (column == 3) //Time
text = MovieList[index].GetTime(true); text = MovieList[index].GetTime(true);
} }
private void MovieView_QueryItemBkColor(int index, int column, ref Color color) private void MovieView_QueryItemBkColor(int index, int column, ref Color color)
{ {
}
private void Cancel_Click(object sender, EventArgs e) }
{
this.Close();
}
private void Run() private void Cancel_Click(object sender, EventArgs e)
{ {
Global.MainForm.StartNewMovie(MovieList[MovieView.SelectedIndices[0]], false); this.Close();
} }
private void OK_Click(object sender, EventArgs e) private void Run()
{ {
Global.MainForm.ReadOnly = ReadOnlyCheckBox.Checked; Global.MainForm.StartNewMovie(MovieList[MovieView.SelectedIndices[0]], false);
Run(); }
this.Close();
}
private void BrowseMovies_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog(); Global.MainForm.ReadOnly = ReadOnlyCheckBox.Checked;
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, ""); Run();
ofd.Filter = "Movie files (*.tas)|*.TAS;*.ZIP;*.7z|FCEUX Movies|*.FM2|PCEjin Movies|*.PCE|Archive Files|*.zip;*.7z|All Files|*.*"; this.Close();
}
Global.Sound.StopSound();
var result = ofd.ShowDialog();
Global.Sound.StartSound();
if (result == DialogResult.OK)
{
var file = new FileInfo(ofd.FileName);
if (!file.Exists)
return;
else
{
AddMovieToList(ofd.FileName);
}
}
}
private void AddMovieToList(string filename) private void BrowseMovies_Click(object sender, EventArgs e)
{ {
var file = new HawkFile(filename); OpenFileDialog ofd = new OpenFileDialog();
if (!file.Exists) ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
return; ofd.Filter = "Movie files (*.tas)|*.TAS;*.ZIP;*.7z|FCEUX Movies|*.FM2|PCEjin Movies|*.PCE|Archive Files|*.zip;*.7z|All Files|*.*";
else
{
PreLoadMovieFile(file);
MovieView.ItemCount = MovieList.Count;
UpdateList();
MovieView.SelectedIndices.Clear();
MovieView.setSelection(MovieList.Count - 1);
sortReverse = false;
sortedCol = "";
}
}
private void PreLoadMovieFile(HawkFile path) Global.Sound.StopSound();
{ var result = ofd.ShowDialog();
Movie m = new Movie(path.CanonicalFullPath, MOVIEMODE.INACTIVE); Global.Sound.StartSound();
m.PreLoadText(); if (result == DialogResult.OK)
//m.LoadMovie(); {
if (path.Extension.ToUpper() == ".FM2") var file = new FileInfo(ofd.FileName);
m.SetHeaderLine(MovieHeader.PLATFORM, "NES"); if (!file.Exists)
else if (path.Extension.ToUpper() == ".MC2") return;
m.SetHeaderLine(MovieHeader.PLATFORM, "PCE"); else
MovieList.Add(m); {
} AddMovieToList(ofd.FileName);
}
}
}
private void UpdateList() private void AddMovieToList(string filename)
{ {
MovieView.Refresh(); var file = new HawkFile(filename);
UpdateMovieCount(); if (!file.Exists)
} return;
else
{
PreLoadMovieFile(file);
MovieView.ItemCount = MovieList.Count;
UpdateList();
MovieView.SelectedIndices.Clear();
MovieView.setSelection(MovieList.Count - 1);
sortReverse = false;
sortedCol = "";
}
}
private void UpdateMovieCount() private void PreLoadMovieFile(HawkFile path)
{ {
int x = MovieList.Count; Movie m = new Movie(path.CanonicalFullPath, MOVIEMODE.INACTIVE);
if (x == 1) m.PreLoadText();
MovieCount.Text = x.ToString() + " movie"; //m.LoadMovie();
else if (path.Extension.ToUpper() == ".FM2")
MovieCount.Text = x.ToString() + " movies"; m.SetHeaderLine(MovieHeader.PLATFORM, "NES");
} else if (path.Extension.ToUpper() == ".MC2")
m.SetHeaderLine(MovieHeader.PLATFORM, "PCE");
MovieList.Add(m);
}
private void PlayMovie_Load(object sender, EventArgs e) private void UpdateList()
{ {
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, ""); MovieView.Refresh();
if (!Directory.Exists(d)) UpdateMovieCount();
Directory.CreateDirectory(d); }
foreach (string f in Directory.GetFiles(d, "*.tas"))
AddMovieToList(f);
foreach (string f in Directory.GetFiles(d, "*.fm2"))
AddMovieToList(f);
foreach (string f in Directory.GetFiles(d, "*.mc2"))
AddMovieToList(f);
}
private void MovieView_SelectedIndexChanged(object sender, EventArgs e) private void UpdateMovieCount()
{ {
DetailsView.Items.Clear(); int x = MovieList.Count;
int x = MovieView.SelectedIndices[0]; if (x == 1)
Dictionary<string, string> h = MovieList[x].GetHeaderInfo(); MovieCount.Text = x.ToString() + " movie";
else
foreach (var kvp in h) MovieCount.Text = x.ToString() + " movies";
{ }
ListViewItem item = new ListViewItem(kvp.Key);
item.SubItems.Add(kvp.Value);
DetailsView.Items.Add(item);
}
}
private void button1_Click(object sender, EventArgs e) private void PlayMovie_Load(object sender, EventArgs e)
{ {
//TODO: a comments viewer/editor string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
} if (!Directory.Exists(d))
Directory.CreateDirectory(d);
foreach (string f in Directory.GetFiles(d, "*.tas"))
AddMovieToList(f);
foreach (string f in Directory.GetFiles(d, "*.fm2"))
AddMovieToList(f);
foreach (string f in Directory.GetFiles(d, "*.mc2"))
AddMovieToList(f);
}
private void button2_Click(object sender, EventArgs e) private void MovieView_SelectedIndexChanged(object sender, EventArgs e)
{ {
//TODO: a subtitle viewer/editor DetailsView.Items.Clear();
} int x = MovieView.SelectedIndices[0];
Dictionary<string, string> h = MovieList[x].GetHeaderInfo();
private void MovieView_DoubleClick(object sender, EventArgs e) foreach (var kvp in h)
{ {
Run(); ListViewItem item = new ListViewItem(kvp.Key);
this.Close(); item.SubItems.Add(kvp.Value);
} DetailsView.Items.Add(item);
}
}
private void MovieView_DragEnter(object sender, DragEventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); //TODO: a comments viewer/editor
} }
private void MovieView_DragDrop(object sender, DragEventArgs e) private void button2_Click(object sender, EventArgs e)
{ {
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); //TODO: a subtitle viewer/editor
foreach (string path in filePaths) }
{
if (Path.GetExtension(path) == ".tas" || Path.GetExtension(path) == ".fm2" ||
Path.GetExtension(path) == ".mc2")
AddMovieToList(path);
}
}
private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e) private void MovieView_DoubleClick(object sender, EventArgs e)
{ {
OrderColumn(e.Column); Run();
} this.Close();
}
private void OrderColumn(int columnToOrder) private void MovieView_DragEnter(object sender, DragEventArgs e)
{ {
string columnName = MovieView.Columns[columnToOrder].Text; e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
if (sortedCol.CompareTo(columnName) != 0) }
sortReverse = false;
MovieList.Sort((x, y) => x.CompareTo(y, columnName) * (sortReverse ? -1 : 1));
sortedCol = columnName;
sortReverse = !(sortReverse);
MovieView.Refresh();
}
} private void MovieView_DragDrop(object sender, DragEventArgs e)
{
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string path in filePaths)
{
if (Path.GetExtension(path) == ".tas" || Path.GetExtension(path) == ".fm2" ||
Path.GetExtension(path) == ".mc2")
AddMovieToList(path);
}
}
private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e)
{
OrderColumn(e.Column);
}
private void OrderColumn(int columnToOrder)
{
string columnName = MovieView.Columns[columnToOrder].Text;
if (sortedCol.CompareTo(columnName) != 0)
sortReverse = false;
MovieList.Sort((x, y) => x.CompareTo(y, columnName) * (sortReverse ? -1 : 1));
sortedCol = columnName;
sortReverse = !(sortReverse);
MovieView.Refresh();
}
}
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -361,28 +361,28 @@
this.showChangeCountsToolStripMenuItem.Checked = true; this.showChangeCountsToolStripMenuItem.Checked = true;
this.showChangeCountsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.showChangeCountsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.showChangeCountsToolStripMenuItem.Name = "showChangeCountsToolStripMenuItem"; this.showChangeCountsToolStripMenuItem.Name = "showChangeCountsToolStripMenuItem";
this.showChangeCountsToolStripMenuItem.Size = new System.Drawing.Size(206, 22); this.showChangeCountsToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.showChangeCountsToolStripMenuItem.Text = "Change Counts"; this.showChangeCountsToolStripMenuItem.Text = "Change Counts";
this.showChangeCountsToolStripMenuItem.Click += new System.EventHandler(this.showChangeCountsToolStripMenuItem_Click); this.showChangeCountsToolStripMenuItem.Click += new System.EventHandler(this.showChangeCountsToolStripMenuItem_Click);
// //
// showPreviousValueToolStripMenuItem // showPreviousValueToolStripMenuItem
// //
this.showPreviousValueToolStripMenuItem.Name = "showPreviousValueToolStripMenuItem"; this.showPreviousValueToolStripMenuItem.Name = "showPreviousValueToolStripMenuItem";
this.showPreviousValueToolStripMenuItem.Size = new System.Drawing.Size(206, 22); this.showPreviousValueToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.showPreviousValueToolStripMenuItem.Text = "Previous Value"; this.showPreviousValueToolStripMenuItem.Text = "Previous Value";
this.showPreviousValueToolStripMenuItem.Click += new System.EventHandler(this.showPreviousValueToolStripMenuItem_Click); this.showPreviousValueToolStripMenuItem.Click += new System.EventHandler(this.showPreviousValueToolStripMenuItem_Click);
// //
// prevValueShowsChangeAmountToolStripMenuItem // prevValueShowsChangeAmountToolStripMenuItem
// //
this.prevValueShowsChangeAmountToolStripMenuItem.Name = "prevValueShowsChangeAmountToolStripMenuItem"; this.prevValueShowsChangeAmountToolStripMenuItem.Name = "prevValueShowsChangeAmountToolStripMenuItem";
this.prevValueShowsChangeAmountToolStripMenuItem.Size = new System.Drawing.Size(206, 22); this.prevValueShowsChangeAmountToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.prevValueShowsChangeAmountToolStripMenuItem.Text = "Prev Value as change"; this.prevValueShowsChangeAmountToolStripMenuItem.Text = "Prev Value as change";
this.prevValueShowsChangeAmountToolStripMenuItem.Click += new System.EventHandler(this.prevValueShowsChangeAmountToolStripMenuItem_Click); this.prevValueShowsChangeAmountToolStripMenuItem.Click += new System.EventHandler(this.prevValueShowsChangeAmountToolStripMenuItem_Click);
// //
// toolStripSeparator7 // toolStripSeparator7
// //
this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(203, 6); this.toolStripSeparator7.Size = new System.Drawing.Size(200, 6);
// //
// restoreWindowSizeToolStripMenuItem // restoreWindowSizeToolStripMenuItem
// //
@ -416,6 +416,7 @@
this.WatchListView.TabIndex = 1; this.WatchListView.TabIndex = 1;
this.WatchListView.UseCompatibleStateImageBehavior = false; this.WatchListView.UseCompatibleStateImageBehavior = false;
this.WatchListView.View = System.Windows.Forms.View.Details; this.WatchListView.View = System.Windows.Forms.View.Details;
this.WatchListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.WatchListView_ColumnClick);
this.WatchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WatchListView_MouseDoubleClick); this.WatchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WatchListView_MouseDoubleClick);
this.WatchListView.ColumnReordered += new System.Windows.Forms.ColumnReorderedEventHandler(this.ColumnReorder); this.WatchListView.ColumnReordered += new System.Windows.Forms.ColumnReorderedEventHandler(this.ColumnReorder);
this.WatchListView.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.WatchListView_AfterLabelEdit); this.WatchListView.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.WatchListView_AfterLabelEdit);

View File

@ -17,8 +17,8 @@ namespace BizHawk.MultiClient
public partial class RamWatch : Form public partial class RamWatch : Form
{ {
//TODO: //TODO:
//Restore window size should restore column order as well
//When receiving a watch from a different domain, should something be done? //When receiving a watch from a different domain, should something be done?
//when sorting, "Prev as Change" option not taken into account
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight; int defaultHeight;
@ -35,6 +35,9 @@ namespace BizHawk.MultiClient
bool changes = false; bool changes = false;
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>(); List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
string sortedCol;
bool sortReverse;
public void Restart() public void Restart()
{ {
if (!this.IsHandleCreated || this.IsDisposed) return; if (!this.IsHandleCreated || this.IsDisposed) return;
@ -132,6 +135,8 @@ namespace BizHawk.MultiClient
WatchListView.QueryItemBkColor += new QueryItemBkColorHandler(WatchListView_QueryItemBkColor); WatchListView.QueryItemBkColor += new QueryItemBkColorHandler(WatchListView_QueryItemBkColor);
WatchListView.VirtualMode = true; WatchListView.VirtualMode = true;
Closing += (o, e) => SaveConfigSettings(); Closing += (o, e) => SaveConfigSettings();
sortReverse = false;
sortedCol = "";
} }
protected override void OnClosing(CancelEventArgs e) protected override void OnClosing(CancelEventArgs e)
@ -312,6 +317,8 @@ namespace BizHawk.MultiClient
currentWatchFile = ""; currentWatchFile = "";
changes = false; changes = false;
MessageLabel.Text = ""; MessageLabel.Text = "";
sortReverse = false;
sortedCol = "";
} }
} }
@ -1376,5 +1383,21 @@ namespace BizHawk.MultiClient
i++; i++;
} while (columnHeaders.Count() > 0); } while (columnHeaders.Count() > 0);
} }
private void OrderColumn(int columnToOrder)
{
string columnName = WatchListView.Columns[columnToOrder].Text;
if (sortedCol.CompareTo(columnName) != 0)
sortReverse = false;
watchList.Sort((x, y) => x.CompareTo(y, columnName));//* (sortReverse ? -1 : 1));
//sortedCol = columnName;
//sortReverse = !(sortReverse);
WatchListView.Refresh();
}
private void WatchListView_ColumnClick(object sender, ColumnClickEventArgs e)
{
OrderColumn(e.Column);
}
} }
} }

View File

@ -5,230 +5,383 @@ using System.Text;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public enum atype { BYTE, WORD, DWORD, SEPARATOR }; //TODO: more custom types too like 12.4 and 24.12 fixed point public enum atype { BYTE, WORD, DWORD, SEPARATOR }; //TODO: more custom types too like 12.4 and 24.12 fixed point
public enum asigned { SIGNED, UNSIGNED, HEX }; public enum asigned { SIGNED, UNSIGNED, HEX };
/// <summary> /// <summary>
/// An object that represent a ram address and related properties /// An object that represent a ram address and related properties
/// </summary> /// </summary>
public class Watch public class Watch
{ {
public Watch() public Watch()
{ {
address = 0; address = 0;
value = 0; value = 0;
type = atype.BYTE; type = atype.BYTE;
signed = asigned.UNSIGNED; signed = asigned.UNSIGNED;
bigendian = true; bigendian = true;
notes = ""; notes = "";
changecount = 0; changecount = 0;
prev = 0; prev = 0;
} }
public Watch(Watch w) public Watch(Watch w)
{ {
address = w.address; address = w.address;
value = w.value; value = w.value;
type = w.type; type = w.type;
signed = w.signed; signed = w.signed;
bigendian = w.bigendian; bigendian = w.bigendian;
notes = w.notes; notes = w.notes;
changecount = w.changecount; changecount = w.changecount;
prev = w.prev; prev = w.prev;
} }
public Watch(int Address, int Value, atype Type, asigned Signed, bool BigEndian, string Notes) public Watch(int Address, int Value, atype Type, asigned Signed, bool BigEndian, string Notes)
{ {
address = Address; address = Address;
value = Value; value = Value;
type = Type; type = Type;
signed = Signed; signed = Signed;
bigendian = BigEndian; bigendian = BigEndian;
notes = Notes; notes = Notes;
changecount = 0; changecount = 0;
prev = 0; prev = 0;
} }
public int address { get; set; } public int address { get; set; }
public int value { get; set; } //Current value public int value { get; set; } //Current value
public int prev { get; set; } public int prev { get; set; }
public atype type { get; set; } //Address type (byte, word, dword, etc public atype type { get; set; } //Address type (byte, word, dword, etc
public asigned signed { get; set; } //Signed/Unsigned? public asigned signed { get; set; } //Signed/Unsigned?
public bool bigendian { get; set; } public bool bigendian { get; set; }
public string notes { get; set; } //User notes public string notes { get; set; } //User notes
public int changecount { get; set; } public int changecount { get; set; }
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;
case 'S':
type = atype.SEPARATOR;
return true;
default:
return false;
}
}
public char GetTypeByChar() public bool SetTypeByChar(char c) //b = byte, w = word, d = dword
{ {
switch (type) switch (c)
{ {
case atype.BYTE: case 'b':
return 'b'; type = atype.BYTE;
case atype.WORD: return true;
return 'w'; case 'w':
case atype.DWORD: type = atype.WORD;
return 'd'; return true;
case atype.SEPARATOR: case 'd':
return 'S'; type = atype.DWORD;
default: return true;
return 'b'; //Just in case case 'S':
} type = atype.SEPARATOR;
} return true;
default:
return false;
}
}
public bool SetSignedByChar(char c) //s = signed, u = unsigned, h = hex public char GetTypeByChar()
{ {
switch (c) switch (type)
{ {
case 's': case atype.BYTE:
signed = asigned.SIGNED; return 'b';
return true; case atype.WORD:
case 'u': return 'w';
signed = asigned.UNSIGNED; case atype.DWORD:
return true; return 'd';
case 'h': case atype.SEPARATOR:
signed = asigned.HEX; return 'S';
return true; default:
default: return 'b'; //Just in case
return false; }
} }
}
public char GetSignedByChar() public bool SetSignedByChar(char c) //s = signed, u = unsigned, h = hex
{ {
switch (signed) switch (c)
{ {
case asigned.SIGNED: case 's':
return 's'; signed = asigned.SIGNED;
case asigned.UNSIGNED: return true;
return 'u'; case 'u':
case asigned.HEX: signed = asigned.UNSIGNED;
return 'h'; return true;
default: case 'h':
return 's'; //Just in case signed = asigned.HEX;
} return true;
} default:
return false;
}
}
private void PeekByte(MemoryDomain domain) public char GetSignedByChar()
{ {
value = domain.PeekByte(address); switch (signed)
} {
case asigned.SIGNED:
return 's';
case asigned.UNSIGNED:
return 'u';
case asigned.HEX:
return 'h';
default:
return 's'; //Just in case
}
}
private int PeekWord(MemoryDomain domain, int addr) private void PeekByte(MemoryDomain domain)
{ {
int temp = 0; value = domain.PeekByte(address);
if (bigendian) }
{
temp = ((domain.PeekByte(addr) * 256) +
domain.PeekByte(addr + 1));
}
else
{
temp = ((domain.PeekByte(addr) +
domain.PeekByte(addr + 1) * 256));
}
return temp;
}
private void PeekDWord(MemoryDomain domain) private int PeekWord(MemoryDomain domain, int addr)
{ {
value = ((PeekWord(domain, address) * 65536) + int temp = 0;
PeekWord(domain, address + 2)); if (bigendian)
} {
temp = ((domain.PeekByte(addr) * 256) +
domain.PeekByte(addr + 1));
}
else
{
temp = ((domain.PeekByte(addr) +
domain.PeekByte(addr + 1) * 256));
}
return temp;
}
public void PeekAddress(MemoryDomain domain) private void PeekDWord(MemoryDomain domain)
{ {
if (type == atype.SEPARATOR) value = ((PeekWord(domain, address) * 65536) +
return; PeekWord(domain, address + 2));
}
switch(type) public void PeekAddress(MemoryDomain domain)
{ {
case atype.BYTE: if (type == atype.SEPARATOR)
PeekByte(domain); return;
break;
case atype.WORD:
value = PeekWord(domain, address);
break;
case atype.DWORD:
PeekDWord(domain);
break;
}
}
private void PokeByte(MemoryDomain domain) switch (type)
{ {
domain.PokeByte(address, (byte)value); case atype.BYTE:
} PeekByte(domain);
break;
case atype.WORD:
value = PeekWord(domain, address);
break;
case atype.DWORD:
PeekDWord(domain);
break;
}
}
private void PokeWord(MemoryDomain domain) private void PokeByte(MemoryDomain domain)
{ {
if (bigendian) domain.PokeByte(address, (byte)value);
{ }
domain.PokeByte(address, (byte)(value / 256));
domain.PokeByte(address + 1, (byte)(value % 256));
}
else
{
domain.PokeByte(address + 1, (byte)(value / 256));
domain.PokeByte(address, (byte)(value % 256));
}
}
private void PokeDWord(MemoryDomain domain) private void PokeWord(MemoryDomain domain)
{ {
if (bigendian) if (bigendian)
{ {
domain.PokeByte(address, (byte)(value << 6)); domain.PokeByte(address, (byte)(value / 256));
domain.PokeByte(address + 1, (byte)(value << 4)); domain.PokeByte(address + 1, (byte)(value % 256));
domain.PokeByte(address + 2, (byte)(value << 2)); }
domain.PokeByte(address + 3, (byte)(value)); else
} {
else domain.PokeByte(address + 1, (byte)(value / 256));
{ domain.PokeByte(address, (byte)(value % 256));
domain.PokeByte(address + 1, (byte)(value << 6)); }
domain.PokeByte(address, (byte)(value << 4)); }
domain.PokeByte(address + 3, (byte)(value << 2));
domain.PokeByte(address + 2, (byte)(value));
}
}
public void PokeAddress(MemoryDomain domain) private void PokeDWord(MemoryDomain domain)
{ {
if (type == atype.SEPARATOR) if (bigendian)
return; {
domain.PokeByte(address, (byte)(value << 6));
domain.PokeByte(address + 1, (byte)(value << 4));
domain.PokeByte(address + 2, (byte)(value << 2));
domain.PokeByte(address + 3, (byte)(value));
}
else
{
domain.PokeByte(address + 1, (byte)(value << 6));
domain.PokeByte(address, (byte)(value << 4));
domain.PokeByte(address + 3, (byte)(value << 2));
domain.PokeByte(address + 2, (byte)(value));
}
}
switch (type) public void PokeAddress(MemoryDomain domain)
{ {
case atype.BYTE: if (type == atype.SEPARATOR)
PokeByte(domain); return;
break;
case atype.WORD: switch (type)
PokeWord(domain); {
break; case atype.BYTE:
case atype.DWORD: PokeByte(domain);
PokeDWord(domain); break;
break; case atype.WORD:
} PokeWord(domain);
} break;
} case atype.DWORD:
PokeDWord(domain);
break;
}
}
private int CompareAddress(Watch Other)
{
if (this.address < Other.address)
return -1;
else if (this.address > Other.address)
return 1;
else
return 0;
}
private int CompareValue(Watch Other)
{
if (this.value < Other.value)
return -1;
else if (this.value > Other.value)
return 1;
else
return 0;
}
private int ComparePrev(Watch Other)
{
if (this.prev < Other.prev)
return -1;
else if (this.prev > Other.prev)
return 1;
else
return 0;
}
private int CompareChanges(Watch Other)
{
if (this.changecount < Other.changecount)
return -1;
else if (this.changecount > Other.changecount)
return 1;
else
return 0;
}
private int CompareNotes(Watch Other)
{
if (this.notes == null & Other.notes == null)
return 0;
else if (this.notes == null)
return -1;
else if (Other.notes == null)
return 1;
else
return this.notes.CompareTo(Other.notes);
}
public int CompareTo(Watch Other, string parameter)
{
int compare = 0;
if (parameter == "Address")
{
compare = CompareAddress(Other);
if (compare == 0)
{
compare = CompareValue(Other);
if (compare == 0)
{
compare = CompareChanges(Other);
if (compare == 0)
{
compare = ComparePrev(Other);
if (compare == 0)
compare = CompareNotes(Other);
}
}
}
}
else if (parameter == "Value")
{
compare = CompareValue(Other);
if (compare == 0)
{
compare = CompareAddress(Other);
if (compare == 0)
{
compare = CompareChanges(Other);
if (compare == 0)
{
compare = ComparePrev(Other);
if (compare == 0)
compare = CompareNotes(Other);
}
}
}
}
else if (parameter == "Prev")
{
compare = ComparePrev(Other);
if (compare == 0)
{
compare = CompareAddress(Other);
if (compare == 0)
{
compare = CompareValue(Other);
if (compare == 0)
{
compare = CompareChanges(Other);
if (compare == 0)
compare = CompareNotes(Other);
}
}
}
}
else if (parameter == "Changes")
{
compare = CompareChanges(Other);
if (compare == 0)
{
compare = CompareAddress(Other);
if (compare == 0)
{
compare = CompareValue(Other);
if (compare == 0)
{
compare = ComparePrev(Other);
if (compare == 0)
compare = CompareNotes(Other);
}
}
}
}
else if (parameter == "Notes")
{
compare = CompareNotes(Other);
if (compare == 0)
{
compare = CompareAddress(Other);
if (compare == 0)
{
compare = CompareValue(Other);
if (compare == 0)
{
compare = CompareChanges(Other);
if (compare == 0)
compare = ComparePrev(Other);
}
}
}
}
return compare;
}
}
} }