public Armor(int armorIndex, FF1Rom rom) { ArmorIndex = armorIndex; //read stats from memory int armorBaseOffset = FF1Rom.ArmorOffset + (ArmorIndex * FF1Rom.ArmorSize); Weight = rom.Get(armorBaseOffset, 1).ToBytes()[0]; Absorb = rom.Get(armorBaseOffset + 1, 1).ToBytes()[0]; ElementalResist = rom.Get(armorBaseOffset + 2, 1).ToBytes()[0]; SpellIndex = rom.Get(armorBaseOffset + 3, 1).ToBytes()[0]; Type = (ArmorType)rom.Get(FF1Rom.ArmorTypeOffset + ArmorIndex, 1).ToBytes()[0]; //get name stuff Icon = ArmorIcon.NONE; Name = rom.ItemsText[(int)Item.Cloth + ArmorIndex]; foreach (var kv in IconCodes) { if (Name.Contains(kv.Value)) { Icon = kv.Key; break; } } }
public Armor(int armorIndex, string name, ArmorIcon icon, byte weight, byte absorb, byte elementalResist, byte spellIndex, ArmorType type) { ArmorIndex = armorIndex; Name = name; Icon = icon; Weight = weight; Absorb = absorb; ElementalResist = elementalResist; SpellIndex = spellIndex; Type = type; }
private ArmorIcon getArmorIconFromByte(byte icon) { ArmorIcon matchedType = ArmorIcon.NONE; foreach (ArmorIcon temp in (ArmorIcon[])Enum.GetValues(typeof(ArmorIcon))) { if (icon == (byte)temp) { matchedType = temp; } } return(matchedType); }
public Armor(int armorIndex, byte[] nameBytes, ArmorIcon icon, byte weight, byte absorb, byte elementalResist, byte spellIndex) { ArmorIndex = armorIndex; NameBytes = nameBytes; Icon = icon; if (icon != ArmorIcon.NONE) { NameBytes[6] = (byte)icon; } Weight = weight; Absorb = absorb; ElementalResist = elementalResist; SpellIndex = spellIndex; }
public Armor(int armorIndex, NesRom rom) { ArmorIndex = armorIndex; //read stats from memory int armorBaseOffset = FF1Rom.ArmorOffset + (ArmorIndex * FF1Rom.ArmorSize); Weight = rom.Get(armorBaseOffset, 1).ToBytes()[0]; Absorb = rom.Get(armorBaseOffset + 1, 1).ToBytes()[0]; ElementalResist = rom.Get(armorBaseOffset + 2, 1).ToBytes()[0]; SpellIndex = rom.Get(armorBaseOffset + 3, 1).ToBytes()[0]; //read permissions int armorPermissionOffset = FF1Rom.ArmorPermissionsOffset + (ArmorIndex * FF1Rom.PermissionsSize); byte highByte = rom.Get(armorPermissionOffset, 1).ToBytes()[0]; byte lowByte = rom.Get(armorPermissionOffset + 1, 1).ToBytes()[0]; ushort assembledUShort = BitConverter.ToUInt16(new byte[2] { highByte, lowByte }, 0); ushort convertedClassPermissions = (ushort)(assembledUShort ^ 0xFFF); ClassUsability = convertedClassPermissions; //get name stuff Icon = ArmorIcon.NONE; int armorBaseNameOffset = FF1Rom.GearTextOffset + ((ArmorIndex + 40) * FF1Rom.GearTextSize) + (ArmorIndex > 31 ? 1 : 0); //TODO figure out if treasure hunt is enabled, if so add 6 to this offset byte currentValue; NameBytes = rom.Get(armorBaseNameOffset, 8).ToBytes(); //find icon for (int i = 0; i < 8; i++) { currentValue = NameBytes[i]; //icon range > 200 if (currentValue > 200) { //check for icon Icon = getArmorIconFromByte(currentValue); } } }