diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj
index 5f0b4f6c0..a5b15466d 100644
--- a/PKHeX/PKHeX.csproj
+++ b/PKHeX/PKHeX.csproj
@@ -380,7 +380,6 @@
-
diff --git a/PKHeX/PKM/BK4.cs b/PKHeX/PKM/BK4.cs
index 154afddcc..1dde82c15 100644
--- a/PKHeX/PKM/BK4.cs
+++ b/PKHeX/PKM/BK4.cs
@@ -45,19 +45,19 @@ public BK4(byte[] decryptedData = null, string ident = null)
public override int CurrentHandler { get { return 0; } set { } }
// Structure
- public override uint PID { get { return Util.SwapEndianness(BitConverter.ToUInt32(Data, 0x00)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x00); } }
- public override ushort Sanity { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x04)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x04); } }
- public override ushort Checksum { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x06)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x06); } }
+ public override uint PID { get { return BigEndian.ToUInt32(Data, 0x00); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x00); } }
+ public override ushort Sanity { get { return BigEndian.ToUInt16(Data, 0x04); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x04); } }
+ public override ushort Checksum { get { return BigEndian.ToUInt16(Data, 0x06); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x06); } }
#region Block A
- public override int Species { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x08)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x08); } }
- public override int HeldItem { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x0A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x0A); } }
- public override int SID { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x0C)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x0C); } }
- public override int TID { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x0E)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x0E); } }
+ public override int Species { get { return BigEndian.ToUInt16(Data, 0x08); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x08); } }
+ public override int HeldItem { get { return BigEndian.ToUInt16(Data, 0x0A); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x0A); } }
+ public override int SID { get { return BigEndian.ToUInt16(Data, 0x0C); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x0C); } }
+ public override int TID { get { return BigEndian.ToUInt16(Data, 0x0E); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x0E); } }
public override uint EXP
{
- get { return Util.SwapEndianness(BitConverter.ToUInt32(Data, 0x10)); }
- set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x10); }
+ get { return BigEndian.ToUInt32(Data, 0x10); }
+ set { BigEndian.GetBytes(value).CopyTo(Data, 0x10); }
}
public override int OT_Friendship { get { return Data[0x14]; } set { Data[0x14] = (byte)value; } }
public override int Ability { get { return Data[0x15]; } set { Data[0x15] = (byte)value; } }
@@ -115,10 +115,10 @@ public override uint EXP
#endregion
#region Block B
- public override int Move1 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x28)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x28); } }
- public override int Move2 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2A); } }
- public override int Move3 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2C)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2C); } }
- public override int Move4 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2E)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2E); } }
+ public override int Move1 { get { return BigEndian.ToUInt16(Data, 0x28); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x28); } }
+ public override int Move2 { get { return BigEndian.ToUInt16(Data, 0x2A); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x2A); } }
+ public override int Move3 { get { return BigEndian.ToUInt16(Data, 0x2C); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
+ public override int Move4 { get { return BigEndian.ToUInt16(Data, 0x2E); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
public override int Move1_PP { get { return Data[0x30]; } set { Data[0x30] = (byte)value; } }
public override int Move2_PP { get { return Data[0x31]; } set { Data[0x31] = (byte)value; } }
public override int Move3_PP { get { return Data[0x32]; } set { Data[0x32] = (byte)value; } }
@@ -127,7 +127,7 @@ public override uint EXP
public override int Move2_PPUps { get { return Data[0x35]; } set { Data[0x35] = (byte)value; } }
public override int Move3_PPUps { get { return Data[0x36]; } set { Data[0x36] = (byte)value; } }
public override int Move4_PPUps { get { return Data[0x37]; } set { Data[0x37] = (byte)value; } }
- public uint IV32 { get { return Util.SwapEndianness(BitConverter.ToUInt32(Data, 0x38)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x38); } }
+ public uint IV32 { get { return BigEndian.ToUInt32(Data, 0x38); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x38); } }
public override int IV_HP { get { return (int)(IV32 >> 02) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 02)) | (uint)((value > 31 ? 31 : value) << 02)); } }
public override int IV_ATK { get { return (int)(IV32 >> 07) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 07)) | (uint)((value > 31 ? 31 : value) << 07)); } }
public override int IV_DEF { get { return (int)(IV32 >> 12) & 0x1F; } set { IV32 = (uint)((IV32 & ~(0x1F << 12)) | (uint)((value > 31 ? 31 : value) << 12)); } }
@@ -274,33 +274,33 @@ public override int Egg_Location
{
get
{
- ushort hgssloc = Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x44));
+ ushort hgssloc = BigEndian.ToUInt16(Data, 0x44);
if (hgssloc != 0)
return hgssloc;
- return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x7E));
+ return BigEndian.ToUInt16(Data, 0x7E);
}
set
{
if (value == 0)
{
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x44);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x7E);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x44);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x7E);
}
else if (PtHGSS)
{
- BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x44);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0xBBA)).CopyTo(Data, 0x7E); // Faraway Place (for DP display)
+ BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x44);
+ BigEndian.GetBytes((ushort)0xBBA).CopyTo(Data, 0x7E); // Faraway Place (for DP display)
}
else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010))
{
// Met location not in DP, set to Mystery Zone (0, illegal) as opposed to Faraway Place
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x44);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x7E);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x44);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x7E);
}
else
{
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x44);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x7E);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x44);
+ BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x7E);
}
}
}
@@ -308,33 +308,33 @@ public override int Met_Location
{
get
{
- ushort hgssloc = Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x46));
+ ushort hgssloc = BigEndian.ToUInt16(Data, 0x46);
if (hgssloc != 0)
return hgssloc;
- return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x80));
+ return BigEndian.ToUInt16(Data, 0x80);
}
set
{
if (value == 0)
{
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x46);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x80);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x46);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x80);
}
else if (PtHGSS)
{
- BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x46);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0xBBA)).CopyTo(Data, 0x80); // Faraway Place (for DP display)
+ BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x46);
+ BigEndian.GetBytes((ushort)0xBBA).CopyTo(Data, 0x80); // Faraway Place (for DP display)
}
else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010))
{
// Met location not in DP, set to Mystery Zone (0, illegal) as opposed to Faraway Place
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x46);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x80);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x46);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x80);
}
else
{
- BitConverter.GetBytes(Util.SwapEndianness((ushort)0)).CopyTo(Data, 0x46);
- BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x80);
+ BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x46);
+ BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x80);
}
}
}
@@ -372,13 +372,13 @@ public override int Ball
#endregion
public override int Stat_Level { get { return Data[0x8C]; } set { Data[0x8C] = (byte)value; } }
- public override int Stat_HPCurrent { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x8E)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x8E); } }
- public override int Stat_HPMax { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x90)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x90); } }
- public override int Stat_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x92)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x92); } }
- public override int Stat_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x94)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x94); } }
- public override int Stat_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x96)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x96); } }
- public override int Stat_SPA { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x98)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x98); } }
- public override int Stat_SPD { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x9A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x9A); } }
+ public override int Stat_HPCurrent { get { return BigEndian.ToUInt16(Data, 0x8E); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x8E); } }
+ public override int Stat_HPMax { get { return BigEndian.ToUInt16(Data, 0x90); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x90); } }
+ public override int Stat_ATK { get { return BigEndian.ToUInt16(Data, 0x92); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x92); } }
+ public override int Stat_DEF { get { return BigEndian.ToUInt16(Data, 0x94); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x94); } }
+ public override int Stat_SPE { get { return BigEndian.ToUInt16(Data, 0x96); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x96); } }
+ public override int Stat_SPA { get { return BigEndian.ToUInt16(Data, 0x98); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x98); } }
+ public override int Stat_SPD { get { return BigEndian.ToUInt16(Data, 0x9A); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x9A); } }
public override int PSV => (int)((PID >> 16 ^ PID & 0xFFFF) >> 3);
public override int TSV => (TID ^ SID) >> 3;
@@ -424,7 +424,7 @@ protected override ushort CalculateChecksum()
{
ushort chk = 0;
for (int i = 8; i < SIZE_STORED; i += 2)
- chk += Util.SwapEndianness(BitConverter.ToUInt16(Data, i));
+ chk += BigEndian.ToUInt16(Data, i);
return chk;
}
diff --git a/PKHeX/PKM/PK1.cs b/PKHeX/PKM/PK1.cs
index bed5c560f..b97f61b44 100644
--- a/PKHeX/PKM/PK1.cs
+++ b/PKHeX/PKM/PK1.cs
@@ -136,7 +136,7 @@ public override int Species
}
}
- public override int Stat_HPCurrent { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x1); } }
+ public override int Stat_HPCurrent { get { return BigEndian.ToUInt16(Data, 0x1); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x1); } }
public int Status_Condition { get { return Data[4]; } set { Data[4] = (byte)value; } }
public int Type_A { get { return Data[5]; } set { Data[5] = (byte)value; } }
public int Type_B { get { return Data[6]; } set { Data[6] = (byte)value; } }
@@ -145,20 +145,20 @@ public override int Species
public override int Move2 { get { return Data[9]; } set { Data[9] = (byte)value; } }
public override int Move3 { get { return Data[10]; } set { Data[10] = (byte)value; } }
public override int Move4 { get { return Data[11]; } set { Data[11] = (byte)value; } }
- public override int TID { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0xC)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0xC); } }
+ public override int TID { get { return BigEndian.ToUInt16(Data, 0xC); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xC); } }
public override uint EXP
{
- get { return (Util.SwapEndianness(BitConverter.ToUInt32(Data, 0xE)) >> 8) & 0x00FFFFFF; }
- set { Array.Copy(BitConverter.GetBytes(Util.SwapEndianness((value << 8) & 0xFFFFFF00)), 0, Data, 0xE, 3); }
+ get { return (BigEndian.ToUInt32(Data, 0xE) >> 8) & 0x00FFFFFF; }
+ set { Array.Copy(BigEndian.GetBytes((value << 8) & 0xFFFFFF00), 0, Data, 0xE, 3); }
}
- public override int EV_HP { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x11)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x11); } }
- public override int EV_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x13)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x13); } }
- public override int EV_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x15)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x15); } }
- public override int EV_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x17)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x17); } }
- public int EV_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x19)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x19); } }
+ public override int EV_HP { get { return BigEndian.ToUInt16(Data, 0x11); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x11); } }
+ public override int EV_ATK { get { return BigEndian.ToUInt16(Data, 0x13); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x13); } }
+ public override int EV_DEF { get { return BigEndian.ToUInt16(Data, 0x15); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x15); } }
+ public override int EV_SPE { get { return BigEndian.ToUInt16(Data, 0x17); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x17); } }
+ public int EV_SPC { get { return BigEndian.ToUInt16(Data, 0x19); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x19); } }
public override int EV_SPA { get { return EV_SPC; } set { EV_SPC = value; } }
public override int EV_SPD { get { return EV_SPC; } set { } }
- public ushort DV16 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1B)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x1B); } }
+ public ushort DV16 { get { return BigEndian.ToUInt16(Data, 0x1B); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x1B); } }
public override int IV_HP { get { return ((IV_ATK & 1) << 3) | ((IV_DEF & 1) << 2) | ((IV_SPE & 1) << 1) | ((IV_SPC & 1) << 0); } set { } }
public override int IV_ATK { get { return (DV16 >> 12) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 12)) | (ushort)((value > 0xF ? 0xF : value) << 12)); } }
public override int IV_DEF { get { return (DV16 >> 8) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 8)) | (ushort)((value > 0xF ? 0xF : value) << 8)); } }
@@ -182,11 +182,11 @@ public override int Stat_Level
get { return Data[0x21]; }
set { Data[0x21] = (byte)value; Data[0x3] = (byte)value; }
}
- public override int Stat_HPMax { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x22)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x22); } }
- public override int Stat_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x24)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x24); } }
- public override int Stat_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x26)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x26); } }
- public override int Stat_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x28)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x28); } }
- public int Stat_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2A); } }
+ public override int Stat_HPMax { get { return BigEndian.ToUInt16(Data, 0x22); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x22); } }
+ public override int Stat_ATK { get { return BigEndian.ToUInt16(Data, 0x24); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x24); } }
+ public override int Stat_DEF { get { return BigEndian.ToUInt16(Data, 0x26); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x26); } }
+ public override int Stat_SPE { get { return BigEndian.ToUInt16(Data, 0x28); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x28); } }
+ public int Stat_SPC { get { return BigEndian.ToUInt16(Data, 0x2A); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x2A); } }
// Leave SPA and SPD as alias for SPC
public override int Stat_SPA { get { return Stat_SPC; } set { Stat_SPC = value; } }
public override int Stat_SPD { get { return Stat_SPC; } set { } }
@@ -260,8 +260,7 @@ public override bool CanHoldItem(ushort[] ValidArray)
public PK2 convertToPK2()
{
- PK2 pk2 = new PK2(null, Identifier, Japanese);
- pk2.Species = Species;
+ PK2 pk2 = new PK2(null, Identifier, Japanese) {Species = Species};
Array.Copy(Data, 0x7, pk2.Data, 0x1, 0x1A);
// https://github.com/pret/pokecrystal/blob/master/engine/link.asm#L1132
if (!Legal.HeldItems_GSC.Contains((ushort)pk2.HeldItem))
diff --git a/PKHeX/PKM/PK2.cs b/PKHeX/PKM/PK2.cs
index 9917a5c86..24048e5f9 100644
--- a/PKHeX/PKM/PK2.cs
+++ b/PKHeX/PKM/PK2.cs
@@ -139,20 +139,20 @@ public override int Species
public override int Move2 { get { return Data[3]; } set { Data[3] = (byte)value; } }
public override int Move3 { get { return Data[4]; } set { Data[4] = (byte)value; } }
public override int Move4 { get { return Data[5]; } set { Data[5] = (byte)value; } }
- public override int TID { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 6)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 6); } }
+ public override int TID { get { return BigEndian.ToUInt16(Data, 6); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 6); } }
public override uint EXP
{
- get { return (Util.SwapEndianness(BitConverter.ToUInt32(Data, 8)) >> 8) & 0x00FFFFFF; }
- set { Array.Copy(BitConverter.GetBytes(Util.SwapEndianness((value << 8) & 0xFFFFFF00)), 0, Data, 8, 3); }
+ get { return (BigEndian.ToUInt32(Data, 8) >> 8) & 0x00FFFFFF; }
+ set { Array.Copy(BigEndian.GetBytes((value << 8) & 0xFFFFFF00), 0, Data, 8, 3); }
}
- public override int EV_HP { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0xB)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0xB); } }
- public override int EV_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0xD)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0xD); } }
- public override int EV_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0xF)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0xF); } }
- public override int EV_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x11)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x11); } }
- public int EV_SPC { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x13)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x13); } }
+ public override int EV_HP { get { return BigEndian.ToUInt16(Data, 0xB); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xB); } }
+ public override int EV_ATK { get { return BigEndian.ToUInt16(Data, 0xD); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xD); } }
+ public override int EV_DEF { get { return BigEndian.ToUInt16(Data, 0xF); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0xF); } }
+ public override int EV_SPE { get { return BigEndian.ToUInt16(Data, 0x11); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x11); } }
+ public int EV_SPC { get { return BigEndian.ToUInt16(Data, 0x13); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x13); } }
public override int EV_SPA { get { return EV_SPC; } set { EV_SPC = value; } }
public override int EV_SPD { get { return EV_SPC; } set { } }
- public ushort DV16 { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x15)); } set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x15); } }
+ public ushort DV16 { get { return BigEndian.ToUInt16(Data, 0x15); } set { BigEndian.GetBytes(value).CopyTo(Data, 0x15); } }
public override int IV_HP { get { return ((IV_ATK & 1) << 3) | ((IV_DEF & 1) << 2) | ((IV_SPE & 1) << 1) | ((IV_SPC & 1) << 0); } set { } }
public override int IV_ATK { get { return (DV16 >> 12) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 12)) | (ushort)((value > 0xF ? 0xF : value) << 12)); } }
public override int IV_DEF { get { return (DV16 >> 8) & 0xF; } set { DV16 = (ushort)((DV16 & ~(0xF << 8)) | (ushort)((value > 0xF ? 0xF : value) << 8)); } }
@@ -173,7 +173,7 @@ public override uint EXP
public override int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
public override int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | value << 4); } }
// Crystal only Caught Data
- private int CaughtData { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x1D)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x1D); } }
+ private int CaughtData { get { return BigEndian.ToUInt16(Data, 0x1D); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x1D); } }
public int Met_TimeOfDay { get { return (CaughtData >> 14) & 0x3; } set { CaughtData = (CaughtData & 0x3FFF) | ((value & 0x3) << 14); } }
public override int Met_Level { get { return (CaughtData >> 8) & 0x3F; } set { CaughtData = (CaughtData & 0xC0FF) | ((value & 0x3F) << 8); } }
public override int OT_Gender { get { return (CaughtData >> 7) & 1; } set { CaughtData = (CaughtData & 0xFFEF) | ((value & 1) << 7); } }
@@ -190,13 +190,13 @@ public override int Stat_Level
#region Party Attributes
public int Status_Condition { get { return Data[0x20]; } set { Data[0x20] = (byte)value; } }
- public override int Stat_HPCurrent { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x22)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x22); } }
- public override int Stat_HPMax { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x24)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x24); } }
- public override int Stat_ATK { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x26)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x26); } }
- public override int Stat_DEF { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x28)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x28); } }
- public override int Stat_SPE { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2A)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2A); } }
- public override int Stat_SPA { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2C)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2C); } }
- public override int Stat_SPD { get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2E)); } set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data, 0x2E); } }
+ public override int Stat_HPCurrent { get { return BigEndian.ToUInt16(Data, 0x22); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x22); } }
+ public override int Stat_HPMax { get { return BigEndian.ToUInt16(Data, 0x24); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x24); } }
+ public override int Stat_ATK { get { return BigEndian.ToUInt16(Data, 0x26); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x26); } }
+ public override int Stat_DEF { get { return BigEndian.ToUInt16(Data, 0x28); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x28); } }
+ public override int Stat_SPE { get { return BigEndian.ToUInt16(Data, 0x2A); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x2A); } }
+ public override int Stat_SPA { get { return BigEndian.ToUInt16(Data, 0x2C); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x2C); } }
+ public override int Stat_SPD { get { return BigEndian.ToUInt16(Data, 0x2E); } set { BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x2E); } }
#endregion
public override ushort[] getStats(PersonalInfo p)
diff --git a/PKHeX/PKM/PKX.cs b/PKHeX/PKM/PKX.cs
index 146dfbee7..3c0c84a52 100644
--- a/PKHeX/PKM/PKX.cs
+++ b/PKHeX/PKM/PKX.cs
@@ -1103,7 +1103,7 @@ public static string array2strG4BE(byte[] strdata)
string s = "";
for (int i = 0; i < strdata.Length; i += 2)
{
- ushort val = Util.SwapEndianness(BitConverter.ToUInt16(strdata, i));
+ ushort val = BigEndian.ToUInt16(strdata, i);
if (val == 0xFFFF) break;
ushort chr = val2charG4(val);
if (chr == 0xFFFF) break;
@@ -1121,7 +1121,7 @@ public static byte[] str2arrayG4BE(string str)
ushort val = char2valG4(chr);
if (val == 0xFFFF || chr == 0xFFFF)
{ Array.Resize(ref strdata, i * 2); break; }
- BitConverter.GetBytes(Util.SwapEndianness(val)).CopyTo(strdata, i * 2);
+ BigEndian.GetBytes(val).CopyTo(strdata, i * 2);
}
BitConverter.GetBytes((ushort)0xFFFF).CopyTo(strdata, strdata.Length - 2);
return strdata;
diff --git a/PKHeX/Saves/SAV1.cs b/PKHeX/Saves/SAV1.cs
index 7367f3757..b878b59a6 100644
--- a/PKHeX/Saves/SAV1.cs
+++ b/PKHeX/Saves/SAV1.cs
@@ -232,8 +232,8 @@ public override int Gender
}
public override ushort TID
{
- get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, Japanese ? 0x25FB : 0x2605)); }
- set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, Japanese ? 0x25FB : 0x2605); }
+ get { return BigEndian.ToUInt16(Data, Japanese ? 0x25FB : 0x2605); }
+ set { BigEndian.GetBytes(value).CopyTo(Data, Japanese ? 0x25FB : 0x2605); }
}
public override ushort SID
{
@@ -304,21 +304,21 @@ public int TextSpeed
}
public override uint Money
{
- get { return uint.Parse((Util.SwapEndianness(BitConverter.ToUInt32(Data, Japanese ? 0x25EE : 0x25F3)) >> 8).ToString("X6")); }
+ get { return uint.Parse((BigEndian.ToUInt32(Data, Japanese ? 0x25EE : 0x25F3) >> 8).ToString("X6")); }
set
{
- BitConverter.GetBytes(Util.SwapEndianness(Convert.ToUInt32(value.ToString("000000"), 16))).Skip(1).ToArray().CopyTo(Data, Japanese ? 0x25EE : 0x25F3);
+ BigEndian.GetBytes(Convert.ToUInt32(value.ToString("000000"), 16)).Skip(1).ToArray().CopyTo(Data, Japanese ? 0x25EE : 0x25F3);
}
}
public uint Coin
{
get
{
- return uint.Parse(Util.SwapEndianness(BitConverter.ToUInt16(Data, Japanese ? 0x2846 : 0x2850)).ToString("X4"));
+ return uint.Parse(BigEndian.ToUInt16(Data, Japanese ? 0x2846 : 0x2850).ToString("X4"));
}
set
{
- BitConverter.GetBytes(Util.SwapEndianness(Convert.ToUInt16(value.ToString("0000"), 16))).ToArray().CopyTo(Data, Japanese ? 0x2846 : 0x2850);
+ BigEndian.GetBytes(Convert.ToUInt16(value.ToString("0000"), 16)).ToArray().CopyTo(Data, Japanese ? 0x2846 : 0x2850);
}
}
diff --git a/PKHeX/Saves/SAV2.cs b/PKHeX/Saves/SAV2.cs
index eba3971e0..6ed79fb3e 100644
--- a/PKHeX/Saves/SAV2.cs
+++ b/PKHeX/Saves/SAV2.cs
@@ -366,8 +366,8 @@ public override int Gender
}
public override ushort TID
{
- get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, 0x2009)); }
- set { BitConverter.GetBytes(Util.SwapEndianness(value)).CopyTo(Data, 0x2009); }
+ get { return BigEndian.ToUInt16(Data, 0x2009); }
+ set { BigEndian.GetBytes(value).CopyTo(Data, 0x2009); }
}
public override ushort SID
{
@@ -376,8 +376,8 @@ public override ushort SID
}
public override int PlayedHours
{
- get { return Util.SwapEndianness(BitConverter.ToUInt16(Data, TimePlayedOffset)); }
- set { BitConverter.GetBytes(Util.SwapEndianness((ushort)value)).CopyTo(Data,TimePlayedOffset); }
+ get { return BigEndian.ToUInt16(Data, TimePlayedOffset); }
+ set { BigEndian.GetBytes((ushort)value).CopyTo(Data,TimePlayedOffset); }
}
public override int PlayedMinutes
{
@@ -438,21 +438,21 @@ public int TextSpeed
}
public override uint Money
{
- get { return Util.SwapEndianness(BitConverter.ToUInt32(Data, MoneyOffset)) >> 8; }
+ get { return BigEndian.ToUInt32(Data, MoneyOffset) >> 8; }
set
{
- BitConverter.GetBytes(Util.SwapEndianness(value > 999999 ? 999999 : value)).Skip(1).ToArray().CopyTo(Data, MoneyOffset);
+ BigEndian.GetBytes(value > 999999 ? 999999 : value).Skip(1).ToArray().CopyTo(Data, MoneyOffset);
}
}
public uint Coin
{
get
{
- return Util.SwapEndianness(BitConverter.ToUInt16(Data, MoneyOffset+7));
+ return BigEndian.ToUInt16(Data, MoneyOffset+7);
}
set
{
- BitConverter.GetBytes(Util.SwapEndianness(value > 9999 ? 9999 : value)).ToArray().CopyTo(Data, MoneyOffset + 7);
+ BigEndian.GetBytes(value > 9999 ? 9999 : value).ToArray().CopyTo(Data, MoneyOffset + 7);
}
}
diff --git a/PKHeX/Saves/SAV3Colosseum.cs b/PKHeX/Saves/SAV3Colosseum.cs
index 449f0e2a4..216200da2 100644
--- a/PKHeX/Saves/SAV3Colosseum.cs
+++ b/PKHeX/Saves/SAV3Colosseum.cs
@@ -300,8 +300,8 @@ protected override void setDex(PKM pkm)
private TimeSpan PlayedSpan
{
- get { return TimeSpan.FromSeconds((double)(Util.SwapEndianness(BitConverter.ToUInt32(Data, 40)) - 0x47000000) / 128); }
- set { BitConverter.GetBytes(Util.SwapEndianness((uint)(value.TotalSeconds * 128) + 0x47000000)).CopyTo(Data, 40); }
+ get { return TimeSpan.FromSeconds((double)(BigEndian.ToUInt32(Data, 40) - 0x47000000) / 128); }
+ set { BigEndian.GetBytes((uint)(value.TotalSeconds * 128) + 0x47000000).CopyTo(Data, 40); }
}
public override int PlayedHours
{
diff --git a/PKHeX/Util/ByteUtil.cs b/PKHeX/Util/ByteUtil.cs
deleted file mode 100644
index 4c41fe1cf..000000000
--- a/PKHeX/Util/ByteUtil.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace PKHeX
-{
- public partial class Util
- {
- ///
- /// Swaps the Endianness of an int
- ///
- /// Value to swap endianness of.
- /// The endianness-swapped value.
- internal static int SwapEndianness(int val)
- {
- return (int) SwapEndianness((uint) val);
- }
-
- ///
- /// Swaps the Endianness of a uint
- ///
- /// Value to swap endianness of.
- /// The endianness-swapped value.
- internal static uint SwapEndianness(uint val)
- {
- return ((val & 0x000000FF) << 24)
- | ((val & 0x0000FF00) << 8)
- | ((val & 0x00FF0000) >> 8)
- | ((val & 0xFF000000) >> 24);
- }
-
- ///
- /// Swaps the Endianness of a short
- ///
- /// Value to swap endianness of.
- /// The endianness-swapped value.
- internal static short SwapEndianness(short val)
- {
- return (short)SwapEndianness((ushort)val);
- }
-
- ///
- /// Swaps the Endianness of a ushort
- ///
- /// Value to swap endianness of.
- /// The endianness-swapped value.
- internal static ushort SwapEndianness(ushort val)
- {
- return (ushort) (((val & 0x00FF) << 8) | ((val & 0xFF00) >> 8));
- }
- }
-}