public static void ReadInstrumentSetList() { // traverse the whole audiobank index and grab details about every bank // use those details to generate a list from the vanilla game that we can modify as needed List <InstrumentSetInfo> InstrumentSets = new List <InstrumentSetInfo>(); for (int inst_set_num = 0; inst_set_num <= 0x28; ++inst_set_num) { // each bank has one 16 byte sentence of data, first word is address, second length, last 8 bytes metadata int table_pointer_addr = Addresses.AudiobankTable + (16 * inst_set_num); int bank_location = (ReadWriteUtils.ReadU16(table_pointer_addr) << 16) + ReadWriteUtils.ReadU16(table_pointer_addr + 2); int bank_length = (ReadWriteUtils.ReadU16(table_pointer_addr + 4) << 16) + ReadWriteUtils.ReadU16(table_pointer_addr + 6); byte[] metadata = new byte[8]; for (int b = 0; b < 8; ++b) { metadata[b] = ReadWriteUtils.Read(table_pointer_addr + 8 + b); } byte[] bank_data = new byte[bank_length]; for (int b = 0; b < bank_length; ++b) { bank_data[b] = ReadWriteUtils.Read(Addresses.Audiobank + bank_location + b); } InstrumentSetInfo new_bank = new InstrumentSetInfo { BankSlot = inst_set_num, BankMetaData = metadata, BankBinary = bank_data }; InstrumentSets.Add(new_bank); } RomData.InstrumentSetList = InstrumentSets; }
public static void ReadInstrumentSetList() { /// traverse the whole audiobank index and grab details about every bank /// use those details to generate a list from the vanilla game that we can modify as needed RomData.InstrumentSetList = new List <InstrumentSetInfo>(); for (int audiobankIndex = 0; audiobankIndex <= 0x28; ++audiobankIndex) { // each bank has one 16 byte sentence of data, first word is address, second is length, last 2 words metadata int audiobankIndexAddr = Addresses.AudiobankTable + (audiobankIndex * 0x10); int audiobankBankOffset = (ReadWriteUtils.ReadU16(audiobankIndexAddr) << 16) + ReadWriteUtils.ReadU16(audiobankIndexAddr + 2); int bankLength = (ReadWriteUtils.ReadU16(audiobankIndexAddr + 4) << 16) + ReadWriteUtils.ReadU16(audiobankIndexAddr + 6); byte[] bankMetadata = new byte[8]; for (int b = 0; b < 8; ++b) { bankMetadata[b] = ReadWriteUtils.Read(audiobankIndexAddr + 8 + b); } byte[] bankData = new byte[bankLength]; for (int b = 0; b < bankLength; ++b) { bankData[b] = ReadWriteUtils.Read(Addresses.Audiobank + audiobankBankOffset + b); } var newInstrumentSet = new InstrumentSetInfo { BankSlot = audiobankIndex, BankMetaData = bankMetadata, BankBinary = bankData }; RomData.InstrumentSetList.Add(newInstrumentSet); } }
private static void UpdateChest(Item location, Item item, ChestTypeAttribute.ChestType?overrideChestType) { var chestType = item.GetAttribute <ChestTypeAttribute>().Type; if (overrideChestType.HasValue) { chestType = overrideChestType.Value; } var chestAttribute = location.GetAttribute <ChestAttribute>(); if (chestAttribute != null) { foreach (var address in chestAttribute.Addresses) { var chestVariable = ReadWriteUtils.Read(address); chestVariable &= 0x0F; // remove existing chest type var newChestType = ChestAttribute.GetType(chestType, chestAttribute.Type); newChestType <<= 4; chestVariable |= newChestType; ReadWriteUtils.WriteToROM(address, chestVariable); } } var grottoChestAttribute = location.GetAttribute <GrottoChestAttribute>(); if (grottoChestAttribute != null) { foreach (var address in grottoChestAttribute.Addresses) { var grottoVariable = ReadWriteUtils.Read(address); grottoVariable &= 0x1F; // remove existing chest type var newChestType = (byte)chestType; newChestType <<= 5; grottoVariable |= newChestType; // add new chest type ReadWriteUtils.WriteToROM(address, grottoVariable); } } }