ff7_field_disassembler.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. #include "ff7_field_disassembler.h"
  2. #include "ff7_field_engine.h"
  3. #include "decompiler_engine.h"
  4. #include <boost/format.hpp>
  5. #include "lzs.h"
  6. #include "make_unique.h"
  7. #include <boost/algorithm/string/split.hpp>
  8. #include <boost/algorithm/string.hpp>
  9. #include "ff7_field_codegen.h"
  10. FF7::FF7Disassembler::FF7Disassembler(SUDM::IScriptFormatter& formatter, FF7FieldEngine* engine, InstVec& insts, const std::vector<unsigned char>& rawScriptData)
  11. : SimpleDisassembler(insts),
  12. mEngine(engine),
  13. mFormatter(formatter)
  14. {
  15. mbFromRaw = true;
  16. kSectionPointersSize = 0; // If loading a raw section then we don't have a "sections header" to skip
  17. auto dataCopy = rawScriptData;
  18. mStream = std::make_unique<BinaryReader>(std::move(dataCopy));
  19. ReadHeader();
  20. }
  21. FF7::FF7Disassembler::FF7Disassembler(SUDM::IScriptFormatter& formatter, FF7FieldEngine *engine, InstVec &insts)
  22. : SimpleDisassembler(insts),
  23. mEngine(engine),
  24. mFormatter(formatter)
  25. {
  26. }
  27. FF7::FF7Disassembler::~FF7Disassembler()
  28. {
  29. }
  30. void FF7::FF7Disassembler::ReadHeader()
  31. {
  32. if (!mbFromRaw)
  33. {
  34. // First read the file section pointers
  35. for (int i = 0; i < kNumSections; i++)
  36. {
  37. mSections[i] = mStream->ReadU32();
  38. }
  39. // Now fix up from PSX RAM pointers to simple file offsets
  40. const uint32 basePtr = mSections[0];
  41. for (int i = 0; i < kNumSections; i++)
  42. {
  43. mSections[i] = (mSections[i] - basePtr) + kSectionPointersSize;
  44. }
  45. // Now seek to the script section
  46. mStream->Seek(mSections[eScript]);
  47. }
  48. // Read the script header
  49. mHeader.Read(*mStream);
  50. mScaleFactor = static_cast<float>(mHeader.mScale) / 512.0f;
  51. }
  52. void FF7::FF7Disassembler::open(const char *filename)
  53. {
  54. // Read all of the file, decompress it, then stuff it into a stream
  55. mStream = std::make_unique<BinaryReader>(Lzs::Decompress(BinaryReader::ReadAll(filename)));
  56. ReadHeader();
  57. }
  58. uint32 FF7::FF7Disassembler::GetEndOfScriptOffset(uint16 curEntryPoint, size_t entityIndex, size_t scriptIndex)
  59. {
  60. uint16 nextEntryPoint = curEntryPoint;
  61. do
  62. {
  63. if (scriptIndex + 1 >= 32)
  64. {
  65. if (entityIndex + 1 >= mHeader.mEntityScripts.size())
  66. {
  67. // This is the very last script, so use the end of its data which is the offset to strings
  68. return mHeader.mOffsetToStrings;
  69. }
  70. else
  71. {
  72. // Wrap around to the next entity
  73. entityIndex++;
  74. scriptIndex = 0;
  75. }
  76. }
  77. else
  78. {
  79. // Get the next script in the same entity
  80. scriptIndex++;
  81. }
  82. nextEntryPoint = mHeader.mEntityScripts[entityIndex][scriptIndex];
  83. } while (nextEntryPoint == curEntryPoint);
  84. return nextEntryPoint;
  85. }
  86. std::unique_ptr<Function> FF7::FF7Disassembler::StartFunction(size_t scriptIndex)
  87. {
  88. auto func = std::make_unique<Function>();
  89. func->_retVal = false;
  90. func->_args = 0;
  91. func->_name = "script_" + std::to_string(scriptIndex);
  92. func->mStartAddr = _address;
  93. return func;
  94. }
  95. struct ScriptInfo
  96. {
  97. uint16 mEntryPoint;
  98. uint32 mNextEntryPoint;
  99. size_t mIndex;
  100. };
  101. void FF7::FF7Disassembler::doDisassemble()
  102. {
  103. // Loop through the scripts for each entity
  104. for (size_t entityNumber = 0; entityNumber < mHeader.mEntityScripts.size(); entityNumber++)
  105. {
  106. std::string strOriginalName = mHeader.mFieldEntityNames[entityNumber].data();
  107. if (strOriginalName.empty())
  108. {
  109. // If the entity name was blank in the file then use a consistent generated name
  110. strOriginalName = "entity_" + std::to_string(entityNumber);
  111. }
  112. const std::string entityName = mFormatter.EntityName(strOriginalName);
  113. // Only parse each script one
  114. std::set<uint16> parsedScripts;
  115. std::vector<ScriptInfo> scriptInfo;
  116. // Collect the scripts to parse
  117. for (size_t scriptIndex = 0; scriptIndex < mHeader.mEntityScripts[entityNumber].size(); scriptIndex++)
  118. {
  119. uint16 scriptEntryPoint = mHeader.mEntityScripts[entityNumber][scriptIndex];
  120. if (parsedScripts.find(scriptEntryPoint) != std::end(parsedScripts))
  121. {
  122. // If we've already parsed this scripts entry point, then don't do it again as it means
  123. // two scripts have the same entry which only seems to be true for "empty" scripts
  124. continue;
  125. }
  126. parsedScripts.insert(scriptEntryPoint);
  127. const uint32 nextScriptEntryPoint = GetEndOfScriptOffset(scriptEntryPoint, entityNumber, scriptIndex);
  128. const uint32 scriptSize = nextScriptEntryPoint - scriptEntryPoint;
  129. if (scriptSize > 0)
  130. {
  131. ScriptInfo info = { scriptEntryPoint, nextScriptEntryPoint, scriptIndex };
  132. scriptInfo.push_back(info);
  133. }
  134. }
  135. for (auto it = scriptInfo.begin(); it != scriptInfo.end(); it++)
  136. {
  137. const bool isStart = it == scriptInfo.begin();
  138. const bool isEnd = it == (--scriptInfo.end());
  139. DisassembleIndivdualScript(entityName, entityNumber, it->mIndex, it->mEntryPoint, it->mNextEntryPoint, isStart, isEnd);
  140. }
  141. }
  142. }
  143. static int FindId(uint32 startAddr, uint32 endAddr, const InstVec& insts)
  144. {
  145. for (const InstPtr& instruction : insts)
  146. {
  147. if (instruction->_address >= startAddr && instruction->_address <= endAddr)
  148. {
  149. if (instruction->_opcode == FF7::eOpcodes::opCodeCHAR)
  150. {
  151. return instruction->_params[0]->getSigned();
  152. }
  153. }
  154. }
  155. return -1;
  156. }
  157. void FF7::FF7Disassembler::AddFunc(
  158. std::string entityName, size_t entityIndex, size_t scriptIndex,
  159. uint32 nextScriptEntryPoint, const bool isStart, bool isEnd,
  160. bool toReturnOnly, std::string funcName
  161. ){
  162. const auto kScriptEntryPoint = mStream->Position();
  163. // Read each block of opcodes up to a return
  164. const size_t oldNumInstructions = _insts.size();
  165. auto func = StartFunction(scriptIndex);
  166. if (toReturnOnly)
  167. {
  168. // Read opcodes to the end or bail at the first return
  169. ReadOpCodesToPositionOrReturn(nextScriptEntryPoint + kSectionPointersSize);
  170. auto streamPos = mStream->Position();
  171. const size_t endPos = nextScriptEntryPoint + kSectionPointersSize;
  172. if (streamPos != endPos)
  173. {
  174. // Can't be the end if there is more data
  175. isEnd = false;
  176. }
  177. }
  178. else
  179. {
  180. while (mStream->Position() != nextScriptEntryPoint + kSectionPointersSize)
  181. {
  182. // Keep going till we have all of the script, i.e if we bail at a return then call
  183. // again till we have everything
  184. ReadOpCodesToPositionOrReturn(nextScriptEntryPoint + kSectionPointersSize);
  185. }
  186. }
  187. std::string metaData;
  188. if (isStart && isEnd)
  189. {
  190. metaData = "start_end_";
  191. }
  192. else if (isStart)
  193. {
  194. metaData = "start_";
  195. }
  196. else if (isEnd)
  197. {
  198. metaData = "end_";
  199. }
  200. const size_t newNumInstructions = _insts.size();
  201. func->mNumInstructions = newNumInstructions - oldNumInstructions;
  202. func->mEndAddr = _insts.back()->_address;
  203. if (!funcName.empty())
  204. {
  205. func->_name = funcName;
  206. }
  207. int id = FindId(func->mStartAddr, func->mEndAddr, _insts);
  208. // If there is no ID check if there was an ID for this entity in any of its other functions and use that instead
  209. if (id == -1)
  210. {
  211. for (auto& func : mEngine->_functions)
  212. {
  213. FunctionMetaData metaData(func.second._metadata);
  214. if (metaData.EntityName() == entityName && metaData.CharacterId() != -1)
  215. {
  216. id = metaData.CharacterId();
  217. break;
  218. }
  219. }
  220. }
  221. metaData += std::to_string(id) + "_" + entityName;
  222. func->_metadata = metaData;
  223. mEngine->_functions[kScriptEntryPoint] = *func;
  224. mEngine->AddEntityFunction(entityName, entityIndex, func->_name, scriptIndex);
  225. }
  226. void FF7::FF7Disassembler::DisassembleIndivdualScript(std::string entityName,
  227. size_t entityIndex,
  228. size_t scriptIndex,
  229. size_t scriptEntryPoint,
  230. uint32 nextScriptEntryPoint,
  231. bool isStart,
  232. bool isEnd)
  233. {
  234. scriptEntryPoint += kSectionPointersSize;
  235. mStream->Seek(scriptEntryPoint);
  236. _addressBase = mStream->Position();
  237. _address = _addressBase;
  238. // "Normal" script
  239. if (scriptIndex > 0)
  240. {
  241. if (scriptIndex == 1)
  242. {
  243. AddFunc(entityName, entityIndex, scriptIndex, nextScriptEntryPoint, isStart, isEnd, false, "on_interact");
  244. }
  245. else
  246. {
  247. AddFunc(entityName, entityIndex, scriptIndex, nextScriptEntryPoint, isStart, isEnd, false, "");
  248. }
  249. }
  250. else
  251. {
  252. const size_t endPos = nextScriptEntryPoint + kSectionPointersSize;
  253. // Read the init script, which means stop at the first return
  254. AddFunc(entityName, entityIndex, scriptIndex, nextScriptEntryPoint, isStart, isEnd, true, "on_start");
  255. // TODO: Delete the last return in the "init" function before
  256. // concatenating the main function starting with.
  257. // Not at the end of this script? Then the remaining data is the "main" script
  258. auto streamPos = mStream->Position();
  259. if (streamPos != endPos)
  260. {
  261. // The "main" script can have more than one return statement
  262. AddFunc(entityName, entityIndex, scriptIndex, nextScriptEntryPoint, false, isEnd, false, "on_update");
  263. streamPos = mStream->Position();
  264. // But should end exactly on the end pos
  265. if (streamPos != endPos)
  266. {
  267. throw InternalDecompilerError();
  268. }
  269. }
  270. }
  271. }
  272. const FF7::TInstructRecord kOpcodes[] =
  273. {
  274. // Flow
  275. { 1, FF7::eOpcodes::RET, "RET", "", FF7::FF7ControlFlowInstruction::Create },
  276. { 1, FF7::eOpcodes::REQ, "REQ", "BU", FF7::FF7ControlFlowInstruction::Create },
  277. { 1, FF7::eOpcodes::REQSW, "REQSW", "BU", FF7::FF7ControlFlowInstruction::Create },
  278. { 1, FF7::eOpcodes::REQEW, "REQEW", "BU", FF7::FF7ControlFlowInstruction::Create },
  279. { 1, FF7::eOpcodes::NOP, "NOP", "", FF7::FF7NoOperationInstruction::Create },
  280. { 1, FF7::eOpcodes::IFUB, "IFUB", "NNBBBL", FF7::FF7NoOperationInstruction::Create }
  281. };
  282. std::map<std::string, const FF7::TInstructRecord*> FF7::FieldInstructions()
  283. {
  284. // Convert the array to a map that we can query on by mnemonic
  285. std::map<std::string, const TInstructRecord*> mnemonicToInstructionRecords;
  286. for (size_t i = 0; i < boost::size(kOpcodes); i++)
  287. {
  288. mnemonicToInstructionRecords[kOpcodes[i].mMnemonic] = &kOpcodes[i];
  289. }
  290. return mnemonicToInstructionRecords;
  291. }
  292. void FF7::FF7Disassembler::ReadOpCodesToPositionOrReturn(size_t endPos)
  293. {
  294. /* Need all opcodes in the array before this will work
  295. // Convert the array to a map that we can query on by opcode
  296. std::map<unsigned int, const TInstructRecord*> opcodeToInstructionRecords;
  297. for (size_t i = 0; i < boost::size(kOpcodes); i++)
  298. {
  299. opcodeToInstructionRecords[kOpcodes[i].mOpCode] = &kOpcodes[i];
  300. }
  301. while (mStream->Position() < endPos)
  302. {
  303. // See if the next data is a 1 byte opcode
  304. uint16 opcode = mStream->ReadU8();
  305. auto it = opcodeToInstructionRecords.find(opcode);
  306. _address++;
  307. if (it == std::end(opcodeToInstructionRecords))
  308. {
  309. // No, is it a 2 byte opcode?
  310. opcode = (mStream->ReadU8() << 8) + opcode;
  311. _address++;
  312. it = opcodeToInstructionRecords.find(opcode);
  313. if (it == std::end(opcodeToInstructionRecords))
  314. {
  315. // There are no instructions bigger than 2 bytes, so fail
  316. throw UnknownSubOpcodeException(_address, opcode);
  317. }
  318. }
  319. InstPtr inst = it->second->mFactoryFunc();
  320. inst->_opcode = opcode;
  321. inst->_address = _address;
  322. inst->_stackChange = 0;
  323. inst->_name = it->second->mMnemonic;
  324. readParams(inst, it->second->mArgumentFormat);
  325. _insts.push_back(inst);
  326. }
  327. */
  328. std::vector<unsigned int> exitAddrs;
  329. while (mStream->Position() < endPos)
  330. {
  331. uint8 opcode = mStream->ReadU8();
  332. uint32 full_opcode = 0;
  333. std::string opcodePrefix;
  334. switch (opcode)
  335. {
  336. // Flow
  337. OPCODE(eOpcodes::IFUB, "IFUB", FF7CondJumpInstruction, 0, "NBBBB");
  338. OPCODE(eOpcodes::RET, "RET", FF7ControlFlowInstruction, 0, "");
  339. OPCODE(eOpcodes::REQ, "REQ", FF7ControlFlowInstruction, 0, "BU");
  340. OPCODE(eOpcodes::REQSW, "REQSW", FF7ControlFlowInstruction, 0, "BU");
  341. OPCODE(eOpcodes::REQEW, "REQEW", FF7ControlFlowInstruction, 0, "BU");
  342. OPCODE(eOpcodes::PREQ, "PREQ", FF7ControlFlowInstruction, 0, "BU");
  343. OPCODE(eOpcodes::PRQSW, "PRQSW", FF7ControlFlowInstruction, 0, "BU");
  344. OPCODE(eOpcodes::PRQEW, "PRQEW", FF7ControlFlowInstruction, 0, "BU");
  345. OPCODE(eOpcodes::RETTO, "RETTO", FF7ControlFlowInstruction, 0, "U");
  346. OPCODE(eOpcodes::JMPF, "JMPF", FF7UncondJumpInstruction, 0, "B");
  347. OPCODE(eOpcodes::JMPFL, "JMPFL", FF7UncondJumpInstruction, 0, "w");
  348. OPCODE(eOpcodes::JMPB, "JMPB", FF7UncondJumpInstruction, 0, "B");
  349. OPCODE(eOpcodes::JMPBL, "JMPBL", FF7UncondJumpInstruction, 0, "w");
  350. OPCODE(eOpcodes::IFUBL, "IFUBL", FF7CondJumpInstruction, 0, "NBBBw");
  351. OPCODE(eOpcodes::IFSW, "IFSW", FF7CondJumpInstruction, 0, "NwwBB");
  352. OPCODE(eOpcodes::IFSWL, "IFSWL", FF7CondJumpInstruction, 0, "NwwBw");
  353. OPCODE(eOpcodes::IFUW, "IFUW", FF7CondJumpInstruction, 0, "NwwBB");
  354. OPCODE(eOpcodes::IFUWL, "IFUWL", FF7CondJumpInstruction, 0, "NwwBw");
  355. OPCODE(eOpcodes::WAIT, "WAIT", FF7ControlFlowInstruction, 0, "w");
  356. OPCODE(eOpcodes::IFKEY, "IFKEY", FF7CondJumpInstruction, 0, "wB");
  357. OPCODE(eOpcodes::IFKEYON, "IFKEYON", FF7CondJumpInstruction, 0, "wB");
  358. OPCODE(eOpcodes::IFKEYOFF, "IFKEYOFF", FF7CondJumpInstruction, 0, "wB");
  359. OPCODE(eOpcodes::NOP, "NOP", FF7NoOperationInstruction, 0, "");
  360. OPCODE(eOpcodes::IFPRTYQ, "IFPRTYQ", FF7CondJumpInstruction, 0, "BB");
  361. OPCODE(eOpcodes::IFMEMBQ, "IFMEMBQ", FF7CondJumpInstruction, 0, "BB");
  362. // Module
  363. OPCODE(eOpcodes::DSKCG, "DSKCG", FF7ModuleInstruction, 0, "B");
  364. START_SUBOPCODE(eOpcodes::SPECIAL)
  365. OPCODE(eSpecialOpcodes::ARROW, "ARROW", FF7ModuleInstruction, 0, "B");
  366. OPCODE(eSpecialOpcodes::PNAME, "PNAME", FF7ModuleInstruction, 0, "B");
  367. OPCODE(eSpecialOpcodes::GMSPD, "GMSPD", FF7ModuleInstruction, 0, "B");
  368. OPCODE(eSpecialOpcodes::SMSPD, "SMSPD", FF7ModuleInstruction, 0, "BB");
  369. OPCODE(eSpecialOpcodes::FLMAT, "FLMAT", FF7ModuleInstruction, 0, "");
  370. OPCODE(eSpecialOpcodes::FLITM, "FLITM", FF7ModuleInstruction, 0, "");
  371. OPCODE(eSpecialOpcodes::BTLCK, "BTLCK", FF7ModuleInstruction, 0, "B");
  372. OPCODE(eSpecialOpcodes::MVLCK, "MVLCK", FF7ModuleInstruction, 0, "B");
  373. OPCODE(eSpecialOpcodes::SPCNM, "SPCNM", FF7ModuleInstruction, 0, "BB");
  374. OPCODE(eSpecialOpcodes::RSGLB, "RSGLB", FF7ModuleInstruction, 0, "");
  375. OPCODE(eSpecialOpcodes::CLITM, "CLITM", FF7ModuleInstruction, 0, "");
  376. END_SUBOPCODE
  377. OPCODE(eOpcodes::MINIGAME, "MINIGAME", FF7ModuleInstruction, 0, "wsswBB");
  378. OPCODE(eOpcodes::BTMD2, "BTMD2", FF7ModuleInstruction, 0, "d");
  379. OPCODE(eOpcodes::BTRLD, "BTRLD", FF7ModuleInstruction, 0, "NB");
  380. OPCODE(eOpcodes::BTLTB, "BTLTB", FF7ModuleInstruction, 0, "B");
  381. OPCODE(eOpcodes::MAPJUMP, "MAPJUMP", FF7ModuleInstruction, 0, "wsswB");
  382. OPCODE(eOpcodes::LSTMP, "LSTMP", FF7ModuleInstruction, 0, "NB");
  383. OPCODE(eOpcodes::BATTLE, "BATTLE", FF7ModuleInstruction, 0, "Nw");
  384. OPCODE(eOpcodes::BTLON, "BTLON", FF7ModuleInstruction, 0, "B");
  385. OPCODE(eOpcodes::BTLMD, "BTLMD", FF7ModuleInstruction, 0, "w");
  386. OPCODE(eOpcodes::MPJPO, "MPJPO", FF7ModuleInstruction, 0, "B");
  387. OPCODE(eOpcodes::PMJMP, "PMJMP", FF7ModuleInstruction, 0, "w");
  388. OPCODE(eOpcodes::PMJMP2, "PMJMP2", FF7ModuleInstruction, 0, "");
  389. OPCODE(eOpcodes::GAMEOVER, "GAMEOVER", FF7ModuleInstruction, 0, "");
  390. // Math
  391. OPCODE(eOpcodes::PLUS_, "PLUS!", FF7MathInstruction, 0, "NBB");
  392. OPCODE(eOpcodes::PLUS2_, "PLUS2!", FF7MathInstruction, 0, "NBw");
  393. OPCODE(eOpcodes::MINUS_, "MINUS!", FF7MathInstruction, 0, "NBB");
  394. OPCODE(eOpcodes::MINUS2_, "MINUS2!", FF7MathInstruction, 0, "NBw");
  395. OPCODE(eOpcodes::INC_, "INC!", FF7MathInstruction, 0, "BB");
  396. OPCODE(eOpcodes::INC2_, "INC2!", FF7MathInstruction, 0, "BB");
  397. OPCODE(eOpcodes::DEC_, "DEC!", FF7MathInstruction, 0, "BB");
  398. OPCODE(eOpcodes::DEC2_, "DEC2!", FF7MathInstruction, 0, "BB");
  399. OPCODE(eOpcodes::RDMSD, "RDMSD", FF7MathInstruction, 0, "NB");
  400. OPCODE(eOpcodes::SETBYTE, "SETBYTE", FF7MathInstruction, 0, "NBB");
  401. OPCODE(eOpcodes::SETWORD, "SETWORD", FF7MathInstruction, 0, "NBw");
  402. OPCODE(eOpcodes::BITON, "BITON", FF7MathInstruction, 0, "NBB");
  403. OPCODE(eOpcodes::BITOFF, "BITOFF", FF7MathInstruction, 0, "NBB");
  404. OPCODE(eOpcodes::BITXOR, "BITXOR", FF7MathInstruction, 0, "NBB");
  405. OPCODE(eOpcodes::PLUS, "PLUS", FF7MathInstruction, 0, "NBB");
  406. OPCODE(eOpcodes::PLUS2, "PLUS2", FF7MathInstruction, 0, "NBw");
  407. OPCODE(eOpcodes::MINUS, "MINUS", FF7MathInstruction, 0, "NBB");
  408. OPCODE(eOpcodes::MINUS2, "MINUS2", FF7MathInstruction, 0, "NBw");
  409. OPCODE(eOpcodes::MUL, "MUL", FF7MathInstruction, 0, "NBB");
  410. OPCODE(eOpcodes::MUL2, "MUL2", FF7MathInstruction, 0, "NBw");
  411. OPCODE(eOpcodes::DIV, "DIV", FF7MathInstruction, 0, "NBB");
  412. OPCODE(eOpcodes::DIV2, "DIV2", FF7MathInstruction, 0, "NBw");
  413. OPCODE(eOpcodes::MOD, "MOD", FF7MathInstruction, 0, "NBB");
  414. OPCODE(eOpcodes::MOD2, "MOD2", FF7MathInstruction, 0, "NBw");
  415. OPCODE(eOpcodes::AND, "AND", FF7MathInstruction, 0, "NBB");
  416. OPCODE(eOpcodes::AND2, "AND2", FF7MathInstruction, 0, "NBw");
  417. OPCODE(eOpcodes::OR, "OR", FF7MathInstruction, 0, "NBB");
  418. OPCODE(eOpcodes::OR2, "OR2", FF7MathInstruction, 0, "NBw");
  419. OPCODE(eOpcodes::XOR, "XOR", FF7MathInstruction, 0, "NBB");
  420. OPCODE(eOpcodes::XOR2, "XOR2", FF7MathInstruction, 0, "NBw");
  421. OPCODE(eOpcodes::INC, "INC", FF7MathInstruction, 0, "BB");
  422. OPCODE(eOpcodes::INC2, "INC2", FF7MathInstruction, 0, "BB");
  423. OPCODE(eOpcodes::DEC, "DEC", FF7MathInstruction, 0, "BB");
  424. OPCODE(eOpcodes::DEC2, "DEC2", FF7MathInstruction, 0, "BB");
  425. OPCODE(eOpcodes::RANDOM, "RANDOM", FF7MathInstruction, 0, "BB");
  426. OPCODE(eOpcodes::LBYTE, "LBYTE", FF7MathInstruction, 0, "NBB");
  427. OPCODE(eOpcodes::HBYTE, "HBYTE", FF7MathInstruction, 0, "NBw");
  428. OPCODE(eOpcodes::TWOBYTE, "2BYTE", FF7MathInstruction, 0, "NNBBB");
  429. OPCODE(eOpcodes::SIN, "SIN", FF7MathInstruction, 0, "NNwwwB");
  430. OPCODE(eOpcodes::COS, "COS", FF7MathInstruction, 0, "NNwwwB");
  431. // Window
  432. OPCODE(eOpcodes::TUTOR, "TUTOR", FF7WindowInstruction, 0, "B");
  433. OPCODE(eOpcodes::WCLS, "WCLS", FF7WindowInstruction, 0, "B");
  434. OPCODE(eOpcodes::WSIZW, "WSIZW", FF7WindowInstruction, 0, "Bwwww");
  435. OPCODE(eOpcodes::WSPCL, "WSPCL", FF7WindowInstruction, 0, "BBBB");
  436. OPCODE(eOpcodes::WNUMB, "WNUMB", FF7WindowInstruction, 0, "NBwwB"); // NBdB when N == 0
  437. OPCODE(eOpcodes::STTIM, "STTIM", FF7WindowInstruction, 0, "NNBBB");
  438. OPCODE(eOpcodes::MESSAGE, "MESSAGE", FF7WindowInstruction, 0, "BB");
  439. OPCODE(eOpcodes::MPARA, "MPARA", FF7WindowInstruction, 0, "NBBB");
  440. OPCODE(eOpcodes::MPRA2, "MPRA2", FF7WindowInstruction, 0, "NBBw");
  441. OPCODE(eOpcodes::MPNAM, "MPNAM", FF7WindowInstruction, 0, "B");
  442. OPCODE(eOpcodes::ASK, "ASK", FF7WindowInstruction, 0, "NBBBBB");
  443. OPCODE(eOpcodes::MENU, "MENU", FF7WindowInstruction, 0, "NBB");
  444. OPCODE(eOpcodes::MENU2, "MENU2", FF7WindowInstruction, 0, "B");
  445. OPCODE(eOpcodes::WINDOW, "WINDOW", FF7WindowInstruction, 0, "Bwwww");
  446. OPCODE(eOpcodes::WMOVE, "WMOVE", FF7WindowInstruction, 0, "Bss");
  447. OPCODE(eOpcodes::WMODE, "WMODE", FF7WindowInstruction, 0, "BBB");
  448. OPCODE(eOpcodes::WREST, "WREST", FF7WindowInstruction, 0, "B");
  449. OPCODE(eOpcodes::WCLSE, "WCLSE", FF7WindowInstruction, 0, "B");
  450. OPCODE(eOpcodes::WROW, "WROW", FF7WindowInstruction, 0, "BB");
  451. OPCODE(eOpcodes::GWCOL, "GWCOL", FF7WindowInstruction, 0, "NNBBBB");
  452. OPCODE(eOpcodes::SWCOL, "SWCOL", FF7WindowInstruction, 0, "NNBBBB");
  453. // Party
  454. OPCODE(eOpcodes::SPTYE, "SPTYE", FF7PartyInstruction, 0, "NNBBB");
  455. OPCODE(eOpcodes::GTPYE, "GTPYE", FF7PartyInstruction, 0, "NNBBB");
  456. OPCODE(eOpcodes::GOLDU, "GOLDU", FF7PartyInstruction, 0, "Nww"); // Nd when N == 0
  457. OPCODE(eOpcodes::GOLDD, "GOLDD", FF7PartyInstruction, 0, "Nww"); // Nd when N == 0
  458. OPCODE(eOpcodes::CHGLD, "CHGLD", FF7PartyInstruction, 0, "NBB");
  459. OPCODE(eOpcodes::HMPMAX1, "HMPMAX1", FF7PartyInstruction, 0, "");
  460. OPCODE(eOpcodes::HMPMAX2, "HMPMAX2", FF7PartyInstruction, 0, "");
  461. OPCODE(eOpcodes::MHMMX, "MHMMX", FF7PartyInstruction, 0, "");
  462. OPCODE(eOpcodes::HMPMAX3, "HMPMAX3", FF7PartyInstruction, 0, "");
  463. OPCODE(eOpcodes::MPU, "MPU", FF7PartyInstruction, 0, "NBw");
  464. OPCODE(eOpcodes::MPD, "MPD", FF7PartyInstruction, 0, "NBw");
  465. OPCODE(eOpcodes::HPU, "HPU", FF7PartyInstruction, 0, "NBw");
  466. OPCODE(eOpcodes::HPD, "HPD", FF7PartyInstruction, 0, "NBw");
  467. OPCODE(eOpcodes::STITM, "STITM", FF7PartyInstruction, 0, "NwB");
  468. OPCODE(eOpcodes::DLITM, "DLITM", FF7PartyInstruction, 0, "NwB");
  469. OPCODE(eOpcodes::CKITM, "CKITM", FF7PartyInstruction, 0, "NwB");
  470. OPCODE(eOpcodes::SMTRA, "SMTRA", FF7PartyInstruction, 0, "NNBBBB");
  471. OPCODE(eOpcodes::DMTRA, "DMTRA", FF7PartyInstruction, 0, "NNBBBBB");
  472. OPCODE(eOpcodes::CMTRA, "CMTRA", FF7PartyInstruction, 0, "NNNBBBBBB");
  473. OPCODE(eOpcodes::GETPC, "GETPC", FF7PartyInstruction, 0, "NBB");
  474. OPCODE(eOpcodes::PRTYP, "PRTYP", FF7PartyInstruction, 0, "B");
  475. OPCODE(eOpcodes::PRTYM, "PRTYM", FF7PartyInstruction, 0, "B");
  476. OPCODE(eOpcodes::PRTYE, "PRTYE", FF7PartyInstruction, 0, "BBB");
  477. OPCODE(eOpcodes::MMBUD, "MMBUD", FF7PartyInstruction, 0, "BB");
  478. OPCODE(eOpcodes::MMBLK, "MMBLK", FF7PartyInstruction, 0, "B");
  479. OPCODE(eOpcodes::MMBUK, "MMBUK", FF7PartyInstruction, 0, "B");
  480. // Model
  481. OPCODE(eOpcodes::JOIN, "JOIN", FF7ModelInstruction, 0, "B");
  482. OPCODE(eOpcodes::SPLIT, "SPLIT", FF7ModelInstruction, 0, "NNNssBssBB");
  483. OPCODE(eOpcodes::BLINK, "BLINK", FF7ModelInstruction, 0, "B");
  484. OPCODE_BASE(eOpcodes::KAWAI)
  485. {
  486. int length = this->mStream->ReadU8();
  487. assert(length >= 3);
  488. std::ostringstream paramStream;
  489. for (int i = 3; i < length; ++i)
  490. {
  491. paramStream << "B";
  492. }
  493. auto parameters = paramStream.str();
  494. opcode = this->mStream->ReadU8();
  495. switch (opcode)
  496. {
  497. OPCODE(eKawaiOpcodes::EYETX, "EYETX", FF7ModelInstruction, 0, parameters.c_str()); // was BBBB
  498. OPCODE(eKawaiOpcodes::TRNSP, "TRNSP", FF7ModelInstruction, 0, parameters.c_str()); // was B
  499. OPCODE(eKawaiOpcodes::AMBNT, "AMBNT", FF7ModelInstruction, 0, parameters.c_str()); // was BBBBBBB
  500. OPCODE(eKawaiOpcodes::Unknown03, "Unknown03", FF7ModelInstruction, 0, parameters.c_str());
  501. OPCODE(eKawaiOpcodes::Unknown04, "Unknown04", FF7ModelInstruction, 0, parameters.c_str());
  502. OPCODE(eKawaiOpcodes::Unknown05, "Unknown05", FF7ModelInstruction, 0, parameters.c_str());
  503. OPCODE(eKawaiOpcodes::LIGHT, "LIGHT", FF7ModelInstruction, 0, parameters.c_str());
  504. OPCODE(eKawaiOpcodes::Unknown07, "Unknown07", FF7ModelInstruction, 0, parameters.c_str());
  505. OPCODE(eKawaiOpcodes::Unknown08, "Unknown08", FF7ModelInstruction, 0, parameters.c_str());
  506. OPCODE(eKawaiOpcodes::Unknown09, "Unknown09", FF7ModelInstruction, 0, parameters.c_str());
  507. OPCODE(eKawaiOpcodes::SBOBJ, "SBOBJ", FF7ModelInstruction, 0, parameters.c_str());
  508. OPCODE(eKawaiOpcodes::Unknown0B, "Unknown0B", FF7ModelInstruction, 0, parameters.c_str());
  509. OPCODE(eKawaiOpcodes::Unknown0C, "Unknown0C", FF7ModelInstruction, 0, parameters.c_str());
  510. OPCODE(eKawaiOpcodes::SHINE, "SHINE", FF7ModelInstruction, 0, parameters.c_str());
  511. OPCODE(eKawaiOpcodes::RESET, "RESET", FF7ModelInstruction, 0, parameters.c_str());
  512. default:
  513. throw UnknownSubOpcodeException(this->_address, opcode);
  514. }
  515. INC_ADDR;
  516. INC_ADDR;
  517. }
  518. OPCODE_END
  519. OPCODE(eOpcodes::KAWIW, "KAWIW", FF7ModelInstruction, 0, "");
  520. OPCODE(eOpcodes::PMOVA, "PMOVA", FF7ModelInstruction, 0, "B");
  521. OPCODE(eOpcodes::PDIRA, "PDIRA", FF7ModelInstruction, 0, "B");
  522. OPCODE(eOpcodes::PTURA, "PTURA", FF7ModelInstruction, 0, "BBB");
  523. OPCODE(eOpcodes::PGTDR, "PGTDR", FF7ModelInstruction, 0, "NBB");
  524. OPCODE(eOpcodes::PXYZI, "PXYZI", FF7ModelInstruction, 0, "NNBBBBB");
  525. OPCODE(eOpcodes::TLKON, "TLKON", FF7ModelInstruction, 0, "B");
  526. OPCODE(eOpcodes::PC, "PC", FF7ModelInstruction, 0, "B");
  527. OPCODE(eOpcodes::opCodeCHAR, "CHAR", FF7ModelInstruction, 0, "B");
  528. OPCODE(eOpcodes::DFANM, "DFANM", FF7ModelInstruction, 0, "BB");
  529. OPCODE(eOpcodes::ANIME1, "ANIME1", FF7ModelInstruction, 0, "BB");
  530. OPCODE(eOpcodes::VISI, "VISI", FF7ModelInstruction, 0, "B");
  531. OPCODE(eOpcodes::XYZI, "XYZI", FF7ModelInstruction, 0, "NNsssw");
  532. OPCODE(eOpcodes::XYI, "XYI", FF7ModelInstruction, 0, "NNssw");
  533. OPCODE(eOpcodes::XYZ, "XYZ", FF7ModelInstruction, 0, "NNsss");
  534. OPCODE(eOpcodes::MOVE, "MOVE", FF7ModelInstruction, 0, "Nss");
  535. OPCODE(eOpcodes::CMOVE, "CMOVE", FF7ModelInstruction, 0, "Nss");
  536. OPCODE(eOpcodes::MOVA, "MOVA", FF7ModelInstruction, 0, "B");
  537. OPCODE(eOpcodes::TURA, "TURA", FF7ModelInstruction, 0, "BBB");
  538. OPCODE(eOpcodes::ANIMW, "ANIMW", FF7ModelInstruction, 0, "");
  539. OPCODE(eOpcodes::FMOVE, "FMOVE", FF7ModelInstruction, 0, "Nss");
  540. OPCODE(eOpcodes::ANIME2, "ANIME2", FF7ModelInstruction, 0, "BB");
  541. OPCODE(eOpcodes::ANIM_1, "ANIM!1", FF7ModelInstruction, 0, "BB");
  542. OPCODE(eOpcodes::CANIM1, "CANIM1", FF7ModelInstruction, 0, "BBBB");
  543. OPCODE(eOpcodes::CANM_1, "CANM!1", FF7ModelInstruction, 0, "BBBB");
  544. OPCODE(eOpcodes::MSPED, "MSPED", FF7ModelInstruction, 0, "Nw");
  545. OPCODE(eOpcodes::DIR, "DIR", FF7ModelInstruction, 0, "BB");
  546. OPCODE(eOpcodes::TURNGEN, "TURNGEN", FF7ModelInstruction, 0, "NBBBB");
  547. OPCODE(eOpcodes::TURN, "TURN", FF7ModelInstruction, 0, "NBBBB");
  548. OPCODE(eOpcodes::DIRA, "DIRA", FF7ModelInstruction, 0, "B");
  549. OPCODE(eOpcodes::GETDIR, "GETDIR", FF7ModelInstruction, 0, "NBB");
  550. OPCODE(eOpcodes::GETAXY, "GETAXY", FF7ModelInstruction, 0, "NBBB");
  551. OPCODE(eOpcodes::GETAI, "GETAI", FF7ModelInstruction, 0, "NBB");
  552. OPCODE(eOpcodes::ANIM_2, "ANIM!2", FF7ModelInstruction, 0, "BB");
  553. OPCODE(eOpcodes::CANIM2, "CANIM2", FF7ModelInstruction, 0, "BBBB");
  554. OPCODE(eOpcodes::CANM_2, "CANM!2", FF7ModelInstruction, 0, "BBBB");
  555. OPCODE(eOpcodes::ASPED, "ASPED", FF7ModelInstruction, 0, "Nw");
  556. OPCODE(eOpcodes::CC, "CC", FF7ModelInstruction, 0, "B");
  557. OPCODE(eOpcodes::JUMP, "JUMP", FF7ModelInstruction, 0, "NNssww");
  558. OPCODE(eOpcodes::AXYZI, "AXYZI", FF7ModelInstruction, 0, "NNBBBBB");
  559. OPCODE(eOpcodes::LADER, "LADER", FF7ModelInstruction, 0, "NNssswBBBB");
  560. OPCODE(eOpcodes::OFST, "OFST", FF7ModelInstruction, 0, "NNBsssw");
  561. OPCODE(eOpcodes::OFSTW, "OFSTW", FF7ModelInstruction, 0, "");
  562. OPCODE(eOpcodes::TALKR, "TALKR", FF7ModelInstruction, 0, "NB");
  563. OPCODE(eOpcodes::SLIDR, "SLIDR", FF7ModelInstruction, 0, "NB");
  564. OPCODE(eOpcodes::SOLID, "SOLID", FF7ModelInstruction, 0, "B");
  565. OPCODE(eOpcodes::TLKR2, "TLKR2", FF7ModelInstruction, 0, "Nw");
  566. OPCODE(eOpcodes::SLDR2, "SLDR2", FF7ModelInstruction, 0, "Nw");
  567. OPCODE(eOpcodes::CCANM, "CCANM", FF7ModelInstruction, 0, "BBB");
  568. OPCODE(eOpcodes::FCFIX, "FCFIX", FF7ModelInstruction, 0, "B");
  569. OPCODE(eOpcodes::ANIMB, "ANIMB", FF7ModelInstruction, 0, "");
  570. OPCODE(eOpcodes::TURNW, "TURNW", FF7ModelInstruction, 0, "");
  571. // Walkmesh
  572. OPCODE(eOpcodes::SLIP, "SLIP", FF7WalkmeshInstruction, 0, "B");
  573. OPCODE(eOpcodes::UC, "UC", FF7WalkmeshInstruction, 0, "B");
  574. OPCODE(eOpcodes::IDLCK, "IDLCK", FF7WalkmeshInstruction, 0, "wB");
  575. OPCODE(eOpcodes::LINE, "LINE", FF7WalkmeshInstruction, 0, "ssssss");
  576. OPCODE(eOpcodes::LINON, "LINON", FF7WalkmeshInstruction, 0, "B");
  577. OPCODE(eOpcodes::SLINE, "SLINE", FF7WalkmeshInstruction, 0, "NNNssssss");
  578. // Backgnd
  579. OPCODE(eOpcodes::BGPDH, "BGPDH", FF7BackgroundInstruction, 0, "NBs");
  580. OPCODE(eOpcodes::BGSCR, "BGSCR", FF7BackgroundInstruction, 0, "NBss");
  581. OPCODE(eOpcodes::MPPAL, "MPPAL", FF7BackgroundInstruction, 0, "NNNBBBBBBB");
  582. OPCODE(eOpcodes::BGON, "BGON", FF7BackgroundInstruction, 0, "NBB");
  583. OPCODE(eOpcodes::BGOFF, "BGOFF", FF7BackgroundInstruction, 0, "NBB");
  584. OPCODE(eOpcodes::BGROL, "BGROL", FF7BackgroundInstruction, 0, "NB");
  585. OPCODE(eOpcodes::BGROL2, "BGROL2", FF7BackgroundInstruction, 0, "NB");
  586. OPCODE(eOpcodes::BGCLR, "BGCLR", FF7BackgroundInstruction, 0, "NB");
  587. OPCODE(eOpcodes::STPAL, "STPAL", FF7BackgroundInstruction, 0, "NBBB");
  588. OPCODE(eOpcodes::LDPAL, "LDPAL", FF7BackgroundInstruction, 0, "NBBB");
  589. OPCODE(eOpcodes::CPPAL, "CPPAL", FF7BackgroundInstruction, 0, "NBBB");
  590. OPCODE(eOpcodes::RTPAL, "RTPAL", FF7BackgroundInstruction, 0, "NNBBBB");
  591. OPCODE(eOpcodes::ADPAL, "ADPAL", FF7BackgroundInstruction, 0, "NNNBBBBBB");
  592. OPCODE(eOpcodes::MPPAL2, "MPPAL2", FF7BackgroundInstruction, 0, "NNNBBBBBB");
  593. OPCODE(eOpcodes::STPLS, "STPLS", FF7BackgroundInstruction, 0, "BBBB");
  594. OPCODE(eOpcodes::LDPLS, "LDPLS", FF7BackgroundInstruction, 0, "BBBB");
  595. OPCODE(eOpcodes::CPPAL2, "CPPAL2", FF7BackgroundInstruction, 0, "BBBBBBB");
  596. OPCODE(eOpcodes::RTPAL2, "RTPAL2", FF7BackgroundInstruction, 0, "BBBBBBB");
  597. OPCODE(eOpcodes::ADPAL2, "ADPAL2", FF7BackgroundInstruction, 0, "BBBBBBBBBB");
  598. // Camera
  599. OPCODE(eOpcodes::NFADE, "NFADE", FF7CameraInstruction, 0, "NNBBBBBB");
  600. OPCODE(eOpcodes::SHAKE, "SHAKE", FF7CameraInstruction, 0, "BBBBBBB");
  601. OPCODE(eOpcodes::SCRLO, "SCRLO", FF7CameraInstruction, 0, "B");
  602. OPCODE(eOpcodes::SCRLC, "SCRLC", FF7CameraInstruction, 0, "BBBB");
  603. OPCODE(eOpcodes::SCRLA, "SCRLA", FF7CameraInstruction, 0, "NwBB");
  604. OPCODE(eOpcodes::SCR2D, "SCR2D", FF7CameraInstruction, 0, "Nss");
  605. OPCODE(eOpcodes::SCRCC, "SCRCC", FF7CameraInstruction, 0, "");
  606. OPCODE(eOpcodes::SCR2DC, "SCR2DC", FF7CameraInstruction, 0, "NNssw");
  607. OPCODE(eOpcodes::SCRLW, "SCRLW", FF7CameraInstruction, 0, "");
  608. OPCODE(eOpcodes::SCR2DL, "SCR2DL", FF7CameraInstruction, 0, "NNssw");
  609. OPCODE(eOpcodes::VWOFT, "VWOFT", FF7CameraInstruction, 0, "NssB");
  610. OPCODE(eOpcodes::FADE, "FADE", FF7CameraInstruction, 0, "NNBBBBBB");
  611. OPCODE(eOpcodes::FADEW, "FADEW", FF7CameraInstruction, 0, "");
  612. OPCODE(eOpcodes::SCRLP, "SCRLP", FF7CameraInstruction, 0, "NwBB");
  613. OPCODE(eOpcodes::MVCAM, "MVCAM", FF7CameraInstruction, 0, "B");
  614. // AV
  615. OPCODE(eOpcodes::BGMOVIE, "BGMOVIE", FF7AudioVideoInstruction, 0, "B");
  616. OPCODE(eOpcodes::AKAO2, "AKAO2", FF7AudioVideoInstruction, 0, "NNNBwwwww");
  617. OPCODE(eOpcodes::MUSIC, "MUSIC", FF7AudioVideoInstruction, 0, "B");
  618. OPCODE(eOpcodes::SOUND, "SOUND", FF7AudioVideoInstruction, 0, "NwB");
  619. OPCODE(eOpcodes::AKAO, "AKAO", FF7AudioVideoInstruction, 0, "NNNBBwwww");
  620. OPCODE(eOpcodes::MUSVT, "MUSVT", FF7AudioVideoInstruction, 0, "B");
  621. OPCODE(eOpcodes::MUSVM, "MUSVM", FF7AudioVideoInstruction, 0, "B");
  622. OPCODE(eOpcodes::MULCK, "MULCK", FF7AudioVideoInstruction, 0, "B");
  623. OPCODE(eOpcodes::BMUSC, "BMUSC", FF7AudioVideoInstruction, 0, "B");
  624. OPCODE(eOpcodes::CHMPH, "CHMPH", FF7AudioVideoInstruction, 0, "BBB");
  625. OPCODE(eOpcodes::PMVIE, "PMVIE", FF7AudioVideoInstruction, 0, "B");
  626. OPCODE(eOpcodes::MOVIE, "MOVIE", FF7AudioVideoInstruction, 0, "");
  627. OPCODE(eOpcodes::MVIEF, "MVIEF", FF7AudioVideoInstruction, 0, "NB");
  628. OPCODE(eOpcodes::FMUSC, "FMUSC", FF7AudioVideoInstruction, 0, "B");
  629. OPCODE(eOpcodes::CMUSC, "CMUSC", FF7AudioVideoInstruction, 0, "BBBBBBB");
  630. OPCODE(eOpcodes::CHMST, "CHMST", FF7AudioVideoInstruction, 0, "NB");
  631. // Uncat
  632. OPCODE(eOpcodes::MPDSP, "MPDSP", FF7UncategorizedInstruction, 0, "B");
  633. OPCODE(eOpcodes::SETX, "SETX", FF7UncategorizedInstruction, 0, "BBBBBB");
  634. OPCODE(eOpcodes::GETX, "GETX", FF7UncategorizedInstruction, 0, "BBBBBB");
  635. OPCODE(eOpcodes::SEARCHX, "SEARCHX", FF7UncategorizedInstruction, 0, "BBBBBBBBBB");
  636. default:
  637. throw UnknownOpcodeException(this->_address, opcode);
  638. }
  639. INC_ADDR;
  640. // Are we within an "if" statement tracking
  641. InstPtr i = this->_insts.back();
  642. if (i->isCondJump())
  643. {
  644. exitAddrs.push_back(i->getDestAddress());
  645. }
  646. if (!exitAddrs.empty())
  647. {
  648. if (i->_address == exitAddrs.back())
  649. {
  650. exitAddrs.pop_back();
  651. }
  652. }
  653. // Only bail if its the first RET that isn't within an "if" block
  654. if (full_opcode == eOpcodes::RET && exitAddrs.empty())
  655. {
  656. return;
  657. }
  658. }
  659. }