CDL - add .cdl file map to dialogbox display
This commit is contained in:
parent
8497c25414
commit
1ce0437c3d
|
@ -74,38 +74,45 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void UpdateDisplay()
|
||||
{
|
||||
var lines = new List<string>();
|
||||
if (_cdl == null)
|
||||
{
|
||||
lines.Add("No CDL loaded.");
|
||||
CdlTextbox.Text = "No CDL loaded.";
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
sw.WriteLine("CDL contains the following domains:");
|
||||
foreach (var kvp in _cdl)
|
||||
{
|
||||
lines.Add("CDL contains the following domains:");
|
||||
foreach (var kvp in _cdl)
|
||||
int total = 0;
|
||||
unsafe
|
||||
{
|
||||
int total = 0;
|
||||
unsafe
|
||||
fixed (byte* data = kvp.Value)
|
||||
{
|
||||
fixed (byte* data = kvp.Value)
|
||||
byte* src = data;
|
||||
byte* end = data + kvp.Value.Length;
|
||||
while (src < end)
|
||||
{
|
||||
byte* src = data;
|
||||
byte* end = data + kvp.Value.Length;
|
||||
while (src < end)
|
||||
if (*src++ != 0)
|
||||
{
|
||||
if (*src++ != 0)
|
||||
{
|
||||
total++;
|
||||
}
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lines.Add(string.Format("Domain {0} Size {1} Mapped {2}% ({3}/{4} bytes)", kvp.Key, kvp.Value.Length, total / (float) kvp.Value.Length * 100f, total, kvp.Value.Length));
|
||||
}
|
||||
|
||||
sw.WriteLine("Domain {0} Size {1} Mapped {2}% ({3}/{4} bytes)", kvp.Key, kvp.Value.Length, total / (float)kvp.Value.Length * 100f, total, kvp.Value.Length);
|
||||
}
|
||||
|
||||
sw.WriteLine();
|
||||
|
||||
var bm = _cdl.GetBlockMap();
|
||||
foreach (var kvp in bm)
|
||||
{
|
||||
sw.WriteLine("{0:X8}: {1}", kvp.Value, kvp.Key);
|
||||
}
|
||||
|
||||
CdlTextbox.Lines = lines.ToArray();
|
||||
CdlTextbox.Text = sw.ToString();
|
||||
}
|
||||
|
||||
public bool AskSaveChanges()
|
||||
|
|
|
@ -71,17 +71,44 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
public void Save(Stream s)
|
||||
{
|
||||
_Save(s, true);
|
||||
}
|
||||
|
||||
Dictionary<string, long> _Save(Stream s, bool forReal)
|
||||
{
|
||||
var ret = new Dictionary<string, long>();
|
||||
var w = new BinaryWriter(s);
|
||||
w.Write("BIZHAWK-CDL-2");
|
||||
w.Write(SubType.PadRight(15));
|
||||
w.Write(Count);
|
||||
foreach (var kvp in this)
|
||||
w.Flush();
|
||||
long addr = s.Position;
|
||||
if (forReal)
|
||||
{
|
||||
w.Write(kvp.Key);
|
||||
w.Write(kvp.Value.Length);
|
||||
w.Write(kvp.Value);
|
||||
foreach (var kvp in this)
|
||||
{
|
||||
w.Write(kvp.Key);
|
||||
w.Write(kvp.Value.Length);
|
||||
w.Write(kvp.Value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kvp in this)
|
||||
{
|
||||
addr += kvp.Key.Length + 1; //assumes shortly-encoded key names
|
||||
addr += 4;
|
||||
ret[kvp.Key] = addr;
|
||||
addr += kvp.Value.Length;
|
||||
}
|
||||
}
|
||||
w.Flush();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Dictionary<string, long> GetBlockMap()
|
||||
{
|
||||
return _Save(new MemoryStream(), false);
|
||||
}
|
||||
|
||||
public void Load(Stream s)
|
||||
|
|
Loading…
Reference in New Issue