diff --git a/PKHeX.Core/Saves/SAV8BS.cs b/PKHeX.Core/Saves/SAV8BS.cs index 37f7b3778..e1dfafd6c 100644 --- a/PKHeX.Core/Saves/SAV8BS.cs +++ b/PKHeX.Core/Saves/SAV8BS.cs @@ -24,7 +24,7 @@ public SAV8BS(byte[] data, bool exportable = true) : base(data, exportable) Work = new FlagWork8b(this, 0x00004); Items = new MyItem8b(this, 0x0563C); Underground = new UndergroundItemList8b(this, 0x111BC); - // saveItemShortcut; ushort[4] + SelectBoundItems = new SaveItemShortcut8b(this, 0x14090); // size: 0x8 PartyInfo = new Party8b(this, 0x14098); BoxLayout = new BoxLayout8b(this, 0x148AA); // size: 0x64A // 0x14EF4 - Box[40] @@ -37,15 +37,15 @@ public SAV8BS(byte[] data, bool exportable = true) : base(data, exportable) Zukan = new Zukan8b(this, 0x7A328); // size: 0x30B8 BattleTrainer = new BattleTrainerStatus8b(this, 0x7D3E0); // size: 0x1618 - // 0x7E9F8 - Menu selections (TopMenuItemTypeInt32, bool IsNew)[8], TopMenuItemTypeInt32 LastSelected - FieldObjects = new FieldObjectSave8b(this, 0x7EA3C); // + MenuSelection = new MenuSelect8b(this, 0x7E9F8); // size: 0x44 + FieldObjects = new FieldObjectSave8b(this, 0x7EA3C); // size: 0x109A0 (1000 * 0x44) Records = new Record8b(this, 0x8F3DC); // size: 0x78 * 12 Encounter = new EncounterSave8b(this, 0x8F97C); // size: 0x188 Player = new PlayerData8b(this, 0x8FB04); // 0x80 SealDeco = new SealBallDecoData8b(this, 0x8FB84); // size: 0x4288 SealList = new SealList8b(this, 0x93E0C); // size: 0x960 SaveSealData[200] Random = new RandomGroup8b(this, 0x9476C); // size: 0x630 - // FieldGimmickSaveData; int[3] gearRotate + FieldGimmick = new FieldGimmickSave8b(this, 0x94D9C); // FieldGimmickSaveData; int[3] gearRotate BerryTrees = new BerryTreeGrowSave8b(this, 0x94DA8); // size: 0x808 Poffins = new PoffinSaveData8b(this, 0x955B0); // size: 0x644 BattleTower = new BattleTowerWork8b(this, 0x95BF4); // size: 0x1B8 @@ -194,6 +194,7 @@ public override bool ChecksumsValid public FlagWork8b Work { get; } public MyItem8b Items { get; } public UndergroundItemList8b Underground { get; } + public SaveItemShortcut8b SelectBoundItems { get; } public Party8b PartyInfo { get; } // public MyItem Items { get; } public BoxLayout8b BoxLayout { get; } @@ -204,6 +205,7 @@ public override bool ChecksumsValid // public Misc8 Misc { get; } public Zukan8b Zukan { get; } public BattleTrainerStatus8b BattleTrainer { get; } + public MenuSelect8b MenuSelection { get; } public FieldObjectSave8b FieldObjects { get; } public Record8b Records { get; } public EncounterSave8b Encounter { get; } @@ -211,6 +213,7 @@ public override bool ChecksumsValid public SealBallDecoData8b SealDeco { get; } public SealList8b SealList { get; } public RandomGroup8b Random { get; } + public FieldGimmickSave8b FieldGimmick { get; } public BerryTreeGrowSave8b BerryTrees { get; } public PoffinSaveData8b Poffins { get; } public BattleTowerWork8b BattleTower { get; } diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/FieldGimmickSave8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/FieldGimmickSave8b.cs new file mode 100644 index 000000000..e1c7942a7 --- /dev/null +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/FieldGimmickSave8b.cs @@ -0,0 +1,18 @@ +using System; +using System.ComponentModel; + +namespace PKHeX.Core +{ + /// + /// size: 0xC + /// + [TypeConverter(typeof(ExpandableObjectConverter))] + public sealed class FieldGimmickSave8b : SaveBlock + { + public FieldGimmickSave8b(SAV8BS sav, int offset) : base(sav) => Offset = offset; + + public int Value0 { get => BitConverter.ToInt32(Data, Offset + 0x00); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x00); } + public int Value1 { get => BitConverter.ToInt32(Data, Offset + 0x04); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x04); } + public int Value2 { get => BitConverter.ToInt32(Data, Offset + 0x08); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x08); } + } +} diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/MenuSelect8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/MenuSelect8b.cs new file mode 100644 index 000000000..3376644a3 --- /dev/null +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/MenuSelect8b.cs @@ -0,0 +1,50 @@ +using System; +using System.ComponentModel; + +namespace PKHeX.Core +{ + /// + /// Tracks the main menu items. Size: 0x44 + /// + [TypeConverter(typeof(ExpandableObjectConverter))] + public sealed class MenuSelect8b : SaveBlock + { + // (TopMenuItemTypeInt32, bool IsNew)[8], TopMenuItemTypeInt32 LastSelected + private const int COUNT_ITEMS = 8; + private const int SIZE_TUPLE = 4 + 4; // int,bool32 + public MenuSelect8b(SAV8BS sav, int offset) : base(sav) => Offset = offset; + + public int GetMenuItem(int index) + { + int ofs = GetOffset(index); + return BitConverter.ToInt32(Data, Offset + ofs); + } + + public void SetMenuItem(int index, int value) + { + int ofs = GetOffset(index); + BitConverter.GetBytes(value).CopyTo(Data, Offset + ofs); + } + + public bool GetMenuItemIsNew(int index) + { + int ofs = GetOffset(index); + return BitConverter.ToInt32(Data, Offset + ofs + 4) == 1; + } + + public void SetMenuItemIsNew(int index, bool value) + { + int ofs = GetOffset(index); + BitConverter.GetBytes(value).CopyTo(Data, Offset + ofs + 4); + } + + private static int GetOffset(int index) + { + if ((uint)index >= COUNT_ITEMS) + throw new ArgumentOutOfRangeException(nameof(index)); + return index * SIZE_TUPLE; + } + + public int LastSelectedMenu { get => BitConverter.ToInt32(Data, Offset + 0x40); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x40); } + } +} diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/SaveItemShortcut8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/SaveItemShortcut8b.cs new file mode 100644 index 000000000..746d9c2b9 --- /dev/null +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/SaveItemShortcut8b.cs @@ -0,0 +1,19 @@ +using System; +using System.ComponentModel; + +namespace PKHeX.Core +{ + /// + /// Tracks the 4 select bound item slots. Size: 0x8 (4 * u16) + /// + [TypeConverter(typeof(ExpandableObjectConverter))] + public sealed class SaveItemShortcut8b : SaveBlock + { + public SaveItemShortcut8b(SAV8BS sav, int offset) : base(sav) => Offset = offset; + + public int Item0 { get => BitConverter.ToInt32(Data, Offset + 0x00); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x00); } + public int Item1 { get => BitConverter.ToInt32(Data, Offset + 0x02); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x02); } + public int Item2 { get => BitConverter.ToInt32(Data, Offset + 0x04); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x04); } + public int Item3 { get => BitConverter.ToInt32(Data, Offset + 0x06); set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x06); } + } +}