Misc tweaks

This commit is contained in:
Kurt 2023-05-09 20:17:15 -07:00
parent 709da45449
commit 8a2f1d56c2
5 changed files with 25 additions and 20 deletions

View file

@ -87,7 +87,8 @@ public sealed class GameDataPA8 : HomeOptional1, IGameDataSide, IScaledSizeAbsol
pk.GV_SPE = GV_SPE;
pk.GV_SPA = GV_SPA;
pk.GV_SPD = GV_SPD;
Data.Slice(0x28, 8 + 8).CopyTo(pk.Data.AsSpan(0x155)); // Copy both bitflag regions
PurchasedRecord.CopyTo(pk.PurchasedRecord);
MasteredRecord.CopyTo(pk.MasteredRecord);
}
public PKM ConvertToPKM(PKH pkh) => ConvertToPA8(pkh);

View file

@ -50,11 +50,11 @@ public sealed class GameDataPK8 : HomeOptional1, IGameDataSide, IGigantamax, IDy
public byte Fullness { get => Data[0x2C]; set => Data[0x2C] = value; }
private Span<byte> RecordFlag => Data.Slice(0x2D, 14);
public bool GetMoveRecordFlag(int index) => FlagUtil.GetFlag(RecordFlag, index >> 3, index & 7);
public void SetMoveRecordFlag(int index, bool value) => FlagUtil.SetFlag(RecordFlag, index >> 3, index & 7, value);
public bool GetMoveRecordFlagAny() => RecordFlag.IndexOfAnyExcept<byte>(0) >= 0;
public void ClearMoveRecordFlags() => RecordFlag.Clear();
private Span<byte> RecordFlags => Data.Slice(0x2D, 14);
public bool GetMoveRecordFlag(int index) => FlagUtil.GetFlag(RecordFlags, index >> 3, index & 7);
public void SetMoveRecordFlag(int index, bool value) => FlagUtil.SetFlag(RecordFlags, index >> 3, index & 7, value);
public bool GetMoveRecordFlagAny() => RecordFlags.IndexOfAnyExcept<byte>(0) >= 0;
public void ClearMoveRecordFlags() => RecordFlags.Clear();
public int Palma { get => ReadInt32LittleEndian(Data[0x3B..]); set => WriteInt32LittleEndian(Data[0x3B..], value); }
public int Ball { get => Data[0x3F]; set => Data[0x3F] = (byte)value; }
@ -75,8 +75,8 @@ public sealed class GameDataPK8 : HomeOptional1, IGameDataSide, IGigantamax, IDy
pk.DynamaxLevel = DynamaxLevel;
pk.Fullness = Fullness;
pk.Palma = Palma;
PokeJob.CopyTo(pk.Data.AsSpan(0xCE)); // PokeJob
RecordFlag.CopyTo(pk.Data.AsSpan(0x127)); // Move Record
PokeJob.CopyTo(pk.PokeJob);
RecordFlags.CopyTo(pk.RecordFlags);
}
public PKM ConvertToPKM(PKH pkh) => ConvertToPK8(pkh);
@ -100,10 +100,14 @@ public sealed class GameDataPK8 : HomeOptional1, IGameDataSide, IGigantamax, IDy
var side = pkh.DataPB8 as IGameDataSide
?? pkh.DataPA8 as IGameDataSide
?? pkh.DataPK9;
if (side is null)
return null;
if (side is not null)
return Create(side, pkh.Version);
var ver = pkh.Version;
return null;
}
private static GameDataPK8 Create(IGameDataSide side, int ver)
{
var met = side.Met_Location;
var ball = GetBall(side.Ball);
var egg = GetEggLocation(side.Egg_Location);

View file

@ -504,13 +504,13 @@ public sealed class PA8 : PKM, ISanityChecksum, IMoveReset,
set => WriteUInt64LittleEndian(Data.AsSpan(0x14D), value);
}
private Span<byte> PurchasedRecord => Data.AsSpan(0x155, 8);
public Span<byte> PurchasedRecord => Data.AsSpan(0x155, 8);
public bool GetPurchasedRecordFlag(int index) => FlagUtil.GetFlag(PurchasedRecord, index >> 3, index & 7);
public void SetPurchasedRecordFlag(int index, bool value) => FlagUtil.SetFlag(PurchasedRecord, index >> 3, index & 7, value);
public bool GetPurchasedRecordFlagAny() => PurchasedRecord.IndexOfAnyExcept<byte>(0) >= 0;
public int GetPurchasedCount() => BitOperations.PopCount(ReadUInt64LittleEndian(PurchasedRecord));
private Span<byte> MasteredRecord => Data.AsSpan(0x15D, 8);
public Span<byte> MasteredRecord => Data.AsSpan(0x15D, 8);
public bool GetMasteredRecordFlag(int index) => FlagUtil.GetFlag(MasteredRecord, index >> 3, index & 7);
public void SetMasteredRecordFlag(int index, bool value) => FlagUtil.SetFlag(MasteredRecord, index >> 3, index & 7, value);
public bool GetMasteredRecordFlagAny() => MasteredRecord.IndexOfAnyExcept<byte>(0) >= 0;

View file

@ -467,7 +467,7 @@ public sealed class PK9 : PKM, ISanityChecksum, ITeraType, IMoveReset, ITechReco
private const int RecordStart = 0x12F;
internal const int COUNT_RECORD = 200; // Up to 200 TM flags, but not all are used.
private const int RecordLength = COUNT_RECORD / 8;
internal Span<byte> RecordFlags => Data.AsSpan(RecordStart, RecordLength);
public Span<byte> RecordFlags => Data.AsSpan(RecordStart, RecordLength);
public bool GetMoveRecordFlag(int index)
{

View file

@ -395,7 +395,7 @@ public abstract class G8PKM : PKM, ISanityChecksum, IMoveReset,
public byte HT_Feeling { get => Data[0xCB]; set => Data[0xCB] = value; }
public ushort HT_TextVar { get => ReadUInt16LittleEndian(Data.AsSpan(0xCC)); set => WriteUInt16LittleEndian(Data.AsSpan(0xCC), value); }
private Span<byte> PokeJob => Data.Slice(0xCE, 14);
public Span<byte> PokeJob => Data.Slice(0xCE, 14);
public bool GetPokeJobFlag(int index) => FlagUtil.GetFlag(PokeJob, index >> 3, index & 7);
public void SetPokeJobFlag(int index, bool value) => FlagUtil.SetFlag(PokeJob, index >> 3, index & 7, value);
public bool GetPokeJobFlagAny() => PokeJob.IndexOfAnyExcept<byte>(0) >= 0;
@ -450,11 +450,11 @@ public abstract class G8PKM : PKM, ISanityChecksum, IMoveReset,
public bool HT_SPD { get => ((HyperTrainFlags >> 4) & 1) == 1; set => HyperTrainFlags = (byte)((HyperTrainFlags & ~(1 << 4)) | ((value ? 1 : 0) << 4)); }
public bool HT_SPE { get => ((HyperTrainFlags >> 5) & 1) == 1; set => HyperTrainFlags = (byte)((HyperTrainFlags & ~(1 << 5)) | ((value ? 1 : 0) << 5)); }
private Span<byte> RecordFlag => Data.Slice(0x127, 14);
public bool GetMoveRecordFlag(int index) => FlagUtil.GetFlag(RecordFlag, index >> 3, index & 7);
public void SetMoveRecordFlag(int index, bool value) => FlagUtil.SetFlag(RecordFlag, index >> 3, index & 7, value);
public bool GetMoveRecordFlagAny() => RecordFlag.IndexOfAnyExcept<byte>(0) >= 0;
public void ClearMoveRecordFlags() => RecordFlag.Clear();
public Span<byte> RecordFlags => Data.Slice(0x127, 14);
public bool GetMoveRecordFlag(int index) => FlagUtil.GetFlag(RecordFlags, index >> 3, index & 7);
public void SetMoveRecordFlag(int index, bool value) => FlagUtil.SetFlag(RecordFlags, index >> 3, index & 7, value);
public bool GetMoveRecordFlagAny() => RecordFlags.IndexOfAnyExcept<byte>(0) >= 0;
public void ClearMoveRecordFlags() => RecordFlags.Clear();
// Why did you mis-align this field, GameFreak?
public ulong Tracker