2016-02-23 06:52:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
2017-01-08 07:54:09 +00:00
|
|
|
|
public static class Data
|
2016-04-19 01:21:50 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public static byte[][] UnpackMini(byte[] fileData, string identifier)
|
2016-04-19 01:21:50 +00:00
|
|
|
|
{
|
2016-10-24 04:57:43 +00:00
|
|
|
|
if (fileData == null || fileData.Length < 4)
|
|
|
|
|
return null;
|
|
|
|
|
|
2017-03-17 06:16:11 +00:00
|
|
|
|
if (identifier[0] != fileData[0] || identifier[1] != fileData[1])
|
|
|
|
|
return null;
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2017-03-17 06:16:11 +00:00
|
|
|
|
int count = BitConverter.ToUInt16(fileData, 2); int ctr = 4;
|
|
|
|
|
int start = BitConverter.ToInt32(fileData, ctr); ctr += 4;
|
|
|
|
|
byte[][] returnData = new byte[count][];
|
|
|
|
|
for (int i = 0; i < count; i++)
|
2016-04-19 01:21:50 +00:00
|
|
|
|
{
|
2017-03-17 06:16:11 +00:00
|
|
|
|
int end = BitConverter.ToInt32(fileData, ctr); ctr += 4;
|
|
|
|
|
int len = end - start;
|
|
|
|
|
byte[] data = new byte[len];
|
|
|
|
|
Buffer.BlockCopy(fileData, start, data, 0, len);
|
|
|
|
|
returnData[i] = data;
|
|
|
|
|
start = end;
|
2016-04-19 01:21:50 +00:00
|
|
|
|
}
|
2017-03-17 06:16:11 +00:00
|
|
|
|
return returnData;
|
2016-04-19 01:21:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|