Previous 15994 Revisions Next

r8292 Saturday 19th June, 2010 at 06:29:55 UTC by Fabio Priuli
[NES] wip
* some tentative work on implementing MMC6 vs. MMC3 differences in PCB emulation
* slightly simplified configuration of pcb-specific read/write handlers
* extended hardwired mirroring definition to cope with all possible pcb setups
[src/mess/includes]nes.h
[src/mess/machine]nes.c nes_mmc.c nes_mmc.h nes_pcb.c nes_unif.c
[src/mess/video]nes.c

src/mess/video/nes.c
r8291r8292
2020      set_nt_mirroring(machine, PPU_MIRROR_4SCREEN);
2121   else
2222   {
23      switch(state->hard_mirroring)
23      switch (state->hard_mirroring)
2424      {
25         case 0:
26            set_nt_mirroring(machine, PPU_MIRROR_HORZ);
25         case PPU_MIRROR_HORZ:
26         case PPU_MIRROR_VERT:
27         case PPU_MIRROR_HIGH:
28         case PPU_MIRROR_LOW:
29            set_nt_mirroring(machine, state->hard_mirroring);
2730            break;
28         case 1:
29            set_nt_mirroring(machine, PPU_MIRROR_VERT);
30            break;
3131         default:
3232            set_nt_mirroring(machine, PPU_MIRROR_NONE);
3333            break;
src/mess/includes/nes.h
r8291r8292
132132   UINT8      IRQ_reset;
133133   UINT8      IRQ_status;
134134   UINT8      IRQ_mode;
135   UINT8      IRQ_clear;
135136   int        mult1, mult2;
136137
137138   UINT8 mmc_chr_source;         // This is set at init to CHRROM or CHRRAM. a few mappers can swap between
r8291r8292
156157   // misc mapper related variables which should be merged with the above one, where possible
157158   UINT8 MMC1_regs[4];
158159   UINT8 MMC2_regs[4];   // these replace bank0/bank0_hi/bank1/bank1_hi
159   
160
161   UINT8 mmc3_alt_irq;
162
160163   int MMC5_rom_bank_mode;
161164   int MMC5_vrom_bank_mode;
162165   int MMC5_vram_protect;
r8291r8292
164167   int vrom_page_a;
165168   int vrom_page_b;
166169   // int vrom_next[4];
167   
170
171   UINT8 mmc6_reg;
172
168173   // these might be unified in single mmc_reg[] array, together with state->mmc_cmd1 & state->mmc_cmd2
169174   // but be careful that MMC3 clones often use state->mmc_cmd1/state->mmc_cmd2 (from base MMC3) AND additional regs below!
170175   UINT8 mapper45_reg[4];
src/mess/machine/nes_pcb.c
r8291r8292
320320   { "IREM-H-3001",      IREM_H3001 },
321321   { "IREM-HOLYDIVER",   IREM_HOLYDIV },
322322   { "IREM-TAM-S1",      IREM_TAM_S1 },
323   /* FIXME: Made up boards the different mirroring handling */
324   { "IREM-G101-A",      IREM_G101_A },
325323//
326324   { "JALECO-JF-23",     JALECO_SS88006 },
327325   { "JALECO-JF-24",     JALECO_SS88006 },
r8291r8292
832830
833831   switch (board)
834832   {
835      case STD_SOROM:      // there are 2 WRAM banks only and battery is bank 2 for the cart (hence, we invert bank, because we have battery first)
836         if (!BIT(state->mmc_reg[3], 4))
837            memory_install_readwrite_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
838         else
839            memory_unmap_readwrite(space, 0x6000, 0x7fff, 0, 0);
840         wram_bank(machine, 0, bank ? NES_BATTERY : NES_WRAM);
841         break;
842833      case STD_SXROM:      // here also reads are disabled!
843834         if (!BIT(state->mmc_reg[3], 4))
844835            memory_install_readwrite_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
845836         else
837         {
846838            memory_unmap_readwrite(space, 0x6000, 0x7fff, 0, 0);
839            break;
840         }
847841      case STD_SXROM_A:   // ignore WRAM enable bit
848842         if (state->battery_size > 0x2000)
849843            wram_bank(machine, ((state->mmc_reg[1] & 3) >> 2), NES_BATTERY);
850844         else
851845            wram_bank(machine, 0, NES_BATTERY);
852846         break;
847      case STD_SOROM:      // there are 2 WRAM banks only and battery is bank 2 for the cart (hence, we invert bank, because we have battery first)
848         if (!BIT(state->mmc_reg[3], 4))
849            memory_install_readwrite_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
850         else
851         {
852            memory_unmap_readwrite(space, 0x6000, 0x7fff, 0, 0);
853            break;
854         }
855      case STD_SOROM_A:   // ignore WRAM enable bit
856         wram_bank(machine, 0, bank ? NES_BATTERY : NES_WRAM);
857         break;
853858   }
854859}
855860
r8291r8292
973978
974979static WRITE8_HANDLER( sxrom_w )
975980{
981   nes_state *state = (nes_state *)space->machine->driver_data;
982
976983   LOG_MMC(("sxrom_w, offset: %04x, data: %02x\n", offset, data));
977   common_sxrom_write_handler(space, offset, data, STD_SXROM);
984   common_sxrom_write_handler(space, offset, data, state->pcb_id);
978985}
979986
980static WRITE8_HANDLER( sxrom_a_w )
981{
982   LOG_MMC(("sxrom_a_w, offset: %04x, data: %02x\n", offset, data));
983   common_sxrom_write_handler(space, offset, data, STD_SXROM_A);
984}
985
986static WRITE8_HANDLER( sorom_w )
987{
988   LOG_MMC(("sorom_w, offset: %04x, data: %02x\n", offset, data));
989   common_sxrom_write_handler(space, offset, data, STD_SOROM);
990}
991
992987/*************************************************************
993988 
994989 PxROM (MMC2 based) board emulation
r8291r8292
10941089 
10951090 *************************************************************/
10961091
1092static void mmc3_set_wram( const address_space *space )
1093{
1094   running_machine *machine = space->machine;
1095   nes_state *state = (nes_state *)machine->driver_data;
1096
1097   if (BIT(state->mmc_latch2, 7))
1098         memory_install_readwrite_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
1099   else
1100   {
1101      memory_unmap_readwrite(space, 0x6000, 0x7fff, 0, 0);
1102      return;
1103   }
1104
1105   if (BIT(state->mmc_latch2, 6))
1106      memory_install_write_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
1107   else
1108   {
1109      memory_unmap_write(space, 0x6000, 0x7fff, 0, 0);
1110      return;
1111   }
1112   
1113   wram_bank(machine, 0, state->battery_size ? NES_BATTERY : NES_WRAM);
1114}
1115
10971116static void mmc3_set_prg( running_machine *machine, int prg_base, int prg_mask )
10981117{
10991118   nes_state *state = (nes_state *)machine->driver_data;
r8291r8292
11281147   if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE)
11291148   {
11301149      int priorCount = state->IRQ_count;
1131      if ((state->IRQ_count == 0))
1132      {
1150      if ((state->IRQ_count == 0) || state->IRQ_clear)
11331151         state->IRQ_count = state->IRQ_count_latch;
1134      }
11351152      else
11361153         state->IRQ_count--;
11371154     
1138      if (state->IRQ_enable && !blanked && (state->IRQ_count == 0) && priorCount)
1155      if (state->IRQ_enable && !blanked && (state->IRQ_count == 0) && (priorCount || state->IRQ_clear || !state->mmc3_alt_irq))
11391156      {
11401157         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
11411158                video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen)));
11421159         cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE);
11431160      }
11441161   }
1162   state->IRQ_clear = 0;
11451163}
11461164
11471165static WRITE8_HANDLER( txrom_w )
11481166{
11491167   nes_state *state = (nes_state *)space->machine->driver_data;
1150   UINT8 MMC3_helper, cmd;
1168   UINT8 mmc3_helper, cmd;
11511169   
11521170   LOG_MMC(("txrom_w, offset: %04x, data: %02x\n", offset, data));
11531171   
11541172   switch (offset & 0x6001)
11551173   {
11561174      case 0x0000:
1157         MMC3_helper = state->mmc_latch1 ^ data;
1175         mmc3_helper = state->mmc_latch1 ^ data;
11581176         state->mmc_latch1 = data;
11591177         
11601178         /* Has PRG Mode changed? */
1161         if (MMC3_helper & 0x40)
1179         if (mmc3_helper & 0x40)
11621180            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
11631181         
11641182         /* Has CHR Mode changed? */
1165         if (MMC3_helper & 0x80)
1183         if (mmc3_helper & 0x80)
11661184            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
11671185         break;
11681186         
r8291r8292
11871205         set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
11881206         break;
11891207         
1190      case 0x2001: /* extra RAM enable/disable */
1191         state->mmc_latch2 = data;   /* This actually is made of two parts: data&0x80 = WRAM enabled and data&0x40 = WRAM readonly!  */
1192         if (data)
1193            memory_install_write_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
1194         else
1195            memory_unmap_write(space, 0x6000, 0x7fff, 0, 0);
1208      case 0x2001:
1209         state->mmc_latch2 = data;
1210         mmc3_set_wram(space);
11961211         break;
11971212         
11981213      case 0x4000:
11991214         state->IRQ_count_latch = data;
12001215         break;
12011216         
1202      case 0x4001: /* some sources state that here we must have state->IRQ_count = state->IRQ_count_latch */
1217      case 0x4001:
12031218         state->IRQ_count = 0;
12041219         break;
12051220         
r8291r8292
12251240 
12261241 *************************************************************/
12271242
1243static WRITE8_HANDLER( hkrom_m_w )
1244{
1245   nes_state *state = (nes_state *)space->machine->driver_data;
1246   UINT8 write_hi, write_lo;
1247   LOG_MMC(("hkrom_m_w, offset: %04x, data: %02x\n", offset, data));
1248   
1249   if (offset < 0x1000)
1250      return;   
1251
1252   offset &= 0x3ff;
1253   // banks can be written only if both read & write is enabled!
1254   write_hi = ((state->mmc6_reg & 0xc0) == 0xc0);
1255   write_lo = ((state->mmc6_reg & 0x60) == 0x60);
1256
1257   if (BIT(offset, 9) && write_hi)   // access to upper 1k
1258      state->battery_ram[offset] = data;
1259   
1260   if (!BIT(offset, 9) && write_lo)   // access to lower 1k
1261      state->battery_ram[offset] = data;
1262}
1263
1264static READ8_HANDLER( hkrom_m_r )
1265{
1266   nes_state *state = (nes_state *)space->machine->driver_data;
1267   LOG_MMC(("hkrom_m_r, offset: %04x\n", offset));
1268   
1269   if (offset < 0x1000)
1270      return 0xff;   // here it should be open bus
1271
1272   if (!(state->mmc6_reg & 0xa0))
1273      return 0xff;   // here it should be open bus
1274   
1275   offset &= 0x3ff;
1276
1277   if (BIT(offset, 9) && BIT(state->mmc6_reg, 7))   // access to upper 1k when upper read is enabled
1278      return state->battery_ram[offset];
1279
1280   if (!BIT(offset, 9) && BIT(state->mmc6_reg, 5))   // access to lower 1k when lower read is enabled
1281      return state->battery_ram[offset];
1282
1283   // If only one bank is enabled for reading, the other reads back as zero
1284   return 0x00;
1285}
1286
12281287static WRITE8_HANDLER( hkrom_w )
12291288{
1289   nes_state *state = (nes_state *)space->machine->driver_data;
1290   UINT8 mmc6_helper;
12301291   LOG_MMC(("hkrom_w, offset: %04x, data: %02x\n", offset, data));
1231   /* what are the differences MMC6 vs. MMC3? */
1232   txrom_w(space, offset, data);
1292
1293   switch (offset & 0x6001)
1294   {
1295      case 0x0000:
1296         mmc6_helper = state->mmc_cmd1 ^ data;
1297         state->mmc_latch1 = data;
1298
1299         if (!state->mmc_latch2 && BIT(data, 5))   // if WRAM is disabled and has to be enabled, write
1300            state->mmc_latch2 = BIT(data, 5);   // (once WRAM has been enabled, it cannot be disabled without resetting the game)
1301         
1302         /* Has PRG Mode changed? */
1303         if (BIT(mmc6_helper, 6))
1304            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1305         
1306         /* Has CHR Mode changed? */
1307         if (BIT(mmc6_helper, 7))
1308            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
1309         break;
1310
1311      case 0x2001:
1312         if (state->mmc_latch2)
1313            state->mmc6_reg = data;
1314         break;
1315
1316      case 0x4001:
1317         state->IRQ_count = 0;
1318         state->IRQ_clear = 1;
1319         break;
1320         
1321      default:
1322         txrom_w(space, offset, data);
1323         break;
1324   }
12331325}
12341326
12351327/*************************************************************
r8291r8292
12861378      case 0x0001:
12871379         cmd = state->mmc_latch1 & 0x07;
12881380         switch (cmd)
1289      {
1381         {
12901382         case 0: case 1:
12911383         case 2: case 3: case 4: case 5:
12921384            state->mmc_vrom_bank[cmd] = data;
r8291r8292
12981390            state->mmc_prg_bank[cmd - 6] = data;
12991391            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
13001392            break;
1301      }
1393         }
13021394         break;
13031395         
13041396      case 0x2000:
r8291r8292
1025810350   { SUNSOFT_DCS,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ntbrom_w),              NULL, NULL, NULL },
1025910351   { STD_JXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(jxrom_w),               NULL, NULL, jxrom_irq },
1026010352   { STD_SXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
10261   { STD_SXROM_A,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_a_w),             NULL, NULL, NULL },
10262   { STD_SOROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sorom_w),               NULL, NULL, NULL },
10353   { STD_SOROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
10354   { STD_SXROM_A,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
10355   { STD_SOROM_A,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(sxrom_w),               NULL, NULL, NULL },
1026310356   { STD_TXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w),               NULL, NULL, mmc3_irq },
10264   { STD_HKROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(hkrom_w),               NULL, NULL, mmc3_irq },
10357   { STD_HKROM,            NES_NOACCESS, {hkrom_m_w, hkrom_m_r}, NES_WRITEONLY(hkrom_w),     NULL, NULL, mmc3_irq },
1026510358   { STD_TQROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tqrom_w),               NULL, NULL, mmc3_irq },
1026610359   { STD_TXSROM,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txsrom_w),              NULL, NULL, mmc3_irq },
1026710360   { STD_DXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(dxrom_w),               NULL, NULL, NULL },
src/mess/machine/nes.c
r8291r8292
149149
150150         // there are still some quirk about writes to bank5... I hope to fix them soon. (mappers 34,45,52,246 have both mid_w and WRAM-->check)
151151         if (state->mmc_write_mid)
152            memory_install_write8_handler(space, 0x6000, 0x7fff, 0, 0, nes_mid_mapper_w);
153//         memory_install_read8_handler(space, 0x6000, 0x7fff, 0, 0, nes_mid_mapper_r);
154         memory_install_write8_handler(space, 0x8000, 0xffff, 0, 0, nes_mapper_w);
155//         memory_install_read8_handler(space, 0x8000, 0xffff, 0, 0, nes_mapper_r);
152            memory_install_write8_handler(space, 0x6000, 0x7fff, 0, 0, state->mmc_write_mid);
153         if (state->mmc_write)
154            memory_install_write8_handler(space, 0x8000, 0xffff, 0, 0, state->mmc_write);
155
156         // In fact, we also allow single pcbs to overwrite the bank read handlers defined above,
157         // because some pcbs (mainly pirate ones) require protection values to be read instead of
158         // the expected ROM banks: these handlers, though, must take care of the ROM access as well
159         if (state->mmc_read_mid)
160            memory_install_read8_handler(space, 0x6000, 0x7fff, 0, 0, state->mmc_read_mid);
161         if (state->mmc_read)
162            memory_install_read8_handler(space, 0x8000, 0xffff, 0, 0, state->mmc_read);
156163         break;
157164   }
158165
r8291r8292
680687            logerror("NES: No extrainfo found\n");
681688         }
682689
683         state->hard_mirroring = local_options & 0x01;
690         state->hard_mirroring = (local_options & 0x01) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ;
684691//         printf("%d\n", state->hard_mirroring);
685692         state->battery = local_options & 0x02;
686693         state->trainer = local_options & 0x04;
r8291r8292
11581165      if (image_get_feature(image, "mirroring") != NULL)
11591166      {
11601167         const char *mirroring = image_get_feature(image, "mirroring");
1161         if (strcmp(mirroring, "horizontal") == 0)
1162            state->hard_mirroring = 0;
1163         if (strcmp(mirroring, "vertical") == 0)
1164            state->hard_mirroring = 1;
1168         if (!strcmp(mirroring, "horizontal"))
1169            state->hard_mirroring = PPU_MIRROR_HORZ;
1170         if (!strcmp(mirroring, "vertical"))
1171            state->hard_mirroring = PPU_MIRROR_VERT;
1172         if (!strcmp(mirroring, "high"))
1173            state->hard_mirroring = PPU_MIRROR_HIGH;
1174         if (!strcmp(mirroring, "low"))
1175            state->hard_mirroring = PPU_MIRROR_LOW;
11651176      }
11661177
11671178      state->chr_open_bus = 0;
r8291r8292
12151226      }
12161227
12171228      /* Check for other misc board variants */
1218      if (state->pcb_id == STD_SXROM || state->pcb_id == STD_SOROM)
1219      {
1220         if (!strcmp(image_get_feature(image, "mmc1_type"), "MMC1A"))   // in MMC1-A PRG RAM is always enabled
1221            state->pcb_id = STD_SXROM_A;
1222      }
1229      if (state->pcb_id == STD_SOROM && !strcmp(image_get_feature(image, "mmc1_type"), "MMC1A"))
1230         state->pcb_id = STD_SOROM_A;   // in MMC1-A PRG RAM is always enabled
12231231     
1232      if (state->pcb_id == STD_SXROM && !strcmp(image_get_feature(image, "mmc1_type"), "MMC1A"))
1233         state->pcb_id = STD_SXROM_A;   // in MMC1-A PRG RAM is always enabled
1234     
1235      if (state->pcb_id == IREM_G101 && !strcmp(image_get_feature(image, "mirroring"), "high"))
1236         state->pcb_id = IREM_G101_A;
1237     
12241238      if (state->pcb_id == STD_NXROM || state->pcb_id == SUNSOFT_DCS)
12251239      {
12261240         if (image_get_software_region(image, "minicart") != NULL)   // check for dual minicart
r8291r8292
12301244         }
12311245      }
12321246     
1233     
12341247#if 1
12351248      printf("PCB Feature: %s\n", image_get_feature(image, "pcb"));
12361249      printf("PRG chunks: %d\n", state->prg_chunks);
src/mess/machine/nes_unif.c
r8291r8292
197197      case STD_SXROM:   // mapper 1, 155
198198      case STD_SOROM:
199199      case STD_SXROM_A:
200      case STD_SOROM_A:
200201         state->mmc_latch1 = 0;
201202         state->mmc_count = 0;
202203         state->mmc_reg[0] = 0x0f;
r8291r8292
225226         break;
226227      case STD_TXROM:   // mapper 4
227228      case STD_TVROM:
228      case STD_HKROM:   // MMC6
229229      case REXSOFT_DBZ5:   // mapper 12
230230      case WAIXING_TYPE_A:   // mapper 74
231231      case STD_TXSROM:   // mapper 118
r8291r8292
244244            set_nt_page(machine, 2, CART_NTRAM, 2, 1);
245245            set_nt_page(machine, 3, CART_NTRAM, 3, 1);
246246         }
247         state->mmc3_alt_irq = 0;   // in fact, later MMC3 boards seem to use MMC6-type IRQ... more investigations are in progress at NESDev...
247248         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
248249         state->mmc_prg_bank[1] = state->mmc_prg_bank[3] = 0xff;   // but some pirate clone mappers change them after writing certain registers
249250         state->mmc_latch1 = 0;
r8291r8292
254255         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
255256         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
256257         break;
258      case STD_HKROM:   // MMC6 (basically the same as TxROM, but alt IRQ behaviour)
259         state->mmc3_alt_irq = 1;
260         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
261         state->mmc_prg_bank[1] = state->mmc_prg_bank[3] = 0xff;   // but some pirate clone mappers change them after writing certain registers
262         state->mmc_latch1 = 0;
263         state->mmc_latch2 = 0x80;
264         state->mmc_prg_base = state->mmc_chr_base = 0;
265         state->mmc_prg_mask = state->mmc_chr_mask = 0xff;   // these could be init'ed as xxx_chunks-1 and they would work the same
266         state->mmc_chr_source = state->chr_chunks ? CHRROM : CHRRAM;
267         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
268         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
269         break;         
257270      case PAL_ZZ:   // mapper 37
271         state->mmc3_alt_irq = 0;
258272         state->mmc_prg_bank[0] = state->mmc_prg_bank[2] = 0xfe;
259273         state->mmc_prg_bank[1] = state->mmc_prg_bank[3] = 0xff;
260274         state->mmc_latch1 = 0;
r8291r8292
267281         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
268282         break;
269283      case NES_QJ:   // mapper 47
284         state->mmc3_alt_irq = 0;
270285         state->mmc_prg_bank[0] = state->mmc_prg_bank[2] = 0xfe;
271286         state->mmc_prg_bank[1] = state->mmc_prg_bank[3] = 0xff;
272287         state->mmc_latch1 = 0;
r8291r8292
12591274   state->four_screen_vram = (unif_board->nt == NT_4SCR_2K || unif_board->nt == NT_4SCR_4K) ? 1 : 0;
12601275
12611276   if (unif_board->nt == NT_VERT)
1262      state->hard_mirroring = 1;
1277      state->hard_mirroring = PPU_MIRROR_VERT;
12631278   else if (unif_board->nt == NT_HORZ)
1264      state->hard_mirroring = 0;
1279      state->hard_mirroring = PPU_MIRROR_HORZ;
12651280
12661281   if (unif_board->chrram <= CHRRAM_8)
12671282      state->vram_chunks = 1;
src/mess/machine/nes_mmc.c
r8291r8292
146146           0x2000-0x3fff PPU
147147           0x4000-0x4017 APU
148148           0x4018-0x5fff Expansion Area
149           0x6000-0x7fff SRAM
149           0x6000-0x7fff PRG RAM
150150           0x8000-0xffff PRG ROM
151151
152152    nes_chr_r/w take care of RAM, nes_nt_r/w take care of PPU.
153153    for mapper specific emulation, we generically setup the
154154    following handlers:
155155    - nes_low_mapper_r/w take care of accesses to 0x4100-0x5fff
156    - nes_mid_mapper_r/w take care of accesses to 0x6000-0x7fff
157    - nes_mapper_r/w takes care of accesses to 0x8000-0xffff
156      (calling state->mmc_write_low/state->mmc_read_low)
157    - state->mmc_write/read_mid take care of 0x6000-0x7fff
158    - state->mmc_write/read take care of access to 0x8000-0xffff
158159      (most mappers only writes in this area)
159160    some mappers may access 0x4018-0x4100: this must be taken
160161    care separately in init_nes_core
r8291r8292
235236   return 0;
236237}
237238
238WRITE8_HANDLER( nes_mid_mapper_w )
239{
240   nes_state *state = (nes_state *)space->machine->driver_data;
241
242   if (state->mmc_write_mid)
243      (*state->mmc_write_mid)(space, offset, data);
244   else
245      logerror("Unimplemented MID mapper write, offset: %04x, data: %02x\n", offset + 0x6000, data);
246}
247
248// currently, this is not used (but it might become handy for some pirate mapper)
249READ8_HANDLER( nes_mid_mapper_r )
250{
251   nes_state *state = (nes_state *)space->machine->driver_data;
252
253   if (state->mmc_read_mid)
254      (*state->mmc_read_mid)(space, offset);
255   else
256      logerror("Unimplemented MID mapper read, offset: %04x\n", offset + 0x6000);
257
258   return 0;
259}
260
261WRITE8_HANDLER( nes_mapper_w )
262{
263   nes_state *state = (nes_state *)space->machine->driver_data;
264
265   if (state->mmc_write)
266      (*state->mmc_write)(space, offset, data);
267   else
268      logerror("Unimplemented mapper write, offset: %04x, data: %02x\n", offset + 0x8000, data);
269}
270
271// currently, this is not used (but it might become handy for some pirate mapper)
272READ8_HANDLER( nes_mapper_r )
273{
274   nes_state *state = (nes_state *)space->machine->driver_data;
275   
276   if (state->mmc_read)
277      (*state->mmc_read)(space, offset);
278   else
279      logerror("Unimplemented mapper read, offset: %04x\n", offset + 0x8000);
280   
281   return 0;
282}
283
284
285239/*************************************************************
286240
287241    Helpers to handle MMC
src/mess/machine/nes_mmc.h
r8291r8292
99   STD_DXROM, STD_EXROM, STD_FXROM, STD_GXROM,
1010   STD_HKROM, STD_JXROM, STD_MXROM, STD_NXROM,
1111   STD_PXROM, STD_SXROM, STD_TXROM, STD_TXSROM,
12   STD_TQROM, STD_UN1ROM, STD_UXROM,
12   STD_TQROM, STD_TVROM, STD_UN1ROM, STD_UXROM,
1313   HVC_FAMBASIC, NES_QJ, PAL_ZZ, UXROM_CC,
14   STD_DRROM, STD_SXROM_A, STD_SOROM, STD_TVROM,
14   STD_DRROM, STD_SXROM_A, STD_SOROM, STD_SOROM_A,
1515   /* Discrete components boards (by various manufacturer */
1616   DIS_74X161X138, DIS_74X139X74, DIS_74X377,
1717   DIS_74X161X161X32, DIS_74X161X161X32_A,
r8291r8292
109109int nes_get_pcb_id(running_machine *machine, const char *feature);
110110
111111WRITE8_HANDLER( nes_low_mapper_w );
112WRITE8_HANDLER( nes_mid_mapper_w );
113WRITE8_HANDLER( nes_mapper_w );
114112READ8_HANDLER( nes_low_mapper_r );
115READ8_HANDLER( nes_mid_mapper_r );
116READ8_HANDLER( nes_mapper_r );
117113WRITE8_HANDLER( nes_chr_w );
118114READ8_HANDLER( nes_chr_r );
119115WRITE8_HANDLER( nes_nt_w );

Previous 15994 Revisions Next


© 1998-2018 The MESS Team