Esempio n. 1
0
        public static void WriteMessageTable(MessageTable table, bool isQuickTextEnabled)
        {
            if (isQuickTextEnabled)
            {
                var regex = new Regex("(?<!(?:\x1B|\x1C|\x1D|\x1E).?)(?:\x1F..|\x17|\x18)", RegexOptions.Singleline);
                foreach (var messageEntry in table.messages.Values)
                {
                    messageEntry.Message = regex.Replace(messageEntry.Message, "");
                }
            }
            byte[] new_message_data = table.Rebuild();

            int fileIndex = RomUtils.GetFileIndexForWriting(MESSAGE_DATA_ADDRESS);
            var file      = RomData.MMFileList[fileIndex];

            file.Data = new_message_data;
            file.End  = file.Addr + new_message_data.Length;


            fileIndex = RomUtils.GetFileIndexForWriting(MESSAGE_TABLE_ADDRESS);
            file      = RomData.MMFileList[fileIndex];
            int code_baseAddr = MESSAGE_TABLE_ADDRESS - file.Addr;
            var code_data     = file.Data;

            foreach (var item in table.messages.Values)
            {
                ReadWriteUtils.Arr_WriteU16(code_data, code_baseAddr, item.Id);
                ReadWriteUtils.Arr_WriteU32(code_data, code_baseAddr + 4, (uint)item.address);
                code_baseAddr += 8;
            }

            //write terminator record
            ReadWriteUtils.Arr_WriteU16(code_data, code_baseAddr, 0xFFFF);
            ReadWriteUtils.Arr_WriteU32(code_data, code_baseAddr + 4, 0);
        }
Esempio n. 2
0
        public static void WriteMessageTable(MessageTable table)
        {
            byte[] new_message_data = table.Rebuild();

            int fileIndex = RomUtils.GetFileIndexForWriting(MESSAGE_DATA_ADDRESS);
            var file      = RomData.MMFileList[fileIndex];

            file.Data = new_message_data;
            file.End  = file.Addr + new_message_data.Length;


            fileIndex = RomUtils.GetFileIndexForWriting(MESSAGE_TABLE_ADDRESS);
            file      = RomData.MMFileList[fileIndex];
            int code_baseAddr = MESSAGE_TABLE_ADDRESS - file.Addr;
            var code_data     = file.Data;

            foreach (var item in table.messages.Values)
            {
                ReadWriteUtils.Arr_WriteU16(code_data, code_baseAddr, item.Id);
                ReadWriteUtils.Arr_WriteU32(code_data, code_baseAddr + 4, (uint)item.address);
                code_baseAddr += 8;
            }

            //write terminator record
            ReadWriteUtils.Arr_WriteU16(code_data, code_baseAddr, 0xFFFF);
            ReadWriteUtils.Arr_WriteU32(code_data, code_baseAddr + 4, 0);
        }
Esempio n. 3
0
        public static void WriteEntrances(int[] olde, int[] newe)
        {
            int f = RomUtils.GetFileIndexForWriting(0xC5BC64);

            uint[] data = new uint[newe.Length];

            for (int i = 0; i < newe.Length; i++)
            {
                data[i] = ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, GetEntranceAddr(newe[i]));
            }

            for (int i = 0; i < newe.Length; i++)
            {
                ReadWriteUtils.Arr_WriteU32(RomData.MMFileList[f].Data, GetEntranceAddr(olde[i]), data[i]);
            }
        }
Esempio n. 4
0
 private void WriteTatlColour()
 {
     if (_settings.TatlColorSchema != TatlColorSchema.Random)
     {
         var          selectedColorSchemaIndex = (int)_settings.TatlColorSchema;
         byte[]       c    = new byte[8];
         List <int[]> locs = ResourceUtils.GetAddresses(Values.AddrsDirectory + "tatl-colour");
         for (int i = 0; i < locs.Count; i++)
         {
             ReadWriteUtils.Arr_WriteU32(c, 0, Values.TatlColours[selectedColorSchemaIndex, i << 1]);
             ReadWriteUtils.Arr_WriteU32(c, 4, Values.TatlColours[selectedColorSchemaIndex, (i << 1) + 1]);
             ReadWriteUtils.WriteROMAddr(locs[i], c);
         }
     }
     else
     {
         ResourceUtils.ApplyHack(Values.ModsDirectory + "rainbow-tatl");
     }
 }
Esempio n. 5
0
        public static void DisableCombatMusicOnEnemy(GameObjects.Actor actor)
        {
            int actorInitVarRomAddr = actor.GetAttribute <ActorInitVarOffsetAttribute>().Offset;
            /// each enemy actor has actor init variables,
            /// if they have combat music is determined if a flag is set in the seventh byte
            /// disabling combat music means disabling this bit for most enemies
            int actorFileID = (int)actor;

            RomUtils.CheckCompressed(actorFileID);
            int  actorFlagLocation = (actorInitVarRomAddr + 7);// - RomData.MMFileList[ActorFID].Addr; // file offset
            byte flagByte          = RomData.MMFileList[actorFileID].Data[actorFlagLocation];

            RomData.MMFileList[actorFileID].Data[actorFlagLocation] = (byte)(flagByte & 0xFB);

            if (actor == GameObjects.Actor.DekuBabaWithered) // special case: when they regrow music returns
            {
                // when they finish regrowing their combat music bit is reset, we need to no-op this to stop it
                //  [ori t3,t1,0x0005] which is [35 2B 00 05] becomes [00 00 00 00]
                ReadWriteUtils.Arr_WriteU32(RomData.MMFileList[actorFileID].Data, 0x12BC, 0x00000000);
            }
        }