PCE CDL - some cleanups like icons and shortcut keys on menus, Recent menu, autoload, other misc tool options

This commit is contained in:
adelikat 2014-04-13 01:05:23 +00:00
parent 7f37535cd5
commit aaeb2c9cdd
4 changed files with 337 additions and 147 deletions

View File

@ -385,6 +385,10 @@ namespace BizHawk.Client.Common
public bool PCEBGViewerAutoload = false;
public int PCEBGViewerRefreshRate = 16;
// PCE CDL settings
public ToolDialogSettings PceCdlSettings = new ToolDialogSettings();
public RecentFiles RecentPceCdlFiles = new RecentFiles(8);
#region Cheats Dialog
public ToolDialogSettings CheatsSettings = new ToolDialogSettings();

View File

@ -344,6 +344,11 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Tools.Load<PceBgViewer>();
}
if (Global.Config.RecentPceCdlFiles.AutoLoad && Global.Emulator is PCEngine)
{
GlobalWin.Tools.Load<PCECDL>();
}
if (Global.Config.AutoLoadSNESGraphicsDebugger && Global.Emulator is LibsnesCore)
{
GlobalWin.Tools.Load<SNESGraphicsDebugger>();

View File

@ -29,121 +29,219 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PCECDL));
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.unionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.disassembleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textBox1 = new System.Windows.Forms.TextBox();
this.LoggingActiveCheckbox = new System.Windows.Forms.CheckBox();
this.menuStrip1 = new MenuStripEx();
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.NewMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OpenMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveAsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AppendMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.RecentSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.noneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.ClearMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DisassembleMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CdlTextbox = new System.Windows.Forms.TextBox();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// checkBox1
// LoggingActiveCheckbox
//
this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(12, 244);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(101, 17);
this.checkBox1.TabIndex = 1;
this.checkBox1.Text = "Loging is Active";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
this.LoggingActiveCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.LoggingActiveCheckbox.AutoSize = true;
this.LoggingActiveCheckbox.Location = new System.Drawing.Point(12, 244);
this.LoggingActiveCheckbox.Name = "LoggingActiveCheckbox";
this.LoggingActiveCheckbox.Size = new System.Drawing.Size(101, 17);
this.LoggingActiveCheckbox.TabIndex = 1;
this.LoggingActiveCheckbox.Text = "Loging is Active";
this.LoggingActiveCheckbox.UseVisualStyleBackColor = true;
this.LoggingActiveCheckbox.CheckedChanged += new System.EventHandler(this.LoggingActiveCheckbox_CheckedChanged);
//
// menuStrip1
//
this.menuStrip1.ClickThrough = true;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem});
this.FileSubMenu,
this.OptionsSubMenu});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(292, 24);
this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
// FileSubMenu
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem,
this.clearToolStripMenuItem,
this.loadToolStripMenuItem,
this.saveToolStripMenuItem,
this.unionToolStripMenuItem,
this.disassembleToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "&File";
this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.NewMenuItem,
this.OpenMenuItem,
this.SaveMenuItem,
this.SaveAsMenuItem,
this.AppendMenuItem,
this.RecentSubMenu,
this.toolStripSeparator2,
this.ClearMenuItem,
this.DisassembleMenuItem,
this.toolStripSeparator1,
this.ExitMenuItem});
this.FileSubMenu.Name = "FileSubMenu";
this.FileSubMenu.Size = new System.Drawing.Size(37, 20);
this.FileSubMenu.Text = "&File";
//
// newToolStripMenuItem
// NewMenuItem
//
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.newToolStripMenuItem.Text = "&New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
this.NewMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.NewFile;
this.NewMenuItem.Name = "NewMenuItem";
this.NewMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
this.NewMenuItem.Size = new System.Drawing.Size(195, 22);
this.NewMenuItem.Text = "&New";
this.NewMenuItem.Click += new System.EventHandler(this.NewMenuItem_Click);
//
// clearToolStripMenuItem
// OpenMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.clearToolStripMenuItem.Text = "&Clear";
this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click);
this.OpenMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.OpenFile;
this.OpenMenuItem.Name = "OpenMenuItem";
this.OpenMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.OpenMenuItem.Size = new System.Drawing.Size(195, 22);
this.OpenMenuItem.Text = "&Open...";
this.OpenMenuItem.Click += new System.EventHandler(this.OpenMenuItem_Click);
//
// loadToolStripMenuItem
// SaveMenuItem
//
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
this.loadToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.loadToolStripMenuItem.Text = "&Load...";
this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click);
this.SaveMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.SaveAs;
this.SaveMenuItem.Name = "SaveMenuItem";
this.SaveMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.SaveMenuItem.Size = new System.Drawing.Size(195, 22);
this.SaveMenuItem.Text = "&Save";
this.SaveMenuItem.Click += new System.EventHandler(this.SaveMenuItem_Click);
//
// saveToolStripMenuItem
// SaveAsMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.saveToolStripMenuItem.Text = "&Save...";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
this.SaveAsMenuItem.Name = "SaveAsMenuItem";
this.SaveAsMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S)));
this.SaveAsMenuItem.Size = new System.Drawing.Size(195, 22);
this.SaveAsMenuItem.Text = "&Save As...";
this.SaveAsMenuItem.Click += new System.EventHandler(this.SaveAsMenuItem_Click);
//
// unionToolStripMenuItem
// AppendMenuItem
//
this.unionToolStripMenuItem.Name = "unionToolStripMenuItem";
this.unionToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.unionToolStripMenuItem.Text = "&Union...";
this.unionToolStripMenuItem.Click += new System.EventHandler(this.unionToolStripMenuItem_Click);
this.AppendMenuItem.Name = "AppendMenuItem";
this.AppendMenuItem.Size = new System.Drawing.Size(195, 22);
this.AppendMenuItem.Text = "&Append File...";
this.AppendMenuItem.Click += new System.EventHandler(this.AppendMenuItem_Click);
//
// disassembleToolStripMenuItem
// RecentSubMenu
//
this.disassembleToolStripMenuItem.Name = "disassembleToolStripMenuItem";
this.disassembleToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.disassembleToolStripMenuItem.Text = "&Disassemble...";
this.disassembleToolStripMenuItem.Click += new System.EventHandler(this.disassembleToolStripMenuItem_Click);
this.RecentSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.noneToolStripMenuItem});
this.RecentSubMenu.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Recent;
this.RecentSubMenu.Name = "RecentSubMenu";
this.RecentSubMenu.Size = new System.Drawing.Size(195, 22);
this.RecentSubMenu.Text = "Recent";
this.RecentSubMenu.DropDownOpened += new System.EventHandler(this.RecentSubMenu_DropDownOpened);
//
// textBox1
// noneToolStripMenuItem
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.noneToolStripMenuItem.Name = "noneToolStripMenuItem";
this.noneToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
this.noneToolStripMenuItem.Text = "None";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(192, 6);
//
// ClearMenuItem
//
this.ClearMenuItem.Name = "ClearMenuItem";
this.ClearMenuItem.Size = new System.Drawing.Size(195, 22);
this.ClearMenuItem.Text = "&Clear";
this.ClearMenuItem.Click += new System.EventHandler(this.ClearMenuItem_Click);
//
// DisassembleMenuItem
//
this.DisassembleMenuItem.Name = "DisassembleMenuItem";
this.DisassembleMenuItem.Size = new System.Drawing.Size(195, 22);
this.DisassembleMenuItem.Text = "&Disassemble...";
this.DisassembleMenuItem.Click += new System.EventHandler(this.DisassembleMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(192, 6);
//
// ExitMenuItem
//
this.ExitMenuItem.Name = "ExitMenuItem";
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.ExitMenuItem.Size = new System.Drawing.Size(195, 22);
this.ExitMenuItem.Text = "&Close";
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
//
// OptionsSubMenu
//
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu";
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
this.OptionsSubMenu.Text = "&Options";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
//
// SaveWindowPositionMenuItem
//
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22);
this.SaveWindowPositionMenuItem.Text = "Save Window Position";
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
//
// AlwaysOnTopMenuItem
//
this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem";
this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(191, 22);
this.AlwaysOnTopMenuItem.Text = "&Always On Top";
this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
//
// CdlTextbox
//
this.CdlTextbox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(0, 27);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(292, 211);
this.textBox1.TabIndex = 3;
this.CdlTextbox.Location = new System.Drawing.Point(0, 27);
this.CdlTextbox.Multiline = true;
this.CdlTextbox.Name = "CdlTextbox";
this.CdlTextbox.ReadOnly = true;
this.CdlTextbox.Size = new System.Drawing.Size(292, 211);
this.CdlTextbox.TabIndex = 3;
//
// FloatingWindowMenuItem
//
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22);
this.FloatingWindowMenuItem.Text = "&Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// PCECDL
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.CdlTextbox);
this.Controls.Add(this.LoggingActiveCheckbox);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Name = "PCECDL";
this.Text = "Code Data Logger";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PCECDL_FormClosing);
this.Load += new System.EventHandler(this.PCECDL_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
@ -153,16 +251,26 @@
#endregion
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem unionToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ToolStripMenuItem disassembleToolStripMenuItem;
private System.Windows.Forms.CheckBox LoggingActiveCheckbox;
private MenuStripEx menuStrip1;
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
private System.Windows.Forms.ToolStripMenuItem ClearMenuItem;
private System.Windows.Forms.ToolStripMenuItem OpenMenuItem;
private System.Windows.Forms.ToolStripMenuItem SaveAsMenuItem;
private System.Windows.Forms.ToolStripMenuItem AppendMenuItem;
private System.Windows.Forms.ToolStripMenuItem NewMenuItem;
private System.Windows.Forms.TextBox CdlTextbox;
private System.Windows.Forms.ToolStripMenuItem DisassembleMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
private System.Windows.Forms.ToolStripMenuItem SaveMenuItem;
private System.Windows.Forms.ToolStripMenuItem RecentSubMenu;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
}
}

View File

@ -1,28 +1,28 @@
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 BizHawk.Client.Common;
using BizHawk.Emulation.Cores.PCEngine;
using BizHawk.Emulation.Cores.Components.H6280;
using System.IO;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Components.H6280;
using BizHawk.Emulation.Cores.PCEngine;
namespace BizHawk.Client.EmuHawk
{
public partial class PCECDL : Form, IToolForm
{
PCEngine emu;
CodeDataLog CDL;
// TODO
// Loading doesn't work
// Save
// Save Window position and size
// Restore settings
private PCEngine _emu;
private CodeDataLog _cdl;
public PCECDL()
{
InitializeComponent();
TopMost = Global.Config.PceCdlSettings.TopMost;
Restart();
}
@ -35,30 +35,30 @@ namespace BizHawk.Client.EmuHawk
{
if (Global.Emulator is PCEngine)
{
emu = (PCEngine)Global.Emulator;
checkBox1.Checked = emu.Cpu.CDLLoggingActive;
CDL = emu.Cpu.CDL;
emu.InitCDLMappings();
_emu = (PCEngine)Global.Emulator;
LoggingActiveCheckbox.Checked = _emu.Cpu.CDLLoggingActive;
_cdl = _emu.Cpu.CDL;
_emu.InitCDLMappings();
UpdateDisplay();
}
else
{
emu = null;
_emu = null;
Close();
}
}
void UpdateDisplay()
private void UpdateDisplay()
{
List<string> Lines = new List<string>();
if (CDL == null)
var lines = new List<string>();
if (_cdl == null)
{
Lines.Add("No CDL loaded.");
lines.Add("No CDL loaded.");
}
else
{
Lines.Add("CDL contains the following domains:");
foreach (var kvp in CDL)
lines.Add("CDL contains the following domains:");
foreach (var kvp in _cdl)
{
int total = 0;
unsafe
@ -70,14 +70,18 @@ namespace BizHawk.Client.EmuHawk
while (src < end)
{
if (*src++ != 0)
{
total++;
}
}
}
}
Lines.Add(string.Format("Domain {0} Size {1} Mapped {2}%", kvp.Key, kvp.Value.Length, total / (float) kvp.Value.Length * 100f));
lines.Add(string.Format("Domain {0} Size {1} Mapped {2}%", kvp.Key, kvp.Value.Length, total / (float) kvp.Value.Length * 100f));
}
}
textBox1.Lines = Lines.ToArray();
CdlTextbox.Lines = lines.ToArray();
}
public bool AskSave()
@ -90,18 +94,47 @@ namespace BizHawk.Client.EmuHawk
get { return false; }
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
private void LoadFileFromRecent(string path)
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
var newCDL = CodeDataLog.Load(fs);
if (!newCDL.CheckConsistency(_emu.Cpu.Mappings))
{
MessageBox.Show(this, "CDL file does not match emulator's current memory map!");
}
else
{
_cdl = newCDL;
_emu.Cpu.CDL = _cdl;
UpdateDisplay();
}
}
}
#region Events
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
{
RecentSubMenu.DropDownItems.Clear();
RecentSubMenu.DropDownItems.AddRange(
ToolHelpers.GenerateRecentMenu(Global.Config.RecentPceCdlFiles, LoadFileFromRecent));
RecentSubMenu.DropDownItems.Add(
ToolHelpers.GenerateAutoLoadItem(Global.Config.RecentPceCdlFiles));
}
private void NewMenuItem_Click(object sender, EventArgs e)
{
var result = MessageBox.Show(this, "OK to create new CDL?", "Query", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
CDL = CodeDataLog.Create(emu.Cpu.Mappings);
emu.Cpu.CDL = CDL;
_cdl = CodeDataLog.Create(_emu.Cpu.Mappings);
_emu.Cpu.CDL = _cdl;
UpdateDisplay();
}
}
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
private void OpenMenuItem_Click(object sender, EventArgs e)
{
var result = MessageBox.Show(this, "OK to load new CDL?", "Query", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
@ -110,27 +143,33 @@ namespace BizHawk.Client.EmuHawk
result = ofd.ShowDialog(this);
if (result == DialogResult.OK)
{
using (FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
using (var fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
{
var newCDL = CodeDataLog.Load(fs);
if (!newCDL.CheckConsistency(emu.Cpu.Mappings))
if (!newCDL.CheckConsistency(_emu.Cpu.Mappings))
{
MessageBox.Show(this, "CDL file does not match emulator's current memory map!");
}
else
{
CDL = newCDL;
emu.Cpu.CDL = CDL;
_cdl = newCDL;
_emu.Cpu.CDL = _cdl;
UpdateDisplay();
Global.Config.RecentPceCdlFiles.Add(ofd.FileName);
}
}
}
}
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
private void SaveMenuItem_Click(object sender, EventArgs e)
{
if (CDL == null)
// TODO
}
private void SaveAsMenuItem_Click(object sender, EventArgs e)
{
if (_cdl == null)
{
MessageBox.Show(this, "Cannot save with no CDL loaded!", "Alert");
}
@ -140,17 +179,18 @@ namespace BizHawk.Client.EmuHawk
var result = sfd.ShowDialog(this);
if (result == DialogResult.OK)
{
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
using (var fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
{
CDL.Save(fs);
_cdl.Save(fs);
Global.Config.RecentPceCdlFiles.Add(sfd.FileName);
}
}
}
}
private void unionToolStripMenuItem_Click(object sender, EventArgs e)
private void AppendMenuItem_Click(object sender, EventArgs e)
{
if (CDL == null)
if (_cdl == null)
{
MessageBox.Show(this, "Cannot union with no CDL loaded!", "Alert");
}
@ -160,24 +200,19 @@ namespace BizHawk.Client.EmuHawk
var result = ofd.ShowDialog(this);
if (result == DialogResult.OK)
{
using (FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
using (var fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read))
{
var newCDL = CodeDataLog.Load(fs);
CDL.LogicalOrFrom(newCDL);
_cdl.LogicalOrFrom(newCDL);
UpdateDisplay();
}
}
}
}
private void PCECDL_FormClosing(object sender, FormClosingEventArgs e)
private void ClearMenuItem_Click(object sender, EventArgs e)
{
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
{
if (CDL == null)
if (_cdl == null)
{
MessageBox.Show(this, "Cannot clear with no CDL loaded!", "Alert");
}
@ -186,25 +221,15 @@ namespace BizHawk.Client.EmuHawk
var result = MessageBox.Show(this, "OK to clear CDL?", "Query", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
CDL.ClearData();
_cdl.ClearData();
UpdateDisplay();
}
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
private void DisassembleMenuItem_Click(object sender, EventArgs e)
{
if (checkBox1.Checked && CDL == null)
{
MessageBox.Show(this, "Cannot log with no CDL loaded!", "Alert");
checkBox1.Checked = false;
}
emu.Cpu.CDLLoggingActive = checkBox1.Checked;
}
private void disassembleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (CDL == null)
if (_cdl == null)
{
MessageBox.Show(this, "Cannot disassemble with no CDL loaded!", "Alert");
}
@ -214,12 +239,60 @@ namespace BizHawk.Client.EmuHawk
var result = sfd.ShowDialog(this);
if (result == DialogResult.OK)
{
using (FileStream fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
using (var fs = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
{
CDL.Disassemble(fs, Global.Emulator.MemoryDomains);
_cdl.Disassemble(fs, Global.Emulator.MemoryDomains);
}
}
}
}
private void ExitMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
SaveWindowPositionMenuItem.Checked = Global.Config.PceCdlSettings.SaveWindowPosition;
TopMost = AlwaysOnTopMenuItem.Checked = Global.Config.PceCdlSettings.TopMost;
FloatingWindowMenuItem.Checked = Global.Config.PceCdlSettings.FloatingWindow;
}
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Global.Config.PceCdlSettings.SaveWindowPosition ^= true;
}
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{
Global.Config.PceCdlSettings.TopMost ^= true;
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Global.Config.PceCdlSettings.FloatingWindow ^= true;
}
private void PCECDL_Load(object sender, EventArgs e)
{
if (Global.Config.RecentPceCdlFiles.AutoLoad)
{
LoadFileFromRecent(Global.Config.RecentPceCdlFiles.MostRecent);
}
}
private void LoggingActiveCheckbox_CheckedChanged(object sender, EventArgs e)
{
if (LoggingActiveCheckbox.Checked && _cdl == null)
{
MessageBox.Show(this, "Cannot log with no CDL loaded!", "Alert");
LoggingActiveCheckbox.Checked = false;
}
_emu.Cpu.CDLLoggingActive = LoggingActiveCheckbox.Checked;
}
#endregion
}
}