Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// Build table <see cref="byte"/> array.
        /// </summary>
        /// <returns>Table <see cref="byte"/> array.</returns>
        public byte[] Build()
        {
            var bytes = new byte[this.Overrides.Length * 4];

            for (int i = 0; i < this.Overrides.Length; i++)
            {
                var entry  = this.Overrides[i];
                var offset = i * 4;
                ReadWriteUtils.Arr_WriteU16(bytes, offset, entry.GraphicId);
                ReadWriteUtils.Arr_WriteU16(bytes, offset + 2, entry.ObjectId);
            }
            return(bytes);
        }