private void Initialize(BitBlock bits) { IsValid = bits[0]; Unk1 = bits.GetRange(1, 4); Level = bits.GetInt(0, 5, 7); MetAt = bits.GetInt(0, 12, 8); MetFloor = bits.GetInt(0, 20, 7); Unk2 = bits[27]; IQ = bits.GetInt(0, 28, 10); RosterNumber = bits.GetInt(0, 38, 10); Unk3 = bits.GetRange(48, 22); ID = new ExplorersPokemonId(bits.GetInt(0, 70, 11)); CurrentHP = bits.GetInt(0, 81, 10); MaxHP = bits.GetInt(0, 81, 10); Attack = bits.GetInt(0, 101, 8); SpAttack = bits.GetInt(0, 109, 8); Defense = bits.GetInt(0, 117, 8); SpDefense = bits.GetInt(0, 125, 8); Exp = bits.GetInt(0, 133, 24); Attack1 = new ExplorersActiveAttack(bits.GetRange(157, ExplorersActiveAttack.BitLength)); Attack2 = new ExplorersActiveAttack(bits.GetRange(186, ExplorersActiveAttack.BitLength)); Attack3 = new ExplorersActiveAttack(bits.GetRange(215, ExplorersActiveAttack.BitLength)); Attack4 = new ExplorersActiveAttack(bits.GetRange(244, ExplorersActiveAttack.BitLength)); Unk4 = bits.GetRange(273, 105); IQMap = bits.GetRange(378, 69); Tactic = bits.GetInt(0, 447, 4); Unk5 = bits.GetRange(451, 15); Name = bits.GetStringPMD(0, 466, 10); }
private void Initialize(BitBlock bits) { IsValid = bits[0]; Level = bits.GetInt(0, 1, 7); ID = new ExplorersPokemonId(bits.GetInt(0, 8, 11)); MetAt = bits.GetInt(0, 19, 8); MetFloor = bits.GetInt(0, 27, 7); Unk1 = bits[34]; EvolvedAtLevel1 = bits.GetInt(0, 35, 7); EvolvedAtLevel2 = bits.GetInt(0, 42, 7); IQ = bits.GetInt(0, 49, 10); HP = bits.GetInt(0, 59, 10); Attack = bits.GetInt(0, 69, 8); SpAttack = bits.GetInt(0, 77, 8); Defense = bits.GetInt(0, 85, 8); SpDefense = bits.GetInt(0, 93, 8); Exp = bits.GetInt(0, 101, 24); IQMap = bits.GetRange(125, 69); Tactic = bits.GetInt(0, 194, 4); Attack1 = new ExplorersAttack(bits.GetRange(198, ExplorersAttack.BitLength)); Attack2 = new ExplorersAttack(bits.GetRange(219, ExplorersAttack.BitLength)); Attack3 = new ExplorersAttack(bits.GetRange(240, ExplorersAttack.BitLength)); Attack4 = new ExplorersAttack(bits.GetRange(261, ExplorersAttack.BitLength)); Name = bits.GetStringPMD(0, 282, 10); }
public BitBlock GetActivePokemonBits() { var bits = new BitBlock(BitLength); bits[0] = IsValid; bits.SetRange(1, 4, Unk1); bits.SetInt(0, 5, 7, Level); bits.SetInt(0, 12, 8, MetAt); bits.SetInt(0, 20, 7, MetFloor); bits[27] = Unk2; bits.SetInt(0, 28, 10, IQ); bits.SetInt(0, 38, 10, RosterNumber); bits.SetRange(48, 22, Unk3); bits.SetInt(0, 70, 11, ID.ID); bits.SetInt(0, 81, 10, CurrentHP); bits.SetInt(0, 91, 10, MaxHP); bits.SetInt(0, 101, 8, Attack); bits.SetInt(0, 109, 8, SpAttack); bits.SetInt(0, 117, 8, Defense); bits.SetInt(0, 125, 8, SpDefense); bits.SetInt(0, 133, 24, Exp); bits.SetRange(157, ExplorersActiveAttack.BitLength, Attack1.ToBitBlock()); bits.SetRange(186, ExplorersActiveAttack.BitLength, Attack2.ToBitBlock()); bits.SetRange(215, ExplorersActiveAttack.BitLength, Attack3.ToBitBlock()); bits.SetRange(244, ExplorersActiveAttack.BitLength, Attack4.ToBitBlock()); bits.SetRange(273, 105, Unk4); bits.SetRange(378, 69, IQMap); bits.SetInt(0, 447, 4, Tactic); bits.SetRange(451, 15, Unk5); bits.SetStringPMD(0, 466, 10, Name); return(bits); }
public BitBlock GetStoredPokemonBits() { var bits = new BitBlock(BitLength); bits[0] = IsValid; bits.SetInt(0, 1, 7, Level); bits.SetInt(0, 8, 11, ID.RawID); bits.SetInt(0, 19, 8, MetAt); bits.SetInt(0, 27, 7, MetFloor); bits[34] = Unk1; bits.SetInt(0, 35, 7, EvolvedAtLevel1); bits.SetInt(0, 42, 7, EvolvedAtLevel2); bits.SetInt(0, 49, 10, IQ); bits.SetInt(0, 59, 10, HP); bits.SetInt(0, 69, 8, Attack); bits.SetInt(0, 77, 8, SpAttack); bits.SetInt(0, 85, 8, Defense); bits.SetInt(0, 93, 8, SpDefense); bits.SetInt(0, 101, 24, Exp); bits.SetRange(125, 69, IQMap); bits.SetInt(0, 194, 4, Tactic); bits.SetRange(198, ExplorersAttack.BitLength, Attack1.ToBitBlock()); bits.SetRange(219, ExplorersAttack.BitLength, Attack2.ToBitBlock()); bits.SetRange(240, ExplorersAttack.BitLength, Attack3.ToBitBlock()); bits.SetRange(261, ExplorersAttack.BitLength, Attack4.ToBitBlock()); bits.SetStringPMD(0, 282, 10, Name); return(bits); }
public void GetUInt_ByteAligned() { var testBlock = new BitBlock(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 5, 0, 0, 0 }); Assert.AreEqual(uint.MaxValue, testBlock.GetUInt(0, 0, 32)); Assert.AreEqual((uint)5, testBlock.GetUInt(4, 0, 32)); }
public void GetInt_ByteAligned() { var testBlock = new BitBlock(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 5, 0, 0, 0 }); Assert.AreEqual(-1, testBlock.GetInt(0, 0, 32)); Assert.AreEqual(5, testBlock.GetInt(4, 0, 32)); }
public BitBlock GetQuicksavePokemonBits() { var bits = new BitBlock(BitLength); bits.SetRange(0, 80, Unk1); bits.SetInt(0, 80, 16, TransformedID.ID); bits.SetInt(0, 96, 16, ID.ID); bits.SetRange(112, 48, Unk2); bits.SetInt(0, 144, 8, Level); bits.SetRange(152, 48, Unk3); bits.SetInt(0, 192, 16, CurrentHP); bits.SetInt(0, 208, 16, MaxHP); bits.SetRange(240, 32, Unk4); bits.SetInt(0, 256, 8, Attack); bits.SetInt(0, 264, 8, Defense); bits.SetInt(0, 272, 8, SpAttack); bits.SetInt(0, 280, 8, SpDefense); bits.SetInt(0, 288, 32, Exp); bits.SetRange(320, 2408, Unk5); bits.SetRange(2696 + 0 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength, Attack1.ToBitBlock()); bits.SetRange(2696 + 1 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength, Attack2.ToBitBlock()); bits.SetRange(2696 + 2 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength, Attack3.ToBitBlock()); bits.SetRange(2696 + 3 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength, Attack4.ToBitBlock()); bits.SetRange(2840, 592, Unk6); return(bits); }
public BitBlock GetStoredPokemonBits() { var bits = new BitBlock(BitLength); // Bit 0 is always 1 for some reason bits[0] = true; bits.SetInt(0, 1, 7, Level); bits.SetInt(0, 8, 11, ID.RawID); bits.SetInt(0, 19, 8, MetAt); bits.SetInt(0, 27, 7, MetFloor); bits[34] = Unk1; bits.SetInt(0, 35, 7, EvolvedAtLevel1); bits.SetInt(0, 42, 7, EvolvedAtLevel2); bits.SetInt(0, 49, 10, IQ); bits.SetInt(0, 59, 10, HP); bits.SetInt(0, 69, 8, Attack); bits.SetInt(0, 77, 8, SpAttack); bits.SetInt(0, 85, 8, Defense); bits.SetInt(0, 93, 8, SpDefense); bits.SetInt(0, 101, 24, Exp); bits.SetRange(125, 92, IQMap); bits.SetInt(0, 217, 4, Tactic); bits.SetRange(221, ExplorersAttack.BitLength, Attack1.ToBitBlock()); bits.SetRange(242, ExplorersAttack.BitLength, Attack2.ToBitBlock()); bits.SetRange(263, ExplorersAttack.BitLength, Attack3.ToBitBlock()); bits.SetRange(284, ExplorersAttack.BitLength, Attack4.ToBitBlock()); bits.SetStringPMD(0, 305, 10, Name); bits.SetRange(385, 2, Unk2); return(bits); }
private void Initialize(BitBlock bits) { // Bit 0 is always 1 for some reason Level = bits.GetInt(0, 1, 7); ID = new ExplorersPokemonId(bits.GetInt(0, 8, 11)); MetAt = bits.GetInt(0, 19, 8); MetFloor = bits.GetInt(0, 27, 7); Unk1 = bits[34]; EvolvedAtLevel1 = bits.GetInt(0, 35, 7); EvolvedAtLevel2 = bits.GetInt(0, 42, 7); IQ = bits.GetInt(0, 49, 10); HP = bits.GetInt(0, 59, 10); Attack = bits.GetInt(0, 69, 8); SpAttack = bits.GetInt(0, 77, 8); Defense = bits.GetInt(0, 85, 8); SpDefense = bits.GetInt(0, 93, 8); Exp = bits.GetInt(0, 101, 24); IQMap = bits.GetRange(125, 92); Tactic = bits.GetInt(0, 217, 4); Attack1 = new ExplorersAttack(bits.GetRange(221, ExplorersAttack.BitLength)); Attack2 = new ExplorersAttack(bits.GetRange(242, ExplorersAttack.BitLength)); Attack3 = new ExplorersAttack(bits.GetRange(263, ExplorersAttack.BitLength)); Attack4 = new ExplorersAttack(bits.GetRange(284, ExplorersAttack.BitLength)); Name = bits.GetStringPMD(0, 305, 10); Unk2 = bits.GetRange(385, 3); }
public RBAttack(BitBlock bits) { IsValid = bits[0]; IsLinked = bits[1]; IsSwitched = bits[2]; IsSet = bits[3]; ID = bits.GetInt(0, 4, 9); PowerBoost = bits.GetInt(0, 13, 7); }
public SkyQuicksavePokemon() { Unk1 = new BitBlock(80); Unk2 = new BitBlock(48); Unk3 = new BitBlock(48); Unk4 = new BitBlock(32); Unk5 = new BitBlock(2408); Unk6 = new BitBlock(592); }
public ExplorersAttack(BitBlock bits) { IsValid = bits[0]; IsLinked = bits[1]; IsSwitched = bits[2]; IsSet = bits[3]; ID = bits.GetInt(0, 4, 10); PowerBoost = bits.GetInt(0, 14, 7); }
public BitBlock ToBitBlock() { var bits = new BitBlock(BitLength); bits[0] = IsValid; bits[1] = IsLinked; bits[2] = IsSwitched; bits[3] = IsSet; bits.SetInt(0, 4, 10, ID); bits.SetInt(0, 14, 7, PowerBoost); return(bits); }
public SkyQuicksaveAttack(BitBlock bits) { IsValid = bits[0]; IsLinked = bits[1]; IsSwitched = bits[2]; IsSet = bits[3]; IsSealed = bits[4]; Unknown = bits.GetRange(5, 11); ID = bits.GetInt(0, 16, 16); PP = bits.GetInt(0, 32, 8); PowerBoost = bits.GetInt(0, 40, 8); }
public void Initialize(BitBlock bits) { IsValid = bits.Bits[0]; Flag1 = bits.Bits[1]; Flag2 = bits.Bits[2]; Flag3 = bits.Bits[3]; Flag4 = bits.Bits[4]; Flag5 = bits.Bits[5]; Flag6 = bits.Bits[6]; Flag7 = bits.Bits[7]; Parameter = bits.GetInt(0, 8, 7); ID = bits.GetInt(0, 15, 8); }
public BitBlock ToBitBlock() { var bits = new BitBlock(BitLength); bits[0] = IsValid; bits[1] = IsLinked; bits[2] = IsSwitched; bits[3] = IsSet; bits[4] = IsSealed; bits.SetRange(5, 11, Unknown); bits.SetInt(0, 16, 16, ID); bits.SetInt(0, 32, 8, PP); bits.SetInt(0, 40, 8, PowerBoost); return(bits); }
private void SaveItems() { // Stored items var compiledItems = new Dictionary <int, int>(); // Key = item ID, value = quantity // - Combine the quantities foreach (var item in StoredItems) { if (!compiledItems.ContainsKey(item.ItemID)) { compiledItems.Add(item.ItemID, 0); } compiledItems[item.ItemID] = Math.Min(item.Quantity + compiledItems[item.ItemID], 1024); } // - Update the save var block = new BitBlock(Offsets.StoredItemCount * 10); for (int i = 0; i < Offsets.StoredItemCount; i++) { if (compiledItems.ContainsKey(i + 1)) { block.SetNextInt(10, compiledItems[i + 1]); } else { block.SetNextInt(10, 0); } } Bits.SetRange(Offsets.StoredItemOffset, Offsets.StoredItemCount * 10, block); // Held items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + i * 33; if (HeldItems.Count > i) { Bits.SetRange(index, 33, HeldItems[i].GetHeldItemBits()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } }
public BitBlock ToBitBlock() { var bits = new BitBlock(33); bits[0] = IsValid; bits[1] = Flag1; bits[2] = Flag2; bits[3] = Flag3; bits[4] = Flag4; bits[5] = Flag5; bits[6] = Flag6; bits[7] = Flag7; bits.SetInt(0, 8, 10, Parameter); bits.SetInt(0, 18, 10, ID); bits.SetInt(0, 28, 3, (int)Holder); return(bits); }
public BitBlock GetHeldItemBits() { var output = new BitBlock(Length); output.Bits[0] = IsValid; output.Bits[1] = Flag1; output.Bits[2] = Flag2; output.Bits[3] = Flag3; output.Bits[4] = Flag4; output.Bits[5] = Flag5; output.Bits[6] = Flag6; output.Bits[7] = Flag7; output.SetInt(0, 8, 7, this.Parameter); output.SetInt(0, 15, 8, ID); return(output); }
public TDHeldItem(BitBlock bits) { bits.Position = 0; IsValid = bits[0]; Flag1 = bits[1]; Flag2 = bits[2]; Flag3 = bits[3]; Flag4 = bits[4]; Flag5 = bits[5]; Flag6 = bits[6]; Flag7 = bits[7]; Parameter = bits.GetInt(0, 8, 10); ID = bits.GetInt(0, 18, 10); var heldBy = bits.GetInt(0, 28, 3); switch (heldBy) { case 0: Holder = ItemHolder.None; break; case 1: Holder = ItemHolder.TeamMember1; break; case 2: Holder = ItemHolder.TeamMember2; break; case 3: Holder = ItemHolder.TeamMember3; break; case 4: Holder = ItemHolder.TeamMember4; break; default: throw new ArgumentException("Invalid item holder: " + heldBy.ToString()); } }
private void Initialize(BitBlock bits) { Level = bits.GetInt(0, 0, 7); ID = bits.GetInt(0, 7, 9); MetAt = bits.GetInt(0, 16, 7); Unk1 = bits.GetRange(23, 21); IQ = bits.GetInt(0, 44, 10); HP = bits.GetInt(0, 54, 10); Attack = bits.GetInt(0, 64, 8); SpAttack = bits.GetInt(0, 72, 8); Defense = bits.GetInt(0, 80, 8); SpDefense = bits.GetInt(0, 88, 8); Exp = bits.GetInt(0, 96, 24); Unk2 = bits.GetRange(120, 43); Attack1 = new RBAttack(bits.GetRange(163, RBAttack.BitLength)); Attack2 = new RBAttack(bits.GetRange(183, RBAttack.BitLength)); Attack3 = new RBAttack(bits.GetRange(203, RBAttack.BitLength)); Attack4 = new RBAttack(bits.GetRange(223, RBAttack.BitLength)); Name = bits.GetStringPMD(0, 243, 10); }
public BitBlock GetStoredPokemonBits() { var bits = new BitBlock(BitLength); bits.SetInt(0, 0, 7, Level); bits.SetInt(0, 7, 9, ID); bits.SetInt(0, 16, 7, MetAt); bits.SetRange(23, 21, Unk1); bits.SetInt(0, 44, 10, IQ); bits.SetInt(0, 54, 10, HP); bits.SetInt(0, 64, 8, Attack); bits.SetInt(0, 72, 8, SpAttack); bits.SetInt(0, 80, 8, Defense); bits.SetInt(0, 88, 8, SpDefense); bits.SetInt(0, 96, 24, Exp); bits.SetRange(120, 43, Unk2); bits.SetRange(163, RBAttack.BitLength, Attack1.ToBitBlock()); bits.SetRange(183, RBAttack.BitLength, Attack2.ToBitBlock()); bits.SetRange(203, RBAttack.BitLength, Attack3.ToBitBlock()); bits.SetRange(223, RBAttack.BitLength, Attack4.ToBitBlock()); bits.SetStringPMD(0, 243, 10, Name); return(bits); }
public void Initialize(BitBlock bits) { Unk1 = bits.GetRange(0, 80); TransformedID = new ExplorersPokemonId(bits.GetInt(0, 80, 16)); ID = new ExplorersPokemonId(bits.GetInt(0, 96, 16)); Unk2 = bits.GetRange(112, 48); Level = bits.GetInt(0, 144, 8); Unk3 = bits.GetRange(152, 48); CurrentHP = bits.GetInt(0, 192, 16); MaxHP = bits.GetInt(0, 208, 16); HPBoost = bits.GetInt(0, 224, 16); Unk4 = bits.GetRange(240, 32); Attack = bits.GetInt(0, 256, 8); Defense = bits.GetInt(0, 264, 8); SpAttack = bits.GetInt(0, 272, 8); SpDefense = bits.GetInt(0, 280, 8); Exp = bits.GetInt(0, 280, 32); Unk5 = bits.GetRange(320, 2408); Attack1 = new SkyQuicksaveAttack(bits.GetRange(2696 + 0 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength)); Attack2 = new SkyQuicksaveAttack(bits.GetRange(2696 + 1 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength)); Attack3 = new SkyQuicksaveAttack(bits.GetRange(2696 + 2 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength)); Attack4 = new SkyQuicksaveAttack(bits.GetRange(2696 + 3 * SkyQuicksaveAttack.BitLength, SkyQuicksaveAttack.BitLength)); Unk6 = bits.GetRange(2840, 592); }
public SkyQuicksavePokemon(BitBlock bits) { Initialize(bits); }
public SkyStoredPokemon(BitBlock bits) { Initialize(bits); }
public RBHeldItem(BitBlock bits) { Initialize(bits); }
public SkyActivePokemon(BitBlock bits) { Initialize(bits); }
public static void SetStringPMD(this BitBlock binary, int byteIndex, int bitIndex, int byteLength, string value) { binary.SetString(byteIndex * 8 + bitIndex, byteLength, new DSMysteryDungeonCharacterEncoding(), value); }
public static string GetStringPMD(this BitBlock binary, int byteIndex, int bitIndex, int byteLength) { return(binary.GetString(byteIndex * 8 + bitIndex, byteLength, new DSMysteryDungeonCharacterEncoding())); }
private void SaveItems() { // Stored items var ids = new BitBlock(11 * 1000); var parameters = new BitBlock(11 * 1000); for (int i = 0; i < 1000; i++) { if (StoredItems.Count > i) { ids.SetNextInt(11, StoredItems[i].ID); parameters.SetNextInt(11, StoredItems[i].Parameter); } else { ids.SetNextInt(11, 0); parameters.SetNextInt(11, 0); } } Bits.SetRange(Offsets.StoredItemOffset, 11 * 1000, ids); Bits.SetRange(Offsets.StoredItemOffset + 11 * 1000, 11 * 1000, parameters); // Held items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + i * 33; if (HeldItems.Count > i) { Bits.SetRange(index, 33, HeldItems[i].ToBitBlock()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } // Sp. Episode Held items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + (i + 50) * 33; if (SpEpisodeHeldItems.Count > i) { Bits.SetRange(index, 33, SpEpisodeHeldItems[i].ToBitBlock()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } // Friend RescueHeld items for (int i = 0; i < 50; i++) { var index = Offsets.HeldItemOffset + (i + 100) * 33; if (HeldItems.Count > i) { Bits.SetRange(index, 33, HeldItems[i].ToBitBlock()); } else { Bits.SetRange(index, 33, new BitBlock(33)); } } }