mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-06-02 22:14:43 -05:00
Cleaned up byte offset comments.
This commit is contained in:
parent
9ef94ad18c
commit
fffedcb82d
|
|
@ -130,54 +130,54 @@ namespace PkmnFoundations.Structures
|
||||||
// todo: enclose in properties and validate these when assigning.
|
// todo: enclose in properties and validate these when assigning.
|
||||||
if (TrainerNameEncoded.RawData.Length != 0x10) throw new FormatException("Trainer name length is incorrect");
|
if (TrainerNameEncoded.RawData.Length != 0x10) throw new FormatException("Trainer name length is incorrect");
|
||||||
|
|
||||||
writer.Write(DataActual, 0, 0xEC); // 0x0000
|
writer.Write(DataActual, 0, 0xEC); // 0000
|
||||||
writer.Write(Species); // 0x00EC
|
writer.Write(Species); // 00EC
|
||||||
writer.Write((byte)Gender); // 0x00EE
|
writer.Write((byte)Gender); // 00EE
|
||||||
writer.Write(Level); // 0x00EF
|
writer.Write(Level); // 00EF
|
||||||
writer.Write(RequestedSpecies); // 0x00F0
|
writer.Write(RequestedSpecies); // 00F0
|
||||||
writer.Write((byte)RequestedGender); // 0x00F2
|
writer.Write((byte)RequestedGender); // 00F2
|
||||||
writer.Write(RequestedMinLevel); // 0x00F3
|
writer.Write(RequestedMinLevel); // 00F3
|
||||||
writer.Write(RequestedMaxLevel); // 0x00F4
|
writer.Write(RequestedMaxLevel); // 00F4
|
||||||
writer.Write(Unknown1); // 0x00F5
|
writer.Write(Unknown1); // 00F5
|
||||||
writer.Write((byte)TrainerGender); // 0x00F6
|
writer.Write((byte)TrainerGender); // 00F6
|
||||||
writer.Write(Unknown2); // 0x00F7
|
writer.Write(Unknown2); // 00F7
|
||||||
writer.Write(DateToTimestamp(TimeDeposited)); // 0x00F8
|
writer.Write(DateToTimestamp(TimeDeposited)); // 00F8
|
||||||
writer.Write(DateToTimestamp(TimeExchanged)); // 0x0100
|
writer.Write(DateToTimestamp(TimeExchanged)); // 0100
|
||||||
writer.Write(PID); // 0x0108
|
writer.Write(PID); // 0108
|
||||||
writer.Write(TrainerNameEncoded.RawData, 0, 0x10); // 0x010C
|
writer.Write(TrainerNameEncoded.RawData, 0, 0x10); // 010C
|
||||||
writer.Write(TrainerOT); // 0x011C
|
writer.Write(TrainerOT); // 011C
|
||||||
writer.Write(TrainerCountry); // 0x011E
|
writer.Write(TrainerCountry); // 011E
|
||||||
writer.Write(TrainerRegion); // 0x011F
|
writer.Write(TrainerRegion); // 011F
|
||||||
writer.Write(TrainerClass); // 0x0120
|
writer.Write(TrainerClass); // 0120
|
||||||
writer.Write(IsExchanged); // 0x0121
|
writer.Write(IsExchanged); // 0121
|
||||||
writer.Write(TrainerVersion); // 0x0122
|
writer.Write(TrainerVersion); // 0122
|
||||||
writer.Write(TrainerLanguage); // 0x0123
|
writer.Write(TrainerLanguage); // 0123
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Load(BinaryReader reader)
|
protected override void Load(BinaryReader reader)
|
||||||
{
|
{
|
||||||
DataActual = reader.ReadBytes(0xEC); // 0x0000
|
DataActual = reader.ReadBytes(0xEC); // 0000
|
||||||
Species = reader.ReadUInt16(); // 0x00EC
|
Species = reader.ReadUInt16(); // 00EC
|
||||||
Gender = (Genders)reader.ReadByte(); // 0x00EE
|
Gender = (Genders)reader.ReadByte(); // 00EE
|
||||||
Level = reader.ReadByte(); // 0x00EF
|
Level = reader.ReadByte(); // 00EF
|
||||||
RequestedSpecies = reader.ReadUInt16(); // 0x00F0
|
RequestedSpecies = reader.ReadUInt16(); // 00F0
|
||||||
RequestedGender = (Genders)reader.ReadByte(); // 0x00F2
|
RequestedGender = (Genders)reader.ReadByte(); // 00F2
|
||||||
RequestedMinLevel = reader.ReadByte(); // 0x00F3
|
RequestedMinLevel = reader.ReadByte(); // 00F3
|
||||||
RequestedMaxLevel = reader.ReadByte(); // 0x00F4
|
RequestedMaxLevel = reader.ReadByte(); // 00F4
|
||||||
Unknown1 = reader.ReadByte(); // 0x00F5
|
Unknown1 = reader.ReadByte(); // 00F5
|
||||||
TrainerGender = (TrainerGenders)reader.ReadByte(); // 0x00F6
|
TrainerGender = (TrainerGenders)reader.ReadByte(); // 00F6
|
||||||
Unknown2 = reader.ReadByte(); // 0x00F7
|
Unknown2 = reader.ReadByte(); // 00F7
|
||||||
TimeDeposited = TimestampToDate(reader.ReadUInt64()); // 0x00F8
|
TimeDeposited = TimestampToDate(reader.ReadUInt64()); // 00F8
|
||||||
TimeExchanged = TimestampToDate(reader.ReadUInt64()); // 0x0100
|
TimeExchanged = TimestampToDate(reader.ReadUInt64()); // 0100
|
||||||
PID = reader.ReadInt32(); // 0x0108
|
PID = reader.ReadInt32(); // 0108
|
||||||
TrainerNameEncoded = new EncodedString4(reader.ReadBytes(0x10)); // 0x010C
|
TrainerNameEncoded = new EncodedString4(reader.ReadBytes(0x10)); // 010C
|
||||||
TrainerOT = reader.ReadUInt16(); // 0x011C
|
TrainerOT = reader.ReadUInt16(); // 011C
|
||||||
TrainerCountry = reader.ReadByte(); // 0x011E
|
TrainerCountry = reader.ReadByte(); // 011E
|
||||||
TrainerRegion = reader.ReadByte(); // 0x011F
|
TrainerRegion = reader.ReadByte(); // 011F
|
||||||
TrainerClass = reader.ReadByte(); // 0x0120
|
TrainerClass = reader.ReadByte(); // 0120
|
||||||
IsExchanged = reader.ReadByte(); // 0x0121
|
IsExchanged = reader.ReadByte(); // 0121
|
||||||
TrainerVersion = reader.ReadByte(); // 0x0122
|
TrainerVersion = reader.ReadByte(); // 0122
|
||||||
TrainerLanguage = reader.ReadByte(); // 0x0123
|
TrainerLanguage = reader.ReadByte(); // 0123
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Size
|
public override int Size
|
||||||
|
|
|
||||||
|
|
@ -134,58 +134,58 @@ namespace PkmnFoundations.Structures
|
||||||
// todo: enclose in properties and validate these when assigning.
|
// todo: enclose in properties and validate these when assigning.
|
||||||
if (TrainerNameEncoded.RawData.Length != 0x10) throw new FormatException("Trainer name length is incorrect");
|
if (TrainerNameEncoded.RawData.Length != 0x10) throw new FormatException("Trainer name length is incorrect");
|
||||||
|
|
||||||
writer.Write(DataActual, 0, 0xEC); // 0x0000
|
writer.Write(DataActual, 0, 0xEC); // 0000
|
||||||
writer.Write(Species); // 0x00EC
|
writer.Write(Species); // 00EC
|
||||||
writer.Write((byte)Gender); // 0x00EE
|
writer.Write((byte)Gender); // 00EE
|
||||||
writer.Write(Level); // 0x00EF
|
writer.Write(Level); // 00EF
|
||||||
writer.Write(RequestedSpecies); // 0x00F0
|
writer.Write(RequestedSpecies); // 00F0
|
||||||
writer.Write((byte)RequestedGender); // 0x00F2
|
writer.Write((byte)RequestedGender); // 00F2
|
||||||
writer.Write(RequestedMinLevel); // 0x00F3
|
writer.Write(RequestedMinLevel); // 00F3
|
||||||
writer.Write(RequestedMaxLevel); // 0x00F4
|
writer.Write(RequestedMaxLevel); // 00F4
|
||||||
writer.Write(Unknown1); // 0x00F5
|
writer.Write(Unknown1); // 00F5
|
||||||
writer.Write((byte)TrainerGender); // 0x00F6
|
writer.Write((byte)TrainerGender); // 00F6
|
||||||
writer.Write(Unknown2); // 0x00F7
|
writer.Write(Unknown2); // 00F7
|
||||||
writer.Write(DateToTimestamp(TimeDeposited)); // 0x00F8
|
writer.Write(DateToTimestamp(TimeDeposited)); // 00F8
|
||||||
writer.Write(DateToTimestamp(TimeExchanged)); // 0x0100
|
writer.Write(DateToTimestamp(TimeExchanged)); // 0100
|
||||||
writer.Write(PID); // 0x0108
|
writer.Write(PID); // 0108
|
||||||
writer.Write(TrainerOT); // 0x010C
|
writer.Write(TrainerOT); // 010C
|
||||||
writer.Write(TrainerNameEncoded.RawData, 0, 0x10); // 0x0110
|
writer.Write(TrainerNameEncoded.RawData, 0, 0x10); // 0110
|
||||||
writer.Write(TrainerCountry); // 0x0120
|
writer.Write(TrainerCountry); // 0120
|
||||||
writer.Write(TrainerRegion); // 0x0121
|
writer.Write(TrainerRegion); // 0121
|
||||||
writer.Write(TrainerClass); // 0x0122
|
writer.Write(TrainerClass); // 0122
|
||||||
writer.Write(IsExchanged); // 0x0123
|
writer.Write(IsExchanged); // 0123
|
||||||
writer.Write(TrainerVersion); // 0x0124
|
writer.Write(TrainerVersion); // 0124
|
||||||
writer.Write(TrainerLanguage); // 0x0125
|
writer.Write(TrainerLanguage); // 0125
|
||||||
writer.Write(TrainerBadges); // 0x0126
|
writer.Write(TrainerBadges); // 0126
|
||||||
writer.Write(TrainerUnityTower); // 0x0127
|
writer.Write(TrainerUnityTower); // 0127
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Load(BinaryReader reader)
|
protected override void Load(BinaryReader reader)
|
||||||
{
|
{
|
||||||
DataActual = reader.ReadBytes(0xEC); // 0x0000
|
DataActual = reader.ReadBytes(0xEC); // 0000
|
||||||
Species = reader.ReadUInt16(); // 0x00EC
|
Species = reader.ReadUInt16(); // 00EC
|
||||||
Gender = (Genders)reader.ReadByte(); // 0x00EE
|
Gender = (Genders)reader.ReadByte(); // 00EE
|
||||||
Level = reader.ReadByte(); // 0x00EF
|
Level = reader.ReadByte(); // 00EF
|
||||||
RequestedSpecies = reader.ReadUInt16(); // 0x00F0
|
RequestedSpecies = reader.ReadUInt16(); // 00F0
|
||||||
RequestedGender = (Genders)reader.ReadByte(); // 0x00F2
|
RequestedGender = (Genders)reader.ReadByte(); // 00F2
|
||||||
RequestedMinLevel = reader.ReadByte(); // 0x00F3
|
RequestedMinLevel = reader.ReadByte(); // 00F3
|
||||||
RequestedMaxLevel = reader.ReadByte(); // 0x00F4
|
RequestedMaxLevel = reader.ReadByte(); // 00F4
|
||||||
Unknown1 = reader.ReadByte(); // 0x00F5
|
Unknown1 = reader.ReadByte(); // 00F5
|
||||||
TrainerGender = (TrainerGenders)reader.ReadByte(); // 0x00F6
|
TrainerGender = (TrainerGenders)reader.ReadByte(); // 00F6
|
||||||
Unknown2 = reader.ReadByte(); // 0x00F7
|
Unknown2 = reader.ReadByte(); // 00F7
|
||||||
TimeDeposited = TimestampToDate(reader.ReadUInt64()); // 0x00F8
|
TimeDeposited = TimestampToDate(reader.ReadUInt64()); // 00F8
|
||||||
TimeExchanged = TimestampToDate(reader.ReadUInt64()); // 0x0100
|
TimeExchanged = TimestampToDate(reader.ReadUInt64()); // 0100
|
||||||
PID = reader.ReadInt32(); // 0x0108
|
PID = reader.ReadInt32(); // 0108
|
||||||
TrainerOT = reader.ReadUInt32(); // 0x010C
|
TrainerOT = reader.ReadUInt32(); // 010C
|
||||||
TrainerNameEncoded = new EncodedString5(reader.ReadBytes(0x10)); // 0x0110
|
TrainerNameEncoded = new EncodedString5(reader.ReadBytes(0x10)); // 0110
|
||||||
TrainerCountry = reader.ReadByte(); // 0x0120
|
TrainerCountry = reader.ReadByte(); // 0120
|
||||||
TrainerRegion = reader.ReadByte(); // 0x0121
|
TrainerRegion = reader.ReadByte(); // 0121
|
||||||
TrainerClass = reader.ReadByte(); // 0x0122
|
TrainerClass = reader.ReadByte(); // 0122
|
||||||
IsExchanged = reader.ReadByte(); // 0x0123
|
IsExchanged = reader.ReadByte(); // 0123
|
||||||
TrainerVersion = reader.ReadByte(); // 0x0124
|
TrainerVersion = reader.ReadByte(); // 0124
|
||||||
TrainerLanguage = reader.ReadByte(); // 0x0125
|
TrainerLanguage = reader.ReadByte(); // 0125
|
||||||
TrainerBadges = reader.ReadByte(); // 0x0126
|
TrainerBadges = reader.ReadByte(); // 0126
|
||||||
TrainerUnityTower = reader.ReadByte(); // 0x0127
|
TrainerUnityTower = reader.ReadByte(); // 0127
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Size
|
public override int Size
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,13 @@ namespace PkmnFoundations.Structures
|
||||||
protected override void Load(BinaryReader reader)
|
protected override void Load(BinaryReader reader)
|
||||||
{
|
{
|
||||||
// header (unencrypted)
|
// header (unencrypted)
|
||||||
Personality = reader.ReadUInt32();
|
Personality = reader.ReadUInt32(); // 0000
|
||||||
ushort zero = reader.ReadUInt16();
|
ushort zero = reader.ReadUInt16(); // 0004
|
||||||
ushort checksum = reader.ReadUInt16();
|
ushort checksum = reader.ReadUInt16(); // 0006
|
||||||
|
|
||||||
// read out the main payload, apply xor decryption
|
// read out the main payload, apply xor decryption
|
||||||
byte[][] blocks = new byte[4][];
|
byte[][] blocks = new byte[4][];
|
||||||
for (int x = 0; x < 4; x++)
|
for (int x = 0; x < 4; x++) // 0008
|
||||||
blocks[x] = reader.ReadBytes(32);
|
blocks[x] = reader.ReadBytes(32);
|
||||||
|
|
||||||
DecryptBlocks(blocks, checksum);
|
DecryptBlocks(blocks, checksum);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user