示例#1
0
        private void SendTexture(AMemory Memory)
        {
            long TicPos = (long)GetRegister(NsGpuRegister._3dTicAddressHigh) << 32 |
                          (long)GetRegister(NsGpuRegister._3dTicAddressLow) << 0;

            int CbData = GetRegister(NsGpuRegister._3dCbData0);

            int TicIndex = (CbData >> 0) & 0xfffff;
            int TscIndex = (CbData >> 20) & 0xfff; //I guess?

            TicPos = Gpu.MemoryMgr.GetCpuAddr(TicPos + TicIndex * 0x20);

            if (TicPos != -1)
            {
                int Word0 = Memory.ReadInt32(TicPos + 0x0);
                int Word1 = Memory.ReadInt32(TicPos + 0x4);
                int Word2 = Memory.ReadInt32(TicPos + 0x8);
                int Word3 = Memory.ReadInt32(TicPos + 0xc);
                int Word4 = Memory.ReadInt32(TicPos + 0x10);
                int Word5 = Memory.ReadInt32(TicPos + 0x14);
                int Word6 = Memory.ReadInt32(TicPos + 0x18);
                int Word7 = Memory.ReadInt32(TicPos + 0x1c);

                long TexAddress = Word1;

                TexAddress |= (long)(Word2 & 0xff) << 32;

                TexAddress = Gpu.MemoryMgr.GetCpuAddr(TexAddress);

                if (TexAddress != -1)
                {
                    NsGpuTextureFormat Format = (NsGpuTextureFormat)(Word0 & 0x7f);

                    int Width  = (Word4 & 0xffff) + 1;
                    int Height = (Word5 & 0xffff) + 1;

                    byte[] Buffer = GetDecodedTexture(Memory, Format, TexAddress, Width, Height);

                    if (Buffer != null)
                    {
                        Gpu.Renderer.QueueAction(delegate()
                        {
                            Gpu.Renderer.SendR8G8B8A8Texture(0, Buffer, Width, Height);
                        });
                    }
                }
            }
        }
示例#2
0
        private static byte[] GetDecodedTexture(
            AMemory Memory,
            NsGpuTextureFormat Format,
            long Position,
            int Width,
            int Height)
        {
            byte[] Data = null;

            switch (Format)
            {
            case NsGpuTextureFormat.BC1:
            {
                int Size = (Width * Height) >> 1;

                Data = AMemoryHelper.ReadBytes(Memory, Position, Size);

                Data = BCn.DecodeBC1(new NsGpuTexture()
                    {
                        Width  = Width,
                        Height = Height,
                        Data   = Data
                    }, 0);

                break;
            }

            case NsGpuTextureFormat.BC2:
            {
                int Size = Width * Height;

                Data = AMemoryHelper.ReadBytes(Memory, Position, Size);

                Data = BCn.DecodeBC2(new NsGpuTexture()
                    {
                        Width  = Width,
                        Height = Height,
                        Data   = Data
                    }, 0);

                break;
            }

            case NsGpuTextureFormat.BC3:
            {
                int Size = Width * Height;

                Data = AMemoryHelper.ReadBytes(Memory, Position, Size);

                Data = BCn.DecodeBC3(new NsGpuTexture()
                    {
                        Width  = Width,
                        Height = Height,
                        Data   = Data
                    }, 0);

                break;
            }

                //default: throw new NotImplementedException(Format.ToString());
            }

            return(Data);
        }