Example #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;
        }
Example #2
0
        private const int SIZE_RESERVED = 0x10000; // unpacked box data
        public override byte[] Write(bool DSV)
        {
            // Copy Box data back
            for (int i = 5; i < 14; i++)
            {
                int blockIndex = Array.IndexOf(BlockOrder, i);
                if (blockIndex == -1) // block empty
                {
                    continue;
                }
                Array.Copy(Data, Box + (i - 5) * 0xF80, Data, blockIndex * 0x1000 + ABO, chunkLength[i]);
            }

            setChecksums();
            return(Data.Take(Data.Length - SIZE_RESERVED).ToArray());
        }
Example #3
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());
        }
Example #4
0
 // Configuration
 public override SaveFile Clone()
 {
     return(new SAV3(Data.Take(Box).ToArray(), Version));
 }