daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Aug 4th, 2017 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <idc.idc>
  3. #include <functions.idc>
  4.  
  5. // ---------------------------------
  6. // KOEI CROSSPLATFORM GAME SCRIPTS
  7. // ---------------------------------
  8.  
  9. //#define MANUAL
  10.  
  11. #ifdef MANUAL
  12. //  #define AUTODETECT
  13. //  #define MMC 1
  14.     #define MMC 5
  15.     #define LAST_BANK   0x1F
  16. //  #define LAST_BANK   0x3F
  17. #endif
  18.  
  19. static make_data_array_cust(ea, len, cmt) {
  20.     MakeUnknown(ea, len, DOUNK_SIMPLE);
  21.     if(len==2) {
  22.         MakeWord(ea);
  23.     } else {
  24.         MakeData(ea, FF_BYTE, len, 0);
  25.         SetArrayFormat(ea, AP_IDXHEX, 16 /*len*/, 0);
  26.     }
  27.     cmt = substr(CommentEx(ea, 0), 0, 3) + cmt;
  28.     MakeComm(ea, "");
  29.     MakeComm(ea, cmt);
  30.     return ea + len;
  31. }
  32.  
  33. static make_offset_custom(ea, exec, mmc, last_bank, defb1, defb2) {
  34.     auto ofs = Word(ea), bank = GetReg(ea,"ds")-1;
  35.     if(mmc == 1) {
  36.         if(ofs<0x8000)
  37.             ea = make_offset_ex(ea, -1, exec, 1);
  38.         else if(ofs>=0xC000)
  39.             ea = make_offset_ex(ea, last_bank, exec, 1);
  40.         else
  41.             ea = make_offset_ex(ea, bank, exec, 1);
  42.     } else if (mmc == 5) {
  43.         if(ofs<0x8000)
  44.             ea = make_offset_ex(ea, -1, exec, 1);
  45.         else if(ofs>=0xE000)
  46.             ea = make_offset_ex(ea, last_bank, exec, 1);
  47.         else if((ofs>=0xC000)&&(ofs<0xE000))
  48.             ea = make_offset_ex(ea, last_bank-1, exec, 1);
  49.         else if((defb2!=-1)&&((ofs>=0xA000)&&(ofs<0xC000))&&(exec==1))
  50.             ea = make_offset_ex(ea, defb2, exec, 1);
  51.         else if((defb1!=-1)&&((ofs>=0x8000)&&(ofs<0xA000))&&(exec==1))
  52.             ea = make_offset_ex(ea, defb1, exec, 1);
  53.         else
  54.             ea = make_offset_ex(ea, bank, exec, 1);
  55.     }
  56.     return ea;
  57. }
  58.  
  59. static get_offset_custom(ea, exec, mmc, last_bank, defb1, defb2) {
  60.     auto ofs = Word(ea), bank = GetReg(ea,"ds")-1;
  61.     if(mmc == 1) {
  62.         if(ofs<0x8000)
  63.             ea = MK_FP(AskSelector(0), 0) + ofs;
  64.         else if(ofs>=0xC000)
  65.             ea = MK_FP(AskSelector(last_bank + 1), 0) + ofs;
  66.         else
  67.             ea = MK_FP(AskSelector(bank + 1), 0) + ofs;
  68.     } else if (mmc==5) {
  69.         if(ofs<0x8000)
  70.             ea = MK_FP(AskSelector(0), 0) + ofs;
  71.         else if(ofs>=0xE000)
  72.             ea = MK_FP(AskSelector(last_bank + 1), 0) + ofs;
  73.         else if((ofs>=0xC000)&&(ofs<0xE000))
  74.             ea = MK_FP(AskSelector(last_bank - 1 + 1), 0) + ofs;
  75.         else if((defb2!=-1)&&((ofs>=0xA000)&&(ofs<0xC000))&&(exec==1))
  76.             ea = MK_FP(AskSelector(defb2 + 1), 0) + ofs;
  77.         else if((defb1!=-1)&&((ofs>=0x8000)&&(ofs<0xA000))&&(exec==1))
  78.             ea = MK_FP(AskSelector(defb1 + 1), 0) + ofs;
  79.         else
  80.             ea = MK_FP(AskSelector(bank + 1), 0) + ofs;
  81.     }
  82.     return ea;
  83. }
  84.  
  85. static get_name_offset_custom(ea,exec,mmc, last_bank, defb1, defb2) {
  86.     auto ofs_ea = get_offset_custom(ea,exec, mmc, last_bank, defb1, defb2);
  87.     auto ofs_name = NameEx(BADADDR, ofs_ea);
  88.     if(ofs_name == "") {
  89.         return form("0x%08x", ofs_ea);
  90.     } else {
  91.         return ofs_name;
  92.     }
  93. }
  94.  
  95. static set_name_offset_custom(ea,ofs_name,exec,mmc, last_bank, defb1, defb2) {
  96.     auto ofs_ea = get_offset_custom(ea,exec, mmc, last_bank, defb1, defb2);
  97.     ofs_name = form("_%s_%X",ofs_name,ofs_ea);
  98.     MakeNameEx(ofs_ea,ofs_name,SN_CHECK|SN_NOWARN);
  99. }
  100.  
  101. static native_calls_search(opcode,mmc, last_bank, defb1, defb2) {
  102.     auto ea = -1, tmp0, tmp1;
  103.     auto bank = GetReg(ea,"ds")-1;
  104.     Message(" Native call search start (%s)...\n", opcode);
  105.     do {
  106.         ea = FindBinary(ea + 1, SEARCH_DOWN|SEARCH_CASE, opcode);
  107.         if(ea != BADADDR) {
  108.             auto base, offs;
  109.             Message(" >found one at 0x%08x\n", ea);
  110.             tmp0 = get_name_offset_custom(ea + 3,1,mmc,last_bank,defb1,defb2);
  111.             tmp0 = substr(tmp0, 0, 3);
  112.             if((tmp0 == "loc")||(tmp0 == "sub"))
  113.                 set_name_offset_custom(ea + 3,"procedure",1,mmc,last_bank,defb1,defb2);
  114.             make_offset_custom(ea + 3, 1, mmc, last_bank, defb1, defb2);    // exec
  115.             tmp0 = Byte(ea + 5);
  116.             tmp1 = tmp0&0x80?"-":"";
  117.             if(tmp0&0x80)
  118.                 tmp0 = 0x100-tmp0;
  119.             make_data_array_cust(ea + 5, 1, "");
  120.             MakeCode(ea);
  121.             AutoMark(ea, AU_CODE);
  122.             MakeCode(ea + 6);
  123.             AutoMark(ea + 6, AU_CODE);
  124.             Wait();
  125.         }
  126.     } while (ea != BADADDR);
  127.     Message(" Done!\n");
  128. }
  129.  
  130. static koei_opcode(cmd) {
  131.     auto ret = "unk";
  132.     if((cmd >= 0x00)&&(cmd <= 0x0B))      ret = form("MOV       A, [HP-var%d]",(0xC-cmd&0xF));
  133.     else if((cmd >= 0x0C)&&(cmd <= 0x0F)) ret = form("MOV       A, [HP+arg%d]",(cmd&0xF)-0xC);
  134.     else if((cmd >= 0x10)&&(cmd <= 0x1B)) ret = form("MOV       B, [HP-var%d]",(0xC-cmd&0xF));
  135.     else if((cmd >= 0x1C)&&(cmd <= 0x1F)) ret = form("MOV       B, [HP+arg%d]",(cmd&0xF)-0xC);
  136.     else if((cmd >= 0x20)&&(cmd <= 0x2B)) ret = form("MOV       [HP-var%d], A",(0xC-cmd&0xF));
  137.     else if((cmd >= 0x2C)&&(cmd <= 0x2F)) ret = form("MOV       [HP+arg%d],A",(cmd&0xF)-0xC);
  138.     else if((cmd >= 0x30)&&(cmd <= 0x3B)) ret = form("PUSH      [HP-var%d]",(0xC-cmd&0xF));
  139.     else if((cmd >= 0x3C)&&(cmd <= 0x3F)) ret = form("PUSH      [HP+arg%d]",(cmd&0xF)-0xC);
  140.     else if((cmd >= 0x40)&&(cmd <= 0x4F)) ret = form("MOVI      A, %d",cmd&0xF);
  141.     else if((cmd >= 0x50)&&(cmd <= 0x5F)) ret = form("MOVI      B, %d",cmd&0xF);
  142.     else if((cmd >= 0x60)&&(cmd <= 0x6F)) ret = form("PUSHI     %d",cmd&0xF);
  143.     else if((cmd >= 0x70)&&(cmd <= 0x7F)) ret = form("ADDI      A, %d",cmd&0xF);
  144.     else if(cmd == 0x81) ret = "MOV       A, [HP%s%d]";
  145.     else if(cmd == 0x82) ret = "MOV       A, [HP%s%d]";
  146.     else if(cmd == 0x83) ret = "MOV       B, [HP%s%d]";
  147.     else if(cmd == 0x84) ret = "MOV       B, [HP%s%d]";
  148.     else if(cmd == 0x85) ret = "MOV       [HP%s%d], A";
  149.     else if(cmd == 0x86) ret = "MOV       [HP%s%d], A";
  150.     else if(cmd == 0x87) ret = "PUSH      [HP%s%d]";
  151.     else if(cmd == 0x88) ret = "PUSH      [HP%s%d]";
  152.     else if(cmd == 0x89) ret = "MOVS.B    A, $%02X";
  153.     else if(cmd == 0x8A) ret = "MOV       A, %s";
  154.     else if(cmd == 0x8B) ret = "MOVS.B    B, $%02X";
  155.     else if(cmd == 0x8C) ret = "MOV       B, %s";
  156.     else if(cmd == 0x8D) ret = "PUSHS.B   $%02X";
  157.     else if(cmd == 0x8E) ret = "PUSH      %s";
  158.     else if(cmd == 0x8F) ret = "ADDS.B    A, $%02X";
  159.     else if(cmd == 0x90) ret = "ADD       A, %s%d";
  160.     else if(cmd == 0xA0) ret = "MOVU.B    A, [HP%s%d]";
  161.     else if(cmd == 0xA1) ret = "MOVU.B    B, [HP%s%d]";
  162.     else if(cmd == 0xA2) ret = "MOVU.B    [HP%s%d], A";
  163.     else if(cmd == 0xA3) ret = "PUSHS.B   [HP%s%d]";
  164.     else if(cmd == 0xA4) ret = "MOV       A, [%s]";
  165.     else if(cmd == 0xA5) ret = "MOVU.B    A, [%s]";
  166.     else if(cmd == 0xA6) ret = "MOV       B, [%s]";
  167.     else if(cmd == 0xA7) ret = "MOVU.B    B, [%s]";
  168.     else if(cmd == 0xA8) ret = "MOV       [%s], A";
  169.     else if(cmd == 0xA9) ret = "MOVU.B    [%s], A";
  170.     else if(cmd == 0xAA) ret = "PUSH      [%s]";
  171.     else if(cmd == 0xAB) ret = "PUSHU.B   [%s]";
  172.     else if(cmd == 0xAC) ret = "EJSR      %s";
  173.     else if(cmd == 0xAD) ret = "COPY      [B], [A], $%04X";
  174.     else if(cmd == 0xAE) ret = "ADDU.B    SP, %02X";
  175.     else if(cmd == 0xAF) ret = "ADD       SP, %s%d";
  176.     else if(cmd == 0xB0) ret = "MOV       A, [A]";
  177.     else if(cmd == 0xB1) ret = "MOV       [POP B], A";
  178.     else if(cmd == 0xB2) ret = "NOP";
  179.     else if(cmd == 0xB3) ret = "PUSH      A";
  180.     else if(cmd == 0xB4) ret = "POP       B";
  181.     else if(cmd == 0xB5) ret = "MUL       A, B";
  182.     else if(cmd == 0xB6) ret = "DIVS      A, B";
  183.     else if(cmd == 0xB8) ret = "DIVU      A, B";
  184.     else if(cmd == 0xB9) ret = "MODS      A, B";    // AWJ
  185.     else if(cmd == 0xBA) ret = "MODU      A, B";    // AWJ
  186.     else if(cmd == 0xBB) ret = "ADD       A, B";
  187.     else if(cmd == 0xBC) ret = "SUB       A, B";
  188.     else if(cmd == 0xBD) ret = "ASL       A, B";
  189.     else if(cmd == 0xBE) ret = "LSR       A, B";
  190.     else if(cmd == 0xBF) ret = "ASR       A, B";
  191.     else if(cmd == 0xC0) ret = "CMPS.EQ   A, B";    //  A == B AWJ
  192.     else if(cmd == 0xC1) ret = "CMPS.NE   A, B";    //  A != B AWJ
  193.     else if(cmd == 0xC2) ret = "CMPS.LT   A, B";    // sA <  B AWJ
  194.     else if(cmd == 0xC3) ret = "CMPS.LE   A, B";    // sA <= B AWJ
  195.     else if(cmd == 0xC4) ret = "CMPS.GT   A, B";    // sA >  B AWJ
  196.     else if(cmd == 0xC5) ret = "CMPS.GE   A, B";    // sA >= B AWJ
  197.     else if(cmd == 0xC6) ret = "CMPU.LT   A, B";    // uA <  B AWJ
  198.     else if(cmd == 0xC7) ret = "CMPU.LE   A, B";    // uA <= B AWJ
  199.     else if(cmd == 0xC8) ret = "CMPU.GT   A, B";    // uA >  B AWJ
  200.     else if(cmd == 0xC9) ret = "CMPU.GE   A, B";    // uA >= B AWJ
  201.     else if(cmd == 0xCA) ret = "NOT       A";       // if A>0, A=0, else A=1 fix AWJ
  202.     else if(cmd == 0xCB) ret = "NEG       A";       // A = -A
  203.     else if(cmd == 0xCC) ret = "COMP      A";       // A = ~A
  204.     else if(cmd == 0xCD) ret = "SWAP      A, B";
  205.     else if(cmd == 0xCF) ret = "RET";
  206.     else if(cmd == 0xD0) ret = "INC       A";
  207.     else if(cmd == 0xD1) ret = "DEC       A";
  208.     else if(cmd == 0xD2) ret = "ASL       A";
  209.     else if(cmd == 0xD3) ret = "MOVU.B    A, [A]";
  210.     else if(cmd == 0xD4) ret = "MOVU.B    [POP B], A";
  211.     else if(cmd == 0xD5) ret = "SWITCH    %s%d, %d";
  212.     else if(cmd == 0xD6) ret = "JMP       %s";
  213.     else if(cmd == 0xD7) ret = "BRKT      A, %s";
  214.     else if(cmd == 0xD8) ret = "BRKF      A, %s";
  215.     else if(cmd == 0xD9) ret = "SWITCH.C  %d";
  216.     else if(cmd == 0xDA) ret = "AND       A, B";
  217.     else if(cmd == 0xDB) ret = "OR        A, B";
  218.     else if(cmd == 0xDC) ret = "XOR       A, B";
  219.     else if(cmd == 0xDD) ret = "EJSR      A";
  220.     else if(cmd == 0xDE) ret = "MOV       A, HP%s%d";
  221.     else if(cmd == 0xDF) ret = "MOV       B, HP%s%d";
  222.     else if(cmd == 0xE0) ret = "MOVBF.S   A, [A], %d, %d";  // sA = bit[A][%d-%d] AWJ
  223.     else if(cmd == 0xE1) ret = "MOVBF.U   A, [A], %d, %d";  // uA = bit[A][%d-%d] AWJ
  224.     else if(cmd == 0xE2) ret = "MOVBF     [B], A, %d, %d";  // [B] = bitA[%d-%d]  AWJ
  225.     else if(cmd == 0xE3) ret = "JMP.B     %s [PC-%d]";
  226.     else if(cmd == 0xE4) ret = "BRKT.B    %s [PC-%d]";
  227.     else if(cmd == 0xE5) ret = "BRKF.B    %s [PC-%d]";
  228.     else if(cmd == 0xE6) ret = "JMP.B     %s [PC+%d]";
  229.     else if(cmd == 0xE7) ret = "BRKT.B    %s [PC+%d]";
  230.     else if(cmd == 0xE8) ret = "BRKF.B    %s [PC+%d]";
  231.     else if(cmd == 0xE9) ret = "EJSR      %s, SP+%d";
  232.     else if(cmd == 0xEA) ret = "EJSR      A, SP+%d";
  233.     return ret;
  234. }
  235.  
  236. static koei_disasm(ea, stopea, mmc, last_bank, defb1, defb2) {
  237.     auto cmd_opc = "", cmd, tmp0, tmp1, tmp2, i, do_stop = 0;
  238.     auto bank = GetReg(ea,"ds"), BIOS_SUB_PTR;
  239.  
  240.     // detect the bytecode execution routine offset
  241.     tmp0 = FindBinary(0, SEARCH_DOWN|SEARCH_CASE, "68 85 08 68 85 09 68 85 00 68 85 01 A0 07 38");
  242.     if(mmc == 1)
  243.         BIOS_SUB_PTR = (tmp0&0x3FFF)|0xC000;
  244.     else if(mmc == 5) {
  245.         if(((GetReg(tmp0,"ds")-1)&1)==0)
  246.             BIOS_SUB_PTR = (tmp0&0x1FFF)|0xC000;
  247.         else
  248.             BIOS_SUB_PTR = (tmp0&0x1FFF)|0xE000;
  249.     }
  250.  
  251. #ifdef MANUAL
  252. //  Message("> START AT 0x%08X\n",ea);
  253.  
  254.     while(1) {  // manual exit                          // NO INDENTION!!
  255. #else
  256.     while(ea<=stopea) {
  257. #endif
  258.  
  259.     if(isCode(GetFlags(ea))) {
  260.         if(Byte(ea)==0x20) {
  261.             // check if we at the bytecode execution routine
  262.             tmp0=Word(ea+1);
  263.             if(tmp0==BIOS_SUB_PTR) {
  264.                 tmp0 = Word(ea+3);
  265.                 tmp1 = tmp0&0x8000?"-":"";
  266.                 if(tmp0&0x8000)
  267.                     tmp0 = 0x10000-tmp0;
  268.                 // write down some info about variables buffer in stack
  269.                 ea = make_data_array_cust(ea+3, 2, form("LOCAL VARS ARRAY SIZE: %s%d",tmp1,tmp0));
  270.             } else {
  271.                 // stop if any other native 6502 opcode, obviously some error here
  272.                 Message(" 6502 opcode at 0x%08x, silly!\n",ea);
  273.                 return ea;
  274.             }
  275.         } else {
  276.             Message(" 6502 opcode at 0x%08x, silly!\n",ea);
  277.             return ea;
  278.         }
  279.     }
  280.  
  281.     if(ea != BADADDR) {
  282.         // get opcode
  283.         cmd = Byte(ea);
  284.         // get opcode name
  285.         cmd_opc = koei_opcode(cmd);
  286.  
  287. //      Message("->cur ea = 0x%08X\n",ea);
  288. //      Message("->cur cmd = %02X (%s)\n",cmd,cmd_opc);
  289.  
  290.         if(cmd==0xCF) {                                 // ret/exit/stop
  291.             ea = make_data_array_cust(ea, 1, cmd_opc);
  292. #ifdef MANUAL
  293. //          Message("> STOP AT 0x%08X\n",ea);
  294.             return ea;
  295. #endif
  296.         } else if(cmd==0xD5) {                          // switch
  297.             tmp0 = Word(ea + 1);
  298.             tmp1 = Word(ea + 3);
  299.             tmp2 = tmp0&0x8000?"-":"";
  300.             if(tmp0&0x8000)
  301.                 tmp0 = 0x10000-tmp0;
  302.             ea = make_data_array_cust(ea, 5, form(cmd_opc,tmp2,tmp0,tmp1));
  303.             tmp2 = substr(CommentEx(ea, 0), 0, 3) + "DEFAULT";
  304.             MakeComm(ea, "");
  305.             MakeComm(ea, tmp2);
  306.             set_name_offset_custom(ea,"case",0,mmc,last_bank,defb1,defb2);
  307.             ea = make_offset_custom(ea, 0, mmc, last_bank, defb1, defb2);               // no exec, default case
  308.             for(i=0;i<tmp1;i++) {
  309.                 tmp2 = substr(CommentEx(ea, 0), 0, 3) + form("CASE: %d",i);
  310.                 MakeComm(ea, "");
  311.                 MakeComm(ea, tmp2);
  312.                 set_name_offset_custom(ea,"case",0,mmc,last_bank,defb1,defb2);
  313.                 ea = make_offset_custom(ea, 0, mmc, last_bank, defb1, defb2);           // no exec, switch case
  314.             }
  315.         } else if(cmd==0xD9) {                          // switch compare
  316.             tmp0 = Word(ea + 1);
  317.             ea = make_data_array_cust(ea, 3, form(cmd_opc,tmp0));
  318.             for(i=0;i<tmp0;i++) {
  319.                 ea = make_data_array_cust(ea, 2, form("CASE: %d",i));
  320.                 set_name_offset_custom(ea,"case",0,mmc,last_bank,defb1,defb2);
  321.                 ea = make_offset_custom(ea, 0, mmc, last_bank, defb1, defb2);           // no exec, switch case
  322.             }
  323.             tmp2 = substr(CommentEx(ea, 0), 0, 3) + "DEFAULT";
  324.             MakeComm(ea, "");
  325.             MakeComm(ea, tmp2);
  326.             set_name_offset_custom(ea,"defult_case",0,mmc,last_bank,defb1,defb2);
  327.             ea = make_offset_custom(ea, 0, mmc, last_bank, defb1, defb2);               // no exec, default case
  328.         } else if(((cmd>=0x00)&&(cmd<=0x7F))||((cmd>=0xB0)&&(cmd<=0xB6))||((cmd>=0xB8)&&(cmd<=0xCD))||((cmd>=0xD0)&&(cmd<=0xD4))||((cmd>=0xDA)&&(cmd<=0xDD))) {         // no args
  329.             ea = make_data_array_cust(ea, 1, cmd_opc);
  330. //      } else if((cmd == 0x80)||((cmd>=0x91)&&(cmd<=0x9F))||(cmd == 0xCE)||((cmd>=0xEB)&&(cmd<=0xFF))) {
  331.                                                         // BRK/EMPTY opcodes
  332. //          ea = make_data_array_cust(ea, 1, cmd_opc);
  333.         } else if(((cmd&0xF1)==0x81)||(cmd==0xAE)) {    // 1b arg
  334.             if(cmd<=0x88) {
  335.                 tmp0 = Byte(ea + 1);
  336.                 tmp1 = tmp0&0x80?"-":"+";
  337.                 if(tmp0&0x80)
  338.                     tmp0 = 0x100-tmp0;
  339.                 ea = make_data_array_cust(ea, 2, form(cmd_opc,tmp1,tmp0));
  340.             } else {
  341.                 tmp0 = Byte(ea + 1);
  342.                 ea = make_data_array_cust(ea, 2, form(cmd_opc,tmp0));
  343.             }
  344.         } else if((cmd==0x82)||(cmd==0x84)||(cmd==0x86)||(cmd==0x88)||(cmd==0x90)||((cmd>=0xA0)&&(cmd<=0xA3))||(cmd==0xAD)||(cmd==0xAF)||(cmd==0xDE)||(cmd==0xDF)) {
  345.                                                         // 2b arg
  346.             tmp0 = Word(ea + 1);
  347.             tmp1 = tmp0&0x8000?"-":"+";
  348.             if(tmp0&0x8000)
  349.                 tmp0 = 0x10000-tmp0;
  350.             ea = make_data_array_cust(ea, 3, form(cmd_opc,tmp1,tmp0));
  351.         } else if((cmd>=0xE0)&&(cmd<=0xE2)) {           // 1b + 1b arg
  352.             tmp0 = Byte(ea + 1);
  353.             tmp1 = Byte(ea + 2);
  354.             ea = make_data_array_cust(ea, 3, form(cmd_opc,tmp0,tmp1));
  355.         } else if(((cmd>=0xA4)&&(cmd<=0xAB))||(cmd==0x8A)||(cmd==0x8C)||(cmd==0x8E)) {
  356.                                                         // ofs arg, no exec
  357.             tmp1 = get_name_offset_custom(ea + 1,0,mmc,last_bank,defb1,defb2);
  358.             ea = make_data_array_cust(ea, 1, form(cmd_opc,tmp1));
  359.             ea = make_offset_custom(ea, 0, mmc, last_bank, defb1, defb2);
  360.         } else if((cmd>=0xD6)&&(cmd<=0xD8)) {           // opcode local ofs with name, no exec
  361.             tmp1 = get_name_offset_custom(ea + 1,0,mmc,last_bank,defb1,defb2);
  362.             ea = make_data_array_cust(ea, 1, form(cmd_opc,tmp1));
  363.             set_name_offset_custom(ea,"loc",0,mmc,last_bank,defb1,defb2);
  364.             ea = make_offset_custom(ea, 0, mmc, last_bank, defb1, defb2);
  365.         } else if((cmd==0xAC)) {                        // ofs arg, exec
  366.             tmp1 = get_name_offset_custom(ea + 1,1,mmc,last_bank,defb1,defb2);
  367.             ea = make_data_array_cust(ea, 1, form(cmd_opc,tmp1));
  368.             tmp1 = substr(tmp1, 0, 3);
  369.             if((tmp1 == "loc")||(tmp1 == "sub"))
  370.                 set_name_offset_custom(ea,"procedure",1,mmc,last_bank,defb1,defb2);
  371.             ea = make_offset_custom(ea, 1, mmc, last_bank, defb1, defb2);
  372.         } else if(cmd==0xE9) {                          // ofs arg, byte arg, exec
  373.             tmp0 = Word(ea + 1);
  374.             tmp1 = Byte(ea + 3);
  375.             tmp2 = get_name_offset_custom(ea + 1,1,mmc,last_bank,defb1,defb2);
  376.             ea = make_data_array_cust(ea, 1, form(cmd_opc,tmp2,tmp1));
  377.             tmp2 = substr(tmp2, 0, 3);
  378.             if((tmp2 == "loc")||(tmp2 == "sub"))
  379.                 set_name_offset_custom(ea,"procedure",1,mmc,last_bank,defb1,defb2);
  380.             ea = make_offset_custom(ea, 1, mmc, last_bank, defb1, defb2);
  381.             ea = make_data_array_cust(ea, 1, "");
  382.         } else if(cmd==0xEA) {                          // special indirect EJSR
  383.             tmp0 = Byte(ea + 1);
  384.             ea = make_data_array_cust(ea, 2, form(cmd_opc,tmp0));
  385.         } else if((cmd>=0xE3)&&(cmd<=0xE5)) {           // special relative branches (never used, may be redundant)
  386.             tmp0 = Byte(ea + 1);
  387.             tmp1 = NameEx(BADADDR, ea - tmp0 + 1);
  388.             if(tmp1 == "")
  389.                 tmp1 = form("0x%08x", ea - tmp0 + 1);
  390.             ea = make_data_array_cust(ea, 2, form(cmd_opc,tmp1,tmp0));
  391.         } else if((cmd>=0xE6)&&(cmd<=0xE8)) {           // special relative branches
  392.             tmp0 = Byte(ea + 1);
  393.             tmp1 = NameEx(BADADDR, ea + tmp0 + 1);
  394.             if(tmp1 == "")
  395.                 tmp1 = form("0x%08x", ea + tmp0 + 1);
  396.             ea = make_data_array_cust(ea, 2, form(cmd_opc,tmp1,tmp0));
  397.         } else if(cmd==0xB7) {                          // aithm32 opcodes
  398.             tmp0 = Byte(ea + 1);
  399.             if(tmp0 == 0x01)      cmd_opc = "MUL.D     A, B";
  400.             else if(tmp0 == 0x02) cmd_opc = "DIVS.D    A, B";
  401.             else if(tmp0 == 0x03) cmd_opc = "ADD.D     A, B";
  402.             else if(tmp0 == 0x04) cmd_opc = "SUB.D     A, B";
  403.             else if(tmp0 == 0x05) cmd_opc = "NEG.D     A";
  404.             else if(tmp0 == 0x06) cmd_opc = "CMP.D.EQ  A, B";
  405.             else if(tmp0 == 0x07) cmd_opc = "CMP.D.NE  A, B";
  406.             else if(tmp0 == 0x08) cmd_opc = "CMPS.D.LT A, B";
  407.             else if(tmp0 == 0x09) cmd_opc = "CMPS.D.LE A, B";
  408.             else if(tmp0 == 0x0A) cmd_opc = "CMPS.D.GT A, B";
  409.             else if(tmp0 == 0x0B) cmd_opc = "CMPS.D.GE A, B";
  410.             else if(tmp0 == 0x0C) cmd_opc = "MOV.D     A, [HP%s%d]";
  411.             else if(tmp0 == 0x0D) cmd_opc = "MOV.D     B, [HP%s%d]";
  412.             else if(tmp0 == 0x0E) cmd_opc = "MOV.D     [HP%s%d], A";
  413.             else if(tmp0 == 0x0F) cmd_opc = "PUSH.D    [HP%s%d]";
  414.             else if(tmp0 == 0x10) cmd_opc = "MOV.D     A, [%s]";
  415.             else if(tmp0 == 0x11) cmd_opc = "MOV.D     B, [%s]";
  416.             else if(tmp0 == 0x12) cmd_opc = "MOV.D     [%s], A";
  417.             else if(tmp0 == 0x13) cmd_opc = "PUSH.D    [%s]";
  418.             else if(tmp0 == 0x14) cmd_opc = "PUSH.D    A";              // AWJ
  419.             else if(tmp0 == 0x15) cmd_opc = "POP.D     B";
  420.             else if(tmp0 == 0x16) cmd_opc = "MOV.D     A, [A]";
  421.             else if(tmp0 == 0x17) cmd_opc = "MOV.D     [pop B], A";
  422.             else if(tmp0 == 0x18) cmd_opc = "MOV.D     A, %d";
  423.             else if(tmp0 == 0x19) cmd_opc = "MOV.D     B, %d";
  424.             else if(tmp0 == 0x1A) cmd_opc = "SWAP.D    A, B";
  425.             else if(tmp0 == 0x1B) cmd_opc = "INC.D     A";
  426.             else if(tmp0 == 0x1C) cmd_opc = "DEC.D     A";
  427.             else if(tmp0 == 0x1D) cmd_opc = "BOOL.D    A";              // A = bool(A != 0)
  428.             else if(tmp0 == 0x1E) cmd_opc = "MODS.D    A, B";
  429.             else if(tmp0 == 0x1F) cmd_opc = "ASL.D     A, B";
  430.             else if(tmp0 == 0x20) cmd_opc = "ASR.D     A, B";
  431.             else if(tmp0 == 0x21) cmd_opc = "COMP.D    A";
  432.             else if(tmp0 == 0x22) cmd_opc = "AND.D     A, B";
  433.             else if(tmp0 == 0x23) cmd_opc = "OR.D      A, B";
  434.             else if(tmp0 == 0x24) cmd_opc = "XOR.D     A, B";
  435.             else if(tmp0 == 0x25) cmd_opc = "EXTS.D    A";
  436.             else if(tmp0 == 0x26) cmd_opc = "EXTU.D    A";
  437.             else if(tmp0 == 0x27) cmd_opc = "NOP.D";
  438.             else if(tmp0 == 0x28) cmd_opc = "NOT.D     A";              // should be if A>0, A=0, else A=1 but never saves the result!
  439.             else if(tmp0 == 0x29) cmd_opc = "CMP.D.LT  A, B";
  440.             else if(tmp0 == 0x2A) cmd_opc = "CMP.D.LE  A, B";
  441.             else if(tmp0 == 0x2B) cmd_opc = "CMP.D.GT  A, B";
  442.             else if(tmp0 == 0x2C) cmd_opc = "CMP.D.GE  A, B";
  443.             else if(tmp0 == 0x2D) cmd_opc = "LSR.D     A, B";
  444.             else if(tmp0 == 0x2E) cmd_opc = "DIVU.D    A, B";
  445.             else if(tmp0 == 0x2F) cmd_opc = "MODU.D    A, B";
  446.             else cmd_opc = "(illegal)";
  447.             if(((tmp0>=0x01)&&(tmp0<=0x0B))||((tmp0>=0x14)&&(tmp0<=0x17))||((tmp0>=0x1A)&&(tmp0<=0x2F))) {
  448.                                                         // no args
  449.                 ea = make_data_array_cust(ea, 2, cmd_opc);
  450.             } else if((tmp0>=0x0C)&&(tmp0<=0x0F)) {     // word args
  451.                 tmp1 = Word(ea + 2);
  452.                 tmp2 = tmp1&0x8000?"-":"+";
  453.                 if(tmp1&0x8000)
  454.                     tmp1 = 0x10000-tmp1;
  455.                 ea = make_data_array_cust(ea, 4, form(cmd_opc,tmp2,tmp1));
  456.             } else if((tmp0>=0x10)&&(tmp0<=0x13)) {     // ofs arg, no exec
  457.                 tmp1 = get_name_offset_custom(ea + 2,0,mmc,last_bank,defb1,defb2);
  458.                 ea = make_data_array_cust(ea, 2, form(cmd_opc,tmp1));
  459.                 ea = make_offset_custom(ea, 0, mmc, last_bank, defb1, defb2);
  460.             } else if((tmp0==0x18)||(tmp0==0x19)) {     // dword arg
  461.                 tmp1 = Dword(ea + 2);
  462.                 ea = make_data_array_cust(ea, 6, form(cmd_opc,tmp1));
  463.             } else {
  464.                 Message(" unknown 32-bit arithmetic opcode at 0x%08x = %02x\n", ea, tmp0);
  465.                 return ea;
  466.             }
  467.         } else {
  468.             Message(" unknown script opcode at 0x%08x = %02x\n", ea, cmd);
  469.             return ea;
  470.         }
  471.     } else {
  472.         Message(" bad address.\n",ea);
  473.         return ea;
  474.     }
  475.     }           // WHILE END, NO INDENTION!!
  476.     return ea;
  477. }
  478.  
  479. #ifdef MANUAL
  480. static koei_script_selection(void) {
  481.     Jump(
  482.         koei_disasm(ScreenEA(),BADADDR, MMC, LAST_BANK, -1, -1)//;
  483.     );
  484. }
  485. #endif
  486.  
  487. static makevarnotlove(ea,name,len) {
  488.     if(len) {
  489.         MakeUnknown(ea, len, DOUNK_SIMPLE);
  490.         MakeWord(ea);
  491.         MakeData(ea, FF_BYTE, len, 0);
  492.         SetArrayFormat(ea, AP_IDXHEX|AP_ALLOWDUPS, 0x10, 0);
  493.     }
  494.     MakeNameEx(ea,name,SN_CHECK|SN_NOWARN);
  495. }
  496.  
  497. static ea_to_pattern(ea,mmc,last_bank) {
  498.     auto tmp0, bank = GetReg(ea,"ds")-1;
  499.     if(mmc == 1) {
  500.         if(bank == last_bank)
  501.             tmp0 = (ea&0x3FFF)|0xC000;
  502.         else
  503.             tmp0 = (ea&0x3FFF)|0x8000;
  504.     } if(mmc == 5) {
  505.         if(bank < (last_bank-1)) {
  506.             if(SegStart(MK_FP(AskSelector(bank+1),0x8000)) != BADADDR)
  507.                 tmp0 = (ea&0x1FFF)|0x8000;
  508.             else if(SegStart(MK_FP(AskSelector(bank+1),0xA000)) != BADADDR)
  509.                 tmp0 = (ea&0x1FFF)|0xA000;
  510.         } else if((bank&1)==0)
  511.             tmp0 = (ea&0x1FFF)|0xC000;
  512.         else
  513.             tmp0 = (ea&0x1FFF)|0xE000;
  514.     }
  515.     return form("20 %02X %02X", tmp0&0xFF, tmp0>>8);    // JSR opcode pattern
  516. }
  517.  
  518. static auto_search_pattern(pattern, name,mmc,last_bank) {
  519.     auto tmp0;
  520.     tmp0 = FindBinary(0, SEARCH_DOWN|SEARCH_CASE, pattern);
  521.     if(tmp0 != BADADDR) {
  522.         makevarnotlove(tmp0,name,0);
  523.         Message("Found \"%s\" at 0x%08X.\n",name,tmp0);
  524.         return ea_to_pattern(tmp0,mmc,last_bank);
  525.     } else {
  526.         Message("Can't find \"%s\".\n",name);
  527.         return -1;
  528.     }
  529. }
  530.  
  531. static main(void) {
  532.     auto tmp0, tmp1;
  533.  
  534. // A0 17 B1 02 99 4E 00 88 C0 01 D0 F6 A9 ?? 48 A9 ?? 48 08 - bios_call_args
  535. // 85 50 A9 ?? 85 51 A9 ?? 48 A9 16 48 08 6C ?? ?? EA 60    - bios_call_fast
  536.  
  537. #ifdef MANUAL
  538.     makevarnotlove(0,"_reg0",2);
  539.     makevarnotlove(2,"_regSP",2);
  540.     makevarnotlove(4,"_regHP",2);
  541.     makevarnotlove(6,"_regPC",2);
  542.     makevarnotlove(8,"_regA",4);
  543.     makevarnotlove(0xC,"_regB",4);
  544.     makevarnotlove(0x10,"_reg32",4);
  545.     makevarnotlove(0x50,"_bios_args",22);
  546.     makevarnotlove(0x66,"_bios_result",2);
  547.     makevarnotlove(0x100,"_cpu_stack",256);
  548.     makevarnotlove(0x200,"_scr_stack",1024);
  549.     makevarnotlove(0x600,"_spr_buf",256);
  550.  
  551.     if(MMC == 5) {
  552.         makevarnotlove(0x5100,"_MMC5_PRG_SIZE",1);
  553.         makevarnotlove(0x5101,"_MMC5_CHR_SIZE",1);
  554.         makevarnotlove(0x5102,"_MMC5_WRAM0_ENABLE",1);
  555.         makevarnotlove(0x5103,"_MMC5_WRAM1_ENABLE",1);
  556.         makevarnotlove(0x5104,"_MMC5_CHR_MODE",1);
  557.         makevarnotlove(0x5105,"_MMC5_NT_MODE",1);
  558.         makevarnotlove(0x5106,"_MMC5_NT_FILL",1);
  559.         makevarnotlove(0x5107,"_MMC5_AT_FILL",12);
  560.         makevarnotlove(0x5113,"_MMC5_PRG_PAGES",5);
  561.         makevarnotlove(0x5120,"_MMC5_CHR_BANKSA",8);
  562.         makevarnotlove(0x5128,"_MMC5_CHR_BANKSB",8);
  563.         makevarnotlove(0x5200,"_MMC5_SP_MODE",1);
  564.         makevarnotlove(0x5201,"_MMC5_SP_SCROLL",1);
  565.         makevarnotlove(0x5202,"_MMC5_SP_PAGE",2);
  566.         makevarnotlove(0x5204,"_MMC5_IRQ_ENABLE",1);
  567.         makevarnotlove(0x5205,"_MMC5_MUL0",1);
  568.         makevarnotlove(0x5206,"_MMC5_MUL1",1);
  569.         makevarnotlove(0x5C00,"_MMC5_EXRAM",1024);
  570.     }
  571.  
  572.     AddHotkey("Shift-O", "koei_script_selection");
  573.  
  574.     #ifdef AUTODETECT
  575.     // search for native version of "EJSR ofs, sp+N" opcode
  576.     tmp0 = auto_search_pattern("68 85 00 68 85 01 38 A0 03 A5 02 F1 00 85 02 B0 02 C6 03", "_native_procedure_call_param",MMC,LAST_BANK);
  577.     if(tmp0 != -1) native_calls_search(tmp0,MMC,LAST_BANK,-1,-1);
  578.  
  579.     // search for native version of bytecode procedure execution routine (prepares stack, do bytecode stack backup)
  580.     tmp0 = auto_search_pattern("68 85 08 68 85 09 18 68 69 01 85 00 68 69 00 85 01 A0 07", "_native_procedure_exec_param",MMC,LAST_BANK);
  581.     if(tmp0 != -1) parametric_fixsize(tmp0, 3);
  582.  
  583.     // search for all bytecode procedure execution routines
  584.     tmp0 = FindBinary(0, SEARCH_DOWN|SEARCH_CASE, "68 85 08 68 85 09 68 85 00 68 85 01 A0 07 38");
  585.     if(tmp0 != BADADDR)
  586.         makevarnotlove(tmp0,"_procedure_exec_param",0);
  587.         Message("Found \"_procedure_exec_param\" at 0x%08X.\n",tmp0);
  588.         tmp1 = ea_to_pattern(tmp0,MMC,LAST_BANK);
  589.         tmp0 = -1;
  590.         parametric_stopbytes(tmp1, "CF");   // first pass, protects from auto code
  591.         Message(" Procedure auto search start.\n");
  592.         while ((tmp0 = FindBinary(tmp0 + 1, SEARCH_DOWN|SEARCH_CASE, tmp1)) != BADADDR) {
  593.             Message(" >found one at 0x%08X.\n",tmp0);
  594.             make_data_array_cust(tmp0 + 3, 2, "");
  595.             MakeCode(tmp0);
  596.             AutoMark(tmp0, AU_CODE);
  597.             Wait();
  598.             koei_disasm(tmp0,BADADDR,MMC,LAST_BANK,-1,-1);
  599.         }
  600.         Message(" Done!\n");
  601.     #endif
  602.  
  603. #else
  604.  
  605.     auto md5 = GetInputMD5();
  606.  
  607.     if (md5=="42C744D52C85EB55974586E470842DC1") {
  608.         Message(" Start Gemfire decompilation.\n");
  609.         koei_disasm(0x008003, 0x00978C, 5, 0x1F, -1, -1);
  610.         koei_disasm(0x020003, 0x020824, 5, 0x1F, -1, -1);
  611.         koei_disasm(0x038142, 0x039E77, 5, 0x1F, -1, -1);
  612.         koei_disasm(0x06A003, 0x06B700, 5, 0x1F, -1, -1);
  613.         koei_disasm(0x084003, 0x084D83, 5, 0x1F, -1, -1);
  614.         koei_disasm(0x09E003, 0x09ED41, 5, 0x1F, -1, -1);
  615.         koei_disasm(0x0B6003, 0x0B7472, 5, 0x1F, -1, -1);
  616.         koei_disasm(0x0CE003, 0x0CEECB, 5, 0x1F, -1, -1);
  617.         koei_disasm(0x0E6003, 0x0E7710, 5, 0x1F, -1, -1);
  618.         koei_disasm(0x0E7A16, 0x0E7C6D, 5, 0x1F, -1, -1);
  619.         koei_disasm(0x102003, 0x102E93, 5, 0x1F, -1, -1);
  620.         koei_disasm(0x11A003, 0x11AA70, 5, 0x1F, -1, -1);
  621.         koei_disasm(0x132003, 0x133FFE, 5, 0x1F, -1, -1);
  622.         koei_disasm(0x14C000, 0x14C325, 5, 0x1F, -1, -1);
  623.         koei_disasm(0x164003, 0x1659DD, 5, 0x1F, -1, -1);
  624.         koei_disasm(0x196003, 0x1978F2, 5, 0x1F, -1, -1);
  625.         koei_disasm(0x2F6003, 0x2F618F, 5, 0x1F, -1, -1);
  626.         koei_disasm(0x2F622D, 0x2F7E53, 5, 0x1F, -1, -1);
  627.         koei_disasm(0x2F7F3B, 0x2F7FA9, 5, 0x1F, -1, -1);
  628.     } else if (md5=="23FE0C32B5480F063110A90313735C71") {
  629.         Message(" Start Royal Blood decompilation.\n");
  630.         koei_disasm(0x008003, 0x009607, 5, 0x1F, -1, -1);
  631.         koei_disasm(0x020003, 0x020578, 5, 0x1F, -1, -1);
  632.         koei_disasm(0x038003, 0x039E88, 5, 0x1F, -1, -1);
  633.         koei_disasm(0x06A003, 0x06B698, 5, 0x1F, -1, -1);
  634.         koei_disasm(0x084003, 0x084DDB, 5, 0x1F, -1, -1);
  635.         koei_disasm(0x09E003, 0x09ECE2, 5, 0x1F, -1, -1);
  636.         koei_disasm(0x0B8003, 0x0B9309, 5, 0x1F, -1, -1);
  637.         koei_disasm(0x0D0003, 0x0D0EA6, 5, 0x1F, -1, -1);
  638.         koei_disasm(0x0E8003, 0x0E9725, 5, 0x1F, -1, -1);
  639.         koei_disasm(0x0E99B4, 0x0E9BFB, 5, 0x1F, -1, -1);
  640.         koei_disasm(0x104003, 0x1052E0, 5, 0x1F, -1, -1);
  641.         koei_disasm(0x11C003, 0x11CA70, 5, 0x1F, -1, -1);
  642.         koei_disasm(0x134003, 0x135FFE, 5, 0x1F, -1, -1);
  643.         koei_disasm(0x14E000, 0x14E530, 5, 0x1F, -1, -1);
  644.         koei_disasm(0x166003, 0x16796A, 5, 0x1F, -1, -1);
  645.         koei_disasm(0x198003, 0x1998F2, 5, 0x1F, -1, -1);
  646.         koei_disasm(0x300003, 0x30018F, 5, 0x1F, -1, -1);
  647.         koei_disasm(0x30022D, 0x301DA1, 5, 0x1F, -1, -1);
  648.         koei_disasm(0x301E89, 0x301ED8, 5, 0x1F, -1, -1);
  649.     } else if (md5=="9C77BD2874CB7F80AA8A05919203300C") {
  650.         Message(" Start Aoki Ookami 1 decompilation.\n");
  651.         koei_disasm(0x008003, 0x00B11A, 1, 0xF, -1, -1);
  652.         koei_disasm(0x020003, 0x02311F, 1, 0xF, -1, -1);
  653.         koei_disasm(0x038003, 0x03B3E7, 1, 0xF, -1, -1);
  654.         koei_disasm(0x050003, 0x0518DA, 1, 0xF, -1, -1);
  655.         koei_disasm(0x068003, 0x069700, 1, 0xF, -1, -1);
  656.         koei_disasm(0x080003, 0x083B4A, 1, 0xF, -1, -1);
  657.         koei_disasm(0x098003, 0x0980AA, 1, 0xF, -1, -1);
  658.         koei_disasm(0x0F8003, 0x0F8232, 1, 0xF, -1, -1);
  659.         koei_disasm(0x140003, 0x14028B, 1, 0xF, -1, -1);
  660.         koei_disasm(0x174A03, 0x176D30, 1, 0xF, -1, -1);
  661.     } else if (md5=="C7F80A7E1A2A5335AF114CAC7B424ACF") {
  662.         Message(" Start Genghis Khan 1 decompilation.\n");
  663.         koei_disasm(0x008003, 0x00B21B, 1, 0xF, -1, -1);
  664.         koei_disasm(0x020003, 0x022FB0, 1, 0xF, -1, -1);
  665.         koei_disasm(0x038003, 0x03ADE3, 1, 0xF, -1, -1);
  666.         koei_disasm(0x050003, 0x051BC2, 1, 0xF, -1, -1);
  667.         koei_disasm(0x068003, 0x069768, 1, 0xF, -1, -1);
  668.         koei_disasm(0x080003, 0x083BB1, 1, 0xF, -1, -1);
  669.         koei_disasm(0x098003, 0x0980AA, 1, 0xF, -1, -1);
  670.         koei_disasm(0x0F8003, 0x0F8232, 1, 0xF, -1, -1);
  671.         koei_disasm(0x140003, 0x14028B, 1, 0xF, -1, -1);
  672.         koei_disasm(0x174B03, 0x176DC2, 1, 0xF, -1, -1);
  673.     } else if (md5=="5EF1BA9461974F34B0633EAF063490DD") {
  674.         Message(" Start Bandit Kings decompilation.\n");
  675.         koei_disasm(0x008003, 0x008C25, 5, 0x1F, -1, -1);
  676.         koei_disasm(0x008CE9, 0x009366, 5, 0x1F, -1, -1);
  677.         koei_disasm(0x020003, 0x021B3A, 5, 0x1F, -1, -1);
  678.         koei_disasm(0x03A003, 0x03A7DD, 5, 0x1F, -1, -1);
  679.         koei_disasm(0x03B003, 0x03BD91, 5, 0x1F, -1, -1);
  680.         koei_disasm(0x054003, 0x055AF5, 5, 0x1F, -1, -1);
  681.         koei_disasm(0x06E003, 0x06F7A2, 5, 0x1F, -1, -1);
  682.         koei_disasm(0x088003, 0x08924A, 5, 0x1F, -1, -1);
  683.         koei_disasm(0x0A2003, 0x0A32B3, 5, 0x1F, -1, -1);
  684.         koei_disasm(0x0A3357, 0x0A3609, 5, 0x1F, -1, -1);
  685.         koei_disasm(0x0BC003, 0x0BD9F5, 5, 0x1F, -1, -1);
  686.         koei_disasm(0x0D6003, 0x0D71DB, 5, 0x1F, -1, -1);
  687.         koei_disasm(0x0EE003, 0x0EFBD7, 5, 0x1F, -1, -1);
  688.         koei_disasm(0x108003, 0x1096B8, 5, 0x1F, -1, -1);
  689.         koei_disasm(0x122003, 0x12395B, 5, 0x1F, -1, -1);
  690.         koei_disasm(0x13A003, 0x13BFFF, 5, 0x1F, -1, -1);
  691.         koei_disasm(0x154000, 0x155286, 5, 0x1F, -1, -1);
  692.         koei_disasm(0x16C003, 0x16DFFF, 5, 0x1F, -1, -1);
  693.         koei_disasm(0x186000, 0x187038, 5, 0x1F, -1, -1);
  694.         koei_disasm(0x1A0003, 0x1A140A, 5, 0x1F, -1, -1);
  695.         koei_disasm(0x29C003, 0x29C3D4, 5, 0x1F, -1, -1);
  696.         koei_disasm(0x304190, 0x305D5B, 5, 0x1F, -1, -1);
  697.         koei_disasm(0x322003, 0x3223BE, 5, 0x1F, -1, -1);
  698.     } else if (md5=="862DFE1D1345A8903819DFB0614E3D88") {
  699.         Message(" Start Suikoden decompilation.\n");
  700.         koei_disasm(0x008003, 0x008BF8, 5, 0x1F, -1, -1);
  701.         koei_disasm(0x008CBC, 0x0098E3, 5, 0x1F, -1, -1);
  702.         koei_disasm(0x020003, 0x021B63, 5, 0x1F, -1, -1);
  703.         koei_disasm(0x03A003, 0x03A81B, 5, 0x1F, 1, -1);    // first half of bank uses 1 as library
  704.         koei_disasm(0x03B003, 0x03BDD5, 5, 0x1F, 9, -1);    // second half uses 9 instead
  705.         koei_disasm(0x054003, 0x055AEB, 5, 0x1F, 1, -1);
  706.         koei_disasm(0x06E003, 0x06F991, 5, 0x1F, 1, -1);
  707.         koei_disasm(0x086003, 0x087307, 5, 0x1F, 1, -1);
  708.         koei_disasm(0x0A0003, 0x0A1130, 5, 0x1F, 1, -1);
  709.         koei_disasm(0x0A11D4, 0x0A1486, 5, 0x1F, 1, -1);
  710.         koei_disasm(0x0BA003, 0x0BBA02, 5, 0x1F, 1, -1);
  711.         koei_disasm(0x0D4003, 0x0D51CB, 5, 0x1F, 1, -1);
  712.         koei_disasm(0x0EC003, 0x0EDBBC, 5, 0x1F, -1, -1);
  713.         koei_disasm(0x106003, 0x1076E5, 5, 0x1F, 9, -1);
  714.         koei_disasm(0x120003, 0x121958, 5, 0x1F, 9, -1);
  715.         koei_disasm(0x138003, 0x139FFF, 5, 0x1F, -1, 0xD);  // paired banks, goes together always
  716.         koei_disasm(0x152000, 0x153244, 5, 0x1F, 0xC, -1);
  717.         koei_disasm(0x16A003, 0x16BFFF, 5, 0x1F, -1, 0xF);
  718.         koei_disasm(0x184000, 0x185064, 5, 0x1F, 0xE, -1);
  719.         koei_disasm(0x19E003, 0x19F452, 5, 0x1F, -1, -1);
  720.         koei_disasm(0x302190, 0x303C76, 5, 0x1F, -1, -1);
  721.         koei_disasm(0x320003, 0x3203B8, 5, 0x1F, -1, -1);
  722.     } else if (md5=="60F52E9EF4B97E52AB6D47BE73DA815F") {
  723.         Message(" Start L'Empereur usa decompilation.\n");
  724.         koei_disasm(0x00A003, 0x00B4E4, 5, 0x1F, -1, -1);
  725.         koei_disasm(0x022003, 0x0230A3, 5, 0x1F, -1, -1);
  726.         koei_disasm(0x03C003, 0x03D03B, 5, 0x1F, -1, -1);
  727.         koei_disasm(0x056003, 0x057E1F, 5, 0x1F, -1, -1);
  728.         koei_disasm(0x070003, 0x071A38, 5, 0x1F, -1, -1);
  729.         koei_disasm(0x08A003, 0x08BCFF, 5, 0x1F, -1, -1);
  730.         koei_disasm(0x0A4003, 0x0A5A1F, 5, 0x1F, -1, -1);
  731.         koei_disasm(0x0BE003, 0x0BFED3, 5, 0x1F, -1, -1);
  732.         koei_disasm(0x0D8003, 0x0D9455, 5, 0x1F, -1, -1);
  733.         koei_disasm(0x0F2003, 0x0F3AD2, 5, 0x1F, -1, -1);
  734.         koei_disasm(0x10A003, 0x10B8E6, 5, 0x1F, -1, -1);
  735.         koei_disasm(0x124003, 0x125C84, 5, 0x1F, -1, -1);
  736.         koei_disasm(0x13E003, 0x13EF11, 5, 0x1F, -1, -1);
  737.         koei_disasm(0x158194, 0x159BFC, 5, 0x1F, -1, -1);
  738.         koei_disasm(0x172003, 0x1731BE, 5, 0x1F, -1, -1);
  739.         koei_disasm(0x18A003, 0x18A781, 5, 0x1F, -1, -1);
  740.         koei_disasm(0x1A2003, 0x1A314F, 5, 0x1F, -1, -1);
  741.         koei_disasm(0x1BA003, 0x1BBFFD, 5, 0x1F, -1, -1);
  742.         koei_disasm(0x1D4000, 0x1D4CDF, 5, 0x1F, -1, -1);
  743.         koei_disasm(0x304003, 0x30530F, 5, 0x1F, -1, -1);
  744.         koei_disasm(0x322003, 0x3221C0, 5, 0x1F, -1, -1);
  745.     } else if (md5=="0F7EB49332C0ACF1D97FC63A08C485C3") {
  746.         Message(" Start L'Empereur japan decompilation.\n");
  747.         koei_disasm(0x00A003, 0x00B499, 5, 0x1F, -1, -1);
  748.         koei_disasm(0x022003, 0x0230B8, 5, 0x1F, -1, -1);
  749.         koei_disasm(0x03C003, 0x03D022, 5, 0x1F, -1, -1);
  750.         koei_disasm(0x056003, 0x057E1B, 5, 0x1F, -1, -1);
  751.         koei_disasm(0x070003, 0x071A3D, 5, 0x1F, -1, -1);
  752.         koei_disasm(0x08A003, 0x08BCF4, 5, 0x1F, -1, -1);
  753.         koei_disasm(0x0A4003, 0x0A5A11, 5, 0x1F, -1, -1);
  754.         koei_disasm(0x0BE003, 0x0BFEBD, 5, 0x1F, -1, -1);
  755.         koei_disasm(0x0D8003, 0x0D9455, 5, 0x1F, -1, -1);
  756.         koei_disasm(0x0F2003, 0x0F3AE6, 5, 0x1F, -1, -1);
  757.         koei_disasm(0x10A003, 0x10B8A6, 5, 0x1F, -1, -1);
  758.         koei_disasm(0x124003, 0x125C5F, 5, 0x1F, -1, -1);
  759.         koei_disasm(0x13E003, 0x13EF0C, 5, 0x1F, -1, -1);
  760.         koei_disasm(0x158194, 0x159BDC, 5, 0x1F, -1, -1);
  761.         koei_disasm(0x172003, 0x1731BE, 5, 0x1F, -1, -1);
  762.         koei_disasm(0x18A003, 0x18A6FE, 5, 0x1F, -1, -1);
  763.         koei_disasm(0x1A2003, 0x1A312C, 5, 0x1F, -1, -1);
  764.         koei_disasm(0x1BA003, 0x1BBFFF, 5, 0x1F, -1, -1);
  765.         koei_disasm(0x1D4001, 0x1D4C95, 5, 0x1F, -1, -1);
  766.         koei_disasm(0x302003, 0x30335E, 5, 0x1F, -1, -1);
  767.         koei_disasm(0x320003, 0x3201A9, 5, 0x1F, -1, -1);
  768.     } else if (md5=="B35C3CBB57EF285A24EA35426BEB8D3C") {
  769.         Message(" Start Romance of Three Kingdoms decompilation.\n");
  770.         koei_disasm(0x008003, 0x00A26C, 1, 0xF, -1, -1);
  771.         koei_disasm(0x020089, 0x023A4C, 1, 0xF, -1, -1);
  772.         koei_disasm(0x038003, 0x03A6FC, 1, 0xF, -1, -1);
  773.         koei_disasm(0x050003, 0x052553, 1, 0xF, -1, -1);
  774.         koei_disasm(0x0F8003, 0x0F82DA, 1, 0xF, -1, -1);
  775.         koei_disasm(0x129603, 0x12A6FC, 1, 0xF, -1, -1);
  776.         koei_disasm(0x1749C3, 0x176EB3, 1, 0xF, -1, -1);
  777.     } else if (md5=="B2A5321E8625D74F9CCC9BD475472FDC") {
  778.         Message(" Start Sangokushi decompilation.\n");
  779.         koei_disasm(0x008003, 0x00A23E, 1, 0xF, -1, -1);
  780.         koei_disasm(0x020089, 0x023A5B, 1, 0xF, -1, -1);
  781.         koei_disasm(0x038003, 0x03ABB3, 1, 0xF, -1, -1);
  782.         koei_disasm(0x050003, 0x05251F, 1, 0xF, -1, -1);
  783.         koei_disasm(0x0F8003, 0x0F82DA, 1, 0xF, -1, -1);
  784.         koei_disasm(0x129603, 0x12A703, 1, 0xF, -1, -1);
  785.         koei_disasm(0x1749C3, 0x177062, 1, 0xF, -1, -1);
  786.     } else if (md5=="A185F95B3AE2209644C2D9885DFA1A3B") {
  787.         Message(" Start Nobunaga's Ambitions decompilation.\n");
  788.         koei_disasm(0x008003, 0x00A849, 1, 0xF, -1, -1);
  789.         koei_disasm(0x020003, 0x0239B1, 1, 0xF, -1, -1);
  790.         koei_disasm(0x038086, 0x03B0B8, 1, 0xF, -1, -1);
  791.         koei_disasm(0x0F8003, 0x0F808E, 1, 0xF, -1, -1);
  792.         koei_disasm(0x158003, 0x158225, 1, 0xF, -1, -1);
  793.         koei_disasm(0x174A03, 0x174BCC, 1, 0xF, -1, -1);
  794.         koei_disasm(0x174C35, 0x176822, 1, 0xF, -1, -1);
  795.     } else if (md5=="44B65B5E88CF5A329F7A08C8A2D9F672") {
  796.         Message(" Start Nobunaga no Yabou decompilation.\n");
  797.         koei_disasm(0x008003, 0x00A83A, 1, 0xF, -1, -1);
  798.         koei_disasm(0x020003, 0x023980, 1, 0xF, -1, -1);
  799.         koei_disasm(0x038003, 0x03AFF6, 1, 0xF, -1, -1);
  800.         koei_disasm(0x0F8003, 0x0F808E, 1, 0xF, -1, -1);
  801.         koei_disasm(0x158003, 0x158225, 1, 0xF, -1, -1);
  802.         koei_disasm(0x174A03, 0x174BCC, 1, 0xF, -1, -1);
  803.         koei_disasm(0x174C35, 0x1767EE, 1, 0xF, -1, -1);
  804.     } else if (md5=="967FB047B19FB85DDA51B88A3FF72B94") {
  805.         Message(" Start Nobunaga no Yabou revA decompilation.\n");
  806.         koei_disasm(0x008003, 0x00A83A, 1, 0xF, -1, -1);
  807.         koei_disasm(0x020003, 0x0239AB, 1, 0xF, -1, -1);
  808.         koei_disasm(0x038003, 0x03B016, 1, 0xF, -1, -1);
  809.         koei_disasm(0x0F8003, 0x0F808E, 1, 0xF, -1, -1);
  810.         koei_disasm(0x158003, 0x158225, 1, 0xF, -1, -1);
  811.         koei_disasm(0x174A03, 0x174BCC, 1, 0xF, -1, -1);
  812.         koei_disasm(0x174C35, 0x176817, 1, 0xF, -1, -1);
  813.     } else if (md5=="A33DFE9E4ADC67321877042F51877687") {
  814.         Message(" Start Nobunaga's Ambition 2 decompilation.\n");
  815.         koei_disasm(0x00A003, 0x00BA8C, 5, 0x1F, -1, -1);
  816.         koei_disasm(0x022003, 0x022ED0, 5, 0x1F, -1, -1);
  817.         koei_disasm(0x03A003, 0x03BA95, 5, 0x1F, -1, -1);
  818.         koei_disasm(0x054003, 0x0554AD, 5, 0x1F, -1, -1);
  819.         koei_disasm(0x06E003, 0x06F9DB, 5, 0x1F, -1, -1);
  820.         koei_disasm(0x088003, 0x08994B, 5, 0x1F, -1, -1);
  821.         koei_disasm(0x0A2003, 0x0A3843, 5, 0x1F, -1, -1);
  822.         koei_disasm(0x0BC003, 0x0BD32C, 5, 0x1F, -1, -1);
  823.         koei_disasm(0x0D6003, 0x0D6C3D, 5, 0x1F, -1, -1);
  824.         koei_disasm(0x0EE003, 0x0EFA90, 5, 0x1F, -1, -1);
  825.         koei_disasm(0x108003, 0x109B96, 5, 0x1F, -1, -1);
  826.         koei_disasm(0x122003, 0x1236F0, 5, 0x1F, -1, -1);
  827.         koei_disasm(0x13A003, 0x13BCDA, 5, 0x1F, -1, -1);
  828.         koei_disasm(0x16C003, 0x16DFFE, 5, 0x1F, -1, -1);
  829.         koei_disasm(0x186001, 0x186F97, 5, 0x1F, -1, -1);
  830.         koei_disasm(0x19E003, 0x19F688, 5, 0x1F, -1, -1);
  831.         koei_disasm(0x300003, 0x30158C, 5, 0x1F, -1, -1);
  832.         koei_disasm(0x31E003, 0x31E21F, 5, 0x1F, -1, -1);
  833.     } else if (md5=="C2240AAEBE0911C1684B656B7B5B8B0C") {
  834.         Message(" Start Nobunaga no Yabou 2 decompilation.\n");
  835.         koei_disasm(0x00A003, 0x00B99E, 5, 0x1F, -1, -1);
  836.         koei_disasm(0x022003, 0x022EF4, 5, 0x1F, -1, -1);
  837.         koei_disasm(0x03A003, 0x03BA98, 5, 0x1F, -1, -1);
  838.         koei_disasm(0x054003, 0x0552D7, 5, 0x1F, -1, -1);
  839.         koei_disasm(0x06E003, 0x06F9DE, 5, 0x1F, -1, -1);
  840.         koei_disasm(0x088003, 0x089AB5, 5, 0x1F, -1, -1);
  841.         koei_disasm(0x0A2003, 0x0A385F, 5, 0x1F, -1, -1);
  842.         koei_disasm(0x0BC003, 0x0BD301, 5, 0x1F, -1, -1);
  843.         koei_disasm(0x0D6003, 0x0D6C3C, 5, 0x1F, -1, -1);
  844.         koei_disasm(0x0EE003, 0x0EFABA, 5, 0x1F, -1, -1);
  845.         koei_disasm(0x108003, 0x109BBE, 5, 0x1F, -1, -1);
  846.         koei_disasm(0x122003, 0x1236F0, 5, 0x1F, -1, -1);
  847.         koei_disasm(0x13A003, 0x13BCA5, 5, 0x1F, -1, -1);
  848.         koei_disasm(0x16C003, 0x16DFFF, 5, 0x1F, -1, -1);
  849.         koei_disasm(0x186000, 0x18700A, 5, 0x1F, -1, -1);
  850.         koei_disasm(0x19E003, 0x19F5B7, 5, 0x1F, -1, -1);
  851.         koei_disasm(0x300003, 0x3014F7, 5, 0x1F, -1, -1);
  852.         koei_disasm(0x31E003, 0x31E21F, 5, 0x1F, -1, -1);
  853.     } else if (md5=="A53911F154FF89CE1BAF305126F6949F") {
  854.         #define UNCHARTED
  855.         Message(" Start Uncharted Waters decompilation.\n");
  856.         koei_disasm(0x008003, 0x009909, 5, 0x3F, -1, 1);
  857.         koei_disasm(0x022003, 0x022691, 5, 0x3F, -1, 1);
  858.         koei_disasm(0x022B2C, 0x023671, 5, 0x3F, -1, 1);
  859.         koei_disasm(0x0237CE, 0x023A8B, 5, 0x3F, -1, 1);
  860.         koei_disasm(0x03A003, 0x03AFC1, 5, 0x3F, -1, 1);
  861.         koei_disasm(0x082003, 0x082C74, 5, 0x3F, -1, 1);
  862.         koei_disasm(0x0CB8CB, 0x0CBBE3, 5, 0x3F, -1, 1);
  863.         koei_disasm(0x0E2003, 0x0E2061, 5, 0x3F, -1, 1);
  864.         koei_disasm(0x112003, 0x112370, 5, 0x3F, -1, 1);
  865.         koei_disasm(0x12C003, 0x12DCDC, 5, 0x3F, -1, 1);
  866.         koei_disasm(0x15E003, 0x15F5F7, 5, 0x3F, -1, 1);
  867.         koei_disasm(0x176003, 0x176D96, 5, 0x3F, -1, 1);
  868.         koei_disasm(0x190003, 0x1914E9, 5, 0x3F, -1, 1);
  869.         koei_disasm(0x1A8003, 0x1A874D, 5, 0x3F, -1, 1);
  870.         koei_disasm(0x1A8DC3, 0x1A971F, 5, 0x3F, -1, 1);
  871.         koei_disasm(0x1C0003, 0x1C12B0, 5, 0x3F, -1, 1);
  872.         koei_disasm(0x1D8003, 0x1D94D5, 5, 0x3F, -1, 1);
  873.         koei_disasm(0x1F0003, 0x1F14C9, 5, 0x3F, -1, 1);
  874.         koei_disasm(0x208003, 0x209257, 5, 0x3F, -1, 1);
  875.         koei_disasm(0x220003, 0x22105C, 5, 0x3F, -1, 1);
  876.         koei_disasm(0x238003, 0x23917E, 5, 0x3F, -1, 1);
  877.         koei_disasm(0x250003, 0x2512B1, 5, 0x3F, -1, 1);
  878.         koei_disasm(0x268003, 0x269066, 5, 0x3F, -1, 1);
  879.         koei_disasm(0x280003, 0x280912, 5, 0x3F, -1, 1);
  880.         koei_disasm(0x298003, 0x299A68, 5, 0x3F, -1, 1);
  881.         koei_disasm(0x2B0003, 0x2B0B8D, 5, 0x3F, -1, 1);
  882.         koei_disasm(0x2C8003, 0x2C88CC, 5, 0x3F, -1, 1);
  883.         koei_disasm(0x2E0003, 0x2E0B9A, 5, 0x3F, -1, 1);
  884.         koei_disasm(0x35C003, 0x35C2B3, 5, 0x3F, -1, 1);
  885.         koei_disasm(0x374003, 0x374225, 5, 0x3F, -1, 1);
  886.         koei_disasm(0x38C003, 0x38C498, 5, 0x3F, -1, 1);
  887.         koei_disasm(0x3A6003, 0x3A673B, 5, 0x3F, -1, 1);
  888.         koei_disasm(0x60047B, 0x600EAC, 5, 0x3F, -1, 1);
  889.         koei_disasm(0x6014A5, 0x601CEB, 5, 0x3F, -1, 1);
  890.         koei_disasm(0x61E003, 0x61E0FF, 5, 0x3F, -1, 1);
  891.     } else if (md5=="F8B22A4C325C32071090492AC8174D0A") {
  892.         #define DAIKOKUJIDAI
  893.         Message(" Start Daikoukai Jidai decompilation.\n");
  894.         koei_disasm(0x008003, 0x0099C5, 5, 0x3F, -1, 1);
  895.         koei_disasm(0x022003, 0x022689, 5, 0x3F, -1, 1);
  896.         koei_disasm(0x022B24, 0x0235C5, 5, 0x3F, -1, 1);
  897.         koei_disasm(0x023722, 0x0239DF, 5, 0x3F, -1, 1);
  898.         koei_disasm(0x03A003, 0x03AE6A, 5, 0x3F, -1, 1);
  899.         koei_disasm(0x082003, 0x082C74, 5, 0x3F, -1, 1);
  900.         koei_disasm(0x0CB82D, 0x0CBB48, 5, 0x3F, -1, 1);
  901.         koei_disasm(0x0E2003, 0x0E2061, 5, 0x3F, -1, 1);
  902.         koei_disasm(0x112003, 0x112370, 5, 0x3F, -1, 1);
  903.         koei_disasm(0x12C003, 0x12DD18, 5, 0x3F, -1, 1);
  904.         koei_disasm(0x15E003, 0x15F5CA, 5, 0x3F, -1, 1);
  905.         koei_disasm(0x176003, 0x176D8B, 5, 0x3F, -1, 1);
  906.         koei_disasm(0x190003, 0x1914A0, 5, 0x3F, -1, 1);
  907.         koei_disasm(0x1A8003, 0x1A872C, 5, 0x3F, -1, 1);
  908.         koei_disasm(0x1A8DA2, 0x1A96A3, 5, 0x3F, -1, 1);
  909.         koei_disasm(0x1C2003, 0x1C32B7, 5, 0x3F, -1, 1);
  910.         koei_disasm(0x1DA003, 0x1DB562, 5, 0x3F, -1, 1);
  911.         koei_disasm(0x1F2003, 0x1F3496, 5, 0x3F, -1, 1);
  912.         koei_disasm(0x20A003, 0x20B23A, 5, 0x3F, -1, 1);
  913.         koei_disasm(0x222003, 0x22302D, 5, 0x3F, -1, 1);
  914.         koei_disasm(0x23A003, 0x23B1DD, 5, 0x3F, -1, 1);
  915.         koei_disasm(0x252003, 0x253307, 5, 0x3F, -1, 1);
  916.         koei_disasm(0x26A003, 0x26B0A8, 5, 0x3F, -1, 1);
  917.         koei_disasm(0x282003, 0x2828E0, 5, 0x3F, -1, 1);
  918.         koei_disasm(0x29A003, 0x29BA32, 5, 0x3F, -1, 1);
  919.         koei_disasm(0x2B4003, 0x2B4B8D, 5, 0x3F, -1, 1);
  920.         koei_disasm(0x2CC003, 0x2CC8CF, 5, 0x3F, -1, 1);
  921.         koei_disasm(0x2E4003, 0x2E4B78, 5, 0x3F, -1, 1);
  922.         koei_disasm(0x360003, 0x3602B3, 5, 0x3F, -1, 1);
  923.         koei_disasm(0x378003, 0x378225, 5, 0x3F, -1, 1);
  924.         koei_disasm(0x390003, 0x390167, 5, 0x3F, -1, 1);
  925.         koei_disasm(0x3A8003, 0x3A89C0, 5, 0x3F, -1, 1);
  926.         koei_disasm(0x60247B, 0x602EAC, 5, 0x3F, -1, 1);
  927.         koei_disasm(0x6034A5, 0x603CEB, 5, 0x3F, -1, 1);
  928.         koei_disasm(0x620003, 0x6200FF, 5, 0x3F, -1, 1);
  929.     } else if (md5=="13B9EE48FEABFB16851016E0EFC245C7") {
  930.         Message(" Start Famicom Top Management decompilation.\n");
  931.         koei_disasm(0x008003, 0x00B5F3, 1, 0xF, -1, -1);
  932.         koei_disasm(0x020003, 0x023159, 1, 0xF, -1, -1);
  933.         koei_disasm(0x038003, 0x03B8EC, 1, 0xF, -1, -1);
  934.         koei_disasm(0x050003, 0x052486, 1, 0xF, -1, -1);
  935.         koei_disasm(0x068003, 0x06B1B8, 1, 0xF, -1, -1);
  936.         koei_disasm(0x080003, 0x082E44, 1, 0xF, -1, -1);
  937.         koei_disasm(0x0F8003, 0x0FA187, 1, 0xF, -1, -1);
  938.         koei_disasm(0x128003, 0x129798, 1, 0xF, -1, -1);
  939.         koei_disasm(0x140003, 0x143BB1, 1, 0xF, -1, -1);
  940.         koei_disasm(0x174983, 0x17694E, 1, 0xF, -1, -1);
  941.     } else if (md5=="78D9B15C629CA983AC7D681685A67625") {
  942.         Message(" Start Ishin no Arashi decompilation.\n");
  943.         koei_disasm(0x008003, 0x008E0E, 5, 0x1F, -1, -1);
  944.         koei_disasm(0x022003, 0x023D24, 5, 0x1F, -1, -1);
  945.         koei_disasm(0x03A003, 0x03B7AC, 5, 0x1F, -1, -1);
  946.         koei_disasm(0x06C003, 0x06D418, 5, 0x1F, -1, -1);
  947.         koei_disasm(0x086003, 0x087429, 5, 0x1F, -1, -1);
  948.         koei_disasm(0x0A0003, 0x0A0E06, 5, 0x1F, -1, -1);
  949.         koei_disasm(0x0B8003, 0x0B9A93, 5, 0x1F, -1, -1);
  950.         koei_disasm(0x0D2003, 0x0D2A47, 5, 0x1F, -1, -1);
  951.         koei_disasm(0x0D2F77, 0x0D38DB, 5, 0x1F, -1, -1);
  952.         koei_disasm(0x0EC003, 0x0ED639, 5, 0x1F, -1, -1);
  953.         koei_disasm(0x106003, 0x106FE5, 5, 0x1F, -1, -1);
  954.         koei_disasm(0x11E003, 0x11F114, 5, 0x1F, -1, -1);
  955.         koei_disasm(0x138003, 0x139145, 5, 0x1F, -1, -1);
  956.         koei_disasm(0x150003, 0x1511E6, 5, 0x1F, -1, -1);
  957.         koei_disasm(0x168003, 0x169FFF, 5, 0x1F, -1, -1);
  958.         koei_disasm(0x182003, 0x183037, 5, 0x1F, -1, -1);
  959.         koei_disasm(0x2FC003, 0x2FD958, 5, 0x1F, -1, -1);
  960.         koei_disasm(0x31A003, 0x31A055, 5, 0x1F, -1, -1);
  961.     } else if (md5=="F47EF59EA3453BEA7C41385839FF9CA8") {
  962.         Message(" Start Romance of The Three Kingdoms 2 decompilation.\n");
  963.         koei_disasm(0x00A003, 0x00BA88, 5, 0x1F, -1, -1);
  964.         koei_disasm(0x022003, 0x023D31, 5, 0x1F, -1, -1);
  965.         koei_disasm(0x03C003, 0x03DB7D, 5, 0x1F, -1, -1);
  966.         koei_disasm(0x056003, 0x057BCE, 5, 0x1F, -1, -1);
  967.         koei_disasm(0x070003, 0x071DC6, 5, 0x1F, -1, -1);
  968.         koei_disasm(0x08A003, 0x08B813, 5, 0x1F, -1, -1);
  969.         koei_disasm(0x0A4003, 0x0A591B, 5, 0x1F, -1, -1);
  970.         koei_disasm(0x0BE003, 0x0BF8BC, 5, 0x1F, -1, -1);
  971.         koei_disasm(0x0D6003, 0x0D75FE, 5, 0x1F, -1, -1);
  972.         koei_disasm(0x0F0003, 0x0F1C39, 5, 0x1F, -1, -1);
  973.         koei_disasm(0x0F1E03, 0x0F1F0B, 5, 0x1F, -1, -1);
  974.         koei_disasm(0x10A003, 0x10BCDA, 5, 0x1F, -1, -1);
  975.         koei_disasm(0x124003, 0x125B6C, 5, 0x1F, -1, -1);
  976.         koei_disasm(0x13E003, 0x13FAA8, 5, 0x1F, -1, -1);
  977.         koei_disasm(0x156003, 0x157DD5, 5, 0x1F, -1, -1);
  978.         koei_disasm(0x170C03, 0x171B99, 5, 0x1F, -1, -1);
  979.         koei_disasm(0x188003, 0x189FFE, 5, 0x1F, -1, -1);
  980.         koei_disasm(0x1A2000, 0x1A2543, 5, 0x1F, -1, -1);
  981.         koei_disasm(0x1A2E12, 0x1A3329, 5, 0x1F, -1, -1);
  982.         koei_disasm(0x1BA003, 0x1BB846, 5, 0x1F, -1, -1);
  983.         koei_disasm(0x1D2003, 0x1D2CA6, 5, 0x1F, -1, -1);
  984.         koei_disasm(0x206103, 0x2067E7, 5, 0x1F, -1, -1);
  985.         koei_disasm(0x207D03, 0x207F6B, 5, 0x1F, -1, -1);
  986.         koei_disasm(0x220003, 0x2207FA, 5, 0x1F, -1, -1);
  987.         koei_disasm(0x220A83, 0x220C25, 5, 0x1F, -1, -1);
  988.         koei_disasm(0x220D83, 0x220ECD, 5, 0x1F, -1, -1);
  989.         koei_disasm(0x304003, 0x3055D0, 5, 0x1F, -1, -1);
  990.         koei_disasm(0x322003, 0x322257, 5, 0x1F, -1, -1);
  991.     } else if (md5=="0694CF9EBCDC9318EF67B45D0A44E2DF") {
  992.         Message(" Start Sangokushi 2 decompilation.\n");
  993.         koei_disasm(0x00A003, 0x00BA44, 5, 0x1F, -1, -1);
  994.         koei_disasm(0x022003, 0x023D35, 5, 0x1F, -1, -1);
  995.         koei_disasm(0x03C003, 0x03DBF9, 5, 0x1F, 1, -1);    // bank 1 visible from banks 2-7
  996.         koei_disasm(0x056003, 0x057D71, 5, 0x1F, 1, -1);
  997.         koei_disasm(0x070003, 0x071F12, 5, 0x1F, 1, -1);
  998.         koei_disasm(0x08A003, 0x08BAF4, 5, 0x1F, 1, -1);
  999.         koei_disasm(0x0A4003, 0x0A5AE0, 5, 0x1F, 1, -1);
  1000.         koei_disasm(0x0BE003, 0x0BFA78, 5, 0x1F, 1, -1);
  1001.         koei_disasm(0x0D6003, 0x0D75D1, 5, 0x1F, -1, -1);
  1002.         koei_disasm(0x0F0003, 0x0F1C2B, 5, 0x1F, -1, -1);
  1003.         koei_disasm(0x10A003, 0x10BC3E, 5, 0x1F, -1, -1);
  1004.         koei_disasm(0x124003, 0x125AB7, 5, 0x1F, -1, -1);
  1005.         koei_disasm(0x13E003, 0x13FADE, 5, 0x1F, -1, -1);
  1006.         koei_disasm(0x156003, 0x157DB6, 5, 0x1F, -1, -1);
  1007.         koei_disasm(0x170A03, 0x171B50, 5, 0x1F, -1, -1);
  1008.         koei_disasm(0x188003, 0x189FFE, 5, 0x1F, -1, -1);
  1009.         koei_disasm(0x1A2000, 0x1A24F5, 5, 0x1F, -1, -1);
  1010.         koei_disasm(0x1A2D12, 0x1A31A7, 5, 0x1F, -1, -1);
  1011.         koei_disasm(0x1BA003, 0x1BB87D, 5, 0x1F, -1, -1);
  1012.         koei_disasm(0x1D2003, 0x1D2A8B, 5, 0x1F, -1, -1);
  1013.         koei_disasm(0x206103, 0x2067E9, 5, 0x1F, -1, -1);
  1014.         koei_disasm(0x207D03, 0x207F6B, 5, 0x1F, -1, -1);
  1015.         koei_disasm(0x304003, 0x30557A, 5, 0x1F, -1, -1);
  1016.         koei_disasm(0x322003, 0x322204, 5, 0x1F, -1, -1);
  1017.     } else if (md5=="E0359CFF7EDFFF4C8BDF4C61D8451305") {
  1018.         Message(" Start Nobunaga no Yabou 3 decompilation.\n");
  1019.         koei_disasm(0x00A003, 0x00BC6A, 5, 0x3F, -1, -1);
  1020.         koei_disasm(0x024003, 0x024B0C, 5, 0x3F, -1, -1);
  1021.         koei_disasm(0x03C003, 0x03CFD4, 5, 0x3F, -1, -1);
  1022.         koei_disasm(0x054003, 0x054208, 5, 0x3F, -1, -1);
  1023.         koei_disasm(0x06C003, 0x06CE54, 5, 0x3F, -1, -1);
  1024.         koei_disasm(0x086003, 0x087DAD, 5, 0x3F, -1, -1);
  1025.         koei_disasm(0x0A0003, 0x0A0DC6, 5, 0x3F, -1, -1);
  1026.         koei_disasm(0x0B8003, 0x0B9CC9, 5, 0x3F, -1, -1);
  1027.         koei_disasm(0x0D2003, 0x0D361D, 5, 0x3F, -1, -1);
  1028.         koei_disasm(0x0EC003, 0x0EDCC9, 5, 0x3F, -1, -1);
  1029.         koei_disasm(0x106003, 0x107B14, 5, 0x3F, -1, -1);
  1030.         koei_disasm(0x120003, 0x121845, 5, 0x3F, -1, -1);
  1031.         koei_disasm(0x13A003, 0x13BF66, 5, 0x3F, -1, -1);
  1032.         koei_disasm(0x154003, 0x155E9A, 5, 0x3F, -1, -1);
  1033.         koei_disasm(0x16C003, 0x16CFED, 5, 0x3F, -1, -1);
  1034.         koei_disasm(0x184003, 0x1855B3, 5, 0x3F, -1, -1);
  1035.         koei_disasm(0x19C003, 0x19D383, 5, 0x3F, -1, -1);
  1036.         koei_disasm(0x1B6003, 0x1B7AEC, 5, 0x3F, -1, -1);
  1037.         koei_disasm(0x1D0003, 0x1D19CB, 5, 0x3F, -1, -1);
  1038.         koei_disasm(0x1EA003, 0x1EB4DF, 5, 0x3F, -1, -1);
  1039.         koei_disasm(0x204003, 0x204C42, 5, 0x3F, -1, -1);
  1040.         koei_disasm(0x21C003, 0x21C809, 5, 0x3F, -1, -1);
  1041.         koei_disasm(0x236003, 0x236BE8, 5, 0x3F, -1, -1);
  1042.         koei_disasm(0x250003, 0x25042E, 5, 0x3F, -1, -1);
  1043.         koei_disasm(0x26A003, 0x26AC38, 5, 0x3F, -1, -1);
  1044.         koei_disasm(0x285D08, 0x285E52, 5, 0x3F, -1, -1);
  1045.         koei_disasm(0x29E003, 0x29FBEC, 5, 0x3F, -1, -1);
  1046.         koei_disasm(0x2B86A2, 0x2B9C1B, 5, 0x3F, -1, -1);
  1047.         koei_disasm(0x2D2003, 0x2D2190, 5, 0x3F, -1, -1);
  1048.         koei_disasm(0x2D2959, 0x2D3BAC, 5, 0x3F, -1, -1);
  1049.         koei_disasm(0x2EC003, 0x2ED509, 5, 0x3F, -1, -1);
  1050.         koei_disasm(0x306003, 0x306BAF, 5, 0x3F, -1, -1);
  1051.         koei_disasm(0x5C4003, 0x5C44DD, 5, 0x3F, -1, -1);
  1052.         koei_disasm(0x62A003, 0x62A185, 5, 0x3F, -1, -1);
  1053.         koei_disasm(0x62A552, 0x62B553, 5, 0x3F, -1, -1);
  1054.         koei_disasm(0x62B7F9, 0x62BF47, 5, 0x3F, -1, -1);
  1055.     } else if(md5 == "2C9B111B2CC753657EDE3D48E4253355") {
  1056.         Message(" Start Aoki Ookami 2 decompilation.\n");
  1057.         koei_disasm(0x06C003, 0x06CEE8, 5, 0x3F, -1, -1);
  1058.         koei_disasm(0x086003, 0x087ADB, 5, 0x3F, -1, -1);
  1059.         koei_disasm(0x0A0003, 0x0A10B8, 5, 0x3F, -1, -1);
  1060.         koei_disasm(0x0BA2F2, 0x0BBE05, 5, 0x3F, -1, -1);
  1061.         koei_disasm(0x0EC003, 0x0EC6EA, 5, 0x3F, -1, -1);
  1062.         koei_disasm(0x10652E, 0x106DD9, 5, 0x3F, -1, -1);
  1063.         koei_disasm(0x120003, 0x121130, 5, 0x3F, -1, -1);
  1064.         koei_disasm(0x13A003, 0x13ACB7, 5, 0x3F, -1, -1);
  1065.         koei_disasm(0x1549D9, 0x155F10, 5, 0x3F, -1, -1);
  1066.         koei_disasm(0x16E003, 0x16FAF7, 5, 0x3F, -1, -1);
  1067.         koei_disasm(0x1A0003, 0x1A1368, 5, 0x3F, -1, -1);
  1068.         koei_disasm(0x1BA003, 0x1BAF96, 5, 0x3F, -1, -1);
  1069.         koei_disasm(0x1D4003, 0x1D5212, 5, 0x3F, -1, -1);
  1070.         koei_disasm(0x1EE003, 0x1EEEAA, 5, 0x3F, -1, -1);
  1071.         koei_disasm(0x208003, 0x208E99, 5, 0x3F, -1, -1);
  1072.         koei_disasm(0x222003, 0x2236E6, 5, 0x3F, -1, -1);
  1073.         koei_disasm(0x23C003, 0x23D391, 5, 0x3F, -1, -1);
  1074.         koei_disasm(0x256003, 0x2579F6, 5, 0x3F, -1, -1);
  1075.         koei_disasm(0x270003, 0x270EA5, 5, 0x3F, -1, -1);
  1076.         koei_disasm(0x28A003, 0x28BCA0, 5, 0x3F, -1, -1);
  1077.         koei_disasm(0x2A4003, 0x2A55F7, 5, 0x3F, -1, -1);
  1078.         koei_disasm(0x2BE003, 0x2BF8B7, 5, 0x3F, -1, -1);
  1079.         koei_disasm(0x2D8003, 0x2D96E4, 5, 0x3F, -1, -1);
  1080.         koei_disasm(0x2F0003, 0x2F1645, 5, 0x3F, -1, -1);
  1081.         koei_disasm(0x30A003, 0x30AE1D, 5, 0x3F, -1, -1);
  1082.         koei_disasm(0x4CE003, 0x4CF45A, 5, 0x3F, -1, -1);
  1083.         koei_disasm(0x4E6008, 0x4E7A98, 5, 0x3F, -1, -1);
  1084.         koei_disasm(0x500003, 0x50181B, 5, 0x3F, -1, -1);
  1085.         koei_disasm(0x51A003, 0x51B8E6, 5, 0x3F, -1, -1);
  1086.         koei_disasm(0x534003, 0x5352B6, 5, 0x3F, -1, -1);
  1087.         koei_disasm(0x568003, 0x568C3E, 5, 0x3F, -1, -1);
  1088.         koei_disasm(0x5694D8, 0x569C45, 5, 0x3F, -1, -1);
  1089.         koei_disasm(0x582003, 0x58269E, 5, 0x3F, -1, -1);
  1090.         koei_disasm(0x632003, 0x632FC9, 5, 0x3F, -1, -1);
  1091.         koei_disasm(0x63322F, 0x633662, 5, 0x3F, -1, -1);
  1092.     }
  1093.     Message(" Done.\n");
  1094. #endif
  1095. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top