示例#1
0
        } // return_6

        //=========== Stack Manipulation ===========//
        private string Decompile_0A(MSCCommand cmd)
        {
            if (cmd.Returns)
            {
                return($"0x{cmd.Parameters[0]:X}");
            }
            else
            {
                return(cmd.ToString());
            }
        } // pushInt
示例#2
0
        public string Decompile(MSCScript script)
        {
            var analyzer = new MSCAnalyzer(script);

            analyzer.Analyze_1();
            Target  = script;
            Manager = new MSCCommandManager(Target);
            StringBuilder sb = new StringBuilder();

            while (!Manager.End)
            {
                MSCCommand cmd = Manager.Next();

                // Do ending brackets
                while (INDENT_STACK.Contains(cmd.FileOffset - 0x30))
                {
                    INDENT_STACK.Remove(cmd.FileOffset - 0x30);
                    foreach (int off in INDENT_STACK)
                    {
                        sb.Append("   ");
                    }

                    sb.Append("}\n");
                }

                // If the command is passed to the next add it to the assignment stack
                if (Manager.Position != script.Count &&
                    cmd.Ident == 0x0A && Manager.PeekNext().Ident == 0x36)
                {
                    sb.Append(DoIndent(cmd.ToString()) + "\n");
                    continue;
                }
                else if (cmd.Returns)
                {
                    COMMANDS.Push(cmd);
                    continue;
                }

                sb.Append(DecompileCMD(cmd) /*.TrimEnd() + $" \t// 0x{cmd.FileOffset - 0x30:X}*/ + "\n");
            }
            return(sb.ToString());
        }
示例#3
0
        private string DecompileCMD(MSCCommand cmd)
        {
            var sb = new StringBuilder();

            // Do current indent
            if (!cmd.Returns)
            {
                foreach (int i in INDENT_STACK)
                {
                    sb.Append("   ");
                }
            }

            switch (cmd.Ident)
            {
            case 0x06:
                sb.Append(Decompile_06(cmd));
                break;

            case 0x0A:
                sb.Append(Decompile_0A(cmd));
                break;

            case 0x0B:
                sb.Append(Decompile_0B(cmd));
                break;

            case 0x0D:
                sb.Append(Decompile_0D(cmd));
                break;

            case 0x13:
                sb.Append(Decompile_13(cmd));
                break;

            case 0x1C:
                sb.Append(Decompile_1C(cmd));
                break;

            case 0x26:
                sb.Append(Decompile_26(cmd));
                break;

            case 0x27:
                sb.Append(Decompile_27(cmd));
                break;

            case 0x28:
                sb.Append(Decompile_28(cmd));
                break;

            case 0x29:
                sb.Append(Decompile_29(cmd));
                break;

            case 0x2A:
                sb.Append(Decompile_2A(cmd));
                break;

            case 0x2B:
                sb.Append(Decompile_2B(cmd));
                break;

            case 0x2C:
                sb.Append(Decompile_2C(cmd));
                break;

            case 0x2D:
                sb.Append(Decompile_2D(cmd));
                break;

            case 0x2E:
                sb.Append(Decompile_2E(cmd));
                break;

            case 0x2F:
                sb.Append(Decompile_2F(cmd));
                break;

            case 0x31:
                sb.Append(Decompile_31(cmd));
                break;

            case 0x34:
                sb.Append(Decompile_34(cmd));
                break;

            case 0x36:
                sb.Append(Decompile_36(cmd));
                break;

            case 0x41:
                sb.Append(Decompile_41(cmd));
                break;

            default:
                sb.Append(cmd.ToString());
                break;
            }
            return(sb.ToString());
        }