Previous 15994 Revisions Next

r8376 Thursday 1st July, 2010 at 23:50:06 UTC by Fabio Priuli
[NES] simplifying and improving emulation of a few MMC3 clone boards
[src/mess/machine]nes_mmc.h nes_pcb.c nes_unif.c

src/mess/machine/nes_pcb.c
r8375r8376
577577   { "BMC-NTD-03",          BMC_NTD_03 },
578578   { "BMC-8157",            UNSUPPORTED_BOARD /*BMC_8157*/ },
579579   { "BMC-BS-5",            BMC_BENSHENG_BS5 },
580   { "BMC-FK23C",           UNSUPPORTED_BOARD /*BMC_FK23C*/ },
581   { "BMC-FK23CA",          UNSUPPORTED_BOARD /*BMC_FK23C*/ },   // diff reg init
580   { "BMC-FK23C",           BMC_FK23C },
581   { "BMC-FK23CA",          BMC_FK23CA },
582582   { "BMC-GHOSTBUSTERS63IN1", BMC_G63IN1 },
583583   { "BMC-SUPERVISION16IN1", UNSUPPORTED_BOARD },   // mapper 53
584584   { "BMC-RESETBASED-4IN1", UNSUPPORTED_BOARD },// mapper 60 with 64k prg and 32k chr
r8375r8376
12281228   nes_state *state = (nes_state *)machine->driver_data;
12291229   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
12301230
1231   if (state->mmc3_prg_cb)
1232   {
1233      state->mmc3_prg_cb(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
1234      state->mmc3_prg_cb(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask));
1235      state->mmc3_prg_cb(machine, 2, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
1236      state->mmc3_prg_cb(machine, 3, prg_base | (state->mmc_prg_bank[3] & prg_mask));
1237   }
1238   else
1239   {
1240      prg8_x(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
1241      prg8_x(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask));
1242      prg8_x(machine, 2, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
1243      prg8_x(machine, 3, prg_base | (state->mmc_prg_bank[3] & prg_mask));
1244   }
1231   state->mmc3_prg_cb(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
1232   state->mmc3_prg_cb(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask));
1233   state->mmc3_prg_cb(machine, 2, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
1234   state->mmc3_prg_cb(machine, 3, prg_base | (state->mmc_prg_bank[3] & prg_mask));
12451235}
12461236
12471237static void mmc3_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask )
r8375r8376
12491239   nes_state *state = (nes_state *)machine->driver_data;
12501240   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
12511241
1252   if (state->mmc3_chr_cb)
1253   {
1254      state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
1255      state->mmc3_chr_cb(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
1256      state->mmc3_chr_cb(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
1257      state->mmc3_chr_cb(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] |  0x01) & chr_mask), chr);
1258      state->mmc3_chr_cb(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr);
1259      state->mmc3_chr_cb(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr);
1260      state->mmc3_chr_cb(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr);
1261      state->mmc3_chr_cb(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr);
1262   }
1263   else
1264   {
1265      chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
1266      chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
1267      chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
1268      chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] |  0x01) & chr_mask), chr);
1269      chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr);
1270      chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr);
1271      chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr);
1272      chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr);
1273   }
1242   state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
1243   state->mmc3_chr_cb(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
1244   state->mmc3_chr_cb(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
1245   state->mmc3_chr_cb(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] |  0x01) & chr_mask), chr);
1246   state->mmc3_chr_cb(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr);
1247   state->mmc3_chr_cb(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr);
1248   state->mmc3_chr_cb(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr);
1249   state->mmc3_chr_cb(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr);
12741250}
12751251
12761252/* Here, IRQ counter decrements every scanline. */
r8375r8376
69156891
69166892 *************************************************************/
69176893
6918// remove mask & base parameters!
6919static void sgame_boog_set_prg( running_machine *machine, int prg_base, int prg_mask )
6894static void sgame_boog_prg_cb( running_machine *machine, int start, int bank )
69206895{
69216896   nes_state *state = (nes_state *)machine->driver_data;
6922   if (state->map215_reg[0] & 0x80)
6897   if (!(state->map215_reg[0] & 0x80))   // if this is != 0 we should never even arrive here
69236898   {
6924      prg16_89ab(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10));
6925      prg16_cdef(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10));
6926   }
6927   else
6928   {
6929      state->mmc_prg_base = (state->map215_reg[1] & 0x08) ? 0x20 : (state->map215_reg[1] & 0x10);
6930      state->mmc_prg_mask = (state->map215_reg[1] & 0x08) ? 0x1f : 0x0f;
6899      if (state->map215_reg[1] & 0x08)
6900         bank = (bank & 0x1f) | 0x20;
6901      else
6902         bank = (bank & 0x0f) | (state->map215_reg[1] & 0x10);
69316903
6932      mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
6904      prg8_x(machine, start, bank);
69336905   }
69346906}
69356907
6936static void sgame_boog_set_chr( running_machine *machine, UINT8 chr )
6908static void sgame_boog_chr_cb( running_machine *machine, int start, int bank, int source )
69376909{
69386910   nes_state *state = (nes_state *)machine->driver_data;
6939   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
6940   int chr_base = (state->map215_reg[1] & 0x04) ? 0x100 : ((state->map215_reg[1] & 0x10) << 3);
6941   int chr_mask = (state->map215_reg[1] & 0x04) ? 0xff : 0x7f;
6911   
6912   if ((state->map215_reg[1] & 0x04))
6913      bank |= 0x100;
6914   else
6915      bank = (bank & 0x7f) | ((state->map215_reg[1] & 0x10) << 3);
6916   
6917   chr1_x(machine, start, bank, source);
6918}
69426919
6943   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
6944   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
6945   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
6946   chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] |  0x01) & chr_mask), chr);
6947   chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr);
6948   chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr);
6949   chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr);
6950   chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr);
6920static void sgame_boog_set_prg( running_machine *machine )
6921{
6922   nes_state *state = (nes_state *)machine->driver_data;
6923   if (state->map215_reg[0] & 0x80)
6924   {
6925      prg16_89ab(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10));
6926      prg16_cdef(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10));
6927   }
6928   else
6929      mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
69516930}
69526931
69536932static WRITE8_HANDLER( sgame_boog_l_w )
r8375r8376
69596938   if (offset == 0x1000)
69606939   {
69616940      state->map215_reg[0] = data;
6962      sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6941      sgame_boog_set_prg(space->machine);
69636942   }
69646943   else if (offset == 0x1001)
69656944   {
69666945      state->map215_reg[1] = data;
6967      sgame_boog_set_chr(space->machine, state->mmc_chr_source);
6946      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
69686947   }
69696948   else if (offset == 0x1007)
69706949   {
69716950      state->mmc_latch1 = 0;
69726951      state->map215_reg[2] = data;
6973      sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6974      sgame_boog_set_chr(space->machine, state->mmc_chr_source);
6952      sgame_boog_set_prg(space->machine);
6953      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
69756954   }
69766955}
69776956
6957static WRITE8_HANDLER( sgame_boog_m_w )
6958{
6959   nes_state *state = (nes_state *)space->machine->driver_data;
6960   LOG_MMC(("sgame_boog_m_w, offset: %04x, data: %02x\n", offset, data));
6961   
6962   if (offset == 0x0000)
6963   {
6964      state->map215_reg[0] = data;
6965      sgame_boog_set_prg(space->machine);
6966   }
6967   else if (offset == 0x0001)
6968   {
6969      state->map215_reg[1] = data;
6970      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
6971   }
6972   else if (offset == 0x0007)
6973   {
6974      state->mmc_latch1 = 0;
6975      state->map215_reg[2] = data;
6976      sgame_boog_set_prg(space->machine);
6977      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
6978   }
6979}
6980
69786981static WRITE8_HANDLER( sgame_boog_w )
69796982{
69806983   nes_state *state = (nes_state *)space->machine->driver_data;
6981   UINT8 MMC3_helper, cmd;
69826984   static const UINT8 conv_table[8] = {0,2,5,3,6,1,7,4};
69836985   LOG_MMC(("sgame_boog_w, offset: %04x, data: %02x\n", offset, data));
69846986
6985   if (!state->map215_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers
6987   switch (offset & 0x6001)
69866988   {
6987      switch (offset & 0x6001)
6988      {
6989         case 0x0000:
6990            MMC3_helper = state->mmc_latch1 ^ data;
6991            state->mmc_latch1 = data;
6992
6993            /* Has PRG Mode changed? */
6994            if (MMC3_helper & 0x40)
6995               sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6996
6997            /* Has CHR Mode changed? */
6998            if (MMC3_helper & 0x80)
6999               sgame_boog_set_chr(space->machine, state->mmc_chr_source);
7000            break;
7001
7002         case 0x0001:
7003            cmd = state->mmc_latch1 & 0x07;
7004            switch (cmd)
6989      case 0x0000:
6990         if (!state->map215_reg[2])
6991            txrom_w(space, 0x0000, data);
6992         break;
6993         
6994      case 0x0001:
6995         if (!state->map215_reg[2])
6996            txrom_w(space, 0x0001, data);
6997         else if (state->map215_reg[3] && ((state->map215_reg[0] & 0x80) == 0 || (state->mmc_latch1 & 0x07) < 6))   // if we use the prg16 banks and cmd=6,7 DON'T enter!
70056998         {
7006            case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
7007            case 2: case 3: case 4: case 5:
7008               state->mmc_vrom_bank[cmd] = data;
7009               sgame_boog_set_chr(space->machine, state->mmc_chr_source);
7010               break;
7011            case 6:
7012            case 7:
7013               state->mmc_prg_bank[cmd - 6] = data;
7014               sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7015               break;
6999            state->map215_reg[3] = 0;
7000            txrom_w(space, 0x0001, data);
70167001         }
7017            break;
7018
7019         default:
7020            txrom_w(space, offset, data);
7021            break;
7022      }
7023   }
7024   else
7025   {
7026      switch (offset & 0x6001)
7027      {
7028         case 0x0000:
7029            break;
7030
7031         case 0x0001:
7032            cmd = state->mmc_latch1 & 0x07;
7033            if (state->map215_reg[3] && ((state->map215_reg[0] & 0x80) == 0 || cmd < 6))   // if we use the prg16 banks and cmd=6,7 DON'T enter!
7034            {
7035               state->map215_reg[3] = 0;
7036               switch (cmd)
7037               {
7038                  case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
7039                  case 2: case 3: case 4: case 5:
7040                     state->mmc_vrom_bank[cmd] = data;
7041                     sgame_boog_set_chr(space->machine, state->mmc_chr_source);
7042                     break;
7043                  case 6:
7044                  case 7:
7045                     state->mmc_prg_bank[cmd - 6] = data;
7046                     sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7047                     break;
7048               }
7049            }
7050            break;
7051
7052         case 0x2000:
7002         break;
7003         
7004      case 0x2000:
7005         if (!state->map215_reg[2])
7006            txrom_w(space, 0x2000, data);
7007         else
7008         {
70537009            data = (data & 0xc0) | conv_table[data & 0x07];
7054            MMC3_helper = state->mmc_latch1 ^ data;
7055            state->mmc_latch1 = data;
7056
7057            /* Has PRG Mode changed? */
7058            if (MMC3_helper & 0x40)
7059               sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7060
7061            /* Has CHR Mode changed? */
7062            if (MMC3_helper & 0x80)
7063               sgame_boog_set_chr(space->machine, state->mmc_chr_source);
7064
70657010            state->map215_reg[3] = 1;
7011            txrom_w(space, 0x0000, data);
70667012            break;
7013         }
7014         break;
70677015
7068            //      case 0x2001:
7069            //          txrom_w(space, 0x4001, data);
7070            //          break;
7071
7072         case 0x4000:
7016      case 0x4000:
7017         if (!state->map215_reg[2])
7018            txrom_w(space, 0x4000, data);
7019         else
70737020            set_nt_mirroring(space->machine, ((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
7074            break;
7021         break;
70757022
7076         case 0x4001:
7023      case 0x4001:
7024         if (!state->map215_reg[2])
7025            txrom_w(space, 0x4001, data);
7026         else
70777027            txrom_w(space, 0x6001, data);
7078            break;
7028         break;
70797029
7080            //      case 0x6000:
7081            //          txrom_w(space, 0x6000, data);
7082            //          break;
7083
7084         case 0x6001:
7030      case 0x6001:
7031         if (!state->map215_reg[2])
7032            txrom_w(space, 0x6001, data);
7033         else
7034         {
70857035            txrom_w(space, 0x4000, data);
70867036            txrom_w(space, 0x4001, data);
7087            break;
7088
7089         default:
7090            txrom_w(space, offset, data);
7091            break;
7092      }
7037         }
7038         break;
7039         
7040      default:
7041         txrom_w(space, offset, data);
7042         break;
70937043   }
70947044}
70957045
r8375r8376
90478997
90488998 *************************************************************/
90498999
9050static void kof96_set_prg( running_machine *machine, int prg_base, int prg_mask )
9000static void kof96_prg_cb( running_machine *machine, int start, int bank )
90519001{
90529002   nes_state *state = (nes_state *)machine->driver_data;
9053   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
90549003
90559004   if (!(state->mapper187_reg[0] & 0x80))
9056   {
9057      prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
9058      prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask));
9059      prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
9060      prg8_ef(machine, prg_base | (state->mmc_prg_bank[3] & prg_mask));
9061   }
9005      prg8_x(machine, start, bank);
90629006}
90639007
9064static void kof96_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask )
9008static void kof96_chr_cb( running_machine *machine, int start, int bank, int source )
90659009{
90669010   nes_state *state = (nes_state *)machine->driver_data;
90679011   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
9068   UINT8 new_base[8];
9069   int i;
90709012
9071   for (i = 0; i < 8; i++)
9072      new_base[i] = ((i & 0x04) == chr_page)? (chr_base | 0x100) : chr_base;
9013   if ((start & 0x04) == chr_page)
9014      bank |= 0x100;
90739015
9074   chr1_x(machine, chr_page ^ 0, new_base[0] | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
9075   chr1_x(machine, chr_page ^ 1, new_base[1] | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
9076   chr1_x(machine, chr_page ^ 2, new_base[2] | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
9077   chr1_x(machine, chr_page ^ 3, new_base[3] | ((state->mmc_vrom_bank[1] |  0x01) & chr_mask), chr);
9078   chr1_x(machine, chr_page ^ 4, new_base[4] | (state->mmc_vrom_bank[2] & chr_mask), chr);
9079   chr1_x(machine, chr_page ^ 5, new_base[5] | (state->mmc_vrom_bank[3] & chr_mask), chr);
9080   chr1_x(machine, chr_page ^ 6, new_base[6] | (state->mmc_vrom_bank[4] & chr_mask), chr);
9081   chr1_x(machine, chr_page ^ 7, new_base[7] | (state->mmc_vrom_bank[5] & chr_mask), chr);
9016   chr1_x(machine, start, bank, source);
90829017}
90839018
90849019static WRITE8_HANDLER( kof96_l_w )
r8375r8376
90909025
90919026   if (offset == 0x1000)
90929027   {
9093      switch (data & 0x03)
9094      {
9095         case 0x00:
9096         case 0x01:
9097            state->mapper187_reg[1] = 0x83;
9098            break;
9099         case 0x02:
9100            state->mapper187_reg[1] = 0x42;
9101            break;
9102         case 0x03:
9103            state->mapper187_reg[1] = 0x00;
9104            break;
9105      }
9106   }
9107
9108   if (!(offset <= 0x1000))
9109   {
91109028      state->mapper187_reg[0] = data;
91119029
91129030      if (state->mapper187_reg[0] & 0x80)
r8375r8376
91229040         }
91239041      }
91249042      else
9125         kof96_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
9043         mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
91269044   }
9045
9046   if (offset >= 0x1000)
9047   {
9048      switch (data & 0x03)
9049      {
9050         case 0x00:
9051         case 0x01:
9052            state->mapper187_reg[1] = 0x83;
9053            break;
9054         case 0x02:
9055            state->mapper187_reg[1] = 0x42;
9056            break;
9057         case 0x03:
9058            state->mapper187_reg[1] = 0x00;
9059            break;
9060      }
9061     
9062   }
9063   
9064   if (!state->mapper187_reg[3] && offset > 0x1000)
9065   {
9066      state->mapper187_reg[3] = 1;
9067      memory_write_byte(space, 0x4017, 0x40);
9068   }
91279069}
91289070
91299071static READ8_HANDLER( kof96_l_r )
r8375r8376
91419083static WRITE8_HANDLER( kof96_w )
91429084{
91439085   nes_state *state = (nes_state *)space->machine->driver_data;
9144   UINT8 MMC3_helper, cmd;
91459086   LOG_MMC(("kof96_w, offset: %04x, data: %02x\n", offset, data));
91469087
91479088   switch (offset & 0x6003)
91489089   {
91499090      case 0x0000:
91509091         state->mapper187_reg[2] = 1;
9151         MMC3_helper = state->mmc_latch1 ^ data;
9152         state->mmc_latch1 = data;
9153
9154         /* Has PRG Mode changed? */
9155         if (MMC3_helper & 0x40)
9156            kof96_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
9157
9158         /* Has CHR Mode changed? */
9159         if (MMC3_helper & 0x80)
9160            kof96_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
9092         txrom_w(space, 0x0000, data);
91619093         break;
91629094
91639095      case 0x0001:
91649096         if (state->mapper187_reg[2])
9165         {
9166            cmd = state->mmc_latch1 & 0x07;
9167            switch (cmd)
9168            {
9169               case 0: case 1:
9170               case 2: case 3: case 4: case 5:
9171                  state->mmc_vrom_bank[cmd] = data;
9172                  kof96_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
9173                  break;
9174               case 6:
9175               case 7:
9176                  state->mmc_prg_bank[cmd - 6] = data;
9177                  kof96_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
9178                  break;
9179            }
9180         }
9097            txrom_w(space, 0x0001, data);
91819098         break;
91829099
91839100      case 0x0002:
r8375r8376
99759892 *************************************************************/
99769893
99779894/*************************************************************
9895 
9896 Board BMC-FK23C
9897 
9898 In MESS: partially supported (still to sort initial banking
9899 for many games)
9900 
9901 *************************************************************/
99789902
9903#if 0
9904static void fk23c_prg_cb( running_machine *machine, int start, int bank )
9905{
9906   nes_state *state = (nes_state *)machine->driver_data;
9907   
9908   if (((state->mmc_reg[0] & 0x07) - 3) > 1 && (!(state->mmc_reg[3] & 0x02) || start < 2))
9909   {
9910      if (state->mmc_reg[0] & 0x03)
9911         bank = (bank & (0x3f >> (state->mmc_reg[0] & 0x03))) | (state->mmc_reg[1] << 1);
9912     
9913      prg8_x(machine, start, bank);
9914   }
9915}
9916
9917static void fk23c_chr_cb( running_machine *machine, int start, int bank, int source )
9918{
9919   nes_state *state = (nes_state *)machine->driver_data;
9920   
9921   if (!(state->mmc_reg[0] & 0x40) && (!(state->mmc_reg[3] & 0x02) || (start != 1 && start != 3)))
9922      chr1_x(machine, start, ((state->mmc_reg[2] & 0x7f) << 3) | bank, source);
9923}
9924
9925#endif
9926
9927static void fk23c_prg_cb( running_machine *machine, int start, int bank )
9928{
9929   nes_state *state = (nes_state *)machine->driver_data;
9930   UINT8 mask = (0x3f >> (state->mmc_reg[0] & 0x03));
9931   
9932   if ((state->mmc_reg[0] & 0x07) < 3)
9933   {
9934      if (!(state->mmc_reg[0] & 0x03))
9935         bank = (bank & mask) | ((state->mmc_reg[1]  & (0x7f ^ mask)) << 1);
9936
9937      prg8_x(machine, start, bank);
9938   }
9939}
9940
9941static void fk23c_chr_cb( running_machine *machine, int start, int bank, int source )
9942{
9943   nes_state *state = (nes_state *)machine->driver_data;
9944
9945   if (!(state->mmc_reg[0] & 0x40) && (!(state->mmc_reg[3] & 0x02) || (start != 1 && start != 3)))
9946      chr1_x(machine, start, ((state->mmc_reg[2] & 0x7f) << 3) | bank, source);
9947}
9948
9949static void fk23c_set_prg( running_machine *machine )
9950{
9951   nes_state *state = (nes_state *)machine->driver_data;
9952
9953   if ((state->mmc_reg[0] & 0x07) == 4)
9954      prg32(machine, (state->mmc_reg[1] & 0x7f) >> 1);
9955   else if ((state->mmc_reg[0] & 0x07) == 3)
9956   {
9957      prg16_89ab(machine, state->mmc_reg[1] & 0x7f);
9958      prg16_cdef(machine, state->mmc_reg[1] & 0x7f);
9959   }
9960   else
9961   {
9962      if (state->mmc_reg[3] & 0x02)
9963      {
9964         prg8_cd(machine, state->mmc_reg[4]);
9965         prg8_ef(machine, state->mmc_reg[5]);
9966      }
9967     
9968      mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
9969   }
9970}
9971
9972static void fk23c_set_chr( running_machine *machine )
9973{
9974   nes_state *state = (nes_state *)machine->driver_data;
9975
9976   if (state->mmc_reg[0] & 0x40)
9977      chr8(machine, state->mmc_reg[2] | state->mmc_cmd1, state->mmc_chr_source);
9978   else
9979   {
9980      if (state->mmc_reg[3] & 0x02)
9981      {
9982         int base = (state->mmc_reg[2] & 0x7f) << 3;
9983         chr1_x(machine, 1, base | state->mmc_reg[6], state->mmc_chr_source);
9984         chr1_x(machine, 3, base | state->mmc_reg[7], state->mmc_chr_source);
9985      }
9986
9987      mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
9988   }
9989}
9990
9991static WRITE8_HANDLER( fk23c_l_w )
9992{
9993   nes_state *state = (nes_state *)space->machine->driver_data;
9994   LOG_MMC(("fk23c_l_w, offset: %04x, data: %02x\n", offset, data));
9995   offset += 0x100;
9996
9997   if (offset >= 0x1000)
9998   {
9999      if (offset & (1 << 4))   // here it should be (4 + state->mmc_dipsetting)
10000      {
10001         state->mmc_reg[offset & 0x03] = data;
10002         
10003         fk23c_set_prg(space->machine);
10004         fk23c_set_chr(space->machine);
10005      }
10006   }
10007}
10008
10009static WRITE8_HANDLER( fk23c_w )
10010{
10011   nes_state *state = (nes_state *)space->machine->driver_data;
10012   LOG_MMC(("fk23c_w, offset: %04x, data: %02x\n", offset, data));
10013   
10014   if (state->mmc_reg[0] & 0x40)
10015   {
10016      if (state->mmc_reg[0] & 0x30)
10017         state->mmc_cmd1 = 0;
10018      else
10019      {
10020         state->mmc_cmd1 = data & 0x03;
10021         fk23c_set_chr(space->machine);
10022      }
10023   }
10024   else
10025   {
10026      switch (offset & 0x6001)
10027      {
10028         case 0x0001:
10029            if ((state->mmc_reg[3] & 0x02) && (state->mmc_latch1 & 0x08))
10030            {
10031               state->mmc_reg[4 | (state->mmc_latch1 & 0x03)] = data;
10032               fk23c_set_prg(space->machine);
10033               fk23c_set_chr(space->machine);
10034            }
10035            else
10036               txrom_w(space, offset, data);
10037            break;
10038           
10039         case 0x2000:
10040            set_nt_mirroring(space->machine, data ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10041            break;
10042           
10043         default:
10044            txrom_w(space, offset, data);
10045            break;
10046      }   
10047   }
10048}
10049
10050
10051/*************************************************************
10052
997910053 Board BMC-64IN1NOREPEAT
998010054
998110055 Games: 64-in-1 Y2K
r8375r8376
1173111805
1173211806static WRITE8_HANDLER( dummy_l_w )
1173311807{
11734   logerror("write access, offset: %04x, data: %02x\n", offset + 0x8000, data);
11808   logerror("write access, offset: %04x, data: %02x\n", offset + 0x4100, data);
1173511809}
1173611810
1173711811static WRITE8_HANDLER( dummy_m_w )
r8375r8376
1174111815
1174211816static WRITE8_HANDLER( dummy_w )
1174311817{
11744   logerror("write access, offset: %04x, data: %02x\n", offset + 0x4100, data);
11818   logerror("write access, offset: %04x, data: %02x\n", offset + 0x8000, data);
1174511819}
1174611820
1174711821static READ8_HANDLER( dummy_l_r )
1174811822{
11749   logerror("read access, offset: %04x\n", offset + 0x8000);   
11823   logerror("read access, offset: %04x\n", offset + 0x4100);   
1175011824   return 0x00;
1175111825}
1175211826
r8375r8376
1175811832
1175911833static READ8_HANDLER( dummy_r )
1176011834{
11761   logerror("read access, offset: %04x\n", offset + 0x4100);   
11835   logerror("read access, offset: %04x\n", offset + 0x8000);   
1176211836   return 0x00;
1176311837}
1176411838
r8375r8376
1189611970   { REXSOFT_DBZ5,         {rex_dbz_l_w, rex_dbz_l_r}, NES_NOACCESS, NES_WRITEONLY(rex_dbz_w), NULL, NULL, mmc3_irq },
1189711971   { REXSOFT_SL1632,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rex_sl1632_w),          NULL, NULL, mmc3_irq },
1189811972   { RUMBLESTATION_BOARD,  NES_NOACCESS, NES_WRITEONLY(rumblestation_m_w), NES_WRITEONLY(rumblestation_w),      NULL, NULL, NULL },
11899   { SUPERGAME_BOOGERMAN,  NES_WRITEONLY(sgame_boog_l_w), NES_NOACCESS, NES_WRITEONLY(sgame_boog_w), NULL, NULL, mmc3_irq },
11973   { SUPERGAME_BOOGERMAN,  NES_WRITEONLY(sgame_boog_l_w), NES_WRITEONLY(sgame_boog_m_w), NES_WRITEONLY(sgame_boog_w), NULL, NULL, mmc3_irq },
1190011974   { SUPERGAME_LIONKING,   NES_NOACCESS, NES_WRITEONLY(sgame_lion_m_w), NES_WRITEONLY(sgame_lion_w), NULL, NULL, mmc3_irq },
1190111975   { TENGEN_800008,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800008_w),       NULL, NULL, NULL },
1190211976   { TENGEN_800032,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800032_w),       NULL, NULL, tengen_800032_irq },
r8375r8376
1199212066   { BMC_G63IN1,           NES_NOACCESS, NES_NOACCESS, {bmc_gb63_w, bmc_gb63_r},             NULL, NULL, NULL },
1199312067   { UNL_EDU2K,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(edu2k_w),               NULL, NULL, NULL },
1199412068   { UNL_SHJY3,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(shjy3_w),               NULL, NULL, shjy3_irq },
12069   { BMC_FK23C,            NES_WRITEONLY(fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(fk23c_w),   NULL, NULL, mmc3_irq },
12070   { BMC_FK23CA,           NES_WRITEONLY(fk23c_l_w), NES_NOACCESS, NES_WRITEONLY(fk23c_w),   NULL, NULL, mmc3_irq },
1199512071   //
1199612072   { FFE_MAPPER6,          NES_WRITEONLY(mapper6_l_w), NES_NOACCESS, NES_WRITEONLY(mapper6_w), NULL, NULL, ffe_irq },
1199712073   { FFE_MAPPER8,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(mapper8_w),             NULL, NULL, NULL },
r8375r8376
1206512141   if (intf == NULL)
1206612142      fatalerror("Missing PCB interface\n");
1206712143
12068//   state->mmc3_chr_cb = chr1_x;
12069//   state->mmc3_prg_cb = prg8_x;
12070
1207112144   if (intf)
1207212145   {
1207312146      state->mmc_write_low = intf->mmc_l.write;
r8375r8376
1208912162      state->mmc_read = NULL;   // in progress
1209012163      ppu_latch = NULL;
1209112164   }
12165
12166   state->mmc3_prg_cb = prg8_x;
12167   state->mmc3_chr_cb = chr1_x;
12168
12169   switch (state->pcb_id)
12170   {
12171      case SUPERGAME_BOOGERMAN:
12172         state->mmc3_prg_cb = sgame_boog_prg_cb;
12173         state->mmc3_chr_cb = sgame_boog_chr_cb;
12174         break;
12175      case UNL_KOF96:
12176         state->mmc3_prg_cb = kof96_prg_cb;
12177         state->mmc3_chr_cb = kof96_chr_cb;
12178         break;
12179      case BMC_FK23C:
12180         state->mmc3_prg_cb = fk23c_prg_cb;
12181         state->mmc3_chr_cb = fk23c_chr_cb;
12182         break;
12183   }
1209212184}
1209312185
src/mess/machine/nes_unif.c
r8375r8376
690690
691691// mapper 187
692692      case UNL_KOF96:
693         state->mapper187_reg[0] = state->mapper187_reg[1] = state->mapper187_reg[2] = state->mapper187_reg[3] = 0;
693694         mmc3_common_initialize(machine, 0xff, 0xff, 0);
694         state->mapper187_reg[0] = state->mapper187_reg[1] = state->mapper187_reg[2] = state->mapper187_reg[3] = 0;
695         kof96_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
696         kof96_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
697695         break;
698696// mapper 189
699697      case TXC_TW:
r8375r8376
776774
777775// mapper 215
778776      case SUPERGAME_BOOGERMAN:
779         state->mmc_prg_bank[0] = 0x00;
780         state->mmc_prg_bank[2] = 0xfe;
781         state->mmc_prg_bank[1] = 0x01;
782         state->mmc_prg_bank[3] = 0xff;
783         state->mmc_latch1 = 0;
784         state->mmc_latch2 = 0x80;
785777         state->map215_reg[0] = 0x00;
786778         state->map215_reg[1] = 0xff;
787779         state->map215_reg[2] = 0x04;
788780         state->map215_reg[3] = 0;
789         state->mmc_prg_base = 0;
790         state->mmc_prg_mask = 0x1f;
791         sgame_boog_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
792         sgame_boog_set_chr(machine, state->mmc_chr_source);
781         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
782         sgame_boog_set_prg(machine);
783         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
793784         break;
794785
795786// mapper 217
r8375r8376
958949         bmc_gb63_update(machine);
959950         break;
960951
952      case BMC_FK23C:
953         state->mmc_reg[0] = 4;
954         state->mmc_reg[1] = 0xff;
955         state->mmc_reg[2] = state->mmc_reg[3] = 0;
956         state->mmc_reg[4] = state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0xff;
957         mmc3_common_initialize(machine, 0xff, 0xff, 0);
958         fk23c_set_prg(machine);
959         fk23c_set_chr(machine);
960         break;
961         
962      case BMC_FK23CA:
963         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
964         state->mmc_reg[4] = state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0xff;
965         mmc3_common_initialize(machine, 0xff, 0xff, 0);
966         fk23c_set_prg(machine);
967         fk23c_set_chr(machine);
968         break;
969
970
961971      case FFE_MAPPER6:
962972         prg16_89ab(machine, 0);
963973         prg16_cdef(machine, 7);
src/mess/machine/nes_mmc.h
r8375r8376
7676   BMC_GOLDENCARD_6IN1, BMC_72IN1, BMC_SUPER_42IN1, BMC_76IN1,
7777   BMC_1200IN1, BMC_31IN1, BMC_22GAMES, BMC_20IN1, BMC_110IN1,
7878   BMC_GKA, BMC_GKB, BMC_VT5201, BMC_BENSHENG_BS5, BMC_810544,
79   BMC_NTD_03, BMC_G63IN1,
79   BMC_NTD_03, BMC_G63IN1, BMC_FK23C, BMC_FK23CA,
8080   /* Unlicensed */
8181   UNL_8237, UNL_CC21, UNL_AX5705, UNL_KOF97,
8282   UNL_N625092, UNL_SC127, UNL_SMB2J, UNL_T230,

Previous 15994 Revisions Next


© 1998-2018 The MESS Team