Ram WAtch and Hex Editor code cleanup

This commit is contained in:
adelikat 2013-11-28 22:06:38 +00:00
parent bbcc7f3b5f
commit d6954e4209
14 changed files with 1777 additions and 1764 deletions

View File

@ -28,13 +28,13 @@ namespace BizHawk.Client.Common
else
{
_enabled = cheat.Enabled;
_watch = Watch.GenerateWatch(cheat.Domain,
_watch = Watch.GenerateWatch(
cheat.Domain,
cheat.Address ?? 0,
cheat.Size,
cheat.Type,
cheat.Name,
cheat.BigEndian ?? false
);
cheat.BigEndian ?? false);
_compare = cheat.Compare;
_val = cheat.Value ?? 0;
@ -42,6 +42,8 @@ namespace BizHawk.Client.Common
}
}
public delegate void CheatEventHandler(object sender);
public static Cheat Separator
{
get { return new Cheat(SeparatorWatch.Instance, 0, null, false); }
@ -49,10 +51,24 @@ namespace BizHawk.Client.Common
#endregion
#region Properties
#region private parts
public delegate void CheatEventHandler(object sender);
public event CheatEventHandler Changed;
private readonly Watch _watch;
private int? _compare;
private int _val;
private bool _enabled;
private void Changes()
{
if (Changed != null)
{
Changed(this);
}
}
#endregion
#region Properties
public bool IsSeparator
{
@ -61,7 +77,7 @@ namespace BizHawk.Client.Common
public bool Enabled
{
get { if (IsSeparator) return false; else return _enabled; }
get { return !IsSeparator && _enabled; }
}
public int? Address
@ -76,12 +92,12 @@ namespace BizHawk.Client.Common
public bool? BigEndian
{
get { if (IsSeparator) return null; else return _watch.BigEndian; }
get { return IsSeparator ? (bool?)null : _watch.BigEndian; }
}
public int? Compare
{
get { if (_compare.HasValue && !IsSeparator) return _compare; else return null; }
get { return _compare.HasValue && !IsSeparator ? _compare : null; }
}
public MemoryDomain Domain
@ -111,7 +127,7 @@ namespace BizHawk.Client.Common
public string Name
{
get { if (IsSeparator) return String.Empty; else return _watch.Notes; }
get { return IsSeparator ? String.Empty : _watch.Notes; }
}
public string AddressStr
@ -164,6 +180,8 @@ namespace BizHawk.Client.Common
}
}
public event CheatEventHandler Changed;
#endregion
#region Actions
@ -172,7 +190,7 @@ namespace BizHawk.Client.Common
{
if (!IsSeparator)
{
bool wasEnabled = _enabled;
var wasEnabled = _enabled;
_enabled = true;
if (!wasEnabled)
{
@ -185,7 +203,7 @@ namespace BizHawk.Client.Common
{
if (!IsSeparator)
{
bool wasEnabled = _enabled;
var wasEnabled = _enabled;
_enabled = false;
if (wasEnabled)
{
@ -268,22 +286,5 @@ namespace BizHawk.Client.Common
}
#endregion
#region private parts
private readonly Watch _watch;
private int? _compare;
private int _val;
private bool _enabled;
private void Changes()
{
if (Changed != null)
{
Changed(this);
}
}
#endregion
}
}

View File

@ -50,7 +50,7 @@ namespace BizHawk.Client.EmuHawk
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexMenubarColor = colorDialog1.Color;
GlobalWin.Tools.HexEditor.menuStrip1.BackColor = Global.Config.HexMenubarColor;
GlobalWin.Tools.HexEditor.HexMenuStrip.BackColor = Global.Config.HexMenubarColor;
HexMenubar.BackColor = colorDialog1.Color;
}
}

View File

@ -32,7 +32,7 @@
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HexEditor));
this.menuStrip1 = new MenuStripEx();
this.HexMenuStrip = new MenuStripEx();
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.SaveMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveAsBinaryMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -88,24 +88,24 @@
this.HexScrollBar = new System.Windows.Forms.VScrollBar();
this.AddressesLabel = new System.Windows.Forms.Label();
this.Header = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.HexMenuStrip.SuspendLayout();
this.ViewerContextMenuStrip.SuspendLayout();
this.MemoryViewerBox.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.ClickThrough = true;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.HexMenuStrip.ClickThrough = true;
this.HexMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FileSubMenu,
this.EditMenuItem,
this.OptionsSubMenu,
this.SettingsSubMenu});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(584, 24);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
this.HexMenuStrip.Location = new System.Drawing.Point(0, 0);
this.HexMenuStrip.Name = "HexMenuStrip";
this.HexMenuStrip.Size = new System.Drawing.Size(584, 24);
this.HexMenuStrip.TabIndex = 1;
this.HexMenuStrip.Text = "menuStrip1";
//
// FileSubMenu
//
@ -594,9 +594,9 @@
this.ClientSize = new System.Drawing.Size(584, 301);
this.Controls.Add(this.Header);
this.Controls.Add(this.MemoryViewerBox);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.HexMenuStrip);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.MainMenuStrip = this.HexMenuStrip;
this.MinimumSize = new System.Drawing.Size(360, 180);
this.Name = "HexEditor";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
@ -607,8 +607,8 @@
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.HexEditor_KeyUp);
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.HexEditor_MouseWheel);
this.Resize += new System.EventHandler(this.HexEditor_Resize);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.HexMenuStrip.ResumeLayout(false);
this.HexMenuStrip.PerformLayout();
this.ViewerContextMenuStrip.ResumeLayout(false);
this.MemoryViewerBox.ResumeLayout(false);
this.MemoryViewerBox.PerformLayout();
@ -619,7 +619,7 @@
#endregion
public MenuStripEx menuStrip1;
public MenuStripEx HexMenuStrip;
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
private System.Windows.Forms.ToolStripMenuItem SaveAsTextMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;

File diff suppressed because it is too large Load Diff

View File

@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="HexMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ViewerContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
@ -24,7 +23,6 @@ namespace BizHawk.Client.EmuHawk
public void SetLocation(Point p)
{
_location = p;
}
private void HexFind_Load(object sender, EventArgs e)

View File

@ -9,7 +9,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
class ToolHelpers
public static class ToolHelpers
{
public static FileInfo GetWatchFileFromUser(string currentFile)
{
@ -18,6 +18,7 @@ namespace BizHawk.Client.EmuHawk
{
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
}
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
ofd.RestoreDirectory = true;
@ -26,9 +27,11 @@ namespace BizHawk.Client.EmuHawk
var result = ofd.ShowDialog();
GlobalWin.Sound.StartSound();
if (result != DialogResult.OK)
{
return null;
var file = new FileInfo(ofd.FileName);
return file;
}
return new FileInfo(ofd.FileName);
}
public static FileInfo GetWatchSaveFileFromUser(string currentFile)
@ -49,15 +52,18 @@ namespace BizHawk.Client.EmuHawk
sfd.FileName = "NULL";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPath, null);
}
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
sfd.RestoreDirectory = true;
GlobalWin.Sound.StopSound();
var result = sfd.ShowDialog();
GlobalWin.Sound.StartSound();
if (result != DialogResult.OK)
{
return null;
var file = new FileInfo(sfd.FileName);
return file;
}
return new FileInfo(sfd.FileName);
}
public static FileInfo GetCheatFileFromUser(string currentFile)
@ -67,6 +73,7 @@ namespace BizHawk.Client.EmuHawk
{
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
}
ofd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
ofd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
ofd.RestoreDirectory = true;
@ -75,9 +82,11 @@ namespace BizHawk.Client.EmuHawk
var result = ofd.ShowDialog();
GlobalWin.Sound.StartSound();
if (result != DialogResult.OK)
{
return null;
var file = new FileInfo(ofd.FileName);
return file;
}
return new FileInfo(ofd.FileName);
}
public static FileInfo GetCheatSaveFileFromUser(string currentFile)
@ -91,6 +100,7 @@ namespace BizHawk.Client.EmuHawk
{
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
}
sfd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
sfd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
sfd.RestoreDirectory = true;
@ -155,7 +165,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.Sound.StartSound();
}
public static IEnumerable<ToolStripMenuItem> GenerateMemoryDomainMenuItems(Action<string> setCallback, string selectedDomain = "", int? maxSize = null)
public static IEnumerable<ToolStripItem> GenerateMemoryDomainMenuItems(Action<string> setCallback, string selectedDomain = "", int? maxSize = null)
{
var items = new List<ToolStripMenuItem>();
@ -206,9 +216,7 @@ namespace BizHawk.Client.EmuHawk
{
foreach (var watch in watches.Where(watch => !watch.IsSeparator))
{
Global.CheatList.Add(
new Cheat(watch, watch.Value ?? 0)
);
Global.CheatList.Add(new Cheat(watch, watch.Value ?? 0));
}
}
@ -235,7 +243,7 @@ namespace BizHawk.Client.EmuHawk
var column = new ColumnHeader
{
Name = columnName,
Text = columnName.Replace("Column", ""),
Text = columnName.Replace("Column", String.Empty),
Width = columnWidth,
};

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using BizHawk.Client.Common;
@ -24,12 +24,67 @@ namespace BizHawk.Client.EmuHawk
{ WatchList.NOTES, 128 },
};
private readonly WatchList _watches = new WatchList(Global.Emulator.MemoryDomains.MainMemory);
private int _defaultWidth;
private int _defaultHeight;
private string _sortedColumn = String.Empty;
private bool _sortReverse;
private readonly WatchList _watches = new WatchList(Global.Emulator.MemoryDomains.MainMemory);
public RamWatch()
{
InitializeComponent();
WatchListView.QueryItemText += WatchListView_QueryItemText;
WatchListView.QueryItemBkColor += WatchListView_QueryItemBkColor;
WatchListView.VirtualMode = true;
Closing += (o, e) =>
{
if (AskSave())
{
SaveConfigSettings();
}
else
{
e.Cancel = true;
}
};
_sortedColumn = String.Empty;
_sortReverse = false;
TopMost = Global.Config.RamWatchAlwaysOnTop;
}
private IEnumerable<int> SelectedIndices
{
get { return WatchListView.SelectedIndices.Cast<int>(); }
}
private IEnumerable<Watch> SelectedItems
{
get { return SelectedIndices.Select(index => _watches[index]); }
}
private IEnumerable<Watch> SelectedWatches
{
get { return SelectedItems.Where(x => !x.IsSeparator); }
}
#region Properties
public IEnumerable<int> AddressList
{
get
{
return _watches.Where(x => !x.IsSeparator).Select(x => x.Address ?? 0);
}
}
public bool UpdateBefore
{
get { return true; }
}
#endregion
#region API
@ -44,7 +99,7 @@ namespace BizHawk.Client.EmuHawk
public bool AskSave()
{
if (Global.Config.SupressAskSave) //User has elected to not be nagged
if (Global.Config.SupressAskSave) // User has elected to not be nagged
{
return true;
}
@ -72,14 +127,6 @@ namespace BizHawk.Client.EmuHawk
return true;
}
public IEnumerable<int> AddressList
{
get
{
return _watches.Where(x => !x.IsSeparator).Select(x => x.Address ?? 0).ToList();
}
}
public void LoadFileFromRecent(string path)
{
var ask_result = true;
@ -128,29 +175,6 @@ namespace BizHawk.Client.EmuHawk
}
}
public RamWatch()
{
InitializeComponent();
WatchListView.QueryItemText += WatchListView_QueryItemText;
WatchListView.QueryItemBkColor += WatchListView_QueryItemBkColor;
WatchListView.VirtualMode = true;
Closing += (o, e) =>
{
if (AskSave())
{
SaveConfigSettings();
}
else
{
e.Cancel = true;
}
};
_sortedColumn = String.Empty;
_sortReverse = false;
TopMost = Global.Config.RamWatchAlwaysOnTop;
}
public void Restart()
{
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
@ -168,8 +192,6 @@ namespace BizHawk.Client.EmuHawk
}
}
public bool UpdateBefore { get { return true; } }
public void UpdateValues()
{
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
@ -185,11 +207,11 @@ namespace BizHawk.Client.EmuHawk
{
for (var x = 0; x < _watches.Count; x++)
{
var alert = !_watches[x].IsSeparator && Global.CheatList.IsActive(_watches[x].Domain, (_watches[x].Address ?? 0));
var alert = !_watches[x].IsSeparator && Global.CheatList.IsActive(_watches[x].Domain, _watches[x].Address ?? 0);
GlobalWin.OSD.AddGUIText(
_watches[x].ToString(),
Global.Config.DispRamWatchx,
(Global.Config.DispRamWatchy + (x * 14)),
Global.Config.DispRamWatchy + (x * 14),
alert,
Color.Black,
Color.White,
@ -198,8 +220,10 @@ namespace BizHawk.Client.EmuHawk
}
}
if (!IsHandleCreated || IsDisposed) return;
if (!IsHandleCreated || IsDisposed)
{
return;
}
WatchListView.BlazingFast = true;
WatchListView.Refresh();
@ -211,27 +235,6 @@ namespace BizHawk.Client.EmuHawk
#region Private Methods
private void AddNewWatch()
{
var we = new WatchEditor
{
InitialLocation = GetPromptPoint()
};
we.SetWatch(_watches.Domain);
GlobalWin.Sound.StopSound();
we.ShowDialog();
GlobalWin.Sound.StartSound();
if (we.DialogResult == DialogResult.OK)
{
_watches.Add(we.Watches[0]);
Changes();
UpdateWatchCount();
WatchListView.ItemCount = _watches.ItemCount;
UpdateValues();
}
}
private void Changes()
{
_watches.Changes = true;
@ -240,15 +243,16 @@ namespace BizHawk.Client.EmuHawk
private void ColumnPositions()
{
var Columns = Global.Config.RamWatchColumnIndexes
var columns = Global.Config.RamWatchColumnIndexes
.Where(x => WatchListView.Columns.ContainsKey(x.Key))
.OrderBy(x => x.Value).ToList();
.OrderBy(x => x.Value)
.ToList();
for (var i = 0; i < Columns.Count; i++)
for (var i = 0; i < columns.Count; i++)
{
if (WatchListView.Columns.ContainsKey(Columns[i].Key))
if (WatchListView.Columns.ContainsKey(columns[i].Key))
{
WatchListView.Columns[Columns[i].Key].DisplayIndex = i;
WatchListView.Columns[columns[i].Key].DisplayIndex = i;
}
}
}
@ -266,6 +270,7 @@ namespace BizHawk.Client.EmuHawk
{
sb.Append(GetColumnValue(column.Name, index)).Append('\t');
}
sb.Remove(sb.Length - 1, 1);
sb.AppendLine();
}
@ -288,9 +293,7 @@ namespace BizHawk.Client.EmuHawk
InitialLocation = GetPromptPoint(),
};
we.SetWatch(_watches.Domain,
SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit
);
we.SetWatch(_watches.Domain, SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit);
GlobalWin.Sound.StopSound();
var result = we.ShowDialog();
@ -355,22 +358,6 @@ namespace BizHawk.Client.EmuHawk
return PointToScreen(new Point(WatchListView.Location.X, WatchListView.Location.Y));
}
private void InsertSeparator()
{
var indexes = SelectedIndices.ToList();
if (indexes.Any())
{
_watches.Insert(indexes[0], SeparatorWatch.Instance);
}
else
{
_watches.Add(SeparatorWatch.Instance);
}
WatchListView.ItemCount = _watches.ItemCount;
Changes();
UpdateWatchCount();
}
private void LoadColumnInfo()
{
WatchListView.Columns.Clear();
@ -387,8 +374,8 @@ namespace BizHawk.Client.EmuHawk
private void LoadConfigSettings()
{
//Size and Positioning
_defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
// Size and Positioning
_defaultWidth = Size.Width; // Save these first so that the user can restore to its original size
_defaultHeight = Size.Height;
if (Global.Config.RamWatchSaveWindowPosition && Global.Config.RamWatchWndx >= 0 && Global.Config.RamWatchWndy >= 0)
@ -404,61 +391,6 @@ namespace BizHawk.Client.EmuHawk
LoadColumnInfo();
}
private void MoveDown()
{
var indices = SelectedIndices.ToList();
if (indices.Count == 0 || indices.Last() == _watches.Count - 1)
{
return;
}
for (var i = indices.Count - 1; i >= 0; i--)
{
var watch = _watches[indices[i]];
_watches.Remove(watch);
_watches.Insert(indices[i] + 1, watch);
}
var newindices = indices.Select(t => t + 1).ToList();
WatchListView.SelectedIndices.Clear();
foreach (var t in newindices)
{
WatchListView.SelectItem(t, true);
}
Changes();
WatchListView.ItemCount = _watches.ItemCount;
}
private void MoveUp()
{
var indexes = SelectedIndices.ToList();
if (!indexes.Any() || indexes[0] == 0)
{
return;
}
foreach (var index in indexes)
{
var watch = _watches[index];
_watches.Remove(watch);
_watches.Insert(index - 1, watch);
}
Changes();
var indices = indexes.Select(t => t - 1).ToList();
WatchListView.SelectedIndices.Clear();
foreach (var t in indices)
{
WatchListView.SelectItem(t, true);
}
WatchListView.ItemCount = _watches.ItemCount;
}
private void NewWatchList(bool suppressAsk)
{
var result = true;
@ -493,46 +425,6 @@ namespace BizHawk.Client.EmuHawk
WatchListView.Refresh();
}
private void PokeAddress()
{
if (SelectedWatches.Any())
{
var poke = new RamPoke
{
InitialLocation = GetPromptPoint()
};
if (SelectedWatches.Any())
{
poke.SetWatch(SelectedWatches);
}
GlobalWin.Sound.StopSound();
var result = poke.ShowDialog();
if (result == DialogResult.OK)
{
UpdateValues();
}
GlobalWin.Sound.StartSound();
}
}
private void RemoveWatch()
{
var items = SelectedItems.ToList();
if (items.Any())
{
foreach (var item in items)
{
_watches.Remove(item);
}
WatchListView.ItemCount = _watches.ItemCount;
UpdateValues();
UpdateWatchCount();
}
}
private void SaveAs()
{
var result = _watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(_watches.CurrentFileName));
@ -597,29 +489,6 @@ namespace BizHawk.Client.EmuHawk
Global.Config.RamWatchHeight = Bottom - Top;
}
private void SelectAll()
{
for (var i = 0; i < _watches.Count; i++)
{
WatchListView.SelectItem(i, true);
}
}
private IEnumerable<int> SelectedIndices
{
get { return WatchListView.SelectedIndices.Cast<int>(); }
}
private IEnumerable<Watch> SelectedItems
{
get { return SelectedIndices.Select(index => _watches[index]); }
}
private IEnumerable<Watch> SelectedWatches
{
get { return SelectedItems.Where(x => !x.IsSeparator); }
}
private void SetMemoryDomain(string name)
{
_watches.Domain = Global.Emulator.MemoryDomains[name];
@ -683,6 +552,7 @@ namespace BizHawk.Client.EmuHawk
{
return;
}
var columnName = WatchListView.Columns[column].Name;
switch (columnName)
@ -701,6 +571,7 @@ namespace BizHawk.Client.EmuHawk
{
text = _watches[index].ChangeCount.ToString();
}
break;
case WatchList.DIFF:
text = _watches[index].Diff;
@ -718,54 +589,25 @@ namespace BizHawk.Client.EmuHawk
#region Winform Events
private void NewRamWatch_Load(object sender, EventArgs e)
#region File Menu
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
{
LoadConfigSettings();
SaveMenuItem.Enabled = _watches.Changes;
}
private void NewRamWatch_Activated(object sender, EventArgs e)
{
WatchListView.Refresh();
}
private void NewRamWatch_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
}
private void NewRamWatch_DragDrop(object sender, DragEventArgs e)
{
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
if (Path.GetExtension(filePaths[0]) == (".wch"))
{
_watches.Load(filePaths[0], append:false);
WatchListView.ItemCount = _watches.ItemCount;
}
}
private void NewRamWatch_Enter(object sender, EventArgs e)
{
WatchListView.Focus();
}
/*************File***********************/
private void filesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
saveToolStripMenuItem.Enabled = _watches.Changes;
}
private void newListToolStripMenuItem_Click(object sender, EventArgs e)
private void NewListMenuItem_Click(object sender, EventArgs e)
{
NewWatchList(false);
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
private void OpenMenuItem_Click(object sender, EventArgs e)
{
var append = sender == appendFileToolStripMenuItem;
var append = sender == AppendMenuItem;
LoadWatchFile(ToolHelpers.GetWatchFileFromUser(_watches.CurrentFileName), append);
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
private void SaveMenuItem_Click(object sender, EventArgs e)
{
if (!String.IsNullOrWhiteSpace(_watches.CurrentFileName))
{
@ -780,79 +622,121 @@ namespace BizHawk.Client.EmuHawk
}
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
private void SaveAsMenuItem_Click(object sender, EventArgs e)
{
SaveAs();
}
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
{
recentToolStripMenuItem.DropDownItems.Clear();
recentToolStripMenuItem.DropDownItems.AddRange(
RecentSubMenu.DropDownItems.Clear();
RecentSubMenu.DropDownItems.AddRange(
ToolHelpers.GenerateRecentMenu(Global.Config.RecentWatches, LoadFileFromRecent)
);
recentToolStripMenuItem.DropDownItems.Add(
RecentSubMenu.DropDownItems.Add(
ToolHelpers.GenerateAutoLoadItem(Global.Config.RecentWatches)
);
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
private void ExitMenuItem_Click(object sender, EventArgs e)
{
if (!AskSave())
{
return;
}
else
{
Close();
}
Close();
}
/*************Watches***********************/
private void watchesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
#endregion
#region Watch
private void WatchesSubMenu_DropDownOpened(object sender, EventArgs e)
{
editWatchToolStripMenuItem.Enabled =
duplicateWatchToolStripMenuItem.Enabled =
removeWatchToolStripMenuItem.Enabled =
moveUpToolStripMenuItem.Enabled =
moveDownToolStripMenuItem.Enabled =
pokeAddressToolStripMenuItem.Enabled =
freezeAddressToolStripMenuItem.Enabled =
EditWatchMenuItem.Enabled =
DuplicateWatchMenuItem.Enabled =
RemoveWatchMenuItem.Enabled =
MoveUpMenuItem.Enabled =
MoveDownMenuItem.Enabled =
PokeAddressMenuItem.Enabled =
FreezeAddressMenuItem.Enabled =
SelectedIndices.Any();
}
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
private void MemoryDomainsSubMenu_DropDownOpened(object sender, EventArgs e)
{
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
memoryDomainsToolStripMenuItem.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, _watches.Domain.Name).ToArray());
MemoryDomainsSubMenu.DropDownItems.Clear();
MemoryDomainsSubMenu.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, _watches.Domain.Name).ToArray());
}
private void newWatchToolStripMenuItem_Click(object sender, EventArgs e)
private void NewWatchMenuItem_Click(object sender, EventArgs e)
{
AddNewWatch();
var we = new WatchEditor
{
InitialLocation = GetPromptPoint()
};
we.SetWatch(_watches.Domain);
GlobalWin.Sound.StopSound();
we.ShowDialog();
GlobalWin.Sound.StartSound();
if (we.DialogResult == DialogResult.OK)
{
_watches.Add(we.Watches[0]);
Changes();
UpdateWatchCount();
WatchListView.ItemCount = _watches.ItemCount;
UpdateValues();
}
}
private void editWatchToolStripMenuItem_Click(object sender, EventArgs e)
private void EditWatchMenuItem_Click(object sender, EventArgs e)
{
EditWatch();
}
private void removeWatchToolStripMenuItem_Click(object sender, EventArgs e)
private void RemoveWatchMenuItem_Click(object sender, EventArgs e)
{
RemoveWatch();
var items = SelectedItems.ToList();
if (items.Any())
{
foreach (var item in items)
{
_watches.Remove(item);
}
WatchListView.ItemCount = _watches.ItemCount;
UpdateValues();
UpdateWatchCount();
}
}
private void duplicateWatchToolStripMenuItem_Click(object sender, EventArgs e)
private void DuplicateWatchMenuItem_Click(object sender, EventArgs e)
{
EditWatch(duplicate: true);
}
private void pokeAddressToolStripMenuItem_Click(object sender, EventArgs e)
private void PokeAddressMenuItem_Click(object sender, EventArgs e)
{
PokeAddress();
if (SelectedWatches.Any())
{
var poke = new RamPoke
{
InitialLocation = GetPromptPoint()
};
if (SelectedWatches.Any())
{
poke.SetWatch(SelectedWatches);
}
GlobalWin.Sound.StopSound();
if (poke.ShowDialog() == DialogResult.OK)
{
UpdateValues();
}
GlobalWin.Sound.StartSound();
}
}
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
private void FreezeAddressMenuItem_Click(object sender, EventArgs e)
{
var allCheats = SelectedWatches.All(watch => !Global.CheatList.IsActive(watch.Domain, watch.Address ?? 0));
if (allCheats)
@ -865,116 +749,125 @@ namespace BizHawk.Client.EmuHawk
}
}
private void insertSeparatorToolStripMenuItem_Click(object sender, EventArgs e)
private void InsertSeparatorMenuItem_Click(object sender, EventArgs e)
{
InsertSeparator();
var indexes = SelectedIndices.ToList();
if (indexes.Any())
{
_watches.Insert(indexes[0], SeparatorWatch.Instance);
}
else
{
_watches.Add(SeparatorWatch.Instance);
}
WatchListView.ItemCount = _watches.ItemCount;
Changes();
UpdateWatchCount();
}
private void clearChangeCountsToolStripMenuItem_Click(object sender, EventArgs e)
private void ClearChangeCountsMenuItem_Click(object sender, EventArgs e)
{
_watches.ClearChangeCounts();
}
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
private void MoveUpMenuItem_Click(object sender, EventArgs e)
{
MoveUp();
}
private void moveDownToolStripMenuItem_Click(object sender, EventArgs e)
{
MoveDown();
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
SelectAll();
}
/*************Columns***********************/
private void ColumnsSubMenu_DropDownOpened(object sender, EventArgs e)
{
ShowPreviousMenuItem.Checked = Global.Config.RamWatchShowPrevColumn;
ShowChangesMenuItem.Checked = Global.Config.RamWatchShowChangeColumn;
ShowDiffMenuItem.Checked = Global.Config.RamWatchShowDiffColumn;
ShowDomainMenuItem.Checked = Global.Config.RamWatchShowDomainColumn;
}
private void showPreviousValueToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowPrevColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
private void showChangeCountsToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowChangeColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
private void diffToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowDiffColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
private void domainToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowDomainColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
/*************Options***********************/
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
displayWatchesOnScreenToolStripMenuItem.Checked = Global.Config.DisplayRamWatch;
saveWindowPositionToolStripMenuItem.Checked = Global.Config.RamWatchSaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Global.Config.RamWatchAlwaysOnTop;
}
private void definePreviousValueAsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
lastChangeToolStripMenuItem.Checked = false;
previousFrameToolStripMenuItem.Checked = false;
originalToolStripMenuItem.Checked = false;
switch (Global.Config.RamWatchDefinePrevious)
var indexes = SelectedIndices.ToList();
if (!indexes.Any() || indexes[0] == 0)
{
default:
case Watch.PreviousType.LastFrame:
previousFrameToolStripMenuItem.Checked = true;
break;
case Watch.PreviousType.LastChange:
lastChangeToolStripMenuItem.Checked = true;
break;
case Watch.PreviousType.Original:
originalToolStripMenuItem.Checked = true;
break;
return;
}
foreach (var index in indexes)
{
var watch = _watches[index];
_watches.Remove(watch);
_watches.Insert(index - 1, watch);
}
Changes();
var indices = indexes.Select(t => t - 1).ToList();
WatchListView.SelectedIndices.Clear();
foreach (var t in indices)
{
WatchListView.SelectItem(t, true);
}
WatchListView.ItemCount = _watches.ItemCount;
}
private void MoveDownMenuItem_Click(object sender, EventArgs e)
{
var indices = SelectedIndices.ToList();
if (indices.Count == 0 || indices.Last() == _watches.Count - 1)
{
return;
}
for (var i = indices.Count - 1; i >= 0; i--)
{
var watch = _watches[indices[i]];
_watches.Remove(watch);
_watches.Insert(indices[i] + 1, watch);
}
var newindices = indices.Select(t => t + 1).ToList();
WatchListView.SelectedIndices.Clear();
foreach (var t in newindices)
{
WatchListView.SelectItem(t, true);
}
Changes();
WatchListView.ItemCount = _watches.ItemCount;
}
private void SelectAllMenuItem_Click(object sender, EventArgs e)
{
for (var i = 0; i < _watches.Count; i++)
{
WatchListView.SelectItem(i, true);
}
}
private void previousFrameToolStripMenuItem_Click(object sender, EventArgs e)
#endregion
#region Options
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
WatchesOnScreenMenuItem.Checked = Global.Config.DisplayRamWatch;
SaveWindowPositionMenuItem.Checked = Global.Config.RamWatchSaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Global.Config.RamWatchAlwaysOnTop;
}
private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e)
{
PreviousFrameMenuItem.Checked = Global.Config.RamWatchDefinePrevious == Watch.PreviousType.LastFrame;
LastChangeMenuItem.Checked = Global.Config.RamWatchDefinePrevious == Watch.PreviousType.LastChange;
OriginalMenuItem.Checked = Global.Config.RamWatchDefinePrevious == Watch.PreviousType.Original;
}
private void PreviousFrameMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchDefinePrevious = Watch.PreviousType.LastFrame;
}
private void lastChangeToolStripMenuItem_Click(object sender, EventArgs e)
private void LastChangeMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchDefinePrevious = Watch.PreviousType.LastChange;
}
private void originalToolStripMenuItem_Click(object sender, EventArgs e)
private void OriginalMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchDefinePrevious = Watch.PreviousType.Original;
}
private void displayWatchesOnScreenToolStripMenuItem_Click(object sender, EventArgs e)
private void WatchesOnScreenMenuItem_Click(object sender, EventArgs e)
{
Global.Config.DisplayRamWatch ^= true;
@ -988,7 +881,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchSaveWindowPosition ^= true;
}
@ -999,7 +892,7 @@ namespace BizHawk.Client.EmuHawk
TopMost = Global.Config.RamWatchAlwaysOnTop;
}
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
private void RestoreWindowSizeMenuItem_Click(object sender, EventArgs e)
{
Size = new Size(_defaultWidth, _defaultHeight);
@ -1023,9 +916,9 @@ namespace BizHawk.Client.EmuHawk
WatchListView.Columns[WatchList.ADDRESS].Width = _defaultColumnWidths[WatchList.ADDRESS];
WatchListView.Columns[WatchList.VALUE].Width = _defaultColumnWidths[WatchList.VALUE];
//WatchListView.Columns[WatchList.PREV].Width = DefaultColumnWidths[WatchList.PREV];
// WatchListView.Columns[WatchList.PREV].Width = DefaultColumnWidths[WatchList.PREV];
WatchListView.Columns[WatchList.CHANGES].Width = _defaultColumnWidths[WatchList.CHANGES];
//WatchListView.Columns[WatchList.DIFF].Width = DefaultColumnWidths[WatchList.DIFF];
// WatchListView.Columns[WatchList.DIFF].Width = DefaultColumnWidths[WatchList.DIFF];
WatchListView.Columns[WatchList.DOMAIN].Width = _defaultColumnWidths[WatchList.DOMAIN];
WatchListView.Columns[WatchList.NOTES].Width = _defaultColumnWidths[WatchList.NOTES];
@ -1036,8 +929,84 @@ namespace BizHawk.Client.EmuHawk
LoadColumnInfo();
}
/*************Context Menu***********************/
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
#endregion
#region Columns
private void ColumnsSubMenu_DropDownOpened(object sender, EventArgs e)
{
ShowPreviousMenuItem.Checked = Global.Config.RamWatchShowPrevColumn;
ShowChangesMenuItem.Checked = Global.Config.RamWatchShowChangeColumn;
ShowDiffMenuItem.Checked = Global.Config.RamWatchShowDiffColumn;
ShowDomainMenuItem.Checked = Global.Config.RamWatchShowDomainColumn;
}
private void ShowPreviousMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowPrevColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
private void ShowChangesMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowChangeColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
private void ShowDiffMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowDiffColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
private void ShowDomainMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowDomainColumn ^= true;
SaveColumnInfo();
LoadColumnInfo();
}
#endregion
#region Dialog, Context Menu, and ListView Events
private void NewRamWatch_Load(object sender, EventArgs e)
{
LoadConfigSettings();
}
private void NewRamWatch_Activated(object sender, EventArgs e)
{
WatchListView.Refresh();
}
private void NewRamWatch_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
}
private void NewRamWatch_DragDrop(object sender, DragEventArgs e)
{
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
if (Path.GetExtension(filePaths[0]) == ".wch")
{
_watches.Load(filePaths[0], append: false);
WatchListView.ItemCount = _watches.ItemCount;
}
}
private void NewRamWatch_Enter(object sender, EventArgs e)
{
WatchListView.Focus();
}
private void ListViewContextMenu_Opening(object sender, CancelEventArgs e)
{
var indexes = WatchListView.SelectedIndices;
@ -1054,7 +1023,6 @@ namespace BizHawk.Client.EmuHawk
toolStripSeparator4.Visible =
indexes.Count > 0;
var allCheats = _watches.All(x => Global.CheatList.IsActive(x.Domain, x.Address ?? 0));
if (allCheats)
@ -1101,26 +1069,24 @@ namespace BizHawk.Client.EmuHawk
}
}
/*************ListView Events***********************/
private void WatchListView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && !e.Control && !e.Alt && !e.Shift)
{
RemoveWatch();
RemoveWatchMenuItem_Click(sender, e);
}
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) // Select All
{
for (var x = 0; x < _watches.Count; x++)
{
WatchListView.SelectItem(x, true);
}
}
else if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) //Copy
else if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) // Copy
{
CopyWatchesToClipBoard();
}
else if (e.KeyCode == Keys.Enter && !e.Control && !e.Alt && !e.Shift) //Enter
else if (e.KeyCode == Keys.Enter && !e.Control && !e.Alt && !e.Shift) // Enter
{
EditWatch();
}
@ -1148,5 +1114,7 @@ namespace BizHawk.Client.EmuHawk
}
#endregion
#endregion
}
}

View File

@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="ListViewContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>336, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

View File

@ -8,53 +8,53 @@ namespace BizHawk.Common
/// </summary>
public unsafe class CBuffer<T> : IDisposable
{
public GCHandle hnd;
public T[] arr;
public void* ptr;
public byte* byteptr;
public int len;
public int itemsize;
public GCHandle Hnd;
public T[] Arr;
public void* Ptr;
public byte* Byteptr;
public int Len;
public int Itemsize;
public static CBuffer<T> malloc(int amt, int itemsize)
{
return new CBuffer<T>(amt, itemsize);
}
public void Write08(uint addr, byte val) { byteptr[addr] = val; }
public void Write16(uint addr, ushort val) { *(ushort*)(byteptr + addr) = val; }
public void Write32(uint addr, uint val) { *(uint*)(byteptr + addr) = val; }
public void Write64(uint addr, ulong val) { *(ulong*)(byteptr + addr) = val; }
public byte Read08(uint addr) { return byteptr[addr]; }
public ushort Read16(uint addr) { return *(ushort*)(byteptr + addr); }
public uint Read32(uint addr) { return *(uint*)(byteptr + addr); }
public ulong Read64(uint addr) { return *(ulong*)(byteptr + addr); }
public void Write08(int addr, byte val) { byteptr[addr] = val; }
public void Write16(int addr, ushort val) { *(ushort*)(byteptr + addr) = val; }
public void Write32(int addr, uint val) { *(uint*)(byteptr + addr) = val; }
public void Write64(int addr, ulong val) { *(ulong*)(byteptr + addr) = val; }
public byte Read08(int addr) { return byteptr[addr]; }
public ushort Read16(int addr) { return *(ushort*)(byteptr + addr); }
public uint Read32(int addr) { return *(uint*)(byteptr + addr); }
public ulong Read64(int addr) { return *(ulong*)(byteptr + addr); }
public void Write08(uint addr, byte val) { this.Byteptr[addr] = val; }
public void Write16(uint addr, ushort val) { *(ushort*)(this.Byteptr + addr) = val; }
public void Write32(uint addr, uint val) { *(uint*)(this.Byteptr + addr) = val; }
public void Write64(uint addr, ulong val) { *(ulong*)(this.Byteptr + addr) = val; }
public byte Read08(uint addr) { return this.Byteptr[addr]; }
public ushort Read16(uint addr) { return *(ushort*)(this.Byteptr + addr); }
public uint Read32(uint addr) { return *(uint*)(this.Byteptr + addr); }
public ulong Read64(uint addr) { return *(ulong*)(this.Byteptr + addr); }
public void Write08(int addr, byte val) { this.Byteptr[addr] = val; }
public void Write16(int addr, ushort val) { *(ushort*)(this.Byteptr + addr) = val; }
public void Write32(int addr, uint val) { *(uint*)(this.Byteptr + addr) = val; }
public void Write64(int addr, ulong val) { *(ulong*)(this.Byteptr + addr) = val; }
public byte Read08(int addr) { return this.Byteptr[addr]; }
public ushort Read16(int addr) { return *(ushort*)(this.Byteptr + addr); }
public uint Read32(int addr) { return *(uint*)(this.Byteptr + addr); }
public ulong Read64(int addr) { return *(ulong*)(this.Byteptr + addr); }
public CBuffer(T[] arr, int itemsize)
{
this.itemsize = itemsize;
len = arr.Length;
this.arr = arr;
hnd = GCHandle.Alloc(arr, GCHandleType.Pinned);
ptr = hnd.AddrOfPinnedObject().ToPointer();
byteptr = (byte*)ptr;
this.Itemsize = itemsize;
this.Len = arr.Length;
this.Arr = arr;
this.Hnd = GCHandle.Alloc(arr, GCHandleType.Pinned);
this.Ptr = this.Hnd.AddrOfPinnedObject().ToPointer();
this.Byteptr = (byte*)this.Ptr;
}
public CBuffer(int amt, int itemsize)
{
this.itemsize = itemsize;
len = amt;
arr = new T[amt];
hnd = GCHandle.Alloc(arr, GCHandleType.Pinned);
ptr = hnd.AddrOfPinnedObject().ToPointer();
byteptr = (byte*)ptr;
Util.memset(byteptr, 0, len * itemsize);
this.Itemsize = itemsize;
this.Len = amt;
this.Arr = new T[amt];
this.Hnd = GCHandle.Alloc(this.Arr, GCHandleType.Pinned);
this.Ptr = this.Hnd.AddrOfPinnedObject().ToPointer();
this.Byteptr = (byte*)this.Ptr;
Util.memset(this.Byteptr, 0, this.Len * itemsize);
}
public void Dispose()
@ -67,11 +67,11 @@ namespace BizHawk.Common
{
if (disposing)
{
if (arr != null)
if (this.Arr != null)
{
hnd.Free();
this.Hnd.Free();
}
arr = null;
this.Arr = null;
}
}
@ -85,8 +85,8 @@ namespace BizHawk.Common
public byte this[int index]
{
#if DEBUG
get { return arr[index]; }
set { arr[index] = value; }
get { return this.Arr[index]; }
set { this.Arr[index] = value; }
#else
set { Write08(index, value); }
get { return Read08(index);}
@ -101,8 +101,8 @@ namespace BizHawk.Common
public int this[int index]
{
#if DEBUG
get { return arr[index]; }
set { arr[index] = value; }
get { return this.Arr[index]; }
set { this.Arr[index] = value; }
#else
set { Write32(index<<2, (uint) value); }
get { return (int)Read32(index<<2);}
@ -117,8 +117,8 @@ namespace BizHawk.Common
public short this[int index]
{
#if DEBUG
get { return arr[index]; }
set { arr[index] = value; }
get { return this.Arr[index]; }
set { this.Arr[index] = value; }
#else
set { Write32(index << 1, (uint)value); }
get { return (short)Read16(index << 1); }

View File

@ -4,8 +4,8 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Text;
namespace BizHawk.Common
{
@ -98,9 +98,12 @@ namespace BizHawk.Common
/// </summary>
public static string BytesToHexString(byte[] bytes)
{
StringBuilder sb = new StringBuilder();
foreach (byte b in bytes)
var sb = new StringBuilder();
foreach (var b in bytes)
{
sb.AppendFormat("{0:X2}", b);
}
return sb.ToString();
}
@ -524,12 +527,12 @@ namespace BizHawk.Common
public void Sync(string name, ref ByteBuffer byteBuf)
{
SyncBuffer(name, 1, byteBuf.len, byteBuf.ptr);
SyncBuffer(name, 1, byteBuf.Len, byteBuf.Ptr);
}
public void Sync(string name, ref IntBuffer byteBuf)
{
SyncBuffer(name, 4, byteBuf.len, byteBuf.ptr);
SyncBuffer(name, 4, byteBuf.Len, byteBuf.Ptr);
}
public void Sync(string name, ref byte[] val, bool use_null)

View File

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using BizHawk.Common;
@ -79,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
case "Byte[]":
refByteBuffer = new ByteBuffer((byte[])currentValue);
ser.Sync(member.Name, ref refByteBuffer);
currentValue = refByteBuffer.arr;
currentValue = refByteBuffer.Arr;
break;
case "ByteBuffer":
refByteBuffer = (ByteBuffer)currentValue;
@ -99,7 +95,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
case "Int32[]":
refIntBuffer = new IntBuffer((int[])currentValue);
ser.Sync(member.Name, ref refIntBuffer);
currentValue = refIntBuffer.arr;
currentValue = refIntBuffer.Arr;
break;
case "IntBuffer":
refIntBuffer = (IntBuffer)currentValue;

View File

@ -121,7 +121,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
protected void ApplyMemoryMapMask(int mask, ByteBuffer map)
{
byte bmask = (byte)mask;
for (int i = 0; i < map.len; i++)
for (int i = 0; i < map.Len; i++)
map[i] &= bmask;
}