mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-15 00:21:23 -05:00
Merge dualbuffer into sav4
SAV3 has two general save chunks and storage SAV4 also has the hall of fame block, which is a third block; no mo silly names !
This commit is contained in:
parent
972e35a289
commit
229bb0d05d
|
|
@ -1,31 +0,0 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="SaveFile"/> format which stores Box Data in a separate buffer from the game data.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool GetFlag(int offset, int bitIndex) => FlagUtil.GetFlag(General, offset, bitIndex);
|
||||
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,10 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Generation 4 abstract <see cref="SaveFile"/> object.
|
||||
/// </summary>
|
||||
public abstract class SAV4 : DualBufferSAV
|
||||
/// <remarks>
|
||||
/// Storage data is stored in one contiguous block, and the remaining data is stored in another block.
|
||||
/// </remarks>
|
||||
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; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool GetFlag(int offset, int bitIndex) => FlagUtil.GetFlag(General, offset, bitIndex);
|
||||
|
||||
/// <inheritdoc />
|
||||
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<byte>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user