public CodeLine ReadScript_StepReadByOpcode(ScriptOpcode opcode) { opcodeDict[opcode.opcode_byte] = opcode; CodeLine code = ReadCodeLine(); return(code); }
private string DecompileCode(byte[] line) { if (line.Length == 0) { return(""); } MemoryStream ms = new MemoryStream(line); BinaryReader mbr = new BinaryReader(ms); string retn = ""; byte scr_index = mbr.ReadByte(); if (!decompress_dic.ContainsKey(scr_index)) { throw new Exception("未知的opcode!"); } else { string flag = decompress_dic[scr_index].opcode; int param_num = 0; byte[] param_data = null; if (ScriptVersion == 3) { param_num = mbr.ReadByte(); param_data = mbr.ReadBytes(param_num * 2); } string data = ScriptOpcode.ParamDataToString(decompress_dic[scr_index].ReadFunc(ref mbr)); retn = (data.Length > 0 ? " " : "") + data; while (ms.Position + 1 < ms.Length) { retn += " [" + ScriptUtil.Byte2Hex(BitConverter.GetBytes(mbr.ReadUInt16())) + "]"; } if (ms.Position < ms.Length) { retn += " [" + ScriptUtil.Byte2Hex(mbr.ReadByte()) + "]"; } if (ScriptVersion == 2) { //len = flag2 * 2 retn = flag + retn; } else if (ScriptVersion == 3) { param_num = param_data.Length / 2 < param_num ? param_data.Length / 2 : param_num; string tmp = "("; for (int i = 0; i < param_num; i++) { tmp += BitConverter.ToUInt16(param_data, i * 2).ToString(); if (i != param_num - 1) { tmp += ","; } } tmp += ")"; retn = flag + tmp + retn; } } if (retn != " " && retn != "" && Program.debug) { Console.WriteLine(retn); } mbr.Close(); ms.Close(); return(retn); }