Ejemplo n.º 1
0
 private static void SetTexture(Int32 TP, Int32 TY, Int32 TX, Int32 clutY, Int32 clutX, FilterMode filter = FilterMode.Point)
 {
     if (TP != 2)
     {
         PSXGPU.constOffset.z  = 0.5f;
         PSXGPU.constTexSize.x = 256f;
         PSXGPU.constTexSize.y = 256f;
         PSXTexture texture = PSXTextureMgr.GetTexture(TP, TY, TX, clutY, clutX);
         texture.SetFilter(filter);
         if (texture.key != PSXGPU.texKey)
         {
             PSXGPU.curMaterial.mainTexture = texture.texture;
             PSXGPU.texKey        = texture.key;
             PSXGPU.isNeedSetPass = true;
         }
     }
     else
     {
         PSXGPU.constOffset.z  = (Single)((TX << 6) - PSXTextureMgr.GEN_TEXTURE_X) + 0.5f;
         PSXGPU.constTexSize.x = (Single)PSXTextureMgr.GEN_TEXTURE_W;
         PSXGPU.constTexSize.y = (Single)PSXTextureMgr.GEN_TEXTURE_H;
         if (PSXGPU.texKey != 4294967295u)
         {
             PSXGPU.curMaterial.mainTexture = PSXTextureMgr.genTexture;
             PSXGPU.texKey        = UInt32.MaxValue;
             PSXGPU.isNeedSetPass = true;
         }
     }
 }
Ejemplo n.º 2
0
    public unsafe static void MoveImage(Int32 dx, Int32 dy, Int16 *p)
    {
        if (SFX.currentEffectID == 149)
        {
            return;
        }
        if (SFX.currentEffectID == 274)
        {
            PSXTextureMgr.isCaptureSS = true;
            return;
        }
        PSXTextureMgr.ClearKey(dx, dy);
        Int16 num  = *p;
        Int16 num2 = p[1];
        Int16 num3 = p[2];
        Int16 num4 = p[3];

        for (Int32 i = 0; i < (Int32)num4; i++)
        {
            Int32 num5 = (dy + i) * 1024 + dx;
            Int32 num6 = ((Int32)num2 + i) * 1024 + (Int32)num;
            for (Int32 j = 0; j < (Int32)num3; j++)
            {
                PSXTextureMgr.originalVram[num5] = PSXTextureMgr.originalVram[num6];
                num5++;
                num6++;
            }
        }
    }
Ejemplo n.º 3
0
    private void _GenerateSPSMesh()
    {
        if (this.spsPrims.Count == 0)
        {
            return;
        }
        Single    num      = (Single)this.scale / 4096f;
        Matrix4x4 matrix4x = Matrix4x4.TRS(this.pos, Quaternion.Euler(this.rot.x, this.rot.y, this.rot.z), new Vector3(-num, -num, num));

        base.transform.position = this.pos;
        Single d = 0.00390625f;

        this._vertices.Clear();
        this._colors.Clear();
        this._uv.Clear();
        this._indices.Clear();
        for (Int32 i = 0; i < this.spsPrims.Count; i++)
        {
            WorldSPS.WorldSPSPrim worldSPSPrim = this.spsPrims[i];
            Vector3 b     = new Vector3(0f, 0f, (Single)(this.spsPrims.Count - i) / 100f);
            Int32   count = this._vertices.Count;
            this._vertices.Add(worldSPSPrim.v0 + b);
            this._vertices.Add(worldSPSPrim.v1 + b);
            this._vertices.Add(worldSPSPrim.v2 + b);
            this._vertices.Add(worldSPSPrim.v3 + b);
            this._colors.Add(worldSPSPrim.color);
            this._colors.Add(worldSPSPrim.color);
            this._colors.Add(worldSPSPrim.color);
            this._colors.Add(worldSPSPrim.color);
            this._uv.Add(worldSPSPrim.uv0 * d);
            this._uv.Add(worldSPSPrim.uv1 * d);
            this._uv.Add(worldSPSPrim.uv2 * d);
            this._uv.Add(worldSPSPrim.uv3 * d);
            this._indices.Add(count);
            this._indices.Add(count + 1);
            this._indices.Add(count + 2);
            this._indices.Add(count + 1);
            this._indices.Add(count + 3);
            this._indices.Add(count + 2);
        }
        Mesh mesh = this.meshFilter.mesh;

        mesh.Clear();
        mesh.vertices        = this._vertices.ToArray();
        mesh.colors          = this._colors.ToArray();
        mesh.uv              = this._uv.ToArray();
        mesh.triangles       = this._indices.ToArray();
        this.meshFilter.mesh = mesh;
        WorldSPS.WorldSPSPrim worldSPSPrim2 = this.spsPrims[0];
        PSXTexture            texture       = PSXTextureMgr.GetTexture(worldSPSPrim2.FlagTP, worldSPSPrim2.FlagTY, worldSPSPrim2.FlagTX, worldSPSPrim2.FlagClutY, worldSPSPrim2.FlagClutX);

        if (texture.texture.filterMode != FilterMode.Bilinear)
        {
            texture.SetFilter(FilterMode.Bilinear);
        }
        Int32 num2 = (Int32)((this.arate >= 4) ? 4 : this.arate);

        this.materials[num2].mainTexture = texture.texture;
        this.meshRenderer.material       = this.materials[num2];
    }
Ejemplo n.º 4
0
 protected override void Awake()
 {
     base.Awake();
     this.InitStateSystem();
     this.InitStateSerializer();
     this.InitQuadMistDatabase();
     PSXTextureMgr.InitOnce();
     FF9StateSystem.CheckAndroidTVPlatform();
 }
Ejemplo n.º 5
0
    private Texture GetTexture()
    {
        UInt32 textureKey = SFXKey.GetTextureKey(this.key);

        if (SFXKey.GetTextureMode(this.key) != 2u)
        {
            if (SFX.currentEffectID == 435)
            {
                Single[] array   = new Single[2];
                Texture  texture = PSXTextureMgr.GetTexture435(textureKey, array);
                if (texture != (UnityEngine.Object)null)
                {
                    this.constTexParam.y = array[0];
                    this.constTexParam.w = array[1];
                    return(texture);
                }
            }
            return(PSXTextureMgr.GetTexture(this.key).texture);
        }
        if (SFXKey.IsBlurTexture(textureKey))
        {
            if ((this.key & 536870912u) != 0u)
            {
                this.constTexParam.w = 240f;
            }
            else
            {
                this.constTexParam.y = -240f;
                this.constTexParam.w = -240f;
            }
            this.constTexParam.z = 320f;
            return(PSXTextureMgr.blurTexture);
        }
        if ((this.key & 2031616u) == PSXTextureMgr.bgKey)
        {
            return(PSXTextureMgr.bgTexture);
        }
        if (PSXTextureMgr.isCreateGenTexture)
        {
            this.constTexParam.x = (Single)((UInt64)SFXKey.GetPositionX(this.key) - (UInt64)((Int64)PSXTextureMgr.GEN_TEXTURE_X)) + 0.5f;
            this.constTexParam.z = (Single)PSXTextureMgr.GEN_TEXTURE_W;
            this.constTexParam.w = (Single)PSXTextureMgr.GEN_TEXTURE_H;
            return(PSXTextureMgr.genTexture);
        }
        if (SFX.currentEffectID == 274 && textureKey == 5767167u)
        {
            this.constTexParam.x = 176f;
            this.constTexParam.y = 0f;
            this.constTexParam.z = 480f;
            this.constTexParam.w = 360f;
            return(PSXTextureMgr.blurTexture);
        }
        return(PSXTextureMgr.GetTexture(this.key).texture);
    }
Ejemplo n.º 6
0
 private void Awake()
 {
     Application.targetFrameRate = 15;
     this.effNum               = 0;
     this.strEffNum            = this.effNum.ToString();
     Camera.main.orthographic  = false;
     Camera.main.nearClipPlane = 400f;
     Camera.main.farClipPlane  = 16384f;
     Camera.main.fieldOfView   = 45f;
     PSXTextureMgr.InitOnce();
     SFX.SetCameraPhase(0);
     SFX.StartDebugRoom();
 }
Ejemplo n.º 7
0
 public static void MoveImage(Int32 rx, Int32 ry, Int32 rw, Int32 rh, Int32 x, Int32 y)
 {
     for (Int32 i = 0; i < rh; i++)
     {
         Int32 num  = (i + y << 10) + x;
         Int32 num2 = (i + ry << 10) + rx;
         for (Int32 j = 0; j < rw; j++)
         {
             PSXTextureMgr.originalVram[num] = PSXTextureMgr.originalVram[num2];
             num2++;
             num++;
         }
     }
     PSXTextureMgr.ClearKey(x, y);
 }
Ejemplo n.º 8
0
    public static void Render()
    {
        RenderTexture.active = (RenderTexture)null;
        Camera    camera = Camera.main ? Camera.main : GameObject.Find("Battle Camera").GetComponent <BattleMapCameraController>().GetComponent <Camera>();
        Matrix4x4 worldToCameraMatrix = camera.worldToCameraMatrix;

        PSXTextureMgr.BeginRender();
        PSXTextureMgr.CaptureBG();
        camera.worldToCameraMatrix = Matrix4x4.identity;
        for (Int32 i = 0; i < SFXRender.commandBuffer.Count; i++)
        {
            SFXRender.commandBuffer[i].Render(i);
        }
        SFXMesh.DummyRender();
        camera.worldToCameraMatrix = worldToCameraMatrix;
    }
Ejemplo n.º 9
0
    private Boolean _loadSPSTexture()
    {
        TextAsset textAsset = AssetManager.Load <TextAsset>("FieldMaps/" + this.MapName + "/spt.tcb", false);

        if (textAsset != (UnityEngine.Object)null)
        {
            using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(textAsset.bytes)))
            {
                UInt32 num  = binaryReader.ReadUInt32();
                UInt32 num2 = binaryReader.ReadUInt32();
                Int32  num3 = binaryReader.ReadInt32();
                binaryReader.BaseStream.Seek((Int64)((UInt64)num), SeekOrigin.Begin);
                UInt32 num4 = binaryReader.ReadUInt32();
                Int32  num5 = binaryReader.ReadInt32();
                for (Int32 i = 0; i < num3; i++)
                {
                    binaryReader.BaseStream.Seek((Int64)((UInt64)num2), SeekOrigin.Begin);
                    Int32 x    = (Int32)binaryReader.ReadInt16();
                    Int32 y    = (Int32)binaryReader.ReadInt16();
                    Int32 num6 = (Int32)binaryReader.ReadInt16();
                    Int32 num7 = (Int32)binaryReader.ReadInt16();
                    PSXTextureMgr.LoadImageBin(x, y, num6, num7, binaryReader);
                    UInt32 num8 = (UInt32)(num6 * num7 * 2);
                    num2 += num8 + 8u;
                }
                num += 8u;
                for (Int32 j = 0; j < num5; j++)
                {
                    binaryReader.BaseStream.Seek((Int64)((UInt64)num), SeekOrigin.Begin);
                    Int32 x2    = (Int32)binaryReader.ReadInt16();
                    Int32 y2    = (Int32)binaryReader.ReadInt16();
                    Int32 num9  = (Int32)binaryReader.ReadInt16();
                    Int32 num10 = (Int32)binaryReader.ReadInt16();
                    binaryReader.BaseStream.Seek((Int64)((UInt64)num4), SeekOrigin.Begin);
                    PSXTextureMgr.LoadImageBin(x2, y2, num9, num10, binaryReader);
                    UInt32 num8 = (UInt32)(num9 * num10 * 2);
                    num4 += num8;
                    num  += 8u;
                }
            }
            PSXTextureMgr.ClearObject();
            return(true);
        }
        return(false);
    }
Ejemplo n.º 10
0
    public static void _SaveVRamImage(String filename)
    {
        Color32[] array = new Color32[524288];
        for (Int32 i = 0; i < 524288; i++)
        {
            UInt16 psxPixel = PSXTextureMgr.originalVram[i];
            array[i] = PSXTextureMgr._ConvertABGR16toABGR32(psxPixel);
        }
        Texture2D texture2D = new Texture2D(1024, 512);

        texture2D.SetPixels32(array);
        texture2D.Apply();
        Byte[] bytes = texture2D.EncodeToPNG();
        File.WriteAllBytes(filename + ".png", bytes);
        Byte[] array2 = new Byte[(Int32)PSXTextureMgr.originalVram.Length * 2];
        Buffer.BlockCopy(PSXTextureMgr.originalVram, 0, array2, 0, (Int32)array2.Length);
        File.WriteAllBytes(filename + ".bin", array2);
    }
Ejemplo n.º 11
0
 public unsafe static void LoadImage(Int32 x, Int32 y, Int32 w, Int32 h, UInt16 *p)
 {
     PSXTextureMgr.ClearKey(x, y);
     for (Int32 i = 0; i < h; i++)
     {
         Int32 num = (y + i) * 1024 + x;
         for (Int32 j = 0; j < w; j++)
         {
             PSXTextureMgr.originalVram[num] = *(p++);
             num++;
         }
     }
     if (SFX.isDebugPng)
     {
         PSXTexture psxtexture = new PSXTexture();
         psxtexture.GenTexture(3, 0, 0, 0, 0, 1024, 512, FilterMode.Point, TextureWrapMode.Clamp);
         File.WriteAllBytes("Temp/vram.png", psxtexture.texture.EncodeToPNG());
     }
 }
Ejemplo n.º 12
0
 private void OnRenderImage(RenderTexture src, RenderTexture dest)
 {
     PSXTextureMgr.PostBlur(src, dest);
 }
Ejemplo n.º 13
0
 public override void Render(Int32 index)
 {
     PSXTextureMgr.MoveImage(this.rx, this.ry, this.rw, this.rh, this.x, this.y);
 }
Ejemplo n.º 14
0
    private void _GenerateSPSMesh()
    {
        if (this.spsPrims.Count == 0)
        {
            return;
        }
        Boolean   flag            = false;
        BGCAM_DEF currentBgCamera = this.fieldMap.GetCurrentBgCamera();

        if (currentBgCamera == null)
        {
            return;
        }
        Single    num      = (Single)this.scale / 4096f;
        Matrix4x4 localRTS = Matrix4x4.identity;
        Boolean   flag2    = false;

        if (FF9StateSystem.Common.FF9.fldMapNo == 2929)
        {
            flag = true;
        }
        if (flag)
        {
            if (FF9StateSystem.Common.FF9.fldMapNo == 2929)
            {
                localRTS = Matrix4x4.TRS(this.pos * 0.9925f, Quaternion.Euler(-this.rot.x / 2f, -this.rot.y / 2f, this.rot.z / 2f), new Vector3(num, -num, 1f));
            }
            else
            {
                localRTS = Matrix4x4.TRS(this.pos, Quaternion.Euler(this.rot.x, this.rot.y, this.rot.z), new Vector3(num, -num, 1f));
            }
        }
        else
        {
            Vector3 vector = PSX.CalculateGTE_RTPT_POS(this.pos, Matrix4x4.identity, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset(), true);
            num *= currentBgCamera.GetViewDistance() / vector.z;
            if (vector.z < 0f)
            {
                flag2 = true;
            }
            vector.z /= 4f;
            vector.z += (Single)currentBgCamera.depthOffset;
            base.transform.localPosition = new Vector3(vector.x, vector.y, vector.z + (Single)this.zOffset);
            base.transform.localScale    = new Vector3(num, -num, 1f);
            base.transform.localRotation = Quaternion.Euler(this.rot.x, this.rot.y, -this.rot.z);
        }
        this._vertices.Clear();
        this._colors.Clear();
        this._uv.Clear();
        this._indices.Clear();
        for (Int32 i = 0; i < this.spsPrims.Count; i++)
        {
            if (flag2)
            {
                break;
            }
            FieldSPS.FieldSPSPrim fieldSPSPrim = this.spsPrims[i];
            Int32 count = this._vertices.Count;
            if (flag)
            {
                Vector3 a    = PSX.CalculateGTE_RTPT(fieldSPSPrim.v0, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Vector3 a2   = PSX.CalculateGTE_RTPT(fieldSPSPrim.v1, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Vector3 a3   = PSX.CalculateGTE_RTPT(fieldSPSPrim.v2, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Vector3 a4   = PSX.CalculateGTE_RTPT(fieldSPSPrim.v3, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                Single  num2 = PSX.CalculateGTE_RTPTZ(Vector3.zero, localRTS, currentBgCamera.GetMatrixRT(), currentBgCamera.GetViewDistance(), this.fieldMap.GetProjectionOffset());
                num2 /= 4f;
                num2 += (Single)currentBgCamera.depthOffset;
                Vector3 b = new Vector3(0f, 0f, num2 - (Single)i / 100f);
                this._vertices.Add(a + b);
                this._vertices.Add(a2 + b);
                this._vertices.Add(a3 + b);
                this._vertices.Add(a4 + b);
            }
            else
            {
                Vector3 b2 = new Vector3(0f, 0f, (Single)(this.spsPrims.Count - i) / 100f);
                this._vertices.Add(fieldSPSPrim.v0 + b2);
                this._vertices.Add(fieldSPSPrim.v1 + b2);
                this._vertices.Add(fieldSPSPrim.v2 + b2);
                this._vertices.Add(fieldSPSPrim.v3 + b2);
            }
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._uv.Add((fieldSPSPrim.uv0 + new Vector2(0.5f, 0.5f)) * 0.00390625f);
            this._uv.Add((fieldSPSPrim.uv1 + new Vector2(-0.5f, 0.5f)) * 0.00390625f);
            this._uv.Add((fieldSPSPrim.uv2 + new Vector2(0.5f, -0.5f)) * 0.00390625f);
            this._uv.Add((fieldSPSPrim.uv3 + new Vector2(-0.5f, -0.5f)) * 0.00390625f);
            this._indices.Add(count);
            this._indices.Add(count + 1);
            this._indices.Add(count + 2);
            this._indices.Add(count + 1);
            this._indices.Add(count + 3);
            this._indices.Add(count + 2);
        }
        Mesh mesh = this.meshFilter.mesh;

        mesh.Clear();
        mesh.vertices        = this._vertices.ToArray();
        mesh.colors          = this._colors.ToArray();
        mesh.uv              = this._uv.ToArray();
        mesh.triangles       = this._indices.ToArray();
        this.meshFilter.mesh = mesh;
        FieldSPS.FieldSPSPrim fieldSPSPrim2 = this.spsPrims[0];
        PSXTexture            texture       = PSXTextureMgr.GetTexture(fieldSPSPrim2.FlagTP, fieldSPSPrim2.FlagTY, fieldSPSPrim2.FlagTX, fieldSPSPrim2.FlagClutY, fieldSPSPrim2.FlagClutX);

        texture.SetFilter(FilterMode.Bilinear);
        Int32 num3 = (Int32)((this.arate >= 4) ? 4 : this.arate);

        this.materials[num3].mainTexture = texture.texture;
        this.meshRenderer.material       = this.materials[num3];
        if (this.spsActor != (UnityEngine.Object)null)
        {
            this.spsActor.spsPos = this.pos;
        }
    }
Ejemplo n.º 15
0
    private void _GenerateSPSMesh()
    {
        if (this.spsPrims.Count == 0)
        {
            return;
        }
        Single num = (Single)this.scale / 4096f;

        base.transform.localScale    = new Vector3(-num, -num, num);
        base.transform.localRotation = Quaternion.Euler(this.rot.x, this.rot.y, this.rot.z);
        base.transform.localPosition = this.pos;
        Camera  camera = Camera.main ? Camera.main : GameObject.Find("Battle Camera").GetComponent <BattleMapCameraController>().GetComponent <Camera>();
        Vector3 a      = camera.worldToCameraMatrix.inverse.GetColumn(3);
        Single  num2   = Vector3.Distance(a, this.pos);
        Single  num3   = num2 * this.spsScale * BattleSPS.spsK;

        if (num3 > 3f)
        {
            num3 = 3f;
        }
        base.transform.localScale *= num3;
        Matrix4x4 inverse = camera.worldToCameraMatrix.inverse;
        Vector3   vector  = inverse.MultiplyVector(Vector3.forward);
        Vector3   rhs     = inverse.MultiplyVector(Vector3.right);
        Vector3   a2      = Vector3.Cross(vector, rhs);

        base.transform.LookAt(base.transform.position + vector, -a2);
        Single d = 0.00390625f;

        this._vertices.Clear();
        this._colors.Clear();
        this._uv.Clear();
        this._indices.Clear();
        for (Int32 i = 0; i < this.spsPrims.Count; i++)
        {
            BattleSPS.FieldSPSPrim fieldSPSPrim = this.spsPrims[i];
            Vector3 b     = new Vector3(0f, 0f, (Single)(this.spsPrims.Count - i) / 100f);
            Int32   count = this._vertices.Count;
            Vector3 v     = fieldSPSPrim.v0;
            Vector3 v2    = fieldSPSPrim.v1;
            Vector3 v3    = fieldSPSPrim.v2;
            Vector3 v4    = fieldSPSPrim.v3;
            this._vertices.Add(v + b);
            this._vertices.Add(v2 + b);
            this._vertices.Add(v3 + b);
            this._vertices.Add(v4 + b);
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._colors.Add(fieldSPSPrim.color);
            this._uv.Add(fieldSPSPrim.uv0 * d);
            this._uv.Add(fieldSPSPrim.uv1 * d);
            this._uv.Add(fieldSPSPrim.uv2 * d);
            this._uv.Add(fieldSPSPrim.uv3 * d);
            this._indices.Add(count);
            this._indices.Add(count + 1);
            this._indices.Add(count + 2);
            this._indices.Add(count + 1);
            this._indices.Add(count + 3);
            this._indices.Add(count + 2);
        }
        Mesh mesh = this.meshFilter.mesh;

        mesh.Clear();
        mesh.vertices        = this._vertices.ToArray();
        mesh.colors          = this._colors.ToArray();
        mesh.uv              = this._uv.ToArray();
        mesh.triangles       = this._indices.ToArray();
        this.meshFilter.mesh = mesh;
        BattleSPS.FieldSPSPrim fieldSPSPrim2 = this.spsPrims[0];
        PSXTexture             texture       = PSXTextureMgr.GetTexture(fieldSPSPrim2.FlagTP, fieldSPSPrim2.FlagTY, fieldSPSPrim2.FlagTX, fieldSPSPrim2.FlagClutY, fieldSPSPrim2.FlagClutX);

        texture.SetFilter(FilterMode.Bilinear);
        Int32 num4 = (Int32)((this.arate >= 4) ? 4 : this.arate);

        this.materials[num4].mainTexture = BattleSPSSystem.statusTextures[this.refNo].textures[0];
        this.meshRenderer.material       = this.materials[num4];
        if (this.spsActor != (UnityEngine.Object)null)
        {
            this.spsActor.spsPos = this.pos;
        }
    }