Exemplo n.º 1
0
        public MovesetManager(string mtablePath)
        {
            var directory = Path.GetDirectoryName(mtablePath);

            string[] files = Directory.EnumerateFiles(directory, "*.bin").ToArray();

            if (files.Length == 0)
            {
                return;
            }

            foreach (string file in files)
            {
                var filename = Path.GetFileName(file);

                if (filename == "game.bin")
                {
                    Game   = new ACMDFile(file);
                    Endian = Game.Endian;
                }
                if (filename == "effect.bin")
                {
                    Effect = new ACMDFile(file);
                    Endian = Effect.Endian;
                }
                if (filename == "sound.bin")
                {
                    Sound  = new ACMDFile(file);
                    Endian = Sound.Endian;
                }
                if (filename == "expression.bin")
                {
                    Expression = new ACMDFile(file);
                    Endian     = Expression.Endian;
                }
            }
            if (File.Exists(mtablePath))
            {
                MotionTable = new MTable(mtablePath, Endian);
            }

            ScriptsHashList = new List <uint>();
            if (MotionTable != null)
            {
                ScriptsHashList.AddRange(MotionTable.ToList());
            }
        }
Exemplo n.º 2
0
        private void fitOpen_Click(object sender, EventArgs e)
        {
            if (fsDlg.ShowDialog() == DialogResult.OK)
            {
                this.Reset();
                foreach (var p in Directory.EnumerateFiles(fsDlg.SelectedPath))
                {
                    if (p.EndsWith(".bin"))
                    {
                        var acmd = new ACMDFile(p);
                        ScriptFiles.Add(p, acmd);
                        Runtime.WorkingEndian = acmd.Endian;
                    }
                    else if (p.EndsWith(".mtable"))
                    {
                        MotionTable = new MTable(p, Runtime.WorkingEndian);
                    }
                }
                var acmdnode = new TreeNode("ACMD")
                {
                    Name = "nACMD"
                };

                for (int i = 0; i < MotionTable.Count; i++)
                {
                    var node = new ScriptNode(MotionTable[i], $"{i:X} - [{MotionTable[i]:X8}]");
                    foreach (var keypair in ScriptFiles)
                    {
                        if (keypair.Value.Scripts.Keys.Contains(MotionTable[i]))
                        {
                            node.Scripts.Add(Path.GetFileNameWithoutExtension(keypair.Key), keypair.Value.Scripts[MotionTable[i]]);
                        }
                    }
                    acmdnode.Nodes.Add(node);
                }
                FileTree.Nodes.Add(acmdnode);
                IDEMode    = IDE_MODE.Fighter;
                this.Text += fsDlg.SelectedPath;
            }
        }
Exemplo n.º 3
0
        public void OpenFile(string filepath)
        {
            if (filepath.EndsWith(".bin"))
            {
                DataSource source = new DataSource(FileMap.FromFile(filepath));
                if (*(buint *)source.Address == 0x41434D44) // ACMD
                {
                    if (*(byte *)(source.Address + 0x04) == 0x02)
                    {
                        Runtime.WorkingEndian = Endianness.Little;
                    }
                    else if ((*(byte *)(source.Address + 0x04) == 0x00))
                    {
                        Runtime.WorkingEndian = Endianness.Big;
                    }

                    var f    = new ACMDFile(source);
                    var node = new TreeNode("ACMD");
                    foreach (var keypair in f.Scripts)
                    {
                        node.Nodes.Add(new ScriptNode(keypair.Key, $"{keypair.Key:X8}", keypair.Value));
                    }
                    Runtime.Instance.FileTree.Nodes.Add(node);
                }
            }
            else if (filepath.EndsWith(".mscsb")) // MSC
            {
                var f    = new MSCFile(filepath);
                var node = new TreeNode("MSC");

                for (int i = 0; i < f.Scripts.Count; i++)
                {
                    node.Nodes.Add(new ScriptNode((uint)i, $"{i:X8}", f.Scripts.Values[i]));
                }
                Runtime.Instance.FileTree.Nodes.Add(node);
            }
        }
Exemplo n.º 4
0
        public static void decompile_acmd(string mtable, string motionFolder, string output)
        {
            string script_dir = Path.Combine(output, "animcmd");

            Directory.CreateDirectory(script_dir);

            Console.WriteLine($">\tDecompile ACMD.. -> \"{script_dir}\"");

            Endianness endian = Endianness.Big;
            SortedList <string, ACMDFile> files = new SortedList <string, ACMDFile>();

            Dictionary <uint, string> animations = new Dictionary <uint, string>();

            if (!string.IsNullOrEmpty(motionFolder))
            {
                animations = ParseAnimations(motionFolder);
            }

            //string dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            //if (mtable.Contains(Path.DirectorySeparatorChar))
            //    dir = Path.GetDirectoryName(mtable);
            string dir = Path.GetDirectoryName(mtable);

            foreach (string path in Directory.EnumerateFiles(dir, "*.bin"))
            {
                var file = new ACMDFile(path);
                files.Add(Path.GetFileNameWithoutExtension(path), file);
                endian = file.Endian;
            }
            var table  = new MTable(mtable, endian);
            var hashes = new List <uint>(table.ToList());

            write_mlist(table, animations, Path.Combine(output, "fighter.mlist"));

            // workaround for unlisted moves
            foreach (var f in files)
            {
                foreach (var s in f.Value.Scripts)
                {
                    if (!hashes.Contains(s.Key))
                    {
                        hashes.Add(s.Key);
                    }
                }
            }


            foreach (uint u in hashes)
            {
                string animName = $"0x{u:X8}";
                if (animations.ContainsKey(u))
                {
                    animName = animations[u];
                }

#if DEBUG
                Console.WriteLine($">\tDecompiling {animName}..");
#endif

                ACMDScript game = null, effect = null, sound = null, expression = null;
                if (files.ContainsKey("game") && files["game"].Scripts.ContainsKey(u))
                {
                    game = (ACMDScript)files["game"].Scripts[u];
                }
                if (files.ContainsKey("effect") && files["effect"].Scripts.ContainsKey(u))
                {
                    effect = (ACMDScript)files["effect"].Scripts[u];
                }
                if (files.ContainsKey("sound") && files["sound"].Scripts.ContainsKey(u))
                {
                    sound = (ACMDScript)files["sound"].Scripts[u];
                }
                if (files.ContainsKey("expression") && files["expression"].Scripts.ContainsKey(u))
                {
                    expression = (ACMDScript)files["expression"].Scripts[u];
                }

                write_movedef(game, effect, sound, expression, animName, !table.Contains(u), script_dir);
            }
            Console.WriteLine(">\tFinished\n");
        }
Exemplo n.º 5
0
        private unsafe void fOpen_Click(object sender, EventArgs e)
        {
            if (ofDlg.ShowDialog() == DialogResult.OK)
            {
                this.Reset();
                if (ofDlg.FileName.EndsWith(".bin"))
                {
                    DataSource source = new DataSource(FileMap.FromFile(ofDlg.FileName));
                    if (*(buint *)source.Address == 0x41434D44) // ACMD
                    {
                        if (*(byte *)(source.Address + 0x04) == 0x02)
                        {
                            Runtime.WorkingEndian = Endianness.Little;
                        }
                        else if ((*(byte *)(source.Address + 0x04) == 0x00))
                        {
                            Runtime.WorkingEndian = Endianness.Big;
                        }

                        var f = new ACMDFile(source);
                        ScriptFiles.Add(ofDlg.FileName, f);
                        var node = new TreeNode("ACMD")
                        {
                            Name = "nACMD"
                        };
                        foreach (var keypair in f.Scripts)
                        {
                            node.Nodes.Add(new ScriptNode(keypair.Key, $"{keypair.Key:X8}", keypair.Value));
                        }
                        FileTree.Nodes.Add(node);
                    }
                    else if (*(buint *)source.Address == 0xFFFF0000)
                    {
                        source.Close();
                        ParamFile = new ParamFile(ofDlg.FileName);
                        var node = new TreeNode("PARAMS")
                        {
                            Name = "nPARAMS"
                        };
                        FileTree.Nodes.Add(node);
                        PopulateParams();
                    }
                }
                else if (ofDlg.FileName.EndsWith(".mscsb")) // MSC
                {
                    var f = new MSCFile(ofDlg.FileName);
                    ScriptFiles.Add(ofDlg.FileName, f);

                    var node = new TreeNode("MSC")
                    {
                        Name = "nMSC"
                    };
                    for (int i = 0; i < f.Scripts.Count; i++)
                    {
                        var sn = new ScriptNode((uint)i, $"{i:D8}", f.Scripts.Values[i]);
                        if (((MSCScript)f.Scripts.Values[i]).IsEntrypoint)
                        {
                            sn.Text = "Entrypoint";
                        }
                        else if (i == 0)
                        {
                            sn.Text = "Init";
                        }

                        node.Nodes.Add(sn);
                    }
                    FileTree.Nodes.Add(node);
                }
                IDEMode    = IDE_MODE.File;
                this.Text += ofDlg.FileName;
            }
        }
Exemplo n.º 6
0
 public void AcmdMain(ACMDFile resource)
 {
 }
Exemplo n.º 7
0
        public static void compile_acmd(string mlist, string output)
        {
            ACMDFile game       = new ACMDFile(),
                     effect     = new ACMDFile(),
                     sound      = new ACMDFile(),
                     expression = new ACMDFile();


            Directory.CreateDirectory(output);
            Console.WriteLine($">\tCompiling ACMD.. -> \"{output}\"");

            List <uint> hashes = new List <uint>();

            foreach (var line in File.ReadAllLines(mlist))
            {
                if (line.StartsWith("0x"))
                {
                    hashes.Add(Convert.ToUInt32(line.Substring(2), 16));
                }
                else
                {
                    hashes.Add(Crc32.Compute(line.ToLower()));
                }
            }

            foreach (var path in Directory.EnumerateFiles(Path.Combine(Path.GetDirectoryName(mlist), "animcmd"), "*", SearchOption.AllDirectories))
            {
                var defs = ACMDCompiler.CompileFile(path);
                foreach (var move in defs)
                {
#if DEBUG
                    Console.WriteLine($">\tCompiling {move.AnimName}..");
#endif

                    if (move["Main"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Main"].Cast <ICommand>().ToList();
                        game.Scripts.Add(move.CRC, script);
                    }
                    if (move["Sound"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Sound"].Cast <ICommand>().ToList();
                        sound.Scripts.Add(move.CRC, script);
                    }
                    if (move["Effect"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Effect"].Cast <ICommand>().ToList();
                        effect.Scripts.Add(move.CRC, script);
                    }
                    if (move["Expression"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Expression"].Cast <ICommand>().ToList();
                        expression.Scripts.Add(move.CRC, script);
                    }
                }
            }
            var table = new MTable(hashes, Endian);
            table.Export(Path.Combine(output, "motion.mtable"));
            game.Export(Path.Combine(output, "game.bin"), Endian);
            sound.Export(Path.Combine(output, "sound.bin"), Endian);
            effect.Export(Path.Combine(output, "effect.bin"), Endian);
            expression.Export(Path.Combine(output, "expression.bin"), Endian);
            Console.WriteLine(">\tFinished");
        }