sek.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /*
  2. * PicoDrive
  3. * (c) Copyright Dave, 2004
  4. * (C) notaz, 2006-2009
  5. *
  6. * This work is licensed under the terms of MAME license.
  7. * See COPYING file in the top-level directory.
  8. */
  9. #include "pico_int.h"
  10. #include "memory.h"
  11. unsigned int SekCycleCnt;
  12. unsigned int SekCycleAim;
  13. /* context */
  14. // Cyclone 68000
  15. #ifdef EMU_C68K
  16. struct Cyclone PicoCpuCM68k;
  17. #endif
  18. // MUSASHI 68000
  19. #ifdef EMU_M68K
  20. m68ki_cpu_core PicoCpuMM68k;
  21. #endif
  22. // FAME 68000
  23. #ifdef EMU_F68K
  24. M68K_CONTEXT PicoCpuFM68k;
  25. #endif
  26. /* callbacks */
  27. #ifdef EMU_C68K
  28. // interrupt acknowledgment
  29. static int SekIntAck(int level)
  30. {
  31. // try to emulate VDP's reaction to 68000 int ack
  32. if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }
  33. else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }
  34. PicoCpuCM68k.irq = 0;
  35. return CYCLONE_INT_ACK_AUTOVECTOR;
  36. }
  37. static void SekResetAck(void)
  38. {
  39. elprintf(EL_ANOMALY, "Reset encountered @ %06x", SekPc);
  40. }
  41. static int SekUnrecognizedOpcode()
  42. {
  43. unsigned int pc;
  44. pc = SekPc;
  45. elprintf(EL_ANOMALY, "Unrecognized Opcode @ %06x", pc);
  46. // see if we are still in a mapped region
  47. pc &= 0x00ffffff;
  48. if (map_flag_set(m68k_read16_map[pc >> M68K_MEM_SHIFT])) {
  49. elprintf(EL_STATUS|EL_ANOMALY, "m68k crash @%06x", pc);
  50. PicoCpuCM68k.cycles = 0;
  51. PicoCpuCM68k.state_flags |= 1;
  52. return 1;
  53. }
  54. #ifdef EMU_M68K // debugging cyclone
  55. {
  56. extern int have_illegal;
  57. have_illegal = 1;
  58. }
  59. #endif
  60. return 0;
  61. }
  62. #endif
  63. #ifdef EMU_M68K
  64. static int SekIntAckM68K(int level)
  65. {
  66. if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }
  67. else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }
  68. CPU_INT_LEVEL = 0;
  69. return M68K_INT_ACK_AUTOVECTOR;
  70. }
  71. static int SekTasCallback(void)
  72. {
  73. return 0; // no writeback
  74. }
  75. #endif
  76. #ifdef EMU_F68K
  77. static void SekIntAckF68K(unsigned level)
  78. {
  79. if (level == 4) {
  80. Pico.video.pending_ints = 0;
  81. elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCyclesDone());
  82. }
  83. else if(level == 6) {
  84. Pico.video.pending_ints &= ~0x20;
  85. elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCyclesDone());
  86. }
  87. PicoCpuFM68k.interrupts[0] = 0;
  88. }
  89. #endif
  90. PICO_INTERNAL void SekInit(void)
  91. {
  92. #ifdef EMU_C68K
  93. CycloneInit();
  94. memset(&PicoCpuCM68k,0,sizeof(PicoCpuCM68k));
  95. PicoCpuCM68k.IrqCallback=SekIntAck;
  96. PicoCpuCM68k.ResetCallback=SekResetAck;
  97. PicoCpuCM68k.UnrecognizedCallback=SekUnrecognizedOpcode;
  98. PicoCpuCM68k.flags=4; // Z set
  99. #endif
  100. #ifdef EMU_M68K
  101. {
  102. void *oldcontext = m68ki_cpu_p;
  103. m68k_set_context(&PicoCpuMM68k);
  104. m68k_set_cpu_type(M68K_CPU_TYPE_68000);
  105. m68k_init();
  106. m68k_set_int_ack_callback(SekIntAckM68K);
  107. m68k_set_tas_instr_callback(SekTasCallback);
  108. //m68k_pulse_reset();
  109. m68k_set_context(oldcontext);
  110. }
  111. #endif
  112. #ifdef EMU_F68K
  113. {
  114. void *oldcontext = g_m68kcontext;
  115. g_m68kcontext = &PicoCpuFM68k;
  116. memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k));
  117. fm68k_init();
  118. PicoCpuFM68k.iack_handler = SekIntAckF68K;
  119. PicoCpuFM68k.sr = 0x2704; // Z flag
  120. g_m68kcontext = oldcontext;
  121. }
  122. #endif
  123. }
  124. // Reset the 68000:
  125. PICO_INTERNAL int SekReset(void)
  126. {
  127. if (Pico.rom==NULL) return 1;
  128. #ifdef EMU_C68K
  129. CycloneReset(&PicoCpuCM68k);
  130. #endif
  131. #ifdef EMU_M68K
  132. m68k_set_context(&PicoCpuMM68k); // if we ever reset m68k, we always need it's context to be set
  133. m68ki_cpu.sp[0]=0;
  134. m68k_set_irq(0);
  135. m68k_pulse_reset();
  136. REG_USP = 0; // ?
  137. #endif
  138. #ifdef EMU_F68K
  139. {
  140. g_m68kcontext = &PicoCpuFM68k;
  141. fm68k_reset();
  142. }
  143. #endif
  144. return 0;
  145. }
  146. void SekStepM68k(void)
  147. {
  148. SekCycleAim=SekCycleCnt+1;
  149. #if defined(EMU_CORE_DEBUG)
  150. SekCycleCnt+=CM_compareRun(1, 0);
  151. #elif defined(EMU_C68K)
  152. PicoCpuCM68k.cycles=1;
  153. CycloneRun(&PicoCpuCM68k);
  154. SekCycleCnt+=1-PicoCpuCM68k.cycles;
  155. #elif defined(EMU_M68K)
  156. SekCycleCnt+=m68k_execute(1);
  157. #elif defined(EMU_F68K)
  158. SekCycleCnt+=fm68k_emulate(1, 0);
  159. #endif
  160. }
  161. PICO_INTERNAL void SekSetRealTAS(int use_real)
  162. {
  163. #ifdef EMU_C68K
  164. CycloneSetRealTAS(use_real);
  165. #endif
  166. #ifdef EMU_F68K
  167. // TODO
  168. #endif
  169. }
  170. // Pack the cpu into a common format:
  171. // XXX: rename
  172. PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub)
  173. {
  174. unsigned int pc=0;
  175. #if defined(EMU_C68K)
  176. struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;
  177. memcpy(cpu,context->d,0x40);
  178. pc=context->pc-context->membase;
  179. *(unsigned int *)(cpu+0x44)=CycloneGetSr(context);
  180. *(unsigned int *)(cpu+0x48)=context->osp;
  181. cpu[0x4c] = context->irq;
  182. cpu[0x4d] = context->state_flags & 1;
  183. #elif defined(EMU_M68K)
  184. void *oldcontext = m68ki_cpu_p;
  185. m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k);
  186. memcpy(cpu,m68ki_cpu_p->dar,0x40);
  187. pc=m68ki_cpu_p->pc;
  188. *(unsigned int *)(cpu+0x44)=m68k_get_reg(NULL, M68K_REG_SR);
  189. *(unsigned int *)(cpu+0x48)=m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET];
  190. cpu[0x4c] = CPU_INT_LEVEL>>8;
  191. cpu[0x4d] = CPU_STOPPED;
  192. m68k_set_context(oldcontext);
  193. #elif defined(EMU_F68K)
  194. M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k;
  195. memcpy(cpu,context->dreg,0x40);
  196. pc=context->pc;
  197. *(unsigned int *)(cpu+0x44)=context->sr;
  198. *(unsigned int *)(cpu+0x48)=context->asp;
  199. cpu[0x4c] = context->interrupts[0];
  200. cpu[0x4d] = (context->execinfo & FM68K_HALTED) ? 1 : 0;
  201. #endif
  202. *(unsigned int *)(cpu+0x40) = pc;
  203. *(unsigned int *)(cpu+0x50) =
  204. is_sub ? SekCycleCntS68k : SekCycleCnt;
  205. }
  206. PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
  207. {
  208. #if defined(EMU_C68K)
  209. struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;
  210. CycloneSetSr(context, *(unsigned int *)(cpu+0x44));
  211. context->osp=*(unsigned int *)(cpu+0x48);
  212. memcpy(context->d,cpu,0x40);
  213. context->membase = 0;
  214. context->pc = *(unsigned int *)(cpu+0x40);
  215. CycloneUnpack(context, NULL); // rebase PC
  216. context->irq = cpu[0x4c];
  217. context->state_flags = 0;
  218. if (cpu[0x4d])
  219. context->state_flags |= 1;
  220. #elif defined(EMU_M68K)
  221. void *oldcontext = m68ki_cpu_p;
  222. m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k);
  223. m68k_set_reg(M68K_REG_SR, *(unsigned int *)(cpu+0x44));
  224. memcpy(m68ki_cpu_p->dar,cpu,0x40);
  225. m68ki_cpu_p->pc=*(unsigned int *)(cpu+0x40);
  226. m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]=*(unsigned int *)(cpu+0x48);
  227. CPU_INT_LEVEL = cpu[0x4c] << 8;
  228. CPU_STOPPED = cpu[0x4d];
  229. m68k_set_context(oldcontext);
  230. #elif defined(EMU_F68K)
  231. M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k;
  232. memcpy(context->dreg,cpu,0x40);
  233. context->pc =*(unsigned int *)(cpu+0x40);
  234. context->sr =*(unsigned int *)(cpu+0x44);
  235. context->asp=*(unsigned int *)(cpu+0x48);
  236. context->interrupts[0] = cpu[0x4c];
  237. context->execinfo &= ~FM68K_HALTED;
  238. if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED;
  239. #endif
  240. if (is_sub)
  241. SekCycleCntS68k = *(unsigned int *)(cpu+0x50);
  242. else
  243. SekCycleCnt = *(unsigned int *)(cpu+0x50);
  244. }
  245. /* idle loop detection, not to be used in CD mode */
  246. #ifdef EMU_C68K
  247. #include "cpu/cyclone/tools/idle.h"
  248. #endif
  249. static unsigned short **idledet_ptrs = NULL;
  250. static int idledet_count = 0, idledet_bads = 0;
  251. static int idledet_start_frame = 0;
  252. #if 0
  253. #define IDLE_STATS 1
  254. unsigned int idlehit_addrs[128], idlehit_counts[128];
  255. void SekRegisterIdleHit(unsigned int pc)
  256. {
  257. int i;
  258. for (i = 0; i < 127 && idlehit_addrs[i]; i++) {
  259. if (idlehit_addrs[i] == pc) {
  260. idlehit_counts[i]++;
  261. return;
  262. }
  263. }
  264. idlehit_addrs[i] = pc;
  265. idlehit_counts[i] = 1;
  266. idlehit_addrs[i+1] = 0;
  267. }
  268. #endif
  269. void SekInitIdleDet(void)
  270. {
  271. unsigned short **tmp = realloc(idledet_ptrs, 0x200*4);
  272. if (tmp == NULL) {
  273. free(idledet_ptrs);
  274. idledet_ptrs = NULL;
  275. }
  276. else
  277. idledet_ptrs = tmp;
  278. idledet_count = idledet_bads = 0;
  279. idledet_start_frame = Pico.m.frame_count + 360;
  280. #ifdef IDLE_STATS
  281. idlehit_addrs[0] = 0;
  282. #endif
  283. #ifdef EMU_C68K
  284. CycloneInitIdle();
  285. #endif
  286. #ifdef EMU_F68K
  287. fm68k_emulate(0, 1);
  288. #endif
  289. }
  290. int SekIsIdleReady(void)
  291. {
  292. return (Pico.m.frame_count >= idledet_start_frame);
  293. }
  294. int SekIsIdleCode(unsigned short *dst, int bytes)
  295. {
  296. // printf("SekIsIdleCode %04x %i\n", *dst, bytes);
  297. switch (bytes)
  298. {
  299. case 2:
  300. if ((*dst & 0xf000) != 0x6000) // not another branch
  301. return 1;
  302. break;
  303. case 4:
  304. if ( (*dst & 0xff3f) == 0x4a38 || // tst.x ($xxxx.w); tas ($xxxx.w)
  305. (*dst & 0xc1ff) == 0x0038 || // move.x ($xxxx.w), dX
  306. (*dst & 0xf13f) == 0xb038) // cmp.x ($xxxx.w), dX
  307. return 1;
  308. if (PicoAHW & (PAHW_MCD|PAHW_32X))
  309. break;
  310. // with no addons, there should be no need to wait
  311. // for byte change anywhere
  312. if ( (*dst & 0xfff8) == 0x4a10 || // tst.b ($aX)
  313. (*dst & 0xfff8) == 0x4a28) // tst.b ($xxxx,a0)
  314. return 1;
  315. break;
  316. case 6:
  317. if ( ((dst[1] & 0xe0) == 0xe0 && ( // RAM and
  318. *dst == 0x4a39 || // tst.b ($xxxxxxxx)
  319. *dst == 0x4a79 || // tst.w ($xxxxxxxx)
  320. *dst == 0x4ab9 || // tst.l ($xxxxxxxx)
  321. (*dst & 0xc1ff) == 0x0039 || // move.x ($xxxxxxxx), dX
  322. (*dst & 0xf13f) == 0xb039))||// cmp.x ($xxxxxxxx), dX
  323. *dst == 0x0838 || // btst $X, ($xxxx.w) [6 byte op]
  324. (*dst & 0xffbf) == 0x0c38) // cmpi.{b,w} $X, ($xxxx.w)
  325. return 1;
  326. break;
  327. case 8:
  328. if ( ((dst[2] & 0xe0) == 0xe0 && ( // RAM and
  329. *dst == 0x0839 || // btst $X, ($xxxxxxxx.w) [8 byte op]
  330. (*dst & 0xffbf) == 0x0c39))||// cmpi.{b,w} $X, ($xxxxxxxx)
  331. *dst == 0x0cb8) // cmpi.l $X, ($xxxx.w)
  332. return 1;
  333. break;
  334. case 12:
  335. if (PicoAHW & (PAHW_MCD|PAHW_32X))
  336. break;
  337. if ( (*dst & 0xf1f8) == 0x3010 && // move.w (aX), dX
  338. (dst[1]&0xf100) == 0x0000 && // arithmetic
  339. (dst[3]&0xf100) == 0x0000) // arithmetic
  340. return 1;
  341. break;
  342. }
  343. return 0;
  344. }
  345. int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx)
  346. {
  347. int is_main68k = 1;
  348. u16 *target;
  349. uptr v;
  350. #if defined(EMU_C68K)
  351. struct Cyclone *cyc = ctx;
  352. is_main68k = cyc == &PicoCpuCM68k;
  353. pc -= cyc->membase;
  354. #elif defined(EMU_F68K)
  355. is_main68k = ctx == &PicoCpuFM68k;
  356. #endif
  357. pc &= ~0xff000000;
  358. if (!(newop&0x200))
  359. elprintf(EL_IDLE, "idle: patch %06x %04x %04x %c %c #%i", pc, oldop, newop,
  360. (newop&0x200)?'n':'y', is_main68k?'m':'s', idledet_count);
  361. // XXX: probably shouldn't patch RAM too
  362. v = m68k_read16_map[pc >> M68K_MEM_SHIFT];
  363. if (!(v & 0x80000000))
  364. target = (u16 *)((v << 1) + pc);
  365. else {
  366. if (++idledet_bads > 128)
  367. return 2; // remove detector
  368. return 1; // don't patch
  369. }
  370. if (idledet_count >= 0x200 && (idledet_count & 0x1ff) == 0) {
  371. unsigned short **tmp = realloc(idledet_ptrs, (idledet_count+0x200)*4);
  372. if (tmp == NULL)
  373. return 1;
  374. idledet_ptrs = tmp;
  375. }
  376. idledet_ptrs[idledet_count++] = target;
  377. return 0;
  378. }
  379. void SekFinishIdleDet(void)
  380. {
  381. #ifdef EMU_C68K
  382. CycloneFinishIdle();
  383. #endif
  384. #ifdef EMU_F68K
  385. fm68k_emulate(0, 2);
  386. #endif
  387. while (idledet_count > 0)
  388. {
  389. unsigned short *op = idledet_ptrs[--idledet_count];
  390. if ((*op & 0xfd00) == 0x7100)
  391. *op &= 0xff, *op |= 0x6600;
  392. else if ((*op & 0xfd00) == 0x7500)
  393. *op &= 0xff, *op |= 0x6700;
  394. else if ((*op & 0xfd00) == 0x7d00)
  395. *op &= 0xff, *op |= 0x6000;
  396. else
  397. elprintf(EL_STATUS|EL_IDLE, "idle: don't know how to restore %04x", *op);
  398. }
  399. }
  400. #if defined(CPU_CMP_R) || defined(CPU_CMP_W)
  401. #include "debug.h"
  402. struct ref_68k {
  403. u32 dar[16];
  404. u32 pc;
  405. u32 sr;
  406. u32 cycles;
  407. u32 pc_prev;
  408. };
  409. struct ref_68k ref_68ks[2];
  410. static int current_68k;
  411. void SekTrace(int is_s68k)
  412. {
  413. struct ref_68k *x68k = &ref_68ks[is_s68k];
  414. u32 pc = is_s68k ? SekPcS68k : SekPc;
  415. u32 sr = is_s68k ? SekSrS68k : SekSr;
  416. u32 cycles = is_s68k ? SekCycleCntS68k : SekCycleCnt;
  417. u32 r;
  418. u8 cmd;
  419. #ifdef CPU_CMP_W
  420. int i;
  421. if (is_s68k != current_68k) {
  422. current_68k = is_s68k;
  423. cmd = CTL_68K_SLAVE | current_68k;
  424. tl_write(&cmd, sizeof(cmd));
  425. }
  426. if (pc != x68k->pc) {
  427. x68k->pc = pc;
  428. tl_write_uint(CTL_68K_PC, x68k->pc);
  429. }
  430. if (sr != x68k->sr) {
  431. x68k->sr = sr;
  432. tl_write_uint(CTL_68K_SR, x68k->sr);
  433. }
  434. for (i = 0; i < 16; i++) {
  435. r = is_s68k ? SekDarS68k(i) : SekDar(i);
  436. if (r != x68k->dar[i]) {
  437. x68k->dar[i] = r;
  438. tl_write_uint(CTL_68K_R + i, r);
  439. }
  440. }
  441. tl_write_uint(CTL_68K_CYCLES, cycles);
  442. #else
  443. int i, bad = 0;
  444. while (1)
  445. {
  446. int ret = tl_read(&cmd, sizeof(cmd));
  447. if (ret == 0) {
  448. elprintf(EL_STATUS, "EOF");
  449. exit(1);
  450. }
  451. switch (cmd) {
  452. case CTL_68K_SLAVE:
  453. case CTL_68K_SLAVE + 1:
  454. current_68k = cmd & 1;
  455. break;
  456. case CTL_68K_PC:
  457. tl_read_uint(&x68k->pc);
  458. break;
  459. case CTL_68K_SR:
  460. tl_read_uint(&x68k->sr);
  461. break;
  462. case CTL_68K_CYCLES:
  463. tl_read_uint(&x68k->cycles);
  464. goto breakloop;
  465. default:
  466. if (CTL_68K_R <= cmd && cmd < CTL_68K_R + 0x10)
  467. tl_read_uint(&x68k->dar[cmd - CTL_68K_R]);
  468. else
  469. elprintf(EL_STATUS, "invalid cmd: %02x", cmd);
  470. }
  471. }
  472. breakloop:
  473. if (is_s68k != current_68k) {
  474. printf("bad 68k: %d %d\n", is_s68k, current_68k);
  475. bad = 1;
  476. }
  477. if (cycles != x68k->cycles) {
  478. printf("bad cycles: %u %u\n", cycles, x68k->cycles);
  479. bad = 1;
  480. }
  481. if ((pc ^ x68k->pc) & 0xffffff) {
  482. printf("bad PC: %08x %08x\n", pc, x68k->pc);
  483. bad = 1;
  484. }
  485. if (sr != x68k->sr) {
  486. printf("bad SR: %03x %03x\n", sr, x68k->sr);
  487. bad = 1;
  488. }
  489. for (i = 0; i < 16; i++) {
  490. r = is_s68k ? SekDarS68k(i) : SekDar(i);
  491. if (r != x68k->dar[i]) {
  492. printf("bad %c%d: %08x %08x\n", i < 8 ? 'D' : 'A', i & 7,
  493. r, x68k->dar[i]);
  494. bad = 1;
  495. }
  496. }
  497. if (bad) {
  498. for (i = 0; i < 8; i++)
  499. printf("D%d: %08x A%d: %08x\n", i, x68k->dar[i],
  500. i, x68k->dar[i + 8]);
  501. printf("PC: %08x, %08x\n", x68k->pc, x68k->pc_prev);
  502. PDebugDumpMem();
  503. exit(1);
  504. }
  505. x68k->pc_prev = x68k->pc;
  506. #endif
  507. }
  508. #endif // CPU_CMP_*
  509. #if defined(EMU_M68K) && M68K_INSTRUCTION_HOOK == OPT_SPECIFY_HANDLER
  510. static unsigned char op_flags[0x400000/2] = { 0, };
  511. static int atexit_set = 0;
  512. static void make_idc(void)
  513. {
  514. FILE *f = fopen("idc.idc", "w");
  515. int i;
  516. if (!f) return;
  517. fprintf(f, "#include <idc.idc>\nstatic main() {\n");
  518. for (i = 0; i < 0x400000/2; i++)
  519. if (op_flags[i] != 0)
  520. fprintf(f, " MakeCode(0x%06x);\n", i*2);
  521. fprintf(f, "}\n");
  522. fclose(f);
  523. }
  524. void instruction_hook(void)
  525. {
  526. if (!atexit_set) {
  527. atexit(make_idc);
  528. atexit_set = 1;
  529. }
  530. if (REG_PC < 0x400000)
  531. op_flags[REG_PC/2] = 1;
  532. }
  533. #endif
  534. // vim:shiftwidth=2:ts=2:expandtab