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); sb.Append(DoIndent("}\n")); } // If the command is passed to the next add it to the assignment stack if (cmd.Returns) { COMMANDS.Push(cmd); continue; } sb.Append(DecompileCMD(cmd) + "\n"); } return(sb.ToString()); }
public MSCScript ParseScript(BinaryReader reader, uint offset, int size) { MSCScript script = new MSCScript(Offsets.IndexOf(offset), offset) { File = this }; if (offset == EntryPoint) { script.IsEntrypoint = true; } reader.BaseStream.Seek(offset + HEADER_SIZE, SeekOrigin.Begin); uint ident; while (reader.BaseStream.Position != offset + HEADER_SIZE + size) { ident = reader.ReadByte(); var cmd = new MSCCommand(ident); cmd.FileOffset = (int)reader.BaseStream.Position - 1; for (int i = 0; i < cmd.ParamSpecifiers.Length; i++) { switch (cmd.ParamSpecifiers[i]) { case "B": cmd.Parameters.Add(reader.ReadByte()); break; case "I": cmd.Parameters.Add(reader.ReadBint32()); break; case "H": cmd.Parameters.Add(reader.ReadBint16()); break; } } script.Add(cmd); } return(script); }
public MSCAnalyzer(MSCScript script) { Target = script; _commands = new List <Tuple <int, MSCCommand> >(); Manager = new MSCCommandManager(Target); }
public MSCCommandManager(MSCScript script) { Position = 0; End = false; Script = script; }
public MSCFunction(MSCScript target, params object[] parameters) { TargetScript = target; Parameters = parameters; }