Basic Bot - ability to set datasize and endianness of ram values
This commit is contained in:
parent
81df9f1224
commit
eaaac167f1
|
@ -43,6 +43,10 @@
|
||||||
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.MemoryDomainsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.MemoryDomainsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.DataSizeMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this._1ByteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this._2ByteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this._4ByteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.BigEndianMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.BigEndianMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.TurboWhileBottingMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.TurboWhileBottingMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
@ -201,6 +205,7 @@
|
||||||
//
|
//
|
||||||
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.MemoryDomainsMenuItem,
|
this.MemoryDomainsMenuItem,
|
||||||
|
this.DataSizeMenuItem,
|
||||||
this.BigEndianMenuItem,
|
this.BigEndianMenuItem,
|
||||||
this.toolStripSeparator4,
|
this.toolStripSeparator4,
|
||||||
this.TurboWhileBottingMenuItem});
|
this.TurboWhileBottingMenuItem});
|
||||||
|
@ -223,6 +228,38 @@
|
||||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||||
this.toolStripSeparator3.Size = new System.Drawing.Size(57, 6);
|
this.toolStripSeparator3.Size = new System.Drawing.Size(57, 6);
|
||||||
//
|
//
|
||||||
|
// DataSizeMenuItem
|
||||||
|
//
|
||||||
|
this.DataSizeMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this._1ByteMenuItem,
|
||||||
|
this._2ByteMenuItem,
|
||||||
|
this._4ByteMenuItem});
|
||||||
|
this.DataSizeMenuItem.Name = "DataSizeMenuItem";
|
||||||
|
this.DataSizeMenuItem.Size = new System.Drawing.Size(181, 22);
|
||||||
|
this.DataSizeMenuItem.Text = "Data Size";
|
||||||
|
this.DataSizeMenuItem.DropDownOpened += new System.EventHandler(this.DataSizeMenuItem_DropDownOpened);
|
||||||
|
//
|
||||||
|
// _1ByteMenuItem
|
||||||
|
//
|
||||||
|
this._1ByteMenuItem.Name = "_1ByteMenuItem";
|
||||||
|
this._1ByteMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this._1ByteMenuItem.Text = "1 Byte";
|
||||||
|
this._1ByteMenuItem.Click += new System.EventHandler(this._1ByteMenuItem_Click);
|
||||||
|
//
|
||||||
|
// _2ByteMenuItem
|
||||||
|
//
|
||||||
|
this._2ByteMenuItem.Name = "_2ByteMenuItem";
|
||||||
|
this._2ByteMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this._2ByteMenuItem.Text = "2 Bytes";
|
||||||
|
this._2ByteMenuItem.Click += new System.EventHandler(this._2ByteMenuItem_Click);
|
||||||
|
//
|
||||||
|
// _4ByteMenuItem
|
||||||
|
//
|
||||||
|
this._4ByteMenuItem.Name = "_4ByteMenuItem";
|
||||||
|
this._4ByteMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
|
this._4ByteMenuItem.Text = "4 Bytes";
|
||||||
|
this._4ByteMenuItem.Click += new System.EventHandler(this._4ByteMenuItem_Click);
|
||||||
|
//
|
||||||
// BigEndianMenuItem
|
// BigEndianMenuItem
|
||||||
//
|
//
|
||||||
this.BigEndianMenuItem.Name = "BigEndianMenuItem";
|
this.BigEndianMenuItem.Name = "BigEndianMenuItem";
|
||||||
|
@ -879,5 +916,9 @@
|
||||||
private System.Windows.Forms.ToolStripStatusLabel BotStatusButton;
|
private System.Windows.Forms.ToolStripStatusLabel BotStatusButton;
|
||||||
private System.Windows.Forms.ToolStripMenuItem BigEndianMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem BigEndianMenuItem;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem DataSizeMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem _1ByteMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem _2ByteMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem _4ByteMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -52,6 +52,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private MemoryDomain _currentDomain;
|
private MemoryDomain _currentDomain;
|
||||||
private bool _bigEndian;
|
private bool _bigEndian;
|
||||||
|
private int _dataSize;
|
||||||
|
|
||||||
#region Services and Settings
|
#region Services and Settings
|
||||||
|
|
||||||
|
@ -328,6 +329,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
MemoryDomains.Contains(_currentDomain))
|
MemoryDomains.Contains(_currentDomain))
|
||||||
{
|
{
|
||||||
_currentDomain = MemoryDomains.MainMemory;
|
_currentDomain = MemoryDomains.MainMemory;
|
||||||
|
_bigEndian = _currentDomain.EndianType == MemoryDomain.Endian.Big;
|
||||||
|
_dataSize = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isBotting)
|
if (_isBotting)
|
||||||
|
@ -457,10 +460,32 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_bigEndian ^= true;
|
_bigEndian ^= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DataSizeMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_1ByteMenuItem.Checked = _dataSize == 1;
|
||||||
|
_2ByteMenuItem.Checked = _dataSize == 2;
|
||||||
|
_4ByteMenuItem.Checked = _dataSize == 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _1ByteMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_dataSize = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _2ByteMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_dataSize = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _4ByteMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_dataSize = 4;
|
||||||
|
}
|
||||||
|
|
||||||
private void TurboWhileBottingMenuItem_Click(object sender, EventArgs e)
|
private void TurboWhileBottingMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Settings.TurboWhenBotting ^= true;
|
Settings.TurboWhenBotting ^= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -536,6 +561,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public string FromSlot { get; set; }
|
public string FromSlot { get; set; }
|
||||||
public long Attempts { get; set; }
|
public long Attempts { get; set; }
|
||||||
public long Frames { get; set; }
|
public long Frames { get; set; }
|
||||||
|
|
||||||
|
public string MemoryDomain { get; set; }
|
||||||
|
public bool BigEndian { get; set; }
|
||||||
|
public int DataSize { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -584,6 +613,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Attempts = botData.Attempts;
|
Attempts = botData.Attempts;
|
||||||
Frames = botData.Frames;
|
Frames = botData.Frames;
|
||||||
|
|
||||||
|
_currentDomain = !string.IsNullOrWhiteSpace(botData.MemoryDomain)
|
||||||
|
? MemoryDomains[botData.MemoryDomain]
|
||||||
|
: MemoryDomains.MainMemory;
|
||||||
|
|
||||||
|
_bigEndian = botData.BigEndian;
|
||||||
|
_dataSize = botData.DataSize > 0 ? botData.DataSize : 1;
|
||||||
|
|
||||||
UpdateBestAttempt();
|
UpdateBestAttempt();
|
||||||
|
|
||||||
if (_bestBotAttempt != null)
|
if (_bestBotAttempt != null)
|
||||||
|
@ -611,7 +647,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
FromSlot = FromSlot,
|
FromSlot = FromSlot,
|
||||||
FrameLength = FrameLength,
|
FrameLength = FrameLength,
|
||||||
Attempts = Attempts,
|
Attempts = Attempts,
|
||||||
Frames = Frames
|
Frames = Frames,
|
||||||
|
MemoryDomain = _currentDomain.Name,
|
||||||
|
BigEndian = _bigEndian,
|
||||||
|
DataSize = _dataSize
|
||||||
};
|
};
|
||||||
|
|
||||||
var json = ConfigService.SaveWithType(data);
|
var json = ConfigService.SaveWithType(data);
|
||||||
|
@ -668,12 +707,27 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void SetMemoryDomain(string name)
|
private void SetMemoryDomain(string name)
|
||||||
{
|
{
|
||||||
_currentDomain = MemoryDomains[name];
|
_currentDomain = MemoryDomains[name];
|
||||||
|
_bigEndian = MemoryDomains[name].EndianType == MemoryDomain.Endian.Big;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetRamvalue(int addr)
|
private int GetRamvalue(int addr)
|
||||||
{
|
{
|
||||||
// TODO: ability to pick byte size/display type/endian
|
int val;
|
||||||
return _currentDomain.PeekByte(addr);
|
switch (_dataSize)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 1:
|
||||||
|
val = _currentDomain.PeekByte(addr);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
val = _currentDomain.PeekWord(addr, _bigEndian);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
val = (int)_currentDomain.PeekDWord(addr, _bigEndian);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update(bool fast)
|
private void Update(bool fast)
|
||||||
|
|
Loading…
Reference in New Issue