mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-11 07:04:16 +00:00
Remove ram2sav
Also removed injectiondebug and trade packet handling. Improved BAK suggested filename (last saved timestamp)
This commit is contained in:
parent
6ab7ba4bc1
commit
1c53243283
16 changed files with 43 additions and 321 deletions
141
Misc/ram2sav.cs
141
Misc/ram2sav.cs
|
@ -1,141 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX
|
||||
{
|
||||
class ram2sav
|
||||
{
|
||||
internal const uint UNKNOWNVAL = 0x96696996;
|
||||
internal static byte[] getMAIN(byte[] ramsav)
|
||||
{
|
||||
byte[] main;
|
||||
uint[] offsets;
|
||||
uint[] lens;
|
||||
uint[] magics;
|
||||
uint[] skips;
|
||||
uint[] instances;
|
||||
uint val = BitConverter.ToUInt32(ramsav, 0);
|
||||
uint spos = 0;
|
||||
if (ramsav.Length == 0x80000) // ORAS
|
||||
{
|
||||
offsets = new uint[] { 0x00005400, 0x00005800, 0x00006400, 0x00006600, 0x00006800, 0x00006A00, 0x00006C00, 0x00006E00, 0x00007000, 0x00007200, 0x00007400, 0x00009600, 0x00009800, 0x00009E00, 0x0000A400, 0x0000F400, 0x00014400, 0x00019400, 0x00019600, 0x00019E00, 0x0001A400, 0x0001B600, 0x0001BE00, 0x0001C000, 0x0001C200, 0x0001C800, 0x0001CA00, 0x0001CE00, 0x0001D600, 0x0001D800, 0x0001DA00, 0x0001DC00, 0x0001DE00, 0x0001E000, 0x0001E800, 0x0001EE00, 0x0001F200, 0x00020E00, 0x00021000, 0x00021400, 0x00021800, 0x00022000, 0x00023C00, 0x00024000, 0x00024800, 0x00024C00, 0x00025600, 0x00025A00, 0x00026200, 0x00027000, 0x00027200, 0x00027400, 0x00028200, 0x00028A00, 0x00028E00, 0x00030A00, 0x00038400, 0x0006D000, 0x0007B200 };
|
||||
lens = new uint[] { 0x000002C8, 0x00000B90, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000130, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000011CC, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000003E0, 0x00000216, 0x00000640, 0x00001A90, 0x00000400, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00000400, 0x00007AD0, 0x000078B0, 0x00034AD0, 0x0000E058, 0x00000200 };
|
||||
skips = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000000, 0x00000004, 0x00000004 };
|
||||
magics = new uint[] { 0x005E0BB8, 0x005E09C4, 0x005E0904, 0x005E0AA4, 0x005E0BF8, 0x005E05CC, 0x005E0B04, 0x005E0A44, 0x005E0AC4, 0x005E05AC, 0x005E064C, 0x005E0944, 0x005E0924, 0x005E0B78, 0x005E0884, 0x005E0884, 0x005E0884, 0x005E0AE4, 0x005E068C, 0x005DF40C, 0x005E0C18, 0x005E072C, 0x005E05EC, 0x005E0964, 0x005E06AC, 0x005E06EC, 0x005E062C, 0x005E0BD8, 0x005E0A64, 0x005E0B98, 0x005E07CC, 0x005E0A24, 0x005E058C, 0x005E04EC, 0x005E056C, 0x005E082C, 0x005E0984, 0x005E070C, 0x005E0B58, 0x005E054C, 0x005E050C, 0x005E080C, 0x005E076C, 0x005E07AC, 0x005E09E4, 0x005E08A4, 0x005E078C, 0x005E074C, 0x005E060C, 0x005E06CC, UNKNOWNVAL, 0x005E0864, 0x005E07EC, 0x005E0A04, 0x005E052C, 0x005E08C4, 0x005E04CC, 0x005E066C, 0x005E09A4 };
|
||||
instances = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
}
|
||||
else
|
||||
{
|
||||
offsets = new uint[] { 0x00005400, 0x00005800, 0x00006400, 0x00006600, 0x00006800, 0x00006A00, 0x00006C00, 0x00006E00, 0x00007000, 0x00007200, 0x00007400, 0x00009600, 0x00009800, 0x00009E00, 0x0000A400, 0x0000F400, 0x00014400, 0x00019400, 0x00019600, 0x00019E00, 0x0001A400, 0x0001AC00, 0x0001B400, 0x0001B600, 0x0001B800, 0x0001BE00, 0x0001C000, 0x0001C400, 0x0001CC00, 0x0001CE00, 0x0001D000, 0x0001D200, 0x0001D400, 0x0001D600, 0x0001DE00, 0x0001E400, 0x0001E800, 0x00020400, 0x00020600, 0x00020800, 0x00020C00, 0x00021000, 0x00022C00, 0x00023000, 0x00023800, 0x00023C00, 0x00024600, 0x00024A00, 0x00025200, 0x00026000, 0x00026200, 0x00026400, 0x00027200, 0x00027A00, 0x0005C600, 0x0006A800 };
|
||||
lens = new uint[] { 0x000002C8, 0x00000B88, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000140, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000006A0, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000001F0, 0x00000216, 0x00000390, 0x00001A90, 0x00000308, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00034AD0, 0x0000E058, 0x00000200 };
|
||||
skips = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000004 };
|
||||
magics = new uint[] { 0x0059AE94, 0x0059ACC0, 0x0059AC00, 0x0059AD80, 0x0059AED4, 0x0059A8E8, 0x0059ADE0, 0x0059AD20, 0x0059ADA0, 0x0059A8C8, 0x0059A968, 0x0059AC40, 0x0059AC20, 0x0059AE54, 0x0059ABA0, 0x0059ABA0, 0x0059ABA0, 0x0059ADC0, 0x0059A9A8, 0x00599734, 0x0059AEF4, 0x0059AA48, 0x0059A908, 0x0059AC60, 0x0059A9C8, 0x0059AA08, 0x0059A948, 0x0059AEB4, 0x0059AD40, 0x0059AE74, 0x0059AAE8, 0x0059AD00, 0x0059A8A8, 0x0059A800, 0x0059A888, 0x0059AB70, 0x0059AC80, 0x0059AA28, 0x0059AE34, 0x0059A868, 0x0059A820, 0x0059AB28, 0x0059AA88, 0x0059AAC8, 0x0059ACE0, 0x0059ABC0, 0x0059AAA8, 0x0059AA68, 0x0059A928, 0x0059A9E8, 0x0059AD60, 0x0059AB80, 0x0059AB08, 0x0059A7E0, 0x0059A988, 0x0059ACA0 };
|
||||
instances = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
switch (val)
|
||||
{
|
||||
case 0x0059E418:
|
||||
magics = new uint[] { 0x0059E418, 0x0059E244, 0x0059E184, 0x0059E304, 0x0059E458, 0x0059DE6C, 0x0059E364, 0x0059E2A4, 0x0059E324, 0x0059DE4C, 0x0059DEEC, 0x0059E1C4, 0x0059E1A4, 0x0059E3D8, 0x0059E124, 0x0059E124, 0x0059E124, 0x0059E344, 0x0059DF2C, 0x0059CCB8, 0x0059E478, 0x0059DFCC, 0x0059DE8C, 0x0059E1E4, 0x0059DF4C, 0x0059DF8C, 0x0059DECC, 0x0059E438, 0x0059E2C4, 0x0059E3F8, 0x0059E06C, 0x0059E284, 0x0059DE2C, 0x0059DD84, 0x0059DE0C, 0x0059E0CC, 0x0059E204, 0x0059DFAC, 0x0059E3B8, 0x0059DDEC, 0x0059DDA4, 0x0059E0AC, 0x0059E00C, 0x0059E04C, 0x0059E264, 0x0059E144, 0x0059E02C, 0x0059DFEC, 0x0059DEAC, 0x0059DF6C, 0x0059E2E4, 0x0059E104, 0x0059E08C, 0x0059DD64, 0x0059DF0C, 0x0059E224 };
|
||||
break;
|
||||
case 0x0059E408:
|
||||
magics = new uint[] { 0x0059E408, 0x0059E234, 0x0059E174, 0x0059E2F4, 0x0059E448, 0x0059DE5C, 0x0059E354, 0x0059E294, 0x0059E314, 0x0059DE3C, 0x0059DEDC, 0x0059E1B4, 0x0059E194, 0x0059E3C8, 0x0059E114, 0x0059E114, 0x0059E114, 0x0059E334, 0x0059DF1C, 0x0059CCA8, 0x0059E468, 0x0059DFBC, 0x0059DE7C, 0x0059E1D4, 0x0059DF3C, 0x0059DF7C, 0x0059DEBC, 0x0059E428, 0x0059E2B4, 0x0059E3E8, 0x0059E05C, 0x0059E274, 0x0059DE1C, 0x0059DD74, 0x0059DDFC, 0x0059E0BC, 0x0059E1F4, 0x0059DF9C, 0x0059E3A8, 0x0059DDDC, 0x0059DD94, 0x0059E09C, 0x0059DFFC, 0x0059E03C, 0x0059E254, 0x0059E134, 0x0059E01C, 0x0059DFDC, 0x0059DE9C, 0x0059DF5C, 0x0059E2D4, 0x0059E0F4, 0x0059E07C, 0x0059DD54, 0x0059DEFC, 0x0059E214 };
|
||||
break;
|
||||
case 0x0059BEC4:
|
||||
magics = new uint[] { 0x0059BEC4, 0x0059BCF0, 0x0059BC30, 0x0059BDB0, 0x0059BF04, 0x0059B918, 0x0059BE10, 0x0059BD50, 0x0059BDD0, 0x0059B8F8, 0x0059B998, 0x0059BC70, 0x0059BC50, 0x0059BE84, 0x0059BBD0, 0x0059BBD0, 0x0059BBD0, 0x0059BDF0, 0x0059B9D8, 0x0059A764, 0x0059BF24, 0x0059BA78, 0x0059B938, 0x0059BC90, 0x0059B9F8, 0x0059BA38, 0x0059B978, 0x0059BEE4, 0x0059BD70, 0x0059BEA4, 0x0059BB18, 0x0059BD30, 0x0059B8D8, 0x0059B830, 0x0059B8B8, 0x0059BBA0, 0x0059BCB0, 0x0059BA58, 0x0059BE64, 0x0059B898, 0x0059B850, 0x0059BB58, 0x0059BAB8, 0x0059BAF8, 0x0059BD10, 0x0059BBF0, 0x0059BAD8, 0x0059BA98, 0x0059B958, 0x0059BA18, 0x0059BD90, 0x0059BBB0, 0x0059BB38, 0x0059B810, 0x0059B9B8, 0x0059BCD0 };
|
||||
break;
|
||||
}
|
||||
}
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
for (int i = 0; i < lens.Length; i++)
|
||||
{
|
||||
int ofs = FindIndex(ramsav, magics[i], instances[i], spos);
|
||||
ms.Seek(offsets[i] - 0x5400, SeekOrigin.Begin);
|
||||
spos += lens[i];
|
||||
if (ofs > 0)
|
||||
{
|
||||
new MemoryStream(ramsav.Skip(ofs + (int)skips[i]).Take((int)lens[i]).ToArray()).CopyTo(ms);
|
||||
spos += 4;
|
||||
}
|
||||
else
|
||||
new MemoryStream(new byte[(int)lens[i]]).CopyTo(ms);
|
||||
}
|
||||
if (ms.Length % 0x200 != 0)
|
||||
new MemoryStream(new byte[0x200 - ms.Length % 0x200]).CopyTo(ms); // Pad out to 0x200
|
||||
|
||||
main = ms.ToArray();
|
||||
}
|
||||
return main;
|
||||
}
|
||||
internal static byte[] getRAM(byte[] ramsav, byte[] main)
|
||||
{
|
||||
bool oras = main.Length > 0x65600;
|
||||
byte[] newram = new byte[ramsav.Length];
|
||||
Array.Copy(ramsav, newram, ramsav.Length);
|
||||
uint[] offsets;
|
||||
uint[] lens;
|
||||
uint[] magics;
|
||||
uint[] skips;
|
||||
uint[] instances;
|
||||
uint val = BitConverter.ToUInt32(ramsav, 0);
|
||||
uint spos = 0;
|
||||
if (oras) // ORAS
|
||||
{
|
||||
offsets = new uint[] { 0x00005400, 0x00005800, 0x00006400, 0x00006600, 0x00006800, 0x00006A00, 0x00006C00, 0x00006E00, 0x00007000, 0x00007200, 0x00007400, 0x00009600, 0x00009800, 0x00009E00, 0x0000A400, 0x0000F400, 0x00014400, 0x00019400, 0x00019600, 0x00019E00, 0x0001A400, 0x0001B600, 0x0001BE00, 0x0001C000, 0x0001C200, 0x0001C800, 0x0001CA00, 0x0001CE00, 0x0001D600, 0x0001D800, 0x0001DA00, 0x0001DC00, 0x0001DE00, 0x0001E000, 0x0001E800, 0x0001EE00, 0x0001F200, 0x00020E00, 0x00021000, 0x00021400, 0x00021800, 0x00022000, 0x00023C00, 0x00024000, 0x00024800, 0x00024C00, 0x00025600, 0x00025A00, 0x00026200, 0x00027000, 0x00027200, 0x00027400, 0x00028200, 0x00028A00, 0x00028E00, 0x00030A00, 0x00038400, 0x0006D000, 0x0007B200 };
|
||||
lens = new uint[] { 0x000002C8, 0x00000B90, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000130, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000011CC, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000003E0, 0x00000216, 0x00000640, 0x00001A90, 0x00000400, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00000400, 0x00007AD0, 0x000078B0, 0x00034AD0, 0x0000E058, 0x00000200 };
|
||||
skips = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000000, 0x00000004, 0x00000004 };
|
||||
magics = new uint[] { 0x005E0BB8, 0x005E09C4, 0x005E0904, 0x005E0AA4, 0x005E0BF8, 0x005E05CC, 0x005E0B04, 0x005E0A44, 0x005E0AC4, 0x005E05AC, 0x005E064C, 0x005E0944, 0x005E0924, 0x005E0B78, 0x005E0884, 0x005E0884, 0x005E0884, 0x005E0AE4, 0x005E068C, 0x005DF40C, 0x005E0C18, 0x005E072C, 0x005E05EC, 0x005E0964, 0x005E06AC, 0x005E06EC, 0x005E062C, 0x005E0BD8, 0x005E0A64, 0x005E0B98, 0x005E07CC, 0x005E0A24, 0x005E058C, 0x005E04EC, 0x005E056C, 0x005E082C, 0x005E0984, 0x005E070C, 0x005E0B58, 0x005E054C, 0x005E050C, 0x005E080C, 0x005E076C, 0x005E07AC, 0x005E09E4, 0x005E08A4, 0x005E078C, 0x005E074C, 0x005E060C, 0x005E06CC, UNKNOWNVAL, 0x005E0864, 0x005E07EC, 0x005E0A04, 0x005E052C, 0x005E08C4, 0x005E04CC, 0x005E066C, 0x005E09A4 };
|
||||
instances = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
}
|
||||
else
|
||||
{
|
||||
offsets = new uint[] { 0x00005400, 0x00005800, 0x00006400, 0x00006600, 0x00006800, 0x00006A00, 0x00006C00, 0x00006E00, 0x00007000, 0x00007200, 0x00007400, 0x00009600, 0x00009800, 0x00009E00, 0x0000A400, 0x0000F400, 0x00014400, 0x00019400, 0x00019600, 0x00019E00, 0x0001A400, 0x0001AC00, 0x0001B400, 0x0001B600, 0x0001B800, 0x0001BE00, 0x0001C000, 0x0001C400, 0x0001CC00, 0x0001CE00, 0x0001D000, 0x0001D200, 0x0001D400, 0x0001D600, 0x0001DE00, 0x0001E400, 0x0001E800, 0x00020400, 0x00020600, 0x00020800, 0x00020C00, 0x00021000, 0x00022C00, 0x00023000, 0x00023800, 0x00023C00, 0x00024600, 0x00024A00, 0x00025200, 0x00026000, 0x00026200, 0x00026400, 0x00027200, 0x00027A00, 0x0005C600, 0x0006A800 };
|
||||
lens = new uint[] { 0x000002C8, 0x00000B88, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000140, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000006A0, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000001F0, 0x00000216, 0x00000390, 0x00001A90, 0x00000308, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00034AD0, 0x0000E058, 0x00000200 };
|
||||
skips = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000004, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000004, 0x00000004 };
|
||||
magics = new uint[] { 0x0059AE94, 0x0059ACC0, 0x0059AC00, 0x0059AD80, 0x0059AED4, 0x0059A8E8, 0x0059ADE0, 0x0059AD20, 0x0059ADA0, 0x0059A8C8, 0x0059A968, 0x0059AC40, 0x0059AC20, 0x0059AE54, 0x0059ABA0, 0x0059ABA0, 0x0059ABA0, 0x0059ADC0, 0x0059A9A8, 0x00599734, 0x0059AEF4, 0x0059AA48, 0x0059A908, 0x0059AC60, 0x0059A9C8, 0x0059AA08, 0x0059A948, 0x0059AEB4, 0x0059AD40, 0x0059AE74, 0x0059AAE8, 0x0059AD00, 0x0059A8A8, 0x0059A800, 0x0059A888, 0x0059AB70, 0x0059AC80, 0x0059AA28, 0x0059AE34, 0x0059A868, 0x0059A820, 0x0059AB28, 0x0059AA88, 0x0059AAC8, 0x0059ACE0, 0x0059ABC0, 0x0059AAA8, 0x0059AA68, 0x0059A928, 0x0059A9E8, 0x0059AD60, 0x0059AB80, 0x0059AB08, 0x0059A7E0, 0x0059A988, 0x0059ACA0 };
|
||||
instances = new uint[] { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
switch (val)
|
||||
{
|
||||
case 0x0059E418:
|
||||
magics = new uint[] { 0x0059E418, 0x0059E244, 0x0059E184, 0x0059E304, 0x0059E458, 0x0059DE6C, 0x0059E364, 0x0059E2A4, 0x0059E324, 0x0059DE4C, 0x0059DEEC, 0x0059E1C4, 0x0059E1A4, 0x0059E3D8, 0x0059E124, 0x0059E124, 0x0059E124, 0x0059E344, 0x0059DF2C, 0x0059CCB8, 0x0059E478, 0x0059DFCC, 0x0059DE8C, 0x0059E1E4, 0x0059DF4C, 0x0059DF8C, 0x0059DECC, 0x0059E438, 0x0059E2C4, 0x0059E3F8, 0x0059E06C, 0x0059E284, 0x0059DE2C, 0x0059DD84, 0x0059DE0C, 0x0059E0CC, 0x0059E204, 0x0059DFAC, 0x0059E3B8, 0x0059DDEC, 0x0059DDA4, 0x0059E0AC, 0x0059E00C, 0x0059E04C, 0x0059E264, 0x0059E144, 0x0059E02C, 0x0059DFEC, 0x0059DEAC, 0x0059DF6C, 0x0059E2E4, 0x0059E104, 0x0059E08C, 0x0059DD64, 0x0059DF0C, 0x0059E224 };
|
||||
break;
|
||||
case 0x0059E408:
|
||||
magics = new uint[] { 0x0059E408, 0x0059E234, 0x0059E174, 0x0059E2F4, 0x0059E448, 0x0059DE5C, 0x0059E354, 0x0059E294, 0x0059E314, 0x0059DE3C, 0x0059DEDC, 0x0059E1B4, 0x0059E194, 0x0059E3C8, 0x0059E114, 0x0059E114, 0x0059E114, 0x0059E334, 0x0059DF1C, 0x0059CCA8, 0x0059E468, 0x0059DFBC, 0x0059DE7C, 0x0059E1D4, 0x0059DF3C, 0x0059DF7C, 0x0059DEBC, 0x0059E428, 0x0059E2B4, 0x0059E3E8, 0x0059E05C, 0x0059E274, 0x0059DE1C, 0x0059DD74, 0x0059DDFC, 0x0059E0BC, 0x0059E1F4, 0x0059DF9C, 0x0059E3A8, 0x0059DDDC, 0x0059DD94, 0x0059E09C, 0x0059DFFC, 0x0059E03C, 0x0059E254, 0x0059E134, 0x0059E01C, 0x0059DFDC, 0x0059DE9C, 0x0059DF5C, 0x0059E2D4, 0x0059E0F4, 0x0059E07C, 0x0059DD54, 0x0059DEFC, 0x0059E214 };
|
||||
break;
|
||||
case 0x0059BEC4:
|
||||
magics = new uint[] { 0x0059BEC4, 0x0059BCF0, 0x0059BC30, 0x0059BDB0, 0x0059BF04, 0x0059B918, 0x0059BE10, 0x0059BD50, 0x0059BDD0, 0x0059B8F8, 0x0059B998, 0x0059BC70, 0x0059BC50, 0x0059BE84, 0x0059BBD0, 0x0059BBD0, 0x0059BBD0, 0x0059BDF0, 0x0059B9D8, 0x0059A764, 0x0059BF24, 0x0059BA78, 0x0059B938, 0x0059BC90, 0x0059B9F8, 0x0059BA38, 0x0059B978, 0x0059BEE4, 0x0059BD70, 0x0059BEA4, 0x0059BB18, 0x0059BD30, 0x0059B8D8, 0x0059B830, 0x0059B8B8, 0x0059BBA0, 0x0059BCB0, 0x0059BA58, 0x0059BE64, 0x0059B898, 0x0059B850, 0x0059BB58, 0x0059BAB8, 0x0059BAF8, 0x0059BD10, 0x0059BBF0, 0x0059BAD8, 0x0059BA98, 0x0059B958, 0x0059BA18, 0x0059BD90, 0x0059BBB0, 0x0059BB38, 0x0059B810, 0x0059B9B8, 0x0059BCD0 };
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < lens.Length; i++)
|
||||
{
|
||||
int ofs = FindIndex(ramsav, magics[i], instances[i], spos);
|
||||
spos += lens[i];
|
||||
if (ofs <= 0) continue;
|
||||
Array.Copy(main, (int)offsets[i] - 0x5400, newram, ofs + (int)skips[i], lens[i]);
|
||||
spos += 4;
|
||||
}
|
||||
return newram;
|
||||
}
|
||||
|
||||
internal static int FindIndex(byte[] data, uint val, uint instances, uint start)
|
||||
{
|
||||
if (val == UNKNOWNVAL)
|
||||
return -1;
|
||||
|
||||
int ofs = (int)start;
|
||||
int times = 0;
|
||||
uint v = BitConverter.ToUInt32(data, ofs);
|
||||
while ((v != val || times != instances) && ofs + 4 < data.Length)
|
||||
{
|
||||
ofs++;
|
||||
if (v == val)
|
||||
times++;
|
||||
v = BitConverter.ToUInt32(data, ofs);
|
||||
}
|
||||
if (ofs + 4 != data.Length) return ofs + 4;
|
||||
Console.WriteLine("Failed to find " + val.ToString("X8"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -121,7 +121,6 @@
|
|||
<Compile Include="PKX\f3-MemoryAmie.Designer.cs">
|
||||
<DependentUpon>f3-MemoryAmie.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Misc\ram2sav.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
|
|
42
PKX/f1-Main.Designer.cs
generated
42
PKX/f1-Main.Designer.cs
generated
|
@ -215,8 +215,6 @@
|
|||
this.Menu_ExportSAV = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_ExportMAIN = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_ExportBAK = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_ExportRAMSAV = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_ExportTransfer = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_Exit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_Tools = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Menu_Showdown = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -2629,7 +2627,7 @@
|
|||
this.Menu_Open.Name = "Menu_Open";
|
||||
this.Menu_Open.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||
this.Menu_Open.ShowShortcutKeys = false;
|
||||
this.Menu_Open.Size = new System.Drawing.Size(139, 22);
|
||||
this.Menu_Open.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_Open.Text = "&Open...";
|
||||
this.Menu_Open.Click += new System.EventHandler(this.mainMenuOpen);
|
||||
//
|
||||
|
@ -2638,7 +2636,7 @@
|
|||
this.Menu_Save.Name = "Menu_Save";
|
||||
this.Menu_Save.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||
this.Menu_Save.ShowShortcutKeys = false;
|
||||
this.Menu_Save.Size = new System.Drawing.Size(139, 22);
|
||||
this.Menu_Save.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_Save.Text = "&Save PK6...";
|
||||
this.Menu_Save.Click += new System.EventHandler(this.mainMenuSave);
|
||||
//
|
||||
|
@ -2646,12 +2644,10 @@
|
|||
//
|
||||
this.Menu_ExportSAV.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.Menu_ExportMAIN,
|
||||
this.Menu_ExportBAK,
|
||||
this.Menu_ExportRAMSAV,
|
||||
this.Menu_ExportTransfer});
|
||||
this.Menu_ExportBAK});
|
||||
this.Menu_ExportSAV.Enabled = false;
|
||||
this.Menu_ExportSAV.Name = "Menu_ExportSAV";
|
||||
this.Menu_ExportSAV.Size = new System.Drawing.Size(139, 22);
|
||||
this.Menu_ExportSAV.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_ExportSAV.Text = "&Export SAV...";
|
||||
//
|
||||
// Menu_ExportMAIN
|
||||
|
@ -2659,7 +2655,7 @@
|
|||
this.Menu_ExportMAIN.Name = "Menu_ExportMAIN";
|
||||
this.Menu_ExportMAIN.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
|
||||
this.Menu_ExportMAIN.ShowShortcutKeys = false;
|
||||
this.Menu_ExportMAIN.Size = new System.Drawing.Size(157, 22);
|
||||
this.Menu_ExportMAIN.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_ExportMAIN.Text = "&Export main";
|
||||
this.Menu_ExportMAIN.Click += new System.EventHandler(this.clickExportSAV);
|
||||
//
|
||||
|
@ -2668,30 +2664,16 @@
|
|||
this.Menu_ExportBAK.Name = "Menu_ExportBAK";
|
||||
this.Menu_ExportBAK.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.B)));
|
||||
this.Menu_ExportBAK.ShowShortcutKeys = false;
|
||||
this.Menu_ExportBAK.Size = new System.Drawing.Size(157, 22);
|
||||
this.Menu_ExportBAK.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_ExportBAK.Text = "Export &BAK";
|
||||
this.Menu_ExportBAK.Click += new System.EventHandler(this.clickExportSAVBAK);
|
||||
//
|
||||
// Menu_ExportRAMSAV
|
||||
//
|
||||
this.Menu_ExportRAMSAV.Name = "Menu_ExportRAMSAV";
|
||||
this.Menu_ExportRAMSAV.Size = new System.Drawing.Size(157, 22);
|
||||
this.Menu_ExportRAMSAV.Text = "Export &ramsav";
|
||||
this.Menu_ExportRAMSAV.Click += new System.EventHandler(this.clickExportSAV);
|
||||
//
|
||||
// Menu_ExportTransfer
|
||||
//
|
||||
this.Menu_ExportTransfer.Name = "Menu_ExportTransfer";
|
||||
this.Menu_ExportTransfer.Size = new System.Drawing.Size(157, 22);
|
||||
this.Menu_ExportTransfer.Text = "&Transfer ramsav";
|
||||
this.Menu_ExportTransfer.Click += new System.EventHandler(this.clickExportSAV);
|
||||
//
|
||||
// Menu_Exit
|
||||
//
|
||||
this.Menu_Exit.Name = "Menu_Exit";
|
||||
this.Menu_Exit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));
|
||||
this.Menu_Exit.ShowShortcutKeys = false;
|
||||
this.Menu_Exit.Size = new System.Drawing.Size(139, 22);
|
||||
this.Menu_Exit.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_Exit.Text = "&Quit";
|
||||
this.Menu_Exit.Click += new System.EventHandler(this.mainMenuExit);
|
||||
//
|
||||
|
@ -2714,7 +2696,7 @@
|
|||
this.Menu_ShowdownExportParty,
|
||||
this.Menu_ShowdownExportBattleBox});
|
||||
this.Menu_Showdown.Name = "Menu_Showdown";
|
||||
this.Menu_Showdown.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_Showdown.Size = new System.Drawing.Size(143, 22);
|
||||
this.Menu_Showdown.Text = "Showdown";
|
||||
//
|
||||
// Menu_ShowdownImportPK6
|
||||
|
@ -2752,7 +2734,7 @@
|
|||
this.Menu_OpenTemp,
|
||||
this.Menu_OpenCache});
|
||||
this.Menu_CyberGadget.Name = "Menu_CyberGadget";
|
||||
this.Menu_CyberGadget.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_CyberGadget.Size = new System.Drawing.Size(143, 22);
|
||||
this.Menu_CyberGadget.Text = "CyberGadget";
|
||||
//
|
||||
// Menu_CodeGenerator
|
||||
|
@ -2784,7 +2766,7 @@
|
|||
this.Menu_Report,
|
||||
this.Menu_Database});
|
||||
this.Menu_Data.Name = "Menu_Data";
|
||||
this.Menu_Data.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_Data.Size = new System.Drawing.Size(143, 22);
|
||||
this.Menu_Data.Text = "Data";
|
||||
//
|
||||
// Menu_LoadBoxes
|
||||
|
@ -2825,7 +2807,7 @@
|
|||
this.Menu_OpenSDF,
|
||||
this.Menu_OpenSDB});
|
||||
this.Menu_Other.Name = "Menu_Other";
|
||||
this.Menu_Other.Size = new System.Drawing.Size(152, 22);
|
||||
this.Menu_Other.Size = new System.Drawing.Size(143, 22);
|
||||
this.Menu_Other.Text = "Other";
|
||||
//
|
||||
// Menu_OpenSDF
|
||||
|
@ -4723,9 +4705,7 @@
|
|||
private System.Windows.Forms.MaskedTextBox Stat_HP;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_DumpBoxes;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_ExportBAK;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_ExportTransfer;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_ExportMAIN;
|
||||
private System.Windows.Forms.ToolStripMenuItem Menu_ExportRAMSAV;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
153
PKX/f1-Main.cs
153
PKX/f1-Main.cs
|
@ -131,7 +131,6 @@ namespace PKHeX
|
|||
public static PK6 pk6 = new PK6(); // Tab Pokemon Data Storage
|
||||
public static SAV6 SAV = new SAV6();
|
||||
public static byte[] originalSAV; // original save for CyberGadget Codes
|
||||
public static byte[] ramsav; // original ramsav for ramsav exporting
|
||||
public static string pathSDF;
|
||||
public static string path3DS;
|
||||
|
||||
|
@ -625,18 +624,6 @@ namespace PKHeX
|
|||
}
|
||||
}
|
||||
#endregion
|
||||
#region Trade Packets
|
||||
else if (input.Length == 363 && BitConverter.ToUInt16(input, 0x6B) == 0)
|
||||
{
|
||||
// EAD Packet of 363 length
|
||||
populateFields(new PK6(input.Skip(0x67).Take(PK6.SIZE_STORED).ToArray()));
|
||||
}
|
||||
else if (input.Length == 407 && BitConverter.ToUInt16(input, 0x98) == 0)
|
||||
{
|
||||
// EAD Packet of 407 length
|
||||
populateFields(new PK6(input.Skip(0x93).Take(PK6.SIZE_STORED).ToArray()));
|
||||
}
|
||||
#endregion
|
||||
#region Box Data
|
||||
else if ((input.Length == PK6.SIZE_STORED * 30 || input.Length == PK6.SIZE_STORED * 30 * 31) && BitConverter.ToUInt16(input, 4) == 0 && BitConverter.ToUInt32(input, 8) > 0)
|
||||
{
|
||||
|
@ -650,40 +637,6 @@ namespace PKHeX
|
|||
Util.Alert("Box Binary loaded.");
|
||||
}
|
||||
#endregion
|
||||
#region injectiondebug
|
||||
else if (input.Length == 0x10000)
|
||||
{
|
||||
int offset = -1; // Seek to find data start
|
||||
for (int i = 0; i < 0x800; i++)
|
||||
{
|
||||
byte[] data = PKX.decryptArray(input.Skip(i).Take(PK6.SIZE_STORED).ToArray());
|
||||
if (PKX.getCHK(data) != BitConverter.ToUInt16(data, 6)) continue;
|
||||
offset = i; break;
|
||||
}
|
||||
if (offset < 0) { Util.Alert(path, "Unable to read the input file; not an expected injectiondebug.bin."); return; }
|
||||
CB_BoxSelect.SelectedIndex = 0;
|
||||
for (int i = 0; i < input.Length / 270; i++)
|
||||
{
|
||||
byte[] data = input.Skip(offset + PK6.SIZE_STORED * i).Take(PK6.SIZE_STORED).ToArray();
|
||||
SAV.setEK6Stored(data, SAV.Box + i * PK6.SIZE_STORED);
|
||||
}
|
||||
setPKXBoxes();
|
||||
Util.Alert("Injection Binary loaded.");
|
||||
}
|
||||
#endregion
|
||||
#region RAMSAV
|
||||
else if (( /*XY*/ input.Length == 0x70000 || /*ORAS*/ input.Length == 0x80000) && Path.GetFileName(path).Contains("ram"))
|
||||
{
|
||||
if (input.Length == 0x80000)
|
||||
// Scan for FEEB in XY location, 3DS only overwrites data if file already exists.
|
||||
for (int i = 0x60000; i < 0x64000; i+=4)
|
||||
if (BitConverter.ToUInt32(input, i) == SAV6.BEEF) { Array.Resize(ref input, 0x70000); break; }
|
||||
|
||||
ramsav = (byte[])input.Clone();
|
||||
try { openMAIN(ram2sav.getMAIN(input), path, true); }
|
||||
catch { ramsav = null; }
|
||||
}
|
||||
#endregion
|
||||
#region Battle Video
|
||||
else if (input.Length == 0x2E60 && BitConverter.ToUInt64(input, 0xE18) != 0 && BitConverter.ToUInt16(input, 0xE12) == 0)
|
||||
{
|
||||
|
@ -800,22 +753,15 @@ namespace PKHeX
|
|||
if (xorpath != exepath || loop++ > 0) return false; // no xorpad compatible
|
||||
xorpath = Path.GetDirectoryName(path); goto check;
|
||||
}
|
||||
private void openMAIN(byte[] input, string path, bool ram = false)
|
||||
private void openMAIN(byte[] input, string path)
|
||||
{
|
||||
if (!ram)
|
||||
ramsav = null;
|
||||
L_Save.Text = "SAV: " + Path.GetFileName(path);
|
||||
SAV = new SAV6(input);
|
||||
|
||||
// Enable Secondary Tools
|
||||
GB_SAVtools.Enabled =
|
||||
B_JPEG.Enabled = true;
|
||||
GB_SAVtools.Enabled = B_JPEG.Enabled = true;
|
||||
Menu_ExportSAV.Enabled = B_VerifyCHK.Enabled = SAV.Exportable;
|
||||
|
||||
SAV.Edited = false;
|
||||
|
||||
Menu_ExportSAV.Enabled = SAV.Exportable;
|
||||
Menu_ExportTransfer.Enabled = Menu_ExportRAMSAV.Enabled = ramsav != null;
|
||||
B_VerifyCHK.Enabled = ramsav == null;
|
||||
DaycareSlot = 0;
|
||||
|
||||
setBoxNames(); // Display the Box Names
|
||||
|
@ -2498,10 +2444,7 @@ namespace PKHeX
|
|||
if (SAV.Edited) { Util.Alert("Save has been edited. Cannot integrity check."); return; }
|
||||
|
||||
if (PKX.verifyG6SAV(SAV.Data))
|
||||
{
|
||||
Util.Alert("Checksums are correct.");
|
||||
return;
|
||||
}
|
||||
{ Util.Alert("Checksums are correct."); return; }
|
||||
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNoCancel, "Export Checksum Info to Clipboard?"))
|
||||
return;
|
||||
|
||||
|
@ -2510,17 +2453,12 @@ namespace PKHeX
|
|||
private void clickExportSAVBAK(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog
|
||||
{
|
||||
FileName =
|
||||
Util.CleanFileName(ramsav == null
|
||||
? $"main ({SAV.OT} - {SAV.TID}).bak"
|
||||
: $"ramsav ({SAV.OT} - {SAV.TID}).bak")
|
||||
};
|
||||
{ FileName = Util.CleanFileName($"main ({SAV.OT} - {SAV.LastSavedTime}).bak") };
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
string path = sfd.FileName;
|
||||
File.WriteAllBytes(sfd.FileName, ramsav ?? SAV.BAK);
|
||||
File.WriteAllBytes(path, SAV.BAK);
|
||||
Util.Alert("Saved Backup of current SAV to:", path);
|
||||
}
|
||||
private void clickExportSAV(object sender, EventArgs e)
|
||||
|
@ -2537,74 +2475,45 @@ namespace PKHeX
|
|||
SAV.CurrentBox = CB_BoxSelect.SelectedIndex;
|
||||
byte[] sav = SAV.Write();
|
||||
|
||||
SaveFileDialog cySAV = new SaveFileDialog();
|
||||
SaveFileDialog main = new SaveFileDialog();
|
||||
// Try for file path
|
||||
string cyberpath = Util.GetTempFolder();
|
||||
if (ramsav != null && Directory.Exists(path3DS))
|
||||
if (Directory.Exists(path3DS))
|
||||
{
|
||||
cySAV.InitialDirectory = Path.GetPathRoot(path3DS);
|
||||
cySAV.RestoreDirectory = true;
|
||||
main.InitialDirectory = Path.GetPathRoot(path3DS);
|
||||
main.RestoreDirectory = true;
|
||||
}
|
||||
else if (path3DS != null && File.Exists(Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup", "main")))
|
||||
{
|
||||
cySAV.InitialDirectory = Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup");
|
||||
cySAV.RestoreDirectory = true;
|
||||
main.InitialDirectory = Path.Combine(Path.GetPathRoot(path3DS), "SaveDataBackup");
|
||||
main.RestoreDirectory = true;
|
||||
}
|
||||
else if (pathSDF != null && Directory.Exists(pathSDF))
|
||||
{
|
||||
cySAV.InitialDirectory = pathSDF;
|
||||
cySAV.RestoreDirectory = true;
|
||||
main.InitialDirectory = pathSDF;
|
||||
main.RestoreDirectory = true;
|
||||
}
|
||||
else if (Directory.Exists(Path.Combine(cyberpath, "root")))
|
||||
{
|
||||
cySAV.InitialDirectory = Path.Combine(cyberpath, "root");
|
||||
cySAV.RestoreDirectory = true;
|
||||
main.InitialDirectory = Path.Combine(cyberpath, "root");
|
||||
main.RestoreDirectory = true;
|
||||
}
|
||||
else if (Directory.Exists(cyberpath))
|
||||
{
|
||||
cySAV.InitialDirectory = cyberpath;
|
||||
cySAV.RestoreDirectory = true;
|
||||
main.InitialDirectory = cyberpath;
|
||||
main.RestoreDirectory = true;
|
||||
}
|
||||
|
||||
// Export
|
||||
if (sender == Menu_ExportTransfer) // Export RAM SAV to another.
|
||||
{
|
||||
Util.Alert("Please specify the target cart/console-RAM save.");
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
if (ofd.ShowDialog() != DialogResult.OK) return;
|
||||
string target = ofd.FileName;
|
||||
byte[] targetRAM = File.ReadAllBytes(target);
|
||||
byte[] newRAM = ram2sav.getRAM(targetRAM, sav);
|
||||
|
||||
cySAV.Filter = "ramsav|*.bin";
|
||||
cySAV.FileName = "ramsav.bin";
|
||||
DialogResult sdr = cySAV.ShowDialog();
|
||||
if (sdr != DialogResult.OK) return;
|
||||
string path = cySAV.FileName;
|
||||
File.WriteAllBytes(path, newRAM);
|
||||
Util.Alert("Saved RAM SAV to:" + Environment.NewLine + path, "Target RAM:" + Environment.NewLine + target);
|
||||
}
|
||||
else if (sender == Menu_ExportRAMSAV) // Export RAM SAV if it is the currently loaded one.
|
||||
{
|
||||
cySAV.Filter = "ramsav|*.bin";
|
||||
cySAV.FileName = "ramsav.bin";
|
||||
DialogResult sdr = cySAV.ShowDialog();
|
||||
if (sdr != DialogResult.OK) return;
|
||||
string path = cySAV.FileName;
|
||||
File.WriteAllBytes(path, ram2sav.getRAM(ramsav, sav));
|
||||
Util.Alert("Saved RAM SAV to:", path);
|
||||
}
|
||||
else if (sender == Menu_ExportMAIN)
|
||||
{
|
||||
cySAV.Filter = "Cyber SAV|*.*";
|
||||
cySAV.FileName = L_Save.Text.Split(new[] { ": " }, StringSplitOptions.None)[1];
|
||||
DialogResult sdr = cySAV.ShowDialog();
|
||||
if (sdr != DialogResult.OK) return;
|
||||
string path = cySAV.FileName;
|
||||
File.WriteAllBytes(path, sav);
|
||||
Util.Alert("Saved Cyber SAV to:", path);
|
||||
}
|
||||
main.Filter = "Main SAV|*.*";
|
||||
main.FileName = L_Save.Text.Split(new[] {": "}, StringSplitOptions.None)[1];
|
||||
DialogResult sdr = main.ShowDialog();
|
||||
if (sdr != DialogResult.OK) return;
|
||||
string path = main.FileName;
|
||||
File.WriteAllBytes(path, sav);
|
||||
Util.Alert("Exported SAV to:", path);
|
||||
}
|
||||
|
||||
// Box/SAV Functions //
|
||||
private void clickBoxRight(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -2636,10 +2545,7 @@ namespace PKHeX
|
|||
PK6 pk = SAV.getPK6Stored(offset);
|
||||
if (pk.Sanity == 0 && pk.Species != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
populateFields(pk);
|
||||
}
|
||||
try { populateFields(pk); }
|
||||
catch // If it fails, try XORing encrypted zeroes
|
||||
{
|
||||
try
|
||||
|
@ -2664,9 +2570,10 @@ namespace PKHeX
|
|||
{
|
||||
if (!verifiedPKX()) { return; }
|
||||
int slot = getSlot(sender);
|
||||
if (slot == 30 && (CB_Species.SelectedIndex == 0 || CHK_IsEgg.Checked)) { Util.Alert("Can't have empty/egg first slot."); return; }
|
||||
int offset = getPKXOffset(slot);
|
||||
if (slot == 30 && (CB_Species.SelectedIndex == 0 || CHK_IsEgg.Checked))
|
||||
{ Util.Alert("Can't have empty/egg first slot."); return; }
|
||||
|
||||
int offset = getPKXOffset(slot);
|
||||
PK6 pk = preparepkx();
|
||||
if (!SAV.ORAS)
|
||||
{
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = Save PK6...
|
|||
Menu_ExportSAV = Export SAV...
|
||||
Menu_ExportMAIN = Export main
|
||||
Menu_ExportBAK = Export BAK
|
||||
Menu_ExportRAMSAV = Export ramsav
|
||||
Menu_ExportTransfer = Transfer ramsav
|
||||
Menu_Exit = Quit
|
||||
--
|
||||
Menu_Tools = Tools
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = Save PK6...
|
|||
Menu_ExportSAV = Export SAV...
|
||||
Menu_ExportMAIN = Export main
|
||||
Menu_ExportBAK = Export BAK
|
||||
Menu_ExportRAMSAV = Export ramsav
|
||||
Menu_ExportTransfer = Transfer ramsav
|
||||
Menu_Exit = Quit
|
||||
--
|
||||
Menu_Tools = Tools
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = Guardar PK6...
|
|||
Menu_ExportSAV = Guardar SAV...
|
||||
Menu_ExportMAIN = Guardar main
|
||||
Menu_ExportBAK = Guardar BAK
|
||||
Menu_ExportRAMSAV = Guardar ramsav
|
||||
Menu_ExportTransfer = Transferir ramsav
|
||||
Menu_Exit = Salir
|
||||
--
|
||||
Menu_Tools = Útiles
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = Enregistrer PK6...
|
|||
Menu_ExportSAV = Enregistrer SAV...
|
||||
Menu_ExportMAIN = Enregistrer main
|
||||
Menu_ExportBAK = Enregistrer BAK
|
||||
Menu_ExportRAMSAV = Enregistrer ramsav
|
||||
Menu_ExportTransfer = Transfert ramsav
|
||||
Menu_Exit = Quitter
|
||||
--
|
||||
Menu_Tools = Outils
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = Save PK6...
|
|||
Menu_ExportSAV = Export SAV...
|
||||
Menu_ExportMAIN = Export main
|
||||
Menu_ExportBAK = Export BAK
|
||||
Menu_ExportRAMSAV = Export ramsav
|
||||
Menu_ExportTransfer = Transfer ramsav
|
||||
Menu_Exit = Quit
|
||||
--
|
||||
Menu_Tools = Tools
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = 保存 PK6...
|
|||
Menu_ExportSAV = 保存 SAV...
|
||||
Menu_ExportMAIN = 保存 main
|
||||
Menu_ExportBAK = 保存 BAK
|
||||
Menu_ExportRAMSAV = 保存 ramsav
|
||||
Menu_ExportTransfer = 転送 ramsav
|
||||
Menu_Exit = やめる
|
||||
--
|
||||
Menu_Tools = ツール
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = 저장 PK6...
|
|||
Menu_ExportSAV = 저장 SAV...
|
||||
Menu_ExportMAIN = 저장 main
|
||||
Menu_ExportBAK = 저장 BAK
|
||||
Menu_ExportRAMSAV = 저장 ramsav
|
||||
Menu_ExportTransfer = 전송 ramsav
|
||||
Menu_Exit = 종료
|
||||
--
|
||||
Menu_Tools = 도구
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = Guardar PK6...
|
|||
Menu_ExportSAV = Guardar SAV...
|
||||
Menu_ExportMAIN = Guardar main
|
||||
Menu_ExportBAK = Guardar BAK
|
||||
Menu_ExportRAMSAV = Guardar ramsav
|
||||
Menu_ExportTransfer = Transferir ramsav
|
||||
Menu_Exit = Sair
|
||||
--
|
||||
Menu_Tools = Ferramentas
|
||||
|
|
|
@ -22,8 +22,6 @@ Menu_Save = 保存 PK6...
|
|||
Menu_ExportSAV = 保存 SAV...
|
||||
Menu_ExportMAIN = 保存 main
|
||||
Menu_ExportBAK = 保存 BAK
|
||||
Menu_ExportRAMSAV = 保存 ramsav
|
||||
Menu_ExportTransfer = 转移 SAV
|
||||
Menu_Exit = 退出
|
||||
--
|
||||
Menu_Tools = 工具
|
||||
|
|
|
@ -207,11 +207,9 @@ namespace PKHeX
|
|||
byte[] eventflags;
|
||||
if (fi.Length == SAV6.SIZE_ORAS)
|
||||
eventflags = File.ReadAllBytes(path).Skip(Main.SAV.EventFlag).Take(0x180).ToArray();
|
||||
else if (fi.Name.ToLower().Contains("ram") && fi.Length == 0x80000)
|
||||
eventflags = ram2sav.getMAIN(File.ReadAllBytes(path)).Skip(Main.SAV.EventFlag).Take(0x180).ToArray();
|
||||
else
|
||||
{
|
||||
Util.Error("Invalid SAV Size", String.Format("File Size: 0x{1} ({0} bytes)", fi.Length, fi.Length.ToString("X5")), "File Loaded: " + path);
|
||||
Util.Error("Invalid SAV Size", string.Format("File Size: 0x{1} ({0} bytes)", fi.Length, fi.Length.ToString("X5")), "File Loaded: " + path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,11 +175,9 @@ namespace PKHeX
|
|||
byte[] eventflags;
|
||||
if (fi.Length == SAV6.SIZE_XY)
|
||||
eventflags = File.ReadAllBytes(path).Skip(Main.SAV.EventFlag).Take(0x180).ToArray();
|
||||
else if (fi.Name.ToLower().Contains("ram") && fi.Length == 0x70000)
|
||||
eventflags = ram2sav.getMAIN(File.ReadAllBytes(path)).Skip(Main.SAV.EventFlag).Take(0x180).ToArray();
|
||||
else
|
||||
{
|
||||
Util.Error("Invalid SAV Size", String.Format("File Size: 0x{1} ({0} bytes)", fi.Length, fi.Length.ToString("X5")), "File Loaded: " + path);
|
||||
Util.Error("Invalid SAV Size", string.Format("File Size: 0x{1} ({0} bytes)", fi.Length, fi.Length.ToString("X5")), "File Loaded: " + path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ namespace PKHeX
|
|||
}
|
||||
|
||||
editing = true;
|
||||
GB_Map.Enabled = Main.ramsav == null;
|
||||
getComboBoxes();
|
||||
getTextBoxes();
|
||||
getBadges();
|
||||
|
|
Loading…
Reference in a new issue