From e58a1565ad2e4d9d4e6b99c98ba751077fe6f7a8 Mon Sep 17 00:00:00 2001 From: sora10pls <17801814+sora10pls@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:55:19 -0400 Subject: [PATCH] Add ConfigCamera9 --- .../Saves/Access/SaveBlockAccessor9SV.cs | 3 ++ .../Saves/Substructures/Gen9/ConfigCamera9.cs | 44 +++++++++++++++++++ .../Saves/Substructures/Gen9/ConfigSave9.cs | 2 +- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs diff --git a/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs b/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs index 8a941ea34..37edffc9b 100644 --- a/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs +++ b/PKHeX.Core/Saves/Access/SaveBlockAccessor9SV.cs @@ -20,6 +20,7 @@ public sealed class SaveBlockAccessor9SV : SCBlockAccessor, ISaveBlock9Main public PlayTime9 Played { get; } public Zukan9 Zukan { get; } public ConfigSave9 Config { get; } + public ConfigCamera9 ConfigCamera { get; } public TeamIndexes9 TeamIndexes { get; } public Epoch1970Value LastSaved { get; } public PlayerFashion9 PlayerFashion { get; } @@ -40,6 +41,7 @@ public SaveBlockAccessor9SV(SAV9SV sav) Played = new PlayTime9(sav, GetBlock(KPlayTime)); Zukan = new Zukan9(sav, GetBlock(KZukan), GetBlockSafe(KZukanT1)); Config = new ConfigSave9(sav, GetBlock(KConfig)); + ConfigCamera = new ConfigCamera9(sav, GetBlock(KConfigCamera)); TeamIndexes = new TeamIndexes9(sav, GetBlock(KTeamIndexes)); LastSaved = new Epoch1970Value(GetBlock(KLastSaved)); PlayerFashion = new PlayerFashion9(sav, GetBlock(KCurrentClothing)); @@ -63,6 +65,7 @@ public SaveBlockAccessor9SV(SAV9SV sav) public const uint KLeaguePoints = 0xADB4FE17; // u32 private const uint KMyStatus = 0xE3E89BD1; // Trainer Details private const uint KConfig = 0xDF4F1875; // u32 bits + private const uint KConfigCamera = 0x998844C9; // u32 bits private const uint KItem = 0x21C9BD44; // Items private const uint KPlayTime = 0xEDAFF794; // Time Played private const uint KSessionLength = 0x1522C79C; // Milliseconds(?) elapsed diff --git a/PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs b/PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs new file mode 100644 index 000000000..25745a6f3 --- /dev/null +++ b/PKHeX.Core/Saves/Substructures/Gen9/ConfigCamera9.cs @@ -0,0 +1,44 @@ +using System; +using System.Buffers.Binary; + +namespace PKHeX.Core; + +public sealed class ConfigCamera9 : SaveBlock +{ + public ConfigCamera9(SAV9SV sav, SCBlock block) : base(sav, block.Data) { } + + // Structure: u32 + /* CameraSupport:1 | On = 0, Off = 1 + * CameraInterpolation:1 | Slow = 0, Normal = 1 + * CameraDistance:2 | Close = 0, Normal = 1, Far = 2 + * + * Remaining 28 bits unused? + */ + + public int ConfigValue + { + get => BinaryPrimitives.ReadInt32LittleEndian(Data.AsSpan(Offset)); + set => BinaryPrimitives.WriteInt32LittleEndian(Data.AsSpan(Offset), value); + } + + private const int DefaultValue = 0x00000002; + + public void Reset() => ConfigValue = DefaultValue; + + public ConfigOption9 CameraSupport { get => (ConfigOption9)((ConfigValue >> 0) & 1); set => ConfigValue = (ConfigValue & ~(1 << 0)) | ((((int)value) & 1) << 0); } + public CameraInterpolation9 CameraInterpolation { get => (CameraInterpolation9)((ConfigValue >> 1) & 1); set => ConfigValue = (ConfigValue & ~(1 << 1)) | ((((int)value) & 1) << 1); } + public CameraDistance9 CameraDistance { get => (CameraDistance9)(ConfigValue >> 2); set => ConfigValue = (ConfigValue & ~(0b11 << 2)) | (((int)value & 0b11) << 2); } +} + +public enum CameraInterpolation9 : byte +{ + Slow = 0, + Normal = 1, +} + +public enum CameraDistance9 : byte +{ + Close = 0, + Normal = 1, + Far = 2, +} diff --git a/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs b/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs index cdf244ae5..59147a020 100644 --- a/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs +++ b/PKHeX.Core/Saves/Substructures/Gen9/ConfigSave9.cs @@ -58,5 +58,5 @@ public int ConfigValue public enum ConfigOption9 : byte { On = 0, - off = 1, + Off = 1, }