コード例 #1
0
        private void UpdateEntries(String msg, int index)
        {
            m_MsgData[index]       = msg;
            m_ShortVersions[index] = ShortVersion(msg, index);
            int lengthDif = EncodeString(msg).Count - m_StringLengths[index];

            m_StringLengths[index] += lengthDif;

            //Make or remove room for the new string if needed (don't need to for last entry)
            if (lengthDif > 0 && index != m_MsgData.Length - 1)
            {
                uint   curStringStart  = m_StringHeaderData[index] + m_DAT1Start;
                uint   nextStringStart = m_StringHeaderData[index + 1] + m_DAT1Start;
                byte[] followingData   = file.ReadBlock(nextStringStart, (uint)(file.m_Data.Length - nextStringStart));
                for (int i = (int)curStringStart; i < (int)nextStringStart + lengthDif; i++)
                {
                    file.Write8((uint)i, 0);// Fill the gap with zeroes
                }
                file.WriteBlock((uint)(nextStringStart + lengthDif), followingData);
            }
            else if (lengthDif < 0 && index != m_MsgData.Length - 1)
            {
                // lengthDif is negative, -- +
                uint   nextStringStart = m_StringHeaderData[index + 1] + m_DAT1Start;
                byte[] followingData   = file.ReadBlock(nextStringStart, (uint)(file.m_Data.Length - nextStringStart));
                file.WriteBlock((uint)(nextStringStart + lengthDif), followingData);
                int oldSize = file.m_Data.Length;
                Array.Resize(ref file.m_Data, oldSize + lengthDif);// Remove duplicate data at end of file
            }

            // Update pointers to string entry data
            if (lengthDif != 0)
            {
                for (int i = index + 1; i < m_MsgData.Length; i++)
                {
                    if (lengthDif > 0)
                    {
                        m_StringHeaderData[i] += (uint)lengthDif;
                    }
                    else if (lengthDif < 0)
                    {
                        m_StringHeaderData[i] = (uint)(m_StringHeaderData[i] + lengthDif);
                    }

                    file.Write32(m_StringHeaderAddr[i], m_StringHeaderData[i]);
                    file.Write16(m_StringWidthAddr[i], m_StringWidth[i]);
                    file.Write16(m_StringHeightAddr[i], m_StringHeight[i]);
                }
            }
            // Update total file size
            file.Write32(0x08, (uint)(int)(file.Read32(0x08) + lengthDif));
            // Update DAT1 size
            file.Write32(m_DAT1Start - 0x04, (uint)(int)(file.Read32(m_DAT1Start - 0x04) + lengthDif));
        }
コード例 #2
0
 public /*override*/ void Write()
 {
     m_File.Write32(m_Offset + 0x00, m_FileID);
     m_File.Write16(m_Offset + 0x04, m_Bank);
     m_File.Write8(m_Offset + 0x06, m_Volume);
     m_File.Write8(m_Offset + 0x07, m_ChannelPriority);
     m_File.Write8(m_Offset + 0x08, m_PlayerPriority);
     m_File.Write8(m_Offset + 0x09, m_PlayerNumber);
     m_File.WriteBlock(m_Offset + 0x0A, m_Unknown2);
 }
コード例 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            uint flags = (uint)m_Texture.m_Tex.m_TexType;

            flags |= ((uint)Math.Log(m_Texture.m_Tex.m_Width, 2) - 3) << 4;
            flags |= ((uint)Math.Log(m_Texture.m_Tex.m_Height, 2) - 3) << 8;
            flags |= (uint)(m_Texture.m_RepeatX == Particle.Texture.RepeatMode.REPEAT ? 0x1000 : m_Texture.m_RepeatX == Particle.Texture.RepeatMode.FLIP ? 0x5000 : 0);
            flags |= (uint)(m_Texture.m_RepeatY == Particle.Texture.RepeatMode.REPEAT ? 0x2000 : m_Texture.m_RepeatY == Particle.Texture.RepeatMode.FLIP ? 0xa000 : 0);
            flags |= (uint)(m_Texture.m_Tex.m_Colour0Mode != 0 ? 1 : 0) << 16;

            uint texelArrSize = (uint)m_Texture.m_Tex.m_RawTextureData.Length;
            uint palOffset    = 0x20 + texelArrSize;
            uint palSize      = (uint)m_Texture.m_Tex.m_RawPaletteData.Length;
            uint totalSize    = palOffset + palSize;

            m_ParticleTexFile.Write32(0x0, 0x53505420);    // "SPT " in ascii
            m_ParticleTexFile.Write32(0x04, flags);        // flags

            m_ParticleTexFile.Write32(0x08, texelArrSize); // texelArrSize
            m_ParticleTexFile.Write32(0x0c, palOffset);    // palOffset
            m_ParticleTexFile.Write32(0x10, palSize);      // palSize
            m_ParticleTexFile.Write32(0x1c, totalSize);    // totalSize

            m_ParticleTexFile.WriteBlock(0x20, m_Texture.m_Tex.m_RawTextureData);
            m_ParticleTexFile.WriteBlock(palOffset, m_Texture.m_Tex.m_RawPaletteData);

            // make it so the file is only as big as it needs to be
            if (m_ParticleTexFile.m_Data.Length - (int)totalSize > 0)
            {
                m_ParticleTexFile.RemoveSpace(totalSize, (uint)m_ParticleTexFile.m_Data.Length - totalSize);
            }

            m_ParticleTexFile.SaveChanges();
        }