Esempio n. 1
0
        public void Write()
        {
            if (compressed)
            {
                // compress data
                byte[] uncompData = Arrays.UshortToByte(data);
                byte[] compData   = Compress.CompLZ77(uncompData);
                int    newLen     = compData.Length;

                // write new data
                if (newLen <= origLen)
                {
                    int offset = rom.ReadPtr(pointer);
                    rom.ArrayToRom(compData, 0, offset, newLen);
                }
                else
                {
                    int offset = rom.WriteToEnd(compData);
                    rom.WritePtr(pointer, offset);
                }

                origLen = newLen;
            }
            else
            {
                byte[] bytes  = Arrays.UshortToByte(data);
                int    offset = rom.ReadPtr(pointer);
                rom.ArrayToRom(bytes, 0, offset, bytes.Length);
            }
        }
Esempio n. 2
0
File: GFX.cs Progetto: biosp4rk/mzmr
        public void WriteToEnd(Rom rom, int pointer)
        {
            // compress data
            byte[] compData = Compress.CompLZ77(Data);

            // write new data
            int offset = rom.WriteToEnd(compData);

            rom.WritePtr(pointer, offset);
        }
Esempio n. 3
0
 public void CompLZ77Test()
 {
     byte[] input = new byte[]
     {
         1, 2, 3, 4, 5, 0, 1, 2, 0, 1, 2, 3, 4, 5
     };
     byte[] expected = new byte[]
     {
         0x10, 0x0E, 0, 0,
         0x00, 1, 2, 3, 4, 5, 0, 1, 2,
         0xC0, 0x00, 0x02, 0x00, 0x08
     };
     CollectionAssert.AreEqual(expected, Compress.CompLZ77(input));
 }
Esempio n. 4
0
        public void WriteCopy(int newPointer)
        {
            int offset;

            if (compressed)
            {
                byte[] uncompData = Arrays.UshortToByte(data);
                byte[] compData   = Compress.CompLZ77(uncompData);
                offset = rom.WriteToEnd(compData);
            }
            else
            {
                byte[] bytes = Arrays.UshortToByte(data);
                offset = rom.WriteToEnd(bytes);
            }

            rom.WritePtr(newPointer, offset);
        }
Esempio n. 5
0
File: GFX.cs Progetto: biosp4rk/mzmr
        public void Write()
        {
            // compress data
            byte[] compData = Compress.CompLZ77(Data);
            int    newLen   = compData.Length;

            // write new data
            if (newLen <= origLen)
            {
                int offset = rom.ReadPtr(pointer);
                rom.ArrayToRom(compData, 0, offset, newLen);
            }
            else
            {
                int offset = rom.WriteToEnd(compData);
                rom.WritePtr(pointer, offset);
            }

            origLen = newLen;
        }