Accept other RAM dump variants

This commit is contained in:
Kurt
2015-08-22 19:19:52 -07:00
parent 2def9436fc
commit fdf10bd266
2 changed files with 5 additions and 3 deletions

View File

@@ -41,18 +41,19 @@ private void tabMain_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
string path = files[0]; // open first D&D
long len = new FileInfo(files[0]).Length;
if (Directory.Exists(path))
{
findLoop = false;
root = path;
L_IO.Text = root;
}
else if (new FileInfo(files[0]).Length == 0x80000) // RAM
else if (len == 0x80000 || len == 0xC0000 || len == 0x121000 || len == 0x130000) // RAM
{
if (Util.Prompt(MessageBoxButtons.YesNo, "Edit RAM Dump?" + Environment.NewLine + files[0]) == DialogResult.Yes)
{
byte[] data = File.ReadAllBytes(files[0]);
SaveData = new byte[0x7FA00];
SaveData = new byte[data.Length + 0x80]; // shift 0x80 bytes
Array.Copy(data, 0, SaveData, 0x80, SaveData.Length - 0x80);
new Garden().ShowDialog();
}

View File

@@ -136,7 +136,8 @@ private void B_Export_Click(object sender, EventArgs e)
return;
byte[] RAM = saveData().Skip(0x80).ToArray();
Array.Resize(ref RAM, 0x80000);
if (RAM.Length < 0x80000)
Array.Resize(ref RAM, 0x80000);
File.WriteAllBytes(sfd.FileName, RAM);
}