예제 #1
0
        private void getActiveGeneralBlock()
        {
            if (Version < 0)
            {
                return;
            }
            int ofs = 0;

            // Check to see if the save is initialized completely
            // if the block is not initialized, fall back to the other save.
            if (Data.Take(10).SequenceEqual(Enumerable.Repeat((byte)0xFF, 10)))
            {
                generalBlock = 1; return;
            }
            if (Data.Skip(0x40000).Take(10).SequenceEqual(Enumerable.Repeat((byte)0xFF, 10)))
            {
                generalBlock = 0; return;
            }

            // Check SaveCount for current save
            if (Version == GameVersion.DP)
            {
                ofs = 0xC0F0;                            // DP
            }
            else if (Version == GameVersion.Pt)
            {
                ofs = 0xCF1C;                                 // PT
            }
            else if (Version == GameVersion.HGSS)
            {
                ofs = 0xF618;                                   // HGSS
            }
            generalBlock = BitConverter.ToUInt16(Data, ofs) >= BitConverter.ToUInt16(Data, ofs + 0x40000) ? 0 : 1;
        }
예제 #2
0
파일: SAV3.cs 프로젝트: Zovrah/PKHeX
        protected override byte[] GetFinalData()
        {
            // Copy Box data back
            for (int i = 5; i < BLOCK_COUNT; i++)
            {
                int blockIndex = Array.IndexOf(BlockOrder, i);
                if (blockIndex == -1) // block empty
                {
                    continue;
                }
                Array.Copy(Data, Box + ((i - 5) * 0xF80), Data, (blockIndex * SIZE_BLOCK) + ABO, chunkLength[i]);
            }

            SetChecksums();
            return(Data.Take(Data.Length - SIZE_RESERVED).ToArray());
        }
예제 #3
0
        public override byte[] Write(bool DSV)
        {
            // Copy Box data back
            for (int i = 5; i < BLOCK_COUNT; i++)
            {
                int blockIndex = Array.IndexOf(BlockOrder, i);
                if (blockIndex == -1) // block empty
                {
                    continue;
                }
                Array.Copy(Data, Box + (i - 5) * 0xF80, Data, blockIndex * SIZE_BLOCK + ABO, chunkLength[i]);
            }

            setChecksums();
            return(Data.Take(Data.Length - SIZE_RESERVED).ToArray());
        }
예제 #4
0
        private const int SIZE_RESERVED = BLOCK_COUNT * BLOCK_SIZE; // unpacked box data
        public override byte[] Write(bool DSV)
        {
            // Copy Box data back to block
            foreach (RSBOX_Block b in Blocks)
            {
                Array.Copy(Data, Box + b.BlockNumber * (BLOCK_SIZE - 0x10), b.Data, 0xC, b.Data.Length - 0x10);
            }

            setChecksums();

            // Set Data Back
            foreach (RSBOX_Block b in Blocks)
            {
                b.Data.CopyTo(Data, b.Offset);
            }
            byte[] newFile = Data.Take(Data.Length - SIZE_RESERVED).ToArray();
            return(Header.Concat(newFile).ToArray());
        }