private void FillRemake(IReadOnlyList <string> items) { var str = GameInfo.Strings; var invert = ItemRemakeUtil.GetInvertedDictionary(); var ofs = Player.Personal.Offsets.ItemRemakeCollectBit; var max = Player.Personal.Offsets.MaxRemakeBitFlag; var data = Player.Personal.Data; for (int i = 0; i < max; i++) { var remakeIndex = i >> 3; // ItemRemakeInfo.BodyColorCountMax var variant = i & 7; ushort itemId = invert.TryGetValue((short)remakeIndex, out var id) ? id : (ushort)0; var itemName = remakeIndex == 0652 ? "photo" : items[itemId]; var flag = FlagUtil.GetFlag(data, ofs, i); string name = $"{remakeIndex:0000} V{variant:0} - {itemName}"; if (ItemRemakeInfoData.List.TryGetValue((short)remakeIndex, out var info)) { name = $"{name} ({info.GetBodyDescription(variant, str)})"; } CLB_Remake.Items.Add(name, flag); } }
public PersonalInfoSWSH(byte[] data) : base(data) { TMHM = new bool[200]; for (var i = 0; i < CountTR; i++) { TMHM[i] = FlagUtil.GetFlag(Data, 0x28 + (i >> 3), i); TMHM[i + CountTM] = FlagUtil.GetFlag(Data, 0x3C + (i >> 3), i); } // 0x38-0x3B type tutors, but only 8 bits are valid flags. var typeTutors = new bool[8]; for (int i = 0; i < typeTutors.Length; i++) { typeTutors[i] = FlagUtil.GetFlag(Data, 0x38, i); } TypeTutors = typeTutors; // 0xA8-0xAF are armor type tutors, one bit for each type var armorTutors = new bool[18]; for (int i = 0; i < armorTutors.Length; i++) { armorTutors[i] = FlagUtil.GetFlag(Data, 0xA8 + (i >> 3), i); } SpecialTutors = new[] { armorTutors, }; }
private void FillCollect(IReadOnlyList<string> items) { var ofs = Player.Personal.Offsets.ItemCollectBit; var data = Player.Personal.Data; for (int i = 0; i < items.Count; i++) { var flag = FlagUtil.GetFlag(data, ofs, i); string value = items[i]; string name = $"0x{i:X3} - {value}"; CLB_Items.Items.Add(name, flag); } }
public void GetSetFlag(uint raw, int byteIndex, int bitIndex) { Span <byte> data = stackalloc byte[4]; WriteUInt32LittleEndian(data, raw); var value = FlagUtil.GetFlag(data, byteIndex, bitIndex); value.Should().Be(true); Span <byte> copy = stackalloc byte[data.Length]; FlagUtil.SetFlag(copy, byteIndex, bitIndex, true); data.SequenceEqual(copy).Should().BeTrue(); }
private void FillCheckBoxes() { var items = GameInfo.Strings.itemlistdisplay; var ofs = Player.Personal.Offsets.ReceivedItems; var data = Player.Personal.Data; for (int i = 0; i < items.Length; i++) { var flag = FlagUtil.GetFlag(data, ofs, i); string value = items[i]; string name = $"0x{i:X3} - {value}"; CLB_Items.Items.Add(name, flag); } }
private static void LoadFavorites(IEnumerable <InventoryItem> items, Span <byte> favorites) { foreach (var z in items) { var item = (InventoryItem8a)z; var itemID = item.Index; var ofs = itemID >> 3; if ((uint)ofs >= favorites.Length) { continue; } var bit = itemID & 7; item.IsFavorite = FlagUtil.GetFlag(favorites, ofs, bit); } }
public PersonalInfoLA(byte[] data) : base(data) { // TM/TR and Special Tutors are inaccessible; dummy data. // 0xA8-0xAF are armor type tutors, one bit for each type var moveShop = new bool[Legal.MoveShop8_LA.Length]; for (int i = 0; i < moveShop.Length; i++) { moveShop[i] = FlagUtil.GetFlag(Data, 0xA8 + (i >> 3), i); } SpecialTutors = new[] { moveShop, }; }
public void ClearFlag(uint raw, int byteIndex, int bitIndex) { Span <byte> data = stackalloc byte[4]; WriteUInt32LittleEndian(data, raw); var value = FlagUtil.GetFlag(data, byteIndex, bitIndex); value.Should().Be(false); // does nothing on empty Span <byte> copy = stackalloc byte[data.Length]; FlagUtil.SetFlag(copy, byteIndex, bitIndex, false); copy.Count((byte)0).Should().Be(copy.Length); // doesn't clear any other flag data.CopyTo(copy); FlagUtil.SetFlag(copy, byteIndex, bitIndex, false); data.SequenceEqual(copy).Should().BeTrue(); }
private void FillCheckBoxes() { var items = GameInfo.Strings.itemlist.ToArray(); items[0] = string.Empty; var ofs = Player.Personal.Offsets.ReceivedItems; var data = Player.Personal.Data; for (int i = 0; i < items.Length; i++) { var flag = FlagUtil.GetFlag(data, ofs, i); string value = items[i]; if (string.IsNullOrEmpty(value)) { value = i.ToString(); } string name = $"0x{i:X3} - {value}"; CLB_Items.Items.Add(name, flag); } }
public sealed override bool GetFlag(int offset, int bitIndex) => FlagUtil.GetFlag(General, offset, bitIndex);
public bool GetFlag(int index) { var offset = Offset + FlagStart + (index >> 3); return(FlagUtil.GetFlag(Data, offset, index)); }