Fixed some SecretBase3 issues (#4305)

* Fixed some SecretBase3 issues

* Allow settings SpriteItems, use ushort for TID16
This commit is contained in:
BlackShark 2024-06-22 04:27:33 +02:00 committed by GitHub
parent 2ab07201bd
commit 9ca0a46715
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 15 deletions

View File

@ -68,15 +68,15 @@ public SecretBase3Team Team
set => value.Write().CopyTo(TeamData);
}
public int TID16
public ushort TID16
{
get => (ushort)OT_ID;
set => OT_ID = (ushort)(SID16 | (ushort)value);
set => OT_ID = (ushort)(SID16 | value);
}
public int SID16
public ushort SID16
{
get => (ushort)OT_ID >> 8;
set => OT_ID = (ushort)(((ushort)value << 16) | TID16);
get => (ushort)(OT_ID >> 16);
set => OT_ID = (ushort)((value << 16) | TID16);
}
}

View File

@ -18,6 +18,7 @@ public ushort Species
set => SpeciesInternal = SpeciesConverter.GetInternal3(value);
}
public ushort HeldItem { get; set; }
public ushort SpriteItem { get => ItemConverter.GetItemFuture3(HeldItem); set => HeldItem = ItemConverter.GetItemOld3(value); }
public byte Level { get; set; }
public byte EVAll { get; set; }
@ -45,7 +46,7 @@ private string GetSummary(StringBuilder sb, IBasicStrings g)
{
sb.Append($"{Species:000} - {g.Species[Species]}");
if (HeldItem != 0)
sb.Append($" @ {g.Item[HeldItem]}");
sb.Append($" @ {g.Item[SpriteItem]}");
sb.AppendLine();
var moveNames = g.Move;

View File

@ -37,22 +37,22 @@ public byte[] Write()
private SecretBase3PKM GetPKM(int index) => new()
{
PID = ReadUInt32LittleEndian(Data.AsSpan(GetOffsetPID(index))),
Species = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetSpecies(index))),
PID = ReadUInt32LittleEndian(Data.AsSpan(GetOffsetPID(index))),
SpeciesInternal = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetSpecies(index))),
HeldItem = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetItem(index))),
Move1 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 0))),
Move2 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 1))),
Move3 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 2))),
Move4 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 3))),
Level = Data[O_Level + index],
EVAll = Data[O_EV + index],
Move1 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 0))),
Move2 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 1))),
Move3 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 2))),
Move4 = ReadUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 3))),
Level = Data[O_Level + index],
EVAll = Data[O_EV + index],
};
private void SetPKM(int index)
{
var pk = Team[index];
WriteUInt32LittleEndian(Data.AsSpan(GetOffsetPID(index)), pk.PID);
WriteUInt16LittleEndian(Data.AsSpan(GetOffsetSpecies(index)), pk.Species);
WriteUInt16LittleEndian(Data.AsSpan(GetOffsetSpecies(index)), pk.SpeciesInternal);
WriteUInt16LittleEndian(Data.AsSpan(GetOffsetItem(index)), pk.HeldItem);
WriteUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 0)), pk.Move1);
WriteUInt16LittleEndian(Data.AsSpan(GetOffsetMove(index, 1)), pk.Move2);