示例#1
0
        public static List <GBI.F3DCommand> getF3DCommandsFromLines(string[] lines)
        {
            List <GBI.F3DCommand> F3DCommands = new List <GBI.F3DCommand>();

            foreach (string line in lines)
            {
                string[] vs = MISCUtils.ParseAsmbd(line);
                foreach (string command in Enum.GetNames(typeof(GBI.GBICommand)))
                {
                    if (vs[0] == command)
                    {
                        F3DCommands.Add(new GBI.F3DCommand((GBI.GBICommand)Enum.Parse(typeof(GBI.GBICommand), command), getParamsFromStringArray(vs, 1)));
                    }
                }
            }
            return(F3DCommands);
        }
示例#2
0
        public static int getIndexFromLineData(uint line, string[] lineData)
        {
            int index = 0;
            int n     = 0;

            foreach (string lineElem in lineData)
            {
                if (n >= line)
                {
                    break;
                }
                string[] vs = MISCUtils.ParseAsmbd(lineElem);
                foreach (string command in Enum.GetNames(typeof(GBI.GBICommand)))
                {
                    if (vs[0] == command)
                    {
                        index++;
                    }
                }
                n++;
            }
            return(index);
        }
示例#3
0
        public void initF3D()
        {
            int n = -1;

            foreach (string line in dldata)
            {
                n++;
                if (!(line.Contains("gsSP") || line.Contains("gsDP")))
                {
                    continue;
                }
                vals = MISCUtils.ParseAsmbd(line);
                if (vals[0] == "gsSPVertex")
                {
                    List <Vtx> verteces = new List <Vtx>();
                    Vtx        twvtx    = new Vtx();
                    VtxLUT     vl       = new VtxLUT();
                    int[]      vert     = new int[9];
                    string[]   cs       = new string[0];
                    vl.vtxSubData.label       = LakiTool.LUT.Utils.LabelUtil.findLabelFromName(vals[1], curFile);
                    vl.vtxSubData.gData.GFile = curFile;
                    vl.vtxSubData.gData.GLine = (uint)n + 1;
                    uint l = vl.vtxSubData.label.labelLine;
                    while (true)
                    {
                        if (dldata[l].Length < 6 || dldata[l][0] != 'v')
                        {
                            break;
                        }
                        l++;
                        cs = MISCUtils.ParseAsmbd(dldata[l - 1]);
                        for (int v = 0; v < vert.Length; v++)
                        {
                            string c = cs[v + 1];
                            vert[v] = MISCUtils.ParseInt(c);
                        }
                        twvtx.X = (short)vert[0];
                        twvtx.Y = (short)vert[1];
                        twvtx.Z = (short)vert[2];
                        twvtx.S = (short)vert[3];
                        twvtx.T = (short)vert[4];
                        twvtx.R = (byte)vert[5];
                        twvtx.G = (byte)vert[6];
                        twvtx.B = (byte)vert[7];
                        twvtx.A = (byte)vert[8];
                        verteces.Add(twvtx);
                    }
                    vl.vtces = verteces;
                    luts.vtxLUT.Add(vl);
                }
                if (vals[0] == "gsSPLight")
                {
                    LightLUT ll = new LightLUT();
                    ll.lightSubData.label       = LakiTool.LUT.Utils.LabelUtil.findLabelFromName(vals[1], curFile);
                    ll.lightSubData.gData.GFile = curFile;
                    ll.lightSubData.gData.GLine = (uint)n + 1;
                    float[] light = new float[4];
                    for (int v = 0; v < light.Length; v++)
                    {
                        string c = MISCUtils.ParseAsmbd(dldata[ll.lightSubData.label.labelLine])[v + 1];
                        light[v] = (float)MISCUtils.ParseInt(c) / 255f;
                    }
                    ll.col          = light;
                    ll.type         = (uint)MISCUtils.ParseInt(vals[2]);
                    ll.rawLightData = dldata[ll.lightSubData.label.labelLine];
                    luts.lightLUT.Add(ll);
                }
                if (vals[0] == "gsDPSetTextureImage")
                {
                    TexLUT tl = new TexLUT();
                    tl.texSubData.label       = LakiTool.LUT.Utils.LabelUtil.findLabelFromName(vals[4], curFile, fbpath, true);
                    tl.texSubData.gData.GFile = curFile;
                    tl.texSubData.gData.GLine = (uint)n + 1;
                    tl.incbinFile             = MISCUtils.ParseAsmbd(File.ReadAllLines(tl.texSubData.label.labelFile)[tl.texSubData.label.labelLine])[1].Replace("\"", "");
                    if (tl.texSubData.label.labelFound)
                    {
                        string tp = fbpath + "/" + tl.incbinFile;
                        if (File.Exists(tp + ".png"))
                        {
                            tl.texFileName = tp + ".png";
                        }
                        else if (File.Exists(fbpath + "/" + "textures" + tl.incbinFile.Substring(3) + ".png"))
                        {
                            tl.texFileName = fbpath + "/" + "textures" + tl.incbinFile.Substring(3) + ".png";
                        }
                    }
                    else
                    {
                        tl.texFileName = "placeholder.png";
                    }
                    tl.tex = (Bitmap)Bitmap.FromFile(tl.texFileName);
                    luts.texLUT.Add(tl);
                }
            }
        }
示例#4
0
        public void ParseDL(int offset, GBI GBIc, LUTs LUTc)
        {
            int n = -1;

            foreach (string line in dldata)
            {
                n++;
                if (n < offset - 1)
                {
                    continue;
                }
                if (!(line.Contains("gsSP") || line.Contains("gsDP")))
                {
                    continue;
                }
                vals = MISCUtils.ParseAsmbd(line);
                if (vals[0] == "gsSPEndDisplayList" && offset > 0)
                {
                    return;
                }
                if (vals[0] == "gsSP1Triangle")
                {
                    GBIc.gsSP1Triangle(
                        MISCUtils.ParseInt(vals[1]),
                        MISCUtils.ParseInt(vals[2]),
                        MISCUtils.ParseInt(vals[3]),
                        MISCUtils.ParseInt(vals[4])
                        );
                }
                if (vals[0] == "gsSP2Triangles")
                {
                    GBIc.gsSP2Triangles(
                        MISCUtils.ParseInt(vals[1]),
                        MISCUtils.ParseInt(vals[2]),
                        MISCUtils.ParseInt(vals[3]),
                        MISCUtils.ParseInt(vals[4]),
                        MISCUtils.ParseInt(vals[5]),
                        MISCUtils.ParseInt(vals[6]),
                        MISCUtils.ParseInt(vals[7]),
                        MISCUtils.ParseInt(vals[8])
                        );
                }
                if (vals[0] == "gsSPClearGeometryMode")
                {
                    GBIc.gsSPClearGeometryMode(F3DUtils.getGeomModeFromLineData(vals));
                }
                if (vals[0] == "gsSPSetGeometryMode")
                {
                    GBIc.gsSPSetGeometryMode(F3DUtils.getGeomModeFromLineData(vals));
                }
                if (vals[0] == "gsSPVertex")
                {
                    GBIc.gsSPVertex(F3DUtils.getVtxFromName(vals[1], LUTc.vtxLUT).ToArray(), (byte)MISCUtils.ParseInt(vals[2]), (byte)MISCUtils.ParseInt(vals[3]));
                }
                if (vals[0] == "gsSPLight")
                {
                    GBIc.gsSPLight(F3DUtils.getLightFromName(vals[1], LUTc.lightLUT), (byte)MISCUtils.ParseInt(vals[2]));
                }
                if (vals[0] == "gsDPSetEnvColor")
                {
                    GBIc.gsDPSetEnvColor(
                        (byte)MISCUtils.ParseInt(vals[1]),                     //r
                        (byte)MISCUtils.ParseInt(vals[2]),                     //g
                        (byte)MISCUtils.ParseInt(vals[3]),                     //b
                        (byte)MISCUtils.ParseInt(vals[4])                      //a
                        );
                }
                if (vals[0] == "gsDPSetTextureImage")
                {
                    GBIc.gsDPSetTextureImage(F3DUtils.getTexFromName(vals[4], LUTc.texLUT));
                }
                if (vals[0] == "gsDPSetTile")
                {
                    GBIc.gsDPSetTile(F3DUtils.getWarpSTFromLineData(vals));
                }
            }
        }