PlayerFile.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. #include "PlayerFile.h"
  2. #include "FFVIIString.h"
  3. #include "../../common/Logger.h"
  4. PlayerFile::PlayerFile( const Ogre::String &file ):
  5. File( file )
  6. {
  7. DumpData();
  8. }
  9. PlayerFile::PlayerFile( File *file, const u32 &offset, const u32 &length ):
  10. File( file, offset, length )
  11. {
  12. DumpData();
  13. }
  14. PlayerFile::PlayerFile( u8* buffer, const u32 &offset, const u32 &length ):
  15. File( buffer, offset, length )
  16. {
  17. DumpData();
  18. }
  19. PlayerFile::PlayerFile( File *file ):
  20. File( file )
  21. {
  22. DumpData();
  23. }
  24. PlayerFile::~PlayerFile()
  25. {
  26. }
  27. void
  28. PlayerFile::DumpData()
  29. {
  30. /*
  31. for (int i = 0; i < 12; ++i)
  32. {
  33. int ai_offset = GetU16LE(i * 2);
  34. if (ai_offset == 0xffff)
  35. {
  36. continue;
  37. }
  38. LOGGER->Log("PLAYER %x:\n", i);
  39. for (int l = 0; l < 0x10; ++l)
  40. {
  41. u16 local_script_offset = GetU16LE(ai_offset + l * 2);
  42. if (local_script_offset == 0xFFFF)
  43. {
  44. continue;
  45. }
  46. LOGGER->Log("script %x:\n", l);
  47. int script_offset = ai_offset + local_script_offset;
  48. int pointer = 0;
  49. bool run = true;
  50. for (; run == true;)
  51. {
  52. u8 opcode = GetU8(script_offset + pointer);
  53. u8 opcode_h = opcode >> 4;
  54. u8 opcode_l = opcode & 0xF;
  55. LOGGER->Log("0x%04x ", pointer);
  56. if (GetU8(script_offset + pointer + 0) == 0x00 &&
  57. GetU8(script_offset + pointer + 3) == 0x52 &&
  58. GetU8(script_offset + pointer + 4) == 0x70)
  59. {
  60. int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
  61. int bits1 = GetU16LE(script_offset + pointer + 1) & 7;
  62. int jump = GetU16LE(script_offset + pointer + 5);
  63. LOGGER->Log("JumpIfTrue(bit[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
  64. pointer += 7;
  65. continue;
  66. }
  67. if (GetU8(script_offset + pointer + 0) == 0x01 &&
  68. GetU8(script_offset + pointer + 3) == 0x52 &&
  69. GetU8(script_offset + pointer + 4) == 0x70)
  70. {
  71. int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
  72. int bits1 = GetU16LE(script_offset + pointer + 1) & 7;
  73. int jump = GetU16LE(script_offset + pointer + 5);
  74. LOGGER->Log("JumpIfTrue(b[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
  75. pointer += 7;
  76. continue;
  77. }
  78. if (GetU8(script_offset + pointer + 0) == 0x00 &&
  79. GetU8(script_offset + pointer + 3) == 0x70)
  80. {
  81. int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
  82. int bits1 = GetU16LE(script_offset + pointer + 1) & 7;
  83. int jump = GetU16LE(script_offset + pointer + 4);
  84. LOGGER->Log("JumpIfFalse(bit[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
  85. pointer += 6;
  86. continue;
  87. }
  88. if (GetU8(script_offset + pointer + 0) == 0x01 &&
  89. GetU8(script_offset + pointer + 3) == 0x60 &&
  90. GetU8(script_offset + pointer + 5) == 0x35 &&
  91. GetU8(script_offset + pointer + 6) == 0x60 &&
  92. GetU8(script_offset + pointer + 8) == 0x40 &&
  93. GetU8(script_offset + pointer + 9) == 0x70)
  94. {
  95. int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
  96. int bits1 = GetU16LE(script_offset + pointer + 1) & 7;
  97. int value1 = GetU8(script_offset + pointer + 4);
  98. int value2 = GetU8(script_offset + pointer + 7);
  99. int jump = GetU16LE(script_offset + pointer + 10);
  100. LOGGER->Log("JumpIf((b[0x%04x + 0x%02x] & 0x%02x) != 0x%02x)(0x%04x);\n", address1, bits1, value1, value2, jump);
  101. pointer += 12;
  102. continue;
  103. }
  104. if (GetU8(script_offset + pointer + 0) == 0x02 &&
  105. GetU8(script_offset + pointer + 1) == 0x60 &&
  106. GetU8(script_offset + pointer + 2) == 0x20 &&
  107. GetU8(script_offset + pointer + 3) == 0x00 &&
  108. GetU8(script_offset + pointer + 4) == 0x26 &&
  109. GetU8(script_offset + pointer + 5) == 0x40 &&
  110. GetU8(script_offset + pointer + 6) == 0x80 &&
  111. GetU8(script_offset + pointer + 7) == 0x60 &&
  112. GetU8(script_offset + pointer + 8) == 0x00 &&
  113. GetU8(script_offset + pointer + 9) == 0x40 &&
  114. GetU8(script_offset + pointer + 10) == 0x70)
  115. {
  116. int address = GetU16LE(script_offset + pointer + 11);
  117. LOGGER->Log("JumpIfSelfNotInFrontRow(0x%04x);\n", address);
  118. pointer += 13;
  119. continue;
  120. }
  121. if (GetU8(script_offset + pointer + 0) == 0x02 &&
  122. GetU8(script_offset + pointer + 1) == 0x80 &&
  123. GetU8(script_offset + pointer + 2) == 0x20 &&
  124. GetU8(script_offset + pointer + 3) == 0x00 &&
  125. GetU8(script_offset + pointer + 4) == 0x26 &&
  126. GetU8(script_offset + pointer + 5) == 0x40 &&
  127. GetU8(script_offset + pointer + 6) == 0x80 &&
  128. GetU8(script_offset + pointer + 7) == 0x60 &&
  129. GetU8(script_offset + pointer + 8) == 0x00 &&
  130. GetU8(script_offset + pointer + 9) == 0x40 &&
  131. GetU8(script_offset + pointer + 10) == 0x70)
  132. {
  133. int address = GetU16LE(script_offset + pointer + 11);
  134. LOGGER->Log("JumpIfNotAllFriendsInFrontRow(0x%04x);\n", address);
  135. pointer += 13;
  136. continue;
  137. }
  138. if (GetU8(script_offset + pointer + 0) == 0x02 &&
  139. GetU8(script_offset + pointer + 1) == 0x80 &&
  140. GetU8(script_offset + pointer + 2) == 0x20 &&
  141. GetU8(script_offset + pointer + 3) == 0x00 &&
  142. GetU8(script_offset + pointer + 4) == 0x26 &&
  143. GetU8(script_offset + pointer + 5) == 0x40 &&
  144. GetU8(script_offset + pointer + 6) == 0x80 &&
  145. GetU8(script_offset + pointer + 7) == 0x60 &&
  146. GetU8(script_offset + pointer + 8) == 0x01 &&
  147. GetU8(script_offset + pointer + 9) == 0x40 &&
  148. GetU8(script_offset + pointer + 10) == 0x70)
  149. {
  150. int address = GetU16LE(script_offset + pointer + 11);
  151. LOGGER->Log("JumpIfNotAllFriendsInBackRow(0x%04x);\n", address);
  152. pointer += 13;
  153. continue;
  154. }
  155. if (GetU8(script_offset + pointer + 0) == 0x02 &&
  156. GetU8(script_offset + pointer + 1) == 0xA0 &&
  157. GetU8(script_offset + pointer + 2) == 0x20 &&
  158. GetU8(script_offset + pointer + 3) == 0x00 &&
  159. GetU8(script_offset + pointer + 4) == 0x26 &&
  160. GetU8(script_offset + pointer + 5) == 0x40 &&
  161. GetU8(script_offset + pointer + 6) == 0x80 &&
  162. GetU8(script_offset + pointer + 7) == 0x60 &&
  163. GetU8(script_offset + pointer + 8) == 0x00 &&
  164. GetU8(script_offset + pointer + 9) == 0x40 &&
  165. GetU8(script_offset + pointer + 10) == 0x70)
  166. {
  167. int address = GetU16LE(script_offset + pointer + 11);
  168. LOGGER->Log("JumpIfNotAllOpponentsInFrontRow(0x%04x);\n", address);
  169. pointer += 13;
  170. continue;
  171. }
  172. if (GetU8(script_offset + pointer + 0) == 0x02 &&
  173. GetU8(script_offset + pointer + 1) == 0xA0 &&
  174. GetU8(script_offset + pointer + 2) == 0x20 &&
  175. GetU8(script_offset + pointer + 3) == 0x00 &&
  176. GetU8(script_offset + pointer + 4) == 0x26 &&
  177. GetU8(script_offset + pointer + 5) == 0x40 &&
  178. GetU8(script_offset + pointer + 6) == 0x80 &&
  179. GetU8(script_offset + pointer + 7) == 0x60 &&
  180. GetU8(script_offset + pointer + 8) == 0x01 &&
  181. GetU8(script_offset + pointer + 9) == 0x40 &&
  182. GetU8(script_offset + pointer + 10) == 0x70)
  183. {
  184. int address = GetU16LE(script_offset + pointer + 11);
  185. LOGGER->Log("JumpIfNotAllOpponentsInBackRow(0x%04x);\n", address);
  186. pointer += 13;
  187. continue;
  188. }
  189. if (GetU8(script_offset + pointer + 0) == 0x02 &&
  190. GetU8(script_offset + pointer + 1) == 0xA0 &&
  191. GetU8(script_offset + pointer + 2) == 0x20 &&
  192. GetU8(script_offset + pointer + 3) == 0x00 &&
  193. GetU8(script_offset + pointer + 4) == 0x1a &&
  194. GetU8(script_offset + pointer + 5) == 0x40 &&
  195. GetU8(script_offset + pointer + 6) == 0x80 &&
  196. GetU8(script_offset + pointer + 7) == 0x60 &&
  197. GetU8(script_offset + pointer + 8) == 0x00 &&
  198. GetU8(script_offset + pointer + 9) == 0x40 &&
  199. GetU8(script_offset + pointer + 10) == 0x70)
  200. {
  201. int address = GetU16LE(script_offset + pointer + 11);
  202. LOGGER->Log("JumpIfAllOpponentsInDarknessStatus(0x%04x);\n", address);
  203. pointer += 13;
  204. continue;
  205. }
  206. if ((GetU8(script_offset + pointer + 0) == 0x10 || GetU8(script_offset + pointer + 0) == 0x11 || GetU8(script_offset + pointer + 0) == 0x12) &&
  207. GetU8(script_offset + pointer + 3) == 0x60 &&
  208. GetU8(script_offset + pointer + 5) == 0x90)
  209. {
  210. int address = GetU16LE(script_offset + pointer + 1) >> 3;
  211. int bits = GetU16LE(script_offset + pointer + 1) & 7;
  212. int value = GetU8(script_offset + pointer + 4);
  213. LOGGER->Log("[0x%04x + 0x%02x] = b(0x%02x);\n", address, bits, value);
  214. pointer += 6;
  215. continue;
  216. }
  217. if ((GetU8(script_offset + pointer + 0) == 0x10 || GetU8(script_offset + pointer + 0) == 0x11 || GetU8(script_offset + pointer + 0) == 0x12) &&
  218. GetU8(script_offset + pointer + 3) == 0x61 &&
  219. GetU8(script_offset + pointer + 6) == 0x90)
  220. {
  221. int address = GetU16LE(script_offset + pointer + 1) >> 3;
  222. int bits = GetU16LE(script_offset + pointer + 1) & 7;
  223. int value = GetU16LE(script_offset + pointer + 4);
  224. LOGGER->Log("[0x%04x + 0x%02x] = h(0x%04x);\n", address, bits, value);
  225. pointer += 7;
  226. continue;
  227. }
  228. if ((GetU8(script_offset + pointer + 0) == 0x10 || GetU8(script_offset + pointer + 0) == 0x11 || GetU8(script_offset + pointer + 0) == 0x12) &&
  229. GetU8(script_offset + pointer + 3) == 0x62 &&
  230. GetU8(script_offset + pointer + 7) == 0x90)
  231. {
  232. int address = GetU16LE(script_offset + pointer + 1) >> 3;
  233. int bits = GetU16LE(script_offset + pointer + 1) & 7;
  234. int value = (GetU16LE(script_offset + pointer + 4) << 1) | GetU8(script_offset + pointer + 6);
  235. LOGGER->Log("[0x%04x + 0x%02x] = w(0x%08x);\n", address, bits, value);
  236. pointer += 8;
  237. continue;
  238. }
  239. if (GetU8(script_offset + pointer + 0) == 0x11 &&
  240. GetU8(script_offset + pointer + 3) == 0x01 &&
  241. GetU8(script_offset + pointer + 6) == 0x60 &&
  242. GetU8(script_offset + pointer + 8) == 0x35 &&
  243. GetU8(script_offset + pointer + 9) == 0x90)
  244. {
  245. int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
  246. int bits1 = GetU16LE(script_offset + pointer + 1) & 7;
  247. int address2 = GetU16LE(script_offset + pointer + 4) >> 3;
  248. int bits2 = GetU16LE(script_offset + pointer + 4) & 7;
  249. int value = GetU8(script_offset + pointer + 7);
  250. LOGGER->Log("[0x%04x + 0x%02x] = b(b[0x%04x + 0x%02x] & 0x%02x);\n", address1, bits1, address2, bits2, value);
  251. pointer += 10;
  252. continue;
  253. }
  254. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  255. GetU8(script_offset + pointer + 3) == 0x02 &&
  256. GetU8(script_offset + pointer + 6) == 0x90)
  257. {
  258. int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
  259. int bits1 = GetU16LE(script_offset + pointer + 1) & 7;
  260. int address2 = GetU16LE(script_offset + pointer + 4) >> 3;
  261. int bits2 = GetU16LE(script_offset + pointer + 4) & 7;
  262. LOGGER->Log("[0x%04x + 0x%02x] = h(h[0x%04x + 0x%02x]);\n", address1, bits1, address2, bits2);
  263. pointer += 7;
  264. continue;
  265. }
  266. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  267. GetU8(script_offset + pointer + 3) == 0x61 &&
  268. GetU8(script_offset + pointer + 6) == 0x90)
  269. {
  270. int address = GetU16LE(script_offset + pointer + 1) >> 3;
  271. int bits = GetU16LE(script_offset + pointer + 1) & 7;
  272. int value = GetU8(script_offset + pointer + 4) | (GetU8(script_offset + pointer + 5) << 8);
  273. LOGGER->Log("[0x%04x + 0x%02x] = h(0x%04x);\n", address, bits, value);
  274. pointer += 7;
  275. continue;
  276. }
  277. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  278. GetU8(script_offset + pointer + 1) == 0x70 &&
  279. GetU8(script_offset + pointer + 2) == 0x20 &&
  280. GetU8(script_offset + pointer + 3) == 0x02 &&
  281. GetU8(script_offset + pointer + 4) == 0xA0 &&
  282. GetU8(script_offset + pointer + 5) == 0x20 &&
  283. GetU8(script_offset + pointer + 6) == 0x00 &&
  284. GetU8(script_offset + pointer + 7) == 0x26 &&
  285. GetU8(script_offset + pointer + 8) == 0x40 &&
  286. GetU8(script_offset + pointer + 9) == 0x80 &&
  287. GetU8(script_offset + pointer + 10) == 0x60 &&
  288. GetU8(script_offset + pointer + 11) == 0x01 &&
  289. GetU8(script_offset + pointer + 12) == 0x40 &&
  290. GetU8(script_offset + pointer + 13) == 0x82 &&
  291. GetU8(script_offset + pointer + 14) == 0x90)
  292. {
  293. LOGGER->Log("SetRandomOpponentInBackRowToAttack();\n");
  294. pointer += 15;
  295. continue;
  296. }
  297. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  298. GetU8(script_offset + pointer + 1) == 0x70 &&
  299. GetU8(script_offset + pointer + 2) == 0x20 &&
  300. GetU8(script_offset + pointer + 3) == 0x02 &&
  301. GetU8(script_offset + pointer + 4) == 0xA0 &&
  302. GetU8(script_offset + pointer + 5) == 0x20 &&
  303. GetU8(script_offset + pointer + 6) == 0x00 &&
  304. GetU8(script_offset + pointer + 7) == 0x26 &&
  305. GetU8(script_offset + pointer + 8) == 0x40 &&
  306. GetU8(script_offset + pointer + 9) == 0x80 &&
  307. GetU8(script_offset + pointer + 10) == 0x60 &&
  308. GetU8(script_offset + pointer + 11) == 0x00 &&
  309. GetU8(script_offset + pointer + 12) == 0x40 &&
  310. GetU8(script_offset + pointer + 13) == 0x82 &&
  311. GetU8(script_offset + pointer + 14) == 0x90)
  312. {
  313. LOGGER->Log("SetRandomOpponentInFrontRowToAttack();\n");
  314. pointer += 15;
  315. continue;
  316. }
  317. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  318. GetU8(script_offset + pointer + 1) == 0x70 &&
  319. GetU8(script_offset + pointer + 2) == 0x20 &&
  320. GetU8(script_offset + pointer + 3) == 0x02 &&
  321. GetU8(script_offset + pointer + 4) == 0xA0 &&
  322. GetU8(script_offset + pointer + 5) == 0x20 &&
  323. GetU8(script_offset + pointer + 6) == 0x03 &&
  324. GetU8(script_offset + pointer + 7) == 0x60 &&
  325. GetU8(script_offset + pointer + 8) == 0x41 &&
  326. GetU8(script_offset + pointer + 9) == 0x80 &&
  327. GetU8(script_offset + pointer + 10) == 0x85 &&
  328. GetU8(script_offset + pointer + 11) == 0x82 &&
  329. GetU8(script_offset + pointer + 12) == 0x90)
  330. {
  331. LOGGER->Log("SetRandomOpponentWithLowestCurrentHP();\n");
  332. pointer += 13;
  333. continue;
  334. }
  335. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  336. GetU8(script_offset + pointer + 1) == 0x70 &&
  337. GetU8(script_offset + pointer + 2) == 0x20 &&
  338. GetU8(script_offset + pointer + 3) == 0x02 &&
  339. GetU8(script_offset + pointer + 4) == 0xA0 &&
  340. GetU8(script_offset + pointer + 5) == 0x20 &&
  341. GetU8(script_offset + pointer + 6) == 0x03 &&
  342. GetU8(script_offset + pointer + 7) == 0x60 &&
  343. GetU8(script_offset + pointer + 8) == 0x41 &&
  344. GetU8(script_offset + pointer + 9) == 0x80 &&
  345. GetU8(script_offset + pointer + 10) == 0x84 &&
  346. GetU8(script_offset + pointer + 11) == 0x82 &&
  347. GetU8(script_offset + pointer + 12) == 0x90)
  348. {
  349. LOGGER->Log("SetRandomOpponentWithHighestCurrentHP();\n");
  350. pointer += 13;
  351. continue;
  352. }
  353. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  354. GetU8(script_offset + pointer + 1) == 0x70 &&
  355. GetU8(script_offset + pointer + 2) == 0x20 &&
  356. GetU8(script_offset + pointer + 3) == 0x02 &&
  357. GetU8(script_offset + pointer + 4) == 0xA0 &&
  358. GetU8(script_offset + pointer + 5) == 0x20 &&
  359. GetU8(script_offset + pointer + 6) == 0x02 &&
  360. GetU8(script_offset + pointer + 7) == 0x10 &&
  361. GetU8(script_offset + pointer + 8) == 0x41 &&
  362. GetU8(script_offset + pointer + 9) == 0x80 &&
  363. GetU8(script_offset + pointer + 10) == 0x85 &&
  364. GetU8(script_offset + pointer + 11) == 0x82 &&
  365. GetU8(script_offset + pointer + 12) == 0x90)
  366. {
  367. LOGGER->Log("SetRandomOpponentWithLowestMagicDefence();\n");
  368. pointer += 13;
  369. continue;
  370. }
  371. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  372. GetU8(script_offset + pointer + 1) == 0x70 &&
  373. GetU8(script_offset + pointer + 2) == 0x20 &&
  374. GetU8(script_offset + pointer + 3) == 0x02 &&
  375. GetU8(script_offset + pointer + 4) == 0xA0 &&
  376. GetU8(script_offset + pointer + 5) == 0x20 &&
  377. GetU8(script_offset + pointer + 6) == 0x02 &&
  378. GetU8(script_offset + pointer + 7) == 0x00 &&
  379. GetU8(script_offset + pointer + 8) == 0x41 &&
  380. GetU8(script_offset + pointer + 9) == 0x80 &&
  381. GetU8(script_offset + pointer + 10) == 0x85 &&
  382. GetU8(script_offset + pointer + 11) == 0x82 &&
  383. GetU8(script_offset + pointer + 12) == 0x90)
  384. {
  385. LOGGER->Log("SetRandomOpponentWithLowestDefence();\n");
  386. pointer += 13;
  387. continue;
  388. }
  389. if (GetU8(script_offset + pointer + 0) == 0x12 &&
  390. GetU8(script_offset + pointer + 1) == 0x70 &&
  391. GetU8(script_offset + pointer + 2) == 0x20 &&
  392. GetU8(script_offset + pointer + 3) == 0x02 &&
  393. GetU8(script_offset + pointer + 4) == 0xA0 &&
  394. GetU8(script_offset + pointer + 5) == 0x20 &&
  395. GetU8(script_offset + pointer + 6) == 0x82 &&
  396. GetU8(script_offset + pointer + 7) == 0x90)
  397. {
  398. LOGGER->Log("SetRandomOpponentToAttack();\n");
  399. pointer += 8;
  400. continue;
  401. }
  402. if (GetU8(script_offset + pointer + 0) == 0x60 &&
  403. GetU8(script_offset + pointer + 2) == 0x02 &&
  404. GetU8(script_offset + pointer + 5) == 0x92)
  405. {
  406. int action = GetU8(script_offset + pointer + 1);
  407. int address1 = GetU16LE(script_offset + pointer + 3) >> 3;
  408. int bits1 = GetU16LE(script_offset + pointer + 3) & 7;
  409. LOGGER->Log("RunCommand(0x%02x, h[0x%04x + 0x%02x]);\n", action, address1, bits1);
  410. pointer += 6;
  411. continue;
  412. }
  413. if (GetU8(script_offset + pointer + 0) == 0x81 &&
  414. GetU8(script_offset + pointer + 1) == 0x01 &&
  415. GetU8(script_offset + pointer + 4) == 0x34 &&
  416. GetU8(script_offset + pointer + 5) == 0x52 &&
  417. GetU8(script_offset + pointer + 6) == 0x70)
  418. {
  419. int address1 = GetU16LE(script_offset + pointer + 2) >> 3;
  420. int bits1 = GetU16LE(script_offset + pointer + 2) & 7;
  421. int jump = GetU16LE(script_offset + pointer + 7);
  422. LOGGER->Log("JumpIfRandomNot(1/b[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
  423. pointer += 9;
  424. continue;
  425. }
  426. if (GetU8(script_offset + pointer + 0) == 0x81 &&
  427. GetU8(script_offset + pointer + 1) == 0x60 &&
  428. GetU8(script_offset + pointer + 3) == 0x34 &&
  429. GetU8(script_offset + pointer + 4) == 0x52 &&
  430. GetU8(script_offset + pointer + 5) == 0x70)
  431. {
  432. int value = GetU8(script_offset + pointer + 2);
  433. int jump = GetU16LE(script_offset + pointer + 6);
  434. LOGGER->Log("JumpIfRandomNot(1/0x%02x)(0x%04x);\n", value, jump);
  435. pointer += 8;
  436. continue;
  437. }
  438. switch (opcode)
  439. {
  440. case 0x00:
  441. case 0x01:
  442. case 0x02:
  443. case 0x03:
  444. {
  445. LOGGER->Log("0x%02x LoadValue(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
  446. pointer += 3;
  447. }
  448. break;
  449. case 0x10:
  450. case 0x11:
  451. case 0x12:
  452. case 0x13:
  453. {
  454. LOGGER->Log("0x%02x PushAddress(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
  455. pointer += 3;
  456. }
  457. break;
  458. case 0x30:
  459. {
  460. LOGGER->Log("0x%02x MathAdd()\n", opcode);
  461. pointer += 1;
  462. }
  463. break;
  464. case 0x31:
  465. {
  466. LOGGER->Log("0x%02x MathSub()\n", opcode);
  467. pointer += 1;
  468. }
  469. break;
  470. case 0x32:
  471. {
  472. LOGGER->Log("0x%02x MathMul()\n", opcode);
  473. pointer += 1;
  474. }
  475. break;
  476. case 0x33:
  477. {
  478. LOGGER->Log("0x%02x MathDiv()\n", opcode);
  479. pointer += 1;
  480. }
  481. break;
  482. case 0x34:
  483. {
  484. LOGGER->Log("0x%02x MathMod()\n", opcode);
  485. pointer += 1;
  486. }
  487. break;
  488. case 0x35:
  489. {
  490. LOGGER->Log("0x%02x MathAnd()\n", opcode);
  491. pointer += 1;
  492. }
  493. break;
  494. case 0x36:
  495. {
  496. LOGGER->Log("0x%02x MathOr()\n", opcode);
  497. pointer += 1;
  498. }
  499. break;
  500. case 0x37:
  501. {
  502. LOGGER->Log("0x%02x MathNor()\n", opcode);
  503. pointer += 1;
  504. }
  505. break;
  506. case 0x40:
  507. {
  508. LOGGER->Log("0x%02x CompareEqual()\n", opcode);
  509. pointer += 1;
  510. }
  511. break;
  512. case 0x41:
  513. {
  514. LOGGER->Log("0x%02x CompareNotEqual()\n", opcode);
  515. pointer += 1;
  516. }
  517. break;
  518. case 0x42:
  519. {
  520. LOGGER->Log("0x%02x CompareGreaterEqual()\n", opcode);
  521. pointer += 1;
  522. }
  523. break;
  524. case 0x43:
  525. {
  526. LOGGER->Log("0x%02x CompareLessEqual()\n", opcode);
  527. pointer += 1;
  528. }
  529. break;
  530. case 0x44:
  531. {
  532. LOGGER->Log("0x%02x CompareGreater()\n", opcode);
  533. pointer += 1;
  534. }
  535. break;
  536. case 0x45:
  537. {
  538. LOGGER->Log("0x%02x CompareLess()\n", opcode);
  539. pointer += 1;
  540. }
  541. break;
  542. case 0x50:
  543. {
  544. LOGGER->Log("0x%02x LogAnd()\n", opcode);
  545. pointer += 1;
  546. }
  547. break;
  548. case 0x51:
  549. {
  550. LOGGER->Log("0x%02x LogOr()\n", opcode);
  551. pointer += 1;
  552. }
  553. break;
  554. case 0x52:
  555. {
  556. LOGGER->Log("0x%02x LogNot()\n", opcode);
  557. pointer += 1;
  558. }
  559. break;
  560. case 0x60:
  561. {
  562. u32 value = GetU8(script_offset + pointer + 1);
  563. LOGGER->Log("0x%02x PushImmediate(0x%02x)\n", opcode, value);
  564. pointer += 2;
  565. }
  566. break;
  567. case 0x61:
  568. {
  569. u32 value = GetU8(script_offset + pointer + 1) | (GetU8(script_offset + pointer + 2) << 8);
  570. LOGGER->Log("0x%02x PushImmediate(0x%04x)\n", opcode, value);
  571. pointer += 3;
  572. }
  573. break;
  574. case 0x70:
  575. {
  576. LOGGER->Log("0x%02x JumpIfFalse(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
  577. pointer += 3;
  578. }
  579. break;
  580. case 0x71:
  581. {
  582. LOGGER->Log("0x%02x JumpIfNotEqual(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
  583. pointer += 3;
  584. }
  585. break;
  586. case 0x72:
  587. {
  588. LOGGER->Log("0x%02x JumpTo(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
  589. pointer += 3;
  590. }
  591. break;
  592. case 0x73:
  593. {
  594. LOGGER->Log("0x%02x FinishScript()\n", opcode);
  595. run = false;
  596. pointer += 1;
  597. }
  598. break;
  599. case 0x75:
  600. {
  601. LOGGER->Log("0x%02x LinkScriptToOtherPlayer()\n", opcode);
  602. pointer += 1;
  603. }
  604. break;
  605. case 0x80:
  606. {
  607. LOGGER->Log("0x%02x FilterValueByMask()\n", opcode);
  608. pointer += 1;
  609. }
  610. break;
  611. case 0x81:
  612. {
  613. LOGGER->Log("0x%02x MathRandom()\n", opcode);
  614. pointer += 1;
  615. }
  616. break;
  617. case 0x82:
  618. {
  619. LOGGER->Log("0x%02x PickRandomBit()\n", opcode);
  620. pointer += 1;
  621. }
  622. break;
  623. case 0x83:
  624. {
  625. LOGGER->Log("0x%02x CountActiveBits()\n", opcode);
  626. pointer += 1;
  627. }
  628. break;
  629. case 0x84:
  630. {
  631. LOGGER->Log("0x%02x GetHighestMask()\n", opcode);
  632. pointer += 1;
  633. }
  634. break;
  635. case 0x85:
  636. {
  637. LOGGER->Log("0x%02x GetLowestMask()\n", opcode);
  638. pointer += 1;
  639. }
  640. break;
  641. case 0x86:
  642. {
  643. LOGGER->Log("0x%02x GetMPCost()\n", opcode);
  644. pointer += 1;
  645. }
  646. break;
  647. case 0x87:
  648. {
  649. LOGGER->Log("0x%02x SetBit()\n", opcode);
  650. pointer += 1;
  651. }
  652. break;
  653. case 0x90:
  654. {
  655. LOGGER->Log("0x%02x StoreValue()\n", opcode);
  656. pointer += 1;
  657. }
  658. break;
  659. case 0x91:
  660. {
  661. LOGGER->Log("0x%02x Pop()\n", opcode);
  662. pointer += 1;
  663. }
  664. break;
  665. case 0x92:
  666. {
  667. LOGGER->Log("0x%02x RunCommand()\n", opcode);
  668. pointer += 1;
  669. }
  670. break;
  671. case 0x93:
  672. {
  673. LOGGER->Log("0x%02x DisplayText(", opcode);
  674. pointer += 1;
  675. FFVIIString text;
  676. unsigned char letter = GetU8(script_offset + pointer);
  677. while (true)
  678. {
  679. if (letter == 0xea || letter == 0xeb || letter == 0xec || letter == 0xed || letter == 0xee || letter == 0xef || letter == 0xf0 || letter == 0xf1)
  680. {
  681. LOGGER->Log("[variable%02x", letter);
  682. LOGGER->Log("%02x", GetU8(script_offset + pointer + 1));
  683. LOGGER->Log("%02x]", GetU8(script_offset + pointer + 2));
  684. pointer += 3;
  685. }
  686. else
  687. {
  688. LOGGER->Log("%02x", letter);
  689. text.push_back(letter);
  690. pointer += 1;
  691. if (letter == 0xff)
  692. {
  693. break;
  694. }
  695. }
  696. letter = GetU8(script_offset + pointer);
  697. }
  698. RString r_text = FFVIIStringToRString(text);
  699. LOGGER->Log(")(%s)\n", r_text.c_str());
  700. }
  701. break;
  702. case 0x94:
  703. {
  704. LOGGER->Log("0x%02x CopyUnitsData()\n", opcode);
  705. pointer += 1;
  706. }
  707. break;
  708. case 0x95:
  709. {
  710. LOGGER->Log("0x%02x ExchangeByteWithMemory(800f83a4 + 2 <-> memorybank1/2)\n", opcode);
  711. pointer += 1;
  712. }
  713. break;
  714. case 0x96:
  715. {
  716. LOGGER->Log("0x%02x GetUnitsElementalDefense()\n", opcode);
  717. pointer += 1;
  718. }
  719. break;
  720. case 0xA0:
  721. {
  722. LOGGER->Log("0x%02x DebugTextOutput(", opcode);
  723. pointer += 1;
  724. unsigned char pop = GetU8(script_offset + pointer);
  725. pointer += 1;
  726. char letter[2];
  727. letter[1] = 0;
  728. letter[0] = GetU8(script_offset + pointer);
  729. while (letter[0] != 0)
  730. {
  731. LOGGER->Log("%s", letter);
  732. pointer += 1;
  733. letter[0] = GetU8(script_offset + pointer);
  734. }
  735. pointer += 1;
  736. LOGGER->Log(")(pop %d var from stack)\n", pop);
  737. }
  738. break;
  739. default:
  740. {
  741. LOGGER->Log("0x%02x Unknown\n", opcode);
  742. run = false;
  743. }
  744. }
  745. }
  746. LOGGER->Log("\n", l);
  747. }
  748. LOGGER->Log("\n\n\n");
  749. }
  750. */
  751. }