2023-01-22 04:02:33 +00:00
|
|
|
using System;
|
2022-01-03 05:35:59 +00:00
|
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
2019-06-09 02:56:11 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Combined save block; 0x100 for first, 0x100 for second.
|
|
|
|
/// </summary>
|
2024-03-04 05:13:16 +00:00
|
|
|
public sealed class PlayerData5(SAV5 sav, Memory<byte> raw) : SaveBlock<SAV5>(sav, raw)
|
2019-06-09 02:56:11 +00:00
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
private Span<byte> OriginalTrainerTrash => Data.Slice(4, 0x10);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
public string OT
|
|
|
|
{
|
2024-02-23 03:20:54 +00:00
|
|
|
get => SAV.GetString(OriginalTrainerTrash);
|
|
|
|
set => SAV.SetString(OriginalTrainerTrash, value, SAV.MaxStringLengthOT, StringConverterOption.ClearZero);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public uint ID32
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => ReadUInt32LittleEndian(Data[0x14..]);
|
|
|
|
set => WriteUInt32LittleEndian(Data[0x14..], value);
|
2023-01-22 04:02:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ushort TID16
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => ReadUInt16LittleEndian(Data[(0x14 + 0)..]);
|
|
|
|
set => WriteUInt16LittleEndian(Data[(0x14 + 0)..], value);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public ushort SID16
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => ReadUInt16LittleEndian(Data[(0x14 + 2)..]);
|
|
|
|
set => WriteUInt16LittleEndian(Data[(0x14 + 2)..], value);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
2023-02-27 00:33:53 +00:00
|
|
|
public int Country
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x1C];
|
|
|
|
set => Data[0x1C] = (byte)value;
|
2023-02-27 00:33:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int Region
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x1D];
|
|
|
|
set => Data[0x1D] = (byte)value;
|
2023-02-27 00:33:53 +00:00
|
|
|
}
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int Language
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x1E];
|
|
|
|
set => Data[0x1E] = (byte)value;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
public byte Game
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x1F];
|
|
|
|
set => Data[0x1F] = value;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
2024-02-23 03:20:54 +00:00
|
|
|
public byte Gender
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x21];
|
|
|
|
set => Data[0x21] = value;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 22,23 ??
|
|
|
|
|
|
|
|
public int PlayedHours
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => ReadUInt16LittleEndian(Data[0x24..]);
|
|
|
|
set => WriteUInt16LittleEndian(Data[0x24..], (ushort)value);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int PlayedMinutes
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x24 + 2];
|
|
|
|
set => Data[0x24 + 2] = (byte)value;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int PlayedSeconds
|
|
|
|
{
|
2024-03-04 05:13:16 +00:00
|
|
|
get => Data[0x24 + 3];
|
|
|
|
set => Data[0x24 + 3] = (byte)value;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2024-03-05 05:46:11 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2024-03-05 05:46:11 +00:00
|
|
|
public sealed class PlayerPosition5(SAV5 sav, Memory<byte> raw) : SaveBlock<SAV5>(sav, raw)
|
|
|
|
{
|
|
|
|
public int M { get => ReadInt32LittleEndian(Data[0x80..]); set => WriteUInt16LittleEndian(Data[0x80..], (ushort)value); }
|
|
|
|
public int X { get => ReadUInt16LittleEndian(Data[0x86..]); set => WriteUInt16LittleEndian(Data[0x86..], (ushort)value); }
|
|
|
|
public int Z { get => ReadUInt16LittleEndian(Data[0x8A..]); set => WriteUInt16LittleEndian(Data[0x8A..], (ushort)value); }
|
|
|
|
public int Y { get => ReadUInt16LittleEndian(Data[0x8E..]); set => WriteUInt16LittleEndian(Data[0x8E..], (ushort)value); }
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|