Esempio n. 1
0
        private static unsafe Texture2D readTexmapTexture(int index)
        {
            int  length, extra;
            bool is_patched;

            BinaryFileReader reader = m_Index.Seek(index, out length, out extra, out is_patched);

            if (reader == null)
            {
                return(null);
            }

            int metrics_dataread_start = (int)reader.Position;

            int textureSize = (extra == 0) ? 64 : 128;

            uint[]   pixelData = new uint[textureSize * textureSize];
            ushort[] fileData  = reader.ReadUShorts(textureSize * textureSize);

            fixed(uint *pData = pixelData)
            {
                uint *pDataRef = pData;

                int count = 0;
                int max   = textureSize * textureSize;

                while (count < max)
                {
                    uint color      = fileData[count];
                    *    pDataRef++ = 0xFF000000 + (
                        ((((color >> 10) & 0x1F) * multiplier)) |
                        ((((color >> 5) & 0x1F) * multiplier) << 8) |
                        (((color & 0x1F) * multiplier) << 16)
                        );
                    count++;
                }
            }

            Texture2D texture = new Texture2D(m_graphics, textureSize, textureSize);

            texture.SetData <uint>(pixelData);

            Metrics.ReportDataRead((int)reader.Position - metrics_dataread_start);

            return(texture);
        }
        public static Skill GetSkill(int index)
        {
            if (m_List[index] != null)
            {
                return(m_List[index]);
            }

            int              length, extra;
            bool             patched;
            BinaryFileReader reader = m_FileIndex.Seek(index, out length, out extra, out patched);

            if (reader == null)
            {
                return(m_List[index] = new Skill(SkillVars.NullV));
            }

            return(m_List[index] = LoadSkill(index, reader));
        }
Esempio n. 3
0
        public static MultiComponentList Load(int index)
        {
            try
            {
                int              length, extra;
                bool             patched;
                BinaryFileReader reader = m_FileIndex.Seek(index, out length, out extra, out patched);
                if (reader == null)
                {
                    return(MultiComponentList.Empty);
                }

                return(new MultiComponentList(reader, length / 12));
            }
            catch
            {
                return(MultiComponentList.Empty);
            }
        }
Esempio n. 4
0
        private static unsafe Texture2D ReadLandTexture(int index)
        {
            int  length, extra;
            bool is_patched;

            var reader = Index.Seek(index, out length, out extra, out is_patched);

            if (reader == null)
            {
                return(null);
            }

            var data = new uint[44 * 44];

            var fileData = reader.ReadUShorts(((44 + 2) / 2) * 44);
            var i        = 0;

            var count  = 2;
            var offset = 21;

            fixed(uint *pData = data)
            {
                uint *dataRef = pData;

                for (int y = 0; y < 22; y++, count += 2, offset--, dataRef += 44)
                {
                    uint *start = dataRef + offset;
                    uint *end   = start + count;

                    Metrics.ReportDataRead(count * 2);

                    while (start < end)
                    {
                        uint color   = fileData[i++];
                        *    start++ = 0xFF000000 + (
                            ((((color >> 10) & 0x1F) * multiplier)) |
                            ((((color >> 5) & 0x1F) * multiplier) << 8) |
                            (((color & 0x1F) * multiplier) << 16)
                            );
                    }
                }

                count  = 44;
                offset = 0;

                for (var y = 0; y < 22; y++, count -= 2, offset++, dataRef += 44)
                {
                    uint *start = dataRef + offset;
                    uint *end   = start + count;

                    Metrics.ReportDataRead(count * 2);

                    while (start < end)
                    {
                        uint color   = fileData[i++];
                        *    start++ = 0xFF000000 + (
                            ((((color >> 10) & 0x1F) * multiplier)) |
                            ((((color >> 5) & 0x1F) * multiplier) << 8) |
                            (((color & 0x1F) * multiplier) << 16)
                            );
                    }
                }
            }

            var texture = new Texture2D(_graphics, 44, 44);

            texture.SetData <uint>(data);

            return(texture);
        }
Esempio n. 5
0
        public unsafe static Texture2D GetGumpXNA(int index)
        {
            if (index < 0)
            {
                return(null);
            }
            if (m_cache[index] == null)
            {
                int  length, extra;
                bool patched;

                BinaryFileReader reader = m_FileIndex.Seek(index, out length, out extra, out patched);
                if (reader == null)
                {
                    return(null);
                }

                int width  = (extra >> 16) & 0xFFFF;
                int height = extra & 0xFFFF;

                int metrics_dataread_start = (int)reader.Position;

                int[]    lookups  = reader.ReadInts(height);
                ushort[] fileData = reader.ReadUShorts(length - (height * 2));

                uint[] pixels = new uint[width * height];

                fixed(uint *line = &pixels[0])
                {
                    fixed(ushort *data = &fileData[0])
                    {
                        for (int y = 0; y < height; ++y)
                        {
                            ushort *dataRef = data + (lookups[y] - height) * 2;

                            uint *cur = line + (y * width);
                            uint *end = cur + width;

                            while (cur < end)
                            {
                                uint  color = *dataRef++;
                                uint *next  = cur + *dataRef++;

                                if (color == 0)
                                {
                                    cur = next;
                                }
                                else
                                {
                                    uint color32 = 0xFF000000 + (
                                        ((((color >> 10) & 0x1F) * multiplier)) |
                                        ((((color >> 5) & 0x1F) * multiplier) << 8) |
                                        (((color & 0x1F) * multiplier) << 16)
                                        );
                                    while (cur < next)
                                    {
                                        *cur++ = color32;
                                    }
                                }
                            }
                        }
                    }
                }

                Metrics.ReportDataRead(length);

                Texture2D texture = new Texture2D(m_graphicsDevice, width, height, false, SurfaceFormat.Color);
                texture.SetData(pixels);
                m_cache[index] = texture;
            }
            return(m_cache[index]);
        }