public RivalInfoBlockData(GBAGameSave gameSave, byte[] data, BlockDataCollection parent) : base(gameSave, data, parent) { if (parent.GameCode == GameCodes.FireRedLeafGreen) { parent.Mailbox.LoadPart2(ByteHelper.SubByteArray(0, raw, 4 * 36)); ((GBAPokePC)parent.PokePC).AddDaycare(ByteHelper.SubByteArray(256, raw, 3492), parent.GameCode); } else if (parent.GameCode == GameCodes.Emerald) { ((GBAPokePC)parent.PokePC).AddDaycare(ByteHelper.SubByteArray(432, raw, 280), parent.GameCode); } else if (parent.GameCode == GameCodes.RubySapphire) { /*for (int i = 0; i < SectionIDTable.GetContents(SectionID) - 4; i++) { * if (LittleEndian.ToUInt32(raw, i) == 2664098125) * Console.WriteLine(i); * if (LittleEndian.ToUInt32(raw, i) == 183926766) * Console.WriteLine(i); * if (LittleEndian.ToUInt32(raw, i) == 22) * Console.WriteLine(i); * }*/ ((GBAPokePC)parent.PokePC).AddDaycare(ByteHelper.SubByteArray(284, raw, 280), parent.GameCode); } }
public GBASaveData(GBAGameSave gameSave, byte[] data) { if (data.Length != 57344) { throw new Exception("Gen 3 GBA Save data must contain 57344 bytes"); } this.raw = data; this.blockDataCollection = new BlockDataCollection(gameSave, data); }
public TeamAndItemsBlockData(GBAGameSave gameSave, byte[] data, BlockDataCollection parent) : base(gameSave, data, parent) { if (parent.Inventory.Items == null) { parent.Inventory.AddItemInventory(); } if (parent.GameCode == GameCodes.FireRedLeafGreen) { AddPocket(ItemTypes.PC, 664, 30, 999, false, false); AddPocket(ItemTypes.Items, 784, 42, 999, false, false); AddPocket(ItemTypes.KeyItems, 952, 30, 999, false, false); AddPocket(ItemTypes.PokeBalls, 1072, 13, 999, false, false); AddPocket(ItemTypes.TMCase, 1124, 58, 999, false, true); AddPocket(ItemTypes.Berries, 1356, 43, 999, false, true); parent.PokePC.AddParty(ByteHelper.SubByteArray(52, raw, 604)); } else if (parent.GameCode == GameCodes.Emerald) { AddPocket(ItemTypes.PC, 1176, 50, 999, true, false); AddPocket(ItemTypes.Items, 1376, 30, 99, true, false); AddPocket(ItemTypes.KeyItems, 1496, 30, 99, true, false); AddPocket(ItemTypes.PokeBalls, 1616, 16, 99, true, false); AddPocket(ItemTypes.TMCase, 1680, 64, 99, false, true); AddPocket(ItemTypes.Berries, 1936, 46, 999, false, true); AddPokeblockCase(2120, 40); parent.PokePC.AddParty(ByteHelper.SubByteArray(564, raw, 604)); } else { AddPocket(ItemTypes.PC, 1176, 50, 999, true, false); AddPocket(ItemTypes.Items, 1376, 20, 99, true, false); AddPocket(ItemTypes.KeyItems, 1456, 20, 99, true, false); AddPocket(ItemTypes.PokeBalls, 1536, 16, 99, true, false); AddPocket(ItemTypes.TMCase, 1600, 64, 99, false, true); AddPocket(ItemTypes.Berries, 1856, 46, 999, false, true); AddPokeblockCase(2040, 40); parent.PokePC.AddParty(ByteHelper.SubByteArray(564, raw, 604)); } }
public PokeBoxBlockData(GBAGameSave gameSave, byte[] data, BlockDataCollection parent) : base(gameSave, data, parent) { }
public BlockDataCollection(GBAGameSave gameSave, byte[] data) { if (data.Length != 57344) { throw new Exception("Save data size must be 57344 bytes"); } this.inventory = new Inventory(gameSave); this.pokePC = new GBAPokePC(gameSave); this.mailbox = new Mailbox(gameSave, 10); this.gameSave = gameSave; // Find the trainer info block data first to get vital information // AKA: GameCode and Security Key for (int i = 0; i < 14; i++) { if (ReadSectionID(data, i) == SectionTypes.TrainerInfo) { Add(new TrainerInfoBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this)); break; } } // Now that we have the trainer info we can get the rest of the blocks for (int i = 0; i < 14; i++) { SectionTypes sectionID = ReadSectionID(data, i); if (sectionID == SectionTypes.TeamAndItems) { Add(new TeamAndItemsBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this)); } else if (sectionID == SectionTypes.Unknown1) { Add(new NationalPokedexBAndCBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this)); } else if (sectionID == SectionTypes.Unknown2) { Add(new DecorationBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this)); } else if (sectionID == SectionTypes.RivalInfo) { Add(new RivalInfoBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this)); } else if (sectionID >= SectionTypes.PCBufferA && sectionID <= SectionTypes.PCBufferI) { Add(new PokeBoxBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this)); } else if (sectionID != SectionTypes.TrainerInfo) { Add(new BlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this)); } } // Sort the block data list, why not List <IBlockData> list = Enumerable.ToList <IBlockData>((IEnumerable <IBlockData>)Enumerable.OrderBy <IBlockData, SectionTypes>(this, (Func <IBlockData, SectionTypes>)(u => u.SectionID))); Clear(); AddRange((IEnumerable <IBlockData>)list); // Gather Secret Base Data if (GameCode == GameCodes.Emerald || GameCode == GameCodes.RubySapphire) { List <byte> sbData = new List <byte>(19 * 160); if (GameCode == GameCodes.Emerald) { sbData.AddRange(ByteHelper.SubByteArray(3004, NationalPokedexBAndC.Raw, 964)); sbData.AddRange(ByteHelper.SubByteArray(0, DecorationData.Raw, 2076)); } else if (GameCode == GameCodes.RubySapphire) { sbData.AddRange(ByteHelper.SubByteArray(2856, NationalPokedexBAndC.Raw, 1112)); sbData.AddRange(ByteHelper.SubByteArray(0, DecorationData.Raw, 1928)); } secretBaseManager = new SecretBaseManager(gameSave, sbData.ToArray()); } // Gather the PC data List <byte> pcData = new List <byte>(33730); List <IBlockData> pcBlockList = this.Where <IBlockData>((IBlockData u) => { if (u.SectionID < SectionTypes.PCBufferA) { return(false); } return(u.SectionID <= SectionTypes.PCBufferI); }).ToList <IBlockData>(); foreach (IBlockData blockData in pcBlockList) { pcData.AddRange((blockData as PokeBoxBlockData).GetBoxData()); } this.pokePC.Load(pcData.ToArray()); }