mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 20:36:57 -05:00
Update unused byte usage knowledge
DistByte is actually 16bits; no point changing the name. The 32bits afterwards are form duration (Hoopa/Furfrou only), and only exist while the PKM is in the player's party. The game sets an initial value with days to exist in the form before reverting (probably on game restart), checking the delta between days saved. Either way, just set a base value when writing it to the party, else clear the value if it is not supposed to be used. Thanks @SciresM !
This commit is contained in:
@@ -8,7 +8,7 @@ public class PK6 : PKM, IRibbonSet1, IRibbonSet2
|
||||
public static readonly byte[] ExtraBytes =
|
||||
{
|
||||
0x36, 0x37, // Unused Ribbons
|
||||
0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x58, 0x59, 0x73, 0x90, 0x91, 0x9E, 0x9F, 0xA0, 0xA1, 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, 0xC8, 0xC9, 0xD7, 0xE4, 0xE5, 0xE6, 0xE7
|
||||
0x58, 0x59, 0x73, 0x90, 0x91, 0x9E, 0x9F, 0xA0, 0xA1, 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, 0xC8, 0xC9, 0xD7, 0xE4, 0xE5, 0xE6, 0xE7
|
||||
};
|
||||
public sealed override int SIZE_PARTY => PKX.SIZE_6PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_6STORED;
|
||||
@@ -198,7 +198,7 @@ public override uint PID
|
||||
public bool RIB5_7 { get => (RIB5 & (1 << 7)) == 1 << 7; set => RIB5 = (byte)(RIB5 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Unused
|
||||
public int RibbonCountMemoryContest { get => Data[0x38]; set => Data[0x38] = (byte)value; }
|
||||
public int RibbonCountMemoryBattle { get => Data[0x39]; set => Data[0x39] = (byte)value; }
|
||||
private byte DistByte { get => Data[0x3A]; set => Data[0x3A] = value; }
|
||||
private ushort DistByte { get => BitConverter.ToUInt16(Data, 0x3A); set => BitConverter.GetBytes(value).CopyTo(Data, 0x3A); }
|
||||
public bool DistSuperTrain1 { get => (DistByte & (1 << 0)) == 1 << 0; set => DistByte = (byte)(DistByte & ~(1 << 0) | (value ? 1 << 0 : 0)); }
|
||||
public bool DistSuperTrain2 { get => (DistByte & (1 << 1)) == 1 << 1; set => DistByte = (byte)(DistByte & ~(1 << 1) | (value ? 1 << 1 : 0)); }
|
||||
public bool DistSuperTrain3 { get => (DistByte & (1 << 2)) == 1 << 2; set => DistByte = (byte)(DistByte & ~(1 << 2) | (value ? 1 << 2 : 0)); }
|
||||
@@ -207,11 +207,7 @@ public override uint PID
|
||||
public bool DistSuperTrain6 { get => (DistByte & (1 << 5)) == 1 << 5; set => DistByte = (byte)(DistByte & ~(1 << 5) | (value ? 1 << 5 : 0)); }
|
||||
public bool Dist7 { get => (DistByte & (1 << 6)) == 1 << 6; set => DistByte = (byte)(DistByte & ~(1 << 6) | (value ? 1 << 6 : 0)); }
|
||||
public bool Dist8 { get => (DistByte & (1 << 7)) == 1 << 7; set => DistByte = (byte)(DistByte & ~(1 << 7) | (value ? 1 << 7 : 0)); }
|
||||
public byte _0x3B { get => Data[0x3B]; set => Data[0x3B] = value; }
|
||||
public byte _0x3C { get => Data[0x3C]; set => Data[0x3C] = value; }
|
||||
public byte _0x3D { get => Data[0x3D]; set => Data[0x3D] = value; }
|
||||
public byte _0x3E { get => Data[0x3E]; set => Data[0x3E] = value; }
|
||||
public byte _0x3F { get => Data[0x3F]; set => Data[0x3F] = value; }
|
||||
public uint FormDuration { get => BitConverter.ToUInt32(Data, 0x3C); set => BitConverter.GetBytes(value).CopyTo(Data, 0x3C); }
|
||||
#endregion
|
||||
#region Block B
|
||||
public override string Nickname { get => getString(0x40, 24); set => setString(value, 12).CopyTo(Data, 0x40); }
|
||||
|
||||
@@ -9,7 +9,7 @@ public class PK7 : PKM, IRibbonSet1, IRibbonSet2
|
||||
{
|
||||
0x2A, // Old Marking Value
|
||||
// 0x36, 0x37, // Unused Ribbons
|
||||
0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x58, 0x59, 0x73, 0x90, 0x91, 0x9E, 0x9F, 0xA0, 0xA1, 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, 0xC8, 0xC9, 0xD7, 0xE4, 0xE5, 0xE6, 0xE7
|
||||
0x58, 0x59, 0x73, 0x90, 0x91, 0x9E, 0x9F, 0xA0, 0xA1, 0xA7, 0xAA, 0xAB, 0xAC, 0xAD, 0xC8, 0xC9, 0xD7, 0xE4, 0xE5, 0xE6, 0xE7
|
||||
};
|
||||
public sealed override int SIZE_PARTY => PKX.SIZE_6PARTY;
|
||||
public override int SIZE_STORED => PKX.SIZE_6STORED;
|
||||
@@ -206,7 +206,7 @@ public override uint PID
|
||||
public bool RIB6_7 { get => (RIB6 & (1 << 7)) == 1 << 7; set => RIB6 = (byte)(RIB6 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Unused
|
||||
public int RibbonCountMemoryContest { get => Data[0x38]; set => Data[0x38] = (byte)value; }
|
||||
public int RibbonCountMemoryBattle { get => Data[0x39]; set => Data[0x39] = (byte)value; }
|
||||
private byte DistByte { get => Data[0x3A]; set => Data[0x3A] = value; }
|
||||
private ushort DistByte { get => BitConverter.ToUInt16(Data, 0x3A); set => BitConverter.GetBytes(value).CopyTo(Data, 0x3A); }
|
||||
public bool DistSuperTrain1 { get => (DistByte & (1 << 0)) == 1 << 0; set => DistByte = (byte)(DistByte & ~(1 << 0) | (value ? 1 << 0 : 0)); }
|
||||
public bool DistSuperTrain2 { get => (DistByte & (1 << 1)) == 1 << 1; set => DistByte = (byte)(DistByte & ~(1 << 1) | (value ? 1 << 1 : 0)); }
|
||||
public bool DistSuperTrain3 { get => (DistByte & (1 << 2)) == 1 << 2; set => DistByte = (byte)(DistByte & ~(1 << 2) | (value ? 1 << 2 : 0)); }
|
||||
@@ -215,11 +215,7 @@ public override uint PID
|
||||
public bool DistSuperTrain6 { get => (DistByte & (1 << 5)) == 1 << 5; set => DistByte = (byte)(DistByte & ~(1 << 5) | (value ? 1 << 5 : 0)); }
|
||||
public bool Dist7 { get => (DistByte & (1 << 6)) == 1 << 6; set => DistByte = (byte)(DistByte & ~(1 << 6) | (value ? 1 << 6 : 0)); }
|
||||
public bool Dist8 { get => (DistByte & (1 << 7)) == 1 << 7; set => DistByte = (byte)(DistByte & ~(1 << 7) | (value ? 1 << 7 : 0)); }
|
||||
public byte _0x3B { get => Data[0x3B]; set => Data[0x3B] = value; }
|
||||
public byte _0x3C { get => Data[0x3C]; set => Data[0x3C] = value; }
|
||||
public byte _0x3D { get => Data[0x3D]; set => Data[0x3D] = value; }
|
||||
public byte _0x3E { get => Data[0x3E]; set => Data[0x3E] = value; }
|
||||
public byte _0x3F { get => Data[0x3F]; set => Data[0x3F] = value; }
|
||||
public uint FormDuration { get => BitConverter.ToUInt32(Data, 0x3C); set => BitConverter.GetBytes(value).CopyTo(Data, 0x3C); }
|
||||
#endregion
|
||||
#region Block B
|
||||
public override string Nickname { get => getString(0x40, 24); set => setString(value, 12).CopyTo(Data, 0x40); }
|
||||
|
||||
@@ -830,6 +830,22 @@ protected override void setDex(PKM pkm)
|
||||
bit = f + pkm.AltForm;
|
||||
Data[FormDex + FormLen * (2 + shiny) + bit / 8] |= (byte)(1 << (bit % 8));
|
||||
}
|
||||
protected override void setPartyValues(PKM pkm, bool isParty)
|
||||
{
|
||||
uint duration = 0;
|
||||
if (isParty && pkm.AltForm != 0)
|
||||
switch (pkm.Species)
|
||||
{
|
||||
case 676:
|
||||
duration = 5;
|
||||
break;
|
||||
case 720: // Hoopa
|
||||
duration = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
((PK6)pkm).FormDuration = duration;
|
||||
}
|
||||
|
||||
public override bool getCaught(int species)
|
||||
{
|
||||
|
||||
@@ -945,6 +945,22 @@ protected override void setDex(PKM pkm)
|
||||
Data[PokeDexLanguageFlags + (lbit >> 3)] |= (byte)(1 << (lbit & 7));
|
||||
}
|
||||
}
|
||||
protected override void setPartyValues(PKM pkm, bool isParty)
|
||||
{
|
||||
uint duration = 0;
|
||||
if (isParty && pkm.AltForm != 0)
|
||||
switch (pkm.Species)
|
||||
{
|
||||
case 676:
|
||||
duration = 5;
|
||||
break;
|
||||
case 720: // Hoopa
|
||||
duration = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
((PK7)pkm).FormDuration = duration;
|
||||
}
|
||||
private static bool sanitizeFormsToIterate(int species, out int formStart, out int formEnd, int formIn)
|
||||
{
|
||||
// 004AA370 in Moon
|
||||
|
||||
@@ -477,6 +477,7 @@ public void setPartySlot(PKM pkm, int offset, bool? trade = null, bool? dex = nu
|
||||
setPKM(pkm);
|
||||
if (dex ?? SetUpdateDex)
|
||||
setDex(pkm);
|
||||
setPartyValues(pkm, isParty: true);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
if (getPartyOffset(i) == offset)
|
||||
@@ -495,7 +496,7 @@ public virtual void setStoredSlot(PKM pkm, int offset, bool? trade = null, bool?
|
||||
setPKM(pkm);
|
||||
if (dex ?? SetUpdateDex)
|
||||
setDex(pkm);
|
||||
|
||||
setPartyValues(pkm, isParty: false);
|
||||
setData(pkm.EncryptedBoxData, offset);
|
||||
Edited = true;
|
||||
}
|
||||
@@ -604,6 +605,7 @@ public bool setBoxBin(byte[] data, int box)
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual void setPartyValues(PKM pkm, bool isParty) { }
|
||||
protected virtual void setPKM(PKM pkm) { }
|
||||
protected virtual void setDex(PKM pkm) { }
|
||||
public virtual bool getSeen(int species) => false;
|
||||
|
||||
Reference in New Issue
Block a user