コード例 #1
0
        public void getMats(Stream fsMdlx, int cnt1, Stream fsMset, int cnt2, uint offMsetRxxx, float tick)
        {
            if (cntPass == 0)
            {
                o1.Init0();
                o1.Init1(ee);
            }
            if (cntPass == 0)
            {
#if UsePressed_eeram
                Szexp.Decode(KHDebug.MSET.eeramx, ee.ram, ee.ram.Length);
#else
                using (FileStream fsi = File.OpenRead(CnfUt.findeeram)) {
                    fsi.Read(ee.ram, 0, 32 * 1024 * 1024);
                }
#endif
            }

            //  tmp1    1abb0b0 64k [out] temp
            //  tmp2    1abb590 64k [in] st1
            //  tmp3    1ac7410 64k [out] temp
            //  tmp4    1acad50 64k [out] (4x4 matrix for mdlx bone calc)
            //  tmp5    1abb6d0 8k  [out] (Sxyz)
            //  tmp6    1abc520 8k  [out] (Rxyz)
            //  tmp7    1abd370 8k  [out] (Txyz)
            //  tmp8    3b1870  64k [out] (4x4 matrix)  size=64*(cnt2-cnt1)
            //  tmp9    3b5eb0  64k [out] (4x4 matrix)  size=64*(cnt2-cnt1)
            //  tmpa    3b6bb0  64k [out] (4x4 matrix)  size=64*(cnt2-cnt1)
            //  tmpb    3b78b0  64k [out] (s.r.t.?)

            uint Sxyz = tmp5;
            uint Rxyz = tmp6;
            uint Txyz = tmp7;

            uint offMdlxRoot = 10 * 1024 * 1024;
            if (cntPass == 0)
            {
                fsMdlx.Read(ee.ram, (int)offMdlxRoot, 5 * 1024 * 1024);

                offMdlx04 = new RelocMdlx(ee.ram, (int)offMdlxRoot, (int)offMdlxRoot, 0x354398, 0, tmp2, 1).Run();
            }

            uint s4 = tmp1; // temp;
            uint s2 = tmp2; // st1;
            uint a1 = s2;

            for (int w = 0; w < 65536; w++)
            {
                ee.ram[w] = 0;
            }
            for (int w = 0; w < 64; w++)
            {
                ee.ram[s2 + w] = 0;
            }

            if (true)
            {
                Array.Copy(BitConverter.GetBytes(offMdlx04), 0, ee.ram, s2 + 0x14, 4);
                Array.Copy(BitConverter.GetBytes(Sxyz), 0, ee.ram, s2 + 0x1C, 4);
                Array.Copy(BitConverter.GetBytes(Rxyz), 0, ee.ram, s2 + 0x20, 4);
                Array.Copy(BitConverter.GetBytes(Txyz), 0, ee.ram, s2 + 0x24, 4);
                Array.Copy(BitConverter.GetBytes(tmp3), 0, ee.ram, s2 + 0x28, 4);
                Array.Copy(BitConverter.GetBytes(tmp4), 0, ee.ram, s2 + 0x2C, 4);
            }

            /*if (true)
             * {
             *  MemoryStream wri = new MemoryStream(ee.ram, true);
             *  wri.Position = s2;
             *  BinaryWriter wr = new BinaryWriter(wri);
             *  uint[] st1al = new uint[] {
             *      0x0       ,0         ,0    ,0,
             *      0x0       ,offMdlx04 ,0x0  ,Sxyz,
             *      Rxyz      ,Txyz      ,tmp3 ,tmp4,
             *      0x0       ,0x0       ,0x0  ,0,
             *  };
             *  foreach (uint ui in st1al) wr.Write(ui);
             * }*/

            uint offMsetRoot = 15 * 1024 * 1024;
            if (cntPass == 0)
            {
                fsMset.Read(ee.ram, (int)offMsetRoot, 17 * 1024 * 1024);
                RelocMset RM = new RelocMset(ee.ram, offMsetRoot, offMsetRoot, new uint[] { 0, 0, tmp8, tmp9, tmpa, tmpb, });
                RM.Run();
            }
            //uint offMset = 0x009E0340 + 0x1D390;
            //uint offMset = offMsetRoot + 0x3370;
            uint offMset = offMsetRoot + offMsetRxxx;


            // s0, s1, s2, s4, a1
            uint s1 = offMset;
            uint a0 = offMset;
            uint s0 = offMset + 0x90;

            ee.VF[0].w = 1;

            // Opt3
            if (true)
            {
                //ee.r0.UD0 = 0U;
                ee.at.UD0 = 0U;
                ee.v0.UD0 = 0U;
                ee.v1.UD0 = 0U;
                ee.a0.UD0 = a0; // mset +0x00
                ee.a1.UD0 = a1; // info tbl
                ee.a2.UD0 = 0U;
                ee.a3.UD0 = 0U;
                ee.t0.UD0 = 0U;
                ee.t1.UD0 = 0U;
                ee.t2.UD0 = 0U;
                ee.t3.UD0 = 0U;
                ee.t4.UD0 = 0U;
                ee.t5.UD0 = 0U;
                ee.t6.UD0 = 0U;
                ee.t7.UD0 = 0U;
                ee.s0.UD0 = 0U; // s0; // mset +0x90
                ee.s1.UD0 = 0U;
                ee.s2.UD0 = 0U;
                ee.s3.UD0 = 0U;
                ee.s4.UD0 = s4; // temp?
                ee.s5.UD0 = 0U;
                ee.s6.UD0 = 0U;
                ee.s7.UD0 = 0U;
                ee.t8.UD0 = 0U;
                ee.t9.UD0 = 0U;
                ee.k0.UD0 = 0U;
                ee.k1.UD0 = 0U;
                ee.gp.UD0 = 0U;
                ee.sp.UD0 = 0x2000000U;
                ee.s8.UD0 = 0U;
                ee.ra.UD0 = 0xFFFFFFFFU;

                ee.pc = 0x128260;
                while (ee.pc != 0xFFFFFFFFU)
                {
                    if (o1.pfns.ContainsKey(ee.pc) || MobRecUt.Rec1(ee.pc, o1.pfns, ee))
                    {
                        o1.pfns[ee.pc]();
                    }
                    else
                    {
                        throw new RecfnnotFound(ee.pc, "rc3");
                    }
                }
            }
            // Opt2
            if (true)
            {
                //ee.r0.UD0 = 0U;
                ee.at.UD0 = 0U;
                ee.v0.UD0 = 0U;
                ee.v1.UD0 = 0U;
                ee.a0.UD0 = a0; // mset +0x00
                ee.a1.UD0 = a1; // info tbl
                ee.a2.UD0 = 0U;
                ee.a3.UD0 = 0U;
                ee.t0.UD0 = 0U;
                ee.t1.UD0 = 0U;
                ee.t2.UD0 = 0U;
                ee.t3.UD0 = 0U;
                ee.t4.UD0 = 0U;
                ee.t5.UD0 = 0U;
                ee.t6.UD0 = 0U;
                ee.t7.UD0 = 0U;
                ee.s0.UD0 = s0; // mset +0x90
                ee.s1.UD0 = s1;
                ee.s2.UD0 = s2;
                ee.s3.UD0 = 0U;
                ee.s4.UD0 = s4; // temp?
                ee.s5.UD0 = 0U;
                ee.s6.UD0 = 0U;
                ee.s7.UD0 = 0U;
                ee.t8.UD0 = 0U;
                ee.t9.UD0 = 0U;
                ee.k0.UD0 = 0U;
                ee.k1.UD0 = 0U;
                ee.gp.UD0 = 0U;
                ee.sp.UD0 = 0x2000000U;
                ee.s8.UD0 = 0U;
                ee.ra.UD0 = 0xFFFFFFFFU;

                ee.fpr[12].f = tick;

                ee.pc = 0x128918;
                while (ee.pc != 0xFFFFFFFFU)
                {
                    if (o1.pfns.ContainsKey(ee.pc) || MobRecUt.Rec1(ee.pc, o1.pfns, ee))
                    {
                        o1.pfns[ee.pc]();
                    }
                    else
                    {
                        throw new RecfnnotFound(ee.pc, "rc2");
                    }
                }
            }
            // Opt1
            if (true)
            {
                ee.at.UD0 = 0U;
                ee.v0.UD0 = 0U;
                ee.v1.UD0 = 0U;
                ee.a0.UD0 = a0; // mset +0x00
                ee.a1.UD0 = a1; // info tbl
                ee.a2.UD0 = 0U;
                ee.a3.UD0 = 0U;
                ee.t0.UD0 = 0U;
                ee.t1.UD0 = 0U;
                ee.t2.UD0 = 0U;
                ee.t3.UD0 = 0U;
                ee.t4.UD0 = 0U;
                ee.t5.UD0 = 0U;
                ee.t6.UD0 = 0U;
                ee.t7.UD0 = 0U;
                ee.s0.UD0 = s0; // mset +0x90
                ee.s1.UD0 = 0U;
                ee.s2.UD0 = 0U;
                ee.s3.UD0 = 0U;
                ee.s4.UD0 = s4; // temp?
                ee.s5.UD0 = 0U;
                ee.s6.UD0 = 0U;
                ee.s7.UD0 = 0U;
                ee.t8.UD0 = 0U;
                ee.t9.UD0 = 0U;
                ee.k0.UD0 = 0U;
                ee.k1.UD0 = 0U;
                ee.gp.UD0 = 0U;
                ee.sp.UD0 = 0x2000000U;
                ee.s8.UD0 = 0U;
                ee.ra.UD0 = 0xFFFFFFFFU;

                ee.pc = 0x129A18;
                while (ee.pc != 0xFFFFFFFFU)
                {
                    if (o1.pfns.ContainsKey(ee.pc) || MobRecUt.Rec1(ee.pc, o1.pfns, ee))
                    {
                        o1.pfns[ee.pc]();
                    }
                    else
                    {
                        throw new RecfnnotFound(ee.pc, "rc1");
                    }
                }
            }

            //using (FileStream os = new FileStream(@"D:\Desktop\testMine.bin",FileMode.OpenOrCreate))
            using (MemoryStream os = new MemoryStream())
            {
                os.Write(ee.ram, (int)tmp4, 0x40 * cnt1);
                os.Position = 0;
                using (BinaryReader br = new BinaryReader(os))
                {
                    for (int i = 0; i < cnt1; i++)
                    {
                        //Matrix M1 = new Matrix();
                        MatrixBuffer[i].M11 = br.ReadSingle(); MatrixBuffer[i].M12 = br.ReadSingle(); MatrixBuffer[i].M13 = br.ReadSingle(); MatrixBuffer[i].M14 = br.ReadSingle();
                        MatrixBuffer[i].M21 = br.ReadSingle(); MatrixBuffer[i].M22 = br.ReadSingle(); MatrixBuffer[i].M23 = br.ReadSingle(); MatrixBuffer[i].M24 = br.ReadSingle();
                        MatrixBuffer[i].M31 = br.ReadSingle(); MatrixBuffer[i].M32 = br.ReadSingle(); MatrixBuffer[i].M33 = br.ReadSingle(); MatrixBuffer[i].M34 = br.ReadSingle();
                        MatrixBuffer[i].M41 = br.ReadSingle(); MatrixBuffer[i].M42 = br.ReadSingle(); MatrixBuffer[i].M43 = br.ReadSingle(); MatrixBuffer[i].M44 = br.ReadSingle();
                        //matBuff[i] = M1;
                    }
                }
            }

            cntPass++;
        }
コード例 #2
0
        public void Permit_DEB(Stream fsMdlx, int cnt1, Stream fsMset, int cnt2, uint offMsetRxxx, float tick, out float[] Svec, out float[] Rvec, out float[] Tvec)
        {
            if (cntPass == 0)
            {
                o1.Init0();
                o1.Init1(ee);
            }
            if (cntPass == 0)
            {
#if UsePressed_eeram
                Szexp.Decode(KHDebug.MSET.eeramx, ee.ram, ee.ram.Length);
#else
                using (FileStream fsi = File.OpenRead(CnfUt.findeeram)) {
                    fsi.Read(ee.ram, 0, 32 * 1024 * 1024);
                }
#endif
            }

            uint tmp1 = (32 * 1024 * 1024) - (768) - (65536);
            uint tmp2 = (32 * 1024 * 1024) - (768) - (65536) - (65536);
            uint tmp3 = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536);
            uint tmp4 = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536);
            uint tmp5 = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536) - (16 * 512);
            uint tmp6 = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536) - (16 * 512) - (16 * 512);
            uint tmp7 = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536) - (16 * 512) - (16 * 512) - (16 * 512);
            uint tmp8 = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536) - (16 * 512) - (16 * 512) - (16 * 512) - (65536);
            uint tmp9 = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536) - (16 * 512) - (16 * 512) - (16 * 512) - (65536) - (65536);
            uint tmpa = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536) - (16 * 512) - (16 * 512) - (16 * 512) - (65536) - (65536) - (65536);
            uint tmpb = (32 * 1024 * 1024) - (768) - (65536) - (65536) - (65536) - (65536) - (16 * 512) - (16 * 512) - (16 * 512) - (65536) - (65536) - (65536) - (65536);
            //  tmp1    1abb0b0 64k [out] temp
            //  tmp2    1abb590 64k [in] st1
            //  tmp3    1ac7410 64k [out] temp
            //  tmp4    1acad50 64k [out] (4x4 matrix for mdlx bone calc)
            //  tmp5    1abb6d0 8k  [out] (Sxyz)
            //  tmp6    1abc520 8k  [out] (Rxyz)
            //  tmp7    1abd370 8k  [out] (Txyz)
            //  tmp8    3b1870  64k [out] (4x4 matrix)  size=64*(cnt2-cnt1)
            //  tmp9    3b5eb0  64k [out] (4x4 matrix)  size=64*(cnt2-cnt1)
            //  tmpa    3b6bb0  64k [out] (4x4 matrix)  size=64*(cnt2-cnt1)
            //  tmpb    3b78b0  64k [out] (s.r.t.?)

            uint Sxyz = tmp5;
            uint Rxyz = tmp6;
            uint Txyz = tmp7;

            uint offMdlxRoot = 20 * 1024 * 1024;
            if (cntPass == 0)
            {
                fsMdlx.Read(ee.ram, (int)offMdlxRoot, 5 * 1024 * 1024);

                offMdlx04 = new RelocMdlx(ee.ram, (int)offMdlxRoot, (int)offMdlxRoot, 0x354398, 0, tmp2, 1).Run();
            }

            uint s4 = tmp1; // temp;
            uint s2 = tmp2; // st1;
            uint a1 = s2;

            for (int w = 0; w < 65536; w++)
            {
                ee.ram[w] = 0;
            }

            if (true)
            {
                MemoryStream wri = new MemoryStream(ee.ram, true)
                {
                    Position = s2
                };
                BinaryWriter wr    = new BinaryWriter(wri);
                uint[]       st1al = new uint[] {
                    0x0, 0, 0, 0,
                    0x0, offMdlx04, 0x0, Sxyz,
                    Rxyz, Txyz, tmp3, tmp4,
                    0x0, 0x0, 0x0, 0,
                };
                foreach (uint ui in st1al)
                {
                    wr.Write(ui);
                }
            }

            uint offMsetRoot = 25 * 1024 * 1024;
            if (cntPass == 0)
            {
                fsMset.Read(ee.ram, (int)offMsetRoot, 5 * 1024 * 1024);

                RelocMset RM = new RelocMset(ee.ram, offMsetRoot, offMsetRoot, new uint[] { 0, 0, tmp8, tmp9, tmpa, tmpb, });
                RM.Run();
            }

            //uint offMset = 0x009E0340 + 0x1D390;
            //uint offMset = offMsetRoot + 0x3370;
            uint offMset = offMsetRoot + offMsetRxxx;

            // s0, s1, s2, s4, a1
            uint s1 = offMset;
            uint a0 = offMset;
            uint s0 = offMset + 0x90;

            ee.VF[0].w = 1;

            // Opt3
            if (true)
            {
                //ee.r0.UD0 = 0U;
                ee.at.UD0 = 0U;
                ee.v0.UD0 = 0U;
                ee.v1.UD0 = 0U;
                ee.a0.UD0 = a0; // mset +0x00
                ee.a1.UD0 = a1; // info tbl
                ee.a2.UD0 = 0U;
                ee.a3.UD0 = 0U;
                ee.t0.UD0 = 0U;
                ee.t1.UD0 = 0U;
                ee.t2.UD0 = 0U;
                ee.t3.UD0 = 0U;
                ee.t4.UD0 = 0U;
                ee.t5.UD0 = 0U;
                ee.t6.UD0 = 0U;
                ee.t7.UD0 = 0U;
                ee.s0.UD0 = 0U; // s0; // mset +0x90
                ee.s1.UD0 = 0U;
                ee.s2.UD0 = 0U;
                ee.s3.UD0 = 0U;
                ee.s4.UD0 = s4; // temp?
                ee.s5.UD0 = 0U;
                ee.s6.UD0 = 0U;
                ee.s7.UD0 = 0U;
                ee.t8.UD0 = 0U;
                ee.t9.UD0 = 0U;
                ee.k0.UD0 = 0U;
                ee.k1.UD0 = 0U;
                ee.gp.UD0 = 0U;
                ee.sp.UD0 = 0x2000000U;
                ee.s8.UD0 = 0U;
                ee.ra.UD0 = 0xFFFFFFFFU;

                ee.pc = 0x128260;
                while (ee.pc != 0xFFFFFFFFU)
                {
                    if (o1.pfns.ContainsKey(ee.pc) || MobRecUt.Rec1(ee.pc, o1.pfns, ee))
                    {
                        o1.pfns[ee.pc]();
                    }
                    else
                    {
                        throw new RecfnnotFound(ee.pc, "rc3");
                    }
                }
            }
            // Opt2
            if (true)
            {
                //ee.r0.UD0 = 0U;
                ee.at.UD0 = 0U;
                ee.v0.UD0 = 0U;
                ee.v1.UD0 = 0U;
                ee.a0.UD0 = a0; // mset +0x00
                ee.a1.UD0 = a1; // info tbl
                ee.a2.UD0 = 0U;
                ee.a3.UD0 = 0U;
                ee.t0.UD0 = 0U;
                ee.t1.UD0 = 0U;
                ee.t2.UD0 = 0U;
                ee.t3.UD0 = 0U;
                ee.t4.UD0 = 0U;
                ee.t5.UD0 = 0U;
                ee.t6.UD0 = 0U;
                ee.t7.UD0 = 0U;
                ee.s0.UD0 = s0; // mset +0x90
                ee.s1.UD0 = s1;
                ee.s2.UD0 = s2;
                ee.s3.UD0 = 0U;
                ee.s4.UD0 = s4; // temp?
                ee.s5.UD0 = 0U;
                ee.s6.UD0 = 0U;
                ee.s7.UD0 = 0U;
                ee.t8.UD0 = 0U;
                ee.t9.UD0 = 0U;
                ee.k0.UD0 = 0U;
                ee.k1.UD0 = 0U;
                ee.gp.UD0 = 0U;
                ee.sp.UD0 = 0x2000000U;
                ee.s8.UD0 = 0U;
                ee.ra.UD0 = 0xFFFFFFFFU;

                ee.fpr[12].f = tick;

                ee.pc = 0x128918;
                while (ee.pc != 0xFFFFFFFFU)
                {
                    if (o1.pfns.ContainsKey(ee.pc) || MobRecUt.Rec1(ee.pc, o1.pfns, ee))
                    {
                        o1.pfns[ee.pc]();
                    }
                    else
                    {
                        throw new RecfnnotFound(ee.pc, "rc2");
                    }
                }
            }
            // Opt1
            if (false)
            {
                ee.at.UD0 = 0U;
                ee.v0.UD0 = 0U;
                ee.v1.UD0 = 0U;
                ee.a0.UD0 = a0; // mset +0x00
                ee.a1.UD0 = a1; // info tbl
                ee.a2.UD0 = 0U;
                ee.a3.UD0 = 0U;
                ee.t0.UD0 = 0U;
                ee.t1.UD0 = 0U;
                ee.t2.UD0 = 0U;
                ee.t3.UD0 = 0U;
                ee.t4.UD0 = 0U;
                ee.t5.UD0 = 0U;
                ee.t6.UD0 = 0U;
                ee.t7.UD0 = 0U;
                ee.s0.UD0 = s0; // mset +0x90
                ee.s1.UD0 = 0U;
                ee.s2.UD0 = 0U;
                ee.s3.UD0 = 0U;
                ee.s4.UD0 = s4; // temp?
                ee.s5.UD0 = 0U;
                ee.s6.UD0 = 0U;
                ee.s7.UD0 = 0U;
                ee.t8.UD0 = 0U;
                ee.t9.UD0 = 0U;
                ee.k0.UD0 = 0U;
                ee.k1.UD0 = 0U;
                ee.gp.UD0 = 0U;
                ee.sp.UD0 = 0x2000000U;
                ee.s8.UD0 = 0U;
                ee.ra.UD0 = 0xFFFFFFFFU;

                ee.pc = 0x129A18;
                while (ee.pc != 0xFFFFFFFFU)
                {
                    if (o1.pfns.ContainsKey(ee.pc) || MobRecUt.Rec1(ee.pc, o1.pfns, ee))
                    {
                        o1.pfns[ee.pc]();
                    }
                    else
                    {
                        throw new RecfnnotFound(ee.pc, "rc1");
                    }
                }
            }

            {
                MemoryStream si = new MemoryStream(ee.ram, false);
                BinaryReader br = new BinaryReader(si);

                si.Position = Sxyz;
                Svec        = new float[4 * cnt1];
                for (int a = 0; a < 4 * cnt1; a++)
                {
                    Svec[a] = br.ReadSingle();
                }

                si.Position = Rxyz;
                Rvec        = new float[4 * cnt1];
                for (int a = 0; a < 4 * cnt1; a++)
                {
                    Rvec[a] = br.ReadSingle();
                }

                si.Position = Txyz;
                Tvec        = new float[4 * cnt1];
                for (int a = 0; a < 4 * cnt1; a++)
                {
                    Tvec[a] = br.ReadSingle();
                }
            }

            cntPass++;
        }