diff --git a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs index 41126d456..8d1bf20c0 100644 --- a/PKHeX.Core/Editing/Saves/Slots/Extensions.cs +++ b/PKHeX.Core/Editing/Saves/Slots/Extensions.cs @@ -108,7 +108,7 @@ private static List GetExtraSlots6XY(SAV6XY sav) { new SlotInfoMisc(sav.Data, 0, sav.GTS) {Type = StorageSlotType.GTS}, new SlotInfoMisc(sav.Data, 0, sav.Fused) {Type = StorageSlotType.Fused}, - new SlotInfoMisc(sav.Data, 0, sav.SUBE) {Type = StorageSlotType.Misc}, + new SlotInfoMisc(sav.Data, 0, sav.SUBE.Offset + 0x90) {Type = StorageSlotType.Misc}, // Old Man new SlotInfoMisc(sav.Data, 0, sav.GetBattleBoxSlot(0)) {Type = StorageSlotType.BattleBox}, new SlotInfoMisc(sav.Data, 1, sav.GetBattleBoxSlot(1)) {Type = StorageSlotType.BattleBox}, diff --git a/PKHeX.Core/Saves/Access/ISaveBlock6Main.cs b/PKHeX.Core/Saves/Access/ISaveBlock6Main.cs index c24fec252..09c90a061 100644 --- a/PKHeX.Core/Saves/Access/ISaveBlock6Main.cs +++ b/PKHeX.Core/Saves/Access/ISaveBlock6Main.cs @@ -7,5 +7,6 @@ public interface ISaveBlock6Main : ISaveBlock6Core, IPokePuff, IOPower, ILink MysteryBlock6 MysteryGift { get; } SuperTrainBlock SuperTrain { get; } MaisonBlock Maison { get; } + SubEventLog6 SUBE { get; } } } \ No newline at end of file diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessorAO.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessorAO.cs index 9fee2d227..05b518493 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessorAO.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessorAO.cs @@ -33,7 +33,7 @@ public class SaveBlockAccessorAO : ISaveBlockAccessor, ISaveBlock6Ma new BlockInfo6(boAO, 22, 0x16A00, 0x00104), // 22 UnionPokemon new BlockInfo6(boAO, 23, 0x16C00, 0x00004), // 23 ConfigSave new BlockInfo6(boAO, 24, 0x16E00, 0x00420), // 24 Amie decoration stuff - new BlockInfo6(boAO, 25, 0x17400, 0x00064), // 25 OPower = 0x17400; + new BlockInfo6(boAO, 25, 0x17400, 0x00064), // 25 OPower new BlockInfo6(boAO, 26, 0x17600, 0x003F0), // 26 Strength Rock position (xyz float: 84 entries, 12bytes/entry) new BlockInfo6(boAO, 27, 0x17A00, 0x0070C), // 27 Trainer PR Video new BlockInfo6(boAO, 28, 0x18200, 0x00180), // 28 GtsData @@ -50,7 +50,7 @@ public class SaveBlockAccessorAO : ISaveBlockAccessor, ISaveBlock6Ma new BlockInfo6(boAO, 39, 0x1C000, 0x00216), // 39 BattleInstSave new BlockInfo6(boAO, 40, 0x1C400, 0x00640), // 40 BerryField new BlockInfo6(boAO, 41, 0x1CC00, 0x01A90), // 41 MysteryGiftSave - new BlockInfo6(boAO, 42, 0x1E800, 0x00400), // 42 Storyline Records + new BlockInfo6(boAO, 42, 0x1E800, 0x00400), // 42 [SubE]vent Log new BlockInfo6(boAO, 43, 0x1EC00, 0x00618), // 43 PokeDiarySave new BlockInfo6(boAO, 44, 0x1F400, 0x0025C), // 44 Record new BlockInfo6(boAO, 45, 0x1F800, 0x00834), // 45 Friend Safari (0x15 per entry, 100 entries) @@ -88,6 +88,7 @@ public class SaveBlockAccessorAO : ISaveBlockAccessor, ISaveBlock6Ma public Misc6AO Misc { get; } public SuperTrainBlock SuperTrain { get; } public MaisonBlock Maison { get; } + public SubEventLog6 SUBE { get; } public SaveBlockAccessorAO(SAV6AO sav) { @@ -105,6 +106,7 @@ public SaveBlockAccessorAO(SAV6AO sav) OPower = new OPower6(sav, 0x17400); Maison = new MaisonBlock(sav, 0x1BA00); MysteryGift = new MysteryBlock6(sav, 0x1CC00); + SUBE = new SubEventLog6AO(sav, 0x1E800); Records = new RecordBlock6(sav, 0x1F400); SuperTrain = new SuperTrainBlock(sav, 0x20200); Link = new LinkBlock6(sav, 0x20E00); diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessorAODemo.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessorAODemo.cs index 27bfe3aec..62d589d67 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessorAODemo.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessorAODemo.cs @@ -8,20 +8,20 @@ public class SaveBlockAccessorAODemo : ISaveBlockAccessor, ISaveBloc private static readonly BlockInfo6[] BlocksAODemo = { - new BlockInfo6(boAOdemo, 00, 0x00000, 0x00B90), // MyItem // Bag + new BlockInfo6(boAOdemo, 00, 0x00000, 0x00B90), // MyItem new BlockInfo6(boAOdemo, 01, 0x00C00, 0x0002C), // ItemInfo6 new BlockInfo6(boAOdemo, 02, 0x00E00, 0x00038), // GameTime new BlockInfo6(boAOdemo, 03, 0x01000, 0x00150), // Situation - new BlockInfo6(boAOdemo, 04, 0x01200, 0x00004), // [00004] RandomGroup (rand seeds) + new BlockInfo6(boAOdemo, 04, 0x01200, 0x00004), // RandomGroup (rand seeds) new BlockInfo6(boAOdemo, 05, 0x01400, 0x00008), // PlayTime - new BlockInfo6(boAOdemo, 06, 0x01600, 0x00024), // [00024] temp variables (u32 id + 32 u8) - new BlockInfo6(boAOdemo, 07, 0x01800, 0x02100), // [02100] FieldMoveModelSave + new BlockInfo6(boAOdemo, 06, 0x01600, 0x00024), // temp variables (u32 id + 32 u8) + new BlockInfo6(boAOdemo, 07, 0x01800, 0x02100), // FieldMoveModelSave new BlockInfo6(boAOdemo, 08, 0x03A00, 0x00130), // Misc new BlockInfo6(boAOdemo, 09, 0x03C00, 0x00170), // MyStatus new BlockInfo6(boAOdemo, 10, 0x03E00, 0x0061C), // PokePartySave new BlockInfo6(boAOdemo, 11, 0x04600, 0x00504), // EventWork - new BlockInfo6(boAOdemo, 12, 0x04C00, 0x00004), // [00004] Packed Menu Bits - new BlockInfo6(boAOdemo, 13, 0x04E00, 0x00048), // [00048] Repel Info, (Swarm?) and other overworld info (roamer) + new BlockInfo6(boAOdemo, 12, 0x04C00, 0x00004), // Packed Menu Bits + new BlockInfo6(boAOdemo, 13, 0x04E00, 0x00048), // Repel Info, (Swarm?) and other overworld info (roamer) new BlockInfo6(boAOdemo, 14, 0x05000, 0x00400), // PokeDiarySave new BlockInfo6(boAOdemo, 15, 0x05400, 0x0025C), // Record }; diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessorXY.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessorXY.cs index 332b5edd4..f1f9b306f 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessorXY.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessorXY.cs @@ -8,61 +8,61 @@ public class SaveBlockAccessorXY : ISaveBlockAccessor, ISaveBlock6XY public static readonly BlockInfo6[] BlocksXY = { - new BlockInfo6(boXY, 00, 0x00000, 0x002C8), - new BlockInfo6(boXY, 01, 0x00400, 0x00B88), - new BlockInfo6(boXY, 02, 0x01000, 0x0002C), - new BlockInfo6(boXY, 03, 0x01200, 0x00038), - new BlockInfo6(boXY, 04, 0x01400, 0x00150), - new BlockInfo6(boXY, 05, 0x01600, 0x00004), - new BlockInfo6(boXY, 06, 0x01800, 0x00008), - new BlockInfo6(boXY, 07, 0x01A00, 0x001C0), - new BlockInfo6(boXY, 08, 0x01C00, 0x000BE), - new BlockInfo6(boXY, 09, 0x01E00, 0x00024), - new BlockInfo6(boXY, 10, 0x02000, 0x02100), - new BlockInfo6(boXY, 11, 0x04200, 0x00140), - new BlockInfo6(boXY, 12, 0x04400, 0x00440), - new BlockInfo6(boXY, 13, 0x04A00, 0x00574), - new BlockInfo6(boXY, 14, 0x05000, 0x04E28), - new BlockInfo6(boXY, 15, 0x0A000, 0x04E28), - new BlockInfo6(boXY, 16, 0x0F000, 0x04E28), - new BlockInfo6(boXY, 17, 0x14000, 0x00170), - new BlockInfo6(boXY, 18, 0x14200, 0x0061C), - new BlockInfo6(boXY, 19, 0x14A00, 0x00504), - new BlockInfo6(boXY, 20, 0x15000, 0x006A0), - new BlockInfo6(boXY, 21, 0x15800, 0x00644), - new BlockInfo6(boXY, 22, 0x16000, 0x00104), - new BlockInfo6(boXY, 23, 0x16200, 0x00004), - new BlockInfo6(boXY, 24, 0x16400, 0x00420), - new BlockInfo6(boXY, 25, 0x16A00, 0x00064), - new BlockInfo6(boXY, 26, 0x16C00, 0x003F0), - new BlockInfo6(boXY, 27, 0x17000, 0x0070C), - new BlockInfo6(boXY, 28, 0x17800, 0x00180), - new BlockInfo6(boXY, 29, 0x17A00, 0x00004), - new BlockInfo6(boXY, 30, 0x17C00, 0x0000C), - new BlockInfo6(boXY, 31, 0x17E00, 0x00048), - new BlockInfo6(boXY, 32, 0x18000, 0x00054), - new BlockInfo6(boXY, 33, 0x18200, 0x00644), - new BlockInfo6(boXY, 34, 0x18A00, 0x005C8), - new BlockInfo6(boXY, 35, 0x19000, 0x002F8), - new BlockInfo6(boXY, 36, 0x19400, 0x01B40), - new BlockInfo6(boXY, 37, 0x1B000, 0x001F4), - new BlockInfo6(boXY, 38, 0x1B200, 0x001F0), - new BlockInfo6(boXY, 39, 0x1B400, 0x00216), - new BlockInfo6(boXY, 40, 0x1B800, 0x00390), - new BlockInfo6(boXY, 41, 0x1BC00, 0x01A90), - new BlockInfo6(boXY, 42, 0x1D800, 0x00308), - new BlockInfo6(boXY, 43, 0x1DC00, 0x00618), - new BlockInfo6(boXY, 44, 0x1E400, 0x0025C), - new BlockInfo6(boXY, 45, 0x1E800, 0x00834), - new BlockInfo6(boXY, 46, 0x1F200, 0x00318), - new BlockInfo6(boXY, 47, 0x1F600, 0x007D0), - new BlockInfo6(boXY, 48, 0x1FE00, 0x00C48), - new BlockInfo6(boXY, 49, 0x20C00, 0x00078), - new BlockInfo6(boXY, 50, 0x20E00, 0x00200), - new BlockInfo6(boXY, 51, 0x21000, 0x00C84), - new BlockInfo6(boXY, 52, 0x21E00, 0x00628), - new BlockInfo6(boXY, 53, 0x22600, 0x34AD0), - new BlockInfo6(boXY, 54, 0x57200, 0x0E058), + new BlockInfo6(boXY, 00, 0x00000, 0x002C8), // 00 Puff + new BlockInfo6(boXY, 01, 0x00400, 0x00B88), // 01 MyItem + new BlockInfo6(boXY, 02, 0x01000, 0x0002C), // 02 ItemInfo (Select Bound Items) + new BlockInfo6(boXY, 03, 0x01200, 0x00038), // 03 GameTime + new BlockInfo6(boXY, 04, 0x01400, 0x00150), // 04 Situation + new BlockInfo6(boXY, 05, 0x01600, 0x00004), // 05 RandomGroup (rand seeds) + new BlockInfo6(boXY, 06, 0x01800, 0x00008), // 06 PlayTime + new BlockInfo6(boXY, 07, 0x01A00, 0x001C0), // 07 Fashion + new BlockInfo6(boXY, 08, 0x01C00, 0x000BE), // 08 Amie minigame records + new BlockInfo6(boXY, 09, 0x01E00, 0x00024), // 09 temp variables (u32 id + 32 u8) + new BlockInfo6(boXY, 10, 0x02000, 0x02100), // 10 FieldMoveModelSave + new BlockInfo6(boXY, 11, 0x04200, 0x00140), // 11 Misc + new BlockInfo6(boXY, 12, 0x04400, 0x00440), // 12 BOX + new BlockInfo6(boXY, 13, 0x04A00, 0x00574), // 13 BattleBox + new BlockInfo6(boXY, 14, 0x05000, 0x04E28), // 14 PSS1 + new BlockInfo6(boXY, 15, 0x0A000, 0x04E28), // 15 PSS2 + new BlockInfo6(boXY, 16, 0x0F000, 0x04E28), // 16 PSS3 + new BlockInfo6(boXY, 17, 0x14000, 0x00170), // 17 MyStatus + new BlockInfo6(boXY, 18, 0x14200, 0x0061C), // 18 PokePartySave + new BlockInfo6(boXY, 19, 0x14A00, 0x00504), // 19 EventWork + new BlockInfo6(boXY, 20, 0x15000, 0x006A0), // 20 ZukanData + new BlockInfo6(boXY, 21, 0x15800, 0x00644), // 21 hologram clips + new BlockInfo6(boXY, 22, 0x16000, 0x00104), // 22 UnionPokemon + new BlockInfo6(boXY, 23, 0x16200, 0x00004), // 23 ConfigSave + new BlockInfo6(boXY, 24, 0x16400, 0x00420), // 24 Amie decoration stuff + new BlockInfo6(boXY, 25, 0x16A00, 0x00064), // 25 OPower + new BlockInfo6(boXY, 26, 0x16C00, 0x003F0), // 26 Strength Rock position (xyz float: 84 entries, 12bytes/entry) + new BlockInfo6(boXY, 27, 0x17000, 0x0070C), // 27 Trainer PR Video + new BlockInfo6(boXY, 28, 0x17800, 0x00180), // 28 GtsData + new BlockInfo6(boXY, 29, 0x17A00, 0x00004), // 29 Packed Menu Bits + new BlockInfo6(boXY, 30, 0x17C00, 0x0000C), // 30 PSS Profile Q&A (6*questions, 6*answer) + new BlockInfo6(boXY, 31, 0x17E00, 0x00048), // 31 Repel Info, (Swarm?) and other overworld info (roamer) + new BlockInfo6(boXY, 32, 0x18000, 0x00054), // 32 BOSS data fetch history (serial/mystery gift), 4byte intro & 20*4byte entries + new BlockInfo6(boXY, 33, 0x18200, 0x00644), // 33 Streetpass history + new BlockInfo6(boXY, 34, 0x18A00, 0x005C8), // 34 LiveMatchData/BattleSpotData + new BlockInfo6(boXY, 35, 0x19000, 0x002F8), // 35 MAC Address & Network Connection Logging (0x98 per entry, 5 entries) + new BlockInfo6(boXY, 36, 0x19400, 0x01B40), // 36 Dendou (Hall of Fame) + new BlockInfo6(boXY, 37, 0x1B000, 0x001F4), // 37 BattleInstSave (Maison) + new BlockInfo6(boXY, 38, 0x1B200, 0x001F0), // 38 Sodateya (Daycare) + new BlockInfo6(boXY, 39, 0x1B400, 0x00216), // 39 BattleInstSave + new BlockInfo6(boXY, 40, 0x1B800, 0x00390), // 40 + new BlockInfo6(boXY, 41, 0x1BC00, 0x01A90), // 41 MysteryGiftSave + new BlockInfo6(boXY, 42, 0x1D800, 0x00308), // 42 [SubE]vent Log + new BlockInfo6(boXY, 43, 0x1DC00, 0x00618), // 43 PokeDiarySave + new BlockInfo6(boXY, 44, 0x1E400, 0x0025C), // 44 Record + new BlockInfo6(boXY, 45, 0x1E800, 0x00834), // 45 Friend Safari (0x15 per entry, 100 entries) + new BlockInfo6(boXY, 46, 0x1F200, 0x00318), // 46 SuperTrain + new BlockInfo6(boXY, 47, 0x1F600, 0x007D0), // 47 Unused (lmao) + new BlockInfo6(boXY, 48, 0x1FE00, 0x00C48), // 48 LinkInfo + new BlockInfo6(boXY, 49, 0x20C00, 0x00078), // 49 PSS usage info + new BlockInfo6(boXY, 50, 0x20E00, 0x00200), // 50 GameSyncSave + new BlockInfo6(boXY, 51, 0x21000, 0x00C84), // 51 PSS Icon (bool32 data present, 40x40 u16 pic, unused) + new BlockInfo6(boXY, 52, 0x21E00, 0x00628), // 52 ValidationSave (updatabale Public Key for legal check api calls) + new BlockInfo6(boXY, 53, 0x22600, 0x34AD0), // 53 Box + new BlockInfo6(boXY, 54, 0x57200, 0x0E058), // 54 JPEG }; public IReadOnlyList BlockInfo => BlocksXY; @@ -73,6 +73,7 @@ public class SaveBlockAccessorXY : ISaveBlockAccessor, ISaveBlock6XY public PlayTime6 Played { get; } public MyStatus6 Status { get; } public RecordBlock6 Records { get; } + public SubEventLog6 SUBE { get; } public SaveBlockAccessorXY(SAV6XY sav) { @@ -90,6 +91,7 @@ public SaveBlockAccessorXY(SAV6XY sav) Zukan = new Zukan6XY(sav, 0x15000, 0x3C8); OPower = new OPower6(sav, 0x16A00); MysteryGift = new MysteryBlock6(sav, 0x1BC00); + SUBE = new SubEventLog6XY(sav, 0x1D800); Records = new RecordBlock6(sav, 0x1E400); SuperTrain = new SuperTrainBlock(sav, 0x1F200); Link = new LinkBlock6(sav, 0x1FE00); diff --git a/PKHeX.Core/Saves/SAV6.cs b/PKHeX.Core/Saves/SAV6.cs index cc618ffda..be593bbc7 100644 --- a/PKHeX.Core/Saves/SAV6.cs +++ b/PKHeX.Core/Saves/SAV6.cs @@ -42,7 +42,6 @@ public abstract class SAV6 : SAV_BEEF, ITrainerStatRecord, ISaveBlock6Core protected int WondercardFlags { get; set; } = int.MinValue; protected int JPEG { get; set; } = int.MinValue; public int PSS { get; protected set; } = int.MinValue; - public int SUBE { get; protected set; } = int.MinValue; public int BerryField { get; protected set; } = int.MinValue; public int HoF { get; protected set; } = int.MinValue; protected int PCLayout { private get; set; } = int.MinValue; diff --git a/PKHeX.Core/Saves/SAV6AO.cs b/PKHeX.Core/Saves/SAV6AO.cs index 5b437e8dd..ad6ea46bf 100644 --- a/PKHeX.Core/Saves/SAV6AO.cs +++ b/PKHeX.Core/Saves/SAV6AO.cs @@ -36,7 +36,6 @@ private void Initialize() { GTS = 0x18200; // GtsData Fused = 0x16A00; // UnionPokemon - SUBE = 0x1D890; // PokeDiarySave PCLayout = 0x04400; BattleBoxOffset = 0x04A00; @@ -83,6 +82,7 @@ private void Initialize() public MysteryBlock6 MysteryGift => Blocks.MysteryGift; public SuperTrainBlock SuperTrain => Blocks.SuperTrain; public MaisonBlock Maison => Blocks.Maison; + public SubEventLog6 SUBE => Blocks.SUBE; public Misc6AO Misc => Blocks.Misc; public Zukan6AO Zukan => Blocks.Zukan; @@ -185,34 +185,6 @@ public override void SetDaycareHasEgg(int loc, bool hasEgg) protected override bool[] MysteryGiftReceivedFlags { get => Blocks.MysteryGift.MysteryGiftReceivedFlags; set => Blocks.MysteryGift.MysteryGiftReceivedFlags = value; } protected override DataMysteryGift[] MysteryGiftCards { get => Blocks.MysteryGift.MysteryGiftCards; set => Blocks.MysteryGift.MysteryGiftCards = value; } - // Gym History - public ushort[][] GymTeams - { - get - { - const int teamsize = 2 * 6; // 2byte/species, 6species/team - const int size = teamsize * 8; // 8 gyms - int ofs = SUBE - size - 4; - - var data = GetData(ofs, size); - ushort[][] teams = new ushort[8][]; - for (int i = 0; i < teams.Length; i++) - Buffer.BlockCopy(data, teamsize * i, teams[i] = new ushort[6], 0, teamsize); - return teams; - } - set - { - const int teamsize = 2 * 6; // 2byte/species, 6species/team - const int size = teamsize * 8; // 8 gyms - int ofs = SUBE - size - 4; - - byte[] data = new byte[size]; - for (int i = 0; i < value.Length; i++) - Buffer.BlockCopy(value[i], 0, data, teamsize * i, teamsize); - SetData(data, ofs); - } - } - public override int CurrentBox { get => Blocks.BoxLayout.CurrentBox; set => Blocks.BoxLayout.CurrentBox = value; } protected override int GetBoxWallpaperOffset(int box) => Blocks.BoxLayout.GetBoxWallpaperOffset(box); public override int BoxesUnlocked { get => Blocks.BoxLayout.BoxesUnlocked; set => Blocks.BoxLayout.BoxesUnlocked = value; } diff --git a/PKHeX.Core/Saves/SAV6XY.cs b/PKHeX.Core/Saves/SAV6XY.cs index 00c60480c..1b11fb07f 100644 --- a/PKHeX.Core/Saves/SAV6XY.cs +++ b/PKHeX.Core/Saves/SAV6XY.cs @@ -54,7 +54,6 @@ private void Initialize() // Extra Viewable Slots Fused = 0x16000; GTS = 0x17800; - SUBE = 0x1D890; } public int GTS { get; private set; } = int.MinValue; @@ -80,6 +79,7 @@ private void Initialize() public Zukan6XY Zukan => Blocks.Zukan; public Misc6XY Misc => Blocks.Misc; public Fashion6XY Fashion => Blocks.Fashion; + public SubEventLog6 SUBE => Blocks.SUBE; #endregion protected override void SetDex(PKM pkm) => Blocks.Zukan.SetDex(pkm); @@ -120,34 +120,6 @@ public override void SetDaycareRNGSeed(int loc, string seed) private bool HasJPPEGData => Data[JPEG + 0x54] == 0xFF; - // Gym History - public ushort[][] GymTeams - { - get - { - const int teamsize = 2 * 6; // 2byte/species, 6species/team - const int size = teamsize * 8; // 8 gyms - int ofs = SUBE - size - 4; - - var data = GetData(ofs, size); - ushort[][] teams = new ushort[8][]; - for (int i = 0; i < teams.Length; i++) - Buffer.BlockCopy(data, teamsize * i, teams[i] = new ushort[6], 0, teamsize); - return teams; - } - set - { - const int teamsize = 2 * 6; // 2byte/species, 6species/team - const int size = teamsize * 8; // 8 gyms - int ofs = SUBE - size - 4; - - byte[] data = new byte[size]; - for (int i = 0; i < value.Length; i++) - Buffer.BlockCopy(value[i], 0, data, teamsize * i, teamsize); - SetData(data, ofs); - } - } - public void UnlockAllFriendSafariSlots() { // Unlock + reveal all safari slots if friend data is present diff --git a/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs b/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs new file mode 100644 index 000000000..3b6d499cf --- /dev/null +++ b/PKHeX.Core/Saves/Substructures/Gen6/SubEventLog6.cs @@ -0,0 +1,45 @@ +using System; + +namespace PKHeX.Core +{ + public abstract class SubEventLog6 : SaveBlock + { + protected SubEventLog6(SAV6 sav, int offset) : base(sav) => Offset = offset; + + protected abstract int BadgeVictoryOffset { get; } + + private int GetBadgeVictorySpeciesOffset(uint badge, uint slot) + { + if (badge >= 8) + throw new ArgumentException(nameof(badge)); + if (slot >= 6) + throw new ArgumentException(nameof(slot)); + + return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort)); + } + + public ushort GetBadgeVictorySpecies(uint badge, uint slot) + { + var ofs = GetBadgeVictorySpeciesOffset(badge, slot); + return BitConverter.ToUInt16(Data, ofs); + } + + public void GetBadgeVictorySpecies(uint badge, uint slot, ushort species) + { + var ofs = GetBadgeVictorySpeciesOffset(badge, slot); + SAV.SetData(BitConverter.GetBytes(species), ofs); + } + } + + public sealed class SubEventLog6XY : SubEventLog6 + { + public SubEventLog6XY(SAV6XY sav, int offset) : base(sav, offset) { } + protected override int BadgeVictoryOffset => 0x2C; // thru 0x8B + } + + public sealed class SubEventLog6AO : SubEventLog6 + { + public SubEventLog6AO(SAV6AO sav, int offset) : base(sav, offset) { } + protected override int BadgeVictoryOffset => 0x60; // thru 0xBF + } +} \ No newline at end of file