diff --git a/PKHeX.Core/Saves/DualBufferSAV.cs b/PKHeX.Core/Saves/DualBufferSAV.cs deleted file mode 100644 index 11a10f747..000000000 --- a/PKHeX.Core/Saves/DualBufferSAV.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace PKHeX.Core -{ - /// - /// format which stores Box Data in a separate buffer from the game data. - /// - public abstract class DualBufferSAV : SaveFile - { - protected DualBufferSAV(byte[] data) : base(data) { } - protected DualBufferSAV() { } - - // SaveData is chunked into two pieces. - public byte[] Storage { get; protected set; } - public byte[] General { get; protected set; } - - protected abstract int StorageSize { get; } - protected abstract int GeneralSize { get; } - protected abstract int StorageStart { get; } - - /// - public override bool GetFlag(int offset, int bitIndex) => FlagUtil.GetFlag(General, offset, bitIndex); - - /// - public override void SetFlag(int offset, int bitIndex, bool value) => FlagUtil.SetFlag(General, offset, bitIndex, value); - - public override PKM GetPartySlot(int offset) => GetDecryptedPKM(General.Slice(offset, SIZE_PARTY)); - - protected override void WritePartySlot(PKM pkm, int offset) => SetData(General, pkm.EncryptedPartyData, offset); - protected override void WriteStoredSlot(PKM pkm, int offset) => SetData(General, pkm.EncryptedBoxData, offset); - protected override void WriteBoxSlot(PKM pkm, int offset) => SetData(Storage, pkm.EncryptedBoxData, offset); - } -} \ No newline at end of file diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index 0eaff062d..97d269bc4 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -7,7 +7,10 @@ namespace PKHeX.Core /// /// Generation 4 abstract object. /// - public abstract class SAV4 : DualBufferSAV + /// + /// Storage data is stored in one contiguous block, and the remaining data is stored in another block. + /// + public abstract class SAV4 : SaveFile { protected override string BAKText => $"{OT} ({Version}) - {PlayTimeString}"; public override string Filter => (Footer.Length > 0 ? "DeSmuME DSV|*.dsv|" : string.Empty) + "SAV File|*.sav|All Files|*.*"; @@ -17,8 +20,27 @@ public abstract class SAV4 : DualBufferSAV private readonly int GeneralBlockPosition; // Small Block private readonly int StorageBlockPosition; // Big Block + // SaveData is chunked into two pieces. + protected readonly byte[] Storage; + public readonly byte[] General; protected override byte[] StorageData => Storage; + protected abstract int StorageSize { get; } + protected abstract int GeneralSize { get; } + protected abstract int StorageStart { get; } + + /// + public override bool GetFlag(int offset, int bitIndex) => FlagUtil.GetFlag(General, offset, bitIndex); + + /// + public override void SetFlag(int offset, int bitIndex, bool value) => FlagUtil.SetFlag(General, offset, bitIndex, value); + + public override PKM GetPartySlot(int offset) => GetDecryptedPKM(General.Slice(offset, SIZE_PARTY)); + + protected override void WritePartySlot(PKM pkm, int offset) => SetData(General, pkm.EncryptedPartyData, offset); + protected override void WriteStoredSlot(PKM pkm, int offset) => SetData(General, pkm.EncryptedBoxData, offset); + protected override void WriteBoxSlot(PKM pkm, int offset) => SetData(Storage, pkm.EncryptedBoxData, offset); + protected SAV4() { Data = BAK = Array.Empty();