NScumm.Scumm.IO.ResourceFile0.DecodeV1Gfx C# (CSharp) Method

DecodeV1Gfx() private method

private DecodeV1Gfx ( long offset, byte dst, int size ) : void
offset long
dst byte
size int
return void
        void DecodeV1Gfx(long offset, byte[] dst, int size)
        {
            _reader.BaseStream.Seek(offset, SeekOrigin.Begin);
            int x, z;
            byte color, run;
            byte[] common = new byte[4];

            for (z = 0; z < 4; z++)
            {
                common[z] = _reader.ReadByte();
            }

            x = 0;
            while (x < size)
            {
                run = _reader.ReadByte();
                if ((run & 0x80) != 0)
                {
                    color = common[(run >> 5) & 3];
                    run &= 0x1F;
                    for (z = 0; z <= run; z++)
                    {
                        dst[x++] = color;
                    }
                }
                else if ((run & 0x40) != 0)
                {
                    run &= 0x3F;
                    color = _reader.ReadByte();
                    for (z = 0; z <= run; z++)
                    {
                        dst[x++] = color;
                    }
                }
                else
                {
                    for (z = 0; z <= run; z++)
                    {
                        dst[x++] = _reader.ReadByte();
                    }
                }
            }
        }