Debugger - Register box - properly detect flags and use button style and better positioning, convert register textboxes to hex, and set max length of the boxes appropriately given the size of the register
This commit is contained in:
parent
aba50b0f87
commit
0965475999
|
@ -42,6 +42,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
foreach (var register in registers)
|
||||
{
|
||||
Controls
|
||||
.OfType<Panel>()
|
||||
.First(p => p.Name == "FlagPanel")
|
||||
.Controls
|
||||
.OfType<CheckBox>()
|
||||
.ToList()
|
||||
.ForEach(checkbox =>
|
||||
|
@ -59,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (textbox.Name == register.Key)
|
||||
{
|
||||
textbox.Text = register.Value.ToString();
|
||||
textbox.Text = register.Value.Value.ToHexString(register.Value.BitSize / 16);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -118,7 +121,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var registers = Core.GetCpuFlagsAndRegisters();
|
||||
|
||||
int y = 0;
|
||||
foreach (var register in registers)
|
||||
foreach (var register in registers.Where(r => r.Value.BitSize != 1))
|
||||
{
|
||||
this.Controls.Add(new Label
|
||||
{
|
||||
|
@ -129,14 +132,71 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (canset)
|
||||
{
|
||||
if (register.Key.Contains("Flag")) // TODO: this depends on naming conventions!
|
||||
var t = new TextBox
|
||||
{
|
||||
Name = register.Key,
|
||||
Text = register.Value.Value.ToHexString(register.Value.BitSize / 16),
|
||||
Width = 45,
|
||||
Location = new Point(40, y),
|
||||
MaxLength = register.Value.BitSize / 4,
|
||||
CharacterCasing = CharacterCasing.Upper
|
||||
};
|
||||
|
||||
t.TextChanged += (o, e) =>
|
||||
{
|
||||
if (!_supressChangeEvents)
|
||||
{
|
||||
try
|
||||
{
|
||||
Core.SetCpuRegister(t.Name, int.Parse(t.Text));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
t.Enabled = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.Controls.Add(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Controls.Add(new Label
|
||||
{
|
||||
Name = register.Key,
|
||||
Text = register.Value.ToString(),
|
||||
Width = 45,
|
||||
Location = new Point(40, y)
|
||||
});
|
||||
}
|
||||
|
||||
y += 25;
|
||||
}
|
||||
|
||||
var flags = registers.Where(r => r.Value.BitSize == 1);
|
||||
|
||||
if (flags.Any())
|
||||
{
|
||||
var p = new Panel
|
||||
{
|
||||
Name = "FlagPanel",
|
||||
Location = new Point(5, y),
|
||||
BorderStyle = BorderStyle.None,
|
||||
Size = new Size(240, 23),
|
||||
AutoScroll = true
|
||||
};
|
||||
|
||||
foreach (var flag in registers.Where(r => r.Value.BitSize == 1).OrderByDescending(x => x.Key))
|
||||
{
|
||||
var c = new CheckBox
|
||||
{
|
||||
Name = register.Key,
|
||||
Text = "",
|
||||
Checked = register.Value.Value == 1 ? true : false,
|
||||
Location = new Point(40, y)
|
||||
Appearance = System.Windows.Forms.Appearance.Button,
|
||||
Name = flag.Key,
|
||||
Text = flag.Key.Replace("Flag", "").Trim(), // Hack
|
||||
Checked = flag.Value.Value == 1 ? true : false,
|
||||
Location = new Point(40, y),
|
||||
Dock = DockStyle.Left,
|
||||
Size = new Size(23, 23)
|
||||
};
|
||||
|
||||
c.CheckedChanged += (o, e) =>
|
||||
|
@ -157,48 +217,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
};
|
||||
|
||||
this.Controls.Add(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
var t = new TextBox
|
||||
{
|
||||
Name = register.Key,
|
||||
Text = register.Value.ToString(),
|
||||
Width = 45,
|
||||
Location = new Point(40, y),
|
||||
};
|
||||
|
||||
t.TextChanged += (o, e) =>
|
||||
{
|
||||
if (!_supressChangeEvents)
|
||||
{
|
||||
try
|
||||
{
|
||||
Core.SetCpuRegister(t.Name, int.Parse(t.Text));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
t.Enabled = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.Controls.Add(t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Controls.Add(new Label
|
||||
{
|
||||
Name = register.Key,
|
||||
Text = register.Value.ToString(),
|
||||
Width = 45,
|
||||
Location = new Point(40, y)
|
||||
});
|
||||
p.Controls.Add(c);
|
||||
}
|
||||
|
||||
y += 25;
|
||||
this.Controls.Add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,11 @@ namespace BizHawk.Common.NumberExtensions
|
|||
return string.Format("{0:X" + numdigits + "}", n);
|
||||
}
|
||||
|
||||
public static string ToHexString(this ulong n, int numdigits)
|
||||
{
|
||||
return string.Format("{0:X" + numdigits + "}", n);
|
||||
}
|
||||
|
||||
public static bool Bit(this byte b, int index)
|
||||
{
|
||||
return (b & (1 << index)) != 0;
|
||||
|
|
Loading…
Reference in New Issue