Previous 15994 Revisions Next

r8384 Sunday 4th July, 2010 at 09:25:18 UTC by Fabio Priuli
[NES] refactoring emulation of various boards, as a result several MMC3 pirate clones works better (e.g. Contra Fighter now works, but also 5-6 vs fighting games)
[src/mess/includes]nes.h
[src/mess/machine]nes_pcb.c nes_unif.c

src/mess/machine/nes_pcb.c
r8383r8384
10231023
10241024   if (data & 0x80)
10251025   {
1026      state->mmc_count = 0;
1027      state->mmc_latch1 = 0;
1026      state->mmc1_count = 0;
1027      state->mmc1_latch = 0;
10281028
10291029      /* Set reg at 0x8000 to size 16k and lower half swap - needed for Robocop 3, Dynowars */
10301030      state->mmc_reg[0] |= 0x0c;
r8383r8384
10321032      return;
10331033   }
10341034
1035   if (state->mmc_count < 5)
1035   if (state->mmc1_count < 5)
10361036   {
1037      if (state->mmc_count == 0) state->mmc_latch1 = 0;
1038      state->mmc_latch1 >>= 1;
1039      state->mmc_latch1 |= (data & 0x01) ? 0x10 : 0x00;
1040      state->mmc_count++;
1037      if (state->mmc1_count == 0) state->mmc1_latch = 0;
1038      state->mmc1_latch >>= 1;
1039      state->mmc1_latch |= (data & 0x01) ? 0x10 : 0x00;
1040      state->mmc1_count++;
10411041   }
10421042
1043   if (state->mmc_count == 5)
1043   if (state->mmc1_count == 5)
10441044   {
10451045      switch (offset & 0x6000)   /* Which reg shall we write to? */
10461046      {
10471047         case 0x0000:
1048            state->mmc_reg[0] = state->mmc_latch1;
1048            state->mmc_reg[0] = state->mmc1_latch;
10491049
10501050            switch (state->mmc_reg[0] & 0x03)
10511051            {
r8383r8384
10581058            mmc1_set_prg_wram(space, board);
10591059            break;
10601060         case 0x2000:
1061            state->mmc_reg[1] = state->mmc_latch1;
1061            state->mmc_reg[1] = state->mmc1_latch;
10621062            mmc1_set_chr(machine);
10631063            mmc1_set_prg_wram(space, board);
10641064            break;
10651065         case 0x4000:
1066            state->mmc_reg[2] = state->mmc_latch1;
1066            state->mmc_reg[2] = state->mmc1_latch;
10671067            mmc1_set_chr(machine);
10681068            break;
10691069         case 0x6000:
1070            state->mmc_reg[3] = state->mmc_latch1;
1070            state->mmc_reg[3] = state->mmc1_latch;
10711071            mmc1_set_prg_wram(space, board);
10721072            break;
10731073      }
1074
1075      state->mmc_count = 0;
1074      state->mmc1_count = 0;
10761075   }
10771076}
10781077
r8383r8384
11011100   nes_state *state = (nes_state *)device->machine->driver_data;
11021101   if ((offset & 0x3ff0) == 0x0fd0)
11031102   {
1104      LOG_MMC(("mmc2 vrom latch switch (bank 0 low): %02x\n", state->MMC2_regs[0]));
1103      LOG_MMC(("mmc2 vrom latch switch (bank 0 low): %02x\n", state->mmc_reg[0]));
11051104      state->mmc_latch1 = 0xfd;
1106      chr4_0(device->machine, state->MMC2_regs[0], CHRROM);
1105      chr4_0(device->machine, state->mmc_reg[0], CHRROM);
11071106   }
11081107   else if ((offset & 0x3ff0) == 0x0fe0)
11091108   {
1110      LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->MMC2_regs[1]));
1109      LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->mmc_reg[1]));
11111110      state->mmc_latch1 = 0xfe;
1112      chr4_0(device->machine, state->MMC2_regs[1], CHRROM);
1111      chr4_0(device->machine, state->mmc_reg[1], CHRROM);
11131112   }
11141113   else if ((offset & 0x3ff0) == 0x1fd0)
11151114   {
1116      LOG_MMC(("mmc2 vrom latch switch (bank 1 low): %02x\n", state->MMC2_regs[2]));
1115      LOG_MMC(("mmc2 vrom latch switch (bank 1 low): %02x\n", state->mmc_reg[2]));
11171116      state->mmc_latch2 = 0xfd;
1118      chr4_4(device->machine, state->MMC2_regs[2], CHRROM);
1117      chr4_4(device->machine, state->mmc_reg[2], CHRROM);
11191118   }
11201119   else if ((offset & 0x3ff0) == 0x1fe0)
11211120   {
1122      LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->MMC2_regs[3]));
1121      LOG_MMC(("mmc2 vrom latch switch (bank 0 high): %02x\n", state->mmc_reg[3]));
11231122      state->mmc_latch2 = 0xfe;
1124      chr4_4(device->machine, state->MMC2_regs[3], CHRROM);
1123      chr4_4(device->machine, state->mmc_reg[3], CHRROM);
11251124   }
11261125}
11271126
r8383r8384
11351134         prg8_89(space->machine, data);
11361135         break;
11371136      case 0x3000:
1138         state->MMC2_regs[0] = data;
1137         state->mmc_reg[0] = data;
11391138         if (state->mmc_latch1 == 0xfd)
1140            chr4_0(space->machine, state->MMC2_regs[0], CHRROM);
1139            chr4_0(space->machine, state->mmc_reg[0], CHRROM);
11411140         break;
11421141      case 0x4000:
1143         state->MMC2_regs[1] = data;
1142         state->mmc_reg[1] = data;
11441143         if (state->mmc_latch1 == 0xfe)
1145            chr4_0(space->machine, state->MMC2_regs[1], CHRROM);
1144            chr4_0(space->machine, state->mmc_reg[1], CHRROM);
11461145         break;
11471146      case 0x5000:
1148         state->MMC2_regs[2] = data;
1147         state->mmc_reg[2] = data;
11491148         if (state->mmc_latch2 == 0xfd)
1150            chr4_4(space->machine, state->MMC2_regs[2], CHRROM);
1149            chr4_4(space->machine, state->mmc_reg[2], CHRROM);
11511150         break;
11521151      case 0x6000:
1153         state->MMC2_regs[3] = data;
1152         state->mmc_reg[3] = data;
11541153         if (state->mmc_latch2 == 0xfe)
1155            chr4_4(space->machine, state->MMC2_regs[3], CHRROM);
1154            chr4_4(space->machine, state->mmc_reg[3], CHRROM);
11561155         break;
11571156      case 0x7000:
11581157         set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
r8383r8384
12061205   if (state->mmc_write_mid != NULL)
12071206      return;
12081207
1209   if (BIT(state->mmc_latch2, 7))
1208   if (BIT(state->mmc3_wram_protect, 7))
12101209      memory_install_readwrite_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
12111210   else
12121211   {
r8383r8384
12141213      return;
12151214   }
12161215
1217   if (!BIT(state->mmc_latch2, 6))
1216   if (!BIT(state->mmc3_wram_protect, 6))
12181217      memory_install_write_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
12191218   else
12201219   {
r8383r8384
12261225static void mmc3_set_prg( running_machine *machine, int prg_base, int prg_mask )
12271226{
12281227   nes_state *state = (nes_state *)machine->driver_data;
1229   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
1228   UINT8 prg_flip = (state->mmc3_latch & 0x40) ? 2 : 0;
12301229
12311230   state->mmc3_prg_cb(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
12321231   state->mmc3_prg_cb(machine, 1, prg_base | (state->mmc_prg_bank[1] & prg_mask));
r8383r8384
12371236static void mmc3_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask )
12381237{
12391238   nes_state *state = (nes_state *)machine->driver_data;
1240   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
1239   UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5;
12411240
12421241   state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
12431242   state->mmc3_chr_cb(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
r8383r8384
12751274static WRITE8_HANDLER( txrom_w )
12761275{
12771276   nes_state *state = (nes_state *)space->machine->driver_data;
1278   UINT8 mmc3_helper, cmd;
1277   UINT8 mmc_helper, cmd;
12791278
12801279   LOG_MMC(("txrom_w, offset: %04x, data: %02x\n", offset, data));
12811280
12821281   switch (offset & 0x6001)
12831282   {
12841283      case 0x0000:
1285         mmc3_helper = state->mmc_latch1 ^ data;
1286         state->mmc_latch1 = data;
1284         mmc_helper = state->mmc3_latch ^ data;
1285         state->mmc3_latch = data;
12871286
12881287         /* Has PRG Mode changed? */
1289         if (mmc3_helper & 0x40)
1288         if (mmc_helper & 0x40)
12901289            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
12911290
12921291         /* Has CHR Mode changed? */
1293         if (mmc3_helper & 0x80)
1292         if (mmc_helper & 0x80)
12941293            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
12951294         break;
12961295
12971296      case 0x0001:
1298         cmd = state->mmc_latch1 & 0x07;
1297         cmd = state->mmc3_latch & 0x07;
12991298         switch (cmd)
13001299         {
13011300         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
r8383r8384
13161315         break;
13171316
13181317      case 0x2001:
1319         state->mmc_latch2 = data;
1318         state->mmc3_wram_protect = data;
13201319         mmc3_set_wram(space);
13211320         break;
13221321
r8383r8384
14001399   switch (offset & 0x6001)
14011400   {
14021401      case 0x0000:
1403         mmc6_helper = state->mmc_latch1 ^ data;
1404         state->mmc_latch1 = data;
1402         mmc6_helper = state->mmc3_latch ^ data;
1403         state->mmc3_latch = data;
14051404
14061405         if (!state->mmc_latch2 && BIT(data, 5))   // if WRAM is disabled and has to be enabled, write
14071406            state->mmc_latch2 = BIT(data, 5);   // (once WRAM has been enabled, it cannot be disabled without resetting the game)
r8383r8384
14471446static void txsrom_set_mirror( running_machine *machine )
14481447{
14491448   nes_state *state = (nes_state *)machine->driver_data;
1450   if (state->mmc_latch1 & 0x80)
1449   if (state->mmc3_latch & 0x80)
14511450   {
14521451      set_nt_page(machine, 0, CIRAM, (state->mmc_vrom_bank[2] & 0x80) >> 7, 1);
14531452      set_nt_page(machine, 1, CIRAM, (state->mmc_vrom_bank[3] & 0x80) >> 7, 1);
r8383r8384
14631462   }
14641463}
14651464
1466static WRITE8_HANDLER( txsrom_w )
1465static void txsrom_chr_cb( running_machine *machine, int start, int bank, int source )
14671466{
1468   nes_state *state = (nes_state *)space->machine->driver_data;
1469   UINT8 MMC3_helper, cmd;
1470   LOG_MMC(("mapper118_w, offset: %04x, data: %02x\n", offset, data));
1467   txsrom_set_mirror(machine);   // we could probably update only for one (e.g. the first) call, to slightly optimize the code
1468   chr1_x(machine, start, bank, source);
1469}
14711470
1471static WRITE8_HANDLER( txsrom_w )
1472{
1473   LOG_MMC(("txsrom_w, offset: %04x, data: %02x\n", offset, data));
1474   
14721475   switch (offset & 0x6001)
14731476   {
1474      case 0x0000:
1475         MMC3_helper = state->mmc_latch1 ^ data;
1476         state->mmc_latch1 = data;
1477
1478         /* Has PRG Mode changed? */
1479         if (MMC3_helper & 0x40)
1480            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1481
1482         /* Has CHR Mode changed? */
1483         if (MMC3_helper & 0x80)
1484         {
1485            txsrom_set_mirror(space->machine);
1486            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
1487         }
1488         break;
1489
1490      case 0x0001:
1491         cmd = state->mmc_latch1 & 0x07;
1492         switch (cmd)
1493         {
1494         case 0: case 1:
1495         case 2: case 3: case 4: case 5:
1496            state->mmc_vrom_bank[cmd] = data;
1497            txsrom_set_mirror(space->machine);
1498            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
1499            break;
1500         case 6:
1501         case 7:
1502            state->mmc_prg_bank[cmd - 6] = data;
1503            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1504            break;
1505         }
1506         break;
1507
15081477      case 0x2000:
15091478         break;
1510
1479         
15111480      default:
15121481         txrom_w(space, offset, data);
15131482         break;
r8383r8384
15291498static void tqrom_set_chr( running_machine *machine )
15301499{
15311500   nes_state *state = (nes_state *)machine->driver_data;
1532   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
1501   UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5;
15331502   UINT8 chr_src[6], chr_mask[6];
15341503   int i;
15351504
r8383r8384
15521521static WRITE8_HANDLER( tqrom_w )
15531522{
15541523   nes_state *state = (nes_state *)space->machine->driver_data;
1555   UINT8 MMC3_helper, cmd;
1556   LOG_MMC(("mapper119_w, offset: %04x, data: %02x\n", offset, data));
1524   UINT8 mmc_helper, cmd;
1525   LOG_MMC(("tqrom_w, offset: %04x, data: %02x\n", offset, data));
15571526
15581527   switch (offset & 0x6001)
15591528   {
15601529      case 0x0000:
1561         MMC3_helper = state->mmc_latch1 ^ data;
1562         state->mmc_latch1 = data;
1530         mmc_helper = state->mmc3_latch ^ data;
1531         state->mmc3_latch = data;
15631532
15641533         /* Has PRG Mode changed? */
1565         if (MMC3_helper & 0x40)
1534         if (mmc_helper & 0x40)
15661535            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
15671536
15681537         /* Has CHR Mode changed? */
1569         if (MMC3_helper & 0x80)
1538         if (mmc_helper & 0x80)
15701539            tqrom_set_chr(space->machine);
15711540         break;
15721541      case 0x0001: /* $8001 */
1573         cmd = state->mmc_latch1 & 0x07;
1542         cmd = state->mmc3_latch & 0x07;
15741543         switch (cmd)
15751544         {
15761545         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
r8383r8384
16041573static WRITE8_HANDLER( zz_m_w )
16051574{
16061575   nes_state *state = (nes_state *)space->machine->driver_data;
1607   UINT8 map37_helper;
1576   UINT8 mmc_helper = data & 0x07;
16081577   LOG_MMC(("zz_m_w, offset: %04x, data: %02x\n", offset, data));
16091578
1610   map37_helper = data & 0x07;
1611
1612   state->mmc_prg_base = (BIT(map37_helper, 2) << 4) | (((map37_helper & 0x03) == 0x03) ? 0x08 : 0);
1613   state->mmc_prg_mask = (map37_helper << 1) | 0x07;
1614   state->mmc_chr_base = BIT(map37_helper, 2) << 7;
1579   state->mmc_prg_base = (BIT(mmc_helper, 2) << 4) | (((mmc_helper & 0x03) == 0x03) ? 0x08 : 0);
1580   state->mmc_prg_mask = (mmc_helper << 1) | 0x07;
1581   state->mmc_chr_base = BIT(mmc_helper, 2) << 7;
16151582   state->mmc_chr_mask = 0x7f;
16161583   mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
16171584   mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
r8383r8384
50925059   LOG_MMC(("gouder_sf4_l_w, offset: %04x, data: %02x\n", offset, data));
50935060
50945061   if (!(offset < 0x1700))
5095      state->map208_reg[offset & 0x03] = data ^ conv_table[state->map208_reg[4]];
5062      state->mmc_reg[offset & 0x03] = data ^ conv_table[state->mmc_reg[4]];
50965063   else if (!(offset < 0xf00))
5097      state->map208_reg[4] = data;
5064      state->mmc_reg[4] = data;
50985065   else if (!(offset < 0x700))
50995066      prg32(space->machine, ((data >> 3) & 0x02) | (data & 0x01));
51005067}
r8383r8384
51055072   LOG_MMC(("gouder_sf4_l_r, offset: %04x\n", offset));
51065073
51075074   if (!(offset < 0x1700))
5108      return state->map208_reg[offset & 0x03];
5075      return state->mmc_reg[offset & 0x03];
51095076
51105077   return 0x00;
51115078}
51125079
5113/* This is like mmc3 but with no PRG bankswitch (beacuse it is handled by low writes) */
5114// replace with map189_w... they are the same!!
5115static WRITE8_HANDLER( gouder_sf4_w )
5080/* writes to 0x8000-0xffff are like MMC3 but no PRG bankswitch (beacuse it is handled by low writes) */
5081static void gouder_sf4_prg_cb( running_machine *machine, int start, int bank )
51165082{
5117   nes_state *state = (nes_state *)space->machine->driver_data;
5118   UINT8 MMC3_helper, cmd;
5119   LOG_MMC(("gouder_sf4_w, offset: %04x, data: %02x\n", offset, data));
5120
5121   switch (offset & 0x6001)
5122   {
5123      case 0x0000:
5124         MMC3_helper = state->mmc_latch1 ^ data;
5125         state->mmc_latch1 = data;
5126
5127         /* Has CHR Mode changed? */
5128         if (MMC3_helper & 0x80)
5129            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
5130         break;
5131
5132      case 0x0001:
5133         cmd = state->mmc_latch1 & 0x07;
5134         switch (cmd)
5135         {
5136         case 0: case 1:
5137         case 2: case 3: case 4: case 5:
5138            state->mmc_vrom_bank[cmd] = data;
5139            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
5140            break;
5141         }
5142         break;
5143
5144      default:
5145         txrom_w(space, offset, data);
5146         break;
5147   }
5083   return;
51485084}
51495085
5086
51505087/*************************************************************
51515088
51525089 Bootleg Board by Henggedianzi
r8383r8384
56825619static void kay_pp_chr_cb( running_machine *machine, int start, int bank, int source )
56835620{
56845621   nes_state *state = (nes_state *)machine->driver_data;
5685   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
5622   UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5;
56865623   
56875624   if ((start & 0x04) == chr_page)
56885625      bank |= 0x100;
r8383r8384
57395676
57405677 *************************************************************/
57415678
5742static void kasing_set_prg( running_machine *machine, int prg_base, int prg_mask )
5679static void kasing_prg_cb( running_machine *machine, int start, int bank )
57435680{
57445681   nes_state *state = (nes_state *)machine->driver_data;
5745   if (state->mapper115_reg[0] & 0x80)
5746      prg32(machine, state->mapper115_reg[0] >> 1);
5682   if (BIT(state->mmc_reg[0], 7))
5683      prg32(machine, state->mmc_reg[0] >> 1);
57475684   else
5748      mmc3_set_prg(machine, prg_base, prg_mask);
5685      prg8_x(machine, start, bank);
57495686}
5750
5687   
57515688static WRITE8_HANDLER( kasing_m_w )
57525689{
57535690   nes_state *state = (nes_state *)space->machine->driver_data;
57545691   LOG_MMC(("kasing_m_w, offset: %04x, data: %02x\n", offset, data));
5755
5692   
57565693   switch (offset & 0x01)
57575694   {
57585695      case 0x00:
5759         state->mapper115_reg[0] = data;
5760         kasing_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
5696         state->mmc_reg[0] = data;
5697         mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
57615698         break;
57625699      case 0x01:
57635700         state->mmc_chr_base = (data & 0x01) ? 0x100 : 0x000;
r8383r8384
57665703   }
57675704}
57685705
5769static WRITE8_HANDLER( kasing_w )
5770{
5771   nes_state *state = (nes_state *)space->machine->driver_data;
5772   UINT8 map115_helper, cmd;
5773   LOG_MMC(("kasing_w, offset: %04x, data: %02x\n", offset, data));
5774
5775   switch (offset & 0x6001)
5776   {
5777      case 0x0000:
5778         map115_helper = state->mmc_latch1 ^ data;
5779         state->mmc_latch1 = data;
5780
5781         /* Has PRG Mode changed? */
5782         if (map115_helper & 0x40)
5783            kasing_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
5784
5785         /* Has CHR Mode changed? */
5786         if (map115_helper & 0x80)
5787            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
5788         break;
5789
5790      case 0x0001:
5791         cmd = state->mmc_latch1 & 0x07;
5792         switch (cmd)
5793      {
5794         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
5795         case 2: case 3: case 4: case 5:
5796            state->mmc_vrom_bank[cmd] = data;
5797            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
5798            break;
5799         case 6:
5800         case 7:
5801            state->mmc_prg_bank[cmd - 6] = data;
5802            kasing_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
5803            break;
5804      }
5805         break;
5806
5807      default:
5808         txrom_w(space, offset, data);
5809         break;
5810   }
5811}
5812
58135706/*************************************************************
58145707
58155708 Bootleg Board by Magic Series
r8383r8384
61786071
61796072 iNES: mapper 12
61806073
6181 In MESS: Partially Supported
6074 In MESS: Supported
61826075
61836076 *************************************************************/
61846077
61856078static WRITE8_HANDLER( rex_dbz_l_w )
61866079{
61876080   nes_state *state = (nes_state *)space->machine->driver_data;
6188
61896081   LOG_MMC(("rex_dbz_l_w, offset: %04x, data: %02x\n", offset, data));
61906082
6191   state->mapper12_reg = data;
6083   state->mmc_reg[0] = data;
6084   mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
61926085}
61936086
61946087/* we would need to use this read handler in 0x6000-0x7fff as well */
r8383r8384
61986091   return 0x01;
61996092}
62006093
6201static void rex_dbz_set_chr( running_machine *machine )
6094static void rex_dbz_chr_cb( running_machine *machine, int start, int bank, int source )
62026095{
62036096   nes_state *state = (nes_state *)machine->driver_data;
6204   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
6097   int shift = (start < 4) ? 8 : 4;
62056098
6206   chr1_x(machine, chr_page ^ 0, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[0] & ~0x01), CHRROM);
6207   chr1_x(machine, chr_page ^ 1, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[0] |  0x01), CHRROM);
6208   chr1_x(machine, chr_page ^ 2, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[1] & ~0x01), CHRROM);
6209   chr1_x(machine, chr_page ^ 3, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[1] |  0x01), CHRROM);
6210   chr1_x(machine, chr_page ^ 4, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[2], CHRROM);
6211   chr1_x(machine, chr_page ^ 5, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[3], CHRROM);
6212   chr1_x(machine, chr_page ^ 6, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[4], CHRROM);
6213   chr1_x(machine, chr_page ^ 7, ((state->mapper12_reg & 0x10) << 4) | state->mmc_vrom_bank[5], CHRROM);
6099   bank |= ((state->mmc_reg[0] << shift) & 0x100);
6100   chr1_x(machine, start, bank, source);
62146101}
62156102
6216static WRITE8_HANDLER( rex_dbz_w )
6217{
6218   nes_state *state = (nes_state *)space->machine->driver_data;
6219   UINT8 MMC3_helper, cmd;
6220   LOG_MMC(("rex_dbz_w, offset: %04x, data: %02x\n", offset, data));
6221
6222   switch (offset & 0x6001)
6223   {
6224      case 0x0000:
6225         MMC3_helper = state->mmc_latch1 ^ data;
6226         state->mmc_latch1 = data;
6227
6228         /* Has PRG Mode changed? */
6229         if (MMC3_helper & 0x40)
6230            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6231
6232         /* Has CHR Mode changed? */
6233         if (MMC3_helper & 0x80)
6234            rex_dbz_set_chr(space->machine);
6235         break;
6236
6237      case 0x0001:
6238         cmd = state->mmc_latch1 & 0x07;
6239         switch (cmd)
6240      {
6241         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
6242         case 2: case 3: case 4: case 5:
6243            state->mmc_vrom_bank[cmd] = data;
6244            rex_dbz_set_chr(space->machine);
6245            break;
6246         case 6:
6247         case 7:
6248            state->mmc_prg_bank[cmd - 6] = data;
6249            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6250            break;
6251      }
6252         break;
6253
6254      default:
6255         txrom_w(space, offset, data);
6256         break;
6257   }
6258}
6259
62606103/*************************************************************
62616104
62626105 Rex Soft SL1632 Board
r8383r8384
62756118{
62766119   nes_state *state = (nes_state *)machine->driver_data;
62776120
6278   if (state->map14_reg[0] & 0x02)
6121   if (state->mmc_reg[0] & 0x02)
62796122   {
62806123      mmc3_set_prg(machine, prg_base, prg_mask);
62816124   }
r8383r8384
62926135{
62936136   nes_state *state = (nes_state *)machine->driver_data;
62946137   static const UINT8 conv_table[8] = {5, 5, 5, 5, 3, 3, 1, 1};
6295   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
6138   UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5;
62966139   UINT8 bank[8];
62976140   UINT8 chr_base2[8];
62986141   int i;
62996142
6300   if (state->map14_reg[0] & 0x02)
6143   if (state->mmc_reg[0] & 0x02)
63016144   {
63026145      for(i = 0; i < 8; i++)
63036146      {
63046147         bank[i] = state->mmc_vrom_bank[i];
6305         chr_base2[i] = chr_base | ((state->map14_reg[0] << conv_table[i]) & 0x100);
6148         chr_base2[i] = chr_base | ((state->mmc_reg[0] << conv_table[i]) & 0x100);
63066149      }
63076150   }
63086151   else
r8383r8384
63276170static WRITE8_HANDLER( rex_sl1632_w )
63286171{
63296172   nes_state *state = (nes_state *)space->machine->driver_data;
6330   UINT8 map14_helper1, map14_helper2, MMC3_helper, cmd;
6173   UINT8 map14_helper1, map14_helper2, mmc_helper, cmd;
63316174   LOG_MMC(("rex_sl1632_w, offset: %04x, data: %02x\n", offset, data));
63326175
63336176   if (offset == 0x2131)
63346177   {
6335      state->map14_reg[0] = data;
6178      state->mmc_reg[0] = data;
63366179      rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
63376180      rex_sl1632_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
63386181
6339      if (!(state->map14_reg[0] & 0x02))
6340         set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6182      if (!(state->mmc_reg[0] & 0x02))
6183         set_nt_mirroring(space->machine, BIT(state->mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
63416184   }
63426185
6343   if (state->map14_reg[0] & 0x02)
6186   if (state->mmc_reg[0] & 0x02)
63446187   {
63456188      switch (offset & 0x6001)
63466189      {
63476190         case 0x0000:
6348            MMC3_helper = state->mmc_latch1 ^ data;
6349            state->mmc_latch1 = data;
6191            mmc_helper = state->mmc3_latch ^ data;
6192            state->mmc3_latch = data;
63506193
63516194            /* Has PRG Mode changed? */
6352            if (MMC3_helper & 0x40)
6195            if (mmc_helper & 0x40)
63536196               rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
63546197
63556198            /* Has CHR Mode changed? */
6356            if (MMC3_helper & 0x80)
6199            if (mmc_helper & 0x80)
63576200               rex_sl1632_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
63586201            break;
63596202
63606203         case 0x0001:
6361            cmd = state->mmc_latch1 & 0x07;
6204            cmd = state->mmc3_latch & 0x07;
63626205            switch (cmd)
6363         {
6206            {
63646207            case 0: case 1:   // these have to be changed due to the different way rex_sl1632_set_chr works (it handles 1k banks)!
63656208               state->mmc_vrom_bank[2 * cmd] = data;
63666209               state->mmc_vrom_bank[2 * cmd + 1] = data;
r8383r8384
63756218               state->mmc_prg_bank[cmd - 6] = data;
63766219               rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
63776220               break;
6378         }
6221            }
63796222            break;
63806223
63816224         case 0x2000:
6382            set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
6225            set_nt_mirroring(space->machine, BIT(state->mmc_reg[1], 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
63836226            break;
63846227
63856228         default:
r8383r8384
64066249            break;
64076250
64086251         case 0x1000:
6409            state->map14_reg[1] = data;
6410            set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6252            state->mmc_reg[1] = data;
6253            set_nt_mirroring(space->machine, BIT(state->mmc_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
64116254            break;
64126255      }
64136256   }
r8383r8384
69496792static void sgame_boog_prg_cb( running_machine *machine, int start, int bank )
69506793{
69516794   nes_state *state = (nes_state *)machine->driver_data;
6952   if (!(state->map215_reg[0] & 0x80))   // if this is != 0 we should never even arrive here
6795   if (!(state->mmc_reg[0] & 0x80))   // if this is != 0 we should never even arrive here
69536796   {
6954      if (state->map215_reg[1] & 0x08)
6797      if (state->mmc_reg[1] & 0x08)
69556798         bank = (bank & 0x1f) | 0x20;
69566799      else
6957         bank = (bank & 0x0f) | (state->map215_reg[1] & 0x10);
6800         bank = (bank & 0x0f) | (state->mmc_reg[1] & 0x10);
69586801
69596802      prg8_x(machine, start, bank);
69606803   }
r8383r8384
69646807{
69656808   nes_state *state = (nes_state *)machine->driver_data;
69666809   
6967   if ((state->map215_reg[1] & 0x04))
6810   if ((state->mmc_reg[1] & 0x04))
69686811      bank |= 0x100;
69696812   else
6970      bank = (bank & 0x7f) | ((state->map215_reg[1] & 0x10) << 3);
6813      bank = (bank & 0x7f) | ((state->mmc_reg[1] & 0x10) << 3);
69716814   
69726815   chr1_x(machine, start, bank, source);
69736816}
r8383r8384
69756818static void sgame_boog_set_prg( running_machine *machine )
69766819{
69776820   nes_state *state = (nes_state *)machine->driver_data;
6978   if (state->map215_reg[0] & 0x80)
6821   if (state->mmc_reg[0] & 0x80)
69796822   {
6980      prg16_89ab(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10));
6981      prg16_cdef(machine, (state->map215_reg[0] & 0xf0) | (state->map215_reg[1] & 0x10));
6823      prg16_89ab(machine, (state->mmc_reg[0] & 0xf0) | (state->mmc_reg[1] & 0x10));
6824      prg16_cdef(machine, (state->mmc_reg[0] & 0xf0) | (state->mmc_reg[1] & 0x10));
69826825   }
69836826   else
69846827      mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
r8383r8384
69926835
69936836   if (offset == 0x1000)
69946837   {
6995      state->map215_reg[0] = data;
6838      state->mmc_reg[0] = data;
69966839      sgame_boog_set_prg(space->machine);
69976840   }
69986841   else if (offset == 0x1001)
69996842   {
7000      state->map215_reg[1] = data;
6843      state->mmc_reg[1] = data;
70016844      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
70026845   }
70036846   else if (offset == 0x1007)
70046847   {
7005      state->mmc_latch1 = 0;
7006      state->map215_reg[2] = data;
6848      state->mmc3_latch = 0;
6849      state->mmc_reg[2] = data;
70076850      sgame_boog_set_prg(space->machine);
70086851      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
70096852   }
r8383r8384
70166859   
70176860   if (offset == 0x0000)
70186861   {
7019      state->map215_reg[0] = data;
6862      state->mmc_reg[0] = data;
70206863      sgame_boog_set_prg(space->machine);
70216864   }
70226865   else if (offset == 0x0001)
70236866   {
7024      state->map215_reg[1] = data;
6867      state->mmc_reg[1] = data;
70256868      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
70266869   }
70276870   else if (offset == 0x0007)
70286871   {
7029      state->mmc_latch1 = 0;
7030      state->map215_reg[2] = data;
6872      state->mmc3_latch = 0;
6873      state->mmc_reg[2] = data;
70316874      sgame_boog_set_prg(space->machine);
70326875      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
70336876   }
r8383r8384
70426885   switch (offset & 0x6001)
70436886   {
70446887      case 0x0000:
7045         if (!state->map215_reg[2])
6888         if (!state->mmc_reg[2])
70466889            txrom_w(space, 0x0000, data);
70476890         break;
70486891         
70496892      case 0x0001:
7050         if (!state->map215_reg[2])
6893         if (!state->mmc_reg[2])
70516894            txrom_w(space, 0x0001, data);
7052         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!
6895         else if (state->mmc_reg[3] && ((state->mmc_reg[0] & 0x80) == 0 || (state->mmc_latch1 & 0x07) < 6))   // if we use the prg16 banks and cmd=6,7 DON'T enter!
70536896         {
7054            state->map215_reg[3] = 0;
6897            state->mmc_reg[3] = 0;
70556898            txrom_w(space, 0x0001, data);
70566899         }
70576900         break;
70586901         
70596902      case 0x2000:
7060         if (!state->map215_reg[2])
6903         if (!state->mmc_reg[2])
70616904            txrom_w(space, 0x2000, data);
70626905         else
70636906         {
70646907            data = (data & 0xc0) | conv_table[data & 0x07];
7065            state->map215_reg[3] = 1;
6908            state->mmc_reg[3] = 1;
70666909            txrom_w(space, 0x0000, data);
70676910            break;
70686911         }
70696912         break;
70706913
70716914      case 0x4000:
7072         if (!state->map215_reg[2])
6915         if (!state->mmc_reg[2])
70736916            txrom_w(space, 0x4000, data);
70746917         else
70756918            set_nt_mirroring(space->machine, ((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
70766919         break;
70776920
70786921      case 0x4001:
7079         if (!state->map215_reg[2])
6922         if (!state->mmc_reg[2])
70806923            txrom_w(space, 0x4001, data);
70816924         else
70826925            txrom_w(space, 0x6001, data);
70836926         break;
70846927
70856928      case 0x6001:
7086         if (!state->map215_reg[2])
6929         if (!state->mmc_reg[2])
70876930            txrom_w(space, 0x6001, data);
70886931         else
70896932         {
r8383r8384
75767419   txc_tw_l_w(space, offset & 0xff, data);   // offset does not really count for this mapper
75777420}
75787421
7579/* This is like mmc3 but with no PRG bankswitch (beacuse it is handled by low writes) */
7580static WRITE8_HANDLER( txc_tw_w )
7422/* writes to 0x8000-0xffff are like MMC3 but no PRG bankswitch (beacuse it is handled by low writes) */
7423static void txc_tw_prg_cb( running_machine *machine, int start, int bank )
75817424{
7582   nes_state *state = (nes_state *)space->machine->driver_data;
7583   UINT8 MMC3_helper, cmd;
7584   LOG_MMC(("txctw_w, offset: %04x, data: %02x\n", offset, data));
7585
7586   switch (offset & 0x6001)
7587   {
7588      case 0x0000:
7589         MMC3_helper = state->mmc_latch1 ^ data;
7590         state->mmc_latch1 = data;
7591
7592         /* Has CHR Mode changed? */
7593         if (MMC3_helper & 0x80)
7594            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
7595         break;
7596
7597      case 0x0001:
7598         cmd = state->mmc_latch1 & 0x07;
7599         switch (cmd)
7600         {
7601         case 0: case 1:
7602         case 2: case 3: case 4: case 5:
7603            state->mmc_vrom_bank[cmd] = data;
7604            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
7605            break;
7606         }
7607         break;
7608
7609      default:
7610         txrom_w(space, offset, data);
7611         break;
7612   }
7425   return;
76137426}
76147427
76157428/*************************************************************
r8383r8384
79807793   switch (offset & 0x6001)
79817794   {
79827795      case 0x0001:
7983         cmd = state->mmc_latch1 & 0x07;
7796         cmd = state->mmc3_latch & 0x07;
79847797         switch (cmd)
79857798         {
79867799         case 0:    // in this case we set prg_base in addition to state->mmc_vrom_bank!
r8383r8384
83668179{
83678180   nes_state *state = (nes_state *)machine->driver_data;
83688181   
8369   if (!(state->unl_8237_reg[0] & 0x80))
8182   if (!(state->mmc_reg[0] & 0x80))
83708183      prg8_x(machine, start, bank);
83718184}
83728185
83738186static void unl_8237_chr_cb( running_machine *machine, int start, int bank, int source )
83748187{
83758188   nes_state *state = (nes_state *)machine->driver_data;
8376   bank |= ((state->unl_8237_reg[1] << 6) & 0x100);
8189   bank |= ((state->mmc_reg[1] << 6) & 0x100);
83778190
83788191   chr1_x(machine, start, bank, source);
83798192}
r8383r8384
83868199
83878200   if (offset == 0x1000)
83888201   {
8389      state->unl_8237_reg[0] = data;
8390      if (state->unl_8237_reg[0] & 0x80)
8202      state->mmc_reg[0] = data;
8203      if (state->mmc_reg[0] & 0x80)
83918204      {
8392         if (state->unl_8237_reg[0] & 0x20)
8393            prg32(space->machine, (state->unl_8237_reg[0] & 0x0f) >> 1);
8205         if (state->mmc_reg[0] & 0x20)
8206            prg32(space->machine, (state->mmc_reg[0] & 0x0f) >> 1);
83948207         else
83958208         {
8396            prg16_89ab(space->machine, state->unl_8237_reg[0] & 0x1f);
8397            prg16_cdef(space->machine, state->unl_8237_reg[0] & 0x1f);
8209            prg16_89ab(space->machine, state->mmc_reg[0] & 0x1f);
8210            prg16_cdef(space->machine, state->mmc_reg[0] & 0x1f);
83988211         }
83998212      }
84008213      else
r8383r8384
84038216
84048217   if (offset == 0x1001)
84058218   {
8406      state->unl_8237_reg[1] = data;
8219      state->mmc_reg[1] = data;
84078220      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
84088221   }
84098222}
r8383r8384
84118224static WRITE8_HANDLER( unl_8237_w )
84128225{
84138226   nes_state *state = (nes_state *)space->machine->driver_data;
8414   static const UINT8 conv_table[8] = {0,2,6,1,7,3,4,5};
8227   static const UINT8 conv_table[8] = {0, 2, 6, 1, 7, 3, 4, 5};
84158228   LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data));
84168229
84178230   switch (offset & 0x7000)
r8383r8384
84238236         
84248237      case 0x2000:
84258238      case 0x3000:
8426         state->unl_8237_reg[2] = 1;
8239         state->mmc_reg[2] = 1;
84278240         data = (data & 0xc0) | conv_table[data & 0x07];
84288241         txrom_w(space, 0x0000, data);
84298242         break;
84308243
84318244      case 0x4000:
84328245      case 0x5000:
8433         if (state->unl_8237_reg[2])
8246         if (state->mmc_reg[2])
84348247         {
8435            state->unl_8237_reg[2] = 0;
8248            state->mmc_reg[2] = 0;
84368249            txrom_w(space, 0x0001, data);
84378250         }
84388251         break;
r8383r8384
87048517{
87058518   nes_state *state = (nes_state *)machine->driver_data;
87068519
8707   if (!(state->mapper187_reg[0] & 0x80))
8520   if (!(state->mmc_reg[0] & 0x80))
87088521      prg8_x(machine, start, bank);
87098522}
87108523
r8383r8384
87288541
87298542   if (offset == 0x1000)
87308543   {
8731      state->mapper187_reg[0] = data;
8544      state->mmc_reg[0] = data;
87328545
8733      if (state->mapper187_reg[0] & 0x80)
8546      if (state->mmc_reg[0] & 0x80)
87348547      {
8735         new_bank = (state->mapper187_reg[0] & 0x1f);
8548         new_bank = (state->mmc_reg[0] & 0x1f);
87368549
8737         if (state->mapper187_reg[0] & 0x20)
8550         if (state->mmc_reg[0] & 0x20)
87388551            prg32(space->machine, new_bank >> 2);
87398552         else
87408553         {
r8383r8384
87528565      {
87538566         case 0x00:
87548567         case 0x01:
8755            state->mapper187_reg[1] = 0x83;
8568            state->mmc_reg[1] = 0x83;
87568569            break;
87578570         case 0x02:
8758            state->mapper187_reg[1] = 0x42;
8571            state->mmc_reg[1] = 0x42;
87598572            break;
87608573         case 0x03:
8761            state->mapper187_reg[1] = 0x00;
8574            state->mmc_reg[1] = 0x00;
87628575            break;
87638576      }
87648577     
87658578   }
87668579   
8767   if (!state->mapper187_reg[3] && offset > 0x1000)
8580   if (!state->mmc_reg[3] && offset > 0x1000)
87688581   {
8769      state->mapper187_reg[3] = 1;
8582      state->mmc_reg[3] = 1;
87708583      memory_write_byte(space, 0x4017, 0x40);
87718584   }
87728585}
r8383r8384
87788591   offset += 0x100;
87798592
87808593   if (!(offset < 0x1000))
8781      return state->mapper187_reg[1];
8594      return state->mmc_reg[1];
87828595   else
87838596      return 0;
87848597}
r8383r8384
87918604   switch (offset & 0x6003)
87928605   {
87938606      case 0x0000:
8794         state->mapper187_reg[2] = 1;
8607         state->mmc_reg[2] = 1;
87958608         txrom_w(space, 0x0000, data);
87968609         break;
87978610
87988611      case 0x0001:
8799         if (state->mapper187_reg[2])
8612         if (state->mmc_reg[2])
88008613            txrom_w(space, 0x0001, data);
88018614         break;
88028615
r8383r8384
88048617         break;
88058618
88068619      case 0x0003:
8807         state->mapper187_reg[2] = 0;
8620         state->mmc_reg[2] = 0;
88088621
88098622         if (data == 0x28)
88108623            prg8_cd(space->machine, 0x17);
r8383r8384
91448957static WRITE8_HANDLER( unl_sf3_w )
91458958{
91468959   nes_state *state = (nes_state *)space->machine->driver_data;
9147   UINT8 MMC3_helper, cmd;
8960   UINT8 mmc_helper, cmd;
91488961   LOG_MMC(("unl_sf3_w, offset: %04x, data: %02x\n", offset, data));
91498962
91508963   switch (offset & 0x6001)
91518964   {
91528965      case 0x0000:
9153         MMC3_helper = state->mmc_latch1 ^ data;
9154         state->mmc_latch1 = data;
8966         mmc_helper = state->mmc3_latch ^ data;
8967         state->mmc3_latch = data;
91558968
91568969         /* Has PRG Mode changed? */
9157         if (MMC3_helper & 0x40)
8970         if (mmc_helper & 0x40)
91588971            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
91598972
91608973         /* Has CHR Mode changed? */
9161         if (MMC3_helper & 0x80)
8974         if (mmc_helper & 0x80)
91628975            unl_sf3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
91638976         break;
91648977
91658978      case 0x0001:
9166         cmd = state->mmc_latch1 & 0x0f;
8979         cmd = state->mmc3_latch & 0x0f;
91678980         switch (cmd)
9168      {
8981         {
91698982         case 0: case 2: case 4:
91708983            state->mmc_vrom_bank[cmd >> 1] = data;
91718984            unl_sf3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
r8383r8384
91758988            state->mmc_prg_bank[cmd - 6] = data;
91768989            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
91778990            break;
9178      }
8991         }
91798992         break;
91808993
91818994      default:
r8383r8384
97299542      switch (offset & 0x6001)
97309543      {
97319544         case 0x0001:
9732            if ((state->mmc_reg[3] & 0x02) && (state->mmc_latch1 & 0x08))
9545            if ((state->mmc_reg[3] & 0x02) && (state->mmc3_latch & 0x08))
97339546            {
9734               state->mmc_reg[4 | (state->mmc_latch1 & 0x03)] = data;
9547               state->mmc_reg[4 | (state->mmc3_latch & 0x03)] = data;
97359548               fk23c_set_prg(space->machine);
97369549               fk23c_set_chr(space->machine);
97379550            }
r8383r8384
97649577static void bmc_64in1nr_set_prg( running_machine *machine )
97659578{
97669579   nes_state *state = (nes_state *)machine->driver_data;
9767   UINT8 helper1 = (state->bmc_64in1nr_reg[1] & 0x1f);
9768   UINT8 helper2 = (helper1 << 1) | ((state->bmc_64in1nr_reg[1] & 0x40) >> 6);
9580   UINT8 helper1 = (state->mmc_reg[1] & 0x1f);
9581   UINT8 helper2 = (helper1 << 1) | ((state->mmc_reg[1] & 0x40) >> 6);
97699582
9770   if (state->bmc_64in1nr_reg[0] & 0x80)
9583   if (state->mmc_reg[0] & 0x80)
97719584   {
9772      if (state->bmc_64in1nr_reg[1] & 0x80)
9585      if (state->mmc_reg[1] & 0x80)
97739586         prg32(machine, helper1);
97749587      else
97759588      {
r8383r8384
97939606      case 0x1001:
97949607      case 0x1002:
97959608      case 0x1003:
9796         state->bmc_64in1nr_reg[offset & 0x03] = data;
9609         state->mmc_reg[offset & 0x03] = data;
97979610         bmc_64in1nr_set_prg(space->machine);
9798         chr8(space->machine, ((state->bmc_64in1nr_reg[0] >> 1) & 0x03) | (state->bmc_64in1nr_reg[2] << 2), CHRROM);
9611         chr8(space->machine, ((state->mmc_reg[0] >> 1) & 0x03) | (state->mmc_reg[2] << 2), CHRROM);
97999612         break;
98009613   }
98019614   if (offset == 0x1000)   /* reg[0] also sets mirroring */
r8383r8384
98079620   nes_state *state = (nes_state *)space->machine->driver_data;
98089621   LOG_MMC(("bmc_64in1nr_w offset: %04x, data: %02x\n", offset, data));
98099622
9810   state->bmc_64in1nr_reg[3] = data;   // reg[3] is currently unused?!?
9623   state->mmc_reg[3] = data;   // reg[3] is currently unused?!?
98119624}
98129625
98139626/*************************************************************
r8383r8384
99059718
99069719 Games: Super 24-in-1
99079720
9908 In MESS: Supported
9721 In MESS: Partially Supported
99099722
99109723 *************************************************************/
99119724
9912static void bmc_s24in1sc03_set_prg( running_machine *machine )
9725static void bmc_s24in1sc03_prg_cb( running_machine *machine, int start, int bank )
99139726{
99149727   nes_state *state = (nes_state *)machine->driver_data;
99159728   static const UINT8 masks[8] = {0x3f, 0x1f, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00};
9916   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
9917   int prg_base = state->bmc_s24in1sc03_reg[1] << 1;
9918   int prg_mask = masks[state->bmc_s24in1sc03_reg[0] & 0x07];
9729   int prg_base = state->mmc_reg[1] << 1;
9730   int prg_mask = masks[state->mmc_reg[0] & 0x07];
99199731
9920   prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
9921   prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask));
9922   prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
9923   prg8_ef(machine, prg_base | (state->mmc_prg_bank[3] & prg_mask));
9732   bank = prg_base | (bank & prg_mask);
9733   prg8_x(machine, start, bank);
99249734}
99259735
9926static void bmc_s24in1sc03_set_chr( running_machine *machine )
9736static void bmc_s24in1sc03_chr_cb( running_machine *machine, int start, int bank, int source )
99279737{
99289738   nes_state *state = (nes_state *)machine->driver_data;
9929   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
9930   UINT8 chr = (state->bmc_s24in1sc03_reg[0] & 0x20) ? CHRRAM : CHRROM;
9931   int chr_base = (state->bmc_s24in1sc03_reg[2] << 3) & 0xf00;
9932
9933   chr1_x(machine, chr_page ^ 0, chr_base | (state->mmc_vrom_bank[0] & ~0x01), chr);
9934   chr1_x(machine, chr_page ^ 1, chr_base | (state->mmc_vrom_bank[0] |  0x01), chr);
9935   chr1_x(machine, chr_page ^ 2, chr_base | (state->mmc_vrom_bank[1] & ~0x01), chr);
9936   chr1_x(machine, chr_page ^ 3, chr_base | (state->mmc_vrom_bank[1] |  0x01), chr);
9937   chr1_x(machine, chr_page ^ 4, chr_base | state->mmc_vrom_bank[2], chr);
9938   chr1_x(machine, chr_page ^ 5, chr_base | state->mmc_vrom_bank[3], chr);
9939   chr1_x(machine, chr_page ^ 6, chr_base | state->mmc_vrom_bank[4], chr);
9940   chr1_x(machine, chr_page ^ 7, chr_base | state->mmc_vrom_bank[5], chr);
9739   UINT8 chr = BIT(state->mmc_reg[0], 5) ? CHRRAM : CHRROM;
9740   int chr_base = (state->mmc_reg[2] << 3) & 0xf00;
9741   
9742   chr1_x(machine, start, chr_base | bank, chr);
99419743}
99429744
99439745static WRITE8_HANDLER( bmc_s24in1sc03_l_w )
r8383r8384
99489750
99499751   if (offset == 0x1ff0)
99509752   {
9951      state->bmc_s24in1sc03_reg[0] = data;
9952      bmc_s24in1sc03_set_prg(space->machine);
9953      bmc_s24in1sc03_set_chr(space->machine);
9753      state->mmc_reg[0] = data;
9754      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
9755      mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
99549756   }
99559757
99569758   if (offset == 0x1ff1)
99579759   {
9958      state->bmc_s24in1sc03_reg[1] = data;
9959      bmc_s24in1sc03_set_prg(space->machine);
9760      state->mmc_reg[1] = data;
9761      mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
99609762   }
99619763
99629764   if (offset == 0x1ff2)
99639765   {
9964      state->bmc_s24in1sc03_reg[2] = data;
9965      bmc_s24in1sc03_set_chr(space->machine);
9766      state->mmc_reg[2] = data;
9767      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
99669768   }
99679769}
99689770
9969static WRITE8_HANDLER( bmc_s24in1sc03_w )
9970{
9971   nes_state *state = (nes_state *)space->machine->driver_data;
9972   UINT8 cmd, bmc_s24in1sc03_helper;
9973   LOG_MMC(("bmc_s24in1sc03_w offset: %04x, data: %02x\n", offset, data));
9974
9975   switch (offset & 0x6001)
9976   {
9977      case 0x0000:
9978         bmc_s24in1sc03_helper = state->mmc_latch1 ^ data;
9979         state->mmc_latch1 = data;
9980
9981         /* Has PRG Mode changed? */
9982         if (bmc_s24in1sc03_helper & 0x40)
9983            bmc_s24in1sc03_set_prg(space->machine);
9984
9985         /* Has CHR Mode changed? */
9986         if (bmc_s24in1sc03_helper & 0x80)
9987            bmc_s24in1sc03_set_chr(space->machine);
9988         break;
9989
9990      case 0x0001:
9991         cmd = state->mmc_latch1 & 0x07;
9992         switch (cmd)
9993      {
9994         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
9995         case 2: case 3: case 4: case 5:
9996            state->mmc_vrom_bank[cmd] = data;
9997            bmc_s24in1sc03_set_chr(space->machine);
9998            break;
9999         case 6:
10000         case 7:
10001            state->mmc_prg_bank[cmd - 6] = data;
10002            bmc_s24in1sc03_set_prg(space->machine);
10003            break;
10004      }
10005         break;
10006
10007      default:
10008         txrom_w(space, offset, data);
10009         break;
10010   }
10011}
10012
100139771/*************************************************************
100149772
100159773 Board BMC-T-262
r8383r8384
1074110499
1074210500   /* This bit is the "register lock". Once register are locked, writes go to WRAM
1074310501     and there is no way to unlock them (except by resetting the machine) */
10744   if ((state->mapper45_reg[3] & 0x40) && state->wram != NULL)
10502   if ((state->mmc_reg[3] & 0x40) && state->wram != NULL)
1074510503      state->wram[offset] = data;
1074610504   else
1074710505   {
10748      state->mapper45_reg[state->mmc_count] = data;
10506      state->mmc_reg[state->mmc_count] = data;
1074910507      state->mmc_count = (state->mmc_count + 1) & 0x03;
1075010508
1075110509      if (!state->mmc_count)
1075210510      {
10753         LOG_MMC(("bmc_hik8_m_w, command completed %02x %02x %02x %02x\n", state->mapper45_reg[3],
10754                state->mapper45_reg[2], state->mapper45_reg[1], state->mapper45_reg[0]));
10511         LOG_MMC(("bmc_hik8_m_w, command completed %02x %02x %02x %02x\n", state->mmc_reg[3],
10512                state->mmc_reg[2], state->mmc_reg[1], state->mmc_reg[0]));
1075510513
10756         state->mmc_prg_base = state->mapper45_reg[1];
10757         state->mmc_prg_mask = 0x3f ^ (state->mapper45_reg[3] & 0x3f);
10758         state->mmc_chr_base = ((state->mapper45_reg[2] & 0xf0) << 4) | state->mapper45_reg[0];
10759         if (BIT(state->mapper45_reg[2], 3))
10760            state->mmc_chr_mask = (1 << ((state->mapper45_reg[2] & 7) + 1)) - 1;
10761         else if (state->mapper45_reg[2])
10514         state->mmc_prg_base = state->mmc_reg[1];
10515         state->mmc_prg_mask = 0x3f ^ (state->mmc_reg[3] & 0x3f);
10516         state->mmc_chr_base = ((state->mmc_reg[2] & 0xf0) << 4) | state->mmc_reg[0];
10517         if (BIT(state->mmc_reg[2], 3))
10518            state->mmc_chr_mask = (1 << ((state->mmc_reg[2] & 7) + 1)) - 1;
10519         else if (state->mmc_reg[2])
1076210520            state->mmc_chr_mask = 0;
1076310521         else
1076410522            state->mmc_chr_mask = 0xff;   // i.e. we use the vrom_bank with no masking
r8383r8384
1079010548   /* mid writes only work when WRAM is enabled. not sure if I should
1079110549     change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of
1079210550     the read-only bit?) */
10793   if (state->mmc_latch2 & 0x80)
10551   if (state->mmc3_wram_protect & 0x80)
1079410552   {
1079510553      if (data & 0x01)   /* if this is 0, then we have 32k PRG blocks */
1079610554      {
r8383r8384
1082310581static void bmc_ball11_set_banks( running_machine *machine )
1082410582{
1082510583   nes_state *state = (nes_state *)machine->driver_data;
10826   set_nt_mirroring(machine, (state->mapper51_reg[0] == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10584   set_nt_mirroring(machine, (state->mmc_reg[0] == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1082710585
10828   if (state->mapper51_reg[0] & 0x01)
10586   if (state->mmc_reg[0] & 0x01)
1082910587   {
10830      prg32(machine, state->mapper51_reg[1]);
10588      prg32(machine, state->mmc_reg[1]);
1083110589   }
1083210590   else
1083310591   {
10834      prg16_89ab(machine, (state->mapper51_reg[1] << 1) | (state->mapper51_reg[0] >> 1));
10835      prg16_cdef(machine, (state->mapper51_reg[1] << 1) | 0x07);
10592      prg16_89ab(machine, (state->mmc_reg[1] << 1) | (state->mmc_reg[0] >> 1));
10593      prg16_cdef(machine, (state->mmc_reg[1] << 1) | 0x07);
1083610594   }
1083710595}
1083810596
r8383r8384
1084210600
1084310601   LOG_MMC(("bmc_ball11_m_w, offset: %04x, data: %02x\n", offset, data));
1084410602
10845   state->mapper51_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02);
10603   state->mmc_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02);
1084610604   bmc_ball11_set_banks(space->machine);
1084710605}
1084810606
r8383r8384
1085510613   switch (offset & 0x6000)
1085610614   {
1085710615      case 0x4000:   // here we also update reg[0] upper bit
10858         state->mapper51_reg[0] = (state->mapper51_reg[0] & 0x01) | ((data >> 3) & 0x02);
10616         state->mmc_reg[0] = (state->mmc_reg[0] & 0x01) | ((data >> 3) & 0x02);
1085910617      case 0x0000:
1086010618      case 0x2000:
1086110619      case 0x6000:
10862         state->mapper51_reg[1] = data & 0x0f;
10620         state->mmc_reg[1] = data & 0x0f;
1086310621         bmc_ball11_set_banks(space->machine);
1086410622         break;
1086510623   }
r8383r8384
1088910647   /* mid writes only work when WRAM is enabled. not sure if I should
1089010648     change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of
1089110649     the read-only bit?) and it only can happen once! */
10892   if ((state->mmc_latch2 & 0x80) && !state->map52_reg_written)
10650   if ((state->mmc3_wram_protect & 0x80) && !state->map52_reg_written)
1089310651   {
1089410652      map52_helper1 = (data & 0x08);
1089510653      map52_helper2 = (data & 0x40);
r8383r8384
1092610684static void bmc_gc6in1_set_prg( running_machine *machine, int prg_base, int prg_mask )
1092710685{
1092810686   nes_state *state = (nes_state *)machine->driver_data;
10929   state->mmc_prg_base = (state->map217_reg[1] & 0x08) ? 0 : (state->map217_reg[1] & 0x10);
10930   state->mmc_prg_mask = (state->map217_reg[1] & 0x08) ? 0x1f : 0x0f;
10687   state->mmc_prg_base = (state->mmc_reg[1] & 0x08) ? 0 : (state->mmc_reg[1] & 0x10);
10688   state->mmc_prg_mask = (state->mmc_reg[1] & 0x08) ? 0x1f : 0x0f;
1093110689
10932   state->mmc_prg_base |= ((state->map217_reg[1] & 0x03) << 5);
10690   state->mmc_prg_base |= ((state->mmc_reg[1] & 0x03) << 5);
1093310691
1093410692   mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
1093510693}
r8383r8384
1093810696{
1093910697   nes_state *state = (nes_state *)machine->driver_data;
1094010698   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
10941   int chr_base = (state->map217_reg[1] & 0x08) ? 0x00 : ((state->map217_reg[1] & 0x10) << 3);
10942   int chr_mask = (state->map217_reg[1] & 0x08) ? 0xff : 0x7f;
10699   int chr_base = (state->mmc_reg[1] & 0x08) ? 0x00 : ((state->mmc_reg[1] & 0x10) << 3);
10700   int chr_mask = (state->mmc_reg[1] & 0x08) ? 0xff : 0x7f;
1094310701
10944   chr_base |= ((state->map217_reg[1] & 0x03) << 8);
10702   chr_base |= ((state->mmc_reg[1] & 0x03) << 8);
1094510703
1094610704   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
1094710705   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
r8383r8384
1096210720
1096310721   if (offset == 0x1000)
1096410722   {
10965      state->map217_reg[0] = data;
10723      state->mmc_reg[0] = data;
1096610724      if (data & 0x80)
1096710725      {
10968         bank = (data & 0x0f) | ((state->map217_reg[1] & 0x03) << 4);
10726         bank = (data & 0x0f) | ((state->mmc_reg[1] & 0x03) << 4);
1096910727         prg16_89ab(space->machine, bank);
1097010728         prg16_cdef(space->machine, bank);
1097110729      }
r8383r8384
1097410732   }
1097510733   else if (offset == 0x1001)
1097610734   {
10977      state->map217_reg[1] = data;
10735      state->mmc_reg[1] = data;
1097810736      bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1097910737   }
1098010738   else if (offset == 0x1007)
1098110739   {
10982      state->map217_reg[2] = data;
10740      state->mmc_reg[2] = data;
1098310741   }
1098410742}
1098510743
1098610744static WRITE8_HANDLER( bmc_gc6in1_w )
1098710745{
1098810746   nes_state *state = (nes_state *)space->machine->driver_data;
10989   UINT8 MMC3_helper, cmd;
10747   UINT8 mmc_helper, cmd;
1099010748   static const UINT8 conv_table[8] = {0, 6, 3, 7, 5, 2, 4, 1};
1099110749   LOG_MMC(("bmc_gc6in1_w, offset: %04x, data: %02x\n", offset, data));
1099210750
10993   if (!state->map217_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers
10751   if (!state->mmc_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers
1099410752   {
1099510753      switch (offset & 0x6001)
1099610754      {
1099710755         case 0x0000:
10998            MMC3_helper = state->mmc_latch1 ^ data;
10999            state->mmc_latch1 = data;
10756            mmc_helper = state->mmc3_latch ^ data;
10757            state->mmc3_latch = data;
1100010758
1100110759            /* Has PRG Mode changed? */
11002            if (MMC3_helper & 0x40)
10760            if (mmc_helper & 0x40)
1100310761               bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1100410762
1100510763            /* Has CHR Mode changed? */
11006            if (MMC3_helper & 0x80)
10764            if (mmc_helper & 0x80)
1100710765               bmc_gc6in1_set_chr(space->machine, state->mmc_chr_source);
1100810766            break;
1100910767
1101010768         case 0x0001:
11011            cmd = state->mmc_latch1 & 0x07;
10769            cmd = state->mmc3_latch & 0x07;
1101210770            switch (cmd)
1101310771         {
1101410772            case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
r8383r8384
1103910797
1104010798         case 0x0001:
1104110799            data = (data & 0xc0) | conv_table[data & 0x07];
11042            MMC3_helper = state->mmc_latch1 ^ data;
11043            state->mmc_latch1 = data;
10800            mmc_helper = state->mmc3_latch ^ data;
10801            state->mmc3_latch = data;
1104410802
1104510803            /* Has PRG Mode changed? */
11046            if (MMC3_helper & 0x40)
10804            if (mmc_helper & 0x40)
1104710805               bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1104810806
1104910807            /* Has CHR Mode changed? */
11050            if (MMC3_helper & 0x80)
10808            if (mmc_helper & 0x80)
1105110809               bmc_gc6in1_set_chr(space->machine, state->mmc_chr_source);
1105210810
11053            state->map217_reg[3] = 1;
10811            state->mmc_reg[3] = 1;
1105410812            break;
1105510813
1105610814         case 0x2000:
11057            cmd = state->mmc_latch1 & 0x07;
11058            if (state->map217_reg[3])
10815            cmd = state->mmc3_latch & 0x07;
10816            if (state->mmc_reg[3])
1105910817            {
11060               state->map217_reg[3] = 0;
10818               state->mmc_reg[3] = 0;
1106110819               switch (cmd)
1106210820               {
1106310821                  case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
r8383r8384
1152211280static void pjoy84_prg_cb( running_machine *machine, int start, int bank )
1152311281{
1152411282   nes_state *state = (nes_state *)machine->driver_data;
11525   UINT8 flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
11283   UINT8 flip = (state->mmc3_latch & 0x40) ? 2 : 0;
1152611284   
1152711285   if (!(state->mmc_reg[3] & 0x03))
1152811286      prg8_x(machine, start, bank);
r8383r8384
1165011408
1165111409   if (data & 0x80)
1165211410   {
11653      state->mmc_count = 0;
11654      state->mmc_latch2 = 0;
11411      state->mmc1_count = 0;
11412      state->mmc1_latch = 0;
1165511413     
1165611414      state->mmc_reg[0] |= 0x0c;
1165711415      someri_mmc1_set_prg(space->machine);
1165811416      return;
1165911417   }
1166011418   
11661   if (state->mmc_count < 5)
11419   if (state->mmc1_count < 5)
1166211420   {
11663      if (state->mmc_count == 0) state->mmc_latch2 = 0;
11664      state->mmc_latch2 >>= 1;
11665      state->mmc_latch2 |= (data & 0x01) ? 0x10 : 0x00;
11666      state->mmc_count++;
11421      if (state->mmc1_count == 0) state->mmc1_latch = 0;
11422      state->mmc1_latch >>= 1;
11423      state->mmc1_latch |= (data & 0x01) ? 0x10 : 0x00;
11424      state->mmc1_count++;
1166711425   }
1166811426   
11669   if (state->mmc_count == 5)
11427   if (state->mmc1_count == 5)
1167011428   {
1167111429      switch (offset & 0x6000)
1167211430      {
1167311431         case 0x0000:
11674            state->mmc_reg[0] = state->mmc_latch2;
11432            state->mmc_reg[0] = state->mmc1_latch;
1167511433            switch (state->mmc_reg[0] & 0x03)
1167611434            {
1167711435            case 0: set_nt_mirroring(space->machine, PPU_MIRROR_LOW); break;
r8383r8384
1168311441            someri_mmc1_set_prg(space->machine);
1168411442            break;
1168511443         case 0x2000:
11686            state->mmc_reg[1] = state->mmc_latch2;
11444            state->mmc_reg[1] = state->mmc1_latch;
1168711445            someri_mmc1_set_chr(space->machine);
1168811446            someri_mmc1_set_prg(space->machine);
1168911447            break;
1169011448         case 0x4000:
11691            state->mmc_reg[2] = state->mmc_latch2;
11449            state->mmc_reg[2] = state->mmc1_latch;
1169211450            someri_mmc1_set_chr(space->machine);
1169311451            break;
1169411452         case 0x6000:
11695            state->mmc_reg[3] = state->mmc_latch2;
11453            state->mmc_reg[3] = state->mmc1_latch;
1169611454            someri_mmc1_set_prg(space->machine);
1169711455            break;
1169811456      }
1169911457     
11700      state->mmc_count = 0;
11458      state->mmc1_count = 0;
1170111459   }
1170211460}
1170311461
r8383r8384
1170511463static WRITE8_HANDLER( someri_mmc3_w )
1170611464{
1170711465   nes_state *state = (nes_state *)space->machine->driver_data;
11708   UINT8 mmc3_helper, cmd;
11466   UINT8 mmc_helper, cmd;
1170911467   
1171011468   assert(state->mmc_cmd1 == 1);
1171111469   switch (offset & 0x6001)
1171211470   {
1171311471      case 0x0000:
11714         mmc3_helper = state->mmc_latch1 ^ data;
11715         state->mmc_latch1 = data;
11472         mmc_helper = state->mmc3_latch ^ data;
11473         state->mmc3_latch = data;
1171611474         
11717         if (mmc3_helper & 0x40)
11475         if (mmc_helper & 0x40)
1171811476            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1171911477         
11720         if (mmc3_helper & 0x80)
11478         if (mmc_helper & 0x80)
1172111479            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
1172211480         break;
1172311481         
1172411482      case 0x0001:
11725         cmd = state->mmc_latch1 & 0x07;
11483         cmd = state->mmc3_latch & 0x07;
1172611484         switch (cmd)
1172711485         {
1172811486         case 0: case 1:
r8383r8384
1193711695   return 0x00;
1193811696}
1193911697
11940// further review needed for: TXROM, PXROM, FXROM, Bandai LZ93D50, Irem G-101, Konami VRC3
11941// all multicart pcb, many unl/btl pcbs
1194211698static const nes_pcb_intf nes_intf_list[] =
1194311699{
1194411700   { STD_NROM,             NES_NOACCESS, NES_NOACCESS, NES_NOACCESS,                         NULL, NULL, NULL },
r8383r8384
1196511721   { STD_TXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },
1196611722   { STD_TVROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },
1196711723   { STD_TKROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },
11968   { STD_HKROM,            NES_NOACCESS, {hkrom_m_w, hkrom_m_r}, NES_WRITEONLY(hkrom_w),               NULL, NULL, mmc3_irq },
11724   { STD_HKROM,            NES_NOACCESS, {hkrom_m_w, hkrom_m_r}, NES_WRITEONLY(hkrom_w),     NULL, NULL, mmc3_irq },
1196911725   { STD_TQROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tqrom_w),               NULL, NULL, mmc3_irq },
1197011726   { STD_TXSROM,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txsrom_w),              NULL, NULL, mmc3_irq },
1197111727   { STD_DXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dxrom_w),               NULL, NULL, NULL },
r8383r8384
1203311789   { DREAMTECH_BOARD,      NES_WRITEONLY(dreamtech_l_w), NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
1203411790   { FUTUREMEDIA_BOARD,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(futuremedia_w),         NULL, NULL, futuremedia_irq },
1203511791   { FUKUTAKE_BOARD,       {fukutake_l_w, fukutake_l_r}, NES_NOACCESS, NES_NOACCESS,         NULL, NULL, NULL },
12036   { GOUDER_37017,         {gouder_sf4_l_w, gouder_sf4_l_r}, NES_NOACCESS, NES_WRITEONLY(gouder_sf4_w), NULL, NULL, mmc3_irq },
11792   { GOUDER_37017,         {gouder_sf4_l_w, gouder_sf4_l_r}, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1203711793   { HENGEDIANZI_BOARD,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(henggedianzi_w),        NULL, NULL, NULL },
1203811794   { HENGEDIANZI_XJZB,     NES_WRITEONLY(heng_xjzb_l_w), NES_NOACCESS, NES_WRITEONLY(heng_xjzb_w), NULL, NULL, NULL },
1203911795   { HES6IN1_BOARD,        NES_WRITEONLY(hes6in1_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
r8383r8384
1204511801   { KAISER_KS202,         NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ks202_w),               NULL, NULL, ks7032_irq },
1204611802   { KAISER_KS7017,      NES_WRITEONLY(ks7017_l_w), NES_NOACCESS, NES_NOACCESS,            NULL, NULL, mmc_fds_irq },
1204711803   { KAY_PANDAPRINCE,      {kay_pp_l_w, kay_pp_l_r}, NES_NOACCESS, NES_WRITEONLY(kay_pp_w),  NULL, NULL, mmc3_irq },
12048   { KASING_BOARD,         NES_NOACCESS, NES_WRITEONLY(kasing_m_w), NES_WRITEONLY(kasing_w), NULL, NULL, mmc3_irq },
11804   { KASING_BOARD,         NES_NOACCESS, NES_WRITEONLY(kasing_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1204911805   { SACHEN_74LS374,       {sachen_74x374_l_w, sachen_74x374_l_r}, NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL },
1205011806   { SACHEN_74LS374_A,     NES_WRITEONLY(sachen_74x374a_l_w), NES_NOACCESS, NES_NOACCESS,    NULL, NULL, NULL },
1205111807   { SACHEN_8259A,         NES_WRITEONLY(s8259_l_w), NES_WRITEONLY(s8259_m_w), NES_NOACCESS, NULL, NULL, NULL },
r8383r8384
1207011826   { OPENCORP_DAOU306,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(daou306_w),             NULL, NULL, NULL },
1207111827   { RCM_GS2015,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(gs2015_w),              NULL, NULL, NULL },
1207211828   { RCM_TETRISFAMILY,     NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rcm_tf_w),              NULL, NULL, NULL },
12073   { REXSOFT_DBZ5,         {rex_dbz_l_w, rex_dbz_l_r}, NES_NOACCESS, NES_WRITEONLY(rex_dbz_w), NULL, NULL, mmc3_irq },
11829   { REXSOFT_DBZ5,         {rex_dbz_l_w, rex_dbz_l_r}, NES_READONLY(rex_dbz_l_r), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1207411830   { REXSOFT_SL1632,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(rex_sl1632_w),          NULL, NULL, mmc3_irq },
1207511831   { RUMBLESTATION_BOARD,  NES_NOACCESS, NES_WRITEONLY(rumblestation_m_w), NES_WRITEONLY(rumblestation_w),      NULL, NULL, NULL },
1207611832   { SOMERI_SL12,          NES_WRITEONLY(someri_l_w), NES_NOACCESS, NES_WRITEONLY(someri_w), NULL, NULL, mmc3_irq },
r8383r8384
1208211838   { TXC_22211A,           {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
1208311839   { TXC_22211B,           {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211b_w), NULL, NULL, NULL },
1208411840   { TXC_22211C,           {txc_22211_l_w, txc_22211c_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
12085   { TXC_TW,               NES_WRITEONLY(txc_tw_l_w), NES_WRITEONLY(txc_tw_m_w), NES_WRITEONLY(txc_tw_w), NULL, NULL, mmc3_irq },
11841   { TXC_TW,               NES_WRITEONLY(txc_tw_l_w), NES_WRITEONLY(txc_tw_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1208611842   { TXC_STRIKEWOLF,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txc_strikewolf_w),      NULL, NULL, NULL },
1208711843   { TXC_MXMDHTWO,         NES_READONLY(txc_mxmdhtwo_l_r), NES_NOACCESS, NES_WRITEONLY(txc_mxmdhtwo_w), NULL, NULL, NULL },
1208811844   { WAIXING_TYPE_A,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
r8383r8384
1211811874   { UNL_XZY,              NES_WRITEONLY(unl_xzy_l_w), NES_NOACCESS, NES_NOACCESS,           NULL, NULL, NULL },
1211911875   { UNL_RACERMATE,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_racmate_w),         NULL, NULL, NULL },
1212011876   { UNL_STUDYNGAME,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sng32_w),               NULL, NULL, NULL },
12121   { UNL_603_5052,         {unl_6035052_extra_w, unl_6035052_extra_r}, {unl_6035052_extra_w, unl_6035052_extra_r}, NES_WRITEONLY(txrom_w), NULL, NULL, NULL },
11877   { UNL_603_5052,         {unl_6035052_extra_w, unl_6035052_extra_r}, {unl_6035052_extra_w, unl_6035052_extra_r}, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1212211878   { UNL_EDU2K,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(edu2k_w),               NULL, NULL, NULL },
1212311879   { UNL_SHJY3,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(shjy3_w),               NULL, NULL, shjy3_irq },
1212411880   { UNL_H2288,            {h2288_l_w, h2288_l_r}, NES_NOACCESS, NES_WRITEONLY(h2288_w),     NULL, NULL, mmc3_irq },
r8383r8384
1213111887   { BTL_SMB3,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_smb3_w),            NULL, NULL, btl_smb3_irq },
1213211888   { BTL_SUPERBROS11,      NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(btl_smb11_w),           NULL, NULL, mmc3_irq },
1213311889   { BTL_TOBIDASE,         NES_WRITEONLY(btl_tobi_l_w), NES_NOACCESS, NES_NOACCESS,          NULL, NULL, NULL },
12134   { BTL_PIKACHUY2K,       NES_NOACCESS, {btl_pika_y2k_m_w, btl_pika_y2k_m_r}, NES_WRITEONLY(btl_pika_y2k_w),  NULL, NULL, NULL },
11890   { BTL_PIKACHUY2K,       NES_NOACCESS, {btl_pika_y2k_m_w, btl_pika_y2k_m_r}, NES_WRITEONLY(btl_pika_y2k_w),  NULL, NULL, mmc3_irq },
1213511891   { WHIRLWIND_2706,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(whirl2706_w),           NULL, NULL, NULL },
1213611892   //
1213711893   { BMC_190IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_190in1_w),          NULL, NULL, NULL },
r8383r8384
1216011916   { BMC_22GAMES,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_22g_w),             NULL, NULL, NULL },
1216111917   { BMC_20IN1,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_20in1_w),           NULL, NULL, NULL },
1216211918   { BMC_110IN1,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_110in1_w),          NULL, NULL, NULL },
12163   { BMC_64IN1NR,          NES_WRITEONLY(bmc_64in1nr_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_64in1nr_w),      NULL, NULL, NULL },
12164   { BMC_S24IN1SC03,       NES_WRITEONLY(bmc_s24in1sc03_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_s24in1sc03_w),      NULL, NULL, mmc3_irq },
11919   { BMC_64IN1NR,          NES_WRITEONLY(bmc_64in1nr_l_w), NES_NOACCESS, NES_WRITEONLY(bmc_64in1nr_w), NULL, NULL, NULL },
11920   { BMC_S24IN1SC03,       NES_WRITEONLY(bmc_s24in1sc03_l_w), NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1216511921   { BMC_HIK8IN1,          NES_NOACCESS, NES_WRITEONLY(bmc_hik8_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1216611922   { BMC_SUPERHIK_4IN1,    NES_NOACCESS, NES_WRITEONLY(bmc_hik4in1_m_w), NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq },
1216711923   { BMC_SUPERBIG_7IN1,    NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(bmc_sbig7_w),           NULL, NULL, mmc3_irq },
r8383r8384
1227812034
1227912035   switch (state->pcb_id)
1228012036   {
12037      case STD_TXSROM:
12038         state->mmc3_chr_cb = txsrom_chr_cb;
12039         break;
12040      case GOUDER_37017:
12041         state->mmc3_prg_cb = gouder_sf4_prg_cb;
12042         break;
12043      case KASING_BOARD:
12044         state->mmc3_prg_cb = kasing_prg_cb;
12045         break;
12046      case REXSOFT_DBZ5:
12047         state->mmc3_chr_cb = rex_dbz_chr_cb;
12048         break;
12049      case TXC_TW:
12050         state->mmc3_prg_cb = txc_tw_prg_cb;
12051         break;
1228112052      case WAIXING_TYPE_A:
1228212053         state->mmc3_chr_cb = waixing_a_chr_cb;
1228312054         break;
r8383r8384
1233212103         state->mmc3_prg_cb = fk23c_prg_cb;
1233312104         state->mmc3_chr_cb = fk23c_chr_cb;
1233412105         break;
12106      case BMC_S24IN1SC03:
12107         state->mmc3_prg_cb = bmc_s24in1sc03_prg_cb;
12108         state->mmc3_chr_cb = bmc_s24in1sc03_chr_cb;
12109         break;
1233512110      case BMC_PJOY84:
1233612111         state->mmc3_prg_cb = pjoy84_prg_cb;
1233712112         state->mmc3_chr_cb = pjoy84_chr_cb;
src/mess/machine/nes_unif.c
r8383r8384
161161   state->mmc3_alt_irq = IRQ_type;      // later MMC3 boards seem to use MMC6-type IRQ... more investigations are in progress at NESDev...
162162   state->mmc_prg_bank[0] = state->mmc_prg_bank[2] = 0xfe;   // prg_bank[2] & prg_bank[3] remain always the same in most MMC3 variants
163163   state->mmc_prg_bank[1] = state->mmc_prg_bank[3] = 0xff;   // but some pirate clone mappers change them after writing certain registers
164   state->mmc_latch1 = 0;
165   state->mmc_latch2 = 0x80;
164   state->mmc3_latch = 0;
165   state->mmc3_wram_protect = 0x80;
166166   state->mmc_prg_base = state->mmc_chr_base = 0;
167167   state->mmc_prg_mask = prg_mask;
168168   state->mmc_chr_mask = chr_mask;
r8383r8384
314314      case STD_SOROM:
315315      case STD_SXROM_A:
316316      case STD_SOROM_A:
317         state->mmc_count = 0;
317         state->mmc1_latch = 0;
318         state->mmc1_count = 0;
318319         state->mmc_reg[0] = 0x0f;
319320         state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
320321         state->mmc1_reg_write_enable = 1;
r8383r8384
324325         wram_bank(machine, 0, (idx == STD_SOROM) ? NES_WRAM : NES_BATTERY);
325326         break;
326327      case STD_PXROM:   // mapper 9
327         state->MMC2_regs[0] = state->MMC2_regs[2] = 0;
328         state->MMC2_regs[1] = state->MMC2_regs[3] = 0;
328         state->mmc_reg[0] = state->mmc_reg[2] = 0;
329         state->mmc_reg[1] = state->mmc_reg[3] = 0;
329330         state->mmc_latch1 = state->mmc_latch2 = 0xfe;
330331         prg8_89(machine, 0);
331332         prg8_ab(machine, (state->prg_chunks << 1) - 3);
r8383r8384
333334         prg8_ef(machine, (state->prg_chunks << 1) - 1);
334335         break;
335336      case STD_FXROM: // mapper 10
336         state->MMC2_regs[0] = state->MMC2_regs[2] = 0;
337         state->MMC2_regs[1] = state->MMC2_regs[3] = 0;
337         state->mmc_reg[0] = state->mmc_reg[2] = 0;
338         state->mmc_reg[1] = state->mmc_reg[3] = 0;
338339         state->mmc_latch1 = state->mmc_latch2 = 0xfe;
339340         prg16_89ab(machine, 0);
340341         prg16_cdef(machine, state->prg_chunks - 1);
r8383r8384
471472         state->mmc_extra_bank[3] = 0xff;
472473         state->mmc_extra_bank[0] = state->mmc_extra_bank[1] = state->mmc_extra_bank[4] = state->mmc_extra_bank[5] = state->mmc_extra_bank[6] = 0;
473474         state->mmc_extra_bank[7] = state->mmc_extra_bank[8] = state->mmc_extra_bank[9] = state->mmc_extra_bank[0xa] = state->mmc_extra_bank[0xb] = 0;
474         state->map14_reg[0] = state->map14_reg[1] = 0;
475         state->mmc_reg[0] = state->mmc_reg[1] = 0;
475476         mmc3_common_initialize(machine, 0xff, 0xff, 0);
476477         break;
477478// mapper 15
r8383r8384
511512         break;
512513// mapper 45
513514      case BMC_HIK8IN1:
514         state->mapper45_reg[0] = state->mapper45_reg[1] = state->mapper45_reg[2] = state->mapper45_reg[3] = 0;
515         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
515516         mmc3_common_initialize(machine, 0x3f, 0xff, 0);
516517         break;
517518
r8383r8384
525526         break;
526527// mapper 51
527528      case BMC_BALLGAMES_11IN1:
528         state->mapper51_reg[0] = 0x01;
529         state->mapper51_reg[1] = 0x00;
529         state->mmc_reg[0] = 0x01;
530         state->mmc_reg[1] = 0x00;
530531         bmc_ball11_set_banks(machine);
531532         break;
532533// mapper 52
r8383r8384
602603         break;
603604// mapper 115
604605      case KASING_BOARD:
605         state->mapper115_reg[0] = 0;
606         state->mmc_reg[0] = 0;
606607         mmc3_common_initialize(machine, 0xff, 0xff, 0);
607608         break;
608609// mapper 116
r8383r8384
611612         state->mmc_prg_mask = 0xff;
612613         state->mmc_chr_mask = 0xff;
613614         state->mmc_cmd1 = 2; // mode
614         state->mmc_latch1 = 0;
615         state->mmc_latch2 = 0;
615         state->mmc3_latch = 0;
616         state->mmc3_wram_protect = 0;
616617         // MMC1 regs
617         state->mmc_count = 0;
618         state->mmc1_count = 0;
618619         state->mmc_reg[0] = 0x0c;
619620         state->mmc_reg[1] = 0x00;
620621         state->mmc_reg[2] = 0x00;
r8383r8384
739740
740741// mapper 187
741742      case UNL_KOF96:
742         state->mapper187_reg[0] = state->mapper187_reg[1] = state->mapper187_reg[2] = state->mapper187_reg[3] = 0;
743         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
743744         mmc3_common_initialize(machine, 0xff, 0xff, 0);
744745         break;
745746// mapper 189
r8383r8384
814815
815816// mapper 208
816817      case GOUDER_37017:
818         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = state->mmc_reg[4] = 0;
817819         mmc3_common_initialize(machine, 0xff, 0xff, 0);
818         state->map208_reg[0] = state->map208_reg[1] = state->map208_reg[2] = state->map208_reg[3] = state->map208_reg[4] = 0;
819820         break;
820821// mapper 212
821822      case BMC_SUPERHIK_300IN1:
r8383r8384
825826
826827// mapper 215
827828      case SUPERGAME_BOOGERMAN:
828         state->map215_reg[0] = 0x00;
829         state->map215_reg[1] = 0xff;
830         state->map215_reg[2] = 0x04;
831         state->map215_reg[3] = 0;
829         state->mmc_reg[0] = 0x00;
830         state->mmc_reg[1] = 0xff;
831         state->mmc_reg[2] = 0x04;
832         state->mmc_reg[3] = 0;
832833         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
833834         sgame_boog_set_prg(machine);
834835         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
r8383r8384
837838// mapper 217
838839      case BMC_GOLDENCARD_6IN1:
839840         mmc3_common_initialize(machine, 0xff, 0xff, 0);
840         state->map217_reg[0] = 0x00;
841         state->map217_reg[1] = 0xff;
842         state->map217_reg[2] = 0x03;
843         state->map217_reg[3] = 0;
841         state->mmc_reg[0] = 0x00;
842         state->mmc_reg[1] = 0xff;
843         state->mmc_reg[2] = 0x03;
844         state->mmc_reg[3] = 0;
844845         bmc_gc6in1_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
845846         bmc_gc6in1_set_chr(machine, state->mmc_chr_source);
846847         break;
r8383r8384
853854// mapper 223?
854855      case WAIXING_TYPE_I:
855856         mmc3_common_initialize(machine, 0xff, 0xff, 0);
856         state->mmc_latch2 = 0;
857         state->mmc3_wram_protect = 0;
857858         break;
858859         
859860// mapper 224?
r8383r8384
928929
929930// UNIF only
930931      case BMC_64IN1NR:
931         state->bmc_64in1nr_reg[0] = 0x80;
932         state->bmc_64in1nr_reg[1] = 0x43;
933         state->bmc_64in1nr_reg[2] = state->bmc_64in1nr_reg[3] = 0;
932         state->mmc_reg[0] = 0x80;
933         state->mmc_reg[1] = 0x43;
934         state->mmc_reg[2] = state->mmc_reg[3] = 0;
934935         bmc_64in1nr_set_prg(machine);
935936         set_nt_mirroring(machine, PPU_MIRROR_VERT);
936937         break;
r8383r8384
948949         prg32(machine, 0xff);
949950         break;
950951      case BMC_S24IN1SC03:
951         state->bmc_s24in1sc03_reg[0] = 0x24;
952         state->bmc_s24in1sc03_reg[1] = 0x9f;
953         state->bmc_s24in1sc03_reg[2] = 0;
954         state->mmc_prg_bank[0] = 0xfe;
955         state->mmc_prg_bank[1] = 0xff;
956         state->mmc_prg_bank[2] = 0xfe;
957         state->mmc_prg_bank[3] = 0xff;
958         state->mmc_latch1 = 0;
959         state->mmc_latch2 = 0x80;
960         bmc_s24in1sc03_set_prg(machine);
961         bmc_s24in1sc03_set_chr(machine);
952         state->mmc_reg[0] = 0x24;
953         state->mmc_reg[1] = 0x9f;
954         state->mmc_reg[2] = 0;
955         mmc3_common_initialize(machine, 0xff, 0xff, 0);
962956         break;
963957      case BMC_T262:
964958         state->mmc_latch1 = 0;
r8383r8384
971965         prg16_cdef(machine, 8);
972966         break;
973967      case UNL_8237:
974         state->unl_8237_reg[0] = state->unl_8237_reg[1] = state->unl_8237_reg[2] = 0;
968         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = 0;
975969         mmc3_common_initialize(machine, 0xff, 0xff, 0);
976970         break;
977971      case UNL_AX5705:
src/mess/includes/nes.h
r8383r8384
171171   UINT8 mmc_dipsetting;
172172
173173   // misc mapper related variables which should be merged with the above one, where possible
174   UINT8 MMC1_regs[4];
175174   int mmc1_reg_write_enable;
176   UINT8 MMC2_regs[4];   // these replace bank0/bank0_hi/bank1/bank1_hi
175   int mmc1_latch;
176   int mmc1_count;
177177
178   UINT8 mmc3_alt_irq;
178   int mmc3_latch;
179   int mmc3_wram_protect;
180   int mmc3_alt_irq;
179181
180182   int MMC5_rom_bank_mode;
181183   int MMC5_vrom_bank_mode;
r8383r8384
189191
190192   // these might be unified in single mmc_reg[] array, together with state->mmc_cmd1 & state->mmc_cmd2
191193   // but be careful that MMC3 clones often use state->mmc_cmd1/state->mmc_cmd2 (from base MMC3) AND additional regs below!
192   UINT8 mapper45_reg[4];
193   UINT8 mapper51_reg[3];
194194   UINT8 mapper83_reg[10];
195195   UINT8 mapper83_low_reg[4];
196   UINT8 mapper95_reg[4];
197   UINT8 mapper115_reg[4];
198196   UINT8 txc_reg[4];   // used by mappers 132, 172 & 173
199197   UINT8 subor_reg[4];   // used by mappers 166 & 167
200198   UINT8 sachen_reg[8];   // used by mappers 137, 138, 139 & 141
201   UINT8 mapper12_reg;
202199   UINT8 map52_reg_written;
203200   UINT8 map114_reg, map114_reg_enabled;
204   UINT8 map215_reg[4];
205   UINT8 map217_reg[4];
206   UINT8 map249_reg;
207   UINT8 map14_reg[2];
208   UINT8 mapper121_reg[8];
209   UINT8 mapper187_reg[4];
210   UINT8 map208_reg[5];
211   UINT8 bmc_64in1nr_reg[4];
212   UINT8 unl_8237_reg[3];
213   UINT8 bmc_s24in1sc03_reg[3];
214201
215   // mapper 68 needs these for NT mirroring!
216   int m68_mirror;
217   int m0, m1;
218
219   // Famicom Jump II is identified as Mapper 153, but it works in a completely different way.
220   // in particular, it requires these (not needed by other Mapper 153 games)
221   UINT8 map153_reg[8];
222   UINT8 map153_bank_latch;
223
224
225202   /***** NES-cart related *****/
226203
227204   /* load-time cart variables which remain constant */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team