From edfb8fc2fffa0ee14c9e2cd4798293e391a2408a Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 22 Jan 2021 22:55:55 -0800 Subject: [PATCH] Add TID/SID fetch for Battle Revolution Can unlock boxes by setting a nonzero TID/SID https://projectpokemon.org/home/forums/topic/36582-pok%C3%A9mon-battle-revolution-save-research-thread/?do=findComment&comment=221812 ty Akunoko --- PKHeX.Core/Saves/SAV4BR.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Saves/SAV4BR.cs b/PKHeX.Core/Saves/SAV4BR.cs index 1d3a08bf1..05eed42af 100644 --- a/PKHeX.Core/Saves/SAV4BR.cs +++ b/PKHeX.Core/Saves/SAV4BR.cs @@ -72,6 +72,7 @@ protected override byte[] GetFinalData() public readonly IReadOnlyList SaveNames = new string[SAVE_COUNT]; private int _currentSlot = -1; + private const int SIZE_SLOT = 0x6FF00; public int CurrentSlot { @@ -80,7 +81,7 @@ public int CurrentSlot set { _currentSlot = value; - var ofs = 0x6FF00 * _currentSlot; + var ofs = SIZE_SLOT * _currentSlot; Box = ofs + 0x978; Party = ofs + 0x13A54; // first team slot after boxes BoxName = ofs + 0x58674; @@ -168,6 +169,26 @@ private void SetOTName(int slot, string name) public override int GetPartyOffset(int slot) => Party + (SIZE_PARTY * slot); public override int GetBoxOffset(int box) => Box + (SIZE_STORED * box * 30); + public override int TID + { + get => (Data[(_currentSlot * SIZE_SLOT) + 0x12867] << 8) | Data[(_currentSlot * SIZE_SLOT) + 0x12860]; + set + { + Data[(_currentSlot * SIZE_SLOT) + 0x12867] = (byte)(value >> 8); + Data[(_currentSlot * SIZE_SLOT) + 0x12860] = (byte)(value & 0xFF); + } + } + + public override int SID + { + get => (Data[(_currentSlot * SIZE_SLOT) + 0x12865] << 8) | Data[(_currentSlot * SIZE_SLOT) + 0x12866]; + set + { + Data[(_currentSlot * SIZE_SLOT) + 0x12865] = (byte)(value >> 8); + Data[(_currentSlot * SIZE_SLOT) + 0x12866] = (byte)(value & 0xFF); + } + } + // Save file does not have Box Name / Wallpaper info private int BoxName = -1; private const int BoxNameLength = 0x28;