diff --git a/BizHawk.Emulation/Interfaces/IEmulator.cs b/BizHawk.Emulation/Interfaces/IEmulator.cs index 4f94b38eaa..641fde5078 100644 --- a/BizHawk.Emulation/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation/Interfaces/IEmulator.cs @@ -57,6 +57,15 @@ namespace BizHawk PokeByte = pokeByte; } + public MemoryDomain(MemoryDomain domain) + { + Name = domain.Name; + Size = domain.Size; + Endian = domain.Endian; + PeekByte = domain.PeekByte; + PokeByte = domain.PokeByte; + } + public override string ToString() { return Name; diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index 0e739227d9..e469f5500e 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -250,7 +250,7 @@ namespace BizHawk.MultiClient { CloseGame(); Global.Emulator = new NullEmulator(); - RamSearch1.StartNewSearch(); + RamSearch1.Restart(); Text = "BizHawk"; } diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 866b2e706d..4b6112afa0 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -343,7 +343,7 @@ namespace BizHawk.MultiClient LoadRom(filePaths[0]); } - bool IsNullEmulator() + public bool IsNullEmulator() { if (Global.Emulator is NullEmulator) return true; @@ -440,7 +440,7 @@ namespace BizHawk.MultiClient else throttle.SetCoreFps(60); SetSpeedPercent(Global.Config.SpeedPercent); } - RamSearch1.StartNewSearch(); + RamSearch1.Restart(); CurrentlyOpenRom = path; return true; } diff --git a/BizHawk.MultiClient/tools/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/RamSearch.Designer.cs index 42925c028a..4777bf4a0d 100644 --- a/BizHawk.MultiClient/tools/RamSearch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamSearch.Designer.cs @@ -46,6 +46,10 @@ this.Value = new System.Windows.Forms.ColumnHeader(); this.Previous = new System.Windows.Forms.ColumnHeader(); this.Changes = new System.Windows.Forms.ColumnHeader(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.startNewSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); + this.searchToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.newSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -125,11 +129,9 @@ this.AutoSearchCheckBox = new System.Windows.Forms.CheckBox(); this.MemDomainLabel = new System.Windows.Forms.Label(); this.OutputLabel = new System.Windows.Forms.Label(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.startNewSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); - this.searchToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + this.memoryDomainsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SearchtoolStrip1.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); @@ -137,7 +139,6 @@ this.toolStrip2.SuspendLayout(); this.CompareToBox.SuspendLayout(); this.ComparisonBox.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // SearchtoolStrip1 @@ -300,6 +301,34 @@ this.Changes.Text = "Changes"; this.Changes.Width = 55; // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.startNewSearchToolStripMenuItem, + this.toolStripSeparator9, + this.searchToolStripMenuItem2}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(170, 54); + // + // startNewSearchToolStripMenuItem + // + this.startNewSearchToolStripMenuItem.Name = "startNewSearchToolStripMenuItem"; + this.startNewSearchToolStripMenuItem.Size = new System.Drawing.Size(169, 22); + this.startNewSearchToolStripMenuItem.Text = "&Start New Search"; + this.startNewSearchToolStripMenuItem.Click += new System.EventHandler(this.startNewSearchToolStripMenuItem_Click); + // + // toolStripSeparator9 + // + this.toolStripSeparator9.Name = "toolStripSeparator9"; + this.toolStripSeparator9.Size = new System.Drawing.Size(166, 6); + // + // searchToolStripMenuItem2 + // + this.searchToolStripMenuItem2.Name = "searchToolStripMenuItem2"; + this.searchToolStripMenuItem2.Size = new System.Drawing.Size(169, 22); + this.searchToolStripMenuItem2.Text = "&Search"; + this.searchToolStripMenuItem2.Click += new System.EventHandler(this.searchToolStripMenuItem2_Click); + // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -431,6 +460,7 @@ // searchToolStripMenuItem // this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.memoryDomainsToolStripMenuItem, this.searchToolStripMenuItem1, this.undoToolStripMenuItem, this.copyValueToPrevToolStripMenuItem, @@ -1052,33 +1082,11 @@ this.OutputLabel.TabIndex = 9; this.OutputLabel.Text = " "; // - // contextMenuStrip1 + // memoryDomainsToolStripMenuItem // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.startNewSearchToolStripMenuItem, - this.toolStripSeparator9, - this.searchToolStripMenuItem2}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(170, 54); - // - // startNewSearchToolStripMenuItem - // - this.startNewSearchToolStripMenuItem.Name = "startNewSearchToolStripMenuItem"; - this.startNewSearchToolStripMenuItem.Size = new System.Drawing.Size(169, 22); - this.startNewSearchToolStripMenuItem.Text = "&Start New Search"; - this.startNewSearchToolStripMenuItem.Click += new System.EventHandler(this.startNewSearchToolStripMenuItem_Click); - // - // toolStripSeparator9 - // - this.toolStripSeparator9.Name = "toolStripSeparator9"; - this.toolStripSeparator9.Size = new System.Drawing.Size(166, 6); - // - // searchToolStripMenuItem2 - // - this.searchToolStripMenuItem2.Name = "searchToolStripMenuItem2"; - this.searchToolStripMenuItem2.Size = new System.Drawing.Size(169, 22); - this.searchToolStripMenuItem2.Text = "&Search"; - this.searchToolStripMenuItem2.Click += new System.EventHandler(this.searchToolStripMenuItem2_Click); + this.memoryDomainsToolStripMenuItem.Name = "memoryDomainsToolStripMenuItem"; + this.memoryDomainsToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.memoryDomainsToolStripMenuItem.Text = "&Memory Domains"; // // RamSearch // @@ -1103,6 +1111,7 @@ this.LocationChanged += new System.EventHandler(this.RamSearch_LocationChanged); this.SearchtoolStrip1.ResumeLayout(false); this.SearchtoolStrip1.PerformLayout(); + this.contextMenuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); @@ -1117,7 +1126,6 @@ this.CompareToBox.PerformLayout(); this.ComparisonBox.ResumeLayout(false); this.ComparisonBox.PerformLayout(); - this.contextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -1224,5 +1232,6 @@ private System.Windows.Forms.ToolStripMenuItem startNewSearchToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem2; + private System.Windows.Forms.ToolStripMenuItem memoryDomainsToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index f777f10269..03e6139521 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -18,8 +18,8 @@ namespace BizHawk.MultiClient { //TODO: //Window position gets saved but doesn't load properly - //Multiple memory domains //Context Menu - if highlighted items - show Highlight dependent functions + //Format address - number of digits based on max value of domain string systemID = "NULL"; List searchList = new List(); @@ -28,10 +28,12 @@ namespace BizHawk.MultiClient List prevList = new List(); private bool IsAWeededList = false; //For deciding whether the weeded list is relevant (0 size could mean all were removed in a legit preview + MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { }); + public enum SCompareTo { PREV, VALUE, ADDRESS, CHANGES }; public enum SOperator { LESS, GREATER, LESSEQUAL, GREATEREQUAL, EQUAL, NOTEQUAL, DIFFBY }; public enum SSigned { SIGNED, UNSIGNED, HEX }; - + //Reset window position item int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultHeight; @@ -47,7 +49,7 @@ namespace BizHawk.MultiClient for (int x = 0; x < searchList.Count; x++) { searchList[x].prev = searchList[x].value; - searchList[x].PeekAddress(Global.Emulator.MainMemory); + searchList[x].PeekAddress(Domain); if (searchList[x].prev != searchList[x].value) searchList[x].changecount++; @@ -65,7 +67,7 @@ namespace BizHawk.MultiClient defaultWidth = this.Size.Width; //Save these first so that the user can restore to its original size defaultHeight = this.Size.Height; - if (Global.Emulator.MainMemory.Endian == Endian.Big) + if (Domain.Endian == Endian.Big) { bigEndianToolStripMenuItem.Checked = true; littleEndianToolStripMenuItem.Checked = false; @@ -85,6 +87,49 @@ namespace BizHawk.MultiClient { this.Size = new System.Drawing.Size(Global.Config.RamSearchWidth, Global.Config.RamSearchHeight); } + + SetMemoryDomainMenu(); + } + + 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; + } + + public void Restart() + { + SetMemoryDomainMenu(); //Calls Start New Search + } + + private void SetMemoryDomain(int pos) + { + if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check + { + Domain = Global.Emulator.MemoryDomains[pos]; + } + SetPlatformAndMemoryDomainLabel(); + StartNewSearch(); } private void SetTotal() @@ -273,13 +318,13 @@ namespace BizHawk.MultiClient return false; } - public void StartNewSearch() + private void StartNewSearch() { weededList.Clear(); IsAWeededList = false; searchList.Clear(); undoList.Clear(); - GetMemoryDomain(); + SetPlatformAndMemoryDomainLabel(); int startaddress = 0; if (Global.Emulator.SystemId == "PCE") startaddress = 0x1F0000; //For now, until Emulator core functionality can better handle a prefix @@ -302,14 +347,14 @@ namespace BizHawk.MultiClient } } - for (int x = 0; x <= ((Global.Emulator.MainMemory.Size / divisor)-1); x++) + for (int x = 0; x <= ((Domain.Size / divisor)-1); x++) { searchList.Add(new Watch()); searchList[x].address = count + startaddress; searchList[x].type = GetDataSize(); searchList[x].bigendian = GetBigEndian(); searchList[x].signed = GetDataType(); - searchList[x].PeekAddress(Global.Emulator.MainMemory); + searchList[x].PeekAddress(Domain); searchList[x].prev = searchList[x].value; if (includeMisalignedToolStripMenuItem.Checked) count++; @@ -357,9 +402,9 @@ namespace BizHawk.MultiClient StartNewSearch(); } - private void GetMemoryDomain() + private void SetPlatformAndMemoryDomainLabel() { - string memoryDomain = "Main memory"; + string memoryDomain = Domain.ToString(); systemID = Global.Emulator.SystemId; MemDomainLabel.Text = systemID + " " + memoryDomain; } diff --git a/BizHawk.MultiClient/tools/RamSearch.resx b/BizHawk.MultiClient/tools/RamSearch.resx index df3cdfbb8f..767de0f927 100644 --- a/BizHawk.MultiClient/tools/RamSearch.resx +++ b/BizHawk.MultiClient/tools/RamSearch.resx @@ -163,6 +163,9 @@ 259, 17 + + 358, 17 + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 @@ -194,9 +197,6 @@ s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - - 358, 17 - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8