mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 22:08:35 +00:00
Merge branch 'master' of https://github.com/kwsch/PKHeX
This commit is contained in:
commit
05cbad4377
2 changed files with 31 additions and 20 deletions
|
@ -47,7 +47,6 @@ namespace PKHeX
|
|||
if (Version == GameVersion.Invalid)
|
||||
return;
|
||||
|
||||
|
||||
int[] BlockOrder1 = new int[14];
|
||||
for (int i = 0; i < 14; i++)
|
||||
BlockOrder1[i] = BitConverter.ToInt16(Data, i*0x1000 + 0xFF4);
|
||||
|
@ -60,6 +59,11 @@ namespace PKHeX
|
|||
BlockOrder2[i] = BitConverter.ToInt16(Data, 0xE000 + i*0x1000 + 0xFF4);
|
||||
int zeroBlock2 = Array.IndexOf(BlockOrder2, 0);
|
||||
|
||||
if (zeroBlock2 < 0)
|
||||
ActiveSAV = 0;
|
||||
else if (zeroBlock1 < 0)
|
||||
ActiveSAV = 1;
|
||||
else
|
||||
ActiveSAV = BitConverter.ToUInt32(Data, zeroBlock1*0x1000 + 0xFFC) >
|
||||
BitConverter.ToUInt32(Data, zeroBlock2*0x1000 + 0xEFFC)
|
||||
? 0
|
||||
|
|
|
@ -213,27 +213,34 @@ namespace PKHeX
|
|||
if (data.Length != SIZE_G3RAW && data.Length != SIZE_G3RAWHALF)
|
||||
return GameVersion.Invalid;
|
||||
|
||||
int[] BlockOrder = new int[14];
|
||||
for (int i = 0; i < 14; i++)
|
||||
BlockOrder[i] = BitConverter.ToInt16(data, i * 0x1000 + 0xFF4);
|
||||
|
||||
if (BlockOrder.Any(i => i > 0xD || i < 0))
|
||||
return GameVersion.Invalid;
|
||||
|
||||
// Detect RS/E/FRLG
|
||||
// Section 0 stores Game Code @ 0x00AC; 0 for RS, 1 for FRLG, else for Emerald
|
||||
|
||||
int Block0 = Array.IndexOf(BlockOrder, 0);
|
||||
uint GameCode = BitConverter.ToUInt32(data, Block0 * 0x1000 + 0xAC);
|
||||
if (GameCode == uint.MaxValue)
|
||||
return GameVersion.Unknown; // what a hack
|
||||
|
||||
switch (GameCode)
|
||||
// check the save file(s)
|
||||
int count = data.Length/SIZE_G3RAWHALF;
|
||||
for (int s = 0; s < count; s++)
|
||||
{
|
||||
case 0: return GameVersion.RS;
|
||||
case 1: return GameVersion.FRLG;
|
||||
default: return GameVersion.E;
|
||||
int ofs = 0xE000*s;
|
||||
int[] BlockOrder = new int[14];
|
||||
for (int i = 0; i < 14; i++)
|
||||
BlockOrder[i] = BitConverter.ToInt16(data, i * 0x1000 + 0xFF4 + ofs);
|
||||
|
||||
if (BlockOrder.Any(i => i > 0xD || i < 0))
|
||||
continue;
|
||||
|
||||
// Detect RS/E/FRLG
|
||||
// Section 0 stores Game Code @ 0x00AC; 0 for RS, 1 for FRLG, else for Emerald
|
||||
|
||||
int Block0 = Array.IndexOf(BlockOrder, 0);
|
||||
uint GameCode = BitConverter.ToUInt32(data, Block0 * 0x1000 + 0xAC + ofs);
|
||||
if (GameCode == uint.MaxValue)
|
||||
return GameVersion.Unknown; // what a hack
|
||||
|
||||
switch (GameCode)
|
||||
{
|
||||
case 0: return GameVersion.RS;
|
||||
case 1: return GameVersion.FRLG;
|
||||
default: return GameVersion.E;
|
||||
}
|
||||
}
|
||||
return GameVersion.Invalid;
|
||||
}
|
||||
/// <summary>Determines the type of 3rd gen Box RS</summary>
|
||||
/// <param name="data">Save data of which to determine the type</param>
|
||||
|
|
Loading…
Add table
Reference in a new issue