Ram Watch - ability to set memory domain

This commit is contained in:
andres.delikat 2011-03-18 18:27:05 +00:00
parent e2caffcb04
commit 074747d49c
2 changed files with 80 additions and 4 deletions

View File

@ -101,6 +101,9 @@
this.freezeAddressToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FreezetoolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.memoryDomainsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
this.MemDomainLabel = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
@ -225,6 +228,8 @@
// watchesToolStripMenuItem
//
this.watchesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.memoryDomainsToolStripMenuItem,
this.toolStripSeparator8,
this.newWatchToolStripMenuItem,
this.editWatchToolStripMenuItem,
this.removeWatchToolStripMenuItem,
@ -733,6 +738,25 @@
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(188, 6);
//
// memoryDomainsToolStripMenuItem
//
this.memoryDomainsToolStripMenuItem.Name = "memoryDomainsToolStripMenuItem";
this.memoryDomainsToolStripMenuItem.Size = new System.Drawing.Size(222, 22);
this.memoryDomainsToolStripMenuItem.Text = "Memory Domains";
//
// toolStripSeparator8
//
this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(219, 6);
//
// MemDomainLabel
//
this.MemDomainLabel.AutoSize = true;
this.MemDomainLabel.Location = new System.Drawing.Point(147, 57);
this.MemDomainLabel.Name = "MemDomainLabel";
this.MemDomainLabel.Size = new System.Drawing.Size(0, 13);
this.MemDomainLabel.TabIndex = 6;
//
// RamWatch
//
this.AllowDrop = true;
@ -740,6 +764,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(364, 406);
this.Controls.Add(this.MessageLabel);
this.Controls.Add(this.MemDomainLabel);
this.Controls.Add(this.WatchCountLabel);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.menuStrip1);
@ -835,5 +860,8 @@
private System.Windows.Forms.ToolStripMenuItem freezeAddressToolStripMenuItem;
private System.Windows.Forms.ToolStripButton FreezetoolStripButton2;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
private System.Windows.Forms.ToolStripMenuItem memoryDomainsToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
private System.Windows.Forms.Label MemDomainLabel;
}
}

View File

@ -22,6 +22,7 @@ namespace BizHawk.MultiClient
//.wch format includes platform and domain type
//address num digits based on domain size
//Restore window size should restore column order as well
//When receiving a watch from a different domain, should something be done?
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
@ -31,6 +32,8 @@ namespace BizHawk.MultiClient
int defaultChangeWidth;
int NotesWidth;
string systemID = "NULL";
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
List<Watch> watchList = new List<Watch>();
string currentWatchFile = "";
bool changes = false;
@ -55,7 +58,7 @@ namespace BizHawk.MultiClient
for (int x = 0; x < watchList.Count; x++)
{
watchList[x].prev = watchList[x].value;
watchList[x].PeekAddress(Global.Emulator.MainMemory);
watchList[x].PeekAddress(Domain);
if (watchList[x].value != watchList[x].prev)
watchList[x].changecount++;
}
@ -133,7 +136,7 @@ namespace BizHawk.MultiClient
{
if (watchList[index].type == atype.SEPARATOR)
color = this.BackColor;
if (Global.MainForm.Cheats1.IsActiveCheat(Global.Emulator.MainMemory, watchList[index].address))
if (Global.MainForm.Cheats1.IsActiveCheat(Domain, watchList[index].address))
color = Color.LightCyan;
}
@ -145,7 +148,7 @@ namespace BizHawk.MultiClient
if (watchList[index].type == atype.SEPARATOR)
text = "";
else
text = String.Format("{0:X" + GetNumDigits((Global.Emulator.MainMemory.Size - 1)).ToString() + "}", watchList[index].address);
text = String.Format("{0:X" + GetNumDigits((Domain.Size - 1)).ToString() + "}", watchList[index].address);
}
if (column == 1) //Value
{
@ -685,6 +688,7 @@ namespace BizHawk.MultiClient
private void RamWatch_Load(object sender, EventArgs e)
{
LoadConfigSettings();
SetMemoryDomainMenu();
}
private void filesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
@ -1101,7 +1105,7 @@ namespace BizHawk.MultiClient
if (indexes.Count > 0)
{
Cheat c = new Cheat("", watchList[indexes[0]].address, (byte)watchList[indexes[0]].value,
true, Global.Emulator.MainMemory);
true, Domain);
Global.MainForm.Cheats1.AddCheat(c);
}
}
@ -1115,5 +1119,49 @@ namespace BizHawk.MultiClient
{
FreezeAddress();
}
private void SetPlatformAndMemoryDomainLabel()
{
string memoryDomain = Domain.ToString();
systemID = Global.Emulator.SystemId;
MemDomainLabel.Text = systemID + " " + memoryDomain;
}
private void SetMemoryDomain(int pos)
{
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{
Domain = Global.Emulator.MemoryDomains[pos];
}
SetPlatformAndMemoryDomainLabel();
Update();
}
private void SetMemoryDomainMenu()
{
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
if (Global.Emulator.MemoryDomains.Count > 0)
{
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
var item = new ToolStripMenuItem();
item.Text = str;
{
int z = x;
item.Click += (o, ev) => SetMemoryDomain(z);
}
if (x == 0)
{
//item.Checked = true; //TODO: figure out how to check/uncheck these in SetMemoryDomain
SetMemoryDomain(x);
}
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
}
}
else
memoryDomainsToolStripMenuItem.Enabled = false;
}
}
}