fixs spaces into tabs in a bunch of files because I'm tired of fixing it gradually

This commit is contained in:
andres.delikat 2011-06-19 23:39:25 +00:00
parent 38422fda10
commit 5bda595ee7
19 changed files with 2926 additions and 2914 deletions

View File

@ -28,88 +28,89 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button();
this.lvMembers = new System.Windows.Forms.ListView(); this.lvMembers = new System.Windows.Forms.ListView();
this.colSize = new System.Windows.Forms.ColumnHeader(); this.colSize = new System.Windows.Forms.ColumnHeader();
this.colName = new System.Windows.Forms.ColumnHeader(); this.colName = new System.Windows.Forms.ColumnHeader();
this.flowLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// flowLayoutPanel1 // flowLayoutPanel1
// //
this.flowLayoutPanel1.AutoSize = true; this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.Controls.Add(this.btnCancel); this.flowLayoutPanel1.Controls.Add(this.btnCancel);
this.flowLayoutPanel1.Controls.Add(this.btnOK); this.flowLayoutPanel1.Controls.Add(this.btnOK);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 276); this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 276);
this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(528, 29); this.flowLayoutPanel1.Size = new System.Drawing.Size(528, 29);
this.flowLayoutPanel1.TabIndex = 0; this.flowLayoutPanel1.TabIndex = 0;
// //
// btnCancel // btnCancel
// //
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(450, 3); this.btnCancel.Location = new System.Drawing.Point(450, 3);
this.btnCancel.Name = "btnCancel"; this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 1; this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel"; this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
// //
// btnOK // btnOK
// //
this.btnOK.Location = new System.Drawing.Point(369, 3); this.btnOK.Location = new System.Drawing.Point(369, 3);
this.btnOK.Name = "btnOK"; this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23); this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 0; this.btnOK.TabIndex = 0;
this.btnOK.Text = "OK"; this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true; this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click); this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
// //
// lvMembers // lvMembers
// //
this.lvMembers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.lvMembers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colSize, this.colSize,
this.colName}); this.colName});
this.lvMembers.Dock = System.Windows.Forms.DockStyle.Fill; this.lvMembers.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvMembers.FullRowSelect = true; this.lvMembers.FullRowSelect = true;
this.lvMembers.GridLines = true; this.lvMembers.GridLines = true;
this.lvMembers.Location = new System.Drawing.Point(0, 0); this.lvMembers.Location = new System.Drawing.Point(0, 0);
this.lvMembers.Name = "lvMembers"; this.lvMembers.Name = "lvMembers";
this.lvMembers.Size = new System.Drawing.Size(528, 276); this.lvMembers.Size = new System.Drawing.Size(528, 276);
this.lvMembers.TabIndex = 0; this.lvMembers.TabIndex = 0;
this.lvMembers.UseCompatibleStateImageBehavior = false; this.lvMembers.UseCompatibleStateImageBehavior = false;
this.lvMembers.View = System.Windows.Forms.View.Details; this.lvMembers.View = System.Windows.Forms.View.Details;
this.lvMembers.ItemActivate += new System.EventHandler(this.lvMembers_ItemActivate); this.lvMembers.ItemActivate += new System.EventHandler(this.lvMembers_ItemActivate);
// //
// colSize // colSize
// //
this.colSize.Text = "Size"; this.colSize.Text = "Size";
// //
// colName // colName
// //
this.colName.Text = "Name"; this.colName.Text = "Name";
this.colName.Width = 409; this.colName.Width = 409;
// //
// ArchiveChooser // ArchiveChooser
// //
this.AcceptButton = this.btnOK; this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel; this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(528, 305); this.ClientSize = new System.Drawing.Size(528, 305);
this.Controls.Add(this.lvMembers); this.Controls.Add(this.lvMembers);
this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.flowLayoutPanel1);
this.Name = "ArchiveChooser"; this.Name = "ArchiveChooser";
this.ShowIcon = false; this.ShowIcon = false;
this.Text = "Choose File From Archive"; this.Text = "Choose File From Archive";
this.flowLayoutPanel1.ResumeLayout(false); this.Load += new System.EventHandler(this.ArchiveChooser_Load);
this.ResumeLayout(false); this.flowLayoutPanel1.ResumeLayout(false);
this.PerformLayout(); this.ResumeLayout(false);
this.PerformLayout();
} }

View File

@ -51,5 +51,10 @@ namespace BizHawk.MultiClient
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void ArchiveChooser_Load(object sender, EventArgs e)
{
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,37 +3,37 @@ using Newtonsoft.Json;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public static class ConfigService public static class ConfigService
{ {
public static T Load<T>(string filepath) where T : new() public static T Load<T>(string filepath) where T : new()
{ {
T config = new T(); T config = new T();
try try
{ {
var file = new FileInfo(filepath); var file = new FileInfo(filepath);
if(file.Exists) if (file.Exists)
using (var reader = file.OpenText()) using (var reader = file.OpenText())
{ {
var s = new JsonSerializer(); var s = new JsonSerializer();
var r = new JsonReader(reader); var r = new JsonReader(reader);
config = (T) s.Deserialize(r, typeof (T)); config = (T)s.Deserialize(r, typeof(T));
} }
} }
catch { } catch { }
if (config == null) return new T(); if (config == null) return new T();
else return config; else return config;
} }
public static void Save(string filepath, object config) public static void Save(string filepath, object config)
{ {
var file = new FileInfo(filepath); var file = new FileInfo(filepath);
using (var writer = file.CreateText()) using (var writer = file.CreateText())
{ {
var s = new JsonSerializer(); var s = new JsonSerializer();
var w = new JsonWriter(writer) { Formatting = Formatting.Indented }; var w = new JsonWriter(writer) { Formatting = Formatting.Indented };
s.Serialize(w, config); s.Serialize(w, config);
} }
} }
} }
} }

View File

@ -3,24 +3,24 @@ using SlimDX.DirectSound;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public static class Global public static class Global
{ {
public static MainForm MainForm; public static MainForm MainForm;
public static DirectSound DSound; public static DirectSound DSound;
public static Direct3D Direct3D; public static Direct3D Direct3D;
public static Sound Sound; public static Sound Sound;
public static IRenderer RenderPanel; public static IRenderer RenderPanel;
public static Config Config; public static Config Config;
public static IEmulator Emulator; public static IEmulator Emulator;
public static CoreInputComm CoreInputComm; public static CoreInputComm CoreInputComm;
public static RomGame Game; public static RomGame Game;
public static Controller ClientControls; public static Controller ClientControls;
public static Controller SMSControls; public static Controller SMSControls;
public static Controller PCEControls; public static Controller PCEControls;
public static Controller GenControls; public static Controller GenControls;
public static Controller TI83Controls; public static Controller TI83Controls;
public static Controller NESControls; public static Controller NESControls;
public static Controller ActiveController; public static Controller ActiveController;
public static Controller NullControls; public static Controller NullControls;
} }
} }

View File

@ -9,8 +9,8 @@ namespace BizHawk.MultiClient
//split into "bind" and "open (the bound thing)" //split into "bind" and "open (the bound thing)"
//scan archive to flatten interior directories down to a path (maintain our own archive item list) //scan archive to flatten interior directories down to a path (maintain our own archive item list)
public class HawkFile : IDisposable public class HawkFile : IDisposable
{ {
public static bool ExistsAt(string path) public static bool ExistsAt(string path)
{ {
using (var file = new HawkFile(path)) using (var file = new HawkFile(path))
@ -62,7 +62,7 @@ namespace BizHawk.MultiClient
/// <summary> /// <summary>
/// returns the complete canonical full path ("c:\path\to\archive|member") of the bound file /// returns the complete canonical full path ("c:\path\to\archive|member") of the bound file
/// </summary> /// </summary>
public string CanonicalFullPath { get { return MakeCanonicalName(rootPath,memberPath); } } public string CanonicalFullPath { get { return MakeCanonicalName(rootPath, memberPath); } }
/// <summary> /// <summary>
/// returns the complete canonical name ("archive|member") of the bound file /// returns the complete canonical name ("archive|member") of the bound file
@ -72,7 +72,7 @@ namespace BizHawk.MultiClient
/// <summary> /// <summary>
/// returns the virtual name of the bound file (disregarding the archive) /// returns the virtual name of the bound file (disregarding the archive)
/// </summary> /// </summary>
public string Name { get { return GetBoundNameFromCanonical(MakeCanonicalName(rootPath,memberPath)); } } public string Name { get { return GetBoundNameFromCanonical(MakeCanonicalName(rootPath, memberPath)); } }
/// <summary> /// <summary>
/// returns the extension of Name /// returns the extension of Name
@ -111,7 +111,7 @@ namespace BizHawk.MultiClient
List<ArchiveItem> archiveItems; List<ArchiveItem> archiveItems;
public HawkFile(string path) public HawkFile(string path)
{ {
string autobind = null; string autobind = null;
bool isArchivePath = IsCanonicalArchivePath(path); bool isArchivePath = IsCanonicalArchivePath(path);
if (isArchivePath) if (isArchivePath)
@ -121,11 +121,11 @@ namespace BizHawk.MultiClient
autobind = parts[1]; autobind = parts[1];
} }
var fi = new FileInfo(path); var fi = new FileInfo(path);
rootExists = fi.Exists; rootExists = fi.Exists;
if (fi.Exists == false) if (fi.Exists == false)
return; return;
rootPath = path; rootPath = path;
exists = true; exists = true;
@ -158,7 +158,7 @@ namespace BizHawk.MultiClient
exists = false; exists = false;
} }
} }
/// <summary> /// <summary>
/// is the supplied path a canonical name including an archive? /// is the supplied path a canonical name including an archive?
@ -244,7 +244,7 @@ namespace BizHawk.MultiClient
return BindByExtensionCore(false, extensions); return BindByExtensionCore(false, extensions);
} }
/// <summary> /// <summary>
/// Binds the first item in the archive (or the file itself) if the extension matches one of the supplied templates. /// Binds the first item in the archive (or the file itself) if the extension matches one of the supplied templates.
/// You probably should not use this. use BindSoleItemOf or the archive chooser instead /// You probably should not use this. use BindSoleItemOf or the archive chooser instead
/// </summary> /// </summary>
@ -308,7 +308,7 @@ namespace BizHawk.MultiClient
} }
private void AnalyzeArchive(string path) private void AnalyzeArchive(string path)
{ {
SevenZip.FileChecker.ThrowExceptions = false; SevenZip.FileChecker.ThrowExceptions = false;
int offset; int offset;
bool isExecutable; bool isExecutable;
@ -326,10 +326,10 @@ namespace BizHawk.MultiClient
archiveItems = null; archiveItems = null;
} }
} }
} }
public void Dispose() public void Dispose()
{ {
Unbind(); Unbind();
if (extractor != null) extractor.Dispose(); if (extractor != null) extractor.Dispose();
@ -338,5 +338,5 @@ namespace BizHawk.MultiClient
extractor = null; extractor = null;
rootStream = null; rootStream = null;
} }
} }
} }

View File

@ -4,108 +4,108 @@ using System.Text;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public class Controller : IController public class Controller : IController
{ {
private ControllerDefinition type; private ControllerDefinition type;
private Dictionary<string,List<string>> bindings = new Dictionary<string, List<string>>(); private Dictionary<string, List<string>> bindings = new Dictionary<string, List<string>>();
private Dictionary<string,bool> stickyButtons = new Dictionary<string, bool>(); private Dictionary<string, bool> stickyButtons = new Dictionary<string, bool>();
private List<string> unpressedButtons = new List<string>(); private List<string> unpressedButtons = new List<string>();
private List<string> forcePressedButtons = new List<string>(); private List<string> forcePressedButtons = new List<string>();
private List<string> removeFromForcePressedButtons = new List<string>(); private List<string> removeFromForcePressedButtons = new List<string>();
private List<string> programmaticallyPressedButtons = new List<string>(); private List<string> programmaticallyPressedButtons = new List<string>();
private bool movieMode; private bool movieMode;
public bool MovieMode public bool MovieMode
{ {
get { return movieMode; } get { return movieMode; }
set set
{ {
movieMode = value; movieMode = value;
if (value == false) if (value == false)
programmaticallyPressedButtons.Clear(); programmaticallyPressedButtons.Clear();
} }
} }
public Controller(ControllerDefinition definition) public Controller(ControllerDefinition definition)
{ {
type = definition; type = definition;
foreach (var b in type.BoolButtons) foreach (var b in type.BoolButtons)
{ {
bindings[b] = new List<string>(); bindings[b] = new List<string>();
stickyButtons[b] = false; stickyButtons[b] = false;
} }
foreach (var f in type.FloatControls) foreach (var f in type.FloatControls)
bindings[f] = new List<string>(); bindings[f] = new List<string>();
} }
public void BindButton(string button, string control) public void BindButton(string button, string control)
{ {
bindings[button].Add(control); bindings[button].Add(control);
} }
public void BindMulti(string button, string controlString) public void BindMulti(string button, string controlString)
{ {
if (string.IsNullOrEmpty(controlString)) if (string.IsNullOrEmpty(controlString))
return; return;
string[] controlbindings = controlString.Split(','); string[] controlbindings = controlString.Split(',');
foreach (string control in controlbindings) foreach (string control in controlbindings)
bindings[button].Add(control.Trim()); bindings[button].Add(control.Trim());
} }
public ControllerDefinition Type public ControllerDefinition Type
{ {
get { return type; } get { return type; }
} }
public bool this[string button] public bool this[string button]
{ {
get { return IsPressed(button); } get { return IsPressed(button); }
} }
public bool IsPressed(string button) public bool IsPressed(string button)
{ {
if (MovieMode) if (MovieMode)
{ {
return programmaticallyPressedButtons.Contains(button); return programmaticallyPressedButtons.Contains(button);
} }
if (forcePressedButtons.Contains(button)) if (forcePressedButtons.Contains(button))
{ {
removeFromForcePressedButtons.Add(button); removeFromForcePressedButtons.Add(button);
return true; return true;
} }
if (unpressedButtons.Contains(button)) if (unpressedButtons.Contains(button))
{ {
if (IsPressedActually(button) == false) if (IsPressedActually(button) == false)
unpressedButtons.Remove(button); unpressedButtons.Remove(button);
return false; return false;
} }
if (Global.Config.AllowUD_LR == false) if (Global.Config.AllowUD_LR == false)
{ {
string prefix; string prefix;
if (button.Contains("Down")) if (button.Contains("Down"))
{ {
prefix = button.GetPrecedingString("Down"); prefix = button.GetPrecedingString("Down");
if (IsPressed(prefix + "Up")) if (IsPressed(prefix + "Up"))
return false; return false;
} }
if (button.Contains("Right")) if (button.Contains("Right"))
{ {
prefix = button.GetPrecedingString("Right"); prefix = button.GetPrecedingString("Right");
if (IsPressed(prefix + "Left")) if (IsPressed(prefix + "Left"))
return false; return false;
} }
} }
return IsPressedActually(button); return IsPressedActually(button);
} }
public bool IsPressedActually(string button) public bool IsPressedActually(string button)
{ {
bool sticky = stickyButtons[button]; bool sticky = stickyButtons[button];
foreach (var control in bindings[button]) foreach (var control in bindings[button])
@ -113,95 +113,95 @@ namespace BizHawk.MultiClient
return sticky ? false : true; return sticky ? false : true;
return sticky ? true : false; return sticky ? true : false;
} }
public float GetFloat(string name) public float GetFloat(string name)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void UnpressButton(string name) public void UnpressButton(string name)
{ {
unpressedButtons.Add(name); unpressedButtons.Add(name);
} }
private int frameNumber; private int frameNumber;
public void UpdateControls(int frame) public void UpdateControls(int frame)
{ {
if (frame != frameNumber) if (frame != frameNumber)
{ {
// update // update
unpressedButtons.RemoveAll(button => IsPressedActually(button) == false); unpressedButtons.RemoveAll(button => IsPressedActually(button) == false);
forcePressedButtons.RemoveAll(button => removeFromForcePressedButtons.Contains(button)); forcePressedButtons.RemoveAll(button => removeFromForcePressedButtons.Contains(button));
removeFromForcePressedButtons.Clear(); removeFromForcePressedButtons.Clear();
} }
frameNumber = frame; frameNumber = frame;
} }
public void SetSticky(string button, bool sticky) public void SetSticky(string button, bool sticky)
{ {
stickyButtons[button] = sticky; stickyButtons[button] = sticky;
} }
public bool IsSticky(string button) public bool IsSticky(string button)
{ {
return stickyButtons[button]; return stickyButtons[button];
} }
public void ForceButton(string button) public void ForceButton(string button)
{ {
forcePressedButtons.Add(button); forcePressedButtons.Add(button);
} }
public string GetControllersAsMnemonic() public string GetControllersAsMnemonic()
{ {
StringBuilder input = new StringBuilder("|"); StringBuilder input = new StringBuilder("|");
if (type.Name == "SMS Controller") if (type.Name == "SMS Controller")
{ {
input.Append(IsPressed("P1 Up") ? "U" : "."); input.Append(IsPressed("P1 Up") ? "U" : ".");
input.Append(IsPressed("P1 Down") ? "D" : "."); input.Append(IsPressed("P1 Down") ? "D" : ".");
input.Append(IsPressed("P1 Left") ? "L" : "."); input.Append(IsPressed("P1 Left") ? "L" : ".");
input.Append(IsPressed("P1 Right") ? "R" : "."); input.Append(IsPressed("P1 Right") ? "R" : ".");
input.Append(IsPressed("P1 B1") ? "1" : "."); input.Append(IsPressed("P1 B1") ? "1" : ".");
input.Append(IsPressed("P1 B2") ? "2" : "."); input.Append(IsPressed("P1 B2") ? "2" : ".");
input.Append("|"); input.Append("|");
input.Append(IsPressed("P2 Up") ? "U" : "."); input.Append(IsPressed("P2 Up") ? "U" : ".");
input.Append(IsPressed("P2 Down") ? "D" : "."); input.Append(IsPressed("P2 Down") ? "D" : ".");
input.Append(IsPressed("P2 Left") ? "L" : "."); input.Append(IsPressed("P2 Left") ? "L" : ".");
input.Append(IsPressed("P2 Right") ? "R" : "."); input.Append(IsPressed("P2 Right") ? "R" : ".");
input.Append(IsPressed("P2 B1") ? "1" : "."); input.Append(IsPressed("P2 B1") ? "1" : ".");
input.Append(IsPressed("P2 B2") ? "2" : "."); input.Append(IsPressed("P2 B2") ? "2" : ".");
input.Append("|"); input.Append("|");
input.Append(IsPressed("Pause") ? "P" : "."); input.Append(IsPressed("Pause") ? "P" : ".");
input.Append(IsPressed("Reset") ? "R" : "."); input.Append(IsPressed("Reset") ? "R" : ".");
input.Append("|"); input.Append("|");
return input.ToString(); return input.ToString();
} }
if (type.Name == "PC Engine Controller") if (type.Name == "PC Engine Controller")
{ {
input.Append("."); //TODO: reset goes here - the turbografx DOES NOT HAVE A RESET BUTTON. but I assume this is for pcejin movie file compatibility, which is a fools errand anyway......... I'll leave it for now, but marked for deletion input.Append("."); //TODO: reset goes here - the turbografx DOES NOT HAVE A RESET BUTTON. but I assume this is for pcejin movie file compatibility, which is a fools errand anyway......... I'll leave it for now, but marked for deletion
input.Append("|"); input.Append("|");
for (int player = 1; player < 6; player++) for (int player = 1; player < 6; player++)
{ {
input.Append(IsPressed("P" + player.ToString() + " Up") ? "U" : "."); input.Append(IsPressed("P" + player.ToString() + " Up") ? "U" : ".");
input.Append(IsPressed("P" + player.ToString() + " Down") ? "D" : "."); input.Append(IsPressed("P" + player.ToString() + " Down") ? "D" : ".");
input.Append(IsPressed("P" + player.ToString() + " Left") ? "L" : "."); input.Append(IsPressed("P" + player.ToString() + " Left") ? "L" : ".");
input.Append(IsPressed("P" + player.ToString() + " Right") ? "R" : "."); input.Append(IsPressed("P" + player.ToString() + " Right") ? "R" : ".");
input.Append(IsPressed("P" + player.ToString() + " B1") ? "1" : "."); input.Append(IsPressed("P" + player.ToString() + " B1") ? "1" : ".");
input.Append(IsPressed("P" + player.ToString() + " B2") ? "2" : "."); input.Append(IsPressed("P" + player.ToString() + " B2") ? "2" : ".");
input.Append(IsPressed("P" + player.ToString() + " Run") ? "R" : "."); input.Append(IsPressed("P" + player.ToString() + " Run") ? "R" : ".");
input.Append(IsPressed("P" + player.ToString() + " Select") ? "S" : "."); input.Append(IsPressed("P" + player.ToString() + " Select") ? "S" : ".");
input.Append("|"); input.Append("|");
} }
return input.ToString(); return input.ToString();
} }
if (type.Name == "NES Controls") if (type.Name == "NES Controls")
{ {
input.Append(IsPressed("Reset") ? "r" : "."); input.Append(IsPressed("Reset") ? "r" : ".");
input.Append("|"); input.Append("|");
for (int player = 1; player <= 2; player++) for (int player = 1; player <= 2; player++)
@ -216,154 +216,154 @@ namespace BizHawk.MultiClient
input.Append(IsPressed("P" + player.ToString() + " A") ? "A" : "."); input.Append(IsPressed("P" + player.ToString() + " A") ? "A" : ".");
input.Append("|"); input.Append("|");
} }
return input.ToString(); return input.ToString();
} }
if (type.Name == "TI83 Controls") if (type.Name == "TI83 Controls")
{ {
input.Append(IsPressed("0") ? "0" : "."); input.Append(IsPressed("0") ? "0" : ".");
input.Append(IsPressed("1") ? "1" : "."); input.Append(IsPressed("1") ? "1" : ".");
input.Append(IsPressed("2") ? "2" : "."); input.Append(IsPressed("2") ? "2" : ".");
input.Append(IsPressed("3") ? "3" : "."); input.Append(IsPressed("3") ? "3" : ".");
input.Append(IsPressed("4") ? "4" : "."); input.Append(IsPressed("4") ? "4" : ".");
input.Append(IsPressed("5") ? "5" : "."); input.Append(IsPressed("5") ? "5" : ".");
input.Append(IsPressed("6") ? "6" : "."); input.Append(IsPressed("6") ? "6" : ".");
input.Append(IsPressed("7") ? "7" : "."); input.Append(IsPressed("7") ? "7" : ".");
input.Append(IsPressed("8") ? "8" : "."); input.Append(IsPressed("8") ? "8" : ".");
input.Append(IsPressed("9") ? "9" : "."); input.Append(IsPressed("9") ? "9" : ".");
input.Append(IsPressed("DOT") ? "`" : "."); input.Append(IsPressed("DOT") ? "`" : ".");
input.Append(IsPressed("ON") ? "O" : "."); input.Append(IsPressed("ON") ? "O" : ".");
input.Append(IsPressed("ENTER") ? "=" : "."); input.Append(IsPressed("ENTER") ? "=" : ".");
input.Append(IsPressed("UP") ? "U" : "."); input.Append(IsPressed("UP") ? "U" : ".");
input.Append(IsPressed("DOWN") ? "D" : "."); input.Append(IsPressed("DOWN") ? "D" : ".");
input.Append(IsPressed("LEFT") ? "L" : "."); input.Append(IsPressed("LEFT") ? "L" : ".");
input.Append(IsPressed("RIGHT") ? "R": "."); input.Append(IsPressed("RIGHT") ? "R" : ".");
input.Append(IsPressed("PLUS") ? "+": "."); input.Append(IsPressed("PLUS") ? "+" : ".");
input.Append(IsPressed("MINUS") ? "_": "."); input.Append(IsPressed("MINUS") ? "_" : ".");
input.Append(IsPressed("MULTIPLY") ? "*": "."); input.Append(IsPressed("MULTIPLY") ? "*" : ".");
input.Append(IsPressed("DIVIDE") ? "/": "."); input.Append(IsPressed("DIVIDE") ? "/" : ".");
input.Append(IsPressed("CLEAR") ? "c": "."); input.Append(IsPressed("CLEAR") ? "c" : ".");
input.Append(IsPressed("EXP") ? "^": "."); input.Append(IsPressed("EXP") ? "^" : ".");
input.Append(IsPressed("DASH") ? "-": "."); input.Append(IsPressed("DASH") ? "-" : ".");
input.Append(IsPressed("PARAOPEN") ? "(" : "."); input.Append(IsPressed("PARAOPEN") ? "(" : ".");
input.Append(IsPressed("PARACLOSE") ? ")" : "."); input.Append(IsPressed("PARACLOSE") ? ")" : ".");
input.Append(IsPressed("TAN") ? "T" : "."); input.Append(IsPressed("TAN") ? "T" : ".");
input.Append(IsPressed("VARS") ? "V" : "."); input.Append(IsPressed("VARS") ? "V" : ".");
input.Append(IsPressed("COS") ? "C" : "."); input.Append(IsPressed("COS") ? "C" : ".");
input.Append(IsPressed("PRGM") ? "P" : "."); input.Append(IsPressed("PRGM") ? "P" : ".");
input.Append(IsPressed("STAT") ? "s" : "."); input.Append(IsPressed("STAT") ? "s" : ".");
input.Append(IsPressed("MATRIX") ? "m" : "."); input.Append(IsPressed("MATRIX") ? "m" : ".");
input.Append(IsPressed("X") ? "X" : "."); input.Append(IsPressed("X") ? "X" : ".");
input.Append(IsPressed("STO") ? ">" : "."); input.Append(IsPressed("STO") ? ">" : ".");
input.Append(IsPressed("LN") ? "n" : "."); input.Append(IsPressed("LN") ? "n" : ".");
input.Append(IsPressed("LOG") ? "L" : "."); input.Append(IsPressed("LOG") ? "L" : ".");
input.Append(IsPressed("SQUARED") ? "2" : "."); input.Append(IsPressed("SQUARED") ? "2" : ".");
input.Append(IsPressed("NEG1") ? "1" : "."); input.Append(IsPressed("NEG1") ? "1" : ".");
input.Append(IsPressed("MATH") ? "H" : "."); input.Append(IsPressed("MATH") ? "H" : ".");
input.Append(IsPressed("ALPHA") ? "A" : "."); input.Append(IsPressed("ALPHA") ? "A" : ".");
input.Append(IsPressed("GRAPH") ? "G" : "."); input.Append(IsPressed("GRAPH") ? "G" : ".");
input.Append(IsPressed("TRACE") ? "t" : "."); input.Append(IsPressed("TRACE") ? "t" : ".");
input.Append(IsPressed("ZOOM") ? "Z" : "."); input.Append(IsPressed("ZOOM") ? "Z" : ".");
input.Append(IsPressed("WINDOW") ? "W" : "."); input.Append(IsPressed("WINDOW") ? "W" : ".");
input.Append(IsPressed("Y") ? "Y" : "."); input.Append(IsPressed("Y") ? "Y" : ".");
input.Append(IsPressed("2ND") ? "&" : "."); input.Append(IsPressed("2ND") ? "&" : ".");
input.Append(IsPressed("MODE") ? "O" : "."); input.Append(IsPressed("MODE") ? "O" : ".");
input.Append(IsPressed("DEL") ? "D" : "."); input.Append(IsPressed("DEL") ? "D" : ".");
input.Append(IsPressed("COMMA") ? "," : "."); input.Append(IsPressed("COMMA") ? "," : ".");
input.Append(IsPressed("SIN") ? "S" : "."); input.Append(IsPressed("SIN") ? "S" : ".");
input.Append("|.|"); //TODO: perhaps ON should go here? input.Append("|.|"); //TODO: perhaps ON should go here?
return input.ToString(); return input.ToString();
} }
return "?"; return "?";
} }
public void SetControllersAsMnemonic(string mnemonic) public void SetControllersAsMnemonic(string mnemonic)
{ {
MovieMode = true; MovieMode = true;
programmaticallyPressedButtons.Clear(); programmaticallyPressedButtons.Clear();
if (type.Name == "SMS Controller") if (type.Name == "SMS Controller")
{ {
if (mnemonic[1] != '.') programmaticallyPressedButtons.Add("P1 Up"); if (mnemonic[1] != '.') programmaticallyPressedButtons.Add("P1 Up");
if (mnemonic[2] != '.') programmaticallyPressedButtons.Add("P1 Down"); if (mnemonic[2] != '.') programmaticallyPressedButtons.Add("P1 Down");
if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Left"); if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Left");
if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Right"); if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Right");
if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 B1"); if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 B1");
if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 B2"); if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 B2");
if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P2 Up"); if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P2 Up");
if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P2 Down"); if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P2 Down");
if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P2 Left"); if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P2 Left");
if (mnemonic[11] != '.') programmaticallyPressedButtons.Add("P2 Right"); if (mnemonic[11] != '.') programmaticallyPressedButtons.Add("P2 Right");
if (mnemonic[12] != '.') programmaticallyPressedButtons.Add("P2 B1"); if (mnemonic[12] != '.') programmaticallyPressedButtons.Add("P2 B1");
if (mnemonic[13] != '.') programmaticallyPressedButtons.Add("P2 B2"); if (mnemonic[13] != '.') programmaticallyPressedButtons.Add("P2 B2");
if (mnemonic[15] != '.') programmaticallyPressedButtons.Add("Pause"); if (mnemonic[15] != '.') programmaticallyPressedButtons.Add("Pause");
if (mnemonic[16] != '.') programmaticallyPressedButtons.Add("Reset"); if (mnemonic[16] != '.') programmaticallyPressedButtons.Add("Reset");
} }
if (type.Name == "PC Engine Controller") if (type.Name == "PC Engine Controller")
{ {
if (!Global.MainForm.UserMovie.MultiTrack.isActive || (Global.MainForm.UserMovie.GetMovieMode() == MOVIEMODE.PLAY)) if (!Global.MainForm.UserMovie.MultiTrack.isActive || (Global.MainForm.UserMovie.GetMovieMode() == MOVIEMODE.PLAY))
{ {
for (int i = 1; i < 6; i++) for (int i = 1; i < 6; i++)
{ {
if (mnemonic.Length < (1 + i * 9)) return; if (mnemonic.Length < (1 + i * 9)) return;
if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up"); if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up");
if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down"); if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down");
if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left"); if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left");
if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right"); if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right");
if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1"); if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1");
if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2"); if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2");
if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run"); if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run");
if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select"); if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select");
} }
} }
else else
{ {
for (int i = 1; i < 6; i++) for (int i = 1; i < 6; i++)
{ {
if ((Global.MainForm.UserMovie.MultiTrack.CurrentPlayer == i) || Global.MainForm.UserMovie.MultiTrack.RecordAll) if ((Global.MainForm.UserMovie.MultiTrack.CurrentPlayer == i) || Global.MainForm.UserMovie.MultiTrack.RecordAll)
{ {
if (IsPressedActually("P1 Up")) programmaticallyPressedButtons.Add("P" + i + " Up"); if (IsPressedActually("P1 Up")) programmaticallyPressedButtons.Add("P" + i + " Up");
if (IsPressedActually("P1 Down")) programmaticallyPressedButtons.Add("P" + i + " Down"); if (IsPressedActually("P1 Down")) programmaticallyPressedButtons.Add("P" + i + " Down");
if (IsPressedActually("P1 Left")) programmaticallyPressedButtons.Add("P" + i + " Left"); if (IsPressedActually("P1 Left")) programmaticallyPressedButtons.Add("P" + i + " Left");
if (IsPressedActually("P1 Right")) programmaticallyPressedButtons.Add("P" + i + " Right"); if (IsPressedActually("P1 Right")) programmaticallyPressedButtons.Add("P" + i + " Right");
if (IsPressedActually("P1 B1")) programmaticallyPressedButtons.Add("P" + i + " B1"); if (IsPressedActually("P1 B1")) programmaticallyPressedButtons.Add("P" + i + " B1");
if (IsPressedActually("P1 B2")) programmaticallyPressedButtons.Add("P" + i + " B2"); if (IsPressedActually("P1 B2")) programmaticallyPressedButtons.Add("P" + i + " B2");
if (IsPressedActually("P1 Run")) programmaticallyPressedButtons.Add("P" + i + " Run"); if (IsPressedActually("P1 Run")) programmaticallyPressedButtons.Add("P" + i + " Run");
if (IsPressedActually("P1 Select")) programmaticallyPressedButtons.Add("P" + i + " Select"); if (IsPressedActually("P1 Select")) programmaticallyPressedButtons.Add("P" + i + " Select");
} }
else else
{ {
if (mnemonic.Length >= (1 + i * 9)) if (mnemonic.Length >= (1 + i * 9))
{ {
if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up"); if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up");
if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down"); if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down");
if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left"); if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left");
if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right"); if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right");
if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1"); if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1");
if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2"); if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2");
if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run"); if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run");
if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select"); if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select");
} }
} }
} }
} }
} }
if (type.Name == "NES Controls") if (type.Name == "NES Controls")
{ {
if (mnemonic.Length < 10) return; if (mnemonic.Length < 10) return;
//if (mnemonic[1] != '.' && mnemonic[1] != '0') programmaticallyPressedButtons.Add("Reset"); //if (mnemonic[1] != '.' && mnemonic[1] != '0') programmaticallyPressedButtons.Add("Reset");
if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Right"); if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Right");
if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Left"); if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Left");
if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 Down"); if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 Down");
if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 Up"); if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 Up");
if (mnemonic[7] != '.') programmaticallyPressedButtons.Add("P1 Start"); if (mnemonic[7] != '.') programmaticallyPressedButtons.Add("P1 Start");
if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P1 Select"); if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P1 Select");
if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P1 B"); if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P1 B");
if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P1 A"); if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P1 A");
if (mnemonic.Length < 20) return; if (mnemonic.Length < 20) return;
if (mnemonic[12] != '.') programmaticallyPressedButtons.Add("P2 Right"); if (mnemonic[12] != '.') programmaticallyPressedButtons.Add("P2 Right");
@ -374,113 +374,113 @@ namespace BizHawk.MultiClient
if (mnemonic[17] != '.') programmaticallyPressedButtons.Add("P2 Select"); if (mnemonic[17] != '.') programmaticallyPressedButtons.Add("P2 Select");
if (mnemonic[18] != '.') programmaticallyPressedButtons.Add("P2 B"); if (mnemonic[18] != '.') programmaticallyPressedButtons.Add("P2 B");
if (mnemonic[19] != '.') programmaticallyPressedButtons.Add("P2 A"); if (mnemonic[19] != '.') programmaticallyPressedButtons.Add("P2 A");
} }
if (type.Name == "TI83 Controls") if (type.Name == "TI83 Controls")
{ {
if (mnemonic.Length < 50) return; if (mnemonic.Length < 50) return;
if (mnemonic[1] != '.') if (mnemonic[1] != '.')
programmaticallyPressedButtons.Add("0"); programmaticallyPressedButtons.Add("0");
if (mnemonic[2] != '.') if (mnemonic[2] != '.')
programmaticallyPressedButtons.Add("1"); programmaticallyPressedButtons.Add("1");
if (mnemonic[3] != '.') if (mnemonic[3] != '.')
programmaticallyPressedButtons.Add("2"); programmaticallyPressedButtons.Add("2");
if (mnemonic[4] != '.') if (mnemonic[4] != '.')
programmaticallyPressedButtons.Add("3"); programmaticallyPressedButtons.Add("3");
if (mnemonic[5] != '.') if (mnemonic[5] != '.')
programmaticallyPressedButtons.Add("4"); programmaticallyPressedButtons.Add("4");
if (mnemonic[6] != '.') if (mnemonic[6] != '.')
programmaticallyPressedButtons.Add("5"); programmaticallyPressedButtons.Add("5");
if (mnemonic[7] != '.') if (mnemonic[7] != '.')
programmaticallyPressedButtons.Add("6"); programmaticallyPressedButtons.Add("6");
if (mnemonic[8] != '.') if (mnemonic[8] != '.')
programmaticallyPressedButtons.Add("7"); programmaticallyPressedButtons.Add("7");
if (mnemonic[9] != '.') if (mnemonic[9] != '.')
programmaticallyPressedButtons.Add("8"); programmaticallyPressedButtons.Add("8");
if (mnemonic[10] != '.') if (mnemonic[10] != '.')
programmaticallyPressedButtons.Add("9"); programmaticallyPressedButtons.Add("9");
if (mnemonic[11] != '.') if (mnemonic[11] != '.')
programmaticallyPressedButtons.Add("DOT"); programmaticallyPressedButtons.Add("DOT");
if (mnemonic[12] != '.') if (mnemonic[12] != '.')
programmaticallyPressedButtons.Add("ON"); programmaticallyPressedButtons.Add("ON");
if (mnemonic[13] != '.') if (mnemonic[13] != '.')
programmaticallyPressedButtons.Add("ENTER"); programmaticallyPressedButtons.Add("ENTER");
if (mnemonic[14] != '.') if (mnemonic[14] != '.')
programmaticallyPressedButtons.Add("UP"); programmaticallyPressedButtons.Add("UP");
if (mnemonic[15] != '.') if (mnemonic[15] != '.')
programmaticallyPressedButtons.Add("DOWN"); programmaticallyPressedButtons.Add("DOWN");
if (mnemonic[16] != '.') if (mnemonic[16] != '.')
programmaticallyPressedButtons.Add("LEFT"); programmaticallyPressedButtons.Add("LEFT");
if (mnemonic[17] != '.') if (mnemonic[17] != '.')
programmaticallyPressedButtons.Add("RIGHT"); programmaticallyPressedButtons.Add("RIGHT");
if (mnemonic[18] != '.') if (mnemonic[18] != '.')
programmaticallyPressedButtons.Add("PLUS"); programmaticallyPressedButtons.Add("PLUS");
if (mnemonic[19] != '.') if (mnemonic[19] != '.')
programmaticallyPressedButtons.Add("MINUS"); programmaticallyPressedButtons.Add("MINUS");
if (mnemonic[20] != '.') if (mnemonic[20] != '.')
programmaticallyPressedButtons.Add("MULTIPLY"); programmaticallyPressedButtons.Add("MULTIPLY");
if (mnemonic[21] != '.') if (mnemonic[21] != '.')
programmaticallyPressedButtons.Add("DIVIDE"); programmaticallyPressedButtons.Add("DIVIDE");
if (mnemonic[22] != '.') if (mnemonic[22] != '.')
programmaticallyPressedButtons.Add("CLEAR"); programmaticallyPressedButtons.Add("CLEAR");
if (mnemonic[23] != '.') if (mnemonic[23] != '.')
programmaticallyPressedButtons.Add("EXP"); programmaticallyPressedButtons.Add("EXP");
if (mnemonic[24] != '.') if (mnemonic[24] != '.')
programmaticallyPressedButtons.Add("DASH"); programmaticallyPressedButtons.Add("DASH");
if (mnemonic[25] != '.') if (mnemonic[25] != '.')
programmaticallyPressedButtons.Add("PARAOPEN"); programmaticallyPressedButtons.Add("PARAOPEN");
if (mnemonic[26] != '.') if (mnemonic[26] != '.')
programmaticallyPressedButtons.Add("PARACLOSE"); programmaticallyPressedButtons.Add("PARACLOSE");
if (mnemonic[27] != '.') if (mnemonic[27] != '.')
programmaticallyPressedButtons.Add("TAN"); programmaticallyPressedButtons.Add("TAN");
if (mnemonic[28] != '.') if (mnemonic[28] != '.')
programmaticallyPressedButtons.Add("VARS"); programmaticallyPressedButtons.Add("VARS");
if (mnemonic[29] != '.') if (mnemonic[29] != '.')
programmaticallyPressedButtons.Add("COS"); programmaticallyPressedButtons.Add("COS");
if (mnemonic[30] != '.') if (mnemonic[30] != '.')
programmaticallyPressedButtons.Add("PGRM"); programmaticallyPressedButtons.Add("PGRM");
if (mnemonic[31] != '.') if (mnemonic[31] != '.')
programmaticallyPressedButtons.Add("STAT"); programmaticallyPressedButtons.Add("STAT");
if (mnemonic[32] != '.') if (mnemonic[32] != '.')
programmaticallyPressedButtons.Add("MATRIX"); programmaticallyPressedButtons.Add("MATRIX");
if (mnemonic[33] != '.') if (mnemonic[33] != '.')
programmaticallyPressedButtons.Add("X"); programmaticallyPressedButtons.Add("X");
if (mnemonic[34] != '.') if (mnemonic[34] != '.')
programmaticallyPressedButtons.Add("STO"); programmaticallyPressedButtons.Add("STO");
if (mnemonic[35] != '.') if (mnemonic[35] != '.')
programmaticallyPressedButtons.Add("LN"); programmaticallyPressedButtons.Add("LN");
if (mnemonic[36] != '.') if (mnemonic[36] != '.')
programmaticallyPressedButtons.Add("LOG"); programmaticallyPressedButtons.Add("LOG");
if (mnemonic[37] != '.') if (mnemonic[37] != '.')
programmaticallyPressedButtons.Add("SQUARED"); programmaticallyPressedButtons.Add("SQUARED");
if (mnemonic[38] != '.') if (mnemonic[38] != '.')
programmaticallyPressedButtons.Add("NEG"); programmaticallyPressedButtons.Add("NEG");
if (mnemonic[39] != '.') if (mnemonic[39] != '.')
programmaticallyPressedButtons.Add("MATH"); programmaticallyPressedButtons.Add("MATH");
if (mnemonic[40] != '.') if (mnemonic[40] != '.')
programmaticallyPressedButtons.Add("ALPHA"); programmaticallyPressedButtons.Add("ALPHA");
if (mnemonic[41] != '.') if (mnemonic[41] != '.')
programmaticallyPressedButtons.Add("GRAPH"); programmaticallyPressedButtons.Add("GRAPH");
if (mnemonic[42] != '.') if (mnemonic[42] != '.')
programmaticallyPressedButtons.Add("TRACE"); programmaticallyPressedButtons.Add("TRACE");
if (mnemonic[43] != '.') if (mnemonic[43] != '.')
programmaticallyPressedButtons.Add("ZOOM"); programmaticallyPressedButtons.Add("ZOOM");
if (mnemonic[44] != '.') if (mnemonic[44] != '.')
programmaticallyPressedButtons.Add("WINDOW"); programmaticallyPressedButtons.Add("WINDOW");
if (mnemonic[45] != '.') if (mnemonic[45] != '.')
programmaticallyPressedButtons.Add("Y"); programmaticallyPressedButtons.Add("Y");
if (mnemonic[46] != '.') if (mnemonic[46] != '.')
programmaticallyPressedButtons.Add("2ND"); programmaticallyPressedButtons.Add("2ND");
if (mnemonic[47] != '.') if (mnemonic[47] != '.')
programmaticallyPressedButtons.Add("MODE"); programmaticallyPressedButtons.Add("MODE");
if (mnemonic[48] != '.') if (mnemonic[48] != '.')
programmaticallyPressedButtons.Add("DEL"); programmaticallyPressedButtons.Add("DEL");
if (mnemonic[49] != '.') if (mnemonic[49] != '.')
programmaticallyPressedButtons.Add("COMMA"); programmaticallyPressedButtons.Add("COMMA");
if (mnemonic[50] != '.') if (mnemonic[50] != '.')
programmaticallyPressedButtons.Add("SIN"); programmaticallyPressedButtons.Add("SIN");
} }
} }
} }
} }

View File

@ -5,156 +5,156 @@ using SlimDX.DirectInput;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public class GamePad public class GamePad
{ {
// ********************************** Static interface ********************************** // ********************************** Static interface **********************************
private static DirectInput dinput; private static DirectInput dinput;
public static List<GamePad> Devices; public static List<GamePad> Devices;
public static void Initialize() public static void Initialize()
{ {
if (dinput == null) if (dinput == null)
dinput = new DirectInput(); dinput = new DirectInput();
Devices = new List<GamePad>(); Devices = new List<GamePad>();
foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly)) foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly))
{ {
var joystick = new Joystick(dinput, device.InstanceGuid); var joystick = new Joystick(dinput, device.InstanceGuid);
joystick.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); joystick.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
foreach (DeviceObjectInstance deviceObject in joystick.GetObjects()) foreach (DeviceObjectInstance deviceObject in joystick.GetObjects())
{ {
if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0) if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0)
joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-1000, 1000); joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-1000, 1000);
} }
joystick.Acquire(); joystick.Acquire();
GamePad p = new GamePad(device.InstanceName, device.InstanceGuid, joystick); GamePad p = new GamePad(device.InstanceName, device.InstanceGuid, joystick);
Devices.Add(p); Devices.Add(p);
} }
} }
public static void UpdateAll() public static void UpdateAll()
{ {
foreach (var device in Devices) foreach (var device in Devices)
device.Update(); device.Update();
} }
// ********************************** Instance Members ********************************** // ********************************** Instance Members **********************************
private readonly string name; private readonly string name;
private readonly Guid guid; private readonly Guid guid;
private readonly Joystick joystick; private readonly Joystick joystick;
private JoystickState state = new JoystickState(); private JoystickState state = new JoystickState();
private bool[] buttons; private bool[] buttons;
private int[] pov; private int[] pov;
private GamePad(string name, Guid guid, Joystick joystick) private GamePad(string name, Guid guid, Joystick joystick)
{ {
this.name = name; this.name = name;
this.guid = guid; this.guid = guid;
this.joystick = joystick; this.joystick = joystick;
Update(); Update();
} }
public void Update() public void Update()
{ {
if (joystick.Acquire().IsFailure) if (joystick.Acquire().IsFailure)
return; return;
if (joystick.Poll().IsFailure) if (joystick.Poll().IsFailure)
return; return;
state = joystick.GetCurrentState(); state = joystick.GetCurrentState();
if (Result.Last.IsFailure) if (Result.Last.IsFailure)
return; return;
buttons = state.GetButtons(); buttons = state.GetButtons();
pov = state.GetPointOfViewControllers(); pov = state.GetPointOfViewControllers();
} }
public string Name { get { return name; } } public string Name { get { return name; } }
public Guid Guid { get { return guid; } } public Guid Guid { get { return guid; } }
public float X { get { return state.X / 1000f; } } public float X { get { return state.X / 1000f; } }
public float Y { get { return state.Y / 1000f; } } public float Y { get { return state.Y / 1000f; } }
public float Z { get { return state.Z / 1000f; } } public float Z { get { return state.Z / 1000f; } }
public bool[] Buttons { get { return buttons; } } public bool[] Buttons { get { return buttons; } }
public bool Up public bool Up
{ {
get get
{ {
if (state.Y < -250 || state.RotationY < -250) if (state.Y < -250 || state.RotationY < -250)
return true; return true;
foreach (int p in pov) foreach (int p in pov)
if (p.In(0, 4500, 31500)) if (p.In(0, 4500, 31500))
return true; return true;
return false; return false;
} }
} }
public bool Down public bool Down
{ {
get get
{ {
if (state.Y > 250 || state.RotationY > 250) if (state.Y > 250 || state.RotationY > 250)
return true; return true;
foreach (int p in pov) foreach (int p in pov)
if (p.In(13500, 18000, 22500)) if (p.In(13500, 18000, 22500))
return true; return true;
return false; return false;
} }
} }
public bool Left public bool Left
{ {
get get
{ {
if (state.X < -250 || state.RotationX < -250) if (state.X < -250 || state.RotationX < -250)
return true; return true;
foreach (int p in pov) foreach (int p in pov)
if (p.In(22500, 27000, 31500)) if (p.In(22500, 27000, 31500))
return true; return true;
return false; return false;
} }
} }
public bool Right public bool Right
{ {
get get
{ {
if (state.X > 250 || state.RotationX > 250) if (state.X > 250 || state.RotationX > 250)
return true; return true;
foreach (int p in pov) foreach (int p in pov)
if (p.In(4500, 9000, 13500)) if (p.In(4500, 9000, 13500))
return true; return true;
return false; return false;
} }
} }
/// <summary> /// <summary>
/// Note that this does not appear to work at this time. I probably need to have more infos. /// Note that this does not appear to work at this time. I probably need to have more infos.
/// </summary> /// </summary>
public void SetVibration(int left, int right) public void SetVibration(int left, int right)
{ {
int[] temp1, temp2; int[] temp1, temp2;
// my first clue that it doesnt work is that LEFT and RIGHT _ARENT USED_ // my first clue that it doesnt work is that LEFT and RIGHT _ARENT USED_
// I should just look for C++ examples instead of trying to look for SlimDX examples // I should just look for C++ examples instead of trying to look for SlimDX examples
var parameters = new EffectParameters(); var parameters = new EffectParameters();
parameters.Duration = 0x2710; parameters.Duration = 0x2710;
parameters.Gain = 0x2710; parameters.Gain = 0x2710;
parameters.SamplePeriod = 0; parameters.SamplePeriod = 0;
parameters.TriggerButton = 0; parameters.TriggerButton = 0;
parameters.TriggerRepeatInterval = 0x2710; parameters.TriggerRepeatInterval = 0x2710;
parameters.Flags = EffectFlags.None; parameters.Flags = EffectFlags.None;
parameters.GetAxes(out temp1, out temp2); parameters.GetAxes(out temp1, out temp2);
parameters.SetAxes(temp1, temp2); parameters.SetAxes(temp1, temp2);
var effect = new Effect(joystick, EffectGuid.ConstantForce); var effect = new Effect(joystick, EffectGuid.ConstantForce);
effect.SetParameters(parameters); effect.SetParameters(parameters);
effect.Start(1); effect.Start(1);
} }
} }
} }

View File

@ -3,40 +3,40 @@ using SlimDX.DirectInput;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public static class Input public static class Input
{ {
public static void Initialize() public static void Initialize()
{ {
KeyInput.Initialize(); KeyInput.Initialize();
GamePad.Initialize(); GamePad.Initialize();
} }
public static void Update() public static void Update()
{ {
KeyInput.Update(); KeyInput.Update();
GamePad.UpdateAll(); GamePad.UpdateAll();
} }
public static bool IsPressed(string control) public static bool IsPressed(string control)
{ {
string[] controls = control.Split('+'); string[] controls = control.Split('+');
for (int i=0; i<controls.Length; i++) for (int i = 0; i < controls.Length; i++)
{ {
if (IsPressedSingle(controls[i]) == false) if (IsPressedSingle(controls[i]) == false)
return false; return false;
} }
return true; return true;
} }
private static bool IsPressedSingle(string control) private static bool IsPressedSingle(string control)
{ {
if (string.IsNullOrEmpty(control)) if (string.IsNullOrEmpty(control))
return false; return false;
if (control.StartsWith("J1 ")) return GetGamePad(0, control.Substring(3)); if (control.StartsWith("J1 ")) return GetGamePad(0, control.Substring(3));
if (control.StartsWith("J2 ")) return GetGamePad(1, control.Substring(3)); if (control.StartsWith("J2 ")) return GetGamePad(1, control.Substring(3));
if (control.StartsWith("J3 ")) return GetGamePad(2, control.Substring(3)); if (control.StartsWith("J3 ")) return GetGamePad(2, control.Substring(3));
if (control.StartsWith("J4 ")) return GetGamePad(3, control.Substring(3)); if (control.StartsWith("J4 ")) return GetGamePad(3, control.Substring(3));
//Key z = Key.n //Key z = Key.n
Key z = Key.NumberPad4; Key z = Key.NumberPad4;
Key y = Key.LeftArrow; Key y = Key.LeftArrow;
@ -45,35 +45,35 @@ namespace BizHawk.MultiClient
int x = 0; int x = 0;
x++; x++;
} }
Key k = (Key) Enum.Parse(typeof(Key), control, true); Key k = (Key)Enum.Parse(typeof(Key), control, true);
return KeyInput.IsPressed(k); return KeyInput.IsPressed(k);
} }
private static bool GetGamePad(int index, string control) private static bool GetGamePad(int index, string control)
{ {
if (index >= GamePad.Devices.Count) if (index >= GamePad.Devices.Count)
return false; return false;
if (control == "Up") return GamePad.Devices[index].Up; if (control == "Up") return GamePad.Devices[index].Up;
if (control == "Down") return GamePad.Devices[index].Down; if (control == "Down") return GamePad.Devices[index].Down;
if (control == "Left") return GamePad.Devices[index].Left; if (control == "Left") return GamePad.Devices[index].Left;
if (control == "Right") return GamePad.Devices[index].Right; if (control == "Right") return GamePad.Devices[index].Right;
if (control.StartsWith("B")) if (control.StartsWith("B"))
{ {
int buttonIndex = int.Parse(control.Substring(1)) - 1; int buttonIndex = int.Parse(control.Substring(1)) - 1;
if (buttonIndex >= GamePad.Devices[index].Buttons.Length) if (buttonIndex >= GamePad.Devices[index].Buttons.Length)
return false; return false;
return GamePad.Devices[index].Buttons[buttonIndex]; return GamePad.Devices[index].Buttons[buttonIndex];
} }
return false; return false;
} }
public static string GetPressedKey() public static string GetPressedKey()
{ {
//for (int j = 0; j < GamePad.Devices.Count; j++) //for (int j = 0; j < GamePad.Devices.Count; j++)
return null; return null;
} }
} }
} }

View File

@ -1,53 +1,53 @@
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public class MruStack<T> public class MruStack<T>
{ {
private T[] store; private T[] store;
private int count; private int count;
private int head; private int head;
public int Count { get { return count; } } public int Count { get { return count; } }
public MruStack(int capacity) public MruStack(int capacity)
{ {
store = new T[capacity]; store = new T[capacity];
Clear(); Clear();
} }
public void Clear() public void Clear()
{ {
head = 0; head = 0;
count = 0; count = 0;
for (int i = 0; i < store.Length; i++) for (int i = 0; i < store.Length; i++)
store[i] = default(T); store[i] = default(T);
} }
public void Push(T value) public void Push(T value)
{ {
store[head] = value; store[head] = value;
head = (head + 1) % store.Length; head = (head + 1) % store.Length;
if (count < store.Length) if (count < store.Length)
count++; count++;
} }
public T Pop() public T Pop()
{ {
if (count == 0) if (count == 0)
return default(T); return default(T);
head--; head--;
if (head < 0) if (head < 0)
head = store.Length - 1; head = store.Length - 1;
count--; count--;
T value = store[head]; T value = store[head];
store[head] = default(T); store[head] = default(T);
return value; return value;
} }
public bool HasElements() public bool HasElements()
{ {
return count > 0; return count > 0;
} }
} }
} }

View File

@ -6,21 +6,22 @@ using Microsoft.VisualBasic.ApplicationServices;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
static class Program static class Program
{ {
[STAThread] [STAThread]
static void Main(string[] args) static void Main(string[] args)
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath); Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath);
try { Global.DSound = new DirectSound(); } try { Global.DSound = new DirectSound(); }
catch { catch
MessageBox.Show("Couldn't initialize DirectSound!"); {
return; MessageBox.Show("Couldn't initialize DirectSound!");
} return;
}
try { Global.Direct3D = new Direct3D(); } try { Global.Direct3D = new Direct3D(); }
catch catch
@ -29,55 +30,60 @@ namespace BizHawk.MultiClient
Global.Config.ForceGDI = true; Global.Config.ForceGDI = true;
} }
try { try
if (Global.Config.SingleInstanceMode) {
{ if (Global.Config.SingleInstanceMode)
SingleInstanceController controller = new SingleInstanceController(args); {
controller.Run(args); SingleInstanceController controller = new SingleInstanceController(args);
} controller.Run(args);
else }
{ else
var mf = new MainForm(args); {
mf.Show(); var mf = new MainForm(args);
mf.ProgramRunLoop(); mf.Show();
} mf.ProgramRunLoop();
} catch (Exception e) { }
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Oh, no, a terrible thing happened!\n\n" + e.ToString()); MessageBox.Show(e.ToString(), "Oh, no, a terrible thing happened!\n\n" + e.ToString());
} finally { }
if (Global.DSound != null && Global.DSound.Disposed == false) finally
Global.DSound.Dispose(); {
if (Global.Direct3D != null && Global.Direct3D.Disposed == false) if (Global.DSound != null && Global.DSound.Disposed == false)
Global.Direct3D.Dispose(); Global.DSound.Dispose();
} if (Global.Direct3D != null && Global.Direct3D.Disposed == false)
Global.Direct3D.Dispose();
}
} }
public class SingleInstanceController : WindowsFormsApplicationBase public class SingleInstanceController : WindowsFormsApplicationBase
{ {
MainForm mf; MainForm mf;
string[] cmdArgs; string[] cmdArgs;
public SingleInstanceController(string[] args) public SingleInstanceController(string[] args)
{ {
cmdArgs = args; cmdArgs = args;
IsSingleInstance = true; IsSingleInstance = true;
StartupNextInstance += this_StartupNextInstance; StartupNextInstance += this_StartupNextInstance;
} }
void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e) void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
{ {
mf.LoadRom(e.CommandLine[0]); mf.LoadRom(e.CommandLine[0]);
} }
protected override void OnCreateMainForm() protected override void OnCreateMainForm()
{ {
MainForm = new RamWatch(); MainForm = new RamWatch();
mf = new MainForm(cmdArgs); mf = new MainForm(cmdArgs);
MainForm = mf; MainForm = mf;
mf.Show(); mf.Show();
mf.ProgramRunLoop(); mf.ProgramRunLoop();
} }
} }
} }
} }

View File

@ -3,84 +3,84 @@ using System.Text;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public class RecentFiles public class RecentFiles
{ {
private int MAX_RECENT_FILES; //Maximum number of files private int MAX_RECENT_FILES; //Maximum number of files
private List<string> recentlist; //List of recent files private List<string> recentlist; //List of recent files
public RecentFiles() : this(8) {} public RecentFiles() : this(8) { }
public RecentFiles(int max) public RecentFiles(int max)
{ {
recentlist = new List<string>(); recentlist = new List<string>();
MAX_RECENT_FILES = max; MAX_RECENT_FILES = max;
} }
public void Clear() public void Clear()
{ {
recentlist.Clear(); recentlist.Clear();
} }
public bool IsEmpty() public bool IsEmpty()
{ {
if (recentlist.Count == 0) if (recentlist.Count == 0)
return true; return true;
else else
return false; return false;
} }
public int Length() public int Length()
{ {
return recentlist.Count; return recentlist.Count;
} }
public void Add(string newFile) public void Add(string newFile)
{ {
for (int x = 0; x < recentlist.Count; x++) for (int x = 0; x < recentlist.Count; x++)
{ {
if (string.Compare(newFile, recentlist[x]) == 0) if (string.Compare(newFile, recentlist[x]) == 0)
{ {
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
} }
} }
recentlist.Insert(0, newFile); recentlist.Insert(0, newFile);
if (recentlist.Count > MAX_RECENT_FILES) if (recentlist.Count > MAX_RECENT_FILES)
recentlist.Remove(recentlist[recentlist.Count-1]); recentlist.Remove(recentlist[recentlist.Count - 1]);
} }
public bool Remove(string newFile) public bool Remove(string newFile)
{ {
bool removed = false; bool removed = false;
for (int x = 0; x < recentlist.Count; x++) for (int x = 0; x < recentlist.Count; x++)
{ {
if (string.Compare(newFile, recentlist[x]) == 0) if (string.Compare(newFile, recentlist[x]) == 0)
{ {
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
removed = true; removed = true;
} }
} }
return removed; return removed;
} }
public List<string> GetRecentList() public List<string> GetRecentList()
{ {
return recentlist; return recentlist;
} }
public List<string> GetRecentListTruncated(int length) public List<string> GetRecentListTruncated(int length)
{ {
//iterate through list, truncating each item to length, and return the result in a List<string> //iterate through list, truncating each item to length, and return the result in a List<string>
List<string> temp = new List<string>(); List<string> temp = new List<string>();
for (int x = 0; x < recentlist.Count; x++) for (int x = 0; x < recentlist.Count; x++)
{ {
temp.Add(recentlist[x].Substring(0, length)); temp.Add(recentlist[x].Substring(0, length));
} }
return temp; return temp;
} }
public string GetRecentFileByPosition(int position) public string GetRecentFileByPosition(int position)
{ {
return recentlist[position]; return recentlist[position];
} }
} }
} }

View File

@ -3,45 +3,45 @@ using System.Runtime.InteropServices;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
// Derived from http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx // Derived from http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx
public static class ScreenSaver public static class ScreenSaver
{ {
[DllImport("user32.dll", CharSet = CharSet.Auto)] [DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags); private static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags);
private const int SPI_GETSCREENSAVERTIMEOUT = 14; private const int SPI_GETSCREENSAVERTIMEOUT = 14;
private const int SPI_SETSCREENSAVERTIMEOUT = 15; private const int SPI_SETSCREENSAVERTIMEOUT = 15;
private const int SPIF_SENDWININICHANGE = 2; private const int SPIF_SENDWININICHANGE = 2;
public static void ResetTimerImmediate() public static void ResetTimerImmediate()
{ {
SetScreenSaverTimeout(GetScreenSaverTimeout()); SetScreenSaverTimeout(GetScreenSaverTimeout());
} }
private static int ctr; private static int ctr;
public static void ResetTimerPeriodically() public static void ResetTimerPeriodically()
{ {
ctr++; ctr++;
if (ctr == 120) if (ctr == 120)
{ {
SetScreenSaverTimeout(GetScreenSaverTimeout()); SetScreenSaverTimeout(GetScreenSaverTimeout());
ctr = 0; ctr = 0;
} }
} }
// Returns the screen saver timeout setting, in seconds // Returns the screen saver timeout setting, in seconds
private static Int32 GetScreenSaverTimeout() private static Int32 GetScreenSaverTimeout()
{ {
Int32 value = 0; Int32 value = 0;
SystemParametersInfo(SPI_GETSCREENSAVERTIMEOUT, 0, ref value, 0); SystemParametersInfo(SPI_GETSCREENSAVERTIMEOUT, 0, ref value, 0);
return value; return value;
} }
// Pass in the number of seconds to set the screen saver timeout value. // Pass in the number of seconds to set the screen saver timeout value.
private static void SetScreenSaverTimeout(Int32 Value) private static void SetScreenSaverTimeout(Int32 Value)
{ {
int nullVar = 0; int nullVar = 0;
SystemParametersInfo(SPI_SETSCREENSAVERTIMEOUT, Value, ref nullVar, SPIF_SENDWININICHANGE); SystemParametersInfo(SPI_SETSCREENSAVERTIMEOUT, Value, ref nullVar, SPIF_SENDWININICHANGE);
} }
} }
} }

View File

@ -9,180 +9,180 @@ using System.Windows.Forms;
namespace BizHawk.MultiClient.tools namespace BizHawk.MultiClient.tools
{ {
public partial class HotkeyWindow : Form public partial class HotkeyWindow : Form
{ {
public HotkeyWindow() public HotkeyWindow()
{ {
InitializeComponent(); InitializeComponent();
IDW_FRAMEADVANCE.Text = Global.Config.FrameAdvanceBinding; IDW_FRAMEADVANCE.Text = Global.Config.FrameAdvanceBinding;
IDW_PAUSE.Text = Global.Config.EmulatorPauseBinding; IDW_PAUSE.Text = Global.Config.EmulatorPauseBinding;
IDW_HARDRESET.Text = Global.Config.HardResetBinding; IDW_HARDRESET.Text = Global.Config.HardResetBinding;
IDW_REWIND.Text = Global.Config.RewindBinding; IDW_REWIND.Text = Global.Config.RewindBinding;
IDW_UNTHROTTLE.Text = Global.Config.UnthrottleBinding; IDW_UNTHROTTLE.Text = Global.Config.UnthrottleBinding;
IDW_FASTFORWARD.Text = Global.Config.FastForwardBinding; IDW_FASTFORWARD.Text = Global.Config.FastForwardBinding;
IDW_SCREENSHOT.Text = Global.Config.ScreenshotBinding; IDW_SCREENSHOT.Text = Global.Config.ScreenshotBinding;
IDW_FULLSCREEN.Text = Global.Config.ToggleFullscreenBinding; IDW_FULLSCREEN.Text = Global.Config.ToggleFullscreenBinding;
IDW_QuickSave.Text = Global.Config.QuickSave; IDW_QuickSave.Text = Global.Config.QuickSave;
IDW_QuickLoad.Text = Global.Config.QuickLoad; IDW_QuickLoad.Text = Global.Config.QuickLoad;
//Save States //Save States
IDW_SS0.Text = Global.Config.SaveSlot0; IDW_SS0.Text = Global.Config.SaveSlot0;
IDW_SS1.Text = Global.Config.SaveSlot1; IDW_SS1.Text = Global.Config.SaveSlot1;
IDW_SS2.Text = Global.Config.SaveSlot2; IDW_SS2.Text = Global.Config.SaveSlot2;
IDW_SS3.Text = Global.Config.SaveSlot3; IDW_SS3.Text = Global.Config.SaveSlot3;
IDW_SS4.Text = Global.Config.SaveSlot4; IDW_SS4.Text = Global.Config.SaveSlot4;
IDW_SS5.Text = Global.Config.SaveSlot5; IDW_SS5.Text = Global.Config.SaveSlot5;
IDW_SS6.Text = Global.Config.SaveSlot6; IDW_SS6.Text = Global.Config.SaveSlot6;
IDW_SS7.Text = Global.Config.SaveSlot7; IDW_SS7.Text = Global.Config.SaveSlot7;
IDW_SS8.Text = Global.Config.SaveSlot8; IDW_SS8.Text = Global.Config.SaveSlot8;
IDW_SS9.Text = Global.Config.SaveSlot9; IDW_SS9.Text = Global.Config.SaveSlot9;
//Load States //Load States
IDW_LS0.Text = Global.Config.LoadSlot0; IDW_LS0.Text = Global.Config.LoadSlot0;
IDW_LS1.Text = Global.Config.LoadSlot1; IDW_LS1.Text = Global.Config.LoadSlot1;
IDW_LS2.Text = Global.Config.LoadSlot2; IDW_LS2.Text = Global.Config.LoadSlot2;
IDW_LS3.Text = Global.Config.LoadSlot3; IDW_LS3.Text = Global.Config.LoadSlot3;
IDW_LS4.Text = Global.Config.LoadSlot4; IDW_LS4.Text = Global.Config.LoadSlot4;
IDW_LS5.Text = Global.Config.LoadSlot5; IDW_LS5.Text = Global.Config.LoadSlot5;
IDW_LS6.Text = Global.Config.LoadSlot6; IDW_LS6.Text = Global.Config.LoadSlot6;
IDW_LS7.Text = Global.Config.LoadSlot7; IDW_LS7.Text = Global.Config.LoadSlot7;
IDW_LS8.Text = Global.Config.LoadSlot8; IDW_LS8.Text = Global.Config.LoadSlot8;
IDW_LS9.Text = Global.Config.LoadSlot9; IDW_LS9.Text = Global.Config.LoadSlot9;
//Select States //Select States
IDW_ST0.Text = Global.Config.SelectSlot0; IDW_ST0.Text = Global.Config.SelectSlot0;
IDW_ST1.Text = Global.Config.SelectSlot1; IDW_ST1.Text = Global.Config.SelectSlot1;
IDW_ST2.Text = Global.Config.SelectSlot2; IDW_ST2.Text = Global.Config.SelectSlot2;
IDW_ST3.Text = Global.Config.SelectSlot3; IDW_ST3.Text = Global.Config.SelectSlot3;
IDW_ST4.Text = Global.Config.SelectSlot4; IDW_ST4.Text = Global.Config.SelectSlot4;
IDW_ST5.Text = Global.Config.SelectSlot5; IDW_ST5.Text = Global.Config.SelectSlot5;
IDW_ST6.Text = Global.Config.SelectSlot6; IDW_ST6.Text = Global.Config.SelectSlot6;
IDW_ST7.Text = Global.Config.SelectSlot7; IDW_ST7.Text = Global.Config.SelectSlot7;
IDW_ST8.Text = Global.Config.SelectSlot8; IDW_ST8.Text = Global.Config.SelectSlot8;
IDW_ST9.Text = Global.Config.SelectSlot9; IDW_ST9.Text = Global.Config.SelectSlot9;
IDW_TOOLBOX.Text = Global.Config.ToolBox; IDW_TOOLBOX.Text = Global.Config.ToolBox;
IDW_SAVENAMEDSTATE.Text = Global.Config.SaveNamedState; IDW_SAVENAMEDSTATE.Text = Global.Config.SaveNamedState;
IDW_LOADNAMEDSTATE.Text = Global.Config.LoadNamedState; IDW_LOADNAMEDSTATE.Text = Global.Config.LoadNamedState;
IDW_NEXTSLOT.Text = Global.Config.NextSlot; IDW_NEXTSLOT.Text = Global.Config.NextSlot;
IDW_PREVIOUSSLOT.Text = Global.Config.PreviousSlot; IDW_PREVIOUSSLOT.Text = Global.Config.PreviousSlot;
IDW_RamWatch.Text = Global.Config.RamWatch; IDW_RamWatch.Text = Global.Config.RamWatch;
IDW_RamSearch.Text = Global.Config.RamSearch; IDW_RamSearch.Text = Global.Config.RamSearch;
IDW_RamPoke.Text = Global.Config.RamPoke; IDW_RamPoke.Text = Global.Config.RamPoke;
IDW_HexEditor.Text = Global.Config.HexEditor; IDW_HexEditor.Text = Global.Config.HexEditor;
IDW_LuaConsole.Text = Global.Config.LuaConsole; IDW_LuaConsole.Text = Global.Config.LuaConsole;
IDW_Cheats.Text = Global.Config.Cheats; IDW_Cheats.Text = Global.Config.Cheats;
IDW_OpenROM.Text = Global.Config.OpenROM; IDW_OpenROM.Text = Global.Config.OpenROM;
IDW_CloseROM.Text = Global.Config.CloseROM; IDW_CloseROM.Text = Global.Config.CloseROM;
IDW_DisplayFPS.Text = Global.Config.FPSBinding; IDW_DisplayFPS.Text = Global.Config.FPSBinding;
IDW_FrameCounter.Text = Global.Config.FrameCounterBinding; IDW_FrameCounter.Text = Global.Config.FrameCounterBinding;
IDW_LagCounter.Text = Global.Config.LagCounterBinding; IDW_LagCounter.Text = Global.Config.LagCounterBinding;
IDW_InputDisplay.Text = Global.Config.InputDisplayBinding; IDW_InputDisplay.Text = Global.Config.InputDisplayBinding;
IDW_TOGGLEREADONLY.Text = Global.Config.ReadOnlyToggleBinding; IDW_TOGGLEREADONLY.Text = Global.Config.ReadOnlyToggleBinding;
IDW_PLAYMOVIE.Text = Global.Config.PlayMovieBinding; IDW_PLAYMOVIE.Text = Global.Config.PlayMovieBinding;
IDW_RECORDMOVIE.Text = Global.Config.RecordMovieBinding; IDW_RECORDMOVIE.Text = Global.Config.RecordMovieBinding;
IDW_STOPMOVIE.Text = Global.Config.StopMovieBinding; IDW_STOPMOVIE.Text = Global.Config.StopMovieBinding;
IDW_PLAYBEGINNING.Text = Global.Config.PlayBeginningBinding; IDW_PLAYBEGINNING.Text = Global.Config.PlayBeginningBinding;
IDW_VOLUP.Text = Global.Config.VolUpBinding; IDW_VOLUP.Text = Global.Config.VolUpBinding;
IDW_VOLDOWN.Text = Global.Config.VolDownBinding; IDW_VOLDOWN.Text = Global.Config.VolDownBinding;
IDW_TOGGLEMTRACK.Text = Global.Config.ToggleMultiTrack; IDW_TOGGLEMTRACK.Text = Global.Config.ToggleMultiTrack;
IDW_SELECTNONE.Text = Global.Config.MTRecordNone; IDW_SELECTNONE.Text = Global.Config.MTRecordNone;
IDW_MTSELECTALL.Text = Global.Config.MTRecordAll; IDW_MTSELECTALL.Text = Global.Config.MTRecordAll;
IDW_MTINCPLAYER.Text = Global.Config.MTIncrementPlayer; IDW_MTINCPLAYER.Text = Global.Config.MTIncrementPlayer;
IDW_MTDECPLAYER.Text = Global.Config.MTDecrementPlayer; IDW_MTDECPLAYER.Text = Global.Config.MTDecrementPlayer;
} }
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
{ {
this.Close(); this.Close();
} }
private void IDB_SAVE_Click(object sender, EventArgs e) private void IDB_SAVE_Click(object sender, EventArgs e)
{ {
Global.Config.FastForwardBinding = IDW_FASTFORWARD.Text; Global.Config.FastForwardBinding = IDW_FASTFORWARD.Text;
Global.Config.FrameAdvanceBinding = IDW_FRAMEADVANCE.Text; Global.Config.FrameAdvanceBinding = IDW_FRAMEADVANCE.Text;
Global.Config.HardResetBinding = IDW_HARDRESET.Text; Global.Config.HardResetBinding = IDW_HARDRESET.Text;
Global.Config.RewindBinding = IDW_REWIND.Text; Global.Config.RewindBinding = IDW_REWIND.Text;
Global.Config.UnthrottleBinding = IDW_UNTHROTTLE.Text; Global.Config.UnthrottleBinding = IDW_UNTHROTTLE.Text;
Global.Config.EmulatorPauseBinding = IDW_PAUSE.Text; Global.Config.EmulatorPauseBinding = IDW_PAUSE.Text;
Global.Config.ToggleFullscreenBinding = IDW_FULLSCREEN.Text; Global.Config.ToggleFullscreenBinding = IDW_FULLSCREEN.Text;
Global.Config.ScreenshotBinding = IDW_SCREENSHOT.Text; Global.Config.ScreenshotBinding = IDW_SCREENSHOT.Text;
Global.Config.QuickLoad = IDW_QuickLoad.Text; Global.Config.QuickLoad = IDW_QuickLoad.Text;
Global.Config.QuickSave = IDW_QuickSave.Text; Global.Config.QuickSave = IDW_QuickSave.Text;
Global.Config.SaveSlot0 = IDW_SS0.Text; Global.Config.SaveSlot0 = IDW_SS0.Text;
Global.Config.SaveSlot1 = IDW_SS1.Text; Global.Config.SaveSlot1 = IDW_SS1.Text;
Global.Config.SaveSlot2 = IDW_SS2.Text; Global.Config.SaveSlot2 = IDW_SS2.Text;
Global.Config.SaveSlot3 = IDW_SS3.Text; Global.Config.SaveSlot3 = IDW_SS3.Text;
Global.Config.SaveSlot4 = IDW_SS4.Text; Global.Config.SaveSlot4 = IDW_SS4.Text;
Global.Config.SaveSlot5 = IDW_SS5.Text; Global.Config.SaveSlot5 = IDW_SS5.Text;
Global.Config.SaveSlot6 = IDW_SS6.Text; Global.Config.SaveSlot6 = IDW_SS6.Text;
Global.Config.SaveSlot7 = IDW_SS7.Text; Global.Config.SaveSlot7 = IDW_SS7.Text;
Global.Config.SaveSlot8 = IDW_SS8.Text; Global.Config.SaveSlot8 = IDW_SS8.Text;
Global.Config.SaveSlot9 = IDW_SS9.Text; Global.Config.SaveSlot9 = IDW_SS9.Text;
Global.Config.LoadSlot0 = IDW_LS0.Text; Global.Config.LoadSlot0 = IDW_LS0.Text;
Global.Config.LoadSlot1 = IDW_LS1.Text; Global.Config.LoadSlot1 = IDW_LS1.Text;
Global.Config.LoadSlot2 = IDW_LS2.Text; Global.Config.LoadSlot2 = IDW_LS2.Text;
Global.Config.LoadSlot3 = IDW_LS3.Text; Global.Config.LoadSlot3 = IDW_LS3.Text;
Global.Config.LoadSlot4 = IDW_LS4.Text; Global.Config.LoadSlot4 = IDW_LS4.Text;
Global.Config.LoadSlot5 = IDW_LS5.Text; Global.Config.LoadSlot5 = IDW_LS5.Text;
Global.Config.LoadSlot6 = IDW_LS6.Text; Global.Config.LoadSlot6 = IDW_LS6.Text;
Global.Config.LoadSlot7 = IDW_LS7.Text; Global.Config.LoadSlot7 = IDW_LS7.Text;
Global.Config.LoadSlot8 = IDW_LS8.Text; Global.Config.LoadSlot8 = IDW_LS8.Text;
Global.Config.LoadSlot9 = IDW_LS9.Text; Global.Config.LoadSlot9 = IDW_LS9.Text;
Global.Config.SelectSlot0 = IDW_ST0.Text; Global.Config.SelectSlot0 = IDW_ST0.Text;
Global.Config.SelectSlot1 = IDW_ST1.Text; Global.Config.SelectSlot1 = IDW_ST1.Text;
Global.Config.SelectSlot2 = IDW_ST2.Text; Global.Config.SelectSlot2 = IDW_ST2.Text;
Global.Config.SelectSlot3 = IDW_ST3.Text; Global.Config.SelectSlot3 = IDW_ST3.Text;
Global.Config.SelectSlot4 = IDW_ST4.Text; Global.Config.SelectSlot4 = IDW_ST4.Text;
Global.Config.SelectSlot5 = IDW_ST5.Text; Global.Config.SelectSlot5 = IDW_ST5.Text;
Global.Config.SelectSlot6 = IDW_ST6.Text; Global.Config.SelectSlot6 = IDW_ST6.Text;
Global.Config.SelectSlot7 = IDW_ST7.Text; Global.Config.SelectSlot7 = IDW_ST7.Text;
Global.Config.SelectSlot8 = IDW_ST8.Text; Global.Config.SelectSlot8 = IDW_ST8.Text;
Global.Config.SelectSlot9 = IDW_ST9.Text; Global.Config.SelectSlot9 = IDW_ST9.Text;
Global.Config.ToolBox = IDW_TOOLBOX.Text; Global.Config.ToolBox = IDW_TOOLBOX.Text;
Global.Config.SaveNamedState = IDW_SAVENAMEDSTATE.Text; Global.Config.SaveNamedState = IDW_SAVENAMEDSTATE.Text;
Global.Config.LoadNamedState = IDW_LOADNAMEDSTATE.Text; Global.Config.LoadNamedState = IDW_LOADNAMEDSTATE.Text;
Global.Config.PreviousSlot = IDW_PREVIOUSSLOT.Text; Global.Config.PreviousSlot = IDW_PREVIOUSSLOT.Text;
Global.Config.NextSlot = IDW_NEXTSLOT.Text; Global.Config.NextSlot = IDW_NEXTSLOT.Text;
Global.Config.RamWatch = IDW_RamWatch.Text; Global.Config.RamWatch = IDW_RamWatch.Text;
Global.Config.RamSearch = IDW_RamSearch.Text; Global.Config.RamSearch = IDW_RamSearch.Text;
Global.Config.RamPoke = IDW_RamPoke.Text; Global.Config.RamPoke = IDW_RamPoke.Text;
Global.Config.HexEditor = IDW_HexEditor.Text; Global.Config.HexEditor = IDW_HexEditor.Text;
Global.Config.LuaConsole = IDW_LuaConsole.Text; Global.Config.LuaConsole = IDW_LuaConsole.Text;
Global.Config.Cheats = IDW_Cheats.Text; Global.Config.Cheats = IDW_Cheats.Text;
Global.Config.OpenROM = IDW_OpenROM.Text; Global.Config.OpenROM = IDW_OpenROM.Text;
Global.Config.CloseROM = IDW_CloseROM.Text; Global.Config.CloseROM = IDW_CloseROM.Text;
Global.Config.FPSBinding = IDW_DisplayFPS.Text; Global.Config.FPSBinding = IDW_DisplayFPS.Text;
Global.Config.FrameCounterBinding = IDW_FrameCounter.Text; Global.Config.FrameCounterBinding = IDW_FrameCounter.Text;
Global.Config.LagCounterBinding = IDW_LagCounter.Text; Global.Config.LagCounterBinding = IDW_LagCounter.Text;
Global.Config.InputDisplayBinding = IDW_InputDisplay.Text; Global.Config.InputDisplayBinding = IDW_InputDisplay.Text;
Global.Config.ReadOnlyToggleBinding = IDW_TOGGLEREADONLY.Text; Global.Config.ReadOnlyToggleBinding = IDW_TOGGLEREADONLY.Text;
Global.Config.PlayMovieBinding = IDW_PLAYMOVIE.Text; Global.Config.PlayMovieBinding = IDW_PLAYMOVIE.Text;
Global.Config.RecordMovieBinding = IDW_RECORDMOVIE.Text; Global.Config.RecordMovieBinding = IDW_RECORDMOVIE.Text;
Global.Config.StopMovieBinding = IDW_STOPMOVIE.Text; Global.Config.StopMovieBinding = IDW_STOPMOVIE.Text;
Global.Config.PlayBeginningBinding = IDW_PLAYBEGINNING.Text; Global.Config.PlayBeginningBinding = IDW_PLAYBEGINNING.Text;
Global.Config.VolUpBinding = IDW_VOLUP.Text; Global.Config.VolUpBinding = IDW_VOLUP.Text;
Global.Config.VolDownBinding = IDW_VOLDOWN.Text; Global.Config.VolDownBinding = IDW_VOLDOWN.Text;
Global.Config.ToggleMultiTrack = IDW_TOGGLEMTRACK.Text; Global.Config.ToggleMultiTrack = IDW_TOGGLEMTRACK.Text;
Global.Config.MTRecordAll = IDW_MTSELECTALL.Text; Global.Config.MTRecordAll = IDW_MTSELECTALL.Text;
Global.Config.MTRecordNone = IDW_SELECTNONE.Text; Global.Config.MTRecordNone = IDW_SELECTNONE.Text;
Global.Config.MTIncrementPlayer = IDW_MTINCPLAYER.Text; Global.Config.MTIncrementPlayer = IDW_MTINCPLAYER.Text;
Global.Config.MTDecrementPlayer = IDW_MTDECPLAYER.Text; Global.Config.MTDecrementPlayer = IDW_MTDECPLAYER.Text;
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;
this.Close(); this.Close();
} }
private void hotkeyTabs_SelectedIndexChanged(object sender, EventArgs e) private void hotkeyTabs_SelectedIndexChanged(object sender, EventArgs e)
{ {
hotkeyTabs.TabPages[hotkeyTabs.SelectedIndex].Controls[0].Focus(); hotkeyTabs.TabPages[hotkeyTabs.SelectedIndex].Controls[0].Focus();
} }
private void HotkeyWindow_Load(object sender, EventArgs e) private void HotkeyWindow_Load(object sender, EventArgs e)
{ {
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -5,58 +5,58 @@ using System.Text;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public class Cheat public class Cheat
{ {
//TODO: compare value (for NES) //TODO: compare value (for NES)
public string name { get; set; } public string name { get; set; }
public int address { get; set; } public int address { get; set; }
public byte value { get; set; } public byte value { get; set; }
public MemoryDomain domain { get; set; } public MemoryDomain domain { get; set; }
private bool enabled; private bool enabled;
public Cheat() public Cheat()
{ {
name = ""; name = "";
address = 0; address = 0;
value = 0; value = 0;
enabled = false; enabled = false;
domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { }); domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
} }
public Cheat(Cheat c) public Cheat(Cheat c)
{ {
name = c.name; name = c.name;
address = c.address; address = c.address;
value = c.value; value = c.value;
enabled = c.enabled; enabled = c.enabled;
domain = c.domain; domain = c.domain;
} }
public Cheat(string cname, int addr, byte val, bool e, MemoryDomain d) public Cheat(string cname, int addr, byte val, bool e, MemoryDomain d)
{ {
name = cname; name = cname;
address = addr; address = addr;
value = val; value = val;
enabled = e; enabled = e;
domain = d; domain = d;
} }
public void Enable() public void Enable()
{ {
enabled = true; enabled = true;
domain.SetFreeze(address, new MemoryDomain.FreezeData(MemoryDomain.FreezeData.Flag.Frozen, value)); domain.SetFreeze(address, new MemoryDomain.FreezeData(MemoryDomain.FreezeData.Flag.Frozen, value));
} }
public void Disable() public void Disable()
{ {
enabled = false; enabled = false;
domain.SetFreeze(address, MemoryDomain.FreezeData.Empty); domain.SetFreeze(address, MemoryDomain.FreezeData.Empty);
} }
public bool IsEnabled() public bool IsEnabled()
{ {
return enabled; return enabled;
} }
} }
} }

View File

@ -10,353 +10,353 @@ using System.Globalization;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public partial class HexEditor : Form public partial class HexEditor : Form
{ {
//TODO: //TODO:
//different back color for frozen addresses //different back color for frozen addresses
//Find text box - autohighlights matches, and shows total matches //Find text box - autohighlights matches, and shows total matches
//Users can customize background, & text colors //Users can customize background, & text colors
//Tool strip //Tool strip
//Text box showing currently highlighted address(es) & total //Text box showing currently highlighted address(es) & total
//Show num addresses in group box title (show "address" if 1 address) //Show num addresses in group box title (show "address" if 1 address)
//big font for currently mouse over'ed value? //big font for currently mouse over'ed value?
//Unfreeze All items - this one is tricky though, the dialog should keep track of //Unfreeze All items - this one is tricky though, the dialog should keep track of
// which addresses were frozen using this dialog (its own cheatList), and only // which addresses were frozen using this dialog (its own cheatList), and only
// remove those from the Cheats window cheat list // remove those from the Cheats window cheat list
int defaultWidth; int defaultWidth;
int defaultHeight; int defaultHeight;
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>(); List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
public HexEditor() public HexEditor()
{ {
InitializeComponent(); InitializeComponent();
Closing += (o, e) => SaveConfigSettings(); Closing += (o, e) => SaveConfigSettings();
} }
public void SaveConfigSettings() public void SaveConfigSettings()
{ {
if (Global.Config.HexEditorSaveWindowPosition) if (Global.Config.HexEditorSaveWindowPosition)
{ {
Global.Config.HexEditorWndx = this.Location.X; Global.Config.HexEditorWndx = this.Location.X;
Global.Config.HexEditorWndy = this.Location.Y; Global.Config.HexEditorWndy = this.Location.Y;
Global.Config.HexEditorWidth = this.Right - this.Left; Global.Config.HexEditorWidth = this.Right - this.Left;
Global.Config.HexEditorHeight = this.Bottom - this.Top; Global.Config.HexEditorHeight = this.Bottom - this.Top;
} }
} }
private void HexEditor_Load(object sender, EventArgs e) private void HexEditor_Load(object sender, EventArgs e)
{ {
defaultWidth = this.Size.Width; //Save these first so that the user can restore to its original size defaultWidth = this.Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = this.Size.Height; defaultHeight = this.Size.Height;
if (Global.Config.HexEditorSaveWindowPosition) if (Global.Config.HexEditorSaveWindowPosition)
{ {
if (Global.Config.HexEditorSaveWindowPosition && Global.Config.HexEditorWndx >= 0 && Global.Config.HexEditorWndy >= 0) if (Global.Config.HexEditorSaveWindowPosition && Global.Config.HexEditorWndx >= 0 && Global.Config.HexEditorWndy >= 0)
this.Location = new Point(Global.Config.HexEditorWndx, Global.Config.HexEditorWndy); this.Location = new Point(Global.Config.HexEditorWndx, Global.Config.HexEditorWndy);
if (Global.Config.HexEditorWidth >= 0 && Global.Config.HexEditorHeight >= 0) if (Global.Config.HexEditorWidth >= 0 && Global.Config.HexEditorHeight >= 0)
{ {
this.Size = new System.Drawing.Size(Global.Config.HexEditorWidth, Global.Config.HexEditorHeight); this.Size = new System.Drawing.Size(Global.Config.HexEditorWidth, Global.Config.HexEditorHeight);
} }
} }
SetMemoryDomainMenu(); SetMemoryDomainMenu();
} }
private void exitToolStripMenuItem_Click(object sender, EventArgs e) private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{ {
this.Close(); this.Close();
} }
public void UpdateValues() public void UpdateValues()
{ {
if (!this.IsHandleCreated || this.IsDisposed) return; if (!this.IsHandleCreated || this.IsDisposed) return;
MemoryViewer.Refresh(); MemoryViewer.Refresh();
} }
public void Restart() public void Restart()
{ {
if (!this.IsHandleCreated || this.IsDisposed) return; if (!this.IsHandleCreated || this.IsDisposed) return;
SetMemoryDomainMenu(); //Calls update routines SetMemoryDomainMenu(); //Calls update routines
MemoryViewer.ResetScrollBar(); MemoryViewer.ResetScrollBar();
} }
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e) private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{ {
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight); this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
} }
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e) private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.AutoLoadHexEditor ^= true; Global.Config.AutoLoadHexEditor ^= true;
} }
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e) private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
enToolStripMenuItem.Checked = MemoryViewer.BigEndian; enToolStripMenuItem.Checked = MemoryViewer.BigEndian;
switch (MemoryViewer.GetDataSize()) switch (MemoryViewer.GetDataSize())
{ {
default: default:
case 1: case 1:
byteToolStripMenuItem.Checked = true; byteToolStripMenuItem.Checked = true;
byteToolStripMenuItem1.Checked = false; byteToolStripMenuItem1.Checked = false;
byteToolStripMenuItem2.Checked = false; byteToolStripMenuItem2.Checked = false;
break; break;
case 2: case 2:
byteToolStripMenuItem.Checked = false; byteToolStripMenuItem.Checked = false;
byteToolStripMenuItem1.Checked = true; byteToolStripMenuItem1.Checked = true;
byteToolStripMenuItem2.Checked = false; byteToolStripMenuItem2.Checked = false;
break; break;
case 4: case 4:
byteToolStripMenuItem.Checked = false; byteToolStripMenuItem.Checked = false;
byteToolStripMenuItem1.Checked = false; byteToolStripMenuItem1.Checked = false;
byteToolStripMenuItem2.Checked = true; byteToolStripMenuItem2.Checked = true;
break; break;
} }
if (MemoryViewer.GetHighlightedAddress() >= 0) if (MemoryViewer.GetHighlightedAddress() >= 0)
{ {
addToRamWatchToolStripMenuItem1.Enabled = true; addToRamWatchToolStripMenuItem1.Enabled = true;
freezeAddressToolStripMenuItem.Enabled = true; freezeAddressToolStripMenuItem.Enabled = true;
} }
else else
{ {
addToRamWatchToolStripMenuItem1.Enabled = false; addToRamWatchToolStripMenuItem1.Enabled = false;
freezeAddressToolStripMenuItem.Enabled = false; freezeAddressToolStripMenuItem.Enabled = false;
} }
} }
private void SetMemoryDomain(int pos) private void SetMemoryDomain(int pos)
{ {
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{ {
MemoryViewer.SetMemoryDomain(Global.Emulator.MemoryDomains[pos]); MemoryViewer.SetMemoryDomain(Global.Emulator.MemoryDomains[pos]);
} }
UpdateDomainString(); UpdateDomainString();
MemoryViewer.ResetScrollBar(); MemoryViewer.ResetScrollBar();
} }
private void UpdateDomainString() private void UpdateDomainString()
{ {
string memoryDomain = MemoryViewer.GetMemoryDomainStr(); string memoryDomain = MemoryViewer.GetMemoryDomainStr();
string systemID = Global.Emulator.SystemId; string systemID = Global.Emulator.SystemId;
MemoryViewer.Text = systemID + " " + memoryDomain; MemoryViewer.Text = systemID + " " + memoryDomain;
} }
private void SetMemoryDomainMenu() private void SetMemoryDomainMenu()
{ {
memoryDomainsToolStripMenuItem.DropDownItems.Clear(); memoryDomainsToolStripMenuItem.DropDownItems.Clear();
if (Global.Emulator.MemoryDomains.Count > 0) if (Global.Emulator.MemoryDomains.Count > 0)
{ {
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++) for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
{ {
string str = Global.Emulator.MemoryDomains[x].ToString(); string str = Global.Emulator.MemoryDomains[x].ToString();
var item = new ToolStripMenuItem(); var item = new ToolStripMenuItem();
item.Text = str; item.Text = str;
{ {
int z = x; int z = x;
item.Click += (o, ev) => SetMemoryDomain(z); item.Click += (o, ev) => SetMemoryDomain(z);
} }
if (x == 0) if (x == 0)
{ {
SetMemoryDomain(x); SetMemoryDomain(x);
} }
memoryDomainsToolStripMenuItem.DropDownItems.Add(item); memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
domainMenuItems.Add(item); domainMenuItems.Add(item);
} }
} }
else else
memoryDomainsToolStripMenuItem.Enabled = false; memoryDomainsToolStripMenuItem.Enabled = false;
} }
public void GoToAddress(int address) public void GoToAddress(int address)
{ {
if (address < MemoryViewer.GetSize()) if (address < MemoryViewer.GetSize())
{ {
MemoryViewer.SetHighlighted(address); MemoryViewer.SetHighlighted(address);
MemoryViewer.Refresh(); MemoryViewer.Refresh();
} }
} }
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e) private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
{ {
InputPrompt i = new InputPrompt(); InputPrompt i = new InputPrompt();
i.Text = "Go to Address"; i.Text = "Go to Address";
i.SetMessage("Enter a hexadecimal value"); i.SetMessage("Enter a hexadecimal value");
i.ShowDialog(); i.ShowDialog();
if (i.UserOK) if (i.UserOK)
{ {
if (InputValidate.IsValidHexNumber(i.UserText)) if (InputValidate.IsValidHexNumber(i.UserText))
{ {
GoToAddress(int.Parse(i.UserText, NumberStyles.HexNumber)); GoToAddress(int.Parse(i.UserText, NumberStyles.HexNumber));
} }
} }
} }
private void HexEditor_Resize(object sender, EventArgs e) private void HexEditor_Resize(object sender, EventArgs e)
{ {
MemoryViewer.SetUpScrollBar(); MemoryViewer.SetUpScrollBar();
MemoryViewer.Refresh(); MemoryViewer.Refresh();
} }
private void byteToolStripMenuItem_Click(object sender, EventArgs e) private void byteToolStripMenuItem_Click(object sender, EventArgs e)
{ {
MemoryViewer.SetDataSize(1); MemoryViewer.SetDataSize(1);
} }
private void byteToolStripMenuItem1_Click(object sender, EventArgs e) private void byteToolStripMenuItem1_Click(object sender, EventArgs e)
{ {
MemoryViewer.SetDataSize(2); MemoryViewer.SetDataSize(2);
} }
private void byteToolStripMenuItem2_Click(object sender, EventArgs e) private void byteToolStripMenuItem2_Click(object sender, EventArgs e)
{ {
MemoryViewer.SetDataSize(4); MemoryViewer.SetDataSize(4);
} }
private void enToolStripMenuItem_Click(object sender, EventArgs e) private void enToolStripMenuItem_Click(object sender, EventArgs e)
{ {
MemoryViewer.BigEndian ^= true; MemoryViewer.BigEndian ^= true;
} }
private void MemoryViewer_Paint(object sender, PaintEventArgs e) private void MemoryViewer_Paint(object sender, PaintEventArgs e)
{ {
} }
private void AddToRamWatch() private void AddToRamWatch()
{ {
//Add to RAM Watch //Add to RAM Watch
int address = MemoryViewer.GetPointedAddress(); int address = MemoryViewer.GetPointedAddress();
if (address >= 0) if (address >= 0)
{ {
Watch w = new Watch(); Watch w = new Watch();
w.address = address; w.address = address;
switch (MemoryViewer.GetDataSize()) switch (MemoryViewer.GetDataSize())
{ {
default: default:
case 1: case 1:
w.type = atype.BYTE; w.type = atype.BYTE;
break; break;
case 2: case 2:
w.type = atype.WORD; w.type = atype.WORD;
break; break;
case 4: case 4:
w.type = atype.DWORD; w.type = atype.DWORD;
break; break;
} }
w.bigendian = MemoryViewer.BigEndian; w.bigendian = MemoryViewer.BigEndian;
w.signed = asigned.HEX; w.signed = asigned.HEX;
Global.MainForm.LoadRamWatch(); Global.MainForm.LoadRamWatch();
Global.MainForm.RamWatch1.AddWatch(w); Global.MainForm.RamWatch1.AddWatch(w);
} }
} }
private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e) private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e)
{ {
AddToRamWatch(); AddToRamWatch();
} }
private void pokeToolStripMenuItem_Click(object sender, EventArgs e) private void pokeToolStripMenuItem_Click(object sender, EventArgs e)
{ {
int p = MemoryViewer.GetPointedAddress(); int p = MemoryViewer.GetPointedAddress();
if (p >= 0) if (p >= 0)
{ {
InputPrompt i = new InputPrompt(); InputPrompt i = new InputPrompt();
i.Text = "Poke " + String.Format("{0:X}", p); i.Text = "Poke " + String.Format("{0:X}", p);
i.SetMessage("Enter a hexadecimal value"); i.SetMessage("Enter a hexadecimal value");
i.ShowDialog(); i.ShowDialog();
if (i.UserOK) if (i.UserOK)
{ {
if (InputValidate.IsValidHexNumber(i.UserText)) if (InputValidate.IsValidHexNumber(i.UserText))
{ {
int value = int.Parse(i.UserText, NumberStyles.HexNumber); int value = int.Parse(i.UserText, NumberStyles.HexNumber);
MemoryViewer.HighlightPointed(); MemoryViewer.HighlightPointed();
MemoryViewer.PokeHighlighted(value); MemoryViewer.PokeHighlighted(value);
} }
} }
} }
} }
private void addToRamWatchToolStripMenuItem_Click(object sender, EventArgs e) private void addToRamWatchToolStripMenuItem_Click(object sender, EventArgs e)
{ {
AddToRamWatch(); AddToRamWatch();
} }
private void addToRamWatchToolStripMenuItem1_Click(object sender, EventArgs e) private void addToRamWatchToolStripMenuItem1_Click(object sender, EventArgs e)
{ {
AddToRamWatch(); AddToRamWatch();
} }
private void saveWindowsSettingsToolStripMenuItem_Click(object sender, EventArgs e) private void saveWindowsSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.HexEditorSaveWindowPosition ^= true; Global.Config.HexEditorSaveWindowPosition ^= true;
} }
private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e) private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor; autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor;
saveWindowsSettingsToolStripMenuItem.Checked = Global.Config.HexEditorSaveWindowPosition; saveWindowsSettingsToolStripMenuItem.Checked = Global.Config.HexEditorSaveWindowPosition;
} }
private void freezeToolStripMenuItem_Click(object sender, EventArgs e) private void freezeToolStripMenuItem_Click(object sender, EventArgs e)
{ {
FreezeAddress(); FreezeAddress();
} }
private void FreezeAddress() private void FreezeAddress()
{ {
int address = MemoryViewer.GetPointedAddress(); int address = MemoryViewer.GetPointedAddress();
if (address >= 0) if (address >= 0)
{ {
Cheat c = new Cheat(); Cheat c = new Cheat();
c.address = address; c.address = address;
c.value = MemoryViewer.GetPointedValue(); c.value = MemoryViewer.GetPointedValue();
c.domain = MemoryViewer.GetDomain(); c.domain = MemoryViewer.GetDomain();
//TODO: multibyte //TODO: multibyte
switch (MemoryViewer.GetDataSize()) switch (MemoryViewer.GetDataSize())
{ {
default: default:
case 1: case 1:
break; break;
case 2: case 2:
break; break;
case 4: case 4:
break; break;
} }
//w.bigendian = MemoryViewer.BigEndian; //w.bigendian = MemoryViewer.BigEndian;
Global.MainForm.Cheats1.AddCheat(c); Global.MainForm.Cheats1.AddCheat(c);
} }
} }
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e) private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
{ {
FreezeAddress(); FreezeAddress();
} }
private void CheckDomainMenuItems() private void CheckDomainMenuItems()
{ {
for (int x = 0; x < domainMenuItems.Count; x++) for (int x = 0; x < domainMenuItems.Count; x++)
{ {
if (MemoryViewer.GetDomain().Name == domainMenuItems[x].Text) if (MemoryViewer.GetDomain().Name == domainMenuItems[x].Text)
domainMenuItems[x].Checked = true; domainMenuItems[x].Checked = true;
else else
domainMenuItems[x].Checked = false; domainMenuItems[x].Checked = false;
} }
} }
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e) private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
CheckDomainMenuItems(); CheckDomainMenuItems();
} }
} }
} }

View File

@ -10,233 +10,233 @@ using System.Globalization;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public partial class RamPoke : Form public partial class RamPoke : Form
{ {
//TODO: //TODO:
//If signed/unsigned/hex radios selected, auto-change the value box, and auto limit box length //If signed/unsigned/hex radios selected, auto-change the value box, and auto limit box length
//Checked signed/u/h value on RamPoke_Load and set value appopriately //Checked signed/u/h value on RamPoke_Load and set value appopriately
//Memory domain selection //Memory domain selection
//Output message, format number of digits appropriately //Output message, format number of digits appropriately
public Watch watch = new Watch(); public Watch watch = new Watch();
public Point location = new Point(); public Point location = new Point();
public RamPoke() public RamPoke()
{ {
InitializeComponent(); InitializeComponent();
} }
public void SetWatchObject(Watch w) public void SetWatchObject(Watch w)
{ {
watch = w; watch = w;
} }
private void RamPoke_Load(object sender, EventArgs e) private void RamPoke_Load(object sender, EventArgs e)
{ {
SetTypeRadio(watch.type); SetTypeRadio(watch.type);
SetSignedRadio(watch.signed); SetSignedRadio(watch.signed);
if (watch.bigendian == true) if (watch.bigendian == true)
BigEndianRadio.Checked = true; BigEndianRadio.Checked = true;
else else
LittleEndianRadio.Checked = true; LittleEndianRadio.Checked = true;
AddressBox.Text = String.Format("{0:X}", watch.address); AddressBox.Text = String.Format("{0:X}", watch.address);
ValueBox.Text = watch.value.ToString(); ValueBox.Text = watch.value.ToString();
if (location.X > 0 && location.Y > 0) if (location.X > 0 && location.Y > 0)
this.Location = location; this.Location = location;
} }
private void SetTypeRadio(atype a) private void SetTypeRadio(atype a)
{ {
switch (a) switch (a)
{ {
case atype.BYTE: case atype.BYTE:
Byte1Radio.Checked = true; Byte1Radio.Checked = true;
break; break;
case atype.WORD: case atype.WORD:
Byte2Radio.Checked = true; Byte2Radio.Checked = true;
break; break;
case atype.DWORD: case atype.DWORD:
Byte4Radio.Checked = true; Byte4Radio.Checked = true;
break; break;
default: default:
break; break;
} }
} }
private void SetSignedRadio(asigned a) private void SetSignedRadio(asigned a)
{ {
switch (a) switch (a)
{ {
case asigned.SIGNED: case asigned.SIGNED:
SignedRadio.Checked = true; SignedRadio.Checked = true;
break; break;
case asigned.UNSIGNED: case asigned.UNSIGNED:
UnsignedRadio.Checked = true; UnsignedRadio.Checked = true;
break; break;
case asigned.HEX: case asigned.HEX:
HexRadio.Checked = true; HexRadio.Checked = true;
break; break;
default: default:
break; break;
} }
} }
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
this.Close(); this.Close();
} }
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{ {
//Put user settings in the watch file //Put user settings in the watch file
if (InputValidate.IsValidHexNumber(AddressBox.Text)) if (InputValidate.IsValidHexNumber(AddressBox.Text))
watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
else else
{ {
MessageBox.Show("Invalid Address, must be a valid hex number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Invalid Address, must be a valid hex number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
AddressBox.Focus(); AddressBox.Focus();
AddressBox.SelectAll(); AddressBox.SelectAll();
return; return;
} }
if (SignedRadio.Checked) if (SignedRadio.Checked)
watch.signed = asigned.SIGNED; watch.signed = asigned.SIGNED;
else if (UnsignedRadio.Checked) else if (UnsignedRadio.Checked)
watch.signed = asigned.UNSIGNED; watch.signed = asigned.UNSIGNED;
else if (HexRadio.Checked) else if (HexRadio.Checked)
watch.signed = asigned.HEX; watch.signed = asigned.HEX;
if (Byte1Radio.Checked) if (Byte1Radio.Checked)
watch.type = atype.BYTE; watch.type = atype.BYTE;
else if (Byte2Radio.Checked) else if (Byte2Radio.Checked)
watch.type = atype.WORD; watch.type = atype.WORD;
else if (Byte4Radio.Checked) else if (Byte4Radio.Checked)
watch.type = atype.DWORD; watch.type = atype.DWORD;
if (BigEndianRadio.Checked) if (BigEndianRadio.Checked)
watch.bigendian = true; watch.bigendian = true;
else if (LittleEndianRadio.Checked) else if (LittleEndianRadio.Checked)
watch.bigendian = false; watch.bigendian = false;
int x = GetSpecificValue(); int x = GetSpecificValue();
if (x == -99999999) if (x == -99999999)
{ {
MessageBox.Show("Missing or invalid value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Missing or invalid value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
ValueBox.Focus(); ValueBox.Focus();
ValueBox.SelectAll(); ValueBox.SelectAll();
return; return;
} }
else else
watch.value = int.Parse(ValueBox.Text); watch.value = int.Parse(ValueBox.Text);
watch.PokeAddress(Global.Emulator.MainMemory); watch.PokeAddress(Global.Emulator.MainMemory);
//TODO: format value based on watch.type //TODO: format value based on watch.type
OutputLabel.Text = watch.value.ToString() + " written to " + String.Format("{0:X}", watch.address); OutputLabel.Text = watch.value.ToString() + " written to " + String.Format("{0:X}", watch.address);
} }
private void AddressBox_Leave(object sender, EventArgs e) private void AddressBox_Leave(object sender, EventArgs e)
{ {
AddressBox.Text = AddressBox.Text.Replace(" ", ""); AddressBox.Text = AddressBox.Text.Replace(" ", "");
if (!InputValidate.IsValidHexNumber(AddressBox.Text)) if (!InputValidate.IsValidHexNumber(AddressBox.Text))
{ {
AddressBox.Focus(); AddressBox.Focus();
AddressBox.SelectAll(); AddressBox.SelectAll();
ToolTip t = new ToolTip(); ToolTip t = new ToolTip();
t.Show("Must be a valid hexadecimal value", AddressBox, 5000); t.Show("Must be a valid hexadecimal value", AddressBox, 5000);
} }
} }
private void ValueBox_Leave(object sender, EventArgs e) private void ValueBox_Leave(object sender, EventArgs e)
{ {
ValueBox.Text = ValueBox.Text.Replace(" ", ""); ValueBox.Text = ValueBox.Text.Replace(" ", "");
if (!InputValidate.IsValidUnsignedNumber(ValueBox.Text)) if (!InputValidate.IsValidUnsignedNumber(ValueBox.Text))
{ {
ValueBox.Focus(); ValueBox.Focus();
ValueBox.SelectAll(); ValueBox.SelectAll();
ToolTip t = new ToolTip(); ToolTip t = new ToolTip();
t.Show("Must be a valid unsigned decimal value", ValueBox, 5000); t.Show("Must be a valid unsigned decimal value", ValueBox, 5000);
} }
} }
private asigned GetDataType() private asigned GetDataType()
{ {
if (SignedRadio.Checked) if (SignedRadio.Checked)
return asigned.UNSIGNED; return asigned.UNSIGNED;
if (UnsignedRadio.Checked) if (UnsignedRadio.Checked)
return asigned.SIGNED; return asigned.SIGNED;
if (HexRadio.Checked) if (HexRadio.Checked)
return asigned.HEX; return asigned.HEX;
return asigned.UNSIGNED; //Just in case return asigned.UNSIGNED; //Just in case
} }
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e) private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') return; if (e.KeyChar == '\b') return;
if (!InputValidate.IsValidHexNumber(e.KeyChar)) if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true; e.Handled = true;
} }
private void ValueBox_KeyPress(object sender, KeyPressEventArgs e) private void ValueBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') return; if (e.KeyChar == '\b') return;
switch (GetDataType()) switch (GetDataType())
{ {
case asigned.UNSIGNED: case asigned.UNSIGNED:
if (!InputValidate.IsValidUnsignedNumber(e.KeyChar)) if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
e.Handled = true; e.Handled = true;
break; break;
case asigned.SIGNED: case asigned.SIGNED:
if (!InputValidate.IsValidSignedNumber(e.KeyChar)) if (!InputValidate.IsValidSignedNumber(e.KeyChar))
e.Handled = true; e.Handled = true;
break; break;
case asigned.HEX: case asigned.HEX:
if (!InputValidate.IsValidHexNumber(e.KeyChar)) if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true; e.Handled = true;
break; break;
} }
} }
private atype GetDataSize() private atype GetDataSize()
{ {
if (Byte1Radio.Checked) if (Byte1Radio.Checked)
return atype.BYTE; return atype.BYTE;
if (Byte2Radio.Checked) if (Byte2Radio.Checked)
return atype.WORD; return atype.WORD;
if (Byte4Radio.Checked) if (Byte4Radio.Checked)
return atype.DWORD; return atype.DWORD;
return atype.BYTE; return atype.BYTE;
} }
private int GetSpecificValue() private int GetSpecificValue()
{ {
if (ValueBox.Text == "" || ValueBox.Text == "-") return 0; if (ValueBox.Text == "" || ValueBox.Text == "-") return 0;
bool i = false; bool i = false;
switch (GetDataType()) switch (GetDataType())
{ {
case asigned.UNSIGNED: case asigned.UNSIGNED:
i = InputValidate.IsValidUnsignedNumber(ValueBox.Text); i = InputValidate.IsValidUnsignedNumber(ValueBox.Text);
if (!i) return -99999999; if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe since 4 byte values can be entered return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe since 4 byte values can be entered
case asigned.SIGNED: case asigned.SIGNED:
i = InputValidate.IsValidSignedNumber(ValueBox.Text); i = InputValidate.IsValidSignedNumber(ValueBox.Text);
if (!i) return -99999999; if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text); return (int)Int64.Parse(ValueBox.Text);
case asigned.HEX: case asigned.HEX:
i = InputValidate.IsValidHexNumber(ValueBox.Text); i = InputValidate.IsValidHexNumber(ValueBox.Text);
if (!i) return -99999999; if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text, NumberStyles.HexNumber); return (int)Int64.Parse(ValueBox.Text, NumberStyles.HexNumber);
} }
return -99999999; //What are the odds someone wants to search for this value? return -99999999; //What are the odds someone wants to search for this value?
} }
} }
} }

View File

@ -10,154 +10,154 @@ using System.Globalization;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public partial class RamWatchNewWatch : Form public partial class RamWatchNewWatch : Form
{ {
public Watch watch = new Watch(); public Watch watch = new Watch();
public bool userSelected = false; public bool userSelected = false;
public bool customSetup = false; public bool customSetup = false;
public Point location = new Point(); public Point location = new Point();
public RamWatchNewWatch() public RamWatchNewWatch()
{ {
InitializeComponent(); InitializeComponent();
} }
private void SetTypeRadio(atype a) private void SetTypeRadio(atype a)
{ {
switch (a) switch (a)
{ {
case atype.BYTE: case atype.BYTE:
Byte1Radio.Checked = true; Byte1Radio.Checked = true;
break; break;
case atype.WORD: case atype.WORD:
Byte2Radio.Checked = true; Byte2Radio.Checked = true;
break; break;
case atype.DWORD: case atype.DWORD:
Byte4Radio.Checked = true; Byte4Radio.Checked = true;
break; break;
default: default:
break; break;
} }
} }
private void SetSignedRadio(asigned a) private void SetSignedRadio(asigned a)
{ {
switch (a) switch (a)
{ {
case asigned.SIGNED: case asigned.SIGNED:
SignedRadio.Checked = true; SignedRadio.Checked = true;
break; break;
case asigned.UNSIGNED: case asigned.UNSIGNED:
UnsignedRadio.Checked = true; UnsignedRadio.Checked = true;
break; break;
case asigned.HEX: case asigned.HEX:
HexRadio.Checked = true; HexRadio.Checked = true;
break; break;
default: default:
break; break;
} }
} }
public void SetToEditWatch(Watch w, string message) public void SetToEditWatch(Watch w, string message)
{ {
//Sets this dialog to Edit Watch and receives default values //Sets this dialog to Edit Watch and receives default values
this.Text = message; this.Text = message;
customSetup = true; customSetup = true;
AddressBox.Text = string.Format("{0:X4}", w.address); AddressBox.Text = string.Format("{0:X4}", w.address);
NotesBox.Text = w.notes; NotesBox.Text = w.notes;
SetTypeRadio(w.type); SetTypeRadio(w.type);
SetSignedRadio(w.signed); SetSignedRadio(w.signed);
if (w.bigendian == true) if (w.bigendian == true)
BigEndianRadio.Checked = true; BigEndianRadio.Checked = true;
else else
LittleEndianRadio.Checked = true; LittleEndianRadio.Checked = true;
} }
private void RamWatchNewWatch_Load(object sender, EventArgs e) private void RamWatchNewWatch_Load(object sender, EventArgs e)
{ {
if (!customSetup) if (!customSetup)
{ {
Watch w = new Watch(); Watch w = new Watch();
SetTypeRadio(w.type); SetTypeRadio(w.type);
SetSignedRadio(w.signed); SetSignedRadio(w.signed);
AddressBox.Text = "0000"; AddressBox.Text = "0000";
if (w.bigendian == true) if (w.bigendian == true)
BigEndianRadio.Checked = true; BigEndianRadio.Checked = true;
else else
LittleEndianRadio.Checked = true; LittleEndianRadio.Checked = true;
} }
if (location.X > 0 && location.Y > 0) if (location.X > 0 && location.Y > 0)
this.Location = location; this.Location = location;
} }
private void Cancel_Click(object sender, EventArgs e) private void Cancel_Click(object sender, EventArgs e)
{ {
userSelected = false; userSelected = false;
this.Close(); this.Close();
} }
private void OK_Click(object sender, EventArgs e) private void OK_Click(object sender, EventArgs e)
{ {
//Put user settings in the watch file //Put user settings in the watch file
userSelected = true; userSelected = true;
if (InputValidate.IsValidHexNumber(AddressBox.Text)) if (InputValidate.IsValidHexNumber(AddressBox.Text))
watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
else else
{ {
MessageBox.Show("Not a valid address (enter a valid Hex number)", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Not a valid address (enter a valid Hex number)", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
AddressBox.Focus(); AddressBox.Focus();
AddressBox.SelectAll(); AddressBox.SelectAll();
return; return;
} }
if (SignedRadio.Checked) if (SignedRadio.Checked)
watch.signed = asigned.SIGNED; watch.signed = asigned.SIGNED;
else if (UnsignedRadio.Checked) else if (UnsignedRadio.Checked)
watch.signed = asigned.UNSIGNED; watch.signed = asigned.UNSIGNED;
else if (HexRadio.Checked) else if (HexRadio.Checked)
watch.signed = asigned.HEX; watch.signed = asigned.HEX;
if (Byte1Radio.Checked) if (Byte1Radio.Checked)
watch.type = atype.BYTE; watch.type = atype.BYTE;
else if (Byte2Radio.Checked) else if (Byte2Radio.Checked)
watch.type = atype.WORD; watch.type = atype.WORD;
else if (Byte4Radio.Checked) else if (Byte4Radio.Checked)
watch.type = atype.DWORD; watch.type = atype.DWORD;
if (BigEndianRadio.Checked) if (BigEndianRadio.Checked)
watch.bigendian = true; watch.bigendian = true;
else if (LittleEndianRadio.Checked) else if (LittleEndianRadio.Checked)
watch.bigendian = false; watch.bigendian = false;
watch.notes = NotesBox.Text; watch.notes = NotesBox.Text;
this.Close(); this.Close();
} }
private void AddressBox_Leave(object sender, EventArgs e) private void AddressBox_Leave(object sender, EventArgs e)
{ {
AddressBox.Text = AddressBox.Text.Replace(" ", ""); AddressBox.Text = AddressBox.Text.Replace(" ", "");
if (!InputValidate.IsValidHexNumber(AddressBox.Text)) if (!InputValidate.IsValidHexNumber(AddressBox.Text))
{ {
AddressBox.Focus(); AddressBox.Focus();
AddressBox.SelectAll(); AddressBox.SelectAll();
ToolTip t = new ToolTip(); ToolTip t = new ToolTip();
t.Show("MUst be a valid hexadecimal vaue", AddressBox, 5000); t.Show("MUst be a valid hexadecimal vaue", AddressBox, 5000);
} }
} }
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e) private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') return; if (e.KeyChar == '\b') return;
if (!InputValidate.IsValidHexNumber(e.KeyChar)) if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true; e.Handled = true;
} }
} }
} }