From ebed1026cd4d75c1cb6c565b8ac30498ae8ca1ca Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 12 Jul 2018 23:23:36 -0700 Subject: [PATCH] Update national dex magic setting bulbapedia is wrong, first 4 bytes are info values: 0x0 = dex order (alphabetical, numerical), unused in frlg 0x1 = mode (unused in frlg), regional vs national 0x2 = national magic rse (always set in frlg) 0x3 = national magic frlg (never set in rse) refer to disassembly (pokefirered isn't too helpful, less developed. just compare save files & edit ram!) the other 2 values being set are the eventflag & event const, could use the abstraction for those rather than direct ofs writes --- PKHeX.Core/Saves/SAV3.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs index 759fac805..851a52d26 100644 --- a/PKHeX.Core/Saves/SAV3.cs +++ b/PKHeX.Core/Saves/SAV3.cs @@ -655,9 +655,9 @@ public bool NationalDex { case GameVersion.RS: case GameVersion.E: - return BitConverter.ToUInt16(Data, BlockOfs[0] + 0x19) == 0xDA01; + return Data[PokeDex + 2] == 0xDA; // enable nat dex option magic value case GameVersion.FRLG: - return Data[BlockOfs[0] + 0x1B] == 0xB9; + return Data[PokeDex + 3] == 0xB9; } return false; } @@ -668,19 +668,22 @@ public bool NationalDex switch (Version) { case GameVersion.RS: - BitConverter.GetBytes((ushort)(value ? 0xDA01 : 0)).CopyTo(Data, BlockOfs[0] + 0x19); // A + Data[PokeDex + 1] = (byte)(value ? 1 : 0); // mode + Data[PokeDex + 2] = (byte)(value ? 0xDA : 0); // magic Data[BlockOfs[2] + 0x3A6] &= 0xBF; Data[BlockOfs[2] + 0x3A6] |= (byte)(value ? 1 << 6 : 0); // B BitConverter.GetBytes((ushort)(value ? 0x0302 : 0)).CopyTo(Data, BlockOfs[2] + 0x44C); // C break; case GameVersion.E: - BitConverter.GetBytes((ushort)(value ? 0xDA01 : 0)).CopyTo(Data, BlockOfs[0] + 0x19); // A + Data[PokeDex + 1] = (byte)(value ? 1 : 0); // mode + Data[PokeDex + 2] = (byte)(value ? 0xDA : 0); // magic Data[BlockOfs[2] + 0x402] &= 0xBF; // Bit6 Data[BlockOfs[2] + 0x402] |= (byte)(value ? 1 << 6 : 0); // B BitConverter.GetBytes((ushort)(value ? 0x6258 : 0)).CopyTo(Data, BlockOfs[2] + 0x4A8); // C break; case GameVersion.FRLG: - Data[BlockOfs[0] + 0x1B] = (byte)(value ? 0xB9 : 0); // A + Data[PokeDex + 2] = (byte)(value ? 0xDA : 0); // magic + Data[PokeDex + 3] = (byte)(value ? 0xB9 : 0); // magic Data[BlockOfs[2] + 0x68] &= 0xFE; Data[BlockOfs[2] + 0x68] |= (byte)(value ? 1 : 0); // B BitConverter.GetBytes((ushort)(value ? 0x6258 : 0)).CopyTo(Data, BlockOfs[2] + 0x11C); // C