Add ConfigCamera9

This commit is contained in:
sora10pls
2023-10-02 15:55:19 -04:00
parent 8b2b858e69
commit e58a1565ad
3 changed files with 48 additions and 1 deletions

View File

@@ -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

View File

@@ -0,0 +1,44 @@
using System;
using System.Buffers.Binary;
namespace PKHeX.Core;
public sealed class ConfigCamera9 : SaveBlock<SAV9SV>
{
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,
}

View File

@@ -58,5 +58,5 @@ public int ConfigValue
public enum ConfigOption9 : byte
{
On = 0,
off = 1,
Off = 1,
}