コード例 #1
0
ファイル: SAV4.cs プロジェクト: 0ver-flow/PKHeX
        public override int MaxGameID => 15; // Colo/XD

        // Checksums
        protected override void setChecksums()
        {
            switch (Version)
            {
            case GameVersion.DP:
                // 0x0000-0xC0EC @ 0xC0FE
                // 0xc100-0x1E2CC @ 0x1E2DE
                BitConverter.GetBytes(SaveUtil.ccitt16(Data.Skip(0 + GBO).Take(0xC0EC).ToArray())).CopyTo(Data, 0xC0FE + GBO);
                BitConverter.GetBytes(SaveUtil.ccitt16(Data.Skip(0xc100 + SBO).Take(0x121CC).ToArray())).CopyTo(Data, 0x1E2DE + SBO);
                break;

            case GameVersion.Pt:
                // 0x0000-0xCF18 @ 0xCF2A
                // 0xCF2C-0x1F0FC @ 0x1F10E
                BitConverter.GetBytes(SaveUtil.ccitt16(Data.Skip(0 + GBO).Take(0xCF18).ToArray())).CopyTo(Data, 0xCF2A + GBO);
                BitConverter.GetBytes(SaveUtil.ccitt16(Data.Skip(0xCF2C + SBO).Take(0x121D0).ToArray())).CopyTo(Data, 0x1F10E + SBO);
                break;

            case GameVersion.HGSS:
                // 0x0000-0xF618 @ 0xF626
                // 0xF700-0x219FC @ 0x21A0E
                BitConverter.GetBytes(SaveUtil.ccitt16(Data.Skip(0 + GBO).Take(0xF618).ToArray())).CopyTo(Data, 0xF626 + GBO);
                BitConverter.GetBytes(SaveUtil.ccitt16(Data.Skip(0xF700 + SBO).Take(0x12300).ToArray())).CopyTo(Data, 0x21A0E + SBO);
                break;
            }
        }
コード例 #2
0
        private void B_Save_Click(object sender, EventArgs e)
        {
            byte[] bgdata = bg.Write();
            if (bgdata.SequenceEqual(new byte[CGearBackground.SIZE_CGB]))
            {
                return;
            }

            // Data present

            bgdata = CGearBackground.CGBtoPSK(bgdata, SAV.B2W2);

            Array.Copy(bgdata, 0, Main.SAV.Data, SAV.CGearDataOffset, bgdata.Length);
            ushort chk = SaveUtil.ccitt16(bgdata);

            BitConverter.GetBytes(chk).CopyTo(Main.SAV.Data, SAV.CGearDataOffset + bgdata.Length + 2);
            BitConverter.GetBytes(chk).CopyTo(Main.SAV.Data, SAV.CGearDataOffset + bgdata.Length + 0x100);

            byte[] skinchkdata = Main.SAV.Data.Skip(SAV.CGearDataOffset + bgdata.Length + 0x100).Take(4).ToArray();
            ushort skinchkval  = SaveUtil.ccitt16(skinchkdata);

            BitConverter.GetBytes(skinchkval).CopyTo(Main.SAV.Data, SAV.CGearDataOffset + bgdata.Length + 0x112);

            // Indicate in the save file that data is present
            BitConverter.GetBytes((ushort)0xC21E).CopyTo(Main.SAV.Data, 0x19438);



            Main.SAV.Data[SAV.CGearInfoOffset + 0x26] = 1; // data present
            BitConverter.GetBytes(chk).CopyTo(Main.SAV.Data, SAV.CGearInfoOffset + 0x24);

            Main.SAV.Edited = true;
            Close();
        }
コード例 #3
0
ファイル: SAV_Link6.cs プロジェクト: resonancellc/Mass-Editor
        private void B_Save_Click(object sender, EventArgs e)
        {
            byte[] data = new byte[SAV.LinkBlock.Length];
            Array.Copy(LinkInfo.Data, 0, data, 0x1FF, LinkInfo.Data.Length);

            // Fix Checksum just in case.
            ushort ccitt = SaveUtil.ccitt16(data.Skip(0x200).Take(data.Length - 4 - 0x200).ToArray()); // [app,chk)

            BitConverter.GetBytes(ccitt).CopyTo(data, data.Length - 4);

            SAV.LinkBlock = data;
            Array.Copy(SAV.Data, Main.SAV.Data, SAV.Data.Length);
            Close();
        }
コード例 #4
0
ファイル: SAV6.cs プロジェクト: 0ver-flow/PKHeX
 protected override void setChecksums()
 {
     // Check for invalid block lengths
     if (Blocks.Length < 3) // arbitrary...
     {
         Console.WriteLine("Not enough blocks ({0}), aborting setChecksums", Blocks.Length);
         return;
     }
     // Apply checksums
     for (int i = 0; i < Blocks.Length; i++)
     {
         byte[] array = Data.Skip(Blocks[i].Offset).Take(Blocks[i].Length).ToArray();
         BitConverter.GetBytes(SaveUtil.ccitt16(array)).CopyTo(Data, BlockInfoOffset + 6 + i * 8);
     }
 }
コード例 #5
0
 protected override void setChecksums()
 {
     // Check for invalid block lengths
     if (Blocks.Length < 3) // arbitrary...
     {
         Console.WriteLine("Not enough blocks ({0}), aborting setChecksums", Blocks.Length);
         return;
     }
     // Apply checksums
     foreach (BlockInfo b in Blocks)
     {
         byte[] array = Data.Skip(b.Offset).Take(b.Length).ToArray();
         ushort chk   = SaveUtil.ccitt16(array);
         BitConverter.GetBytes(chk).CopyTo(Data, b.ChecksumOffset);
         BitConverter.GetBytes(chk).CopyTo(Data, b.ChecksumMirror);
     }
 }
コード例 #6
0
 protected override void setChecksums()
 {
     // Check for invalid block lengths
     if (Blocks.Length < 3) // arbitrary...
     {
         Console.WriteLine("Not enough blocks ({0}), aborting setChecksums", Blocks.Length);
         return;
     }
     // Apply checksums
     for (int i = 0; i < Blocks.Length; i++)
     {
         if (Blocks[i].Length + Blocks[i].Offset > Data.Length)
         {
             Console.WriteLine("Block {0} has invalid offset/length value.", i); return;
         }
         byte[] array = new byte[Blocks[i].Length];
         Array.Copy(Data, Blocks[i].Offset, array, 0, array.Length);
         BitConverter.GetBytes(SaveUtil.ccitt16(array)).CopyTo(Data, BlockInfoOffset + 6 + i * 8);
     }
 }