示例#1
0
        private unsafe static byte[] Read2Bpp(IAMemory Memory, TextureInfo Texture)
        {
            int Width  = Texture.Width;
            int Height = Texture.Height;

            byte[] Output = new byte[Width * Height * 2];

            ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);

            (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
                Memory,
                Texture.Position);

            fixed(byte *BuffPtr = Output)
            {
                long OutOffs = 0;

                for (int Y = 0; Y < Height; Y++)
                {
                    for (int X = 0; X < Width; X++)
                    {
                        long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);

                        short Pixel = CpuMem.ReadInt16Unchecked(Position + Offset);

                        *(short *)(BuffPtr + OutOffs) = Pixel;

                        OutOffs += 2;
                    }
                }
            }

            return(Output);
        }
示例#2
0
        private unsafe static byte[] Read5551(IAMemory Memory, Texture Texture)
        {
            int Width  = Texture.Width;
            int Height = Texture.Height;

            byte[] Output = new byte[Width * Height * 2];

            ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 2);

            (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
                Memory,
                Texture.Position);

            fixed(byte *BuffPtr = Output)
            {
                long OutOffs = 0;

                for (int Y = 0; Y < Height; Y++)
                {
                    for (int X = 0; X < Width; X++)
                    {
                        long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);

                        uint Pixel = (uint)CpuMem.ReadInt16Unchecked(Position + Offset);

                        Pixel = (Pixel & 0x001f) << 11 |
                                (Pixel & 0x03e0) << 1 |
                                (Pixel & 0x7c00) >> 9 |
                                (Pixel & 0x8000) >> 15;

                        *(short *)(BuffPtr + OutOffs) = (short)Pixel;

                        OutOffs += 2;
                    }
                }
            }

            return(Output);
        }