Skip to content
This repository was archived by the owner on Jan 16, 2020. It is now read-only.

Add legacy conversion #4

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions Rhydon/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,28 @@ private void openFile(byte[] input, string path, string ext)
}
else
{
Util.Error("Unable to recognize file." + Environment.NewLine + "Only valid .pk1/.bin supported.", string.Format($"File Loaded:{Environment.NewLine}{path}"));
Util.Error("Unable to recognize file." + Environment.NewLine + "Only valid .pk1/.bin supported.", $"File Loaded:{Environment.NewLine}{path}");
}
}
else if (input.Length == 0x38 || input.Length == 0x43)
{
// Legacy PK1 from PKXDelta / PikaSav
byte[] legacyInput = new byte[69];
legacyInput[0x00] = 0x01;
legacyInput[0x01] = input[0x00];
legacyInput[0x02] = 0xFF;
legacyInput[0x03] = input[0x00];
Array.Copy(input, 0x18, legacyInput, 0x04, 0x20);
Array.Copy(input, 0x01, legacyInput, 0x2F, 0x16);
PopulateFields(new PokemonList(legacyInput)[0]);
}
#endregion
#region SAV1
else if (input.Length == 0x8000 || input.Length == 0x802C)
{
if (ext != ".dat" && ext != ".sav")
{
Util.Error("Unable to recognize file." + Environment.NewLine + "Only valid .sav/.dat supported.", string.Format($"File Loaded:{Environment.NewLine}{path}"));
Util.Error("Unable to recognize file." + Environment.NewLine + "Only valid .sav/.dat supported.", $"File Loaded:{Environment.NewLine}{path}");
}
if (input.Length == 0x802C) // Support Emulator saves
Array.Resize(ref input, 0x8000);
Expand All @@ -506,13 +520,11 @@ private void openFile(byte[] input, string path, string ext)
// Indicate audibly the save is loaded
SystemSounds.Beep.Play();
}
#endregion
else
{
{
Util.Error("Unable to recognize file.", string.Format($"File Loaded:{Environment.NewLine}{path}"));
}
Util.Error("Unable to recognize file.", $"File Loaded:{Environment.NewLine}{path}");
}
#endregion
}

private void mainMenuSave(object sender, EventArgs e)
Expand Down