Previous 15994 Revisions Next

r8326 Sunday 27th June, 2010 at 10:10:10 UTC by Miodrag Milanović
Performed srcclean on mess tree part.
[src/mess]mess.c messdriv.c tapectrl.c
[src/mess/audio]mea8000.c
[src/mess/devices]aescart.c appldriv.c bitbngr.c cartslot.c cassette.c coco_fdc.c coco_pak.c cococart.c flopdrv.c orch90.c ti99cart.c
[src/mess/drivers]apexc.c apple2.c atom.c cdi.c cfx9850.c e01.c einstein.c gba.c jaguar.c lynx.c mac.c mikromik.c ng_aes.c osborne1.c pc2000.c pce220.c pv1000.c ql.c sg1000.c spectrum.c supracan.c ti89.c tm990189.c vtech1.c x07.c x1.c
[src/mess/formats]timex_dck.c vg5k_cas.c
[src/mess/includes]nes.h
[src/mess/machine]6525tpi.c 8530scc.c a2cffa.c a2cffa.h ap2_slot.c apple2gs.c at29040.c c64.c gb.c ncr5380.c nes.c nes_ines.c nes_mmc.c nes_mmc.h nes_pcb.c nes_unif.c osborne1.c pc8801.c pmd85.c snescart.c thomson.c
[src/mess/osd/windows]menu.c mess.rc
[src/mess/osd/winui]devview.c messui.c msuiutil.c softwarelist.c softwarelist.h
[src/mess/osd/winui/res]logo_mess.bmp mess.ico win_cass.ico win_cyln.ico win_flop.ico win_hard.ico win_noor.ico win_nrnd.ico win_pcrd.ico win_prin.ico win_ptap.ico win_serl.ico win_snap.ico
[src/mess/tests]imgtool_fat.xml imgtool_os9.xml imgtool_prodos.xml mess_mc10.xml
[src/mess/tools/imgtool/windows]wimgtool.rc
[src/mess/tools/imgtool/windows/res]dir.ico doc.ico imgtool.ico readonly.ico
[src/mess/video]ef9345.c gb.c i8275.c nes.c smsvdp.c zx.c

src/mess/devices/orch90.c
r8325r8326
110110   }
111111}
112112
113DEFINE_LEGACY_DEVICE(COCO_CARTRIDGE_PCB_ORCH90, coco_cartridge_pcb_orch90);
No newline at end of file
113DEFINE_LEGACY_DEVICE(COCO_CARTRIDGE_PCB_ORCH90, coco_cartridge_pcb_orch90);
src/mess/devices/ti99cart.c
r8325r8326
578578   ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(cartsys)->token();
579579   ti99_pcb_t *pcb_def = (ti99_pcb_t *)downcast<legacy_device_base *>(pcb)->token();
580580
581//   pcb_def->read = (read16_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_R);
582//   pcb_def->write = (write16_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_W);
583//   pcb_def->read8 = (read8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_R8);
584//   pcb_def->write8 = (write8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_W8);
585//   pcb_def->cruread = (read8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_CRU_R);
586//   pcb_def->cruwrite = (write8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_CRU_W);
581//  pcb_def->read = (read16_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_R);
582//  pcb_def->write = (write16_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_W);
583//  pcb_def->read8 = (read8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_R8);
584//  pcb_def->write8 = (write8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_W8);
585//  pcb_def->cruread = (read8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_CRU_R);
586//  pcb_def->cruwrite = (write8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_CRU_W);
587587
588//   pcb_def->assemble = (assmfct *)pcb->get_config_fct(TI99CART_FCT_ASSM);
589//   pcb_def->disassemble = (assmfct *)pcb->get_config_fct(TI99CART_FCT_DISASSM);
588//  pcb_def->assemble = (assmfct *)pcb->get_config_fct(TI99CART_FCT_ASSM);
589//  pcb_def->disassemble = (assmfct *)pcb->get_config_fct(TI99CART_FCT_DISASSM);
590590
591591   pcb_def->cartridge = &cartslots->cartridge[index];
592592   pcb_def->cartridge->pcb = pcb;
src/mess/devices/cassette.c
r8325r8326
211211
212212   cassette_update(device);
213213
214   length = cassette_get_length(device);   
214   length = cassette_get_length(device);
215215
216216   switch(origin) {
217217   case SEEK_SET:
src/mess/devices/flopdrv.c
r8325r8326
511511{
512512   floppy_drive *flopimg;
513513   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
514   
514
515515   if (image->exists())
516516   {
517517      flopimg = get_safe_token( img );
src/mess/devices/coco_pak.c
r8325r8326
113113static void banked_pak_set_bank(running_device *device, UINT32 bank)
114114{
115115   coco_pak_pcb_t *pak_pcb = get_token(device);
116   
116
117117   UINT64 pos;
118118   UINT32 i;
119119   UINT8 *rom = memory_region(device->machine, "cart");
src/mess/devices/cartslot.c
r8325r8326
278278{
279279   int result;
280280   device_t *device = &image.device();
281   cartslot_t *cart = get_token(device);   
281   cartslot_t *cart = get_token(device);
282282   const cartslot_config *config = get_config(device);
283   
283
284284   /* if this cartridge has a custom DEVICE_IMAGE_LOAD, use it */
285285   if (config->device_load != NULL)
286286      return (*config->device_load)(image);
r8325r8326
289289   multicart_open(image.filename(), device->machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
290290   if (cart->mc == NULL)
291291   {
292         
293     
292
293
294294      /* otherwise try the normal route */
295295      result = process_cartridge(&image, PROCESS_LOAD);
296296      if (result != IMAGE_INIT_PASS)
r8325r8326
389389-------------------------------------------------*/
390390static void add_device_with_subdevices(const running_device *_owner, device_type _type, const char *_tag, UINT32 _clock)
391391{
392/*   astring tempstring;
393   device_list *devlist = &_owner->machine->devicelist;
394   const device_config *cfg = new device_config(&_owner->baseconfig(), _type, _tag, _clock);
395   running_device *dev = devlist->append(_owner->subtag(tempstring,_tag), new running_device(*_owner->machine, *cfg));
392/*  astring tempstring;
393    device_list *devlist = &_owner->machine->devicelist;
394    const device_config *cfg = new device_config(&_owner->baseconfig(), _type, _tag, _clock);
395    running_device *dev = devlist->append(_owner->subtag(tempstring,_tag), new running_device(*_owner->machine, *cfg));
396396
397   const machine_config_token *tokens = (const machine_config_token *)dev->get_config_ptr(DEVINFO_PTR_MACHINE_CONFIG);
398   machine_config *config;
399   const device_config *config_dev;
400   running_device *new_dev = NULL;
401   if (tokens != NULL)
402   {
403      config = machine_config_alloc(tokens);
404      for (config_dev = config->devicelist.first(); config_dev != NULL; config_dev = config_dev->next)
405      {
406         device_config *new_cfg = new device_config(cfg, config_dev->type, config_dev->tag(), config_dev->clock);
407         new_cfg->static_config = config_dev->static_config;
408         memcpy(
409            new_cfg->inline_config,
410            config_dev->inline_config,
411            new_cfg->get_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES));
412         new_dev = devlist->append(dev->subtag(tempstring,config_dev->tag()), new running_device(*_owner->machine, *new_cfg));
413         new_dev->owner = dev;
414      }
415      machine_config_free(config);
416   }*/
397    const machine_config_token *tokens = (const machine_config_token *)dev->get_config_ptr(DEVINFO_PTR_MACHINE_CONFIG);
398    machine_config *config;
399    const device_config *config_dev;
400    running_device *new_dev = NULL;
401    if (tokens != NULL)
402    {
403        config = machine_config_alloc(tokens);
404        for (config_dev = config->devicelist.first(); config_dev != NULL; config_dev = config_dev->next)
405        {
406            device_config *new_cfg = new device_config(cfg, config_dev->type, config_dev->tag(), config_dev->clock);
407            new_cfg->static_config = config_dev->static_config;
408            memcpy(
409                new_cfg->inline_config,
410                config_dev->inline_config,
411                new_cfg->get_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES));
412            new_dev = devlist->append(dev->subtag(tempstring,config_dev->tag()), new running_device(*_owner->machine, *new_cfg));
413            new_dev->owner = dev;
414        }
415        machine_config_free(config);
416    }*/
417417}
418418
419419static DEVICE_IMAGE_GET_DEVICES(cartslot)
src/mess/devices/coco_fdc.c
r8325r8326
228228static DEVICE_START(fdc)
229229{
230230   fdc_t *fdc = get_token(device);
231//   const fdc_hardware_type *hwtype = (const fdc_hardware_type *)device->get_config_ptr(FDCINFO_PTR_HWTYPE);
231//  const fdc_hardware_type *hwtype = (const fdc_hardware_type *)device->get_config_ptr(FDCINFO_PTR_HWTYPE);
232232
233233   /* initialize variables */
234234   memset(fdc, 0, sizeof(*fdc));
235//   fdc->hwtype         = hwtype;
236//   fdc->drq         = hwtype->initial_drq;
235//  fdc->hwtype         = hwtype;
236//  fdc->drq            = hwtype->initial_drq;
237237   fdc->cococart      = device->owner()->owner();
238238   fdc->disto_msm6242   = device->subdevice(DISTO_TAG);
239239   fdc->ds1315         = device->subdevice(CLOUD9_TAG);
src/mess/devices/appldriv.c
r8325r8326
297297   }
298298}
299299
300DEFINE_LEGACY_IMAGE_DEVICE(FLOPPY_APPLE, apple525);
No newline at end of file
300DEFINE_LEGACY_IMAGE_DEVICE(FLOPPY_APPLE, apple525);
src/mess/devices/aescart.c
r8325r8326
545545         memory_region_alloc(image.device().machine,"audiocrypt",size,ROMREGION_ERASEFF);
546546         memcpy(memory_region(image.device().machine,"audiocrypt"),image.get_software_region("audiocrypt"),size);
547547      }
548     
548
549549      // setup cartridge ROM area
550550      memory_install_read_bank(cputag_get_address_space(image.device().machine,"maincpu",ADDRESS_SPACE_PROGRAM),0x000080,0x0fffff,0,0,"cart_rom");
551551      memory_set_bankptr(image.device().machine,"cart_rom",&memory_region(image.device().machine,"maincpu")[0x80]);
552     
552
553553      // handle possible protection
554554      install_protection(image);
555     
555
556556      return IMAGE_INIT_PASS;
557557   }
558558
src/mess/devices/bitbngr.c
r8325r8326
249249   }
250250}
251251
252DEFINE_LEGACY_IMAGE_DEVICE(BITBANGER, bitbanger);
No newline at end of file
252DEFINE_LEGACY_IMAGE_DEVICE(BITBANGER, bitbanger);
src/mess/devices/cococart.c
r8325r8326
9898         throw device_missing_dependencies();
9999      }
100100
101//      cococart->pcb_r = (read8_device_func) cococart->pcb->get_config_fct(COCOCARTINFO_FCT_FF40_R);
102//      cococart->pcb_w = (write8_device_func) cococart->pcb->get_config_fct(COCOCARTINFO_FCT_FF40_W);
101//      cococart->pcb_r = (read8_device_func) cococart->pcb->get_config_fct(COCOCARTINFO_FCT_FF40_R);
102//      cococart->pcb_w = (write8_device_func) cococart->pcb->get_config_fct(COCOCARTINFO_FCT_FF40_W);
103103   }
104104
105105   /* finish setup */
src/mess/osd/windows/menu.c
r8325r8326
14301430
14311431      snprintf(buf, ARRAY_LENGTH(buf), "%s: %s", img->image_config().name(), s);
14321432      win_append_menu_utf8(device_menu, MF_POPUP, (UINT_PTR)sub_menu, buf);
1433     
1433
14341434      cnt++;
14351435   }
14361436}
src/mess/osd/windows/mess.rc
r8325r8326
8383        END
8484        MENUITEM "Show &FPS",                   ID_OPTIONS_TOGGLEFPS
8585        MENUITEM SEPARATOR
86        MENUITEM "&Hide Menubar",              ID_OPTIONS_TOGGLEMENUBAR
87        MENUITEM "&Full Screen",              ID_OPTIONS_FULLSCREEN
86        MENUITEM "&Hide Menubar",             ID_OPTIONS_TOGGLEMENUBAR
87        MENUITEM "&Full Screen",             ID_OPTIONS_FULLSCREEN
8888        MENUITEM "Show P&rofiler",              ID_OPTIONS_PROFILER, GRAYED
8989        MENUITEM "&Debugger...",                ID_OPTIONS_DEBUGGER
9090    END
src/mess/osd/winui/messui.c
r8325r8326
395395   const game_driver *drv;
396396   HWND hwndSoftwarePicker;
397397   HWND hwndSoftwareList;
398   HWND hwndSoftwareDevView;   
398   HWND hwndSoftwareDevView;
399399
400400   // do we have to do anything?
401401   if (!bForce)
r8325r8326
437437      drv = driver_get_compatible(drv);
438438   }
439439   AddSoftwarePickerDirs(hwndSoftwarePicker, GetExtraSoftwarePaths(drvindex), NULL);
440   
440
441441   // set up the software picker
442442   SoftwareList_Clear(hwndSoftwareList);
443443   SoftwareList_SetDriver(hwndSoftwareList, s_config);
r8325r8326
461461               if (list)
462462               {
463463                  for (software_info *swinfo = software_list_first(list); swinfo != NULL; swinfo = software_list_next(list))
464                  {                     
464                  {
465465                     const device_config_image_interface *image;
466                     software_part *part = software_find_part(swinfo, NULL, NULL);         
466                     software_part *part = software_find_part(swinfo, NULL, NULL);
467467
468                     // search for a device with the right interface
468                     // search for a device with the right interface
469469                     for (bool gotone = config->devicelist.first(image); gotone; gotone = image->next(image))
470470                     {
471471                        const char *interface = image->image_interface();
r8325r8326
480480                     }
481481                  }
482482                  software_list_close(list);
483               }                 
483               }
484484            }
485485         }
486486      }
487487   }
488488
489489   /* free the machine config */
490   machine_config_free( config );     
490   machine_config_free( config );
491491}
492492
493493
r8325r8326
578578   if (device == NULL)
579579   {
580580      const device_config_image_interface *dev;
581      for (bool gotone = s_config->mconfig->devicelist.first(dev); gotone; gotone = dev->next(dev))
581      for (bool gotone = s_config->mconfig->devicelist.first(dev); gotone; gotone = dev->next(dev))
582582      {
583583         device = dev;
584         s = GetSelectedSoftware(drvindex, s_config->mconfig, device);         
585         if ((s != NULL) && !mame_stricmp(s, pszFilename)) {           
584         s = GetSelectedSoftware(drvindex, s_config->mconfig, device);
585         if ((s != NULL) && !mame_stricmp(s, pszFilename)) {
586586            break;
587587         }
588588      }
r8325r8326
600600
601601      if (file_extension != NULL)
602602      {
603             const device_config_image_interface *dev;
604         for (bool gotone = s_config->mconfig->devicelist.first(dev); gotone; gotone = dev->next(dev))         
603          const device_config_image_interface *dev;
604         for (bool gotone = s_config->mconfig->devicelist.first(dev); gotone; gotone = dev->next(dev))
605605         {
606606            device = dev;
607607            s = GetSelectedSoftware(drvindex, s_config->mconfig, device);
r8325r8326
632632   const device_config_image_interface *device;
633633   const char *s;
634634
635   for (bool gotone = s_config->mconfig->devicelist.first(device); gotone; gotone = device->next(device))         
635   for (bool gotone = s_config->mconfig->devicelist.first(device); gotone; gotone = device->next(device))
636636   {
637637      s = GetSelectedSoftware(drvindex, s_config->mconfig, device);
638638      if ((s != NULL) && !strcmp(pszFilename, s))
r8325r8326
669669   // be problematic
670670   ListView_SetItemState(hwndSoftware, -1, 0, LVIS_SELECTED);
671671
672   for (bool gotone = s_config->mconfig->devicelist.first(dev); gotone; gotone = dev->next(dev))         
672   for (bool gotone = s_config->mconfig->devicelist.first(dev); gotone; gotone = dev->next(dev))
673673   {
674674      pszSoftware = GetSelectedSoftware(s_config->driver_index, s_config->mconfig, dev);
675675      if (pszSoftware && *pszSoftware)
r8325r8326
725725      };
726726      DevView_SetCallbacks(GetDlgItem(GetMainWindow(), IDC_SWDEVVIEW), &s_devViewCallbacks);
727727   }
728   
728
729729   HWND hwndSoftwareList;
730730
731731   hwndSoftwareList = GetDlgItem(GetMainWindow(), IDC_SOFTLIST);
r8325r8326
880880
881881   }
882882   else
883   {   
883   {
884884      astring extensions((char*)dev->file_extensions());
885885      char *ext = strtok((char*)extensions.cstr(),",");
886886      while (ext != NULL)
r8325r8326
893893            num_extensions++;
894894         }
895895         ext = strtok (NULL, ",");
896      }   
896      }
897897   }
898898}
899899
r8325r8326
13021302      pszFullName = SoftwareList_LookupFilename(hwndSoftwareList, nItem);
13031303
13041304      strncpyz(g_szSelectedSoftware, pszFullName, ARRAY_LENGTH(g_szSelectedSoftware));
1305     
1305
13061306      strncpyz(g_szSelectedDevice, SoftwareList_LookupDevice(hwndSoftwareList, nItem), ARRAY_LENGTH(g_szSelectedDevice));
1307     
1307
13081308      // Set up s_szSelecteItem, for the benefit of UpdateScreenShot()
13091309      strncpyz(g_szSelectedItem, pszFullName, ARRAY_LENGTH(g_szSelectedItem));
13101310
src/mess/osd/winui/res/win_cass.ico
src/mess/osd/winui/res/mess.ico
src/mess/osd/winui/res/win_noor.ico
src/mess/osd/winui/res/logo_mess.bmp
src/mess/osd/winui/res/win_hard.ico
src/mess/osd/winui/res/win_flop.ico
src/mess/osd/winui/res/win_nrnd.ico
src/mess/osd/winui/res/win_snap.ico
src/mess/osd/winui/res/win_ptap.ico
src/mess/osd/winui/res/win_cyln.ico
src/mess/osd/winui/res/win_serl.ico
src/mess/osd/winui/res/win_pcrd.ico
src/mess/osd/winui/res/win_prin.ico
src/mess/osd/winui/devview.c
r8325r8326
203203
204204   // count total amount of devices
205205   nDevCount = 0;
206   
206
207207   {
208208      for (bool gotone = pDevViewInfo->config->mconfig->devicelist.first(dev); gotone; gotone = dev->next(dev))
209209      {
210         nDevCount++;         
211      }   
210         nDevCount++;
211      }
212212   }
213   
213
214214   if (nDevCount > 0)
215   {   
215   {
216216      // get the names of all of the devices
217217      ppszDevices = (LPTSTR *) alloca(nDevCount * sizeof(*ppszDevices));
218218      i = 0;
src/mess/osd/winui/msuiutil.c
r8325r8326
4646   config = machine_config_alloc(gamedrv->machine_config);
4747
4848   for (bool gotone = config->devicelist.first(device); gotone; gotone = device->next(device))
49   {   
49   {
5050      if (device->image_type() == type)
5151      {
5252         b = TRUE;
src/mess/osd/winui/softwarelist.c
r8325r8326
4343   char file_name[MAX_PATH];
4444   char publisher[MAX_PATH];
4545   char year[10];
46   
46
4747   char device[MAX_PATH];
4848};
4949
r8325r8326
131131BOOL SoftwareList_AddFile(HWND hwndPicker,LPCSTR pszName, LPCSTR pszListname, LPCSTR pszDescription, LPCSTR pszPublisher, LPCSTR pszYear, LPCSTR pszDevice)
132132{
133133   Picker_ResetIdle(hwndPicker);
134   
134
135135   software_list_info *pPickerInfo;
136136   file_info **ppNewIndex;
137137   file_info *pInfo;
r8325r8326
157157   strcpy(pInfo->publisher, pszPublisher);
158158   strcpy(pInfo->year, pszYear);
159159   strcpy(pInfo->device, pszDevice);
160   
160
161161   ppNewIndex = (file_info**)malloc((pPickerInfo->file_index_length + 1) * sizeof(*pPickerInfo->file_index));
162162   memcpy(ppNewIndex,pPickerInfo->file_index,pPickerInfo->file_index_length * sizeof(*pPickerInfo->file_index));
163163   if (pPickerInfo->file_index) free(pPickerInfo->file_index);
r8325r8326
175175error:
176176   if (pInfo)
177177      free(pInfo);
178   return FALSE;   
178   return FALSE;
179179}
180180
181181
r8325r8326
266266         s = pszBuffer;
267267         osd_free(t_buf);
268268         break;
269     
269
270270   }
271271   return s;
272272}
src/mess/osd/winui/softwarelist.h
r8325r8326
11//============================================================
22//
3//  softwarelist.h - MESS's software
3//  softwarelist.h - MESS's software
44//
55//============================================================
66
src/mess/mess.c
r8325r8326
106106
107107void print_mess_game_xml(FILE *out, const game_driver *game, const machine_config *config)
108108{
109   print_game_ramoptions( out, game, config );   
109   print_game_ramoptions( out, game, config );
110110}
111111
112112/***************************************************************************
r8325r8326
133133{
134134   /* add MESS-specific options */
135135   options_add_entries(opts, mess_core_options);
136}
136}
src/mess/tapectrl.c
r8325r8326
120120            tapeflags |= MENU_FLAG_LEFT_ARROW;
121121         if (t0 < t1)
122122            tapeflags |= MENU_FLAG_RIGHT_ARROW;
123      }           
123      }
124124
125125      /* name of tape */
126126      ui_menu_item_append(menu, menustate->device->image_config().name(), menustate->device->filename(), flags, TAPECMD_SELECT);
r8325r8326
183183      int index = menustate->index;
184184      device_image_interface *device = NULL;
185185      for (bool gotone = machine->devicelist.first(device); gotone; gotone = device->next(device))
186      {     
186      {
187187         if(device->device().type() == CASSETTE) {
188188            if (index==0) break;
189189            index--;
src/mess/tools/imgtool/windows/res/imgtool.ico
src/mess/tools/imgtool/windows/res/readonly.ico
src/mess/tools/imgtool/windows/res/dir.ico
src/mess/tools/imgtool/windows/res/doc.ico
src/mess/tools/imgtool/windows/wimgtool.rc
r8325r8326
2727// TEXTINCLUDE
2828//
2929
301 TEXTINCLUDE
301 TEXTINCLUDE
3131BEGIN
3232    "wimgres.h\0"
3333END
3434
352 TEXTINCLUDE
352 TEXTINCLUDE
3636BEGIN
3737    "#include <windows.h>\r\n"
3838    "\0"
3939END
4040
413 TEXTINCLUDE
413 TEXTINCLUDE
4242BEGIN
4343    "\r\n"
4444    "\0"
src/mess/audio/mea8000.c
r8325r8326
722722   }
723723}
724724
725DEFINE_LEGACY_DEVICE(MEA8000, mea8000);
No newline at end of file
725DEFINE_LEGACY_DEVICE(MEA8000, mea8000);
src/mess/tests/imgtool_os9.xml
r8325r8326
4949   </checkdirectory>
5050   <checkfile name="FOO.TXT">'Party'</checkfile>
5151   <checkfile name="BAR.TXT">'Lame'</checkfile>
52   
52
5353   <deletefile name="BAR.TXT"/>
5454   <checkdirectory>
5555      <entry name="FOO.TXT" size="5"/>
r8325r8326
134134   <!-- Testing directories -->
135135   <createimage driver="coco_jvc_os9"/>
136136   <recordfreespace/>
137   
137
138138   <createdirectory path="FOO"/>
139139   <putfile name="/FOO/BAR.TXT">'Party'</putfile>
140140
r8325r8326
237237   <!-- Testing many more files in a subdirectory -->
238238   <createimage driver="coco_jvc_os9"/>
239239   <createdirectory path="FOO"/>
240   
240
241241   <putfile name="/FOO/1.TXT">'Alpha'</putfile>
242242   <putfile name="/FOO/2.TXT">'Bravo'</putfile>
243243   <putfile name="/FOO/3.TXT">'Charlie'</putfile>
src/mess/tests/mess_mc10.xml
r8325r8326
11<tests>
22
33<test name="mc10_000" driver="mc10">
4   <wait time="2"/>   
4   <wait time="2"/>
55   <memverify region="ram" start="0">"MICROCOLOR"</memverify>
66</test>
77
src/mess/tests/imgtool_prodos.xml
r8325r8326
22
33<imgtooltest name="prodos_001">
44   <createimage driver="apple2_do_prodos_525"/>
5   
5
66   <putfile name="EMPTY.TXT"/>
77   <checkdirectory>
88      <entry name="EMPTY.TXT" size="0"/>
99   </checkdirectory>
1010   <checkfile name="EMPTY.TXT"/>
11   
11
1212   <putfile name="SEEDLING.TXT">'seed!' * 10 </putfile>
1313   <checkdirectory>
1414      <entry name="EMPTY.TXT" size="0"/>
r8325r8326
153153   <checkdirectory path="/DIR">
154154      <entry name="FILE.TXT"/>
155155   </checkdirectory>
156   
156
157157   <checkfile name="/DIR/FILE.TXT">'subdir file'</checkfile>
158158</imgtooltest>
159159
r8325r8326
168168
169169<imgtooltest name="prodos_007">
170170   <createimage driver="apple2_do_prodos_525"/>
171   
171
172172   <putfile name="FOO.TXT">'data fork text'</putfile>
173173   <checkdirectory>
174174      <entry name="FOO.TXT" size="14"/>
175175   </checkdirectory>
176176   <checkfile name="FOO.TXT" fork="">'data fork text'</checkfile>
177177   <checkfile name="FOO.TXT" fork="RESOURCE_FORK"/>
178   
178
179179   <putfile name="FOO.TXT" fork="RESOURCE_FORK">'resource fork text'</putfile>
180180   <checkdirectory>
181181      <entry name="FOO.TXT" size="14"/>
r8325r8326
186186
187187<imgtooltest name="prodos_008">
188188   <createimage driver="apple2_do_prodos_525"/>
189   
189
190190   <putfile name="FOO.TXT">'data fork text' * 500</putfile>
191191   <checkdirectory>
192192      <entry name="FOO.TXT" size="14"/>
193193   </checkdirectory>
194194   <checkfile name="FOO.TXT" fork="">'data fork text' * 500</checkfile>
195195   <checkfile name="FOO.TXT" fork="RESOURCE_FORK"/>
196   
196
197197   <putfile name="FOO.TXT" fork="RESOURCE_FORK">'resource fork text' * 1000</putfile>
198198   <checkdirectory>
199199      <entry name="FOO.TXT" size="14"/>
r8325r8326
204204
205205<imgtooltest name="prodos_009">
206206   <createimage driver="apple2_do_prodos_525"/>
207   
207
208208   <putfile name="FOO.TXT">'data fork text' * 500</putfile>
209209   <checkattr path="FOO.TXT" name="mac_file_type" value="????"/>
210210   <checkattr path="FOO.TXT" name="mac_file_creator" value="????"/>
211211
212   <setattr path="FOO.TXT" name="mac_file_type" value="TEXT"/>   
212   <setattr path="FOO.TXT" name="mac_file_type" value="TEXT"/>
213213   <checkattr path="FOO.TXT" name="mac_file_type" value="TEXT"/>
214214   <checkattr path="FOO.TXT" name="mac_file_creator" value="????"/>
215215
216   <setattr path="FOO.TXT" name="mac_file_creator" value="NATE"/>   
216   <setattr path="FOO.TXT" name="mac_file_creator" value="NATE"/>
217217   <checkattr path="FOO.TXT" name="mac_file_type" value="TEXT"/>
218   <checkattr path="FOO.TXT" name="mac_file_creator" value="NATE"/>   
218   <checkattr path="FOO.TXT" name="mac_file_creator" value="NATE"/>
219219</imgtooltest>
220220
221221<imgtooltest name="prodos_010">
r8325r8326
223223   <recordfreespace/>
224224<!--
225225   <putfile name="FOO.TXT">'data fork text' * 500</putfile>
226   <setattr path="FOO.TXT" name="mac_file_type" value="TEXT"/>   
226   <setattr path="FOO.TXT" name="mac_file_type" value="TEXT"/>
227227   <putfile name="FOO.TXT" fork="RESOURCE_FORK">'resource fork text' * 1000</putfile>
228228   <deletefile name="FOO.TXT"/>
229229-->
src/mess/tests/imgtool_fat.xml
r8325r8326
126126   <!-- Testing directories -->
127127   <createimage driver="pc_dsk_fat"/>
128128   <recordfreespace/>
129   
129
130130   <createdirectory path="FOO"/>
131131   <putfile name="\FOO\BAR.TXT">'Party'</putfile>
132132
r8325r8326
226226   <!-- Testing many more files in a subdirectory -->
227227   <createimage driver="pc_dsk_fat"/>
228228   <createdirectory path="FOO"/>
229   
229
230230   <putfile name="\FOO\1.TXT">'Alpha'</putfile>
231231   <putfile name="\FOO\2.TXT">'Bravo'</putfile>
232232   <putfile name="\FOO\3.TXT">'Charlie'</putfile>
r8325r8326
246246   <!-- Testing longer file names -->
247247   <createimage driver="pc_dsk_fat"/>
248248   <createdirectory path="FOO"/>
249   
249
250250   <putfile name="\FOO\Alpha.Bravo.TXT">'Aaa'</putfile>
251251   <putfile name="\FOO\Charlie.Delta.Echo.TXT">'Bbbb'</putfile>
252252   <putfile name="\FOO\Foxtrot.Golf.Hotel.India.Juliet.TXT">'Ccccc'</putfile>
src/mess/machine/ap2_slot.c
r8325r8326
177177   /* do we actually have a device, and can we read? */
178178   if ((token->slot_device != NULL) && (config->rhcnxx != NULL))
179179   {
180      return (*config->rhcnxx)(token->slot_device, offset);
180      return (*config->rhcnxx)(token->slot_device, offset);
181181   }
182182
183183   if (config->slotnum > 0)
src/mess/machine/ncr5380.c
r8325r8326
493493
494494#if NCR5380_DEVICE_CONVERSION
495495DEFINE_LEGACY_DEVICE(NCR5380, ncr5380);
496#endif
No newline at end of file
496#endif
src/mess/machine/a2cffa.c
r8325r8326
1/*********************************************************************
2
3   a2cffa.c
4
5   Implementation of Rich Dreher's IDE/CompactFlash card
6   for the Apple II.
7
8   http://www.dreher.net/
9
10*********************************************************************/
11
12#include "a2cffa.h"
13#include "includes/apple2.h"
14#include "machine/idectrl.h"
15
16
17/***************************************************************************
18    PARAMETERS
19***************************************************************************/
20
21#define LOG_A2CFFA   1
22
23
24/***************************************************************************
25    TYPE DEFINITIONS
26***************************************************************************/
27
28typedef struct _a2cffa_token a2cffa_token;
29struct _a2cffa_token
30{
31   UINT8 *ROM;      // card ROM
32   UINT16 lastdata;   // last data from IDE
33};
34
35
36/***************************************************************************
37    INLINE FUNCTIONS
38***************************************************************************/
39
40INLINE a2cffa_token *get_token(running_device *device)
41{
42   assert(device != NULL);
43   assert(device->type() == A2CFFA);
44   return (a2cffa_token *)downcast<legacy_device_base *>(device)->token();
45}
46
47
48
49/***************************************************************************
50    FUNCTION PROTOTYPES
51***************************************************************************/
52
53/*-------------------------------------------------
54    DEVICE_START(a2cffa) - device start
55   function
56-------------------------------------------------*/
57
58static DEVICE_START(a2cffa)
59{
60}
61
62
63
64/*-------------------------------------------------
65    DEVICE_RESET(a2cffa) - device reset
66   function
67-------------------------------------------------*/
68
69static DEVICE_RESET(a2cffa)
70{
71   a2cffa_token *token = get_token(device);
72
73   // find card ROM
74   token->ROM = (UINT8 *)memory_region(device->machine, "cffa");
75}
76
77
78
79/*-------------------------------------------------
80    a2cffa_r - device read function
81-------------------------------------------------*/
82
83READ8_DEVICE_HANDLER(a2cffa_r)
84{
85   a2cffa_token *token = get_token(device);
86
87   if (offset == 0)
88   {
89      return token->lastdata>>8;
90   }   
91   else if (offset == 8)
92   {
93      token->lastdata = ide_controller_r(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 2);
94      return token->lastdata & 0xff;
95   }
96   else if (offset > 8)
97   {
98      return ide_controller_r(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 1);
99   }
100
101   return 0xff;
102}
103
104
105
106/*-------------------------------------------------
107    a2cffa_w - device write function
108-------------------------------------------------*/
109
110WRITE8_DEVICE_HANDLER(a2cffa_w)
111{
112   a2cffa_token *token = get_token(device);
113
114   if (offset == 0)
115   {
116      token->lastdata &= 0x00ff;
117      token->lastdata |= data<<8;
118   }   
119   else if (offset == 8)
120   {
121      token->lastdata &= 0xff00;
122      token->lastdata |= data;
123      ide_controller_w(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 2, token->lastdata);
124   }
125   else if (offset > 8)
126   {
127      ide_controller_w(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 1, data);
128   }
129}
130
131
132/* slot ext. ROM (C800) read function */
133READ8_DEVICE_HANDLER(a2cffa_c800_r)
134{
135   a2cffa_token *token = get_token(device);
136
137   return token->ROM[offset+0x800];
138}
139
140/* slot ext. ROM (C800) write function */
141WRITE8_DEVICE_HANDLER(a2cffa_c800_w)
142{
143}
144
145/* slot ROM (CN00) read function */
146READ8_DEVICE_HANDLER(a2cffa_cnxx_r)
147{
148   a2cffa_token *token = get_token(device);
149
150   return token->ROM[offset+0x700];   // this needs to be = to the slot #, we assume 7 for now
151}
152
153/* slot ROM (CN00) write function */
154WRITE8_DEVICE_HANDLER(a2cffa_cnxx_w)
155{
156}
157
158
159/*-------------------------------------------------
160    DEVICE_GET_INFO(a2cffa) - device get info
161   function
162-------------------------------------------------*/
163
164DEVICE_GET_INFO(a2cffa)
165{
166   switch (state)
167   {
168      /* --- the following bits of info are returned as 64-bit signed integers --- */
169      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(a2cffa_token);      break;
170      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
171
172      /* --- the following bits of info are returned as pointers to data or functions --- */
173      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(a2cffa);   break;
174      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
175      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(a2cffa);   break;
176
177      /* --- the following bits of info are returned as NULL-terminated strings --- */
178      case DEVINFO_STR_NAME:                     strcpy(info->s, "Apple II CFFA Card (www.dreher.net)");         break;
179      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Apple II CFFA Card (www.dreher.net)");         break;
180      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                     break;
181      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
182   }
183}
184
185DEFINE_LEGACY_DEVICE(A2CFFA, a2cffa);
1/*********************************************************************
2 
3    a2cffa.c
4 
5    Implementation of Rich Dreher's IDE/CompactFlash card
6    for the Apple II.
7 
8    http://www.dreher.net/
9 
10*********************************************************************/
11 
12#include "a2cffa.h"
13#include "includes/apple2.h"
14#include "machine/idectrl.h"
15 
16 
17/***************************************************************************
18    PARAMETERS
19***************************************************************************/
20 
21#define LOG_A2CFFA   1
22 
23 
24/***************************************************************************
25    TYPE DEFINITIONS
26***************************************************************************/
27 
28typedef struct _a2cffa_token a2cffa_token;
29struct _a2cffa_token
30{
31   UINT8 *ROM;      // card ROM
32   UINT16 lastdata;   // last data from IDE
33};
34 
35 
36/***************************************************************************
37    INLINE FUNCTIONS
38***************************************************************************/
39 
40INLINE a2cffa_token *get_token(running_device *device)
41{
42   assert(device != NULL);
43   assert(device->type() == A2CFFA);
44   return (a2cffa_token *)downcast<legacy_device_base *>(device)->token();
45}
46 
47 
48 
49/***************************************************************************
50    FUNCTION PROTOTYPES
51***************************************************************************/
52 
53/*-------------------------------------------------
54    DEVICE_START(a2cffa) - device start
55    function
56-------------------------------------------------*/
57 
58static DEVICE_START(a2cffa)
59{
60}
61 
62 
63 
64/*-------------------------------------------------
65    DEVICE_RESET(a2cffa) - device reset
66    function
67-------------------------------------------------*/
68 
69static DEVICE_RESET(a2cffa)
70{
71   a2cffa_token *token = get_token(device);
72 
73   // find card ROM
74   token->ROM = (UINT8 *)memory_region(device->machine, "cffa");
75}
76 
77 
78 
79/*-------------------------------------------------
80    a2cffa_r - device read function
81-------------------------------------------------*/
82 
83READ8_DEVICE_HANDLER(a2cffa_r)
84{
85   a2cffa_token *token = get_token(device);
86 
87   if (offset == 0)
88   {
89      return token->lastdata>>8;
90   }
91   else if (offset == 8)
92   {
93      token->lastdata = ide_controller_r(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 2);
94      return token->lastdata & 0xff;
95   }
96   else if (offset > 8)
97   {
98      return ide_controller_r(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 1);
99   }
100 
101   return 0xff;
102}
103 
104 
105 
106/*-------------------------------------------------
107    a2cffa_w - device write function
108-------------------------------------------------*/
109 
110WRITE8_DEVICE_HANDLER(a2cffa_w)
111{
112   a2cffa_token *token = get_token(device);
113 
114   if (offset == 0)
115   {
116      token->lastdata &= 0x00ff;
117      token->lastdata |= data<<8;
118   }
119   else if (offset == 8)
120   {
121      token->lastdata &= 0xff00;
122      token->lastdata |= data;
123      ide_controller_w(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 2, token->lastdata);
124   }
125   else if (offset > 8)
126   {
127      ide_controller_w(device->machine->devicelist.find("ide"), 0x1f0+offset-8, 1, data);
128   }
129}
130 
131 
132/* slot ext. ROM (C800) read function */
133READ8_DEVICE_HANDLER(a2cffa_c800_r)
134{
135   a2cffa_token *token = get_token(device);
136 
137   return token->ROM[offset+0x800];
138}
139 
140/* slot ext. ROM (C800) write function */
141WRITE8_DEVICE_HANDLER(a2cffa_c800_w)
142{
143}
144 
145/* slot ROM (CN00) read function */
146READ8_DEVICE_HANDLER(a2cffa_cnxx_r)
147{
148   a2cffa_token *token = get_token(device);
149 
150   return token->ROM[offset+0x700];   // this needs to be = to the slot #, we assume 7 for now
151}
152 
153/* slot ROM (CN00) write function */
154WRITE8_DEVICE_HANDLER(a2cffa_cnxx_w)
155{
156}
157 
158 
159/*-------------------------------------------------
160    DEVICE_GET_INFO(a2cffa) - device get info
161    function
162-------------------------------------------------*/
163 
164DEVICE_GET_INFO(a2cffa)
165{
166   switch (state)
167   {
168      /* --- the following bits of info are returned as 64-bit signed integers --- */
169      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(a2cffa_token);      break;
170      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
171 
172      /* --- the following bits of info are returned as pointers to data or functions --- */
173      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(a2cffa);   break;
174      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
175      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(a2cffa);   break;
176 
177      /* --- the following bits of info are returned as NULL-terminated strings --- */
178      case DEVINFO_STR_NAME:                     strcpy(info->s, "Apple II CFFA Card (www.dreher.net)");         break;
179      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Apple II CFFA Card (www.dreher.net)");         break;
180      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                     break;
181      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
182   }
183}
184 
185DEFINE_LEGACY_DEVICE(A2CFFA, a2cffa);
src/mess/machine/a2cffa.h
r8325r8326
1/*********************************************************************
2
3   a2cffa.h
4
5   Implementation of Rich Dreher's IDE/CompactFlash board for
6   the Apple II
7
8*********************************************************************/
9
10#ifndef __A2CFFA__
11#define __A2CFFA__
12
13#include "emu.h"
14
15
16/***************************************************************************
17    CONSTANTS
18***************************************************************************/
19
20DECLARE_LEGACY_DEVICE(A2CFFA, a2cffa);
21
22#define MDRV_A2CFFA_ADD(_tag)   \
23   MDRV_DEVICE_ADD((_tag), A2CFFA, 0)
24
25
26/***************************************************************************
27    FUNCTION PROTOTYPES
28***************************************************************************/
29/* slot read function */
30READ8_DEVICE_HANDLER(a2cffa_r);
31
32/* slot write function */
33WRITE8_DEVICE_HANDLER(a2cffa_w);
34
35/* slot ext. ROM (C800) read function */
36READ8_DEVICE_HANDLER(a2cffa_c800_r);
37
38/* slot ext. ROM (C800) write function */
39WRITE8_DEVICE_HANDLER(a2cffa_c800_w);
40
41/* slot ROM (CN00) read function */
42READ8_DEVICE_HANDLER(a2cffa_cnxx_r);
43
44/* slot ROM (CN00) write function */
45WRITE8_DEVICE_HANDLER(a2cffa_cnxx_w);
46
47#endif /* __A2SCSI__ */
48
1/*********************************************************************
2 
3    a2cffa.h
4 
5    Implementation of Rich Dreher's IDE/CompactFlash board for
6    the Apple II
7 
8*********************************************************************/
9 
10#ifndef __A2CFFA__
11#define __A2CFFA__
12 
13#include "emu.h"
14 
15 
16/***************************************************************************
17    CONSTANTS
18***************************************************************************/
19 
20DECLARE_LEGACY_DEVICE(A2CFFA, a2cffa);
21 
22#define MDRV_A2CFFA_ADD(_tag)   \
23   MDRV_DEVICE_ADD((_tag), A2CFFA, 0)
24 
25 
26/***************************************************************************
27    FUNCTION PROTOTYPES
28***************************************************************************/
29/* slot read function */
30READ8_DEVICE_HANDLER(a2cffa_r);
31 
32/* slot write function */
33WRITE8_DEVICE_HANDLER(a2cffa_w);
34 
35/* slot ext. ROM (C800) read function */
36READ8_DEVICE_HANDLER(a2cffa_c800_r);
37 
38/* slot ext. ROM (C800) write function */
39WRITE8_DEVICE_HANDLER(a2cffa_c800_w);
40 
41/* slot ROM (CN00) read function */
42READ8_DEVICE_HANDLER(a2cffa_cnxx_r);
43 
44/* slot ROM (CN00) write function */
45WRITE8_DEVICE_HANDLER(a2cffa_cnxx_w);
46 
47#endif /* __A2SCSI__ */
48 
src/mess/machine/gb.c
r8325r8326
339339   sgb_tile_data = auto_alloc_array_clear(machine, UINT8, 0x2000 );
340340
341341   add_exit_callback(machine, gb_machine_stop);
342   
342
343343   /* Allocate the serial timer, and disable it */
344344   gb_driver_data.gb_serial_timer = timer_alloc(machine,  gb_serial_timer_proc , NULL);
345345   timer_enable( gb_driver_data.gb_serial_timer, 0 );
src/mess/machine/thomson.c
r8325r8326
188188{
189189   running_device* img = thom_cassette_img(machine);
190190   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
191   
191
192192   if ( image->exists() )
193193   {
194194      cassette_image* cass = cassette_get_image( img );
src/mess/machine/8530scc.c
r8325r8326
8181/***************************************************************************
8282    INLINE FUNCTIONS
8383***************************************************************************/
84         
84
8585INLINE scc8530_t *get_token(running_device *device)
8686{
8787   assert(device->type() == SCC8530);
r8325r8326
138138      scc->IRQType = IRQ_NONE;
139139   }
140140
141//   printf("SCC: irqstat %d, last %d\n", irqstat, scc->lastIRQStat);
142//   printf("ch0: en %d pd %d  ch1: en %d pd %d\n", scc->channel[0].txIRQEnable, scc->channel[0].txIRQPending, scc->channel[1].txIRQEnable, scc->channel[1].txIRQPending);
141//  printf("SCC: irqstat %d, last %d\n", irqstat, scc->lastIRQStat);
142//  printf("ch0: en %d pd %d  ch1: en %d pd %d\n", scc->channel[0].txIRQEnable, scc->channel[0].txIRQPending, scc->channel[1].txIRQEnable, scc->channel[1].txIRQPending);
143143
144144   // don't spam the driver with unnecessary transitions
145145   if (irqstat != scc->lastIRQStat)
r8325r8326
203203      {
204204         pChan->extIRQPending = 1;
205205         pChan->baudIRQPending = 0;
206          scc_updateirqs(device);
206         scc_updateirqs(device);
207207      }
208208   }
209209
r8325r8326
546546
547547   offset &= 3;
548548
549//   printf("SCC: mode %d data %x offset %d\n", scc->mode, data, offset);
549//  printf("SCC: mode %d data %x offset %d\n", scc->mode, data, offset);
550550
551551   switch(offset)
552552   {
r8325r8326
558558            {
559559               scc->mode = 1;
560560               scc->reg = data & 0x0f;
561//               scc_putbreg(device, data & 0xf0);
561//                  scc_putbreg(device, data & 0xf0);
562562            }
563563            else if (data == 0x10)
564564            {
r8325r8326
584584            {
585585               scc->mode = 1;
586586               scc->reg = data & 0x0f;
587//               scc_putareg(device, data & 0xf0);
587//                  scc_putareg(device, data & 0xf0);
588588            }
589589            else if (data == 0x10)
590590            {
src/mess/machine/pmd85.c
r8325r8326
933933      case MATO:
934934         break;
935935   }
936   
936
937937   for (i = 0; i < 4; i++)
938938      for (j = 0; j < 3; j++)
939939         pmd85_ppi_port_outputs[i][j] = 0;
src/mess/machine/osborne1.c
r8325r8326
505505//static int osborne1_daisy_irq_ack(running_device *device)
506506//{
507507//    /* Enable ROM and I/O when IRQ is acknowledged */
508//    UINT8   old_bankswitch = osborne1.bankswitch;
508//    UINT8 old_bankswitch = osborne1.bankswitch;
509509//    const address_space* space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
510510//
511511//    osborne1_bankswitch_w( space, 0, 0 );
r8325r8326
531531//
532532//DEVICE_GET_INFO( osborne1_daisy )
533533//{
534//   switch (state)
535//   {
536//      /* --- the following bits of info are returned as 64-bit signed integers --- */
537//      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
538//      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
534//  switch (state)
535//  {
536//      /* --- the following bits of info are returned as 64-bit signed integers --- */
537//      case DEVINFO_INT_TOKEN_BYTES:                   info->i = 4;                                            break;
538//      case DEVINFO_INT_INLINE_CONFIG_BYTES:           info->i = 0;                                            break;
539539//
540//      /* --- the following bits of info are returned as pointers to data or functions --- */
541//      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(osborne1_daisy);      break;
542//      case DEVINFO_FCT_STOP:                     /* Nothing */                                 break;
543//      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(osborne1_daisy);      break;
544//      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)osborne1_daisy_irq_state;            break;
545//      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)osborne1_daisy_irq_ack;            break;
546//      case DEVINFO_FCT_IRQ_RETI:                  info->f = (genf *)osborne1_daisy_irq_reti;            break;
540//      /* --- the following bits of info are returned as pointers to data or functions --- */
541//      case DEVINFO_FCT_START:                         info->start = DEVICE_START_NAME(osborne1_daisy);        break;
542//      case DEVINFO_FCT_STOP:                          /* Nothing */                                           break;
543//      case DEVINFO_FCT_RESET:                         info->reset = DEVICE_RESET_NAME(osborne1_daisy);        break;
544//      case DEVINFO_FCT_IRQ_STATE:                     info->f = (genf *)osborne1_daisy_irq_state;             break;
545//      case DEVINFO_FCT_IRQ_ACK:                       info->f = (genf *)osborne1_daisy_irq_ack;               break;
546//      case DEVINFO_FCT_IRQ_RETI:                      info->f = (genf *)osborne1_daisy_irq_reti;              break;
547547//
548//      /* --- the following bits of info are returned as NULL-terminated strings --- */
549//      case DEVINFO_STR_NAME:                     strcpy(info->s, "Osborne1 daisy");                        break;
550//      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Z80");                              break;
551//      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
552//      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                              break;
553//      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");               break;
554//   }
548//      /* --- the following bits of info are returned as NULL-terminated strings --- */
549//      case DEVINFO_STR_NAME:                          strcpy(info->s, "Osborne1 daisy");                              break;
550//      case DEVINFO_STR_FAMILY:                        strcpy(info->s, "Z80");                                     break;
551//      case DEVINFO_STR_VERSION:                       strcpy(info->s, "1.0");                                     break;
552//      case DEVINFO_STR_SOURCE_FILE:                   strcpy(info->s, __FILE__);                                      break;
553//      case DEVINFO_STR_CREDITS:                       strcpy(info->s, "Copyright the MESS Team");                 break;
554//  }
555555//}
556556//
557557//DEFINE_LEGACY_DEVICE(OSBORNE1_DAISY, osborne1_daisy);
src/mess/machine/nes_pcb.c
r8325r8326
322322   { "BANDAI-LZ93D50+24C02", BANDAI_LZ93EX },
323323   { "BANDAI-FCG-1",     BANDAI_FCG },
324324   { "BANDAI-FCG-2",     BANDAI_FCG },
325   { "BANDAI-JUMP2",     BANDAI_JUMP2 },   
325   { "BANDAI-JUMP2",     BANDAI_JUMP2 },
326326   { "BANDAI-DATACH",    BANDAI_DATACH },
327327   { "BANDAI-KARAOKE",   BANDAI_KARAOKE },
328328   { "BANDAI-OEKAKIDS",  BANDAI_OEKAKIDS },
r8325r8326
530530   { "BTL-TOBIDASEDAISAKUSEN", UNSUPPORTED_BOARD },// mapper 120
531531   { "BTL-SHUIGUANPIPE",  UNSUPPORTED_BOARD },// mapper 183
532532   { "BTL-PIKACHUY2K",    UNSUPPORTED_BOARD },// mapper 254
533//   
533//
534534   { "BMC-190IN1",          BMC_190IN1 },
535535   { "BMC-64IN1NOREPEAT",   BMC_64IN1NR },
536536   { "BMC-A65AS",           BMC_A65AS },
r8325r8326
623623
624624   PCB Emulation (to be moved to MAME later)
625625
626   In the end, iNES, UNIF and xml should be
627   simply handled through a look-up table
626   In the end, iNES, UNIF and xml should be
627   simply handled through a look-up table
628628   which associates the mapper/board/feature
629629   to the correct pcb_id and then the core
630630   function pcb_handlers_setup should be called
631631   to set-up the expected handlers and callbacks
632 
633   Similarly, PC-10, VSNES and NES-based
634   multigame boards, should simply call
635   pcb_handlers_setup with the proper pcb_id
632
633   Similarly, PC-10, VSNES and NES-based
634   multigame boards, should simply call
635   pcb_handlers_setup with the proper pcb_id
636636   at the beginning, rather than use ad hoc
637637   implementations.
638
638
639639************************************************/
640640
641641
642642/*************************************************************
643
643
644644 UxROM board emulation
645
645
646646 writes to 0x8000-0xffff change PRG 16K lower banks
647
647
648648 missing BC?
649649
650650 iNES: mapper 2
r8325r8326
654654static WRITE8_HANDLER( uxrom_w )
655655{
656656   LOG_MMC(("uxrom_w, offset: %04x, data: %02x\n", offset, data));
657   
657
658658   prg16_89ab(space->machine, data);
659659}
660660
661661/*************************************************************
662
662
663663 Nihon Bussan UNROM M5
664664
665665 Games: Crazy Climber Jpn
666
666
667667 Very simple mapper: prg16_89ab is always set to bank 0,
668668 while prg16_cdef is set by writes to 0x8000-0xffff. The game
669669 uses a custim controller.
670
670
671671 iNES: mapper 180
672
672
673673 In MESS: Supported.
674
674
675675 *************************************************************/
676676
677677static WRITE8_HANDLER( uxrom_cc_w )
678678{
679679   LOG_MMC(("uxrom_cc_w, offset: %04x, data: %02x\n", offset, data));
680   
680
681681   prg16_cdef(space->machine, data);
682682}
683683
684684/*************************************************************
685
685
686686 UN1ROM board emulation
687 
688 writes to 0x8000-0xffff change PRG 16K lower banks
689 
687
688 writes to 0x8000-0xffff change PRG 16K lower banks
689
690690 missing BC?
691691
692692 iNES: mapper 94
693
693
694694 *************************************************************/
695695
696696static WRITE8_HANDLER( un1rom_w )
697697{
698698   LOG_MMC(("un1rom_w, offset: %04x, data: %02x\n", offset, data));
699   
699
700700   prg16_89ab(space->machine, data >> 2);
701701}
702702
703703/*************************************************************
704
704
705705 CNROM board emulation
706
706
707707 writes to 0x8000-0xffff change CHR 8K banks
708
708
709709 missing BC?
710710
711711 iNES: mapper 3
712 
713 Notice that BANDAI_PT554 board (Aerobics Studio) uses very
714 similar hardware but with an additional sound chip which
712
713 Notice that BANDAI_PT554 board (Aerobics Studio) uses very
714 similar hardware but with an additional sound chip which
715715 gets writes to 0x6000 (currently unemulated in MESS)
716716
717717 *************************************************************/
r8325r8326
735735}
736736
737737/*************************************************************
738
738
739739 Bandai PT-554 board emulation
740
740
741741 This is used by Aerobics Studio. It is basically a CNROM board
742742 with an additional sound chip which is not currently emulated by
743743 MESS
744
744
745745 iNES: mapper 3?
746746
747747 *************************************************************/
r8325r8326
749749static WRITE8_HANDLER( bandai_pt554_m_w )
750750{
751751   LOG_MMC(("Bandai PT-554 Sound write, data: %02x\n", data));
752   
752
753753   // according to NEStopia, this is the effect
754754   if (!BIT(data, 6))
755755   {
r8325r8326
758758}
759759
760760/*************************************************************
761
761
762762 CPROM board emulation
763
763
764764 writes to 0x8000-0xffff change CHR 4K lower banks
765
765
766766 iNES: mapper 13
767
767
768768 *************************************************************/
769769
770770static WRITE8_HANDLER( cprom_w )
r8325r8326
774774}
775775
776776/*************************************************************
777
777
778778 AxROM board emulation
779
779
780780 writes to 0x8000-0xffff change PRG banks + sets mirroring
781
781
782782 missing BC for AMROM?
783
783
784784 iNES: mapper 7
785
785
786786 *************************************************************/
787787
788788static WRITE8_HANDLER( axrom_w )
789789{
790790   LOG_MMC(("axrom_w, offset: %04x, data: %02x\n", offset, data));
791   
791
792792   set_nt_mirroring(space->machine, BIT(data, 4) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
793793   prg32(space->machine, data);
794794}
795795
796796/*************************************************************
797
797
798798 BxROM board emulation
799
799
800800 writes to 0x8000-0xffff change PRG banks
801
801
802802 missing BC?
803
803
804804 iNES: mapper 34
805
805
806806 *************************************************************/
807807
808808static WRITE8_HANDLER( bxrom_w )
r8325r8326
810810   /* This portion of the mapper is nearly identical to Mapper 7, except no one-screen mirroring */
811811   /* Deadly Towers is really a BxROM game - the demo screens look wrong using mapper 7. */
812812   LOG_MMC(("bxrom_w, offset: %04x, data: %02x\n", offset, data));
813   
813
814814   prg32(space->machine, data);
815815}
816816
817817/*************************************************************
818
818
819819 GxROM/MxROM board emulation
820
820
821821 writes to 0x8000-0xffff change PRG and CHR banks
822
822
823823 missing BC?
824
824
825825 iNES: mapper 66
826
826
827827 *************************************************************/
828828
829829static WRITE8_HANDLER( gxrom_w )
830830{
831831   LOG_MMC(("gxrom_w, offset %04x, data: %02x\n", offset, data));
832   
832
833833   prg32(space->machine, (data & 0xf0) >> 4);
834834   chr8(space->machine, data & 0x0f, CHRROM);
835835}
836836
837837/*************************************************************
838
838
839839 SxROM (MMC1 based) board emulation
840 
841 iNES: mapper 1 (and 155 for the MMC1A variant which does not
840
841 iNES: mapper 1 (and 155 for the MMC1A variant which does not
842842 have WRAM disable bit)
843
843
844844 *************************************************************/
845845
846846static TIMER_CALLBACK( mmc1_resync_callback )
r8325r8326
890890{
891891   nes_state *state = (nes_state *)machine->driver_data;
892892   UINT8 prg_mode, prg_offset;
893   
893
894894   prg_mode = state->mmc_reg[0] & 0x0c;
895895   /* prg_mode&0x8 determines bank size: 32k (if 0) or 16k (if 1)? when in 16k mode,
896    prg_mode&0x4 determines which half of the PRG space we can swap: if it is 4,
897    mmc_reg[3] sets banks at 0x8000; if it is 0, mmc_reg[3] sets banks at 0xc000. */
898   
896     prg_mode&0x4 determines which half of the PRG space we can swap: if it is 4,
897     mmc_reg[3] sets banks at 0x8000; if it is 0, mmc_reg[3] sets banks at 0xc000. */
898
899899   prg_offset = state->mmc_reg[1] & 0x10;
900900   /* In principle, mmc_reg[2]&0x10 might affect "extended" banks as well, when chr_mode=1.
901    However, quoting Disch's docs: When in 4k CHR mode, 0x10 in both $A000 and $C000 *must* be
902    set to the same value, or else pages will constantly be swapped as graphics render!
903    Hence, we use only mmc_reg[1]&0x10 for prg_offset */
901     However, quoting Disch's docs: When in 4k CHR mode, 0x10 in both $A000 and $C000 *must* be
902     set to the same value, or else pages will constantly be swapped as graphics render!
903     Hence, we use only mmc_reg[1]&0x10 for prg_offset */
904904
905905   switch (prg_mode)
906906   {
907907      case 0x00:
908908      case 0x04:
909//         printf("PRG 32 bank %d \n", (prg_offset + state->mmc_reg[3]) >> 1);
909//          printf("PRG 32 bank %d \n", (prg_offset + state->mmc_reg[3]) >> 1);
910910         prg32(machine, (prg_offset + state->mmc_reg[3]) >> 1);
911911         break;
912912      case 0x08:
913//         printf("PRG 16 bank %d (high) \n", prg_offset + state->mmc_reg[3]);
913//          printf("PRG 16 bank %d (high) \n", prg_offset + state->mmc_reg[3]);
914914         prg16_89ab(machine, prg_offset + 0);
915915         prg16_cdef(machine, prg_offset + state->mmc_reg[3]);
916916         break;
917917      case 0x0c:
918//         printf("PRG 16 bank %d (low) \n", prg_offset + state->mmc_reg[3]);
918//          printf("PRG 16 bank %d (low) \n", prg_offset + state->mmc_reg[3]);
919919         prg16_89ab(machine, prg_offset + state->mmc_reg[3]);
920920         prg16_cdef(machine, prg_offset + 0x0f);
921921         break;
r8325r8326
932932{
933933   nes_state *state = (nes_state *)machine->driver_data;
934934   UINT8 chr_mode = BIT(state->mmc_reg[0], 4);
935   
935
936936   if (chr_mode)
937937   {
938938      chr4_0(machine, state->mmc_reg[1] & 0x1f, state->mmc_chr_source);
r8325r8326
947947   running_machine *machine = space->machine;
948948   nes_state *state = (nes_state *)machine->driver_data;
949949   /* Note that there is only one latch and shift counter, shared amongst the 4 regs */
950   /* Space Shuttle will not work if they have independent variables. */   
951   
950   /* Space Shuttle will not work if they have independent variables. */
951
952952   /* here we would need to add an if(cpu_cycles_passed>1) test, and
953    if requirement is not met simply return without writing anything.
954    Some games (AD&D Hillsfar, Bill & Ted Excellent Adventure, Cosmic
955    Wars, Rocket Ranger, Sesame Street 123 and Snow Brothers) rely on
956    this behavior!! */
953     if requirement is not met simply return without writing anything.
954     Some games (AD&D Hillsfar, Bill & Ted Excellent Adventure, Cosmic
955     Wars, Rocket Ranger, Sesame Street 123 and Snow Brothers) rely on
956     this behavior!! */
957957   if (state->mmc1_reg_write_enable == 0)
958958   {
959959      return;
r8325r8326
968968   {
969969      state->mmc_count = 0;
970970      state->mmc_latch1 = 0;
971     
971
972972      /* Set reg at 0x8000 to size 16k and lower half swap - needed for Robocop 3, Dynowars */
973973      state->mmc_reg[0] |= 0x0c;
974974      mmc1_set_prg_wram(space, board);
975975      return;
976976   }
977   
977
978978   if (state->mmc_count < 5)
979979   {
980980      if (state->mmc_count == 0) state->mmc_latch1 = 0;
r8325r8326
982982      state->mmc_latch1 |= (data & 0x01) ? 0x10 : 0x00;
983983      state->mmc_count++;
984984   }
985   
985
986986   if (state->mmc_count == 5)
987987   {
988988      switch (offset & 0x6000)   /* Which reg shall we write to? */
989989      {
990990         case 0x0000:
991991            state->mmc_reg[0] = state->mmc_latch1;
992           
992
993993            switch (state->mmc_reg[0] & 0x03)
994994            {
995995            case 0: set_nt_mirroring(machine, PPU_MIRROR_LOW); break;
r8325r8326
10141014            mmc1_set_prg_wram(space, board);
10151015            break;
10161016      }
1017     
1017
10181018      state->mmc_count = 0;
10191019   }
10201020}
r8325r8326
10281028}
10291029
10301030/*************************************************************
1031
1031
10321032 PxROM (MMC2 based) board emulation
1033
1033
10341034 iNES: mapper 9
1035
1035
10361036 *************************************************************/
10371037
10381038static void mmc2_latch( running_device *device, offs_t offset )
r8325r8326
11031103}
11041104
11051105/*************************************************************
1106
1106
11071107 FxROM (MMC4 based) board emulation
1108
1108
11091109 iNES: mapper 10
1110
1110
11111111 *************************************************************/
11121112
11131113static WRITE8_HANDLER( fxrom_w )
r8325r8326
11251125}
11261126
11271127/*************************************************************
1128
1128
11291129 TxROM (MMC3 based) board emulation
1130
1130
11311131 iNES: mapper 4
1132
1132
11331133 *************************************************************/
11341134
11351135static void mmc3_set_wram( const address_space *space )
11361136{
11371137   running_machine *machine = space->machine;
11381138   nes_state *state = (nes_state *)machine->driver_data;
1139   
1139
11401140   // skip this function if we are emulating a MMC3 clone with mid writes
11411141   if (state->mmc_write_mid != NULL)
11421142      return;
r8325r8326
11621162{
11631163   nes_state *state = (nes_state *)machine->driver_data;
11641164   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
1165   
1165
11661166   prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
11671167   prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask));
11681168   prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
r8325r8326
11731173{
11741174   nes_state *state = (nes_state *)machine->driver_data;
11751175   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
1176   
1176
11771177   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
11781178   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
11791179   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
r8325r8326
11881188static void mmc3_irq( running_device *device, int scanline, int vblank, int blanked )
11891189{
11901190   nes_state *state = (nes_state *)device->machine->driver_data;
1191   
1191
11921192   if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE)
11931193   {
11941194      int priorCount = state->IRQ_count;
r8325r8326
11961196         state->IRQ_count = state->IRQ_count_latch;
11971197      else
11981198         state->IRQ_count--;
1199     
1199
12001200      if (state->IRQ_enable && !blanked && (state->IRQ_count == 0) && (priorCount || state->IRQ_clear /*|| !state->mmc3_alt_irq*/)) // according to blargg the latter should be present as well, but it breaks Rampart and Joe & Mac US: they probably use the alt irq!
12011201      {
12021202         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
r8325r8326
12111211{
12121212   nes_state *state = (nes_state *)space->machine->driver_data;
12131213   UINT8 mmc3_helper, cmd;
1214   
1214
12151215   LOG_MMC(("txrom_w, offset: %04x, data: %02x\n", offset, data));
1216   
1216
12171217   switch (offset & 0x6001)
12181218   {
12191219      case 0x0000:
12201220         mmc3_helper = state->mmc_latch1 ^ data;
12211221         state->mmc_latch1 = data;
1222         
1222
12231223         /* Has PRG Mode changed? */
12241224         if (mmc3_helper & 0x40)
12251225            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1226         
1226
12271227         /* Has CHR Mode changed? */
12281228         if (mmc3_helper & 0x80)
12291229            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
12301230         break;
1231         
1231
12321232      case 0x0001:
12331233         cmd = state->mmc_latch1 & 0x07;
12341234         switch (cmd)
r8325r8326
12451245            break;
12461246         }
12471247         break;
1248         
1248
12491249      case 0x2000:
12501250         set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
12511251         break;
1252         
1252
12531253      case 0x2001:
12541254         state->mmc_latch2 = data;
12551255         mmc3_set_wram(space);
12561256         break;
1257         
1257
12581258      case 0x4000:
12591259         state->IRQ_count_latch = data;
12601260         break;
1261         
1261
12621262      case 0x4001:
12631263         state->IRQ_count = 0;
12641264         break;
1265         
1265
12661266      case 0x6000:
12671267         state->IRQ_enable = 0;
12681268         break;
1269         
1269
12701270      case 0x6001:
12711271         state->IRQ_enable = 1;
12721272         break;
1273         
1273
12741274      default:
12751275         logerror("txrom_w uncaught: %04x value: %02x\n", offset + 0x8000, data);
12761276         break;
r8325r8326
12781278}
12791279
12801280/*************************************************************
1281
1281
12821282 HKROM (MMC6 based) board emulation
1283
1283
12841284 iNES: mapper 4
1285
1285
12861286 *************************************************************/
12871287
12881288static WRITE8_HANDLER( hkrom_m_w )
r8325r8326
12901290   nes_state *state = (nes_state *)space->machine->driver_data;
12911291   UINT8 write_hi, write_lo;
12921292   LOG_MMC(("hkrom_m_w, offset: %04x, data: %02x\n", offset, data));
1293   
1293
12941294   if (offset < 0x1000)
1295      return;   
1295      return;
12961296
12971297   // banks can be written only if both read & write is enabled!
12981298   write_hi = ((state->mmc6_reg & 0xc0) == 0xc0);
r8325r8326
13001300
13011301   if (BIT(offset, 9) && write_hi)   // access to upper 1k
13021302      state->mapper_ram[offset & (state->mapper_ram_size - 1)] = data;
1303   
1303
13041304   if (!BIT(offset, 9) && write_lo)   // access to lower 1k
13051305      state->mapper_ram[offset & (state->mapper_ram_size - 1)] = data;
13061306}
r8325r8326
13091309{
13101310   nes_state *state = (nes_state *)space->machine->driver_data;
13111311   LOG_MMC(("hkrom_m_r, offset: %04x\n", offset));
1312   
1312
13131313   if (offset < 0x1000)
13141314      return 0xff;   // here it should be open bus
13151315
r8325r8326
13401340
13411341         if (!state->mmc_latch2 && BIT(data, 5))   // if WRAM is disabled and has to be enabled, write
13421342            state->mmc_latch2 = BIT(data, 5);   // (once WRAM has been enabled, it cannot be disabled without resetting the game)
1343         
1343
13441344         /* Has PRG Mode changed? */
13451345         if (BIT(mmc6_helper, 6))
13461346            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1347         
1347
13481348         /* Has CHR Mode changed? */
13491349         if (BIT(mmc6_helper, 7))
13501350            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
r8325r8326
13591359         state->IRQ_count = 0;
13601360         state->IRQ_clear = 1;
13611361         break;
1362         
1362
13631363      default:
13641364         txrom_w(space, offset, data);
13651365         break;
r8325r8326
13671367}
13681368
13691369/*************************************************************
1370
1370
13711371 TxSROM (MMC3 based) board emulation
1372
1372
13731373 iNES: mapper 118
1374
1374
13751375 *************************************************************/
13761376
13771377static void txsrom_set_mirror( running_machine *machine )
r8325r8326
13981398   nes_state *state = (nes_state *)space->machine->driver_data;
13991399   UINT8 MMC3_helper, cmd;
14001400   LOG_MMC(("mapper118_w, offset: %04x, data: %02x\n", offset, data));
1401   
1401
14021402   switch (offset & 0x6001)
14031403   {
14041404      case 0x0000:
14051405         MMC3_helper = state->mmc_latch1 ^ data;
14061406         state->mmc_latch1 = data;
1407         
1407
14081408         /* Has PRG Mode changed? */
14091409         if (MMC3_helper & 0x40)
14101410            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1411         
1411
14121412         /* Has CHR Mode changed? */
14131413         if (MMC3_helper & 0x80)
14141414         {
r8325r8326
14161416            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
14171417         }
14181418         break;
1419         
1419
14201420      case 0x0001:
14211421         cmd = state->mmc_latch1 & 0x07;
14221422         switch (cmd)
r8325r8326
14341434            break;
14351435         }
14361436         break;
1437         
1437
14381438      case 0x2000:
14391439         break;
1440         
1440
14411441      default:
14421442         txrom_w(space, offset, data);
14431443         break;
r8325r8326
14451445}
14461446
14471447/*************************************************************
1448
1448
14491449 TQROM (MMC3 based) board emulation
1450
1450
14511451 iNES: mapper 119
1452
1452
14531453 *************************************************************/
14541454
14551455static void tqrom_set_chr( running_machine *machine )
r8325r8326
14581458   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
14591459   UINT8 chr_src[6], chr_mask[6];
14601460   int i;
1461   
1461
14621462   for (i = 0; i < 6; i++)
14631463   {
14641464      chr_src[i] = (state->mmc_vrom_bank[i] & 0x40) ? CHRRAM : CHRROM;
14651465      chr_mask[i] =  (state->mmc_vrom_bank[i] & 0x40) ? 0x07 : 0x3f;
14661466   }
1467   
1467
14681468   chr1_x(machine, chr_page ^ 0, ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask[0]), chr_src[0]);
14691469   chr1_x(machine, chr_page ^ 1, ((state->mmc_vrom_bank[0] |  0x01) & chr_mask[0]), chr_src[0]);
14701470   chr1_x(machine, chr_page ^ 2, ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask[1]), chr_src[1]);
r8325r8326
14801480   nes_state *state = (nes_state *)space->machine->driver_data;
14811481   UINT8 MMC3_helper, cmd;
14821482   LOG_MMC(("mapper119_w, offset: %04x, data: %02x\n", offset, data));
1483   
1483
14841484   switch (offset & 0x6001)
14851485   {
14861486      case 0x0000:
14871487         MMC3_helper = state->mmc_latch1 ^ data;
14881488         state->mmc_latch1 = data;
1489         
1489
14901490         /* Has PRG Mode changed? */
14911491         if (MMC3_helper & 0x40)
14921492            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1493         
1493
14941494         /* Has CHR Mode changed? */
14951495         if (MMC3_helper & 0x80)
14961496            tqrom_set_chr(space->machine);
r8325r8326
15111511            break;
15121512         }
15131513         break;
1514         
1514
15151515      default:
15161516         txrom_w(space, offset, data);
15171517         break;
r8325r8326
15191519}
15201520
15211521/*************************************************************
1522
1522
15231523 PAL-ZZ board (MMC3 variant for European 3-in-1 Nintendo cart
15241524 Super Mario Bros. + Tetris + Nintendo World Cup)
1525
1525
15261526 iNES: mapper 37
1527
1527
15281528 *************************************************************/
15291529
15301530static WRITE8_HANDLER( zz_m_w )
r8325r8326
15321532   nes_state *state = (nes_state *)space->machine->driver_data;
15331533   UINT8 map37_helper;
15341534   LOG_MMC(("zz_m_w, offset: %04x, data: %02x\n", offset, data));
1535   
1535
15361536   map37_helper = data & 0x07;
1537   
1537
15381538   state->mmc_prg_base = (BIT(map37_helper, 2) << 4) | (((map37_helper & 0x03) == 0x03) ? 0x08 : 0);
15391539   state->mmc_prg_mask = (map37_helper << 1) | 0x07;
15401540   state->mmc_chr_base = BIT(map37_helper, 2) << 7;
r8325r8326
15441544}
15451545
15461546/*************************************************************
1547
1547
15481548 NES-QJ board (MMC3 variant for US 2-in-1 Nintendo cart
15491549 Super Spike V'Ball + Nintendo World Cup)
1550
1550
15511551 iNES: mapper 47
1552
1552
15531553 *************************************************************/
15541554
15551555static WRITE8_HANDLER( qj_m_w )
15561556{
15571557   nes_state *state = (nes_state *)space->machine->driver_data;
15581558   LOG_MMC(("qj_m_w, offset: %04x, data: %02x\n", offset, data));
1559   
1559
15601560   state->mmc_prg_base = BIT(data, 0) << 4;
15611561   state->mmc_prg_mask = 0x0f;
15621562   state->mmc_chr_base = BIT(data, 0) << 7;
r8325r8326
15661566}
15671567
15681568/*************************************************************
1569
1569
15701570 ExROM (MMC5 based) board emulation
1571
1571
15721572 iNES: mapper 5
1573
1573
15741574 MESS status: Mostly Unsupported
1575
1575
15761576 *************************************************************/
15771577
15781578static void mmc5_irq( running_device *device, int scanline, int vblank, int blanked )
15791579{
15801580   nes_state *state = (nes_state *)device->machine->driver_data;
1581   
1581
15821582#if 1
15831583   if (scanline == 0)
15841584      state->IRQ_status |= 0x40;
15851585   else if (scanline > PPU_BOTTOM_VISIBLE_SCANLINE)
15861586      state->IRQ_status &= ~0x40;
15871587#endif
1588   
1588
15891589   if (scanline == state->IRQ_count)
15901590   {
15911591      if (state->IRQ_enable)
15921592         cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE);
1593     
1593
15941594      state->IRQ_status = 0xff;
15951595   }
15961596}
r8325r8326
16211621{
16221622   nes_state *state = (nes_state *)space->machine->driver_data;
16231623   int retVal;
1624   
1624
16251625   /* $5c00 - $5fff: extended videoram attributes */
16261626   if ((offset >= 0x1b00) && (offset <= 0x1eff))
16271627   {
16281628      return state->mmc5_vram[offset - 0x1b00];
16291629   }
1630   
1630
16311631   switch (offset)
16321632   {
16331633      case 0x1104: /* $5204 */
r8325r8326
16411641         state->IRQ_status &= ~0x80;
16421642         return retVal;
16431643#endif
1644         
1644
16451645      case 0x1105: /* $5205 */
16461646         return (state->mult1 * state->mult2) & 0xff;
16471647      case 0x1106: /* $5206 */
16481648         return ((state->mult1 * state->mult2) & 0xff00) >> 8;
1649         
1649
16501650      default:
16511651         logerror("** MMC5 uncaught read, offset: %04x\n", offset + 0x4100);
16521652         return 0x00;
r8325r8326
16571657static WRITE8_HANDLER( exrom_l_w )
16581658{
16591659   nes_state *state = (nes_state *)space->machine->driver_data;
1660   
1660
16611661   //  LOG_MMC(("Mapper 5 write, offset: %04x, data: %02x\n", offset + 0x4100, data));
16621662   /* Send $5000-$5015 to the sound chip */
16631663   if ((offset >= 0xf00) && (offset <= 0xf15))
r8325r8326
16651665      nes_psg_w(state->sound, offset & 0x1f, data);
16661666      return;
16671667   }
1668   
1668
16691669   /* $5c00 - $5fff: extended videoram attributes */
16701670   if ((offset >= 0x1b00) && (offset <= 0x1eff))
16711671   {
r8325r8326
16731673         state->mmc5_vram[offset - 0x1b00] = data;
16741674      return;
16751675   }
1676   
1676
16771677   switch (offset)
16781678   {
16791679      case 0x1000: /* $5100 */
16801680         state->MMC5_rom_bank_mode = data & 0x03;
16811681         LOG_MMC(("MMC5 rom bank mode: %02x\n", data));
16821682         break;
1683         
1683
16841684      case 0x1001: /* $5101 */
16851685         state->MMC5_vrom_bank_mode = data & 0x03;
16861686         LOG_MMC(("MMC5 vrom bank mode: %02x\n", data));
16871687         break;
1688         
1688
16891689      case 0x1002: /* $5102 */
16901690         if (data == 0x02)
16911691            state->MMC5_vram_protect |= 1;
r8325r8326
17001700            state->MMC5_vram_protect = 0;
17011701         LOG_MMC(("MMC5 vram protect 2: %02x\n", data));
17021702         break;
1703         
1703
17041704      case 0x1004: /* $5104 - Extra VRAM (EXRAM) control */
17051705         state->mmc5_vram_control = data & 0x03;
17061706         LOG_MMC(("MMC5 exram control: %02x\n", data));
17071707         break;
1708         
1708
17091709      case 0x1005: /* $5105 */
17101710         mmc5_ppu_mirror(space->machine, 0, data & 0x03);
17111711         mmc5_ppu_mirror(space->machine, 1, (data & 0x0c) >> 2);
17121712         mmc5_ppu_mirror(space->machine, 2, (data & 0x30) >> 4);
17131713         mmc5_ppu_mirror(space->machine, 3, (data & 0xc0) >> 6);
17141714         break;
1715         
1715
17161716         /* tile data for MMC5 flood-fill NT mode */
17171717      case 0x1006:
17181718         state->MMC5_floodtile = data;
17191719         break;
1720         
1720
17211721         /* attr data for MMC5 flood-fill NT mode */
17221722      case 0x1007:
17231723         switch (data & 3)
r8325r8326
17291729         case 3: state->MMC5_floodattr = 0xff; break;
17301730         }
17311731         break;
1732         
1732
17331733      case 0x1013: /* $5113 */
17341734         LOG_MMC(("MMC5 mid RAM bank select: %02x\n", data & 0x07));
17351735         // FIXME: a few Koei games have both WRAM & BWRAM but here we don't support this (yet)
r8325r8326
17381738         else
17391739            wram_bank(space->machine, data, NES_WRAM);
17401740         break;
1741         
1741
17421742      case 0x1014: /* $5114 */
17431743         LOG_MMC(("MMC5 $5114 bank select: %02x (mode: %d)\n", data, state->MMC5_rom_bank_mode));
17441744         switch (state->MMC5_rom_bank_mode)
r8325r8326
21022102            break;
21032103         }
21042104         break;
2105         
2105
21062106      case 0x1030: /* $5130 */
21072107         state->mmc5_high_chr = data & 0x03;
21082108         if (state->mmc5_vram_control == 1)
21092109         {
2110            // in this case state->mmc5_high_chr selects which 256KB of CHR ROM
2110            // in this case state->mmc5_high_chr selects which 256KB of CHR ROM
21112111            // is to be used for all background tiles on the screen.
21122112         }
21132113         break;
2114         
2115         
2114
2115
21162116      case 0x1100: /* $5200 */
21172117         state->mmc5_split_scr = data;
21182118         // in EX2 and EX3 modes, no split screen
21192119         if (state->mmc5_vram_control & 0x02)
21202120            state->mmc5_split_scr &= 0x7f;
21212121         break;
2122         
2122
21232123      case 0x1103: /* $5203 */
21242124         state->IRQ_count = data;
21252125         state->MMC5_scanline = data;
r8325r8326
21352135      case 0x1106: /* $5206 */
21362136         state->mult2 = data;
21372137         break;
2138         
2138
21392139      default:
21402140         logerror("** MMC5 uncaught write, offset: %04x, data: %02x\n", offset + 0x4100, data);
21412141         break;
r8325r8326
21432143}
21442144
21452145/*************************************************************
2146
2146
21472147 NTBROM & Sunsoft-4 board emulation
21482148
21492149 Part of this can be used also for Sunsoft Double Cassette
21502150 System... which games use it?
2151
2151
21522152 iNES: mapper 68
2153
2153
21542154 *************************************************************/
21552155
21562156static void ntbrom_mirror( running_machine *machine, int mirror, int mirr0, int mirr1 )
r8325r8326
21992199static WRITE8_HANDLER( ntbrom_w )
22002200{
22012201   nes_state *state = (nes_state *)space->machine->driver_data;
2202   
2202
22032203   LOG_MMC(("ntbrom_w, offset %04x, data: %02x\n", offset, data));
2204   
2204
22052205   switch (offset & 0x7000)
22062206   {
22072207      case 0x0000:
r8325r8326
22382238}
22392239
22402240/*************************************************************
2241
2241
22422242 JxROM & Sunsoft 5A / 5B / FME7 board emulation
2243 
2244 Notice that Sunsoft-5B = FME7 + sound chip (the latter being
2243
2244 Notice that Sunsoft-5B = FME7 + sound chip (the latter being
22452245 currently unemulated in MESS)
2246
2246
22472247 iNES: mapper 69
2248
2248
22492249 *************************************************************/
22502250
22512251/* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline,
r8325r8326
22542254static void jxrom_irq( running_device *device, int scanline, int vblank, int blanked )
22552255{
22562256   nes_state *state = (nes_state *)device->machine->driver_data;
2257   
2257
22582258   /* TODO: change to reflect the actual number of cycles spent */
22592259   if ((state->IRQ_enable & 0x80) && (state->IRQ_enable & 0x01))
22602260   {
r8325r8326
22792279{
22802280   nes_state *state = (nes_state *)space->machine->driver_data;
22812281   LOG_MMC(("jxrom_w, offset %04x, data: %02x\n", offset, data));
2282   
2282
22832283   switch (offset & 0x6000)
22842284   {
22852285      case 0x0000:
22862286         state->mmc_latch1 = data & 0x0f;
22872287         break;
2288         
2288
22892289      case 0x2000:
22902290         switch (state->mmc_latch1)
22912291         {
22922292         case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
22932293            chr1_x(space->machine, state->mmc_latch1, data, CHRROM);
22942294            break;
2295           
2295
22962296         case 8:
22972297            if (!(data & 0x40))
22982298            {
r8325r8326
23082308               memory_set_bank(space->machine, "bank5", state->prg_bank[4]);
23092309            }
23102310            break;
2311           
2311
23122312         case 9:
23132313            prg8_89(space->machine, data);
23142314            break;
r8325r8326
23382338            break;
23392339         }
23402340         break;
2341         
2341
23422342         /* Here we would have sound command for Sunsoft 5b variant */
23432343         //      case 0x4000:
23442344         //      case 0x6000:
2345         
2345
23462346      case 0x4000:
23472347         LOG_MMC(("Sunsoft-5B Sound: Register select write, data: %02x\n", data));
23482348         break;
r8325r8326
23562356}
23572357
23582358/*************************************************************
2359
2359
23602360 DxROM & Namcot 3433 - 3443 board emulation
2361 
2362 These are the same board, but DRROM (and Tengen 800004) have
2361
2362 These are the same board, but DRROM (and Tengen 800004) have
23632363 4-screen mirroring
2364
2364
23652365 iNES: mappers 88, 206 (same as 88 but possibly 4-screen mirroring)
2366
2366
23672367 *************************************************************/
23682368
23692369static WRITE8_HANDLER( dxrom_w )
r8325r8326
23972397
23982398
23992399/*************************************************************
2400
2400
24012401 Namcot 3453 board emulation
2402
2402
24032403 These are the same as Namcot 34x3, but with additional mirroring
24042404 control
2405
2405
24062406 iNES: mapper 154
2407
2407
24082408 *************************************************************/
24092409
24102410static WRITE8_HANDLER( namcot3453_w )
24112411{
24122412   LOG_MMC(("namcot3453_w, offset: %04x, data: %02x\n", offset, data));
2413   
2413
24142414   // additional mirroring control when writing to even addresses
24152415   if (!(offset & 1))
24162416      set_nt_mirroring(space->machine, BIT(data, 6) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
r8325r8326
24192419}
24202420
24212421/*************************************************************
2422
2422
24232423 Namcot 3446 board emulation
2424
2424
24252425 These are similar Namcot 34x3, but different bankswitch capabilities
2426
2426
24272427 iNES: mapper 76
2428
2428
24292429 *************************************************************/
24302430
24312431static WRITE8_HANDLER( namcot3446_w )
24322432{
24332433   nes_state *state = (nes_state *)space->machine->driver_data;
24342434   LOG_MMC(("namcot3446_w, offset: %04x, data: %02x\n", offset, data));
2435   
2435
24362436   // NEStopia does not have this!
24372437   if (offset >= 0x2000)
24382438   {
r8325r8326
24402440         set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
24412441      return;
24422442   }
2443   
2443
24442444   switch (offset & 1)
24452445   {
24462446      case 1:
r8325r8326
24612461}
24622462
24632463/*************************************************************
2464
2464
24652465 Namcot 3425 board emulation
2466 
2467 These are similar Namcot 34x3, but with NT mirroring (two
2466
2467 These are similar Namcot 34x3, but with NT mirroring (two
24682468 different modes)
2469
2469
24702470 iNES: mappers 95
2471
2471
24722472 *************************************************************/
24732473
24742474static WRITE8_HANDLER( namcot3425_w )
r8325r8326
24782478   LOG_MMC(("namcot3425_w, offset: %04x, data: %02x\n", offset, data));
24792479   if (offset >= 0x2000)
24802480      return;
2481   
2481
24822482   switch (offset & 1)
24832483   {
24842484      case 1:
r8325r8326
25142514}
25152515
25162516/*************************************************************
2517
2517
25182518 Discrete Logic board IC 74x377 by Color Dreams / Nina-007 emulation
2519 
2519
25202520 iNES: mappers 11
2521
2521
25222522 *************************************************************/
25232523
25242524static WRITE8_HANDLER( dis_74x377_w )
25252525{
25262526   nes_state *state = (nes_state *)space->machine->driver_data;
25272527   LOG_MMC(("dis_74x377_w, offset: %04x, data: %02x\n", offset, data));
2528   
2528
25292529   chr8(space->machine, data >> 4, state->mmc_chr_source);
25302530   prg32(space->machine, data & 0x0f);
25312531}
25322532
25332533/*************************************************************
2534
2534
25352535 Discrete Logic board IC 74x139x74 by Konami & Jaleco
2536
2536
25372537 iNES: mappers 87
2538
2538
25392539 *************************************************************/
25402540
25412541static WRITE8_HANDLER( dis_74x139x74_m_w )
25422542{
25432543   LOG_MMC(("dis_74x139x74_m_w, offset: %04x, data: %02x\n", offset, data));
2544   
2544
25452545   chr8(space->machine, ((data & 0x02) >> 1) | ((data & 0x01) << 1), CHRROM);
25462546}
25472547
25482548/*************************************************************
2549
2549
25502550 Discrete Logic board IC 74x161x138
2551
2551
25522552 iNES: mappers 38
2553
2553
25542554 *************************************************************/
25552555
25562556static WRITE8_HANDLER( dis_74x161x138_m_w )
25572557{
25582558   LOG_MMC(("dis_74x161x138_m_w, offset: %04x, data: %02x\n", offset, data));
2559   
2559
25602560   chr8(space->machine, data >> 2, CHRROM);
25612561   prg32(space->machine, data);
25622562}
25632563
25642564/*************************************************************
2565
2565
25662566 Discrete Logic board IC 74x161x161x32
2567
2567
25682568 There are two variants (one with hardwired mirroring, the
2569 other with a mirroring control), making necessary two distinct
2569 other with a mirroring control), making necessary two distinct
25702570 mappers & pcb_id
2571
2571
25722572 iNES: mapper 70 & 152
2573
2573
25742574 *************************************************************/
25752575
25762576static WRITE8_HANDLER( dis_74x161x161x32_w )
25772577{
25782578   nes_state *state = (nes_state *)space->machine->driver_data;
25792579   LOG_MMC(("dis_74x161x161x32_w, offset: %04x, data: %02x\n", offset, data));
2580   
2580
25812581   if (!state->hard_mirroring)   // there are two 'variants' depending on hardwired or mapper ctrl mirroring
25822582      set_nt_mirroring(space->machine, BIT(data, 7) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
25832583   chr8(space->machine, data, CHRROM);
r8325r8326
25852585}
25862586
25872587/*************************************************************
2588
2588
25892589 Bandai LZ93D50 boards emulation
2590
2590
25912591 There are several variants: plain board, board + 24C01 EEPROM,
2592 board + 24C02 EEPROM, board + Barcode Reader (DATACH).
2592 board + 24C02 EEPROM, board + Barcode Reader (DATACH).
25932593 We currently only emulate the base hardware.
2594
2594
25952595 iNES: mapper 16, 153 & 157
2596
2596
25972597 *************************************************************/
25982598
25992599/* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline,
r8325r8326
26022602static void bandai_lz_irq( running_device *device, int scanline, int vblank, int blanked )
26032603{
26042604   nes_state *state = (nes_state *)device->machine->driver_data;
2605   
2605
26062606   /* 114 is the number of cycles per scanline */
26072607   /* TODO: change to reflect the actual number of cycles spent */
26082608   if (state->IRQ_enable)
r8325r8326
26202620{
26212621   nes_state *state = (nes_state *)space->machine->driver_data;
26222622   LOG_MMC(("lz93d50_w, offset: %04x, data: %02x\n", offset, data));
2623   
2623
26242624   switch (offset & 0x000f)
26252625   {
26262626      case 0: case 1: case 2: case 3:
r8325r8326
26722672   nes_state *state = (nes_state *)machine->driver_data;
26732673   UINT8 mmc_helper = 0;
26742674   int i;
2675   
2675
26762676   for (i = 0; i < 8; i++)
26772677      mmc_helper |= ((state->mmc_reg[i] & 0x01) << 4);
2678   
2678
26792679   prg16_89ab(machine, mmc_helper | state->mmc_latch1);
26802680   prg16_cdef(machine, mmc_helper | 0x0f);
26812681}
r8325r8326
26842684{
26852685   nes_state *state = (nes_state *)space->machine->driver_data;
26862686   LOG_MMC(("fjump2_w, offset: %04x, data: %02x\n", offset, data));
2687   
2687
26882688   switch (offset & 0x000f)
26892689   {
26902690      case 0: case 1: case 2: case 3:
r8325r8326
27032703}
27042704
27052705/*************************************************************
2706
2706
27072707 Bandai Karaoke Studio board emulation
2708
2708
27092709 Note: we currently do not emulate the mic
2710
2710
27112711 iNES: mapper 188
2712
2712
27132713 *************************************************************/
27142714
27152715static WRITE8_HANDLER( bandai_ks_w )
27162716{
27172717   LOG_MMC(("bandai_ks_w, offset: %04x, data: %02x\n", offset, data));
2718   
2718
27192719   prg16_89ab(space->machine, data ^ 0x08);
27202720}
27212721
27222722/*************************************************************
2723
2723
27242724 Bandai Oeka Kids board emulation
2725
2725
27262726 Note: we currently do support the correct mirroring
2727
2727
27282728 iNES: mapper 96
2729
2729
27302730 *************************************************************/
27312731
27322732static WRITE8_HANDLER( bandai_ok_w )
r8325r8326
27442744}
27452745
27462746/*************************************************************
2747
2747
27482748 Irem Discrete board emulation (74*161/161/21/138)
2749
2749
27502750 iNES: mapper 77
2751
2751
27522752 *************************************************************/
27532753
27542754static WRITE8_HANDLER( lrog017_w )
27552755{
27562756   LOG_MMC(("lrog017_w, offset: %04x, data: %02x\n", offset, data));
2757   
2757
27582758   prg32(space->machine, data);
27592759   chr2_0(space->machine, (data >> 4), CHRROM);
27602760}
27612761
27622762/*************************************************************
2763
2763
27642764 Irem Holy Diver board emulation
2765
2765
27662766 iNES: mapper 78 (shared with JF-16)
2767
2767
27682768 *************************************************************/
27692769
27702770static WRITE8_HANDLER( irem_hd_w )
27712771{
27722772   LOG_MMC(("irem_hd_w, offset: %04x, data: %02x\n", offset, data));
2773   
2773
27742774   set_nt_mirroring(space->machine, BIT(data, 3) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
27752775   chr8(space->machine, data >> 4, CHRROM);
27762776   prg16_89ab(space->machine, data);
27772777}
27782778
27792779/*************************************************************
2780
2780
27812781 Irem TAM-S1 board emulation
2782 
2782
27832783 iNES: mapper 97
2784
2784
27852785 *************************************************************/
27862786
27872787static WRITE8_HANDLER( tam_s1_w )
27882788{
27892789   LOG_MMC(("tam_s1_w, offset: %04x, data: %02x\n", offset, data));
2790   
2790
27912791   if (offset < 0x4000)
27922792   {
27932793      set_nt_mirroring(space->machine, BIT(data, 7) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
r8325r8326
27962796}
27972797
27982798/*************************************************************
2799
2799
28002800 Irem G-101 board emulation
2801
2801
28022802 Major League uses hardwired mirroring
28032803
28042804 iNES: mapper 32
2805
2805
28062806 *************************************************************/
28072807
28082808static WRITE8_HANDLER( g101_w )
28092809{
28102810   nes_state *state = (nes_state *)space->machine->driver_data;
28112811   LOG_MMC(("g101_w, offset: %04x, data: %02x\n", offset, data));
2812   
2812
28132813   switch (offset & 0x7000)
28142814   {
28152815      case 0x0000:
r8325r8326
28312831}
28322832
28332833/*************************************************************
2834
2834
28352835 Irem H-3001 board emulation
2836
2836
28372837 iNES: mapper 65
2838
2838
28392839 *************************************************************/
28402840
28412841/* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline,
r8325r8326
28472847   if (state->IRQ_enable)
28482848   {
28492849      state->IRQ_count -= 114;
2850     
2850
28512851      if (state->IRQ_count <= 114)
28522852      {
28532853         state->IRQ_enable = 0;
r8325r8326
28602860{
28612861   nes_state *state = (nes_state *)space->machine->driver_data;
28622862   LOG_MMC(("h3001_w, offset %04x, data: %02x\n", offset, data));
2863   
2863
28642864   switch (offset & 0x7fff)
28652865   {
28662866      case 0x0000:
28672867         prg8_89(space->machine, data);
28682868         break;
2869         
2869
28702870      case 0x1001:
28712871         set_nt_mirroring(space->machine, BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
28722872         break;
2873         
2873
28742874      case 0x1003:
28752875         state->IRQ_enable = data & 0x80;
28762876         break;
2877         
2877
28782878      case 0x1004:
28792879         state->IRQ_count = state->IRQ_count_latch;
28802880         break;
2881         
2881
28822882      case 0x1005:
28832883         state->IRQ_count_latch = (state->IRQ_count_latch & 0x00ff) | (data << 8);
28842884         break;
2885         
2885
28862886      case 0x1006:
28872887         state->IRQ_count_latch = (state->IRQ_count_latch & 0xff00) | data;
28882888         break;
2889         
2889
28902890      case 0x2000:
28912891         prg8_ab(space->machine, data);
28922892         break;
2893         
2893
28942894      case 0x3000: case 0x3001: case 0x3002: case 0x3003:
28952895      case 0x3004: case 0x3005: case 0x3006: case 0x3007:
28962896         chr1_x(space->machine, offset & 0x07, data, CHRROM);
28972897         break;
2898         
2898
28992899      case 0x4000:
29002900         prg8_cd(space->machine, data);
29012901         break;
2902         
2902
29032903      default:
29042904         break;
29052905   }
29062906}
29072907
29082908/*************************************************************
2909
2909
29102910 Jaleco SS88006 board emulation, aka JF-27, JF-29, JF-30, ...,
29112911 JF-38, JF-40, JF-41
2912
2912
29132913 iNES: mapper 18
2914
2914
29152915 *************************************************************/
29162916
29172917/* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline,
r8325r8326
29202920static void ss88006_irq( running_device *device, int scanline, int vblank, int blanked )
29212921{
29222922   nes_state *state = (nes_state *)device->machine->driver_data;
2923   
2923
29242924   /* Increment & check the IRQ scanline counter */
29252925   if (state->IRQ_enable)
29262926   {
r8325r8326
29692969   nes_state *state = (nes_state *)space->machine->driver_data;
29702970   UINT8 bank;
29712971   LOG_MMC(("mapper18_w, offset: %04x, data: %02x\n", offset, data));
2972   
2972
29732973   switch (offset & 0x7003)
29742974   {
29752975      case 0x0000:
r8325r8326
29962996         state->mmc_prg_bank[2] = (state->mmc_prg_bank[2] & 0x0f) | (data << 4);
29972997         prg8_cd(space->machine, state->mmc_prg_bank[2]);
29982998         break;
2999         
2999
30003000         /* $9002, 3 (1002, 3) uncaught = Jaleco Baseball writes 0 */
30013001         /* believe it's related to battery-backed ram enable/disable */
3002         
3002
30033003      case 0x2000: case 0x2001: case 0x2002: case 0x2003:
30043004      case 0x3000: case 0x3001: case 0x3002: case 0x3003:
30053005      case 0x4000: case 0x4001: case 0x4002: case 0x4003:
r8325r8326
30093009            state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & 0x0f) | ((data & 0x0f)<< 4);
30103010         else
30113011            state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
3012         
3012
30133013         chr1_x(space->machine, bank, state->mmc_vrom_bank[bank], CHRROM);
30143014         break;
3015         
3015
30163016      case 0x6000:
30173017         state->IRQ_count_latch = (state->IRQ_count_latch & 0xfff0) | (data & 0x0f);
30183018         break;
r8325r8326
30253025      case 0x6003:
30263026         state->IRQ_count_latch = (state->IRQ_count_latch & 0x0fff) | ((data & 0x0f) << 12);
30273027         break;
3028         
3028
30293029      case 0x7000:
30303030         state->IRQ_count = state->IRQ_count_latch;
30313031         break;
r8325r8326
30333033         state->IRQ_enable = data & 0x01;
30343034         state->IRQ_mode = data & 0x0e;
30353035         break;
3036         
3036
30373037      case 0x7002:
30383038         switch (data & 0x03)
30393039         {
r8325r8326
30433043         case 3: set_nt_mirroring(space->machine, PPU_MIRROR_HIGH); break;
30443044         }
30453045         break;
3046         
3046
30473047      default:
30483048         logerror("Jaleco SS88006 uncaught write, addr: %04x, value: %02x\n", offset + 0x8000, data);
30493049         break;
r8325r8326
30513051}
30523052
30533053/*************************************************************
3054
3054
30553055 Jaleco JF-11, JF-12 & JF-14 boards emulation
3056
3056
30573057 iNES: mapper 140
3058
3058
30593059 *************************************************************/
30603060
30613061static WRITE8_HANDLER( jf11_m_w )
r8325r8326
30663066}
30673067
30683068/*************************************************************
3069
3069
30703070 Jaleco JF-13 board emulation
3071
3071
30723072 Note: we don't emulate the additional sound hardware.
30733073
30743074 iNES: mapper 86
3075
3075
30763076 *************************************************************/
30773077
30783078static WRITE8_HANDLER( jf13_m_w )
30793079{
30803080   LOG_MMC(("jf13_m_w, offset: %04x, data: %02x\n", offset, data));
3081   
3081
30823082   if (offset == 0)
30833083   {
30843084      prg32(space->machine, (data >> 4) & 0x03);
r8325r8326
30973097}
30983098
30993099/*************************************************************
3100
3100
31013101 Jaleco JF-16 board emulation
3102
3102
31033103 iNES: mapper 78 (shared with a diff Irem board)
3104
3104
31053105 *************************************************************/
31063106
31073107static WRITE8_HANDLER( jf16_w )
r8325r8326
31143114}
31153115
31163116/*************************************************************
3117
3117
31183118 Jaleco JF-17, JF-26 & JF-28 boards emulation
3119
3119
31203120 Note: we don't emulate the additional sound hardware.
31213121
31223122 iNES: mapper 72
3123
3123
31243124 *************************************************************/
31253125
31263126static WRITE8_HANDLER( jf17_w )
r8325r8326
31363136}
31373137
31383138/*************************************************************
3139
3139
31403140 Jaleco JF-19 & JF-21 boards emulation
3141
3141
31423142 Note: we don't emulate the additional sound hardware.
3143
3143
31443144 iNES: mapper 92
3145
3145
31463146 *************************************************************/
31473147
31483148static WRITE8_HANDLER( jf19_w )
r8325r8326
31583158}
31593159
31603160/*************************************************************
3161
3161
31623162 Konami VRC1 and Jaleco JF20, JF22
31633163
31643164 Games: Exciting Boxing, Ganbare Goemon!, Tetsuwan Atom
3165
3165
31663166 iNES: mapper 75
3167
3167
31683168 In MESS: Supported.
3169
3169
31703170 *************************************************************/
31713171
31723172static WRITE8_HANDLER( konami_vrc1_w )
31733173{
31743174   nes_state *state = (nes_state *)space->machine->driver_data;
31753175   LOG_MMC(("konami_vrc1_w, offset: %04x, data: %02x\n", offset, data));
3176   
3176
31773177   switch (offset & 0x7000)
31783178   {
31793179      case 0x0000:
r8325r8326
32043204}
32053205
32063206/*************************************************************
3207 
3208 Konami VRC-2
3209 
3207
3208 Konami VRC-2
3209
32103210 In MESS: Supported.
3211
3211
32123212 *************************************************************/
32133213
32143214static WRITE8_HANDLER( konami_vrc2_w )
r8325r8326
32193219                  | ((offset << (9 - state->vrc_ls_prg_a)) & 0x200)
32203220                  | ((offset << (8 - state->vrc_ls_prg_b)) & 0x100);
32213221   LOG_MMC(("konami_vrc2_w, offset: %04x, data: %02x\n", offset, data));
3222   
3222
32233223   if (offset < 0x1000)
32243224      prg8_89(space->machine, data);
32253225   else if (offset < 0x2000)
r8325r8326
32393239      bank = ((shifted_offs & 0x7000) - 0x3000) / 0x0800 + BIT(shifted_offs, 9);
32403240      shift = BIT(shifted_offs, 8) * 4;
32413241      mask = (0xf0 >> shift);
3242      state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & mask)
3242      state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & mask)
32433243                           | (((data >> state->vrc_ls_chr) & 0x0f) << shift);
32443244      chr1_x(space->machine, bank, state->mmc_vrom_bank[bank], CHRROM);
32453245   }
r8325r8326
32483248}
32493249
32503250/*************************************************************
3251
3251
32523252 Konami VRC3
32533253
32543254 Games: Salamander
3255
3255
32563256 iNES: mapper 73
3257
3257
32583258 In MESS: Supported. It also uses konami_irq.
3259
3259
32603260 *************************************************************/
32613261
32623262static WRITE8_HANDLER( konami_vrc3_w )
32633263{
32643264   LOG_MMC(("konami_vrc3_w, offset: %04x, data: %02x\n", offset, data));
32653265   nes_state *state = (nes_state *)space->machine->driver_data;
3266   
3266
32673267   switch (offset & 0x7000)
32683268   {
32693269      case 0x0000:
r8325r8326
32933293}
32943294
32953295/*************************************************************
3296
3296
32973297 Konami VRC-4
3298
3298
32993299 In MESS: Supported
3300
3300
33013301 *************************************************************/
33023302
33033303static void vrc4_set_prg( running_machine *machine )
r8325r8326
33353335                  | ((offset << (9 - state->vrc_ls_prg_a)) & 0x200)
33363336                  | ((offset << (8 - state->vrc_ls_prg_b)) & 0x100);
33373337   LOG_MMC(("konami_vrc4_w, offset: %04x, data: %02x\n", offset, data));
3338   
3338
33393339   if (offset < 0x1000)
33403340   {
33413341      state->mmc_prg_bank[0] = data;
r8325r8326
34083408}
34093409
34103410/*************************************************************
3411
3411
34123412 Konami VRC-6
3413
3413
34143414 In MESS: Supported. It also uses konami_irq (there are IRQ
34153415 issues though: see Akumajou Densetsu intro).
3416
3416
34173417 *************************************************************/
34183418
34193419static WRITE8_HANDLER( konami_vrc6_w )
r8325r8326
34243424                  | ((offset << (9 - state->vrc_ls_prg_a)) & 0x200)
34253425                  | ((offset << (8 - state->vrc_ls_prg_b)) & 0x100);
34263426   LOG_MMC(("konami_vrc6_w, offset: %04x, data: %02x\n", offset, data));
3427   
3427
34283428   if (offset < 0x1000)
34293429      prg16_89ab(space->machine, data);
34303430   else if (offset >= 0x4000 && offset < 0x5000)
r8325r8326
34853485}
34863486
34873487/*************************************************************
3488
3488
34893489 Konami VRC7
34903490
34913491 Games: Lagrange Point, Tiny Toon Adventures 2
3492
3492
34933493 iNES: mapper 85
3494
3494
34953495 In MESS: Supported. It also uses konami_irq.
3496
3496
34973497 *************************************************************/
34983498
34993499static WRITE8_HANDLER( konami_vrc7_w )
r8325r8326
35013501   nes_state *state = (nes_state *)space->machine->driver_data;
35023502   UINT8 bank;
35033503   LOG_MMC(("konami_vrc7_w, offset: %04x, data: %02x\n", offset, data));
3504   
3504
35053505   switch (offset & 0x7018)
35063506   {
35073507      case 0x0000:
r8325r8326
35123512      case 0x0018:
35133513         prg8_ab(space->machine, data);
35143514         break;
3515         
3515
35163516      case 0x1000:
35173517         prg8_cd(space->machine, data);
35183518         break;
3519         
3519
35203520         /* TODO: there are sound regs in here */
3521         
3521
35223522      case 0x2000:
35233523      case 0x2008:
35243524      case 0x2010:
r8325r8326
35383538         bank = ((offset & 0x7000) - 0x2000) / 0x0800 + ((offset & 0x0018) ? 1 : 0);
35393539         chr1_x(space->machine, bank, data, state->mmc_chr_source);
35403540         break;
3541         
3541
35423542      case 0x6000:
35433543         switch (data & 0x03)
35443544         {
r8325r8326
35613561      case 0x7008: case 0x7010: case 0x7018:
35623562         state->IRQ_enable = state->IRQ_enable_latch;
35633563         break;
3564         
3564
35653565      default:
35663566         logerror("konami_vrc7_w uncaught write, addr: %04x value: %02x\n", offset + 0x8000, data);
35673567         break;
r8325r8326
35693569}
35703570
35713571/*************************************************************
3572
3572
35733573 Namcot-163 board emulation
3574
3574
35753575 iNES: mapper 19
3576
3576
35773577 *************************************************************/
35783578
35793579/* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline,
r8325r8326
35823582static void namcot163_irq( running_device *device, int scanline, int vblank, int blanked )
35833583{
35843584   nes_state *state = (nes_state *)device->machine->driver_data;
3585   
3585
35863586   if (state->IRQ_enable)
35873587   {
35883588      if (state->IRQ_count >= (0x7fff - 114))
r8325r8326
36003600   nes_state *state = (nes_state *)space->machine->driver_data;
36013601   LOG_MMC(("namcot163_l_w, offset: %04x, data: %02x\n", offset, data));
36023602   offset += 0x100;
3603   
3603
36043604   switch (offset & 0x1800)
36053605   {
36063606      case 0x0800:
r8325r8326
36213621   nes_state *state = (nes_state *)space->machine->driver_data;
36223622   LOG_MMC(("namcot163_l_r, offset: %04x\n", offset));
36233623   offset += 0x100;
3624   
3624
36253625   switch (offset & 0x1800)
36263626   {
36273627      case 0x1000:
r8325r8326
36843684}
36853685
36863686/*************************************************************
3687
3687
36883688 Sunsoft-1 board emulation
3689 
3690 iNES: mapper 184 (Fantasy Zone uses this board with no
3689
3690 iNES: mapper 184 (Fantasy Zone uses this board with no
36913691 CHRROM, and the register switches PRG banks)
3692
3692
36933693 *************************************************************/
36943694
36953695static WRITE8_HANDLER( sunsoft1_m_w )
36963696{
36973697   nes_state *state = (nes_state *)space->machine->driver_data;
36983698   LOG_MMC(("sunsoft1_m_w, offset: %04x, data: %02x\n", offset, data));
3699   
3699
37003700   if (state->chr_chunks)
37013701   {
37023702      chr4_0(space->machine, data & 0x0f, CHRROM);
r8325r8326
37073707}
37083708
37093709/*************************************************************
3710
3710
37113711 Sunsoft-2 board emulation
3712
3712
37133713 The two games using this board have incompatible mirroring
37143714 wiring, making necessary two distinct mappers & pcb_id
3715
3715
37163716 iNES: mapper 89 & 93
3717
3717
37183718 *************************************************************/
37193719
37203720static WRITE8_HANDLER( sunsoft2_w )
r8325r8326
37323732}
37333733
37343734/*************************************************************
3735
3735
37363736 Sunsoft-3 board emulation
3737
3737
37383738 The two games using this board have incompatible mirroring
37393739 wiring, making necessary two distinct mappers & pcb_id
3740
3740
37413741 iNES: mapper 67
3742
3742
37433743 *************************************************************/
37443744
37453745/* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline,
r8325r8326
37483748static void sunsoft3_irq( running_device *device, int scanline, int vblank, int blanked )
37493749{
37503750   nes_state *state = (nes_state *)device->machine->driver_data;
3751   
3751
37523752   /* TODO: change to reflect the actual number of cycles spent: both using 114 or cycling 114,114,113
3753    produces a 1-line glitch in Fantasy Zone 2: it really requires the counter to be updated each CPU cycle! */
3753    produces a 1-line glitch in Fantasy Zone 2: it really requires the counter to be updated each CPU cycle! */
37543754   if (state->IRQ_enable)
37553755   {
37563756      if (state->IRQ_count <= 114)
r8325r8326
37683768{
37693769   nes_state *state = (nes_state *)space->machine->driver_data;
37703770   LOG_MMC(("sunsoft3_w, offset %04x, data: %02x\n", offset, data));
3771   
3771
37723772   switch (offset & 0x7800)
37733773   {
37743774      case 0x0800:
r8325r8326
38143814}
38153815
38163816/*************************************************************
3817
3817
38183818 Taito TC0190FMC + board emulation
3819
3819
38203820 iNES: mapper 33
3821
3821
38223822 *************************************************************/
38233823
38243824static WRITE8_HANDLER( tc0190fmc_w )
38253825{
38263826   LOG_MMC(("tc0190fmc_w, offset: %04x, data: %02x\n", offset, data));
3827   
3827
38283828   switch (offset & 0x7003)
38293829   {
38303830      case 0x0000:
r8325r8326
38563856}
38573857
38583858/*************************************************************
3859
3859
38603860 Taito TC0190FMC + PAL16R4 board emulation
3861
3861
38623862 iNES: mapper 48
3863
3863
38643864 *************************************************************/
38653865
38663866static WRITE8_HANDLER( tc0190fmc_p16_w )
38673867{
38683868   nes_state *state = (nes_state *)space->machine->driver_data;
38693869   LOG_MMC(("tc0190fmc_p16_w, offset: %04x, data: %02x\n", offset, data));
3870   
3870
38713871   switch (offset & 0x7003)
38723872   {
38733873      case 0x0000:
r8325r8326
39013901}
39023902
39033903/*************************************************************
3904
3904
39053905 Taito X1-005 board emulation
3906
3906
39073907 Actually, Fudou Myouou Den uses a variant of the board with
39083908 CIRAM, making necessary two distinct mappers & pcb_id.
3909
3909
39103910 Also, we miss to emulate the security check at 0x7ef8 / 0x7ef9
39113911 and the 0x80 ram!
3912
3912
39133913 iNES: mappers 80 & 207
3914
3914
39153915 *************************************************************/
39163916
39173917static WRITE8_HANDLER( x1005_m_w )
39183918{
39193919   nes_state *state = (nes_state *)space->machine->driver_data;
39203920   LOG_MMC(("x1005_m_w, offset: %04x, data: %02x\n", offset, data));
3921   
3921
39223922   switch (offset)
39233923   {
39243924      case 0x1ef0:
r8325r8326
39823982static WRITE8_HANDLER( x1005a_m_w )
39833983{
39843984   LOG_MMC(("x1005a_m_w, offset: %04x, data: %02x\n", offset, data));
3985   
3985
39863986   // similar to x1005_m_w but mirroring is handled differently
39873987   if (offset == 0x1ef6 || offset == 0x1ef7)
39883988      return;
r8325r8326
40034003}
40044004
40054005/*************************************************************
4006
4006
40074007 Taito X1-017 board emulation
4008 
4008
40094009 We miss to emulate the security check at 0x6000-0x73ff
40104010 and the ram!
4011
4011
40124012 iNES: mapper 82
4013
4013
40144014 *************************************************************/
40154015
40164016static void x1017_set_chr( running_machine *machine )
r8325r8326
40304030   chr1_x(machine, 5 ^ state->mmc_latch1, state->mmc_vrom_bank[3], CHRROM);
40314031   chr1_x(machine, 6 ^ state->mmc_latch1, state->mmc_vrom_bank[4], CHRROM);
40324032   chr1_x(machine, 7 ^ state->mmc_latch1, state->mmc_vrom_bank[5], CHRROM);
4033}   
4033}
40344034
40354035static WRITE8_HANDLER( x1017_m_w )
40364036{
40374037   nes_state *state = (nes_state *)space->machine->driver_data;
40384038   UINT8 reg = offset & 0x07;
40394039   LOG_MMC(("x1017_m_w, offset: %04x, data: %02x\n", offset, data));
4040   
4040
40414041   switch (offset)
40424042   {
40434043      case 0x1ef0:
r8325r8326
40954095      return state->mapper_ram[offset & (state->mapper_ram_size - 1)];
40964096   if (offset < 0x1800 && state->mapper_ram != NULL && state->mmc_reg[2] == 0x84)
40974097      return state->mapper_ram[offset & (state->mapper_ram_size - 1)];
4098   
4098
40994099   return 0xff;
41004100}
41014101
41024102/*************************************************************
4103
4103
41044104      MISC UNLICENSED BOARDS
4105
4105
41064106 *************************************************************/
41074107
41084108/*************************************************************
4109
4109
41104110 AGCI 50282 bootleg board emulation
4111
4111
41124112 iNES: mapper 144
4113
4113
41144114 *************************************************************/
41154115
41164116static WRITE8_HANDLER( agci_50282_w )
41174117{
41184118   LOG_MMC(("agci_50282_w, offset: %04x, data: %02x\n", offset, data));
4119   
4119
41204120   offset += 0x8000;
41214121   data |= (memory_read_byte(space, offset) & 1);
4122   
4122
41234123   chr8(space->machine, data >> 4, CHRROM);
41244124   prg32(space->machine, data);
41254125}
41264126
41274127/*************************************************************
4128
4128
41294129 AVE NINA-001 board emulation
4130
4130
41314131 iNES: mapper 34
4132
4132
41334133 *************************************************************/
41344134
41354135static WRITE8_HANDLER( nina01_m_w )
41364136{
41374137   LOG_MMC(("nina01_m_w, offset: %04x, data: %02x\n", offset, data));
4138   
4138
41394139   switch (offset)
41404140   {
41414141      case 0x1ffd:
r8325r8326
41514151}
41524152
41534153/*************************************************************
4154
4154
41554155 AVE NINA-003, NINA-006 and MB-91 boards emulation
4156
4156
41574157 iNES: mapper 79
4158
4158
41594159 *************************************************************/
41604160
41614161static WRITE8_HANDLER( nina06_l_w )
41624162{
41634163   LOG_MMC(("nina06_l_w, offset: %04x, data: %02x\n", offset, data));
4164   
4164
41654165   if (!(offset & 0x0100))
41664166   {
41674167      prg32(space->machine, data >> 3);
r8325r8326
41704170}
41714171
41724172/*************************************************************
4173
4173
41744174 Active Entertainment Action 52 board emulation
4175
4175
41764176 iNES: mapper 228
4177
4177
41784178 *************************************************************/
41794179
41804180static WRITE8_HANDLER( ae_act52_w )
r8325r8326
41824182   int pbank, cbank;
41834183   UINT8 pmode;
41844184   LOG_MMC(("ae_act52_w, offset: %04x, data: %02x\n", offset, data));
4185   
4185
41864186   set_nt_mirroring(space->machine, BIT(offset, 13) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4187   
4187
41884188   cbank = (data & 0x03) | ((offset & 0x0f) << 2);
41894189   chr8(space->machine, cbank, CHRROM);
4190   
4190
41914191   pmode = offset & 0x20;
41924192   pbank = (offset & 0x1fc0) >> 6;
41934193   if (pmode)
r8325r8326
42014201
42024202
42034203/*************************************************************
4204
4204
42054205 C & E Bootleg Board for Decathlon
4206
4206
42074207 Games: Decathlon
4208
4208
42094209 Pretty simple mapper: writes to 0x8065-0x80a4 set prg32 to
42104210 data & 3; writes to 0x80a5-0x80e4 set chr8 to data & 7
4211
4211
42124212 iNES: mapper 244
4213
4213
42144214 In MESS: Supported.
4215
4215
42164216 *************************************************************/
42174217
42184218static WRITE8_HANDLER( cne_decathl_w )
42194219{
42204220   LOG_MMC(("cne_decathl_w, offset: %04x, data: %02x\n", offset, data));
4221   
4221
42224222   if (offset < 0x0065)
42234223      return;
42244224   if (offset < 0x00a5)
r8325r8326
42334233}
42344234
42354235/*************************************************************
4236
4236
42374237 C & E Bootleg Board for Fong Shen Bang
4238
4238
42394239 Games: Fong Shen Bang - Zhu Lu Zhi Zhan
4240
4240
42414241 Simple mapper: writes to 0x6000-0x67ff set PRG and CHR banks.
42424242 Namely, 0x6000->0x6003 select resp. prg8_89, prg8_ab, prg8_cd
42434243 and prg8_ef. 0x6004->0x6007 select resp. crh2_0, chr2_2,
42444244 chr2_4 and chr2_6. In 0x6800-0x7fff lies WRAM.
4245
4245
42464246 iNES: mapper 246
4247
4247
42484248 In MESS: Supported.
4249
4249
42504250 *************************************************************/
42514251
42524252static WRITE8_HANDLER( cne_fsb_m_w )
42534253{
42544254   nes_state *state = (nes_state *)space->machine->driver_data;
42554255   LOG_MMC(("cne_fsb_m_w, offset: %04x, data: %02x\n", offset, data));
4256   
4256
42574257   if (offset < 0x0800)
42584258   {
42594259      switch (offset & 0x0007)
r8325r8326
42894289}
42904290
42914291/*************************************************************
4292
4292
42934293 C & E Bootleg Board for Sheng Huo Lie Zhuan
4294
4294
42954295 Games: Jing Ke Xin Zhuan, Sheng Huo Lie Zhuan
4296
4296
42974297 Simple Mapper: writes to 0x4020-0x5fff sets prg32 to
42984298 data>>4 and chr8 to data&f. We currently do not map
42994299 writes to 0x4020-0x40ff (to do: verify if this produces
43004300 issues)
4301
4301
43024302 iNES: mapper 240
4303
4303
43044304 In MESS: Supported.
4305
4305
43064306 *************************************************************/
43074307
43084308static WRITE8_HANDLER( cne_shlz_l_w )
43094309{
43104310   LOG_MMC(("cne_shlz_l_w, offset: %04x, data: %02x\n", offset, data));
4311   
4311
43124312   prg32(space->machine, data >> 4);
43134313   chr8(space->machine, data & 0x0f, CHRROM);
43144314}
43154315
43164316/*************************************************************
4317
4317
43184318 Caltron 6 in 1 Board
43194319
43204320 Games: 6 in 1 by Caltron
4321
4321
43224322 iNES: mapper 41
4323
4323
43244324 In MESS: Supported.
4325
4325
43264326 *************************************************************/
43274327
43284328static WRITE8_HANDLER( caltron6in1_m_w )
43294329{
43304330   nes_state *state = (nes_state *)space->machine->driver_data;
43314331   LOG_MMC(("caltron6in1_m_w, offset: %04x, data: %02x\n", offset, data));
4332   
4332
43334333   state->mmc_latch1 = offset & 0xff;
43344334   set_nt_mirroring(space->machine, BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
43354335   prg32(space->machine, offset & 0x07);
r8325r8326
43394339{
43404340   nes_state *state = (nes_state *)space->machine->driver_data;
43414341   LOG_MMC(("caltron6in1_w, offset: %04x, data: %02x\n", offset, data));
4342   
4342
43434343   if (state->mmc_latch1 & 0x04)
43444344      chr8(space->machine, ((state->mmc_latch1 & 0x18) >> 1) | (data & 0x03), CHRROM);
43454345}
43464346
43474347/*************************************************************
4348
4348
43494349 Camerica Boards (BF9093, BF9097, BF909X, ALGNV11)
43504350
43514351 Games: Linus Spacehead's Cosmic Crusade, Micro Machines,
43524352 Mig-29, Stunt Kids
4353
4353
43544354 To emulate NT mirroring for BF9097 board (missing in BF9093)
43554355 we use crc_hack, however Fire Hawk is broken (but without
43564356 mirroring there would be no helicopter graphics).
4357
4357
43584358 iNES: mapper 71
4359
4359
43604360 In MESS: Partially Supported.
4361
4361
43624362 *************************************************************/
43634363
43644364static WRITE8_HANDLER( bf9093_w )
43654365{
43664366   nes_state *state = (nes_state *)space->machine->driver_data;
43674367   LOG_MMC(("bf9093_w, offset: %04x, data: %02x\n", offset, data));
4368   
4368
43694369   switch (offset & 0x7000)
43704370   {
43714371      case 0x0000:
r8325r8326
43834383}
43844384
43854385/*************************************************************
4386
4386
43874387 Camerica BF9096 & ALGQV11 Boards
43884388
43894389 Games: Quattro Adventure, Quattro Arcade, Quattro Sports
4390
4390
43914391 Writes to 0x8000-0x9fff set prg block to (data&0x18)>>1,
43924392 writes to 0xa000-0xbfff set prg page to data&3. selected
43934393 prg are: prg16_89ab = block|page, prg_cdef = 3|page.
43944394 For more info on the hardware to bypass the NES lockout, see
43954395 Kevtris' Camerica Mappers documentation.
4396
4396
43974397 iNES: mapper 232
4398
4398
43994399 In MESS: Supported.
4400
4400
44014401 *************************************************************/
44024402
44034403static void bf9096_set_prg( running_machine *machine )
r8325r8326
44114411{
44124412   nes_state *state = (nes_state *)space->machine->driver_data;
44134413   LOG_MMC(("bf9096_w, offset: %04x, data: %02x\n", offset, data));
4414   
4414
44154415   if (offset < 0x2000)
44164416      state->mmc_latch1 = data;
44174417   else
44184418      state->mmc_latch2 = data;
4419   
4419
44204420   bf9096_set_prg(space->machine);
44214421}
44224422
44234423/*************************************************************
4424
4424
44254425 Camerica Golden Five board
44264426
44274427 Games: Pegasus 5 in 1
4428
4428
44294429 iNES: mapper 104
4430
4430
44314431 In MESS: Supported.
4432
4432
44334433 *************************************************************/
44344434
44354435static WRITE8_HANDLER( golden5_w )
44364436{
44374437   nes_state *state = (nes_state *)space->machine->driver_data;
44384438   LOG_MMC(("golden5_w, offset: %04x, data: %02x\n", offset, data));
4439   
4439
44404440   if (offset < 0x4000)
44414441   {
44424442      if (data & 0x08)
r8325r8326
44454445         prg16_89ab(space->machine, state->mmc_prg_bank[0]);
44464446         prg16_cdef(space->machine, ((data & 0x07) << 4) | 0x0f);
44474447      }
4448     
4448
44494449   }
44504450   else
44514451   {
r8325r8326
44554455}
44564456
44574457/*************************************************************
4458
4458
44594459 Cony Bootleg Board
44604460
44614461 Games: Dragon Ball Party, Fatal Fury 2, Street Blaster II
44624462 Pro, World Heroes 2
4463
4463
44644464 iNES: mapper 83
4465
4465
44664466 In MESS: Supported.
4467
4467
44684468 *************************************************************/
44694469
44704470static WRITE8_HANDLER( cony_l_w )
r8325r8326
45964596}
45974597
45984598/*************************************************************
4599
4599
46004600 Board DREAMTECH01
4601
4601
46024602 Games: Korean Igo
4603
4603
46044604 In MESS: Supported
4605
4605
46064606 *************************************************************/
46074607
46084608static WRITE8_HANDLER( dreamtech_l_w )
46094609{
46104610   LOG_MMC(("dreamtech_l_w offset: %04x, data: %02x\n", offset, data));
46114611   offset += 0x100;
4612   
4612
46134613   if (offset == 0x1020)   /* 0x5020 */
46144614      prg16_89ab(space->machine, data);
46154615}
46164616
46174617/*************************************************************
4618
4618
46194619 Bootleg Board by Future Media
46204620
46214621 Games: Crayon Shin-chan (C), San Guo Zhi 4 - Chi Bi Feng Yun
4622
4622
46234623 iNES: mapper 117
4624
4624
46254625 In MESS: Unsupported.
4626
4626
46274627 *************************************************************/
46284628
46294629static void futuremedia_irq( running_device *device, int scanline, int vblank, int blanked )
r8325r8326
46444644{
46454645   nes_state *state = (nes_state *)space->machine->driver_data;
46464646   LOG_MMC(("futuremedia_w, offset: %04x, data: %02x\n", offset, data));
4647   
4647
46484648   switch (offset)
46494649   {
46504650      case 0x0000:
r8325r8326
46694669      case 0x2007:
46704670         chr1_x(space->machine, offset & 0x07, data, CHRROM);
46714671         break;
4672         
4672
46734673      case 0x5000:
46744674         set_nt_mirroring(space->machine, BIT(data, 0) ?  PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
46754675         break;
4676         
4676
46774677      case 0x4001:
46784678         state->IRQ_count_latch = data;
46794679         break;
r8325r8326
46904690}
46914691
46924692/*************************************************************
4693
4693
46944694 Bootleg Board 37017 (?) by Gouder
46954695
46964696 Games: Street Fighter IV
4697
4697
46984698 MMC3 clone. It also requires reads from 0x5000-0x7fff.
4699
4699
47004700 iNES: mapper 208
4701
4701
47024702 In MESS: Preliminary Support.
4703
4703
47044704 *************************************************************/
47054705
47064706static WRITE8_HANDLER( gouder_sf4_l_w )
r8325r8326
47254725      0x01,0x11,0x41,0x51,0x01,0x11,0x41,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
47264726      0x09,0x19,0x49,0x59,0x09,0x19,0x49,0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
47274727   };
4728   
4728
47294729   LOG_MMC(("gouder_sf4_l_w, offset: %04x, data: %02x\n", offset, data));
4730   
4730
47314731   if (!(offset < 0x1700))
47324732      state->map208_reg[offset & 0x03] = data ^ conv_table[state->map208_reg[4]];
47334733   else if (!(offset < 0xf00))
r8325r8326
47404740{
47414741   nes_state *state = (nes_state *)space->machine->driver_data;
47424742   LOG_MMC(("gouder_sf4_l_r, offset: %04x\n", offset));
4743   
4743
47444744   if (!(offset < 0x1700))
47454745      return state->map208_reg[offset & 0x03];
4746   
4746
47474747   return 0x00;
47484748}
47494749
r8325r8326
47544754   nes_state *state = (nes_state *)space->machine->driver_data;
47554755   UINT8 MMC3_helper, cmd;
47564756   LOG_MMC(("gouder_sf4_w, offset: %04x, data: %02x\n", offset, data));
4757   
4757
47584758   switch (offset & 0x6001)
47594759   {
47604760      case 0x0000:
47614761         MMC3_helper = state->mmc_latch1 ^ data;
47624762         state->mmc_latch1 = data;
4763         
4763
47644764         /* Has CHR Mode changed? */
47654765         if (MMC3_helper & 0x80)
47664766            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
47674767         break;
4768         
4768
47694769      case 0x0001:
47704770         cmd = state->mmc_latch1 & 0x07;
47714771         switch (cmd)
r8325r8326
47774777            break;
47784778         }
47794779         break;
4780         
4780
47814781      default:
47824782         txrom_w(space, offset, data);
47834783         break;
r8325r8326
47854785}
47864786
47874787/*************************************************************
4788
4788
47894789 Bootleg Board by Henggedianzi
47904790
47914791 Games: Mei Guo Fu Hao, Shang Gu Shen Jian , Wang Zi Fu
47924792 Chou Ji
4793
4793
47944794 Writes to 0x8000-0xffff set prg32. Moreover, data&0x20 sets
47954795 NT mirroring.
4796
4796
47974797 iNES: mapper 177
4798
4798
47994799 In MESS: Supported.
4800
4800
48014801 *************************************************************/
48024802
48034803static WRITE8_HANDLER( henggedianzi_w )
48044804{
48054805   LOG_MMC(("henggedianzi_w, offset: %04x, data: %02x\n", offset, data));
4806   
4806
48074807   prg32(space->machine, data);
48084808   set_nt_mirroring(space->machine, BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
48094809}
48104810
48114811/*************************************************************
4812
4812
48134813 Bootleg Board by Henggedianzi
4814
4814
48154815 Games: Xing He Zhan Shi
4816
4816
48174817 Writes to 0x5000-0x5fff set prg32 banks, writes to 0x8000-
48184818 0xffff set NT mirroring
4819
4819
48204820 iNES: mapper 179
4821
4821
48224822 In MESS: Supported.
4823
4823
48244824 *************************************************************/
48254825
48264826static WRITE8_HANDLER( heng_xjzb_l_w )
48274827{
48284828   LOG_MMC(("heng_xjzb_l_w, offset: %04x, data: %02x\n", offset, data));
48294829   offset += 0x4100;
4830   
4830
48314831   if (offset & 0x5000)
48324832      prg32(space->machine, data >> 1);
48334833}
r8325r8326
48354835static WRITE8_HANDLER( heng_xjzb_w )
48364836{
48374837   LOG_MMC(("heng_xjzb_w, offset: %04x, data: %02x\n", offset, data));
4838   
4838
48394839   set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
48404840}
48414841
48424842/*************************************************************
4843
4843
48444844 Bootleg Board by HES (also used by others)
48454845
48464846 Games: AV Hanafuda Club, AV Soccer, Papillon, Sidewinder,
48474847 Total Funpack
4848
4848
48494849 Actually, two variant: one for HES 6-in-1 with mirroring control
48504850 and one for AV Soccer and others with hardwired mirroring
48514851
48524852 iNES: mapper 113
4853
4853
48544854 In MESS: Supported.
4855
4855
48564856 *************************************************************/
48574857
48584858static WRITE8_HANDLER( hes6in1_l_w )
48594859{
48604860   LOG_MMC(("hes6in1_l_w, offset: %04x, data: %02x\n", offset, data));
4861   
4861
48624862   if (!(offset & 0x100))
48634863   {
48644864      prg32(space->machine, (data & 0x38) >> 3);
r8325r8326
48704870static WRITE8_HANDLER( hes_l_w )
48714871{
48724872   LOG_MMC(("hes_l_w, offset: %04x, data: %02x\n", offset, data));
4873   
4873
48744874   if (!(offset & 0x100))
48754875   {
48764876      prg32(space->machine, (data & 0x38) >> 3);
r8325r8326
48794879}
48804880
48814881/*************************************************************
4882
4882
48834883 Bootleg Board by Hosenkan
48844884
48854885 Games: Pocahontas, Super Donkey Kong
4886
4886
48874887 iNES: mapper 182
4888
4888
48894889 In MESS: Supported.
4890
4890
48914891 *************************************************************/
48924892
48934893static WRITE8_HANDLER( hosenkan_w )
48944894{
48954895   nes_state *state = (nes_state *)space->machine->driver_data;
48964896   LOG_MMC(("hosenkan_w, offset: %04x, data: %02x\n", offset, data));
4897   
4897
48984898   switch (offset & 0x7003)
48994899   {
49004900      case 0x0001:
r8325r8326
49454945}
49464946
49474947/*************************************************************
4948
4948
49494949 Bootleg Board by Kaiser (KS7058)
49504950
49514951 Games: Tui Do Woo Ma Jeung
4952
4952
49534953 Writes to 0xf000-0xffff set 4k chr banks. Namely, if
49544954 offset&0x80 is 0 the lower 4k are set, if it is 1 the
49554955 upper 4k are set.
4956
4956
49574957 iNES: mapper 171
4958
4958
49594959 In MESS: Supported.
4960
4960
49614961 *************************************************************/
49624962
49634963static WRITE8_HANDLER( ks7058_w )
49644964{
49654965   LOG_MMC(("ks7058_w, offset: %04x, data: %02x\n", offset, data));
4966   
4966
49674967   switch (offset & 0x7080)
49684968   {
49694969      case 0x7000:
r8325r8326
49764976}
49774977
49784978/*************************************************************
4979
4979
49804980 Bootleg Board by Kay (for Panda Prince)
49814981
49824982 Games: The Panda Prince
4983
4983
49844984 MMC3 clone
4985
4985
49864986 iNES: mapper 121
4987 
4988 In MESS: Only preliminarly supported (Panda Prince works,
4987
4988 In MESS: Only preliminarly supported (Panda Prince works,
49894989 other games require handling properly the protection).
4990 
4990
49914991 *************************************************************/
49924992
49934993static WRITE8_HANDLER( kay_pp_l_w )
r8325r8326
49954995   nes_state *state = (nes_state *)space->machine->driver_data;
49964996   LOG_MMC(("kay_pp_l_w, offset: %04x, data: %02x\n", offset, data));
49974997   offset += 0x100;
4998   
4998
49994999   if (!(offset < 0x1000))
50005000   {
50015001      switch (data & 0x03)
r8325r8326
50195019   nes_state *state = (nes_state *)space->machine->driver_data;
50205020   LOG_MMC(("kay_pp_l_r, offset: %04x\n", offset));
50215021   offset += 0x100;
5022   
5022
50235023   if (!(offset < 0x1000))
50245024      return state->mapper121_reg[2];
50255025   else
r8325r8326
50365036      case 0x29:
50375037      case 0x2b:
50385038      case 0x3f:
5039//         printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
5039//          printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
50405040         state->mapper121_reg[1] = state->mapper121_reg[3];
50415041         break;
50425042      case 0x2c:
5043//         printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
5043//          printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
50445044         state->mapper121_reg[1] = state->mapper121_reg[3];
50455045         break;
5046         
5046
50475047      case 0x28:
5048//         printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
5048//          printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
50495049         state->mapper121_reg[0] = state->mapper121_reg[3];
50505050         break;
5051         
5051
50525052      case 0x2a:
5053//         printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
5053//          printf("reg (%x) %x \n", data, state->mapper121_reg[3]);
50545054         state->mapper121_reg[4] = state->mapper121_reg[3];
50555055         break;
5056         
5056
50575057      case 0x2f:
50585058         break;
50595059
r8325r8326
50705070   nes_state *state = (nes_state *)machine->driver_data;
50715071   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
50725072   UINT8 new_bank1, new_bank2, new_bank3;
5073   
5073
50745074   new_bank2 = state->mapper121_reg[0] ? state->mapper121_reg[0] : state->mmc_prg_bank[2 ^ prg_flip];
50755075   new_bank3 = state->mapper121_reg[1] ? state->mapper121_reg[1] : state->mmc_prg_bank[3];
50765076   new_bank1 = state->mapper121_reg[4] ? state->mapper121_reg[4] : state->mmc_prg_bank[1];
5077   
5077
50785078   prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
50795079   prg8_ab(machine, prg_base | (new_bank1 & prg_mask));
50805080   prg8_cd(machine, prg_base | (new_bank2 & prg_mask));
r8325r8326
50865086   nes_state *state = (nes_state *)space->machine->driver_data;
50875087   UINT8 MMC3_helper, cmd;
50885088   LOG_MMC(("kay_pp_w, offset: %04x, data: %02x\n", offset, data));
5089   
5089
50905090   if ((offset < 0x2000) && (offset & 0x03) == 0x03)
50915091   {
50925092      kay_pp_update_regs(space->machine, data);
r8325r8326
50995099         case 0x0000:
51005100            MMC3_helper = state->mmc_latch1 ^ data;
51015101            state->mmc_latch1 = data;
5102           
5102
51035103            /* Has PRG Mode changed? */
51045104            if (MMC3_helper & 0x40)
51055105               kay_pp_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
5106           
5106
51075107            /* Has CHR Mode changed? */
51085108            if (MMC3_helper & 0x80)
51095109               mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
51105110            break;
5111           
5111
51125112         case 0x0001:
5113            state->mapper121_reg[3] = (BIT(data, 0) << 5) | (BIT(data, 1) << 4) | (BIT(data, 2) << 3)
5113            state->mapper121_reg[3] = (BIT(data, 0) << 5) | (BIT(data, 1) << 4) | (BIT(data, 2) << 3)
51145114                              | (BIT(data, 3) << 2) | (BIT(data, 4) << 1) | BIT(data, 5);
51155115            cmd = state->mmc_latch1 & 0x07;
51165116            switch (cmd)
r8325r8326
51275127               break;
51285128            }
51295129            break;
5130           
5130
51315131         default:
51325132            txrom_w(space, offset, data);
51335133            break;
r8325r8326
51375137
51385138
51395139/*************************************************************
5140
5140
51415141 Bootleg Board by Kasing
51425142
51435143 Games: AV Jiu Ji Mahjong, Bao Qing Tian, Thunderbolt 2,
51445144 Shisen Mahjong 2
5145
5145
51465146 MMC3 clone
5147
5147
51485148 iNES: mapper 115
5149
5149
51505150 In MESS: Supported
5151
5151
51525152 *************************************************************/
51535153
51545154static void kasing_set_prg( running_machine *machine, int prg_base, int prg_mask  )
r8325r8326
51645164{
51655165   nes_state *state = (nes_state *)space->machine->driver_data;
51665166   LOG_MMC(("kasing_m_w, offset: %04x, data: %02x\n", offset, data));
5167   
5167
51685168   switch (offset & 0x01)
51695169   {
51705170      case 0x00:
r8325r8326
51835183   nes_state *state = (nes_state *)space->machine->driver_data;
51845184   UINT8 map115_helper, cmd;
51855185   LOG_MMC(("kasing_w, offset: %04x, data: %02x\n", offset, data));
5186   
5186
51875187   switch (offset & 0x6001)
51885188   {
51895189      case 0x0000:
51905190         map115_helper = state->mmc_latch1 ^ data;
51915191         state->mmc_latch1 = data;
5192         
5192
51935193         /* Has PRG Mode changed? */
51945194         if (map115_helper & 0x40)
51955195            kasing_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
5196         
5196
51975197         /* Has CHR Mode changed? */
51985198         if (map115_helper & 0x80)
51995199            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
52005200         break;
5201         
5201
52025202      case 0x0001:
52035203         cmd = state->mmc_latch1 & 0x07;
52045204         switch (cmd)
r8325r8326
52155215            break;
52165216      }
52175217         break;
5218         
5218
52195219      default:
52205220         txrom_w(space, offset, data);
52215221         break;
r8325r8326
52235223}
52245224
52255225/*************************************************************
5226
5226
52275227 Bootleg Board by Magic Series
52285228
52295229 Games: Magic Dragon
5230
5230
52315231 Very simple mapper: writes to 0x8000-0xffff set prg32 and chr8
52325232 banks
5233
5233
52345234 iNES: mapper 107
5235
5235
52365236 In MESS: Supported.
5237
5237
52385238 *************************************************************/
52395239
52405240static WRITE8_HANDLER( magics_md_w )
52415241{
52425242   LOG_MMC(("magics_md_w, offset: %04x, data: %02x\n", offset, data));
5243   
5243
52445244   prg32(space->machine, data >> 1);
52455245   chr8(space->machine, data, CHRROM);
52465246}
52475247
52485248/*************************************************************
5249
5249
52505250 Bootleg Board by Nanjing
5251
5251
52525252 Games: A lot of pirate originals
5253 
5253
52545254 iNES: mapper 163
5255
5255
52565256 In MESS: Unsupported.
5257
5257
52585258 *************************************************************/
52595259
52605260static void nanjing_irq( running_device *device, int scanline, int vblank, int blanked )
r8325r8326
52685268         chr4_0(device->machine, 1, CHRRAM);
52695269         chr4_4(device->machine, 1, CHRRAM);
52705270      }
5271     
5271
52725272      if (scanline == 239)
52735273      {
52745274         chr4_0(device->machine, 0, CHRRAM);
52755275         chr4_4(device->machine, 0, CHRRAM);
52765276      }
52775277   }
5278   
5278
52795279}
52805280
52815281static WRITE8_HANDLER( nanjing_l_w )
52825282{
52835283   nes_state *state = (nes_state *)space->machine->driver_data;
52845284   LOG_MMC(("nanjing_l_w, offset: %04x, data: %02x\n", offset, data));
5285   
5285
52865286   offset += 0x100;
52875287
52885288   if (offset < 0x1000)
r8325r8326
52945294         prg32(space->machine, 3);
52955295      return;
52965296   }
5297   
5297
52985298   if (offset == 0x1101)   // 0x5101
52995299   {
53005300      UINT8 temp = state->mmc_count;
53015301      state->mmc_count = data;
5302     
5302
53035303      if (temp & !data)
53045304         state->mmc_latch2 ^= 0xff;
53055305   }
r8325r8326
53255325   nes_state *state = (nes_state *)space->machine->driver_data;
53265326   UINT8 value = 0;
53275327   LOG_MMC(("nanjing_l_r, offset: %04x\n", offset));
5328   
5328
53295329   offset += 0x100;
5330   
5330
53315331   if (offset < 0x1000)
53325332      return 0;
5333   
5333
53345334   switch (offset & 0x700)
53355335   {
53365336      case 0x100:
r8325r8326
53525352}
53535353
53545354/*************************************************************
5355
5355
53565356 Bootleg Board by Nitra
53575357
53585358 Games: Time Diver Avenger
5359
5359
53605360 This acts basically like a MMC3 with different use of write
53615361 address.
5362
5362
53635363 iNES: mapper 250
5364
5364
53655365 In MESS: Supported.
5366
5366
53675367 *************************************************************/
53685368
53695369static WRITE8_HANDLER( nitra_w )
53705370{
53715371   LOG_MMC(("nitra_w, offset: %04x, data: %02x\n", offset, data));
5372   
5372
53735373   txrom_w(space, (offset & 0x6000) | ((offset & 0x400) >> 10), offset & 0xff);
53745374}
53755375
53765376/*************************************************************
5377 
5378 NTDEC ASDER Bootleg Board
53795377
5378 NTDEC ASDER Bootleg Board
5379
53805380 Games: Cobra Mission, Fighting Hero III, Huang Di, Master
53815381 Shooter
5382
5382
53835383 iNES: mapper 112
5384
5384
53855385 In MESS: Supported.
5386
5386
53875387 *************************************************************/
53885388
53895389static WRITE8_HANDLER( ntdec_asder_w )
53905390{
53915391   nes_state *state = (nes_state *)space->machine->driver_data;
53925392   LOG_MMC(("ntdec_asder_w, offset: %04x, data: %02x\n", offset, data));
5393   
5393
53945394   switch (offset)
53955395   {
53965396      case 0x0000:
r8325r8326
54365436}
54375437
54385438/*************************************************************
5439
5439
54405440 Bootleg Board by NTDEC for Fighting Hero
54415441
54425442 Games: Fighting Hero
5443
5443
54445444 Very simple mapper: writes to 0x6000-0x7fff swap PRG and
54455445 CHR banks.
5446
5446
54475447 iNES: mapper 193
5448
5448
54495449 In MESS: Supported.
5450
5450
54515451 *************************************************************/
54525452
54535453static WRITE8_HANDLER( ntdec_fh_m_w )
54545454{
54555455   LOG_MMC(("ntdec_fh_m_w, offset: %04x, data: %02x\n", offset, data));
5456   
5456
54575457   switch (offset & 0x03)
54585458   {
54595459      case 0:
r8325r8326
54725472}
54735473
54745474/*************************************************************
5475
5475
54765476 Open Corp DAOU306 board
54775477
54785478 Games: Metal Force (K)
5479
5479
54805480 iNES: mapper 156
5481
5481
54825482 In MESS: Supported.
5483
5483
54845484 *************************************************************/
54855485
54865486static WRITE8_HANDLER( daou306_w )
54875487{
54885488   LOG_MMC(("daou306_w, offset: %04x, data: %02x\n", offset, data));
5489   
5489
54905490   switch (offset)
54915491   {
54925492      case 0x4000:
r8325r8326
55205520}
55215521
55225522/*************************************************************
5523
5523
55245524 RCM GS2015 Board
55255525
55265526 Games: Bonza, Magic Jewelry 2
5527
5527
55285528 Very simple mapper: writes to 0x8000-0xffff sets prg32
55295529 to offset and chr8 to offset>>1 (when chrrom is present)
5530
5530
55315531 iNES: mapper 216
5532
5532
55335533 In MESS: Supported.
5534
5534
55355535 *************************************************************/
55365536
55375537static WRITE8_HANDLER( gs2015_w )
55385538{
55395539   nes_state *state = (nes_state *)space->machine->driver_data;
55405540   LOG_MMC(("gs2015_w, offset: %04x, data: %02x\n", offset, data));
5541   
5541
55425542   prg32(space->machine, offset);
55435543   chr8(space->machine, offset >> 1, state->mmc_chr_source);
55445544}
55455545
55465546/*************************************************************
5547
5547
55485548 Bootleg Board by RCM for Tetris Family
55495549
55505550 Games: Tetris Family 9 in 1, 20 in 1
5551
5551
55525552 Simple Mapper: prg/chr/nt are swapped depending on the offset
55535553 of writes in 0x8000-0xffff. offset&0x80 set NT mirroring,
55545554 when (offset&0x30) is 0,3 prg32 is set; when it is 1,2
55555555 two 16k prg banks are set. See below for the values used in
55565556 these banks.
5557
5557
55585558 iNES: mapper 61
5559
5559
55605560 In MESS: Supported.
5561
5561
55625562 *************************************************************/
55635563
55645564static WRITE8_HANDLER( rcm_tf_w )
55655565{
55665566   LOG_MMC(("rcm_tf_w, offset: %04x, data: %02x\n", offset, data));
5567   
5567
55685568   switch (offset & 0x30)
55695569   {
55705570      case 0x00:
r8325r8326
55815581}
55825582
55835583/*************************************************************
5584
5584
55855585 Bootleg Board by Rex Soft
55865586
55875587 Games: Dragon Ball Z 5, Dragon Ball Z Super
5588
5588
55895589 MMC3 clone
5590
5590
55915591 iNES: mapper 12
5592
5592
55935593 In MESS: Partially Supported
5594
5594
55955595 *************************************************************/
55965596
55975597static WRITE8_HANDLER( rex_dbz_l_w )
55985598{
55995599   nes_state *state = (nes_state *)space->machine->driver_data;
5600   
5600
56015601   LOG_MMC(("rex_dbz_l_w, offset: %04x, data: %02x\n", offset, data));
5602   
5602
56035603   state->mapper12_reg = data;
56045604}
56055605
r8325r8326
56145614{
56155615   nes_state *state = (nes_state *)machine->driver_data;
56165616   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
5617   
5617
56185618   chr1_x(machine, chr_page ^ 0, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[0] & ~0x01), CHRROM);
56195619   chr1_x(machine, chr_page ^ 1, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[0] |  0x01), CHRROM);
56205620   chr1_x(machine, chr_page ^ 2, ((state->mapper12_reg & 0x01) << 8) | (state->mmc_vrom_bank[1] & ~0x01), CHRROM);
r8325r8326
56305630   nes_state *state = (nes_state *)space->machine->driver_data;
56315631   UINT8 MMC3_helper, cmd;
56325632   LOG_MMC(("rex_dbz_w, offset: %04x, data: %02x\n", offset, data));
5633   
5633
56345634   switch (offset & 0x6001)
56355635   {
56365636      case 0x0000:
56375637         MMC3_helper = state->mmc_latch1 ^ data;
56385638         state->mmc_latch1 = data;
5639         
5639
56405640         /* Has PRG Mode changed? */
56415641         if (MMC3_helper & 0x40)
56425642            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
5643         
5643
56445644         /* Has CHR Mode changed? */
56455645         if (MMC3_helper & 0x80)
56465646            rex_dbz_set_chr(space->machine);
56475647         break;
5648         
5648
56495649      case 0x0001:
56505650         cmd = state->mmc_latch1 & 0x07;
56515651         switch (cmd)
r8325r8326
56625662            break;
56635663      }
56645664         break;
5665         
5665
56665666      default:
56675667         txrom_w(space, offset, data);
56685668         break;
r8325r8326
56705670}
56715671
56725672/*************************************************************
5673
5673
56745674 Rex Soft SL1632 Board
56755675
56765676 Games: Samurai Spirits
5677
5677
56785678 MMC3 clone
5679
5679
56805680 iNES: mapper 14
5681
5681
56825682 In MESS: Supported
5683
5683
56845684 *************************************************************/
56855685
56865686static void rex_sl1632_set_prg( running_machine *machine, int prg_base, int prg_mask )
56875687{
56885688   nes_state *state = (nes_state *)machine->driver_data;
5689   
5689
56905690   if (state->map14_reg[0] & 0x02)
56915691   {
56925692      mmc3_set_prg(machine, prg_base, prg_mask);
r8325r8326
57085708   UINT8 bank[8];
57095709   UINT8 chr_base2[8];
57105710   int i;
5711   
5711
57125712   if (state->map14_reg[0] & 0x02)
57135713   {
57145714      for(i = 0; i < 8; i++)
r8325r8326
57255725         chr_base2[i] = chr_base;
57265726      }
57275727   }
5728   
5728
57295729   chr1_x(machine, chr_page ^ 0, chr_base2[0] | (bank[0] & chr_mask), chr);
57305730   chr1_x(machine, chr_page ^ 1, chr_base2[1] | (bank[1] & chr_mask), chr);
57315731   chr1_x(machine, chr_page ^ 2, chr_base2[2] | (bank[2] & chr_mask), chr);
r8325r8326
57415741   nes_state *state = (nes_state *)space->machine->driver_data;
57425742   UINT8 map14_helper1, map14_helper2, MMC3_helper, cmd;
57435743   LOG_MMC(("rex_sl1632_w, offset: %04x, data: %02x\n", offset, data));
5744   
5744
57455745   if (offset == 0x2131)
57465746   {
57475747      state->map14_reg[0] = data;
57485748      rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
57495749      rex_sl1632_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
5750     
5750
57515751      if (!(state->map14_reg[0] & 0x02))
57525752         set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
57535753   }
5754   
5754
57555755   if (state->map14_reg[0] & 0x02)
57565756   {
57575757      switch (offset & 0x6001)
r8325r8326
57595759         case 0x0000:
57605760            MMC3_helper = state->mmc_latch1 ^ data;
57615761            state->mmc_latch1 = data;
5762           
5762
57635763            /* Has PRG Mode changed? */
57645764            if (MMC3_helper & 0x40)
57655765               rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
5766           
5766
57675767            /* Has CHR Mode changed? */
57685768            if (MMC3_helper & 0x80)
57695769               rex_sl1632_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
57705770            break;
5771           
5771
57725772         case 0x0001:
57735773            cmd = state->mmc_latch1 & 0x07;
57745774            switch (cmd)
r8325r8326
57895789               break;
57905790         }
57915791            break;
5792           
5792
57935793         case 0x2000:
57945794            set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
57955795            break;
5796           
5796
57975797         default:
57985798            txrom_w(space, offset, data);
57995799            break;
r8325r8326
58165816            state->mmc_extra_bank[offset >> 13] = data;
58175817            rex_sl1632_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
58185818            break;
5819           
5819
58205820         case 0x1000:
58215821            state->map14_reg[1] = data;
58225822            set_nt_mirroring(space->machine, BIT(state->map14_reg[1], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
r8325r8326
58265826}
58275827
58285828/*************************************************************
5829
5829
58305830 Rumblestation Board
58315831
58325832 Games: Rumblestation 15 in 1
5833
5833
58345834 iNES: mapper 46
5835
5835
58365836 In MESS: Supported.
5837
5837
58385838 *************************************************************/
58395839
58405840static WRITE8_HANDLER( rumblestation_m_w )
58415841{
58425842   nes_state *state = (nes_state *)space->machine->driver_data;
58435843   LOG_MMC(("rumblestation_m_w, offset: %04x, data: %02x\n", offset, data));
5844   
5844
58455845   state->mmc_prg_bank[0] = (state->mmc_prg_bank[0] & 0x01) | ((data & 0x0f) << 1);
58465846   state->mmc_vrom_bank[0] = (state->mmc_vrom_bank[0] & 0x07) | ((data & 0xf0) >> 1);
58475847   prg32(space->machine, state->mmc_prg_bank[0]);
r8325r8326
58525852{
58535853   nes_state *state = (nes_state *)space->machine->driver_data;
58545854   LOG_MMC(("rumblestation_w, offset: %04x, data: %02x\n", offset, data));
5855   
5855
58565856   state->mmc_prg_bank[0] = (state->mmc_prg_bank[0] & ~0x01) | (data & 0x01);
58575857   state->mmc_vrom_bank[0] = (state->mmc_vrom_bank[0] & ~0x07) | ((data & 0x70) >> 4);
58585858   prg32(space->machine, state->mmc_prg_bank[0]);
r8325r8326
58605860}
58615861
58625862/*************************************************************
5863
5863
58645864 Sachen 74x374 bootleg boards
5865
5865
58665866 iNES: mapper 150 & 243
5867
5867
58685868 *************************************************************/
58695869
58705870static void sachen_set_mirror( running_machine *machine, UINT8 nt ) // used by mappers 137, 138, 139, 141
r8325r8326
58945894{
58955895   nes_state *state = (nes_state *)space->machine->driver_data;
58965896   LOG_MMC(("sachen_74x374_l_w, offset: %04x, data: %02x\n", offset, data));
5897   
5897
58985898   /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
58995899   if (!(offset & 0x100))
59005900   {
r8325r8326
59345934{
59355935   nes_state *state = (nes_state *)space->machine->driver_data;
59365936   LOG_MMC(("sachen_74x374_l_r, offset: %04x", offset));
5937   
5937
59385938   /* read  happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
59395939   if (!(offset & 0x100))
59405940      return (~state->mmc_latch1 & 0x3f) /* ^ dips*/;   // we would need to check the Dips here
r8325r8326
59465946{
59475947   nes_state *state = (nes_state *)space->machine->driver_data;
59485948   LOG_MMC(("sachen_74x374a_l_w, offset: %04x, data: %02x\n", offset, data));
5949   
5949
59505950   /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
59515951   if (!(offset & 0x100))
59525952   {
r8325r8326
59865986}
59875987
59885988/*************************************************************
5989
5989
59905990 Sachen S8259 bootleg boards
5991
5991
59925992 iNES: mapper 141 (A), 138 (B), 139 (C), 137 (D)
5993
5993
59945994 *************************************************************/
59955995
59965996static void common_s8259_write_handler( const address_space *space, offs_t offset, UINT8 data, int board )
r8325r8326
60066006      else
60076007      {
60086008         state->sachen_reg[state->mmc_latch1] = data;
6009         
6009
60106010         switch (state->mmc_latch1)
60116011         {
60126012            case 0x05:
r8325r8326
60346034                  add1 = (board == SACHEN_8259B) ? 0 : 1;
60356035                  add2 = (board == SACHEN_8259C) ? 2 : 0;
60366036                  add3 = (board == SACHEN_8259A) ? 1 : (board == SACHEN_8259C) ? 3 : 0;
6037                 
6037
60386038                  if (state->mmc_chr_source == CHRROM)
60396039                  {
60406040                     chr2_0(space->machine, ((state->sachen_reg[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2) << shift, CHRROM);
r8325r8326
60536053{
60546054   nes_state *state = (nes_state *)space->machine->driver_data;
60556055   LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", state->pcb_id, offset, data));
6056   
6056
60576057   common_s8259_write_handler(space, offset, data, state->pcb_id);
60586058}
60596059
r8325r8326
60616061{
60626062   nes_state *state = (nes_state *)space->machine->driver_data;
60636063   LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", state->pcb_id, offset, data));
6064   
6064
60656065   common_s8259_write_handler(space, (offset + 0x100) & 0xfff, data, state->pcb_id);
60666066}
60676067
60686068
60696069/*************************************************************
6070
6070
60716071 Sachen SA0036 bootleg boards
6072
6072
60736073 iNES: mapper 149
6074
6074
60756075 *************************************************************/
60766076
60776077static WRITE8_HANDLER( sa0036_w )
60786078{
60796079   LOG_MMC(("sa0036_w, offset: %04x, data: %02x\n", offset, data));
6080   
6080
60816081   chr8(space->machine, data >> 7, CHRROM);
60826082}
60836083
60846084/*************************************************************
6085
6085
60866086 Sachen SA0037 bootleg boards
6087
6087
60886088 iNES: mapper 148
6089
6089
60906090 *************************************************************/
60916091
60926092static WRITE8_HANDLER( sa0037_w )
60936093{
60946094   LOG_MMC(("sa0037_w, offset: %04x, data: %02x\n", offset, data));
6095   
6095
60966096   prg32(space->machine, data >> 3);
60976097   chr8(space->machine, data, CHRROM);
60986098}
60996099
61006100/*************************************************************
6101
6101
61026102 Sachen SA72007 bootleg boards
6103
6103
61046104 iNES: mapper 145
6105
6105
61066106 *************************************************************/
61076107
61086108static WRITE8_HANDLER( sa72007_l_w )
61096109{
61106110   LOG_MMC(("sa72007_l_w, offset: %04x, data: %02x\n", offset, data));
6111   
6111
61126112   /* only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
61136113   if (!(offset & 0x100))
61146114      chr8(space->machine, data >> 7, CHRROM);
61156115}
61166116
61176117/*************************************************************
6118
6118
61196119 Sachen SA72008 bootleg boards
6120
6120
61216121 iNES: mapper 133
6122
6122
61236123 *************************************************************/
61246124
61256125static WRITE8_HANDLER( sa72008_l_w )
61266126{
61276127   LOG_MMC(("sa72008_l_w, offset: %04x, data: %02x\n", offset, data));
6128   
6128
61296129   prg32(space->machine, data >> 2);
61306130   chr8(space->machine, data, CHRROM);
61316131}
61326132
61336133/*************************************************************
6134
6134
61356135 Sachen TCA-01 bootleg boards
6136
6136
61376137 iNES: mapper 143
6138
6138
61396139 *************************************************************/
61406140
61416141static READ8_HANDLER( tca01_l_r )
61426142{
61436143   LOG_MMC(("tca01_l_r, offset: %04x\n", offset));
6144   
6144
61456145   /* the address is read only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */
61466146   if (!(offset & 0x100))
61476147      return (~offset & 0x3f) | 0x40;
r8325r8326
61506150}
61516151
61526152/*************************************************************
6153
6153
61546154 Sachen TCU-01 bootleg boards
6155
6155
61566156 iNES: mapper 147
6157
6157
61586158 *************************************************************/
61596159
61606160static WRITE8_HANDLER( tcu01_l_w )
61616161{
61626162   LOG_MMC(("tcu01_l_w, offset: %04x, data: %02x\n", offset, data));
6163   
6163
61646164   if ((offset & 0x103) == 0x002)
61656165   {
61666166      prg32(space->machine, ((data >> 6) & 0x02) | ((data >> 2) & 0x01));
r8325r8326
61716171static WRITE8_HANDLER( tcu01_m_w )
61726172{
61736173   LOG_MMC(("tcu01_m_w, offset: %04x, data: %02x\n", offset, data));
6174   
6174
61756175   tcu01_l_w(space, (offset + 0x100) & 0xfff, data);
61766176}
61776177
61786178static WRITE8_HANDLER( tcu01_w )
61796179{
61806180   LOG_MMC(("tcu01_w, offset: %04x, data: %02x\n", offset, data));
6181   
6181
61826182   tcu01_l_w(space, (offset + 0x100) & 0xfff, data);
61836183}
61846184
61856185/*************************************************************
6186
6186
61876187 Sachen TCU-02 bootleg boards
6188
6188
61896189 iNES: mapper 136
6190
6190
61916191 *************************************************************/
61926192
61936193static WRITE8_HANDLER( tcu02_l_w )
61946194{
61956195   nes_state *state = (nes_state *)space->machine->driver_data;
61966196   LOG_MMC(("tcu02_l_w, offset: %04x, data: %02x\n", offset, data));
6197   
6197
61986198   if ((offset & 0x103) == 0x002)
61996199   {
62006200      state->mmc_latch1 = (data & 0x30) | ((data + 3) & 0x0f);
r8325r8326
62066206{
62076207   nes_state *state = (nes_state *)space->machine->driver_data;
62086208   LOG_MMC(("tcu02_l_r, offset: %04x\n", offset));
6209   
6209
62106210   if ((offset & 0x103) == 0x000)
62116211      return state->mmc_latch1 | 0x40;
62126212   else
r8325r8326
62156215
62166216
62176217/*************************************************************
6218
6218
62196219 Subor bootleg board Type 0
6220
6220
62216221 iNES: mapper 167
6222
6222
62236223 *************************************************************/
62246224
62256225static WRITE8_HANDLER( subor0_w )
r8325r8326
62276227   nes_state *state = (nes_state *)space->machine->driver_data;
62286228   UINT8 subor_helper1, subor_helper2;
62296229   LOG_MMC(("subor0_w, offset: %04x, data: %02x\n", offset, data));
6230   
6230
62316231   state->subor_reg[(offset >> 13) & 0x03] = data;
62326232   subor_helper1 = ((state->subor_reg[0] ^ state->subor_reg[1]) << 1) & 0x20;
62336233   subor_helper2 = ((state->subor_reg[2] ^ state->subor_reg[3]) << 0) & 0x1f;
6234   
6234
62356235   if (state->subor_reg[1] & 0x08)
62366236   {
62376237      subor_helper1 += subor_helper2 & 0xfe;
r8325r8326
62486248      subor_helper1 += subor_helper2;
62496249      subor_helper2 = 0x20;
62506250   }
6251   
6251
62526252   prg16_89ab(space->machine, subor_helper1);
62536253   prg16_cdef(space->machine, subor_helper2);
62546254}
62556255
62566256/*************************************************************
6257
6257
62586258 Subor bootleg board Type 1
6259
6259
62606260 iNES: mapper 166
6261
6261
62626262 *************************************************************/
62636263
62646264static WRITE8_HANDLER( subor1_w )
r8325r8326
62666266   nes_state *state = (nes_state *)space->machine->driver_data;
62676267   UINT8 subor_helper1, subor_helper2;
62686268   LOG_MMC(("subor1_w, offset: %04x, data: %02x\n", offset, data));
6269   
6269
62706270   state->subor_reg[(offset >> 13) & 0x03] = data;
62716271   subor_helper1 = ((state->subor_reg[0] ^ state->subor_reg[1]) << 1) & 0x20;
62726272   subor_helper2 = ((state->subor_reg[2] ^ state->subor_reg[3]) << 0) & 0x1f;
6273   
6273
62746274   if (state->subor_reg[1] & 0x08)
62756275   {
62766276      subor_helper1 += subor_helper2 & 0xfe;
r8325r8326
62876287      subor_helper1 += subor_helper2;
62886288      subor_helper2 = 0x07;
62896289   }
6290   
6290
62916291   prg16_89ab(space->machine, subor_helper1);
62926292   prg16_cdef(space->machine, subor_helper2);
62936293}
62946294
62956295/*************************************************************
6296
6296
62976297 Bootleg Board by Super Game
62986298
62996299 Games: Boogerman, Mortal Kombat III
6300
6300
63016301 MMC3 clone. Also, it probably needs a hack to support both
63026302 variants (Boogerman & MK3).
6303
6303
63046304 iNES: mapper 215
6305
6305
63066306 In MESS: Preliminary support.
6307
6307
63086308 *************************************************************/
63096309
63106310// remove mask & base parameters!
r8325r8326
63206320   {
63216321      state->mmc_prg_base = (state->map215_reg[1] & 0x08) ? 0x20 : (state->map215_reg[1] & 0x10);
63226322      state->mmc_prg_mask = (state->map215_reg[1] & 0x08) ? 0x1f : 0x0f;
6323     
6323
63246324      mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
63256325   }
63266326}
r8325r8326
63316331   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
63326332   int chr_base = (state->map215_reg[1] & 0x04) ? 0x100 : ((state->map215_reg[1] & 0x10) << 3);
63336333   int chr_mask = (state->map215_reg[1] & 0x04) ? 0xff : 0x7f;
6334   
6334
63356335   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
63366336   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
63376337   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
r8325r8326
63476347   nes_state *state = (nes_state *)space->machine->driver_data;
63486348   LOG_MMC(("sgame_boog_l_w, offset: %04x, data: %02x\n", offset, data));
63496349   offset += 0x100;
6350   
6350
63516351   if (offset == 0x1000)
63526352   {
63536353      state->map215_reg[0] = data;
r8325r8326
63736373   UINT8 MMC3_helper, cmd;
63746374   static const UINT8 conv_table[8] = {0,2,5,3,6,1,7,4};
63756375   LOG_MMC(("sgame_boog_w, offset: %04x, data: %02x\n", offset, data));
6376   
6376
63776377   if (!state->map215_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers
63786378   {
63796379      switch (offset & 0x6001)
r8325r8326
63816381         case 0x0000:
63826382            MMC3_helper = state->mmc_latch1 ^ data;
63836383            state->mmc_latch1 = data;
6384           
6384
63856385            /* Has PRG Mode changed? */
63866386            if (MMC3_helper & 0x40)
63876387               sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6388           
6388
63896389            /* Has CHR Mode changed? */
63906390            if (MMC3_helper & 0x80)
63916391               sgame_boog_set_chr(space->machine, state->mmc_chr_source);
63926392            break;
6393           
6393
63946394         case 0x0001:
63956395            cmd = state->mmc_latch1 & 0x07;
63966396            switch (cmd)
r8325r8326
64076407               break;
64086408         }
64096409            break;
6410           
6410
64116411         default:
64126412            txrom_w(space, offset, data);
64136413            break;
r8325r8326
64196419      {
64206420         case 0x0000:
64216421            break;
6422           
6422
64236423         case 0x0001:
64246424            cmd = state->mmc_latch1 & 0x07;
64256425            if (state->map215_reg[3] && ((state->map215_reg[0] & 0x80) == 0 || cmd < 6))   // if we use the prg16 banks and cmd=6,7 DON'T enter!
r8325r8326
64406440               }
64416441            }
64426442            break;
6443           
6443
64446444         case 0x2000:
64456445            data = (data & 0xc0) | conv_table[data & 0x07];
64466446            MMC3_helper = state->mmc_latch1 ^ data;
64476447            state->mmc_latch1 = data;
6448           
6448
64496449            /* Has PRG Mode changed? */
64506450            if (MMC3_helper & 0x40)
64516451               sgame_boog_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6452           
6452
64536453            /* Has CHR Mode changed? */
64546454            if (MMC3_helper & 0x80)
64556455               sgame_boog_set_chr(space->machine, state->mmc_chr_source);
6456           
6456
64576457            state->map215_reg[3] = 1;
64586458            break;
6459           
6459
64606460            //      case 0x2001:
64616461            //          txrom_w(space, 0x4001, data);
64626462            //          break;
6463           
6463
64646464         case 0x4000:
64656465            set_nt_mirroring(space->machine, ((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
64666466            break;
6467           
6467
64686468         case 0x4001:
64696469            txrom_w(space, 0x6001, data);
64706470            break;
6471           
6471
64726472            //      case 0x6000:
64736473            //          txrom_w(space, 0x6000, data);
64746474            //          break;
6475           
6475
64766476         case 0x6001:
64776477            txrom_w(space, 0x4000, data);
64786478            txrom_w(space, 0x4001, data);
64796479            break;
6480           
6480
64816481         default:
64826482            txrom_w(space, offset, data);
64836483            break;
r8325r8326
64866486}
64876487
64886488/*************************************************************
6489
6489
64906490 Bootleg Board by Super Game
6491
6491
64926492 Games: The Lion King
6493
6493
64946494 MMC3 clone.
6495
6495
64966496 iNES: mapper 114
6497
6497
64986498 In MESS: Supported.
6499
6499
65006500 *************************************************************/
65016501
65026502static WRITE8_HANDLER( sgame_lion_m_w )
65036503{
65046504   nes_state *state = (nes_state *)space->machine->driver_data;
65056505   LOG_MMC(("sgame_lion_m_w, offset: %04x, data: %02x\n", offset, data));
6506   
6506
65076507   state->map114_reg = data;
6508   
6508
65096509   if (state->map114_reg & 0x80)
65106510   {
65116511      prg16_89ab(space->machine, data & 0x1f);
r8325r8326
65136513   }
65146514   else
65156515      mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
6516   
6516
65176517}
65186518
65196519static WRITE8_HANDLER( sgame_lion_w )
r8325r8326
65216521   nes_state *state = (nes_state *)space->machine->driver_data;
65226522   static const UINT8 conv_table[8] = {0, 3, 1, 5, 6, 7, 2, 4};
65236523   LOG_MMC(("sgame_lion_w, offset: %04x, data: %02x\n", offset, data));
6524   
6524
65256525   if (offset < 0x6000)
65266526   {
65276527      switch (offset & 0x6000)
r8325r8326
65606560}
65616561
65626562/*************************************************************
6563
6563
65646564 Tengen 800008 Board
6565 
6565
65666566 iNES: mapper 3?
6567
6567
65686568 In MESS: Supported.
6569
6569
65706570 *************************************************************/
65716571
65726572static WRITE8_HANDLER( tengen_800008_w )
65736573{
65746574   LOG_MMC(("tengen_800008_w, offset: %04x, data: %02x\n", offset, data));
6575   
6575
65766576   prg32(space->machine, data >> 3);
65776577   chr8(space->machine, data, CHRROM);
65786578}
65796579
65806580/*************************************************************
6581
6581
65826582 Tengen 800032 Board
65836583
65846584 Games: Klax, Road Runner, Rolling Thunder, Shinobi, Skulls
65856585 & Croosbones, Xybots
6586
6586
65876587 iNES: mapper 64
6588
6588
65896589 In MESS: Partially Supported.
6590
6590
65916591 *************************************************************/
65926592
65936593static void tengen_800032_irq( running_device *device, int scanline, int vblank, int blanked )
r8325r8326
66516651{
66526652   nes_state *state = (nes_state *)machine->driver_data;
66536653   UINT8 prg_mode = state->mmc_latch1 & 0x40;
6654   
6654
66556655   prg8_89(machine, state->mmc_prg_bank[prg_mode ? 2: 0]);
66566656   prg8_ab(machine, state->mmc_prg_bank[prg_mode ? 0: 1]);
66576657   prg8_cd(machine, state->mmc_prg_bank[prg_mode ? 1: 2]);
r8325r8326
66616661{
66626662   nes_state *state = (nes_state *)machine->driver_data;
66636663   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
6664   
6664
66656665   if (state->mmc_latch1 & 0x20)
66666666   {
66676667      chr1_x(machine, 0 ^ chr_page, state->mmc_vrom_bank[0], CHRROM);
r8325r8326
66766676      chr1_x(machine, 2 ^ chr_page, state->mmc_vrom_bank[1] & ~0x01, CHRROM);
66776677      chr1_x(machine, 3 ^ chr_page, state->mmc_vrom_bank[1] |  0x01, CHRROM);
66786678   }
6679   
6679
66806680   chr1_x(machine, 4 ^ chr_page, state->mmc_vrom_bank[2], CHRROM);
66816681   chr1_x(machine, 5 ^ chr_page, state->mmc_vrom_bank[3], CHRROM);
66826682   chr1_x(machine, 6 ^ chr_page, state->mmc_vrom_bank[4], CHRROM);
r8325r8326
66886688   nes_state *state = (nes_state *)space->machine->driver_data;
66896689   UINT8 map64_helper, cmd;
66906690   LOG_MMC(("tengen_800032_w, offset: %04x, data: %02x\n", offset, data));
6691   
6691
66926692   switch (offset & 0x6001)
66936693   {
66946694      case 0x0000:
66956695         map64_helper = state->mmc_latch1 ^ data;
66966696         state->mmc_latch1 = data;
6697         
6697
66986698         /* Has PRG Mode changed? */
66996699         if (map64_helper & 0x40)
67006700            tengen_800032_set_prg(space->machine);
6701         
6701
67026702         /* Has CHR Mode changed? */
67036703         if (map64_helper & 0xa0)
67046704            tengen_800032_set_chr(space->machine);
67056705         break;
6706         
6706
67076707      case 0x0001:
67086708         cmd = state->mmc_latch1 & 0x0f;
67096709         switch (cmd)
r8325r8326
67286728            break;
67296729      }
67306730         break;
6731         
6731
67326732      case 0x2000:
67336733         set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
67346734         break;
6735         
6735
67366736      case 0x4000:
67376737         state->IRQ_count_latch = data;
67386738         break;
6739         
6739
67406740      case 0x4001: /* $c001 - IRQ scanline latch */
67416741         state->IRQ_mode = data & 0x01;
67426742         state->IRQ_reset = 1;
67436743         break;
6744         
6744
67456745      case 0x6000:
67466746         state->IRQ_enable = 0;
67476747         break;
6748         
6748
67496749      case 0x6001:
67506750         state->IRQ_enable = 1;
67516751         break;
6752         
6752
67536753      default:
67546754         LOG_MMC(("Mapper 64 write. addr: %04x value: %02x\n", offset + 0x8000, data));
67556755         break;
r8325r8326
67576757}
67586758
67596759/*************************************************************
6760
6760
67616761 Tengen 800037 Board
6762
6762
67636763 Games: Alien Syndrome
6764
6764
67656765 iNES: mapper 158
6766
6766
67676767 In MESS: Very preliminary support.
6768
6768
67696769 *************************************************************/
67706770
67716771// probably wrong...
r8325r8326
67736773{
67746774   nes_state *state = (nes_state *)machine->driver_data;
67756775   UINT8 nt_mode = state->mmc_latch1 & 0x80;
6776   
6776
67776777   set_nt_page(machine, 0, ROM, state->mmc_vrom_bank[nt_mode ? 2 : 0], 0);
67786778   set_nt_page(machine, 1, ROM, state->mmc_vrom_bank[nt_mode ? 3 : 0], 0);
67796779   set_nt_page(machine, 2, ROM, state->mmc_vrom_bank[nt_mode ? 4 : 1], 0);
r8325r8326
67856785   nes_state *state = (nes_state *)space->machine->driver_data;
67866786   UINT8 map158_helper, cmd;
67876787   LOG_MMC(("tengen_800037_w, offset: %04x, data: %02x\n", offset, data));
6788   
6788
67896789   switch (offset & 0x6001)
67906790   {
67916791      case 0x0000:
67926792         map158_helper = state->mmc_latch1 ^ data;
67936793         state->mmc_latch1 = data;
6794         
6794
67956795         /* Has PRG Mode changed? */
67966796         if (map158_helper & 0x40)
67976797            tengen_800032_set_prg(space->machine);
6798         
6798
67996799         /* Has CHR Mode changed? */
68006800         if (map158_helper & 0xa0)
68016801         {
r8325r8326
68036803            tengen_800037_set_mirror(space->machine);
68046804         }
68056805         break;
6806         
6806
68076807      case 0x0001:
68086808         cmd = state->mmc_latch1 & 0x0f;
68096809         switch (cmd)
r8325r8326
68306830            break;
68316831      }
68326832         break;
6833         
6833
68346834      case 0x2000:
68356835         break;
6836         
6836
68376837      default:
68386838         tengen_800032_w(space, offset, data);
68396839         break;
r8325r8326
68416841}
68426842
68436843/*************************************************************
6844
6844
68456845 Bootleg Board 22211 by TXC (Type A)
68466846
68476847 Games: Creatom
6848
6848
68496849 Info from NEStopia: this mapper features write to four
68506850 registers (0x4100-0x4103). The third one is used to select
68516851 PRG and CHR banks.
6852
6852
68536853 iNES: mapper 132
6854
6854
68556855 In MESS: Supported.
6856
6856
68576857 *************************************************************/
68586858
68596859static WRITE8_HANDLER( txc_22211_l_w )
68606860{
68616861   nes_state *state = (nes_state *)space->machine->driver_data;
68626862   LOG_MMC(("txc_22211_l_w, offset: %04x, data: %02x\n", offset, data));
6863   
6863
68646864   if (offset < 4)
68656865      state->txc_reg[offset & 0x03] = data;
68666866}
r8325r8326
68696869{
68706870   nes_state *state = (nes_state *)space->machine->driver_data;
68716871   LOG_MMC(("txc_22211_l_r, offset: %04x\n", offset));
6872   
6872
68736873   if (offset == 0x0000)
68746874      return (state->txc_reg[1] ^ state->txc_reg[2]) | 0x40;
68756875   else
r8325r8326
68806880{
68816881   nes_state *state = (nes_state *)space->machine->driver_data;
68826882   LOG_MMC(("txc_22211_w, offset: %04x, data: %02x\n", offset, data));
6883   
6883
68846884   prg32(space->machine, state->txc_reg[2] >> 2);
68856885   chr8(space->machine, state->txc_reg[2], CHRROM);
68866886}
68876887
68886888/*************************************************************
6889
6889
68906890 Bootleg Board 22211 by TXC (Type B)
6891
6891
68926892 Games: 1991 Du Ma Racing
6893
6893
68946894 This mapper is basically the same as Type A. Only difference is
68956895 in the way CHR banks are selected (see below)
6896
6896
68976897 iNES: mapper 172
6898
6898
68996899 In MESS: Supported.
6900
6900
69016901 *************************************************************/
69026902
69036903static WRITE8_HANDLER( txc_22211b_w )
69046904{
69056905   nes_state *state = (nes_state *)space->machine->driver_data;
69066906   LOG_MMC(("txc_22211b_w, offset: %04x, data: %02x\n", offset, data));
6907   
6907
69086908   prg32(space->machine, state->txc_reg[2] >> 2);
69096909   chr8(space->machine, (((data ^ state->txc_reg[2]) >> 3) & 0x02) | (((data ^ state->txc_reg[2]) >> 5) & 0x01), CHRROM);
69106910}
69116911
69126912/*************************************************************
6913
6913
69146914 Bootleg Board 22211 by TXC (Type C)
6915
6915
69166916 Games: Mahjong Block, Xiao Ma Li
6917
6917
69186918 This mapper is basically the same as 132 too. Only difference is
69196919 in 0x4100 reads which expect also bit 0 to be set
6920
6920
69216921 iNES: mapper 172
6922
6922
69236923 In MESS: Supported.
6924
6924
69256925 *************************************************************/
69266926
69276927static READ8_HANDLER( txc_22211c_l_r )
69286928{
69296929   nes_state *state = (nes_state *)space->machine->driver_data;
69306930   LOG_MMC(("txc_22211c_l_r, offset: %04x\n", offset));
6931   
6931
69326932   if (offset == 0x0000)
69336933      return (state->txc_reg[1] ^ state->txc_reg[2]) | 0x41;
69346934   else
r8325r8326
69366936}
69376937
69386938/*************************************************************
6939
6939
69406940 Bootleg Board 'Thunder Warrior' by TXC
69416941
69426942 Games: Master Fighter II, Master Fighter 3, Thunder Warrior
6943
6943
69446944 MMC3 clone
6945
6945
69466946 iNES: mapper 189
6947
6947
69486948 In MESS: Supported.
6949
6949
69506950 *************************************************************/
69516951
69526952static WRITE8_HANDLER( txc_tw_l_w )
69536953{
69546954   LOG_MMC(("txctw_l_w, offset: %04x, data: %02x\n", offset, data));
6955   
6955
69566956   prg32(space->machine, (data >> 4) | data);
69576957}
69586958
69596959static WRITE8_HANDLER( txc_tw_m_w )
69606960{
69616961   LOG_MMC(("txctw_m_w, offset: %04x, data: %04x\n", offset, data));
6962   
6962
69636963   txc_tw_l_w(space, offset & 0xff, data);   // offset does not really count for this mapper
69646964}
69656965
r8325r8326
69696969   nes_state *state = (nes_state *)space->machine->driver_data;
69706970   UINT8 MMC3_helper, cmd;
69716971   LOG_MMC(("txctw_w, offset: %04x, data: %02x\n", offset, data));
6972   
6972
69736973   switch (offset & 0x6001)
69746974   {
69756975      case 0x0000:
69766976         MMC3_helper = state->mmc_latch1 ^ data;
69776977         state->mmc_latch1 = data;
6978         
6978
69796979         /* Has CHR Mode changed? */
69806980         if (MMC3_helper & 0x80)
69816981            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
69826982         break;
6983         
6983
69846984      case 0x0001:
69856985         cmd = state->mmc_latch1 & 0x07;
69866986         switch (cmd)
r8325r8326
69926992            break;
69936993         }
69946994         break;
6995         
6995
69966996      default:
69976997         txrom_w(space, offset, data);
69986998         break;
r8325r8326
70007000}
70017001
70027002/*************************************************************
7003
7003
70047004 Bootleg Board 'Strike Wolf' by TXC
7005
7005
70067006 Games: Strike Wolf (also Policeman?? according to Nestopia)
70077007
70087008 iNES: mapper 36
7009
7009
70107010 Known Boards: Bootleg Board by TXC
7011
7011
70127012 In MESS: Supported.
7013
7013
70147014 *************************************************************/
70157015
70167016static WRITE8_HANDLER( txc_strikewolf_w )
70177017{
70187018   LOG_MMC(("txc_strikewolf_w, offset: %04x, data: %02x\n", offset, data));
7019   
7019
70207020   if ((offset >= 0x400) && (offset < 0x7fff))
70217021   {
70227022      prg32(space->machine, data >> 4);
r8325r8326
70257025}
70267026
70277027/*************************************************************
7028
7028
70297029 Bootleg Board MXMDHTWO by TXC
70307030
70317031 Games: Commandos, Journey to the West, Ma Bu Mi Zhen &
70327032 Qu Wei Cheng Yu Wu, Si Lu Chuan Qi
7033
7033
70347034 Simple Mapper: writes to 0x8000-0xffff sets the prg32 bank.
70357035 Not sure if returning 0x50 for reads in 0x4100-0x5000 is correct.
7036
7036
70377037 iNES: mapper 241
7038
7038
70397039 In MESS: Supported.
7040
7040
70417041 *************************************************************/
70427042
70437043static READ8_HANDLER( txc_mxmdhtwo_l_r )
r8325r8326
70487048static WRITE8_HANDLER( txc_mxmdhtwo_w )
70497049{
70507050   LOG_MMC(("txc_mxmdhtwo_w, offset: %04x, data: %02x\n", offset, data));
7051   
7051
70527052   prg32(space->machine, data);
70537053}
70547054
70557055/*************************************************************
7056 
7057 Waixing Board Type A
70587056
7057 Waixing Board Type A
7058
70597059 Games: Columbus - Ougon no Yoake (C), Ji Jia Zhan Shi,
70607060 Jia A Fung Yun, Wei Luo Chuan Qi
7061
7061
70627062 This mapper is quite similar to MMC3, but with two differences:
70637063 mirroring is not the same, and when VROM banks 8,9 are accessed
70647064 they point to CHRRAM and not CHRROM.
7065
7065
70667066 iNES: mapper 74
7067
7067
70687068 In MESS: Supported
7069
7069
70707070 *************************************************************/
70717071
70727072/* MIRROR_LOW and MIRROR_HIGH are swapped! */
r8325r8326
70967096   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
70977097   UINT8 chr_src[6];
70987098   int i;
7099   
7099
71007100   for (i = 0; i < 6; i++)
71017101      chr_src[i] = ((state->mmc_vrom_bank[i] == 8) || (state->mmc_vrom_bank[i] == 9)) ? CHRRAM : CHRROM;
7102   
7102
71037103   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]);
71047104   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr_src[0]);
71057105   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]);
r8325r8326
71157115   nes_state *state = (nes_state *)space->machine->driver_data;
71167116   UINT8 MMC3_helper, cmd;
71177117   LOG_MMC(("waixing_a_w, offset: %04x, data: %02x\n", offset, data));
7118   
7118
71197119   switch (offset & 0x6001)
71207120   {
71217121      case 0x0000:
71227122         MMC3_helper = state->mmc_latch1 ^ data;
71237123         state->mmc_latch1 = data;
7124         
7124
71257125         /* Has PRG Mode changed? */
71267126         if (MMC3_helper & 0x40)
71277127            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7128         
7128
71297129         /* Has CHR Mode changed? */
71307130         if (MMC3_helper & 0x80)
71317131            waixing_a_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
71327132         break;
7133         
7133
71347134      case 0x0001:
71357135         cmd = state->mmc_latch1 & 0x07;
71367136         switch (cmd)
r8325r8326
71477147            break;
71487148         }
71497149         break;
7150         
7150
71517151      case 0x2000:
71527152         waixing_set_mirror(space->machine, data);   //maybe data & 0x03?
71537153         break;
7154         
7154
71557155      case 0x2001:
71567156         break;
7157         
7157
71587158      default:
71597159         txrom_w(space, offset, data);
71607160         break;
r8325r8326
71627162}
71637163
71647164/*************************************************************
7165
7165
71667166 Waixing Board Type B
7167
7167
71687168 Games: Sugoro Quest (C)
7169
7169
71707170 MMC3 clone. This is a minor modification of Mapper 74,
71717171 in the sense that it is the same board except for the
71727172 CHRRAM pages.
7173
7173
71747174 iNES: mapper 191
7175
7175
71767176 In MESS: Supported.
7177
7177
71787178 *************************************************************/
71797179
71807180static void waixing_b_set_chr( running_machine *machine, int chr_base, int chr_mask )
r8325r8326
71837183   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
71847184   UINT8 chr_src[6];
71857185   int i;
7186   
7186
71877187   for (i = 0; i < 6; i++)
71887188      chr_src[i] = (state->mmc_vrom_bank[i] & 0x80) ? CHRRAM : CHRROM;
7189   
7189
71907190   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]);
71917191   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr_src[0]);
71927192   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]);
r8325r8326
72027202   nes_state *state = (nes_state *)space->machine->driver_data;
72037203   UINT8 MMC3_helper, cmd;
72047204   LOG_MMC(("waixing_b_w, offset: %04x, data: %02x\n", offset, data));
7205   
7205
72067206   switch (offset & 0x6001)
72077207   {
72087208      case 0x0000:
72097209         MMC3_helper = state->mmc_latch1 ^ data;
72107210         state->mmc_latch1 = data;
7211         
7211
72127212         /* Has PRG Mode changed? */
72137213         if (MMC3_helper & 0x40)
72147214            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7215         
7215
72167216         /* Has CHR Mode changed? */
72177217         if (MMC3_helper & 0x80)
72187218            waixing_b_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
72197219         break;
7220         
7220
72217221      case 0x0001:
72227222         cmd = state->mmc_latch1 & 0x07;
72237223         switch (cmd)
r8325r8326
72347234            break;
72357235         }
72367236         break;
7237         
7237
72387238      default:
72397239         waixing_a_w(space, offset, data);
72407240         break;
r8325r8326
72427242}
72437243
72447244/*************************************************************
7245 
7246 Waixing Board Type C
7247 
7245
7246 Waixing Board Type C
7247
72487248 Games: Ying Lie Qun Xia Zhuan, Young Chivalry
7249
7249
72507250 MMC3 clone. This is a minor modification of Mapper 74,
72517251 in the sense that it is the same board except for the
72527252 CHRRAM pages.
7253
7253
72547254 iNES: mapper 192
7255
7255
72567256 In MESS: Supported.
7257
7257
72587258 *************************************************************/
72597259
72607260static void waixing_c_set_chr( running_machine *machine, int chr_base, int chr_mask )
r8325r8326
72637263   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
72647264   UINT8 chr_src[6];
72657265   int i;
7266   
7266
72677267   for (i = 0; i < 6; i++)
72687268      chr_src[i] = ((state->mmc_vrom_bank[i] == 0x08) || (state->mmc_vrom_bank[i] == 0x09) || (state->mmc_vrom_bank[i] == 0x0a) || (state->mmc_vrom_bank[i] == 0x0b)) ? CHRRAM : CHRROM;
7269   
7269
72707270   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]);
72717271   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr_src[0]);
72727272   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]);
r8325r8326
72827282   nes_state *state = (nes_state *)space->machine->driver_data;
72837283   UINT8 MMC3_helper, cmd;
72847284   LOG_MMC(("waixing_c_w, offset: %04x, data: %02x\n", offset, data));
7285   
7285
72867286   switch (offset & 0x6001)
72877287   {
72887288      case 0x0000:
72897289         MMC3_helper = state->mmc_latch1 ^ data;
72907290         state->mmc_latch1 = data;
7291         
7291
72927292         /* Has PRG Mode changed? */
72937293         if (MMC3_helper & 0x40)
72947294            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7295         
7295
72967296         /* Has CHR Mode changed? */
72977297         if (MMC3_helper & 0x80)
72987298            waixing_c_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
72997299         break;
7300         
7300
73017301      case 0x0001:
73027302         cmd = state->mmc_latch1 & 0x07;
73037303         switch (cmd)
r8325r8326
73147314            break;
73157315         }
73167316         break;
7317         
7317
73187318      default:
73197319         waixing_a_w(space, offset, data);
73207320         break;
r8325r8326
73227322}
73237323
73247324/*************************************************************
7325 
7326 Waixing Board Type D
7327 
7325
7326 Waixing Board Type D
7327
73287328 Games: Super Robot Taisen (C)
7329
7329
73307330 MMC3 clone. This is a minor modification of Mapper 74,
73317331 in the sense that it is the same board except for the
73327332 CHRRAM pages.
7333
7333
73347334 iNES: mapper 194
7335
7335
73367336 In MESS: Supported.
7337
7337
73387338 *************************************************************/
73397339
73407340static void waixing_d_set_chr( running_machine *machine, int chr_base, int chr_mask )
r8325r8326
73437343   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
73447344   UINT8 chr_src[6];
73457345   int i;
7346   
7346
73477347   for (i = 0; i < 6; i++)
73487348      chr_src[i] = (state->mmc_vrom_bank[i] < 0x02) ? CHRRAM : CHRROM;
7349   
7349
73507350   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]);
73517351   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr_src[0]);
73527352   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]);
r8325r8326
73627362   nes_state *state = (nes_state *)space->machine->driver_data;
73637363   UINT8 MMC3_helper, cmd;
73647364   LOG_MMC(("waixing_d_w, offset: %04x, data: %02x\n", offset, data));
7365   
7365
73667366   switch (offset & 0x6001)
73677367   {
73687368      case 0x0000:
73697369         MMC3_helper = state->mmc_latch1 ^ data;
73707370         state->mmc_latch1 = data;
7371         
7371
73727372         /* Has PRG Mode changed? */
73737373         if (MMC3_helper & 0x40)
73747374            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7375         
7375
73767376         /* Has CHR Mode changed? */
73777377         if (MMC3_helper & 0x80)
73787378            waixing_d_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
73797379         break;
7380         
7380
73817381      case 0x0001:
73827382         cmd = state->mmc_latch1 & 0x07;
73837383         switch (cmd)
r8325r8326
73947394            break;
73957395      }
73967396         break;
7397         
7397
73987398      default:
73997399         waixing_a_w(space, offset, data);
74007400         break;
r8325r8326
74027402}
74037403
74047404/*************************************************************
7405 
7406 Waixing Board Type E
7407 
7405
7406 Waixing Board Type E
7407
74087408 Games: Captain Tsubasa Vol. II (C), Chaos World, God
74097409 Slayer (C), Zu Qiu Xiao Jiang
7410
7410
74117411 MMC3 clone. This is a minor modification of Mapper 74,
74127412 in the sense that it is the same board except for the
74137413 CHRRAM pages.
7414
7414
74157415 iNES: mapper 195
7416
7416
74177417 In MESS: Supported.
7418
7418
74197419 *************************************************************/
74207420
74217421static void waixing_e_set_chr( running_machine *machine, int chr_base, int chr_mask )
r8325r8326
74247424   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
74257425   UINT8 chr_src[6];
74267426   int i;
7427   
7427
74287428   for (i = 0; i < 6; i++)
74297429      chr_src[i] = (state->mmc_vrom_bank[i] < 0x04) ? CHRRAM : CHRROM;
7430   
7430
74317431   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]);
74327432   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr_src[0]);
74337433   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]);
r8325r8326
74437443   nes_state *state = (nes_state *)space->machine->driver_data;
74447444   UINT8 MMC3_helper, cmd;
74457445   LOG_MMC(("waixing_e_w, offset: %04x, data: %02x\n", offset, data));
7446   
7446
74477447   switch (offset & 0x6001)
74487448   {
74497449      case 0x0000:
74507450         MMC3_helper = state->mmc_latch1 ^ data;
74517451         state->mmc_latch1 = data;
7452         
7452
74537453         /* Has PRG Mode changed? */
74547454         if (MMC3_helper & 0x40)
74557455            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7456         
7456
74577457         /* Has CHR Mode changed? */
74587458         if (MMC3_helper & 0x80)
74597459            waixing_e_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
74607460         break;
7461         
7461
74627462      case 0x0001:
74637463         cmd = state->mmc_latch1 & 0x07;
74647464         switch (cmd)
r8325r8326
74757475            break;
74767476      }
74777477         break;
7478         
7478
74797479      default:
74807480         waixing_a_w(space, offset, data);
74817481         break;
r8325r8326
74837483}
74847484
74857485/*************************************************************
7486 
7487 Waixing Board Type F
7488 
7486
7487 Waixing Board Type F
7488
74897489 Games: Tenchi wo Kurau II (C)
7490
7490
74917491 MMC3 clone.
7492
7492
74937493 iNES: mapper 198
7494
7494
74957495 In MESS: Preliminary support.
7496
7496
74977497 *************************************************************/
74987498
74997499static void waixing_f_set_prg( running_machine *machine, int prg_base, int prg_mask )
75007500{
75017501   nes_state *state = (nes_state *)machine->driver_data;
75027502   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
7503   
7503
75047504   prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
75057505   prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask));
75067506   prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
r8325r8326
75127512   nes_state *state = (nes_state *)space->machine->driver_data;
75137513   UINT8 MMC3_helper, cmd;
75147514   LOG_MMC(("waixing_f_w, offset: %04x, data: %02x\n", offset, data));
7515   
7515
75167516   switch (offset & 0x6001)
75177517   {
75187518      case 0x0000:
75197519         MMC3_helper = state->mmc_latch1 ^ data;
75207520         state->mmc_latch1 = data;
7521         
7521
75227522         /* Has PRG Mode changed? */
75237523         if (MMC3_helper & 0x40)
75247524            waixing_f_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7525         
7525
75267526         /* Has CHR Mode changed? */
75277527         if (MMC3_helper & 0x80)
75287528            mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
75297529         break;
7530         
7530
75317531      case 0x0001:
75327532         cmd = state->mmc_latch1 & 0x07;
75337533         switch (cmd)
r8325r8326
75447544            break;
75457545      }
75467546         break;
7547         
7547
75487548      default:
75497549         waixing_a_w(space, offset, data);
75507550         break;
r8325r8326
75527552}
75537553
75547554/*************************************************************
7555 
7556 Waixing Board Type G
7557 
7555
7556 Waixing Board Type G
7557
75587558 Games: San Guo Zhi 2, Dragon Ball Z Gaiden (C), Dragon
75597559 Ball Z II (C)
7560
7560
75617561 MMC3 clone
7562
7562
75637563 iNES: mapper 199
7564
7564
75657565 In MESS: Supported.
7566
7566
75677567 *************************************************************/
75687568
75697569static void waixing_g_set_chr( running_machine *machine, int chr_base, int chr_mask )
r8325r8326
75727572   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
75737573   UINT8 chr_src[8];
75747574   int i;
7575   
7575
75767576   for (i = 0; i < 8; i++)
75777577      chr_src[i] = (state->mmc_vrom_bank[i] < 0x08) ? CHRRAM : CHRROM;
7578   
7578
75797579   chr1_x(machine, chr_page ^ 0, chr_base | (state->mmc_vrom_bank[0] & chr_mask), chr_src[0]);
75807580   chr1_x(machine, chr_page ^ 1, chr_base | (state->mmc_vrom_bank[6] & chr_mask), chr_src[6]);
75817581   chr1_x(machine, chr_page ^ 2, chr_base | (state->mmc_vrom_bank[1] & chr_mask), chr_src[1]);
r8325r8326
75917591   nes_state *state = (nes_state *)space->machine->driver_data;
75927592   UINT8 MMC3_helper, cmd;
75937593   LOG_MMC(("waixing_g_w, offset: %04x, data: %02x\n", offset, data));
7594   
7594
75957595   switch (offset & 0x6001)
75967596   {
75977597      case 0x0000:
75987598         MMC3_helper = state->mmc_latch1 ^ data;
75997599         state->mmc_latch1 = data;
7600         
7600
76017601         /* Has PRG Mode changed? */
76027602         if (MMC3_helper & 0x40)
76037603            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
7604         
7604
76057605         /* Has CHR Mode changed? */
76067606         if (MMC3_helper & 0x80)
76077607            waixing_g_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
76087608         break;
7609         
7609
76107610      case 0x0001:
76117611         cmd = state->mmc_latch1 & 0x0f;
76127612         switch (cmd)
r8325r8326
76297629            break;
76307630      }
76317631         break;
7632         
7632
76337633      default:
76347634         txrom_w(space, offset, data);
76357635         break;
r8325r8326
76377637}
76387638
76397639/*************************************************************
7640 
7641 Waixing Board Type H
7642 
7640
7641 Waixing Board Type H
7642
76437643 Games: Ying Xiong Yuan Yi Jing Chuan Qi, Yong Zhe Dou E
76447644 Long - Dragon Quest VII
7645
7645
76467646 MMC3 clone. More info to come.
7647
7647
76487648 iNES: mapper 245
7649
7649
76507650 In MESS: Supported.
7651
7651
76527652 *************************************************************/
76537653
76547654static WRITE8_HANDLER( waixing_h_w )
r8325r8326
76567656   nes_state *state = (nes_state *)space->machine->driver_data;
76577657   UINT8 cmd, map245_helper;
76587658   LOG_MMC(("waixing_h_w, offset: %04x, data: %02x\n", offset, data));
7659   
7659
76607660   switch (offset & 0x6001)
76617661   {
76627662      case 0x0001:
r8325r8326
76857685            break;
76867686      }
76877687         break;
7688         
7688
76897689      case 0x2001:
76907690         break;
7691         
7691
76927692      default:
76937693         txrom_w(space, offset, data);
76947694         break;
r8325r8326
76967696}
76977697
76987698/*************************************************************
7699
7699
77007700 Waixing San Guo Zhi Board
7701
7701
77027702 Games: San Guo Zhi
7703
7703
77047704 This board uses Konami IRQ
7705
7705
77067706 iNES: mapper 252
7707
7707
77087708 In MESS: Unsupported.
7709
7709
77107710 *************************************************************/
77117711
77127712static WRITE8_HANDLER( waixing_sgz_w )
r8325r8326
77147714   nes_state *state = (nes_state *)space->machine->driver_data;
77157715   UINT8 mmc_helper, bank;
77167716   LOG_MMC(("waixing_sgz_w, offset: %04x, data: %02x\n", offset, data));
7717   
7717
77187718   switch (offset & 0x7000)
77197719   {
77207720      case 0x0000:
r8325r8326
77607760
77617761
77627762/*************************************************************
7763
7763
77647764 Waixing San Guo Zhong Lie Zhuan Board
7765
7765
77667766 Games: Fan Kong Jing Ying, San Guo Zhong Lie Zhuan, Xing
77677767 Ji Zheng Ba
7768
7768
77697769 iNES: mapper 178
7770
7770
77717771 In MESS: Supported.
7772
7772
77737773 *************************************************************/
77747774
77757775static WRITE8_HANDLER( waixing_sgzlz_l_w )
77767776{
77777777   nes_state *state = (nes_state *)space->machine->driver_data;
77787778   LOG_MMC(("waixing_sgzlz_l_w, offset: %04x, data: %02x\n", offset, data));
7779   
7779
77807780   switch (offset)
77817781   {
77827782      case 0x700:
r8325r8326
77937793}
77947794
77957795/*************************************************************
7796
7796
77977797 Waixing Final Fantasy V Board
7798
7798
77997799 Games: Darkseed, Digital Dragon, Final Fantasy V, Pocket
78007800 Monster Red
7801
7801
78027802 iNES: mapper 164
7803
7803
78047804 In MESS: Supported.
7805
7805
78067806 *************************************************************/
78077807
78087808static WRITE8_HANDLER( waixing_ffv_l_w )
78097809{
78107810   LOG_MMC(("waixing_ffv_l_w, offset: %04x, data: %02x\n", offset, data));
78117811   offset += 0x4100; /* the checks work better on addresses */
7812   
7812
78137813   if (0x5000 == (offset & 0x7300))
78147814      prg32(space->machine, data);
78157815}
r8325r8326
78227822}
78237823
78247824/*************************************************************
7825
7825
78267826 Waixing Zhan Shi Board
7827
7827
78287828 Games: Wai Xing Zhan Shi
7829
7829
78307830 Simple mapper: writes to 0x8000-0xffff sets prg32 banks to
78317831 (offset>>3)&f. written data&3 sets the mirroring (with
7832 switched high/low compared to the standard one). 
7833 
7832 switched high/low compared to the standard one).
7833
78347834 A crc check is required to support Dragon Quest VIII (which
78357835 uses a slightly different board)
7836
7836
78377837 iNES: mapper 242
7838
7838
78397839 In MESS: Supported.
7840
7840
78417841 *************************************************************/
78427842
78437843static WRITE8_HANDLER( waixing_zs_w )
78447844{
78457845   LOG_MMC(("waixing_zs_w, offset: %04x, data: %02x\n", offset, data));
7846   
7846
78477847   prg32(space->machine, offset >> 3);
7848   
7848
78497849   switch (data & 0x03)
78507850   {
78517851      case 0: set_nt_mirroring(space->machine, PPU_MIRROR_VERT); break;
r8325r8326
78567856}
78577857
78587858/*************************************************************
7859
7859
78607860 Waixing Dragon Quest VIII Board
7861
7861
78627862 Games: Dragon Quest VIII
7863
7863
78647864 Simple mapper: writes to 0x8000-0xffff sets prg32 banks to
78657865 (offset>>3)&f.
7866
7866
78677867 iNES: mapper 242
7868
7868
78697869 In MESS: Supported.
7870
7870
78717871 *************************************************************/
78727872
78737873static WRITE8_HANDLER( waixing_dq8_w )
78747874{
78757875   LOG_MMC(("waixing_dq8_w, offset: %04x, data: %02x\n", offset, data));
7876   
7876
78777877   prg32(space->machine, offset >> 3);
78787878}
78797879
78807880
78817881/*************************************************************
7882
7882
78837883 Waixing PS2 board
78847884
78857885 Games: Bao Xiao Tien Guo, Bio Hazard, Pokemon Gold, Subor (R)
7886
7886
78877887 iNES: mapper 15
7888
7888
78897889 In MESS: Supported
7890
7890
78917891 *************************************************************/
78927892
78937893static WRITE8_HANDLER( waixing_ps2_w )
78947894{
78957895   UINT8 map15_flip = (data & 0x80) >> 7;
78967896   UINT8 map15_helper = (data & 0x7f) << 1;
7897   
7897
78987898   LOG_MMC(("waixing_ps2_w, offset: %04x, data: %02x\n", offset, data));
7899   
7899
79007900   set_nt_mirroring(space->machine, BIT(data, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
7901   
7901
79027902   switch (offset & 0x0fff)
79037903   {
79047904      case 0x000:
r8325r8326
79327932}
79337933
79347934/*************************************************************
7935
7935
79367936 Waixing Board with Security Chip
7937 
7937
79387938 Games: Duo Bao Xiao Ying Hao - Guang Ming yu An Hei Chuan Shuo,
79397939 Myth Struggle, San Shi Liu Ji, Shui Hu Zhuan
7940
7940
79417941 MMC3 clone
7942
7942
79437943 iNES: mapper 249
7944
7944
79457945 In MESS: Partially Supported.
7946
7946
79477947 *************************************************************/
79487948
79497949static void waixing_sec_set_prg( running_machine *machine, int prg_base, int prg_mask )
79507950{
79517951   nes_state *state = (nes_state *)machine->driver_data;
79527952   int i;
7953   
7953
79547954   if (state->map249_reg)
79557955   {
79567956      for (i = 0; i < 4; i ++)   // should this apply only to bank[0],bank[1]?
r8325r8326
79597959         ((state->mmc_prg_bank[i] >> 1) & 0x04) | ((state->mmc_prg_bank[i] << 2) & 0x18);
79607960      }
79617961   }
7962   
7962
79637963   mmc3_set_prg(machine, prg_base, prg_mask);
79647964}
79657965
r8325r8326
79687968   nes_state *state = (nes_state *)machine->driver_data;
79697969   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
79707970   int i;
7971   
7971
79727972   if (state->map249_reg)
79737973   {
79747974      for (i = 0; i < 6; i ++)
r8325r8326
79787978         ((state->mmc_vrom_bank[i] << 3) & 0x20) | ((state->mmc_vrom_bank[i] << 2) & 0xc0);
79797979      }
79807980   }
7981   
7981
79827982   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), state->mmc_chr_source);
79837983   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), state->mmc_chr_source);
79847984   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), state->mmc_chr_source);
r8325r8326
79937993{
79947994   nes_state *state = (nes_state *)space->machine->driver_data;
79957995   LOG_MMC(("waixing_sec_l_w, offset: %04x, data: %02x\n", offset, data));
7996   
7996
79977997   offset += 0x100;
7998   
7998
79997999   if (offset == 0x1000)
80008000   {
80018001      state->map249_reg = data & 0x02;
r8325r8326
80098009   nes_state *state = (nes_state *)space->machine->driver_data;
80108010   UINT8 MMC3_helper, cmd;
80118011   LOG_MMC(("waixing_sec_w, offset: %04x, data: %02x\n", offset, data));
8012   
8012
80138013   switch (offset & 0x6001)
80148014   {
80158015      case 0x0000:
80168016         MMC3_helper = state->mmc_latch1 ^ data;
80178017         state->mmc_latch1 = data;
8018         
8018
80198019         /* Has PRG Mode changed? */
80208020         if (MMC3_helper & 0x40)
80218021            waixing_sec_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
8022         
8022
80238023         /* Has CHR Mode changed? */
80248024         if (MMC3_helper & 0x80)
80258025            waixing_sec_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
80268026         break;
8027         
8027
80288028      case 0x0001:
80298029         cmd = state->mmc_latch1 & 0x07;
80308030         switch (cmd)
r8325r8326
80418041            break;
80428042      }
80438043         break;
8044         
8044
80458045      default:
80468046         txrom_w(space, offset, data);
80478047         break;
r8325r8326
80498049}
80508050
80518051/*************************************************************
8052
8052
80538053 Board UNL-8237
8054
8054
80558055 Games: Pochahontas 2
8056
8056
80578057 MMC3 clone
8058
8058
80598059 In MESS: Not working
8060
8060
80618061 *************************************************************/
80628062
80638063static void unl_8237_set_prg( running_machine *machine )
80648064{
80658065   nes_state *state = (nes_state *)machine->driver_data;
80668066   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
8067   
8067
80688068   if (!(state->unl_8237_reg[0] & 0x80))
80698069   {
80708070      prg8_89(machine, state->mmc_prg_bank[0 ^ prg_flip]);
r8325r8326
80808080   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
80818081   UINT8 bank[8];
80828082   int i;
8083   
8083
80848084   for(i = 0; i < 6; i++)
80858085      bank[i] = state->mmc_vrom_bank[i] | ((state->unl_8237_reg[1] << 6) & 0x100);
8086   
8086
80878087   chr1_x(machine, chr_page ^ 0, (bank[0] & ~0x01), CHRROM);
80888088   chr1_x(machine, chr_page ^ 1, (bank[0] |  0x01), CHRROM);
80898089   chr1_x(machine, chr_page ^ 2, (bank[1] & ~0x01), CHRROM);
r8325r8326
80998099   nes_state *state = (nes_state *)space->machine->driver_data;
81008100   LOG_MMC(("unl_8237_l_w offset: %04x, data: %02x\n", offset, data));
81018101   offset += 0x100;
8102   
8102
81038103   if (offset == 0x1000)
81048104   {
81058105      state->unl_8237_reg[0] = data;
r8325r8326
81168116      else
81178117         unl_8237_set_prg(space->machine);
81188118   }
8119   
8119
81208120   if (offset == 0x1001)
81218121   {
81228122      state->unl_8237_reg[1] = data;
r8325r8326
81308130   UINT8 unl_8237_helper, cmd;
81318131   static const UINT8 conv_table[8] = {0,2,6,1,7,3,4,5};
81328132   LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data));
8133   
8133
81348134   switch (offset & 0x7000)
81358135   {
81368136      case 0x2000:
r8325r8326
81398139         data = (data & 0xc0) | conv_table[data & 0x07];
81408140         unl_8237_helper = state->mmc_latch1 ^ data;
81418141         state->mmc_latch1 = data;
8142         
8142
81438143         /* Has PRG Mode changed? */
81448144         if (unl_8237_helper & 0x40)
81458145            unl_8237_set_prg(space->machine);
8146         
8146
81478147         /* Has CHR Mode changed? */
81488148         if (unl_8237_helper & 0x80)
81498149            unl_8237_set_chr(space->machine);
81508150         break;
8151         
8151
81528152      case 0x4000:
81538153      case 0x5000:
81548154         if (state->unl_8237_reg[2])
r8325r8326
81708170            }
81718171         }
81728172         break;
8173         
8173
81748174      case 0x0000:
81758175      case 0x1000:
81768176         set_nt_mirroring(space->machine, (data | (data >> 7)) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
81778177         break;
8178         
8178
81798179      case 0x6000:
81808180         break;
8181         
8181
81828182      case 0x7000:
81838183         txrom_w(space, 0x6001, data);
81848184         txrom_w(space, 0x4000, data);
r8325r8326
81888188}
81898189
81908190/*************************************************************
8191
8191
81928192 Board UNL-AX5705
8193
8193
81948194 Games: Super Mario Bros. Pocker Mali (Crayon Shin-chan pirate hack)
8195
8195
81968196 In MESS: Supported
8197
8197
81988198 *************************************************************/
81998199
82008200static void unl_ax5705_set_prg( running_machine *machine )
r8325r8326
82098209   nes_state *state = (nes_state *)space->machine->driver_data;
82108210   UINT8 bank;
82118211   LOG_MMC(("unl_ax5705_w offset: %04x, data: %02x\n", offset, data));
8212   
8212
82138213   switch (offset & 0x700f)
82148214   {
82158215      case 0x0000:
r8325r8326
82618261}
82628262
82638263/*************************************************************
8264
8264
82658265 Board UNL-CC-21
8266
8266
82678267 Games: Mi Hun Che
8268
8268
82698269 In MESS: Supported
8270
8270
82718271 *************************************************************/
82728272
82738273static WRITE8_HANDLER( unl_cc21_w )
82748274{
82758275   LOG_MMC(("unl_cc21_w offset: %04x, data: %02x\n", offset, data));
8276   
8276
82778277   set_nt_mirroring(space->machine, BIT(data, 1) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
82788278   chr8(space->machine, (offset & 0x01), CHRROM);
82798279}
82808280
82818281/*************************************************************
8282
8282
82838283 Board UNL-KOF97
8284
8284
82858285 Games: King of Fighters 97 (Rex Soft)
8286
8286
82878287 MMC3 clone
8288
8288
82898289 In MESS: Not working
8290
8290
82918291 *************************************************************/
82928292
82938293static UINT8 unl_kof97_unscramble( UINT8 data )
r8325r8326
82988298static WRITE8_HANDLER( unl_kof97_w )
82998299{
83008300   LOG_MMC(("unl_kof97_w offset: %04x, data: %02x\n", offset, data));
8301   
8301
83028302   /* Addresses 0x9000, 0xa000, 0xd000 & 0xf000 behaves differently than MMC3 */
83038303   if (offset == 0x1000)
83048304   {
r8325r8326
83408340}
83418341
83428342/*************************************************************
8343
8343
83448344 Board UNL-T-230
8345
8345
83468346 Games: Dragon Ball Z IV (Unl)
8347
8347
83488348 In MESS: Supported
8349
8349
83508350 *************************************************************/
83518351
83528352static WRITE8_HANDLER( unl_t230_w )
r8325r8326
83548354   nes_state *state = (nes_state *)space->machine->driver_data;
83558355   UINT8 bank;
83568356   LOG_MMC(("unl_t230_w offset: %04x, data: %02x\n", offset, data));
8357   
8357
83588358   switch (offset & 0x700c)
83598359   {
83608360      case 0x0000:
r8325r8326
83638363         prg16_89ab(space->machine, data);
83648364         break;
83658365
8366      // the part below works like VRC-2. how was the original board wired up?
8366      // the part below works like VRC-2. how was the original board wired up?
83678367      // was there a VRC2? if so, we can use VRC-2 and add proper pin settings to xml!
83688368      case 0x1000:
83698369      case 0x1004:
r8325r8326
83998399            state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & 0x0f) | (data << 4);
84008400         else
84018401            state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
8402         
8402
84038403         chr1_x(space->machine, bank, state->mmc_vrom_bank[bank], state->mmc_chr_source);
84048404         break;
84058405      case 0x7000:
r8325r8326
84178417         if (data & 0x02)
84188418            state->IRQ_count = state->IRQ_count_latch;
84198419         break;
8420         
8420
84218421      default:
84228422         logerror("unl_t230_w uncaught offset: %04x value: %02x\n", offset, data);
84238423         break;
r8325r8326
84258425}
84268426
84278427/*************************************************************
8428
8428
84298429 Bootleg Board for KOF96
84308430
84318431 Games: The King of Fighters 96, Sonic 3D Blast 6, Street
84328432 Fighter Zero 2
8433
8433
84348434 MMC3 clone
8435
8435
84368436 iNES: mapper 187
8437
8437
84388438 In MESS: Preliminary Support.
8439
8439
84408440 *************************************************************/
84418441
84428442static void kof96_set_prg( running_machine *machine, int prg_base, int prg_mask )
84438443{
84448444   nes_state *state = (nes_state *)machine->driver_data;
84458445   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
8446   
8446
84478447   if (!(state->mapper187_reg[0] & 0x80))
84488448   {
84498449      prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
r8325r8326
84598459   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
84608460   UINT8 new_base[8];
84618461   int i;
8462   
8462
84638463   for (i = 0; i < 8; i++)
84648464      new_base[i] = ((i & 0x04) == chr_page)? (chr_base | 0x100) : chr_base;
8465   
8465
84668466   chr1_x(machine, chr_page ^ 0, new_base[0] | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
84678467   chr1_x(machine, chr_page ^ 1, new_base[1] | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
84688468   chr1_x(machine, chr_page ^ 2, new_base[2] | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
r8325r8326
84798479   UINT8 new_bank;
84808480   LOG_MMC(("kof96_l_w, offset: %04x, data: %02x\n", offset, data));
84818481   offset += 0x100;
8482   
8482
84838483   if (offset == 0x1000)
84848484   {
84858485      switch (data & 0x03)
r8325r8326
84968496            break;
84978497      }
84988498   }
8499   
8499
85008500   if (!(offset <= 0x1000))
85018501   {
85028502      state->mapper187_reg[0] = data;
8503     
8503
85048504      if (state->mapper187_reg[0] & 0x80)
85058505      {
85068506         new_bank = (state->mapper187_reg[0] & 0x1f);
8507         
8507
85088508         if (state->mapper187_reg[0] & 0x20)
85098509            prg32(space->machine, new_bank >> 2);
85108510         else
r8325r8326
85238523   nes_state *state = (nes_state *)space->machine->driver_data;
85248524   LOG_MMC(("kof96_l_r, offset: %04x\n", offset));
85258525   offset += 0x100;
8526   
8526
85278527   if (!(offset < 0x1000))
85288528      return state->mapper187_reg[1];
85298529   else
r8325r8326
85358535   nes_state *state = (nes_state *)space->machine->driver_data;
85368536   UINT8 MMC3_helper, cmd;
85378537   LOG_MMC(("kof96_w, offset: %04x, data: %02x\n", offset, data));
8538   
8538
85398539   switch (offset & 0x6003)
85408540   {
85418541      case 0x0000:
85428542         state->mapper187_reg[2] = 1;
85438543         MMC3_helper = state->mmc_latch1 ^ data;
85448544         state->mmc_latch1 = data;
8545         
8545
85468546         /* Has PRG Mode changed? */
85478547         if (MMC3_helper & 0x40)
85488548            kof96_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
8549         
8549
85508550         /* Has CHR Mode changed? */
85518551         if (MMC3_helper & 0x80)
85528552            kof96_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
85538553         break;
8554         
8554
85558555      case 0x0001:
85568556         if (state->mapper187_reg[2])
85578557         {
r8325r8326
85718571            }
85728572         }
85738573         break;
8574         
8574
85758575      case 0x0002:
85768576         break;
8577         
8577
85788578      case 0x0003:
85798579         state->mapper187_reg[2] = 0;
8580         
8580
85818581         if (data == 0x28)
85828582            prg8_cd(space->machine, 0x17);
85838583         else if (data == 0x2a)
85848584            prg8_ab(space->machine, 0x0f);
85858585         break;
8586         
8586
85878587      default:
85888588         txrom_w(space, offset, data);
85898589         break;
r8325r8326
85918591}
85928592
85938593/*************************************************************
8594
8594
85958595 Bootleg Board for MK2
85968596
85978597 Games: Mortal Kombat II, Street Fighter III, Super Mario
85988598 Kart Rider
8599
8599
86008600 This board uses an IRQ system very similar to MMC3. We indeed
86018601 use mapper4_irq, but there is some small glitch!
8602
8602
86038603 iNES: mapper 91
8604
8604
86058605 In MESS: Supported.
8606
8606
86078607 *************************************************************/
86088608
86098609static WRITE8_HANDLER( mk2_m_w )
86108610{
86118611   nes_state *state = (nes_state *)space->machine->driver_data;
86128612   LOG_MMC(("mk2_m_w, offset: %04x, data: %02x\n", offset, data));
8613   
8613
86148614   switch (offset & 0x1000)
86158615   {
86168616      case 0x0000:
r8325r8326
86388638}
86398639
86408640/*************************************************************
8641
8641
86428642 Bootleg Board N625092
86438643
86448644 Games: 400 in 1, 700 in 1, 1000 in 1
8645
8645
86468646 iNES: mapper 221
8647
8647
86488648 In MESS: Supported.
8649
8649
86508650 *************************************************************/
86518651
86528652static void n625092_set_prg( running_machine *machine, UINT8 reg1, UINT8 reg2 )
86538653{
86548654   UINT8 map221_helper1, map221_helper2;
8655   
8655
86568656   map221_helper1 = !(reg1 & 0x01) ? reg2 :
86578657   (reg1 & 0x80) ? reg2 : (reg2 & 0x06) | 0x00;
86588658   map221_helper2 = !(reg1 & 0x01) ? reg2 :
86598659   (reg1 & 0x80) ? 0x07 : (reg2 & 0x06) | 0x01;
8660   
8660
86618661   prg16_89ab(machine, map221_helper1 | ((reg1 & 0x70) >> 1));
86628662   prg16_cdef(machine, map221_helper2 | ((reg1 & 0x70) >> 1));
86638663}
r8325r8326
86668666{
86678667   nes_state *state = (nes_state *)space->machine->driver_data;
86688668   LOG_MMC(("n625092_w, offset: %04x, data: %02x\n", offset, data));
8669   
8669
86708670   if (offset < 0x4000)
86718671   {
86728672      set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
86738673      offset = (offset >> 1) & 0xff;
8674     
8674
86758675      if (state->mmc_latch1 != offset)
86768676      {
86778677         state->mmc_latch1 = offset;
r8325r8326
86818681   else
86828682   {
86838683      offset &= 0x07;
8684     
8684
86858685      if (state->mmc_latch2 != offset)
86868686      {
86878687         state->mmc_latch2 = offset;
r8325r8326
86918691}
86928692
86938693/*************************************************************
8694
8694
86958695 SC-127 Board
86968696
86978697 Games: Wario World II (Kirby Hack)
8698
8698
86998699 iNES: mapper 35
8700
8700
87018701 In MESS: Supported
8702
8702
87038703 *************************************************************/
87048704
87058705static void sc127_irq( running_device *device, int scanline, int vblank, int blanked )
87068706{
87078707   nes_state *state = (nes_state *)device->machine->driver_data;
8708   
8708
87098709   if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE && state->IRQ_enable)
87108710   {
87118711      state->IRQ_count--;
8712     
8712
87138713      if (!blanked && (state->IRQ_count == 0))
87148714      {
87158715         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
r8325r8326
87248724{
87258725   nes_state *state = (nes_state *)space->machine->driver_data;
87268726   LOG_MMC(("sc127_w, offset: %04x, data: %02x\n", offset, data));
8727   
8727
87288728   switch (offset)
87298729   {
87308730      case 0x0000:
r8325r8326
87648764}
87658765
87668766/*************************************************************
8767
8767
87688768 Bootleg Board SMB2J
87698769
87708770 Games: Super Mario Bros. 2 Pirate (LF36)
8771
8771
87728772 iNES: mapper 43
8773
8773
87748774 In MESS: Supported? The only image I found is not working
87758775 (not even in NEStopia).
8776
8776
87778777 *************************************************************/
87788778
87798779static WRITE8_HANDLER( smb2j_w )
87808780{
87818781   nes_state *state = (nes_state *)space->machine->driver_data;
87828782   int bank = (((offset >> 8) & 0x03) * 0x20) + (offset & 0x1f);
8783   
8783
87848784   LOG_MMC(("smb2j_w, offset: %04x, data: %02x\n", offset, data));
8785   
8785
87868786   set_nt_mirroring(space->machine, (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
8787   
8787
87888788   if (offset & 0x0800)
87898789   {
87908790      if (offset & 0x1000)
r8325r8326
88328832}
88338833
88348834/*************************************************************
8835
8835
88368836 BTL-SMB2B
8837
8837
88388838 Games: Super Mario Bros. 2 Pirate (Jpn version of SMB2)
8839
8839
88408840 This was marked as Alt. Levels. is it true?
8841
8841
88428842 iNES: mapper 50
88438843
88448844 In MESS: Supported.
8845
8845
88468846 *************************************************************/
88478847
88488848static void smb2jb_irq( running_device *device, int scanline, int vblank, int blanked )
r8325r8326
88598859      }
88608860      else
88618861         state->IRQ_count += 114;
8862     
8862
88638863      state->IRQ_count &= 0xffff;   // according to docs is 16bit counter -> it wraps only after 0xffff
88648864   }
88658865}
r8325r8326
88708870   UINT8 prg;
88718871   LOG_MMC(("smb2jb_l_w, offset: %04x, data: %02x\n", offset, data));
88728872   offset += 0x100;
8873   
8873
88748874   switch (offset & 0x160)
88758875   {
88768876      case 0x020:
r8325r8326
88888888{
88898889   UINT8 prg;
88908890   LOG_MMC(("smb2jb_extra_w, offset: %04x, data: %02x\n", offset, data));
8891   
8891
88928892   prg = (data & 0x08) | ((data & 0x06) >> 1) | ((data & 0x01) << 2);
88938893   prg8_cd(space->machine, prg);
88948894}
88958895
88968896/*************************************************************
8897
8897
88988898 Bootleg Board for Super Fighter III
8899
8899
89008900 MMC3 clone
8901
8901
89028902 In MESS: Supported.
8903
8903
89048904 *************************************************************/
89058905
89068906static void unl_sf3_set_chr( running_machine *machine, UINT8 chr_source, int chr_base, int chr_mask )
r8325r8326
89168916   nes_state *state = (nes_state *)space->machine->driver_data;
89178917   UINT8 MMC3_helper, cmd;
89188918   LOG_MMC(("unl_sf3_w, offset: %04x, data: %02x\n", offset, data));
8919   
8919
89208920   switch (offset & 0x6001)
89218921   {
89228922      case 0x0000:
89238923         MMC3_helper = state->mmc_latch1 ^ data;
89248924         state->mmc_latch1 = data;
8925         
8925
89268926         /* Has PRG Mode changed? */
89278927         if (MMC3_helper & 0x40)
89288928            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
8929         
8929
89308930         /* Has CHR Mode changed? */
89318931         if (MMC3_helper & 0x80)
89328932            unl_sf3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
89338933         break;
8934         
8934
89358935      case 0x0001:
89368936         cmd = state->mmc_latch1 & 0x0f;
89378937         switch (cmd)
r8325r8326
89478947            break;
89488948      }
89498949         break;
8950         
8950
89518951      default:
89528952         txrom_w(space, offset, data);
89538953         break;
r8325r8326
89558955}
89568956
89578957/*************************************************************
8958
8958
89598959 Bootleg Board for Xiao Zhuan Yuan
89608960
89618961 Games: Shu Qi Yu - Zhi Li Xiao Zhuan Yuan
8962
8962
89638963 Very simple mapper: writes to 0x5ff1 set prg32 (to data>>1),
89648964 while writes to 0x5ff2 set chr8
8965
8965
89668966 iNES: mapper 176
8967
8967
89688968 In MESS: Supported.
8969
8969
89708970 *************************************************************/
89718971
89728972static WRITE8_HANDLER( unl_xzy_l_w )
89738973{
89748974   LOG_MMC(("unl_xzy_l_w, offset: %04x, data: %02x\n", offset, data));
8975   
8975
89768976   switch (offset)
89778977   {
89788978      case 0x1ef1:   /* 0x5ff1 */
r8325r8326
89858985}
89868986
89878987/*************************************************************
8988
8988
89898989 Board UNL-RACERMATE
8990 
8990
89918991 In MESS: *VERY* preliminary support. Also, it seems that this
89928992 board saves to battery the CHRRAM!!!
8993
8993
89948994 *************************************************************/
89958995
89968996static void racmate_update_banks( running_machine *machine )
r8325r8326
90139013}
90149014
90159015/*************************************************************
9016
9016
90179017        BOOTLEG CART VERSIONS OF FDS GAMES
9018
9018
90199019 *************************************************************/
90209020
90219021/*************************************************************
9022
9022
90239023 BTL-SUPERBROS11
9024
9024
90259025 Known Boards: Unknown Bootleg Board
90269026 Games: Super Mario Bros. 11, Super Mario Bros. 17
9027
9027
90289028 This acts basically like a MMC3 with different use of write
90299029 address.
9030
9030
90319031 iNES: mapper 196
9032
9032
90339033 In MESS: Supported.
9034
9034
90359035 *************************************************************/
90369036
90379037static WRITE8_HANDLER( btl_smb11_w )
90389038{
90399039   LOG_MMC(("btl_smb11_w, offset: %04x, data: %02x\n", offset, data));
9040   
9040
90419041   txrom_w(space, (offset & 0x6000) | ((offset & 0x04) >> 2), data);
90429042}
90439043
90449044/*************************************************************
9045
9045
90469046 BTL-MARIOBABY
9047
9047
90489048 Known Boards: Unknown Bootleg Board
90499049 Games: Mario Baby, Ai Senshi Nicol
9050
9050
90519051 iNES: mapper 42
90529052
90539053 In MESS: Supported.
9054
9054
90559055 *************************************************************/
90569056
90579057// is the code fine for ai senshi nicol?!?
r8325r8326
90599059{
90609060   nes_state *state = (nes_state *)space->machine->driver_data;
90619061   LOG_MMC(("btl_mariobaby_w, offset: %04x, data: %02x\n", offset, data));
9062   
9062
90639063   if (offset >= 0x7000)
90649064   {
90659065      switch(offset & 0x03)
r8325r8326
90889088}
90899089
90909090/*************************************************************
9091
9091
90929092 BTL-SMB2A
9093
9093
90949094 Known Boards: Unknown Bootleg Board
90959095 Games: Super Mario Bros. 2 Pirate (Jpn version of SMB2)
9096
9096
90979097 iNES: mapper 40
9098
9098
90999099 In MESS: Supported.
9100
9100
91019101 *************************************************************/
91029102
91039103static void btl_smb2a_irq( running_device *device, int scanline, int vblank, int blanked )
91049104{
91059105   nes_state *state = (nes_state *)device->machine->driver_data;
9106   
9106
91079107   if (state->IRQ_enable)
91089108   {
91099109      if ((0xfff - state->IRQ_count) <= 114)
r8325r8326
91219121{
91229122   nes_state *state = (nes_state *)space->machine->driver_data;
91239123   LOG_MMC(("btl_smb2a_w, offset: %04x, data: %02x\n", offset, data));
9124   
9124
91259125   switch (offset & 0x6000)
91269126   {
91279127      case 0x0000:
r8325r8326
91389138}
91399139
91409140/*************************************************************
9141
9141
91429142 BTL-SMB3
9143
9143
91449144 Known Boards: Unknown Bootleg Board
91459145 Games: Super Mario Bros. 3 Pirate
9146
9146
91479147 iNES: mapper 106
9148
9148
91499149 In MESS: Supported.
9150
9150
91519151 *************************************************************/
91529152
91539153static void btl_smb3_irq( running_device *device, int scanline, int vblank, int blanked )
91549154{
91559155   nes_state *state = (nes_state *)device->machine->driver_data;
9156   
9156
91579157   if (state->IRQ_enable)
91589158   {
91599159      if ((0xffff - state->IRQ_count) < 114)
r8325r8326
91619161         cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE);
91629162         state->IRQ_enable = 0;
91639163      }
9164     
9164
91659165      state->IRQ_count = (state->IRQ_count + 114) & 0xffff;
91669166   }
91679167}
r8325r8326
92149214}
92159215
92169216/*************************************************************
9217
9217
92189218 BTL-DRAGONNINJA
9219
9219
92209220 Known Boards: Unknown Bootleg Board
92219221 Games: Dragon Ninja (Bootleg), Super Mario Bros. 8
9222
9222
92239223 iNES: mapper 222
9224
9224
92259225 In MESS: Unsupported.
9226
9226
92279227 *************************************************************/
92289228
92299229/* Scanline based IRQ ? */
r8325r8326
92349234   {
92359235      if (!state->IRQ_count || ++state->IRQ_count < 240)
92369236         return;
9237     
9237
92389238      state->IRQ_count = 0;
92399239      LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
92409240             device->machine->primary_screen->vpos(), device->machine->primary_screen->hpos()));
r8325r8326
92479247   nes_state *state = (nes_state *)space->machine->driver_data;
92489248   UINT8 bank;
92499249   LOG_MMC(("btl_dn_w, offset: %04x, data: %02x\n", offset, data));
9250   
9250
92519251   switch (offset & 0x7003)
92529252   {
92539253      case 0x0000:
r8325r8326
92839283 *************************************************************/
92849284
92859285/*************************************************************
9286
9286
92879287 Board BMC-64IN1NOREPEAT
9288
9288
92899289 Games: 64-in-1 Y2K
9290
9290
92919291 In MESS: Supported
9292
9292
92939293 *************************************************************/
92949294
92959295static void bmc_64in1nr_set_prg( running_machine *machine )
r8325r8326
92979297   nes_state *state = (nes_state *)machine->driver_data;
92989298   UINT8 helper1 = (state->bmc_64in1nr_reg[1] & 0x1f);
92999299   UINT8 helper2 = (helper1 << 1) | ((state->bmc_64in1nr_reg[1] & 0x40) >> 6);
9300   
9300
93019301   if (state->bmc_64in1nr_reg[0] & 0x80)
93029302   {
93039303      if (state->bmc_64in1nr_reg[1] & 0x80)
r8325r8326
93179317   nes_state *state = (nes_state *)space->machine->driver_data;
93189318   LOG_MMC(("bmc_64in1nr_l_w offset: %04x, data: %02x\n", offset, data));
93199319   offset += 0x100;
9320   
9320
93219321   switch (offset)
93229322   {
93239323      case 0x1000:
r8325r8326
93379337{
93389338   nes_state *state = (nes_state *)space->machine->driver_data;
93399339   LOG_MMC(("bmc_64in1nr_w offset: %04x, data: %02x\n", offset, data));
9340   
9340
93419341   state->bmc_64in1nr_reg[3] = data;   // reg[3] is currently unused?!?
93429342}
93439343
93449344/*************************************************************
9345
9345
93469346 Board BMC-190IN1
9347
9347
93489348 Games: 190-in-1
9349
9349
93509350 In MESS: Supported
9351
9351
93529352 *************************************************************/
93539353
93549354static WRITE8_HANDLER( bmc_190in1_w )
93559355{
93569356   LOG_MMC(("bmc_190in1_w offset: %04x, data: %02x\n", offset, data));
9357   
9357
93589358   set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
93599359   data >>= 2;
93609360   prg16_89ab(space->machine, data);
r8325r8326
93639363}
93649364
93659365/*************************************************************
9366
9366
93679367 Board BMC-A65AS
9368
9368
93699369 Games: 3-in-1 (N068)
9370
9370
93719371 In MESS: Supported
9372
9372
93739373 *************************************************************/
93749374
93759375static WRITE8_HANDLER( bmc_a65as_w )
93769376{
93779377   UINT8 helper = (data & 0x30) >> 1;
93789378   LOG_MMC(("bmc_a65as_w offset: %04x, data: %02x\n", offset, data));
9379   
9379
93809380   if (data & 0x80)
93819381      set_nt_mirroring(space->machine, BIT(data, 5) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
93829382   else
93839383      set_nt_mirroring(space->machine, BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9384   
9384
93859385   if (data & 0x40)
93869386      prg32(space->machine, data >> 1);
93879387   else
r8325r8326
93929392}
93939393
93949394/*************************************************************
9395
9395
93969396 Board BMC-GS2004
9397
9397
93989398 Games: Tetris Family 6-in-1
9399
9399
94009400 In MESS: Preliminary Support. It also misses WRAM handling
94019401 (we need reads from 0x6000-0x7fff)
9402
9402
94039403 *************************************************************/
94049404
94059405static WRITE8_HANDLER( bmc_gs2004_w )
94069406{
94079407   LOG_MMC(("bmc_gs2004_w offset: %04x, data: %02x\n", offset, data));
9408   
9408
94099409   prg32(space->machine, data);
94109410}
94119411
94129412/*************************************************************
9413
9413
94149414 Board BMC-GS2013
9415
9415
94169416 Games: Tetris Family 12-in-1
9417
9417
94189418 In MESS: Preliminary Support. It also misses WRAM handling
94199419 (we need reads from 0x6000-0x7fff)
9420
9420
94219421 *************************************************************/
94229422
94239423static WRITE8_HANDLER( bmc_gs2013_w )
94249424{
94259425   LOG_MMC(("bmc_gs2013_w offset: %04x, data: %02x\n", offset, data));
9426   
9426
94279427   if (data & 0x08)
94289428      prg32(space->machine, data & 0x09);
94299429   else
r8325r8326
94319431}
94329432
94339433/*************************************************************
9434
9434
94359435 Board BMC-SUPER24IN1SC03
9436
9436
94379437 Games: Super 24-in-1
9438
9438
94399439 In MESS: Supported
9440
9440
94419441 *************************************************************/
94429442
94439443static void bmc_s24in1sc03_set_prg( running_machine *machine )
r8325r8326
94479447   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
94489448   int prg_base = state->bmc_s24in1sc03_reg[1] << 1;
94499449   int prg_mask = masks[state->bmc_s24in1sc03_reg[0] & 0x07];
9450   
9450
94519451   prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask));
94529452   prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask));
94539453   prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask));
r8325r8326
94609460   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
94619461   UINT8 chr = (state->bmc_s24in1sc03_reg[0] & 0x20) ? CHRRAM : CHRROM;
94629462   int chr_base = (state->bmc_s24in1sc03_reg[2] << 3) & 0xf00;
9463   
9463
94649464   chr1_x(machine, chr_page ^ 0, chr_base | (state->mmc_vrom_bank[0] & ~0x01), chr);
94659465   chr1_x(machine, chr_page ^ 1, chr_base | (state->mmc_vrom_bank[0] |  0x01), chr);
94669466   chr1_x(machine, chr_page ^ 2, chr_base | (state->mmc_vrom_bank[1] & ~0x01), chr);
r8325r8326
94769476   nes_state *state = (nes_state *)space->machine->driver_data;
94779477   LOG_MMC(("bmc_s24in1sc03_l_w offset: %04x, data: %02x\n", offset, data));
94789478   offset += 0x100;
9479   
9479
94809480   if (offset == 0x1ff0)
94819481   {
94829482      state->bmc_s24in1sc03_reg[0] = data;
94839483      bmc_s24in1sc03_set_prg(space->machine);
94849484      bmc_s24in1sc03_set_chr(space->machine);
94859485   }
9486   
9486
94879487   if (offset == 0x1ff1)
94889488   {
94899489      state->bmc_s24in1sc03_reg[1] = data;
94909490      bmc_s24in1sc03_set_prg(space->machine);
94919491   }
9492   
9492
94939493   if (offset == 0x1ff2)
94949494   {
94959495      state->bmc_s24in1sc03_reg[2] = data;
r8325r8326
95029502   nes_state *state = (nes_state *)space->machine->driver_data;
95039503   UINT8 cmd, bmc_s24in1sc03_helper;
95049504   LOG_MMC(("bmc_s24in1sc03_w offset: %04x, data: %02x\n", offset, data));
9505   
9505
95069506   switch (offset & 0x6001)
95079507   {
95089508      case 0x0000:
95099509         bmc_s24in1sc03_helper = state->mmc_latch1 ^ data;
95109510         state->mmc_latch1 = data;
9511         
9511
95129512         /* Has PRG Mode changed? */
95139513         if (bmc_s24in1sc03_helper & 0x40)
95149514            bmc_s24in1sc03_set_prg(space->machine);
9515         
9515
95169516         /* Has CHR Mode changed? */
95179517         if (bmc_s24in1sc03_helper & 0x80)
95189518            bmc_s24in1sc03_set_chr(space->machine);
95199519         break;
9520         
9520
95219521      case 0x0001:
95229522         cmd = state->mmc_latch1 & 0x07;
95239523         switch (cmd)
r8325r8326
95349534            break;
95359535      }
95369536         break;
9537         
9537
95389538      default:
95399539         txrom_w(space, offset, data);
95409540         break;
r8325r8326
95429542}
95439543
95449544/*************************************************************
9545
9545
95469546 Board BMC-T-262
9547
9547
95489548 Games: 4-in-1 (D-010), 8-in-1 (A-020)
9549
9549
95509550 In MESS: Supported
9551
9551
95529552 *************************************************************/
95539553
95549554static WRITE8_HANDLER( bmc_t262_w )
r8325r8326
95569556   nes_state *state = (nes_state *)space->machine->driver_data;
95579557   UINT8 mmc_helper;
95589558   LOG_MMC(("bmc_t262_w offset: %04x, data: %02x\n", offset, data));
9559   
9559
95609560   if (state->mmc_latch2 || offset == 0)
95619561   {
95629562      state->mmc_latch1 = (state->mmc_latch1 & 0x38) | (data & 0x07);
r8325r8326
95749574}
95759575
95769576/*************************************************************
9577
9577
95789578 Board BMC-WS
9579
9579
95809580 Games: Super 40-in-1
9581
9581
95829582 In MESS: Supported
9583
9583
95849584 *************************************************************/
95859585
95869586static WRITE8_HANDLER( bmc_ws_m_w )
r8325r8326
95889588   nes_state *state = (nes_state *)space->machine->driver_data;
95899589   UINT8 mmc_helper;
95909590   LOG_MMC(("bmc_ws_m_w offset: %04x, data: %02x\n", offset, data));
9591   
9591
95929592   if (offset < 0x1000)
95939593   {
95949594      switch (offset & 0x01)
r8325r8326
96149614}
96159615
96169616/*************************************************************
9617
9617
96189618 BMC-NOVELDIAMOND and BMC-999999in1
9619
9619
96209620 Unknown Bootleg Multigame Board
96219621 Games: I only found 'Novel Diamond 999999-in-1.unf' using
96229622 this mapper (hence the code is used for BMC_NOVELDIAMOND
96239623 board). The code is included here in case a mapper 54
96249624 dump arises.
9625
9625
96269626 iNES: 54 and 213
96279627
96289628 In MESS: Partial Support.
9629
9629
96309630 *************************************************************/
96319631
96329632// Are this correct or should they work the same?
96339633static WRITE8_HANDLER( novel1_w )
96349634{
96359635   LOG_MMC(("novel1_w, offset: %04x, data: %02x\n", offset, data));
9636   
9636
96379637   prg32(space->machine, offset & 0x03);
96389638   chr8(space->machine, offset & 0x07, CHRROM);
96399639}
r8325r8326
96419641static WRITE8_HANDLER( novel2_w )
96429642{
96439643   LOG_MMC(("novel2_w, offset: %04x, data: %02x\n", offset, data));
9644   
9644
96459645   prg32(space->machine, offset >> 1);
96469646   chr8(space->machine, offset >> 3, CHRROM);
96479647}
96489648
96499649/*************************************************************
9650
9650
96519651 Board BMC-GKA
9652
9652
96539653 Unknown Bootleg Multigame Board
96549654 Games: 6 in 1, 54 in 1, 106 in 1
9655
9655
96569656 iNES: mapper 57
96579657
96589658 In MESS: Supported.
9659
9659
96609660 *************************************************************/
96619661
96629662static WRITE8_HANDLER( bmc_gka_w )
96639663{
96649664   nes_state *state = (nes_state *)space->machine->driver_data;
96659665   LOG_MMC(("bmc_gka_w, offset: %04x, data: %02x\n", offset, data));
9666   
9666
96679667   if (offset & 0x0800)
96689668      state->mmc_latch2 = data;
96699669   else
96709670      state->mmc_latch1 = data;
9671   
9671
96729672   if (state->mmc_latch2 & 0x80)
96739673      prg32(space->machine, 2 | (state->mmc_latch2 >> 6));
96749674   else
r8325r8326
96769676      prg16_89ab(space->machine, (state->mmc_latch2 >> 5) & 0x03);
96779677      prg16_cdef(space->machine, (state->mmc_latch2 >> 5) & 0x03);
96789678   }
9679   
9679
96809680   set_nt_mirroring(space->machine, (state->mmc_latch2 & 0x08) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9681   
9681
96829682   chr8(space->machine, (state->mmc_latch1 & 0x03) | (state->mmc_latch2 & 0x07) | ((state->mmc_latch2 & 0x10) >> 1), CHRROM);
96839683}
96849684
96859685
96869686/*************************************************************
9687
9687
96889688 Board BMC-GKB
9689
9689
96909690 Unknown Bootleg Multigame Board
96919691 Games: 68 in 1, 73 in 1, 98 in 1
9692
9692
96939693 iNES: mapper 58
96949694
96959695 In MESS: Supported.
9696
9696
96979697 *************************************************************/
96989698
96999699static WRITE8_HANDLER( bmc_gkb_w )
r8325r8326
97019701   nes_state *state = (nes_state *)space->machine->driver_data;
97029702   UINT8 bank = (offset & 0x40) ? 0 : 1;
97039703   LOG_MMC(("bmc_gkb_w, offset: %04x, data: %02x\n", offset, data));
9704   
9704
97059705   prg16_89ab(space->machine, offset & ~bank);
97069706   prg16_cdef(space->machine, offset | bank);
97079707   chr8(space->machine, offset >> 3, state->mmc_chr_source);
r8325r8326
97099709}
97109710
97119711/*************************************************************
9712
9712
97139713 BMC-SUPER-700IN1
9714
9714
97159715 Unknown Bootleg Multigame Board
97169716 Games: Super 700 in 1
9717
9717
97189718 iNES: mapper 62
97199719
97209720 In MESS: Supported.
9721
9721
97229722 *************************************************************/
97239723
97249724static WRITE8_HANDLER( bmc_super700in1_w )
97259725{
97269726   LOG_MMC(("bmc_super700in1_w, offset :%04x, data: %02x\n", offset, data));
9727   
9727
97289728   chr8(space->machine, ((offset & 0x1f) << 2) | (data & 0x03), CHRROM);
9729   
9729
97309730   if (offset & 0x20)
97319731   {
97329732      prg16_89ab(space->machine, (offset & 0x40) | ((offset >> 8) & 0x3f));
r8325r8326
97369736   {
97379737      prg32(space->machine, ((offset & 0x40) | ((offset >> 8) & 0x3f)) >> 1);
97389738   }
9739   
9739
97409740   set_nt_mirroring(space->machine, BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
97419741}
97429742
97439743/*************************************************************
9744
9744
97459745 BMC-36IN1
9746
9746
97479747 Unknown Bootleg Multigame Board
97489748 Games: 36 in 1, 1200 in 1
9749
9749
97509750 iNES: mapper 200
9751
9751
97529752 In MESS: Supported.
9753
9753
97549754 *************************************************************/
97559755
97569756static WRITE8_HANDLER( bmc_36in1_w )
97579757{
97589758   LOG_MMC(("bmc_36in1_w, offset: %04x, data: %02x\n", offset, data));
9759   
9759
97609760   prg16_89ab(space->machine, offset & 0x07);
97619761   prg16_cdef(space->machine, offset & 0x07);
97629762   chr8(space->machine, offset & 0x07, CHRROM);
9763   
9763
97649764   set_nt_mirroring(space->machine, BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
97659765}
97669766
97679767/*************************************************************
9768
9768
97699769 BMC-21IN1
9770
9770
97719771 Unknown Bootleg Multigame Board
97729772 Games: 8 in 1, 21 in 1
9773
9773
97749774 iNES: mapper 201
9775
9775
97769776 In MESS: Supported.
9777
9777
97789778 *************************************************************/
97799779
97809780static WRITE8_HANDLER( bmc_21in1_w )
97819781{
97829782   LOG_MMC(("bmc_21in1_w, offset: %04x, data: %02x\n", offset, data));
9783   
9783
97849784   prg32(space->machine, offset & 0x03);
97859785   chr8(space->machine, offset & 0x03, CHRROM);
97869786}
97879787
97889788/*************************************************************
9789
9789
97909790 BMC-150IN1
9791
9791
97929792 Unknown Bootleg Multigame Board
97939793 Games: 150 in 1
9794
9794
97959795 iNES: mapper 202
9796
9796
97979797 In MESS: Supported.
9798
9798
97999799 *************************************************************/
98009800
98019801static WRITE8_HANDLER( bmc_150in1_w )
98029802{
98039803   int bank = (offset >> 1) & 0x07;
9804   
9804
98059805   LOG_MMC(("bmc_150in1_w, offset: %04x, data: %02x\n", offset, data));
9806   
9806
98079807   prg16_89ab(space->machine, bank);
98089808   prg16_cdef(space->machine, bank + (((bank & 0x06) == 0x06) ? 1 : 0));
98099809   chr8(space->machine, bank, CHRROM);
9810   
9810
98119811   set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT);
98129812}
98139813
98149814/*************************************************************
9815
9815
98169816 BMC-35IN1
9817
9817
98189818 Unknown Bootleg Multigame Board
98199819 Games: 35 in 1
9820
9820
98219821 iNES: mapper 203
9822
9822
98239823 In MESS: Supported.
9824
9824
98259825 *************************************************************/
98269826
98279827static WRITE8_HANDLER( bmc_35in1_w )
98289828{
98299829   LOG_MMC(("bmc_35in1_w, offset: %04x, data: %02x\n", offset, data));
9830   
9830
98319831   prg16_89ab(space->machine, (data >> 2) & 0x03);
98329832   prg16_cdef(space->machine, (data >> 2) & 0x03);
98339833   chr8(space->machine, data & 0x03, CHRROM);
98349834}
98359835
98369836/*************************************************************
9837
9837
98389838 BMC-64IN1
9839
9839
98409840 Unknown Bootleg Multigame Board
98419841 Games: 64 in 1
9842
9842
98439843 iNES: mapper 204
9844
9844
98459845 In MESS: Supported.
9846
9846
98479847 *************************************************************/
98489848
98499849static WRITE8_HANDLER( bmc_64in1_w )
98509850{
98519851   int bank = (offset >> 1) & (offset >> 2) & 0x01;
9852   
9852
98539853   LOG_MMC(("bmc_64in1_w, offset: %04x, data: %02x\n", offset, data));
9854   
9854
98559855   prg16_89ab(space->machine, offset & ~bank);
98569856   prg16_cdef(space->machine, offset | bank);
98579857   chr8(space->machine, offset & ~bank, CHRROM);
9858   
9858
98599859   set_nt_mirroring(space->machine, BIT(data, 4) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT);
98609860}
98619861
98629862/*************************************************************
9863
9863
98649864 BMC-15IN1
9865
9865
98669866 Unknown Bootleg Multigame Board
98679867 Games: 3 in 1, 15 in 1
9868
9868
98699869 iNES: mapper 205, MMC3 clone
9870
9870
98719871 In MESS: Supported.
9872
9872
98739873 *************************************************************/
98749874
98759875static WRITE8_HANDLER( bmc_15in1_m_w )
98769876{
98779877   nes_state *state = (nes_state *)space->machine->driver_data;
98789878   LOG_MMC(("bmc_15in1_m_w, offset: %04x, data: %02x\n", offset, data));
9879   
9879
98809880   if (offset & 0x0800)
98819881   {
98829882      state->mmc_prg_base = (data & 0x03) << 4;
r8325r8326
98899889}
98909890
98919891/*************************************************************
9892
9892
98939893 BMC-SUPERHIK_300IN1
9894
9894
98959895 Unknown Bootleg Multigame Board
98969896 Games: 100000 in 1, Super HIK 300 in 1, 1997 in 1
9897
9897
98989898 iNES: mapper 212
98999899
99009900 In MESS: Supported.
9901
9901
99029902 *************************************************************/
99039903
99049904static WRITE8_HANDLER( bmc_hik300_w )
99059905{
99069906   LOG_MMC(("bmc_hik300_w, offset: %04x, data: %02x\n", offset, data));
9907   
9907
99089908   set_nt_mirroring(space->machine, BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
99099909   chr8(space->machine, offset, CHRROM);
9910   
9910
99119911   if (offset < 0x4000)
99129912   {
99139913      prg16_89ab(space->machine, offset);
r8325r8326
99189918}
99199919
99209920/*************************************************************
9921
9921
99229922 BMC-SUPERGUN-20IN1
9923
9923
99249924 Unknown Bootleg Multigame Board
99259925 Games: Super Gun 20 in 1
9926
9926
99279927 iNES: mapper 214
9928
9928
99299929 In MESS: Supported.
9930
9930
99319931 *************************************************************/
99329932
99339933static WRITE8_HANDLER( supergun20in1_w )
99349934{
99359935   LOG_MMC(("supergun20in1_w, offset: %04x, data: %02x\n", offset, data));
9936   
9936
99379937   prg16_89ab(space->machine, offset >> 2);
99389938   prg16_cdef(space->machine, offset >> 2);
99399939   chr8(space->machine, offset, CHRROM);
99409940}
99419941
99429942/*************************************************************
9943
9943
99449944 BMC-72IN1
9945
9945
99469946 Unknown Bootleg Multigame Board
99479947 Games: 72 in 1, 115 in 1 and other multigame carts
9948
9948
99499949 iNES: mapper 225
9950
9950
99519951 In MESS: Supported.
9952
9952
99539953 *************************************************************/
99549954
99559955static WRITE8_HANDLER( bmc_72in1_w )
r8325r8326
99579957   int hi_bank;
99589958   int size_16;
99599959   int bank;
9960   
9960
99619961   LOG_MMC(("bmc_72in1_w, offset: %04x, data: %02x\n", offset, data));
9962   
9962
99639963   chr8(space->machine, offset, CHRROM);
99649964   set_nt_mirroring(space->machine, (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
9965   
9965
99669966   hi_bank = offset & 0x40;
99679967   size_16 = offset & 0x1000;
99689968   bank = (offset & 0xf80) >> 7;
r8325r8326
99719971      bank <<= 1;
99729972      if (hi_bank)
99739973         bank ++;
9974     
9974
99759975      prg16_89ab(space->machine, bank);
99769976      prg16_cdef(space->machine, bank);
99779977   }
r8325r8326
99809980}
99819981
99829982/*************************************************************
9983
9983
99849984 BMC-76IN1
9985
9985
99869986 Unknown Bootleg Multigame Board
99879987 Games: 76 in 1, Super 42 in 1
9988
9988
99899989 iNES: mapper 226
9990
9990
99919991 In MESS: Supported.
9992
9992
99939993 *************************************************************/
99949994
99959995// does this work for super42in1 as well?!?
r8325r8326
99999999   int hi_bank;
1000010000   int size_16;
1000110001   int bank;
10002   
10002
1000310003   LOG_MMC(("bmc_76in1_w, offset: %04x, data: %02x\n", offset, data));
10004   
10004
1000510005   if (offset & 0x01)
1000610006      state->mmc_latch2 = data;
1000710007   else
1000810008      state->mmc_latch1 = data;
10009   
10009
1001010010   set_nt_mirroring(space->machine, BIT(state->mmc_latch1, 6) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10011   
10011
1001210012   hi_bank = state->mmc_latch1 & 0x01;
1001310013   size_16 = state->mmc_latch1 & 0x20;
1001410014   bank = ((state->mmc_latch1 & 0x1e) >> 1) | ((state->mmc_latch1 & 0x80) >> 3) | ((state->mmc_latch2 & 0x01) << 5);
10015   
10015
1001610016   if (size_16)
1001710017   {
1001810018      bank <<= 1;
1001910019      if (hi_bank)
1002010020         bank ++;
10021     
10021
1002210022      prg16_89ab(space->machine, bank);
1002310023      prg16_cdef(space->machine, bank);
1002410024   }
r8325r8326
1002710027}
1002810028
1002910029/*************************************************************
10030
10030
1003110031 BMC-1200IN1
10032
10032
1003310033 Unknown Bootleg Multigame Board
1003410034 Games: 1200 in 1, 295 in 1, 76 in 1
10035
10035
1003610036 iNES: mapper 227
10037
10037
1003810038 In MESS: Supported.
10039
10039
1004010040 *************************************************************/
1004110041
1004210042static WRITE8_HANDLER( bmc_1200in1_w )
r8325r8326
1004410044   int hi_bank;
1004510045   int size_32;
1004610046   int bank;
10047   
10047
1004810048   LOG_MMC(("bmc_1200in1_w, offset: %04x, data: %02x\n", offset, data));
10049   
10049
1005010050   hi_bank = offset & 0x04;
1005110051   size_32 = offset & 0x01;
1005210052   bank = ((offset & 0x78) >> 3) | ((offset & 0x0100) >> 4);
r8325r8326
1005510055      bank <<= 1;
1005610056      if (hi_bank)
1005710057         bank ++;
10058     
10058
1005910059      prg16_89ab(space->machine, bank);
1006010060      prg16_cdef(space->machine, bank);
1006110061   }
1006210062   else
1006310063      prg32(space->machine, bank);
10064   
10064
1006510065   if (!(offset & 0x80))
1006610066   {
1006710067      if (offset & 0x200)
r8325r8326
1006910069      else
1007010070         prg16_cdef(space->machine, ((bank << 1) & 0x38));
1007110071   }
10072   
10072
1007310073   set_nt_mirroring(space->machine, BIT(data, 1) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1007410074}
1007510075
1007610076/*************************************************************
10077
10077
1007810078 BMC-31IN1
10079
10079
1008010080 Unknown Bootleg Multigame Board
1008110081 Games: 31 in 1
10082
10082
1008310083 iNES: mapper 229
10084
10084
1008510085 In MESS: Supported.
10086
10086
1008710087 *************************************************************/
1008810088
1008910089static WRITE8_HANDLER( bmc_31in1_w )
1009010090{
1009110091   LOG_MMC(("bmc_31in1_w, offset: %04x, data: %02x\n", offset, data));
10092   
10092
1009310093   set_nt_mirroring(space->machine, BIT(data, 5) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1009410094   chr8(space->machine, offset, CHRROM);
10095   
10095
1009610096   if ((offset & 0x1e) == 0)
1009710097   {
1009810098      prg16_89ab(space->machine, 0);
r8325r8326
1010610106}
1010710107
1010810108/*************************************************************
10109
10109
1011010110 BMC-22GAMES
10111
10111
1011210112 Unknown Bootleg Multigame Board
1011310113 Games: 22 in 1
10114
10114
1011510115 iNES: mapper 230
10116
10116
1011710117 In MESS: Partially Supported. It would need a reset
1011810118 to work (not possible yet)
10119
10119
1012010120 *************************************************************/
1012110121
1012210122static WRITE8_HANDLER( bmc_22g_w )
1012310123{
1012410124   LOG_MMC(("bmc_22g_w, offset: %04x, data: %02x\n", offset, data));
10125   
10125
1012610126   if (1)   // this should flip at reset
1012710127   {
1012810128      prg16_89ab(space->machine, data & 0x07);
r8325r8326
1014410144}
1014510145
1014610146/*************************************************************
10147
10147
1014810148 BMC-20IN1
10149
10149
1015010150 Unknown Bootleg Multigame Board
1015110151 Games: 20 in 1
10152
10152
1015310153 iNES: mapper 231
10154
10154
1015510155 In MESS: Supported.
10156
10156
1015710157 *************************************************************/
1015810158
1015910159static WRITE8_HANDLER( bmc_20in1_w )
1016010160{
1016110161   LOG_MMC(("bmc_20in1_w, offset: %04x, data: %02x\n", offset, data));
10162   
10162
1016310163   set_nt_mirroring(space->machine, BIT(data, 7) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10164   
10164
1016510165   prg16_89ab(space->machine, (offset & 0x1e));
1016610166   prg16_cdef(space->machine, (offset & 0x1e) | ((offset & 0x20) ? 1 : 0));
1016710167}
1016810168
1016910169/*************************************************************
10170
10170
1017110171 BMC-110IN1
10172
10172
1017310173 Known Boards: Unknown Bootleg Board
1017410174 Games: 110 in 1
10175
10175
1017610176 iNES: mapper 255
10177
10177
1017810178 In MESS: Preliminary support.
10179
10179
1018010180 *************************************************************/
1018110181
1018210182static WRITE8_HANDLER( bmc_110in1_w )
1018310183{
1018410184   UINT8 map255_helper1 = (offset >> 12) ? 0 : 1;
1018510185   UINT8 map255_helper2 = ((offset >> 8) & 0x40) | ((offset >> 6) & 0x3f);
10186   
10186
1018710187   LOG_MMC(("bmc_110in1_w, offset: %04x, data: %02x\n", offset, data));
10188   
10188
1018910189   set_nt_mirroring(space->machine, (offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1019010190   prg16_89ab(space->machine, map255_helper1 & ~map255_helper2);
1019110191   prg16_cdef(space->machine, map255_helper1 | map255_helper2);
r8325r8326
1019310193}
1019410194
1019510195/*************************************************************
10196
10196
1019710197 BMC-SUPERBIG-7IN1
10198
10198
1019910199 Known Boards: Unknown Multigame Bootleg Board
1020010200 Games: Kunio 8 in 1, Super Big 7 in 1
10201
10201
1020210202 iNES: mapper 44
10203
10203
1020410204 In MESS: Supported. It also uses mmc3_irq.
10205
10205
1020610206 *************************************************************/
1020710207
1020810208static WRITE8_HANDLER( bmc_sbig7_w )
r8325r8326
1021010210   nes_state *state = (nes_state *)space->machine->driver_data;
1021110211   UINT8 page;
1021210212   LOG_MMC(("bmc_sbig7_w, offset: %04x, data: %02x\n", offset, data));
10213   
10213
1021410214   switch (offset & 0x6001)
1021510215   {
1021610216      case 0x2001: /* $a001 - Select 128K ROM/VROM base (0..5) or last 256K ROM/VRAM base (6) */
1021710217         page = (data & 0x07);
1021810218         if (page > 6)
1021910219            page = 6;
10220         
10220
1022110221         state->mmc_prg_base = page << 4;
1022210222         state->mmc_prg_mask = (page > 5) ? 0x1f : 0x0f;
1022310223         state->mmc_chr_base = page << 7;
r8325r8326
1022510225         mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1022610226         mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
1022710227         break;
10228         
10228
1022910229      default:
1023010230         txrom_w(space, offset, data);
1023110231         break;
r8325r8326
1023310233}
1023410234
1023510235/*************************************************************
10236
10236
1023710237 BMC-HIK8IN1
10238
10238
1023910239 Known Boards: Unknown Multigame Bootleg Board
1024010240 Games: Street Fighter V, various multigame carts
10241
10241
1024210242 iNES: mapper 45
10243
10243
1024410244 In MESS: Supported. It also uses mmc3_irq.
10245
10245
1024610246 *************************************************************/
1024710247
1024810248static WRITE8_HANDLER( bmc_hik8_m_w )
1024910249{
1025010250   nes_state *state = (nes_state *)space->machine->driver_data;
1025110251   LOG_MMC(("bmc_hik8_m_w, offset: %04x, data: %02x\n", offset, data));
10252   
10252
1025310253   /* This bit is the "register lock". Once register are locked, writes go to WRAM
10254    and there is no way to unlock them (except by resetting the machine) */
10254    and there is no way to unlock them (except by resetting the machine) */
1025510255   if ((state->mapper45_reg[3] & 0x40) && state->wram != NULL)
1025610256      state->wram[offset] = data;
1025710257   else
1025810258   {
1025910259      state->mapper45_reg[state->mmc_count] = data;
1026010260      state->mmc_count = (state->mmc_count + 1) & 0x03;
10261     
10261
1026210262      if (!state->mmc_count)
1026310263      {
1026410264         LOG_MMC(("bmc_hik8_m_w, command completed %02x %02x %02x %02x\n", state->mapper45_reg[3],
1026510265                state->mapper45_reg[2], state->mapper45_reg[1], state->mapper45_reg[0]));
10266         
10266
1026710267         state->mmc_prg_base = state->mapper45_reg[1];
1026810268         state->mmc_prg_mask = 0x3f ^ (state->mapper45_reg[3] & 0x3f);
1026910269         state->mmc_chr_base = ((state->mapper45_reg[2] & 0xf0) << 4) | state->mapper45_reg[0];
r8325r8326
1027310273            state->mmc_chr_mask = 0;
1027410274         else
1027510275            state->mmc_chr_mask = 0xff;   // i.e. we use the vrom_bank with no masking
10276         
10276
1027710277         mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1027810278         mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
1027910279      }
r8325r8326
1028110281}
1028210282
1028310283/*************************************************************
10284
10284
1028510285 BMC-SUPERHIK-4IN1
10286
10286
1028710287 Known Boards: Unknown Multigame Bootleg Board
1028810288 Games: Super HIK 4 in 1
10289
10289
1029010290 iNES: mapper 49
10291
10291
1029210292 In MESS: Supported. It also uses mmc3_irq.
10293
10293
1029410294 *************************************************************/
1029510295
1029610296static WRITE8_HANDLER( bmc_hik4in1_m_w )
1029710297{
1029810298   nes_state *state = (nes_state *)space->machine->driver_data;
1029910299   LOG_MMC(("bmc_hik4in1_m_w, offset: %04x, data: %02x\n", offset, data));
10300   
10300
1030110301   /* mid writes only work when WRAM is enabled. not sure if I should
10302    change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of
10303    the read-only bit?) */
10302     change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of
10303     the read-only bit?) */
1030410304   if (state->mmc_latch2 & 0x80)
1030510305   {
1030610306      if (data & 0x01)   /* if this is 0, then we have 32k PRG blocks */
r8325r8326
1031110311      }
1031210312      else
1031310313         prg32(space->machine, (data & 0x30) >> 4);
10314     
10314
1031510315      state->mmc_chr_base = (data & 0xc0) << 1;
1031610316      state->mmc_chr_mask = 0x7f;
1031710317      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
r8325r8326
1031910319}
1032010320
1032110321/*************************************************************
10322
10322
1032310323 BMC-BALLGAMES-11IN1
10324
10324
1032510325 Known Boards: Unknown Multigame Bootleg Board
1032610326 Games: 11 in 1 Ball Games
10327
10327
1032810328 iNES: mapper 51
10329
10329
1033010330 In MESS: Partially Supported.
10331
10331
1033210332 *************************************************************/
1033310333
1033410334static void bmc_ball11_set_banks( running_machine *machine )
1033510335{
1033610336   nes_state *state = (nes_state *)machine->driver_data;
1033710337   set_nt_mirroring(machine, (state->mapper51_reg[0] == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10338   
10338
1033910339   if (state->mapper51_reg[0] & 0x01)
1034010340   {
1034110341      prg32(machine, state->mapper51_reg[1]);
r8325r8326
1035010350static WRITE8_HANDLER( bmc_ball11_m_w )
1035110351{
1035210352   nes_state *state = (nes_state *)space->machine->driver_data;
10353   
10353
1035410354   LOG_MMC(("bmc_ball11_m_w, offset: %04x, data: %02x\n", offset, data));
10355   
10355
1035610356   state->mapper51_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02);
1035710357   bmc_ball11_set_banks(space->machine);
1035810358}
r8325r8326
1036010360static WRITE8_HANDLER( bmc_ball11_w )
1036110361{
1036210362   nes_state *state = (nes_state *)space->machine->driver_data;
10363   
10363
1036410364   LOG_MMC(("bmc_ball11_w, offset: %04x, data: %02x\n", offset, data));
10365   
10365
1036610366   switch (offset & 0x6000)
1036710367   {
1036810368      case 0x4000:   // here we also update reg[0] upper bit
r8325r8326
1037710377}
1037810378
1037910379/*************************************************************
10380
10380
1038110381 BMC-MARIOPARTY-7IN1
10382
10382
1038310383 Known Boards: Unknown Multigame Bootleg Board
1038410384 Games: Mario 7 in 1
10385
10385
1038610386 MMC3 clone
10387
10387
1038810388 iNES: mapper 52
10389
10389
1039010390 In MESS: Supported.
10391
10391
1039210392 *************************************************************/
1039310393
1039410394static WRITE8_HANDLER( bmc_mario7in1_m_w )
r8325r8326
1039610396   nes_state *state = (nes_state *)space->machine->driver_data;
1039710397   UINT8 map52_helper1, map52_helper2;
1039810398   LOG_MMC(("bmc_mario7in1_m_w, offset: %04x, data: %02x\n", offset, data));
10399   
10399
1040010400   /* mid writes only work when WRAM is enabled. not sure if I should
10401    change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of
10402    the read-only bit?) and it only can happen once! */
10401     change the condition to state->mmc_latch2==0x80 (i.e. what is the effect of
10402     the read-only bit?) and it only can happen once! */
1040310403   if ((state->mmc_latch2 & 0x80) && !state->map52_reg_written)
1040410404   {
1040510405      map52_helper1 = (data & 0x08);
1040610406      map52_helper2 = (data & 0x40);
10407     
10407
1040810408      state->mmc_prg_base = map52_helper1 ? ((data & 0x07) << 4) : ((data & 0x06) << 4);
1040910409      state->mmc_prg_mask = map52_helper1 ? 0x0f : 0x1f;
1041010410      state->mmc_chr_base = ((data & 0x20) << 4) | ((data & 0x04) << 6) | (map52_helper2 ? ((data & 0x10) << 3) : 0);
1041110411      state->mmc_chr_mask = map52_helper2 ? 0x7f : 0xff;
1041210412      mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
1041310413      mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
10414     
10414
1041510415      state->map52_reg_written = 1;
1041610416   }
1041710417   else
r8325r8326
1041910419}
1042010420
1042110421/*************************************************************
10422
10422
1042310423 BMC-GOLDENCARD-6IN1
10424
10424
1042510425 Known Boards: Unknown Bootleg Multigame Board
1042610426 Games: Golden Card 6 in 1
10427
10427
1042810428 MMC3 clone
10429
10429
1043010430 iNES: mapper 217
10431
10431
1043210432 In MESS: Supported.
10433
10433
1043410434 *************************************************************/
1043510435
1043610436// remove mask & base parameters!
r8325r8326
1043910439   nes_state *state = (nes_state *)machine->driver_data;
1044010440   state->mmc_prg_base = (state->map217_reg[1] & 0x08) ? 0 : (state->map217_reg[1] & 0x10);
1044110441   state->mmc_prg_mask = (state->map217_reg[1] & 0x08) ? 0x1f : 0x0f;
10442   
10442
1044310443   state->mmc_prg_base |= ((state->map217_reg[1] & 0x03) << 5);
10444   
10444
1044510445   mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
1044610446}
1044710447
r8325r8326
1045110451   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
1045210452   int chr_base = (state->map217_reg[1] & 0x08) ? 0x00 : ((state->map217_reg[1] & 0x10) << 3);
1045310453   int chr_mask = (state->map217_reg[1] & 0x08) ? 0xff : 0x7f;
10454   
10454
1045510455   chr_base |= ((state->map217_reg[1] & 0x03) << 8);
10456   
10456
1045710457   chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr);
1045810458   chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] |  0x01) & chr_mask), chr);
1045910459   chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr);
r8325r8326
1047010470   UINT8 bank;
1047110471   LOG_MMC(("bmc_gc6in1_l_w, offset: %04x, data: %02x\n", offset, data));
1047210472   offset += 0x100;
10473   
10473
1047410474   if (offset == 0x1000)
1047510475   {
1047610476      state->map217_reg[0] = data;
r8325r8326
1050010500   UINT8 MMC3_helper, cmd;
1050110501   static const UINT8 conv_table[8] = {0, 6, 3, 7, 5, 2, 4, 1};
1050210502   LOG_MMC(("bmc_gc6in1_w, offset: %04x, data: %02x\n", offset, data));
10503   
10503
1050410504   if (!state->map217_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers
1050510505   {
1050610506      switch (offset & 0x6001)
r8325r8326
1050810508         case 0x0000:
1050910509            MMC3_helper = state->mmc_latch1 ^ data;
1051010510            state->mmc_latch1 = data;
10511           
10511
1051210512            /* Has PRG Mode changed? */
1051310513            if (MMC3_helper & 0x40)
1051410514               bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
10515           
10515
1051610516            /* Has CHR Mode changed? */
1051710517            if (MMC3_helper & 0x80)
1051810518               bmc_gc6in1_set_chr(space->machine, state->mmc_chr_source);
1051910519            break;
10520           
10520
1052110521         case 0x0001:
1052210522            cmd = state->mmc_latch1 & 0x07;
1052310523            switch (cmd)
r8325r8326
1053410534               break;
1053510535         }
1053610536            break;
10537           
10537
1053810538         default:
1053910539            txrom_w(space, offset, data);
1054010540            break;
r8325r8326
1054710547         case 0x0000:
1054810548            txrom_w(space, 0xc000, data);
1054910549            break;
10550           
10550
1055110551         case 0x0001:
1055210552            data = (data & 0xc0) | conv_table[data & 0x07];
1055310553            MMC3_helper = state->mmc_latch1 ^ data;
1055410554            state->mmc_latch1 = data;
10555           
10555
1055610556            /* Has PRG Mode changed? */
1055710557            if (MMC3_helper & 0x40)
1055810558               bmc_gc6in1_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
10559           
10559
1056010560            /* Has CHR Mode changed? */
1056110561            if (MMC3_helper & 0x80)
1056210562               bmc_gc6in1_set_chr(space->machine, state->mmc_chr_source);
10563           
10563
1056410564            state->map217_reg[3] = 1;
1056510565            break;
10566           
10566
1056710567         case 0x2000:
1056810568            cmd = state->mmc_latch1 & 0x07;
1056910569            if (state->map217_reg[3])
r8325r8326
1058410584               }
1058510585            }
1058610586            break;
10587           
10588           
10587
10588
1058910589         case 0x2001:
1059010590            set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1059110591            break;
10592           
10592
1059310593         default:
1059410594            txrom_w(space, offset, data);
1059510595            break;
r8325r8326
1059810598}
1059910599
1060010600/*************************************************************
10601
10601
1060210602 BMC-FAMILY-4646B
10603
10603
1060410604 Known Boards: Unknown Multigame Bootleg Board (4646B)
1060510605 Games: 2 in 1 - Family Kid & Aladdin 4
10606
10606
1060710607 MMC3 clone
10608
10608
1060910609 iNES: mapper 134
10610
10610
1061110611 In MESS: Supported.
10612
10612
1061310613 *************************************************************/
1061410614
1061510615static WRITE8_HANDLER( bmc_family4646_m_w )
1061610616{
1061710617   nes_state *state = (nes_state *)space->machine->driver_data;
1061810618   LOG_MMC(("bmc_family4646_m_w, offset: %04x, data: %02x\n", offset, data));
10619   
10619
1062010620   if (offset == 0x01)
1062110621   {
1062210622      state->mmc_prg_base = (data & 0x02) << 4;
r8325r8326
1062910629}
1063010630
1063110631/*************************************************************
10632
10632
1063310633 BMC-VT5201
10634
10634
1063510635 *************************************************************/
1063610636
1063710637static WRITE8_HANDLER( bmc_vt5201_w )
1063810638{
1063910639   nes_state *state = (nes_state *)space->machine->driver_data;
1064010640   LOG_MMC(("bmc_vt5201_w, offset: %04x, data: %02x\n", offset, data));
10641   
10641
1064210642   state->mmc_latch1 = BIT(offset, 8);
10643   
10644   // not sure about this mirroring bit!!
10643
10644   // not sure about this mirroring bit!!
1064510645   // without it TN 95 in 1 has glitches in Lunar Ball; with it TN 95 in 1 has glitches in Galaxian!
1064610646   set_nt_mirroring(space->machine, BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1064710647   if (BIT(offset, 7))
r8325r8326
1065810658{
1065910659   nes_state *state = (nes_state *)space->machine->driver_data;
1066010660   LOG_MMC(("bmc_vt5201_r, offset: %04x\n", offset));
10661   //   state->mmc_dipsetting = input_port_read(space->machine, "CARTDIPS");
10661   //  state->mmc_dipsetting = input_port_read(space->machine, "CARTDIPS");
1066210662
1066310663   if (state->mmc_latch1)
1066410664      return state->mmc_dipsetting; // cart mode, depending on the Dip Switches (always zero atm, given we have no way to add cart-based DIPs)
r8325r8326
1068010680}
1068110681
1068210682/*************************************************************
10683
10683
1068410684 BMC-BS-5
10685
10685
1068610686 Games: a few 4 in 1 multicarts
10687
10687
1068810688 *************************************************************/
1068910689
1069010690static void bmc_bs5_update_banks( running_machine *machine )
r8325r8326
1070610706   nes_state *state = (nes_state *)space->machine->driver_data;
1070710707   UINT8 bs5_helper = (offset & 0xc00) >> 10;
1070810708   LOG_MMC(("bmc_bs5_w, offset: %04x, data: %02x\n", offset, data));
10709//   state->mmc_dipsetting = input_port_read(space->machine, "CARTDIPS");
10710   
10709//  state->mmc_dipsetting = input_port_read(space->machine, "CARTDIPS");
10710
1071110711   switch (offset & 0x7000)
1071210712   {
1071310713      case 0x0000:
r8325r8326
1072210722}
1072310723
1072410724/*************************************************************
10725
10725
1072610726 BMC-810544-C-A1
10727
10727
1072810728 Games: 200-in-1 Elfland
1072910729
1073010730 *************************************************************/
r8325r8326
1074310743      prg32(space->machine, bank);
1074410744
1074510745   set_nt_mirroring(space->machine, BIT(data, 4) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
10746   
10746
1074710747   chr8(space->machine, offset & 0x0f, CHRROM);
1074810748}
1074910749
r8325r8326
1080010800   { STD_UN1ROM,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(un1rom_w),              NULL, NULL, NULL },
1080110801   { STD_CPROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(cprom_w),               NULL, NULL, NULL },
1080210802   { STD_CNROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(cnrom_w),               NULL, NULL, NULL },
10803   { BANDAI_PT554,         NES_NOACCESS, NES_WRITEONLY(bandai_pt554_m_w), NES_WRITEONLY(cnrom_w), NULL, NULL, NULL },   
10803   { BANDAI_PT554,         NES_NOACCESS, NES_WRITEONLY(bandai_pt554_m_w), NES_WRITEONLY(cnrom_w), NULL, NULL, NULL },
1080410804   { STD_AXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(axrom_w),               NULL, NULL, NULL },
1080510805   { STD_PXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(pxrom_w),               mmc2_latch, NULL, NULL },
1080610806   { STD_FXROM,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(fxrom_w),               mmc2_latch, NULL, NULL },
r8325r8326
1090910909   { SUBOR_TYPE0,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(subor0_w),              NULL, NULL, NULL },
1091010910   { SUBOR_TYPE1,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(subor1_w),              NULL, NULL, NULL },
1091110911   { MAGICSERIES_MD,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(magics_md_w),           NULL, NULL, NULL },
10912   { NANJING_BOARD,        {nanjing_l_w, nanjing_l_r}, NES_NOACCESS, NES_NOACCESS,           NULL, NULL, nanjing_irq },
10912   { NANJING_BOARD,        {nanjing_l_w, nanjing_l_r}, NES_NOACCESS, NES_NOACCESS,           NULL, NULL, nanjing_irq },
1091310913   { NITRA_TDA,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(nitra_w),               NULL, NULL, mmc3_irq },
1091410914   { NTDEC_ASDER,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(ntdec_asder_w),         NULL, NULL, NULL },
1091510915   { NTDEC_FIGHTINGHERO,   NES_NOACCESS, NES_WRITEONLY(ntdec_fh_m_w), NES_NOACCESS,          NULL, NULL, NULL },
r8325r8326
1092410924   { TENGEN_800008,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800008_w),       NULL, NULL, NULL },
1092510925   { TENGEN_800032,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800032_w),       NULL, NULL, tengen_800032_irq },
1092610926   { TENGEN_800037,        NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(tengen_800037_w),       NULL, NULL, tengen_800032_irq },
10927   { TXC_22211A,           {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
10928   { TXC_22211B,           {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211b_w), NULL, NULL, NULL },
10929   { TXC_22211C,           {txc_22211_l_w, txc_22211c_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
10927   { TXC_22211A,           {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
10928   { TXC_22211B,           {txc_22211_l_w, txc_22211_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211b_w), NULL, NULL, NULL },
10929   { TXC_22211C,           {txc_22211_l_w, txc_22211c_l_r}, NES_NOACCESS, NES_WRITEONLY(txc_22211_w), NULL, NULL, NULL },
1093010930   { TXC_TW,               NES_WRITEONLY(txc_tw_l_w), NES_WRITEONLY(txc_tw_m_w), NES_WRITEONLY(txc_tw_w), NULL, NULL, mmc3_irq },
10931   { TXC_STRIKEWOLF,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txc_strikewolf_w),      NULL, NULL, NULL },
10931   { TXC_STRIKEWOLF,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txc_strikewolf_w),      NULL, NULL, NULL },
1093210932   { TXC_MXMDHTWO,         NES_READONLY(txc_mxmdhtwo_l_r), NES_NOACCESS, NES_WRITEONLY(txc_mxmdhtwo_w), NULL, NULL, NULL },
1093310933   { WAIXING_TYPE_A,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w),           NULL, NULL, mmc3_irq },
1093410934   { WAIXING_TYPE_B,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_b_w),           NULL, NULL, mmc3_irq },
r8325r8326
1094810948   { UNL_8237,             NES_WRITEONLY(unl_8237_l_w), NES_NOACCESS, NES_WRITEONLY(unl_8237_w),      NULL, NULL, mmc3_irq },
1094910949   { UNL_AX5705,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_ax5705_w),          NULL, NULL, NULL },
1095010950   { UNL_CC21,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_cc21_w),            NULL, NULL, NULL },
10951    { UNL_KOF97,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_kof97_w),           NULL, NULL, mmc3_irq },
10952    { UNL_T230,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_t230_w),            NULL, NULL, konami_irq },
10951   { UNL_KOF97,            NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_kof97_w),           NULL, NULL, mmc3_irq },
10952   { UNL_T230,             NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_t230_w),            NULL, NULL, konami_irq },
1095310953   { UNL_KOF96,            {kof96_l_w, kof96_l_r}, NES_NOACCESS, NES_WRITEONLY(kof96_w),     NULL, NULL, mmc3_irq },
1095410954   { UNL_MK2,              NES_NOACCESS, NES_WRITEONLY(mk2_m_w), NES_NOACCESS,               NULL, NULL, mmc3_irq },
1095510955   { UNL_N625092,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(n625092_w),             NULL, NULL, NULL },
r8325r8326
1102711027   nes_state *state = (nes_state *)machine->driver_data;
1102811028   int err = 0;
1102911029   const nes_pcb_intf *intf = nes_pcb_intf_lookup(state->pcb_id);
11030   
11030
1103111031   if (intf == NULL)
1103211032      fatalerror("Missing PCB interface\n");
11033   
11033
1103411034   if (state->chr_chunks == 0)
1103511035      chr8(machine, 0, CHRRAM);
1103611036   else
1103711037      chr8(machine, 0, CHRROM);
11038   
11038
1103911039   /* Set the mapper irq callback */
1104011040   ppu2c0x_set_scanline_callback(state->ppu, intf ? intf->mmc_scanline : NULL);
1104111041   ppu2c0x_set_hblank_callback(state->ppu, intf ? intf->mmc_hblank : NULL);
11042   
11042
1104311043   err = unif_initialize(machine, state->pcb_id);
11044   
11044
1104511045   return err;
1104611046}
1104711047
r8325r8326
1105111051
1105211052   if (pcb == NULL)
1105311053      fatalerror("Unimplemented PCB type %s\n", feature);
11054   
11054
1105511055   return pcb->pcb_id;
1105611056}
1105711057
r8325r8326
1105911059{
1106011060   nes_state *state = (nes_state *)machine->driver_data;
1106111061   const nes_pcb_intf *intf = nes_pcb_intf_lookup(state->pcb_id);
11062   
11062
1106311063   if (intf == NULL)
1106411064      fatalerror("Missing PCB interface\n");
11065   
11065
1106611066   if (intf)
1106711067   {
1106811068      state->mmc_write_low = intf->mmc_l.write;
src/mess/machine/apple2gs.c
r8325r8326
3838        bit 0 - shift key pressed
3939
4040    C027 - KMSTATUS
41        bit 7 - set if mouse register full     
41        bit 7 - set if mouse register full
4242        bit 6 - mouse interupt enable flag
4343        bit 5 - set if data register full
44        bit 4 - data interrupt enabled         
45        bit 3 - set if key data full         
44        bit 4 - data interrupt enabled
45        bit 3 - set if key data full
4646        bit 2 - key data interurpt enabled
4747        bit 1 - clear if horizontal mouse data, set if vertical
4848        bit 0 - command register full
src/mess/machine/nes.c
r8325r8326
6060   {
6161      state->slow_banking = 0;
6262      /* If we are loading a disk we have already filled state->fds_data and we don't want to overwrite it,
63       if we are loading a cart image identified as mapper 20 (probably wrong mapper...) we need to alloc
64       memory for use in nes_fds_r/nes_fds_w. Same goes for allocation of fds_ram (used for bank2)  */
63         if we are loading a cart image identified as mapper 20 (probably wrong mapper...) we need to alloc
64         memory for use in nes_fds_r/nes_fds_w. Same goes for allocation of fds_ram (used for bank2)  */
6565      if (state->fds_data == NULL)
6666      {
6767         UINT32 size = memory_region_length(machine, "maincpu") - 0x10000;
r8325r8326
7070      }
7171      if (state->fds_ram == NULL)
7272         state->fds_ram = auto_alloc_array(machine, UINT8, 0x8000);
73     
73
7474      memory_install_read8_handler(space, 0x4030, 0x403f, 0, 0, nes_fds_r);
7575      memory_install_read_bank(space, 0x6000, 0xdfff, 0, 0, "bank2");
7676      memory_install_read_bank(space, 0xe000, 0xffff, 0, 0, "bank1");
77     
77
7878      memory_install_write8_handler(space, 0x4020, 0x402f, 0, 0, nes_fds_w);
7979      memory_install_write_bank(space, 0x6000, 0xdfff, 0, 0, "bank2");
80     
80
8181      memory_set_bankptr(machine, "bank1", &state->rom[0xe000]);
8282      memory_set_bankptr(machine, "bank2", state->fds_ram);
8383      return;
r8325r8326
9696   memory_install_read_bank(space, 0xc000, 0xdfff, 0, 0, "bank3");
9797   memory_install_read_bank(space, 0xe000, 0xffff, 0, 0, "bank4");
9898   memory_install_readwrite_bank(space, 0x6000, 0x7fff, 0, 0, "bank5");
99   
99
100100   /* configure banks 1-4 */
101101   for (i = 0; i < 4; i++)
102102   {
r8325r8326
108108      memory_set_bank(machine, bank_names[i], i);
109109      state->prg_bank[i] = i;
110110   }
111   
111
112112   /* bank 5 configuration is more delicate, since it can have PRG RAM, PRG ROM or SRAM mapped to it */
113113   /* we first map PRG ROM banks, then the battery bank (if a battery is present), and finally PRG RAM (state->wram) */
114114   memory_configure_bank(machine, "bank5", 0, prg_banks, memory_region(machine, "maincpu") + 0x10000, 0x2000);
115115   state->battery_bank5_start = prg_banks;
116116   state->prgram_bank5_start = prg_banks;
117117   state->empty_bank5_start = prg_banks;
118   
118
119119   /* add battery ram, but only if there's no trainer since they share overlapping memory. */
120120   if (state->battery && !state->trainer)
121121   {
r8325r8326
131131      memory_configure_bank(machine, "bank5", state->prgram_bank5_start, state->wram_size / 0x2000, state->wram, 0x2000);
132132      state->empty_bank5_start += state->wram_size / 0x2000;
133133   }
134   
134
135135   memory_configure_bank(machine, "bank5", state->empty_bank5_start, 1, state->rom + 0x6000, 0x2000);
136   
136
137137   /* if we have any additional PRG RAM, point bank5 to its first bank */
138138   if (state->battery || state->prg_ram)
139139      state->prg_bank[4] = state->battery_bank5_start;
140140   else
141141      state->prg_bank[4] = state->empty_bank5_start; // or shall we point to "maincpu" region at 0x6000? point is that we should never access this region if no sram or wram is present!
142   
142
143143   memory_set_bank(machine, "bank5", state->prg_bank[4]);
144   
144
145145   if (state->four_screen_vram)
146146   {
147147      state->extended_ntram = auto_alloc_array(machine, UINT8, 0x2000);
148148      state_save_register_global_pointer(machine, state->extended_ntram, 0x2000);
149149   }
150   
150
151151   // 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)
152152   if (state->mmc_write_mid)
153153      memory_install_write8_handler(space, 0x6000, 0x7fff, 0, 0, state->mmc_write_mid);
154154   if (state->mmc_write)
155155      memory_install_write8_handler(space, 0x8000, 0xffff, 0, 0, state->mmc_write);
156   
156
157157   // In fact, we also allow single pcbs to overwrite the bank read handlers defined above,
158158   // because some pcbs (mainly pirate ones) require protection values to be read instead of
159159   // the expected ROM banks: these handlers, though, must take care of the ROM access as well
r8325r8326
161161      memory_install_read8_handler(space, 0x6000, 0x7fff, 0, 0, state->mmc_read_mid);
162162   if (state->mmc_read)
163163      memory_install_read8_handler(space, 0x8000, 0xffff, 0, 0, state->mmc_read);
164   
164
165165   // install additional handlers
166166   if (state->pcb_id == BTL_SMB2B)
167167   {
r8325r8326
187187
188188   /* Some carts have extra RAM and require it on at startup, e.g. Metroid */
189189   state->mid_ram_enable = 1;
190   
190
191191   /* Reset the mapper variables. Will also mark the char-gen ram as dirty */
192192   if (state->disk_expansion && state->pcb_id == NO_BOARD)
193193      ppu2c0x_set_hblank_callback(state->ppu, fds_irq);
r8325r8326
299299   nes_state *state = (nes_state *)machine->driver_data;
300300   device_image_interface *image = dynamic_cast<device_image_interface *>(state->cart);
301301   /* Write out the battery file if necessary */
302   if (state->battery)   
302   if (state->battery)
303303      image->battery_save(state->battery_ram, state->battery_size);
304   
304
305305   if (state->mapper_ram_size)
306306      image->battery_save(state->mapper_ram, state->mapper_ram_size);
307307}
r8325r8326
324324      /* Some games expect bit 6 to be set because the last entry on the data bus shows up */
325325      /* in the unused upper 3 bits, so typically a read from $4016 leaves 0x40 there. */
326326      ret = 0x40;
327     
327
328328      ret |= ((state->in_0.i0 >> state->in_0.shift) & 0x01);
329     
329
330330      /* zapper */
331331      if ((cfg & 0x000f) == 0x0002)
332332      {
333333         int x = state->in_0.i1;   /* read Zapper x-position */
334334         int y = state->in_0.i2;   /* read Zapper y-position */
335335         UINT32 pix, color_base;
336         
336
337337         /* get the pixel at the gun position */
338338         pix = ppu2c0x_get_pixel(state->ppu, x, y);
339         
339
340340         /* get the color base from the ppu */
341341         color_base = ppu2c0x_get_colorbase(state->ppu);
342         
342
343343         /* look at the screen and see if the cursor is over a bright pixel */
344344         if ((pix == color_base + 0x20) || (pix == color_base + 0x30) ||
345345            (pix == color_base + 0x33) || (pix == color_base + 0x34))
r8325r8326
348348         }
349349         else
350350            ret |= 0x08;  /* no sprite hit */
351         
351
352352         /* If button 1 is pressed, indicate the light gun trigger is pressed */
353353         ret |= ((state->in_0.i0 & 0x01) << 4);
354354      }
355     
355
356356      if (LOG_JOY)
357357         logerror("joy 0 read, val: %02x, pc: %04x, bits read: %d, chan0: %08x\n", ret, cpu_get_pc(space->cpu), state->in_0.shift, state->in_0.i0);
358     
358
359359      state->in_0.shift++;
360360   }
361361
r8325r8326
371371
372372static UINT8 nes_read_subor_keyboard_line( running_machine *machine, UINT8 scan, UINT8 mode )
373373{
374   static const char *const sub_keyport_names[] = { "SUBKEY0", "SUBKEY1", "SUBKEY2", "SUBKEY3", "SUBKEY4",
374   static const char *const sub_keyport_names[] = { "SUBKEY0", "SUBKEY1", "SUBKEY2", "SUBKEY3", "SUBKEY4",
375375      "SUBKEY5", "SUBKEY6", "SUBKEY7", "SUBKEY8", "SUBKEY9", "SUBKEY10", "SUBKEY11", "SUBKEY12" };
376376   return ((input_port_read(machine, sub_keyport_names[scan]) >> (mode * 4)) & 0x0f) << 1;
377377}
r8325r8326
401401      /* Some games expect bit 6 to be set because the last entry on the data bus shows up */
402402      /* in the unused upper 3 bits, so typically a read from $4017 leaves 0x40 there. */
403403      ret = 0x40;
404     
404
405405      /* Handle data line 0's serial output */
406406      ret |= ((state->in_1.i0 >> state->in_1.shift) & 0x01);
407     
407
408408      /* zapper */
409409      if ((cfg & 0x00f0) == 0x0030)
410410      {
411411         int x = state->in_1.i1;   /* read Zapper x-position */
412412         int y = state->in_1.i2;   /* read Zapper y-position */
413413         UINT32 pix, color_base;
414         
414
415415         /* get the pixel at the gun position */
416416         pix = ppu2c0x_get_pixel(state->ppu, x, y);
417         
417
418418         /* get the color base from the ppu */
419419         color_base = ppu2c0x_get_colorbase(state->ppu);
420         
420
421421         /* look at the screen and see if the cursor is over a bright pixel */
422422         if ((pix == color_base + 0x20) || (pix == color_base + 0x30) ||
423423            (pix == color_base + 0x33) || (pix == color_base + 0x34))
r8325r8326
426426         }
427427         else
428428            ret |= 0x08;  /* no sprite hit */
429         
429
430430         /* If button 1 is pressed, indicate the light gun trigger is pressed */
431431         ret |= ((state->in_1.i0 & 0x01) << 4);
432432      }
433     
433
434434      /* arkanoid dial */
435435      else if ((cfg & 0x00f0) == 0x0040)
436436      {
437437         /* Handle data line 2's serial output */
438438         ret |= ((state->in_1.i2 >> state->in_1.shift) & 0x01) << 3;
439         
439
440440         /* Handle data line 3's serial output - bits are reversed */
441441         /* NPW 27-Nov-2007 - there is no third subscript! commenting out */
442442         /* ret |= ((state->in_1[3] >> state->in_1.shift) & 0x01) << 4; */
443443         /* ret |= ((state->in_1[3] << state->in_1.shift) & 0x80) >> 3; */
444444      }
445     
445
446446      if (LOG_JOY)
447447         logerror("joy 1 read, val: %02x, pc: %04x, bits read: %d, chan0: %08x\n", ret, cpu_get_pc(space->cpu), state->in_1.shift, state->in_1.i0);
448     
448
449449      state->in_1.shift++;
450450   }
451451
r8325r8326
527527
528528   /* Check if lightgun has been chosen as input: if so, enable crosshair */
529529   timer_set(space->machine, attotime_zero, NULL, 0, lightgun_tick);
530   
530
531531   if ((cfg & 0x000f) >= 0x04)   // for now we treat the FC keyboard separately from other inputs!
532532   {
533533      // here we should also have the tape output
r8325r8326
536536      {
537537         int lines = ((cfg & 0x000f) == 0x04) ? 9 : 12;
538538         UINT8 out = BIT(data, 1);   // scan
539         
539
540540         if (state->fck_mode && !out && ++state->fck_scan > lines)
541541            state->fck_scan = 0;
542         
542
543543         state->fck_mode = out;   // access lower or upper 4 bits
544         
544
545545         if (BIT(data, 0))   // reset
546546            state->fck_scan = 0;
547547      }
r8325r8326
550550   {
551551      if (data & 0x01)
552552         return;
553     
553
554554      if (LOG_JOY)
555555         logerror("joy 0 bits read: %d\n", state->in_0.shift);
556     
556
557557      /* Toggling bit 0 high then low resets both controllers */
558558      state->in_0.shift = 0;
559559      state->in_1.shift = 0;
560     
560
561561      /* Read the input devices */
562562      nes_read_input_device(space->machine, cfg >>  0, &state->in_0, 0,  TRUE, -1);
563563      nes_read_input_device(space->machine, cfg >>  4, &state->in_1, 1,  TRUE,  1);
564564      nes_read_input_device(space->machine, cfg >>  8, &state->in_2, 2, FALSE, -1);
565565      nes_read_input_device(space->machine, cfg >> 12, &state->in_3, 3, FALSE, -1);
566     
566
567567      if (cfg & 0x0f00)
568568         state->in_0.i0 |= (state->in_2.i0 << 8) | (0x08 << 16);
569     
569
570570      if (cfg & 0xf000)
571571         state->in_1.i0 |= (state->in_3.i0 << 8) | (0x04 << 16);
572572   }
r8325r8326
616616   {
617617      if (strcmp(nes_line->tag, feature) == 0)
618618         break;
619     
619
620620      nes_line++;
621621   }
622622
r8325r8326
647647         state->format = 1;   // we use this to select between mapper_reset / unif_reset
648648         state->ines20 = 0;
649649         state->battery_size = NES_BATTERY_SIZE; // with iNES we can only support 8K WRAM battery (iNES 2.0 might fix this)
650         state->prg_ram = 1;   // always map state->wram in bank5 (eventually, this should be enabled only for some mappers)
650         state->prg_ram = 1;   // always map state->wram in bank5 (eventually, this should be enabled only for some mappers)
651651
652652         // check if the image is recognized by nes.hsi
653653         mapinfo = image.extrainfo();
r8325r8326
655655         // image_extrainfo() resets the file position back to start.
656656         // Let's skip past the magic header once again.
657657         image.fseek(4, SEEK_SET);
658         
658
659659         image.fread( &state->prg_chunks, 1);
660660         image.fread( &state->chr_chunks, 1);
661661         /* Read the first ROM option byte (offset 6) */
662662         image.fread( &m, 1);
663         
663
664664         /* Interpret the iNES header flags */
665665         state->mapper = (m & 0xf0) >> 4;
666666         local_options = m & 0x0f;
667         
667
668668         /* Read the second ROM option byte (offset 7) */
669669         image.fread( &m, 1);
670         
670
671671         switch (m & 0xc)
672672         {
673673            case 0x4:
674            case 0xc:   
674            case 0xc:
675675               // probably the header got corrupted: don't trust upper bits for mapper
676676               break;
677677
r8325r8326
751751
752752         state->rom = memory_region(image.device().machine, "maincpu");
753753         state->vrom = memory_region(image.device().machine, "gfx1");
754         
754
755755         state->vram_chunks = memory_region_length(image.device().machine, "gfx2") / 0x2000;
756756         state->vram = memory_region(image.device().machine, "gfx2");
757757         // FIXME: this should only be allocated if there is actual wram in the cart (i.e. if state->prg_ram = 1)!
758758         // or if there is a trainer, I think
759759         state->wram_size = 0x10000;
760760         state->wram = auto_alloc_array(image.device().machine, UINT8, state->wram_size);
761         
761
762762         /* Position past the header */
763763         image.fseek(16, SEEK_SET);
764764
r8325r8326
861861            memset(magic2, '\0', sizeof(magic2));
862862            image.fread( &magic2, 4);
863863
864            /* We first run through the whole image to find a [MAPR] chunk. This is needed
865             because, unfortunately, the MAPR chunk is not always the first chunk (see
866             Super 24-in-1). When such a chunk is found, we set mapr_chunk_found=1 and
867             we go back to load other chunks! */
864            /* We first run through the whole image to find a [MAPR] chunk. This is needed
865                 because, unfortunately, the MAPR chunk is not always the first chunk (see
866                 Super 24-in-1). When such a chunk is found, we set mapr_chunk_found=1 and
867                 we go back to load other chunks! */
868868            if (!mapr_chunk_found)
869869            {
870870               if ((magic2[0] == 'M') && (magic2[1] == 'A') && (magic2[2] == 'P') && (magic2[3] == 'R'))
r8325r8326
10491049         memory_region_free(image.device().machine, "maincpu");
10501050         memory_region_free(image.device().machine, "gfx1");
10511051         memory_region_free(image.device().machine, "gfx2");
1052         
1052
10531053         /* Allocate them again, and copy PRG/CHR from temp buffers */
10541054         /* Take care of PRG */
10551055         prg_size = (state->prg_chunks == 1) ? 2 * 0x4000 : state->prg_chunks * 0x4000;
r8325r8326
10781078         // FIXME: this should only be allocated if there is actual wram in the cart (i.e. if state->prg_ram = 1)!
10791079         state->wram_size = 0x10000;
10801080         state->wram = auto_alloc_array(image.device().machine, UINT8, state->wram_size);
1081           
1081
10821082#if SPLIT_PRG
10831083         {
10841084            FILE *prgout;
10851085            char outname[255];
1086           
1086
10871087            sprintf(outname, "%s.prg", image.filename());
10881088            prgout = fopen(outname, "wb");
10891089            if (prgout)
r8325r8326
10911091               fwrite(&state->rom[0x10000], 1, 0x4000 * state->prg_chunks, prgout);
10921092               printf("Created PRG chunk\n");
10931093            }
1094           
1094
10951095            fclose(prgout);
10961096         }
10971097#endif
1098         
1098
10991099#if SPLIT_CHR
11001100         if (state->chr_chunks > 0)
11011101         {
11021102            FILE *chrout;
11031103            char outname[255];
1104           
1104
11051105            sprintf(outname, "%s.chr", image.filename());
11061106            chrout= fopen(outname, "wb");
11071107            if (chrout)
r8325r8326
11141114#endif
11151115         // free the temporary copy of PRG/CHR
11161116         auto_free(image.device().machine, temp_prg);
1117         auto_free(image.device().machine, temp_chr);         
1117         auto_free(image.device().machine, temp_chr);
11181118         logerror("UNIF support is only very preliminary.\n");
11191119      }
11201120      else
r8325r8326
11291129      UINT32 chr_size = image.get_software_region_length("chr");
11301130      UINT32 vram_size = image.get_software_region_length("vram");
11311131      vram_size += image.get_software_region_length("vram2");
1132     
1132
11331133      /* Free the regions that were allocated by the ROM loader */
11341134      memory_region_free(image.device().machine, "maincpu");
11351135      memory_region_free(image.device().machine, "gfx1");
r8325r8326
11881188         state->battery = 1;
11891189         state->battery_size += 0x4000;
11901190      }
1191     
1191
11921192      state->prg_ram = (image.get_software_region("wram") != NULL) ? 1 : 0;
11931193      state->wram_size = image.get_software_region_length("wram");
11941194      state->mapper_ram_size = image.get_software_region_length("mapper_ram");
r8325r8326
12441244         state->vrc_ls_prg_a = nes_cart_get_line(image.get_feature("vrc2-pin3"));
12451245         state->vrc_ls_prg_b = nes_cart_get_line(image.get_feature("vrc2-pin3"));
12461246         state->vrc_ls_chr = (nes_cart_get_line(image.get_feature("vrc2-pin21")) != 10) ? 1 : 0;
1247//         printf("VRC-2, pin3: A%d, pin4: A%d, pin21: %s\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b, state->vrc_ls_chr ? "NC" : "A10");
1247//          printf("VRC-2, pin3: A%d, pin4: A%d, pin21: %s\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b, state->vrc_ls_chr ? "NC" : "A10");
12481248      }
12491249
12501250      if (state->pcb_id == KONAMI_VRC4)
12511251      {
12521252         state->vrc_ls_prg_a = nes_cart_get_line(image.get_feature("vrc4-pin3"));
12531253         state->vrc_ls_prg_b = nes_cart_get_line(image.get_feature("vrc4-pin4"));
1254//         printf("VRC-4, pin3: A%d, pin4: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b);
1254//          printf("VRC-4, pin3: A%d, pin4: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b);
12551255      }
1256     
1256
12571257      if (state->pcb_id == KONAMI_VRC6)
12581258      {
12591259         state->vrc_ls_prg_a = nes_cart_get_line(image.get_feature("vrc6-pin9"));
12601260         state->vrc_ls_prg_b = nes_cart_get_line(image.get_feature("vrc6-pin10"));
1261//         printf("VRC-6, pin9: A%d, pin10: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b);
1261//          printf("VRC-6, pin9: A%d, pin10: A%d\n", state->vrc_ls_prg_a, state->vrc_ls_prg_b);
12621262      }
12631263
12641264      /* Check for other misc board variants */
r8325r8326
12671267         if (image.get_feature("mmc1_type") != NULL && !strcmp(image.get_feature("mmc1_type"), "MMC1A"))
12681268            state->pcb_id = STD_SOROM_A;   // in MMC1-A PRG RAM is always enabled
12691269      }
1270     
1270
12711271      if (state->pcb_id == STD_SXROM)
12721272      {
12731273         if (image.get_feature("mmc1_type") != NULL && !strcmp(image.get_feature("mmc1_type"), "MMC1A"))
12741274            state->pcb_id = STD_SXROM_A;   // in MMC1-A PRG RAM is always enabled
12751275      }
1276     
1276
12771277      if (state->pcb_id == STD_NXROM || state->pcb_id == SUNSOFT_DCS)
12781278      {
12791279         if (image.get_software_region("minicart") != NULL)   // check for dual minicart
r8325r8326
12821282            // we shall load somewhere the minicart, but we still do not support this
12831283         }
12841284      }
1285     
1285
12861286#if 0
12871287      if (state->pcb_id == UNSUPPORTED_BOARD)
12881288         printf("This board (%s) is currently not supported by MESS\n", image_get_feature(image, "pcb"));
r8325r8326
13081308      }
13091309      if (state->mapper_ram_size)
13101310         memcpy(state->mapper_ram, temp_nvram + state->battery_size, state->mapper_ram_size);
1311     
1311
13121312      auto_free(image.device().machine, temp_nvram);
13131313   }
13141314
r8325r8326
13251325}
13261326
13271327/**************************
1328
1328
13291329 Disk System emulation
1330
1330
13311331**************************/
13321332
13331333static void fds_irq( running_device *device, int scanline, int vblank, int blanked )
13341334{
13351335   nes_state *state = (nes_state *)device->machine->driver_data;
1336   
1336
13371337   if (state->IRQ_enable_latch)
13381338      cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE);
1339   
1339
13401340   if (state->IRQ_enable)
13411341   {
13421342      if (state->IRQ_count <= 114)
r8325r8326
13541354{
13551355   nes_state *state = (nes_state *)space->machine->driver_data;
13561356   UINT8 ret = 0x00;
1357   
1357
13581358   switch (offset)
13591359   {
13601360      case 0x00: /* $4030 - disk status 0 */
r8325r8326
14031403static WRITE8_HANDLER( nes_fds_w )
14041404{
14051405   nes_state *state = (nes_state *)space->machine->driver_data;
1406   
1406
14071407   switch (offset)
14081408   {
14091409      case 0x00:
r8325r8326
14251425         break;
14261426      case 0x05:
14271427         state->fds_motor_on = BIT(data, 0);
1428         
1428
14291429         if (BIT(data, 1))
14301430            state->fds_head_position = 0;
1431         
1431
14321432         state->fds_read_mode = BIT(data, 2);
14331433         set_nt_mirroring(space->machine, BIT(data, 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
1434         
1434
14351435         if ((!(data & 0x40)) && (state->fds_write_reg & 0x40))
14361436            state->fds_head_position -= 2; // ???
1437         
1437
14381438         state->IRQ_enable_latch = BIT(data, 7);
14391439         state->fds_write_reg = data;
14401440         break;
r8325r8326
14961496   state->fds_head_position = 0;
14971497   state->fds_status0 = 0;
14981498   state->fds_read_mode = state->fds_write_reg = 0;
1499   
1499
15001500   state->fds_data = auto_alloc_array_clear(machine, UINT8, 65500 * 2);
15011501   state->fds_ram = auto_alloc_array_clear(machine, UINT8, 0x8000);
15021502   state_save_register_global_pointer(machine, state->fds_ram, 0x8000);
r8325r8326
15091509      state->chr_map[i].origin = i * 0x400; // for save state uses!
15101510      state->chr_map[i].access = &state->vram[state->chr_map[i].origin];
15111511   }
1512   
1512
15131513   floppy_install_load_proc(floppy_get_device(machine, 0), nes_load_proc);
15141514   floppy_install_unload_proc(floppy_get_device(machine, 0), nes_unload_proc);
15151515}
src/mess/machine/at29040.c
r8325r8326
274274void at29c040a_w(int id, offs_t offset, UINT8 data)
275275{
276276   offset &= ADDRESS_MASK;
277   
277
278278   /* The special CFI commands assume a smaller address space according */
279279   /* to the specification ("address format A14-A0") */
280280   offs_t cfi_offset = offset & 0x7fff;
281   
281
282282   if (at29c040a[id].s_enabling_bbl)
283283   {
284284      at29c040a[id].s_enabling_bbl = FALSE;
src/mess/machine/nes_unif.c
r8325r8326
1414typedef struct __unif
1515{
1616   const char *board; /* UNIF board */
17   
17
1818   int nvwram;
1919   int wram;
2020   int chrram;
r8325r8326
111111   { "BMC-SUPER24IN1SC03",         8,    0, CHRRAM_8,  NT_X,  BMC_S24IN1SC03},
112112   { "BMC-SUPERHIK8IN1",           8,    0, CHRRAM_0,  NT_X,  BMC_HIK8IN1},
113113   { "BMC-T-262",                  0,    0, CHRRAM_8,  NT_VERT,  BMC_T262},      //UNIF only!
114   { "BMC-WS",                     0,    0, CHRRAM_0,  NT_VERT,  BMC_WS},      //UNIF only!   
114   { "BMC-WS",                     0,    0, CHRRAM_0,  NT_VERT,  BMC_WS},      //UNIF only!
115115   { "BMC-N625092",                0,    0, CHRRAM_0,  NT_VERT,  UNL_N625092},
116116   // below are boards which are not yet supported, but are used by some UNIF files. they are here as a reminder to what is missing to be added
117117   { "UNL-TEK90",                  0,    0, CHRRAM_0,  NT_X,  UNSUPPORTED_BOARD},   // related to JY Company? (i.e. mappers 90, 209, 211?)
r8325r8326
158158{
159159   nes_state *state = (nes_state *)machine->driver_data;
160160   int err = 0, i;
161   
161
162162   switch (idx)
163163   {
164164      case STD_NROM:   // mapper 0
r8325r8326
218218         prg8_ab(machine, (state->prg_chunks << 1) - 3);
219219         prg8_cd(machine, (state->prg_chunks << 1) - 2);
220220         prg8_ef(machine, (state->prg_chunks << 1) - 1);
221         break;         
221         break;
222222      case STD_FXROM: // mapper 10
223223         state->MMC2_regs[0] = state->MMC2_regs[2] = 0;
224224         state->MMC2_regs[1] = state->MMC2_regs[3] = 0;
r8325r8326
271271         state->mmc_chr_source = state->chr_chunks ? CHRROM : CHRRAM;
272272         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
273273         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
274         break;         
274         break;
275275      case PAL_ZZ:   // mapper 37
276276         state->mmc3_alt_irq = 0;
277277         state->mmc_prg_bank[0] = state->mmc_prg_bank[2] = 0xfe;
r8325r8326
722722         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
723723         break;
724724// mapper 116
725//      case SOMERITEAM_SL12:
726//         mapper_initialize(machine, 116);
727//         break;
725//      case SOMERITEAM_SL12:
726//          mapper_initialize(machine, 116);
727//          break;
728728// mapper 117
729729      case FUTUREMEDIA_BOARD:
730730         state->mmc_chr_source = state->chr_chunks ? CHRROM : CHRRAM;
r8325r8326
11771177         set_nt_mirroring(machine, PPU_MIRROR_VERT);
11781178         break;
11791179
1180// UNIF only         
1180// UNIF only
11811181      case BMC_64IN1NR:
11821182         state->bmc_64in1nr_reg[0] = 0x80;
11831183         state->bmc_64in1nr_reg[1] = 0x43;
r8325r8326
12641264         prg16_89ab(machine, 0);
12651265         prg16_cdef(machine, state->prg_chunks - 1);
12661266         break;
1267         
1267
12681268      case BMC_VT5201:
12691269         prg32(machine, 0);
12701270         chr8(machine, 0, CHRROM);
r8325r8326
12771277         state->mmc_prg_bank[3] = 0xff;
12781278         bmc_bs5_update_banks(machine);
12791279         break;
1280         
1281      case BMC_810544:
1280
1281      case BMC_810544:
12821282         prg16_89ab(machine, 0);
12831283         prg16_cdef(machine, 0);
12841284         chr8(machine, 0, CHRROM);
12851285         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12861286         break;
1287         
1287
12881288      case UNSUPPORTED_BOARD:
12891289      default:
12901290         /* Mapper not supported */
12911291         err = 2;
12921292         break;
12931293   }
1294   
1294
12951295   return err;
12961296}
12971297
12981298/*************************************************************
1299
1299
13001300 unif_mapr_setup
13011301
13021302 setup the board specific variables (wram, nvwram, pcb_id etc.)
r8325r8326
13081308{
13091309   nes_state *state = (nes_state *)machine->driver_data;
13101310   const unif *unif_board = nes_unif_lookup(board);
1311   
1311
13121312   logerror("%s\n", board);
1313   
1313
13141314   if (unif_board == NULL)
13151315      fatalerror("Unknown UNIF board %s.", board);
1316   
1316
13171317   state->mapper = 0;   // this allows us to set up memory handlers without duplicating code (for the moment)
13181318   state->pcb_id = unif_board->board_idx;
13191319   state->battery = unif_board->nvwram;   // we should implement battery banks based on the size of this...
src/mess/machine/nes_mmc.c
r8325r8326
2525    * 000 F1 Race requires more precise PPU timing. It currently has plenty of 1-line glitches.
2626    * 001 AD&D Hillsfar and Bill & Ted are broken. We need to ignore the case of writes happening on 2
2727          consecutive CPU cycles because these games use dirty tricks to reset counters (see note in mapper1_w)
28    * 001 Yoshi flashes in-game. Zombie Hunter regressed. Rocket Ranger and Back to the Future have heavily
28    * 001 Yoshi flashes in-game. Zombie Hunter regressed. Rocket Ranger and Back to the Future have heavily
2929          corrupted graphics (since forever) and Snow Bros. (J) has never worked.
3030    * 001, 155 We don't handle (yet) WRAM enable/disable bit
3131    * 002, 003, 094, 097, 152 Bus conflict?
r8325r8326
177177{
178178   nes_state *state = (nes_state *)space->machine->driver_data;
179179   int bank = offset >> 10;
180   
180
181181   // a few CNROM boards contained copy protection schemes through
182182   // suitably configured diodes, so that subsequent CHR reads can
183   // give actual VROM content or open bus values.
183   // give actual VROM content or open bus values.
184184   // For most boards, chr_open_bus remains always zero.
185185   if (state->chr_open_bus)
186186      return 0xff;
r8325r8326
252252      bank &= (state->battery_size / 0x2000) - 1;
253253      state->prg_bank[4] = state->battery_bank5_start + bank;
254254   }
255   else
255   else
256256   {
257257      bank &= (state->wram_size / 0x2000) - 1;
258258      state->prg_bank[4] = state->prgram_bank5_start + bank;
r8325r8326
403403
404404   if (source == CHRRAM && state->vram == NULL)
405405      fatalerror("CHRRAM bankswitch with no VRAM");
406   
406
407407   if (source == CHRROM && state->vrom == NULL)
408408      fatalerror("CHRROM bankswitch with no VROM");
409409}
r8325r8326
443443   int i;
444444
445445   chr_sanity_check(machine, source);
446   
446
447447   if (source == CHRRAM)
448448   {
449449      bank &= ((state->vram_chunks << 1) - 1);
r8325r8326
482482   int i;
483483
484484   chr_sanity_check(machine, source);
485   
485
486486   if (source == CHRRAM)
487487   {
488488      bank &= ((state->vram_chunks << 2) - 1);
r8325r8326
530530   nes_state *state = (nes_state *)machine->driver_data;
531531
532532   chr_sanity_check(machine, source);
533   
533
534534   if (source == CHRRAM)
535535   {
536536      bank &= ((state->vram_chunks << 3) - 1);
r8325r8326
683683
684684
685685/*************************************************************
686
686
687687 Support for xml list
688
688
689689 *************************************************************/
690690
691691/* Include emulation of NES PCBs for softlist */
r8325r8326
703703
704704
705705/*************************************************************
706
706
707707 Support for .nes Files
708
708
709709 *************************************************************/
710710
711711/* Include emulation of iNES Mappers for .nes files */
src/mess/machine/nes_mmc.h
r8325r8326
55enum
66{
77   STD_NROM = 0,
8   STD_AXROM, STD_BXROM, STD_CNROM, STD_CPROM,
9   STD_DXROM, STD_EXROM, STD_FXROM, STD_GXROM,
10   STD_HKROM, STD_JXROM, STD_MXROM, STD_NXROM,
11   STD_PXROM, STD_SXROM, STD_TXROM, STD_TXSROM,
12   STD_TKROM, STD_TQROM, STD_TVROM,
8   STD_AXROM, STD_BXROM, STD_CNROM, STD_CPROM,
9   STD_DXROM, STD_EXROM, STD_FXROM, STD_GXROM,
10   STD_HKROM, STD_JXROM, STD_MXROM, STD_NXROM,
11   STD_PXROM, STD_SXROM, STD_TXROM, STD_TXSROM,
12   STD_TKROM, STD_TQROM, STD_TVROM,
1313   STD_UN1ROM, STD_UXROM,
1414   HVC_FAMBASIC, NES_QJ, PAL_ZZ, UXROM_CC,
1515   STD_DRROM, STD_SXROM_A, STD_SOROM, STD_SOROM_A,
1616   /* Discrete components boards (by various manufacturer) */
17   DIS_74X161X138, DIS_74X139X74,
17   DIS_74X161X138, DIS_74X139X74,
1818   DIS_74X377, DIS_74X161X161X32,
1919   /* Active Enterprises */
2020   ACTENT_ACT52,
r8325r8326
2424   AVE_NINA01, AVE_NINA06,
2525   /* Bandai */
2626   BANDAI_JUMP2, BANDAI_PT554,
27   BANDAI_DATACH, BANDAI_KARAOKE, BANDAI_OEKAKIDS,
27   BANDAI_DATACH, BANDAI_KARAOKE, BANDAI_OEKAKIDS,
2828   BANDAI_FCG, BANDAI_LZ93, BANDAI_LZ93EX,
2929   /* Caltron */
3030   CALTRON_6IN1,
r8325r8326
3434   /* Dreamtech */
3535   DREAMTECH_BOARD,
3636   /* Irem */
37   IREM_G101, IREM_H3001, IREM_LROG017,
37   IREM_G101, IREM_H3001, IREM_LROG017,
3838   IREM_TAM_S1, IREM_HOLYDIV,
3939   /* Jaleco */
4040   JALECO_SS88006, JALECO_JF11, JALECO_JF13,
r8325r8326
5252   /* Sachen */
5353   SACHEN_8259A, SACHEN_8259B, SACHEN_8259C,
5454   SACHEN_8259D, SACHEN_SA0036, SACHEN_SA0037,
55   SACHEN_SA72007, SACHEN_SA72008, SACHEN_TCA01,
56   SACHEN_TCU01, SACHEN_TCU02,
55   SACHEN_SA72007, SACHEN_SA72008, SACHEN_TCA01,
56   SACHEN_TCU01, SACHEN_TCU02,
5757   SACHEN_74LS374, SACHEN_74LS374_A,
5858   /* Sunsoft */
59   SUNSOFT_1, SUNSOFT_2, SUNSOFT_3, SUNSOFT_4,
59   SUNSOFT_1, SUNSOFT_2, SUNSOFT_3, SUNSOFT_4,
6060   SUNSOFT_DCS, SUNSOFT_5B, SUNSOFT_FME7,
6161   /* Taito */
62   TAITO_TC0190FMC, TAITO_TC0190FMCP,
62   TAITO_TC0190FMC, TAITO_TC0190FMCP,
6363   TAITO_X1_005, TAITO_X1_005_A, TAITO_X1_017,
6464   /* Tengen */
6565   TENGEN_800008, TENGEN_800032, TENGEN_800037,
6666   /* TXC */
67   TXC_22211A, TXC_22211B, TXC_22211C,
67   TXC_22211A, TXC_22211B, TXC_22211C,
6868   TXC_MXMDHTWO, TXC_TW, TXC_STRIKEWOLF,
6969   /* Multigame Carts */
7070   BMC_64IN1NR, BMC_190IN1, BMC_A65AS, BMC_GS2004, BMC_GS2013,
7171   BMC_HIK8IN1, BMC_NOVELDIAMOND, BMC_S24IN1SC03, BMC_T262,
7272   BMC_WS, BMC_SUPERBIG_7IN1, BMC_SUPERHIK_4IN1, BMC_BALLGAMES_11IN1,
73   BMC_MARIOPARTY_7IN1, BMC_SUPER_700IN1, BMC_FAMILY_4646B,
73   BMC_MARIOPARTY_7IN1, BMC_SUPER_700IN1, BMC_FAMILY_4646B,
7474   BMC_36IN1, BMC_21IN1, BMC_150IN1, BMC_35IN1, BMC_64IN1,
7575   BMC_15IN1, BMC_SUPERHIK_300IN1, BMC_9999999IN1, BMC_SUPERGUN_20IN1,
7676   BMC_GOLDENCARD_6IN1, BMC_72IN1, BMC_SUPER_42IN1, BMC_76IN1,
77   BMC_1200IN1, BMC_31IN1, BMC_22GAMES, BMC_20IN1, BMC_110IN1,
77   BMC_1200IN1, BMC_31IN1, BMC_22GAMES, BMC_20IN1, BMC_110IN1,
7878   BMC_GKA, BMC_GKB, BMC_VT5201, BMC_BENSHENG_BS5, BMC_810544,
7979   /* Unlicensed */
8080   UNL_8237, UNL_CC21, UNL_AX5705, UNL_KOF97,
src/mess/machine/pc8801.c
r8325r8326
508508   pc8801_update_bank(machine);
509509   pc8801_video_init(machine, hireso);
510510
511   if (extmem_mode != input_port_read(machine, "MEM"))
511   if (extmem_mode != input_port_read(machine, "MEM"))
512512   {
513513      extmem_mode = input_port_read(machine, "MEM");
514514
515515      // reset all the bank-related quantities
516516      memset(extRAM, 0, extRAM_size);
517517
518      for (i = 0; i < 4; i++)
518      for (i = 0; i < 4; i++)
519519         ext_bank_80[i] = NULL;
520520
521      for (i = 0; i < 256; i++)
521      for (i = 0; i < 256; i++)
522522         ext_bank_88[i] = NULL;
523523
524524      num80 = num88 = numIO = 0;
525525
526526      // set up the required number of banks
527      switch (extmem_mode)
527      switch (extmem_mode)
528528      {
529529         case 0x00: /* none */
530530            break;
r8325r8326
576576      }
577577
578578      // point the banks to the correct memory
579      if (num80 != 0 || num88 != 0 || numIO != 0)
579      if (num80 != 0 || num88 != 0 || numIO != 0)
580580      {
581581         e = extRAM;
582582
583         for (i = 0; i < num80; i++)
583         for (i = 0; i < num80; i++)
584584         {
585585            ext_bank_80[i] = e;
586586            e += 0x8000;
587587         }
588 
589         for (i = 0; i < num88 * 4; i++)
588
589         for (i = 0; i < num88 * 4; i++)
590590         {
591            for (j = i; j < 256; j += 16)
591            for (j = i; j < 256; j += 16)
592592            {
593593               ext_bank_88[j] = e;
594594            }
595595            e += 0x8000;
596596         }
597597
598         if (num88 == 0)
598         if (num88 == 0)
599599         {
600            for (i = 0; i < numIO * 32; i++)
600            for (i = 0; i < numIO * 32; i++)
601601            {
602602               ext_bank_88[(i & 0x07) | ((i & 0x18) << 1) | ((i & 0x20) >> 2) | (i & 0xc0)] = e;
603603               e += 0x8000;
604604            }
605         }
606         else
605         }
606         else
607607         {
608            for (i = 0; i < numIO * 32; i++)
608            for (i = 0; i < numIO * 32; i++)
609609            {
610610               ext_bank_88[(i & 0x07) | ((i & 0x78) << 1) | 0x08] = e;
611611               e += 0x8000;
src/mess/machine/nes_ines.c
r8325r8326
99typedef struct __mmc
1010{
1111   int iNesMapper; /* iNES Mapper # */
12   
12
1313   const char *desc;     /* Mapper description */
1414   write8_space_func mmc_write_low; /* $4100-$5fff write routine */
1515   read8_space_func mmc_read_low; /* $4100-$5fff read routine */
r8325r8326
893893         state->mmc5_high_chr = data & 0x03;
894894         if (state->mmc5_vram_control == 1)
895895         {
896            // in this case state->mmc5_high_chr selects which 256KB of CHR ROM
896            // in this case state->mmc5_high_chr selects which 256KB of CHR ROM
897897            // is to be used for all background tiles on the screen.
898898         }
899899         break;
900900
901         
901
902902      case 0x1100: /* $5200 */
903903         state->mmc5_split_scr = data;
904904         // in EX2 and EX3 modes, no split screen
r8325r8326
51455145    Games: Shanghai, Fantasy Zone
51465146
51475147    Very similar to mapper 89, but no NT mirroring for data&8
5148
5148
51495149    In MESS: Supported.
51505150
51515151*************************************************************/
r8325r8326
1090910909}
1091010910
1091110911/*************************************************************
10912
10912
1091310913 mapper_initialize
10914
10914
1091510915 Initialize various constants needed by mappers, depending
1091610916 on the mapper number. As long as the code is mainly iNES
1091710917 centric, also UNIF images will call this function to
1091810918 initialize their bankswitch and registers.
10919
10919
1092010920 *************************************************************/
1092110921
1092210922static int mapper_initialize( running_machine *machine, int mmc_num )
1092310923{
1092410924   nes_state *state = (nes_state *)machine->driver_data;
1092510925   int err = 0, i;
10926   
10926
1092710927   switch (mmc_num)
1092810928   {
1092910929      case 0:
r8325r8326
1117111171         state->mmc_chr_mask = 0x7f;
1117211172         mapper4_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
1117311173         mapper4_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
11174         //         memory_set_bankptr(machine, "bank5", state->wram);
11174         //          memory_set_bankptr(machine, "bank5", state->wram);
1117511175         break;
1117611176      case 46:
1117711177         prg32(machine, 0);
r8325r8326
1120911209         state->mmc_chr_mask = 0xff;
1121011210         mapper4_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
1121111211         mapper4_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
11212         //         memory_set_bankptr(machine, "bank5", state->wram);
11212         //          memory_set_bankptr(machine, "bank5", state->wram);
1121311213         break;
1121411214      case 57:
1121511215         state->mmc_cmd1 = 0x00;
r8325r8326
1146511465         // Famicom Jump II needs also the following!
1146611466         for (i = 0; i < 8; i++)
1146711467            state->map153_reg[i] = 0;
11468         
11468
1146911469         state->map153_bank_latch = 0;
1147011470         if (state->crc_hack)
1147111471            mapper153_set_prg(machine);
r8325r8326
1171211712         err = 2;
1171311713         break;
1171411714   }
11715   
11715
1171611716   return err;
1171711717}
1171811718
1171911719/*************************************************************
11720
11720
1172111721 nes_mapper_reset
11722
11722
1172311723 Resets the mapper bankswitch areas to their defaults.
1172411724 It returns a value "err" that indicates if it was
1172511725 successful. Possible values for err are:
11726
11726
1172711727 0 = success
1172811728 1 = no mapper found
1172911729 2 = mapper not supported
11730
11730
1173111731 *************************************************************/
1173211732
1173311733int nes_mapper_reset( running_machine *machine )
r8325r8326
1173511735   nes_state *state = (nes_state *)machine->driver_data;
1173611736   int err = 0, i;
1173711737   const mmc *mapper;
11738   
11738
1173911739   /* Set the mapper irq callback */
1174011740   mapper = nes_mapper_lookup(state->mapper);
11741   
11741
1174211742   if (mapper == NULL)
1174311743      fatalerror("Unimplemented Mapper %d", state->mapper);
1174411744   //      logerror("Mapper %d is not yet supported, defaulting to no mapper.\n", state->mapper);    // this one would be a better output
11745   
11745
1174611746   ppu2c0x_set_scanline_callback(state->ppu, mapper ? mapper->mmc_scanline : NULL);
1174711747   ppu2c0x_set_hblank_callback(state->ppu, mapper ? mapper->mmc_hblank : NULL);
11748   
11748
1174911749   if (state->chr_chunks == 0)
1175011750      chr8(machine, 0, CHRRAM);
1175111751   else
1175211752      chr8(machine, 0, CHRROM);
11753   
11753
1175411754   state->mmc5_vram_control = 0;
11755   
11755
1175611756   /* Here, we init a few helpers: 4 prg banks and 16 chr banks - some mappers use them */
1175711757   for (i = 0; i < 4; i++)
1175811758      state->mmc_prg_bank[i] = 0;
r8325r8326
1176011760      state->mmc_vrom_bank[i] = 0;
1176111761   for (i = 0; i < 16; i++)
1176211762      state->mmc_extra_bank[i] = 0;
11763   
11763
1176411764   /* Finally, we init IRQ-related quantities. */
1176511765   state->IRQ_enable = state->IRQ_enable_latch = 0;
1176611766   state->IRQ_count = state->IRQ_count_latch = 0;
1176711767   state->IRQ_toggle = 0;
11768   
11768
1176911769   err = mapper_initialize(machine, state->mapper);
11770   
11770
1177111771   return err;
1177211772}
1177311773
r8325r8326
1177511775{
1177611776   nes_state *state = (nes_state *)machine->driver_data;
1177711777   const mmc *mapper = nes_mapper_lookup(state->mapper);
11778   
11778
1177911779   if (mapper)
1178011780   {
1178111781      state->mmc_write_low = mapper->mmc_write_low;
src/mess/machine/6525tpi.c
r8325r8326
625625   return tpi6525->ddr_c;
626626}
627627
628DEFINE_LEGACY_DEVICE(TPI6525, tpi6525);
No newline at end of file
628DEFINE_LEGACY_DEVICE(TPI6525, tpi6525);
src/mess/machine/snescart.c
r8325r8326
232232   UINT8 ii;
233233   UINT8 *battery_ram, *ptr;
234234   int st_sram_offset = 0;
235   
235
236236   battery_ram = (UINT8*)malloc(0x20000);
237237   ptr = battery_ram;
238238   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, cart_tag));
239239   image->battery_load(battery_ram, 0x20000, 0);
240   
240
241241   if (strcmp(cart_tag, "slot_a") == 0)
242242      st_sram_offset = 0x608000;
243   
243
244244   if (strcmp(cart_tag, "slot_b") == 0)
245245      st_sram_offset = 0x708000;
246   
246
247247   /* Cart RAM is at 0x60-0x63:0x8000-0xffff (+0x10 for slot2) */
248248   for (ii = 0; ii < 4; ii++)
249249   {
r8325r8326
252252      /* mirroring */
253253      memcpy(&snes_ram[0x800000 + st_sram_offset + (ii * 0x010000)], &snes_ram[st_sram_offset + (ii * 0x010000)], 0x8000);
254254   }
255   
255
256256   free(battery_ram);
257257}
258258
r8325r8326
261261   snes_state *state = (snes_state *)machine->driver_data;
262262   UINT8 ii;
263263   UINT8 *battery_ram, *ptr;
264   
264
265265   battery_ram = (UINT8*)malloc(0x20000);
266266   ptr = battery_ram;
267   
267
268268   if (state->cart[0].slot_in_use)
269269   {
270270      for (ii = 0; ii < 4; ii++)
r8325r8326
284284      device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "slot_b"));
285285      image->battery_save(battery_ram, 0x20000);
286286   }
287   
287
288288   free(battery_ram);
289289}
290290
r8325r8326
415415{
416416   UINT8 header[512];
417417   UINT32 offset = 512;
418   
418
419419   /* Check for a header (512 bytes) */
420420   if (image.software_entry() == NULL)
421421      image.fread( header, 512);
422422   else
423423      memcpy(header, image.get_software_region("rom"), 512);
424   
424
425425   if ((header[8] == 0xaa) && (header[9] == 0xbb) && (header[10] == 0x04))
426426   {
427427      /* Found an SWC identifier */
r8325r8326
443443      logerror("No header found.\n");
444444      offset = 0;
445445   }
446   
446
447447   return offset;
448448}
449449
450450
451/* This determines if a cart is in Mode 20, 21, 22 or 25; sets state->cart[0].mode and
451/* This determines if a cart is in Mode 20, 21, 22 or 25; sets state->cart[0].mode and
452452 state->cart[0].sram accordingly; and returns the offset of the internal header (needed to
453453 detect BSX and ST carts) */
454454static UINT32 snes_find_hilo_mode( device_image_interface &image, UINT8 *buffer, UINT32 offset, int cartid )
r8325r8326
461461   valid_mode20 = snes_validate_infoblock(buffer, 0x007fc0);
462462   valid_mode21 = snes_validate_infoblock(buffer, 0x00ffc0);
463463   valid_mode25 = snes_validate_infoblock(buffer, 0x40ffc0);
464   
464
465465   /* Images larger than 32mbits are likely ExHiRom */
466466   if (valid_mode25)
467467      valid_mode25 += 4;
468   
468
469469   if ((valid_mode20 >= valid_mode21) && (valid_mode20 >= valid_mode25))
470470   {
471471      if ((buffer[0x007fd5] == 0x32) || ((state->cart_size - offset) > 0x401000))
472472         state->cart[cartid].mode = SNES_MODE_22;   // ExLoRom
473473      else
474474         state->cart[cartid].mode = SNES_MODE_20;   // LoRom
475     
475
476476      retvalue = 0x007fc0;
477     
477
478478      /* a few games require 512k, however we store twice as much to be sure to cover the various mirrors */
479479      state->cart[cartid].sram_max = 0x100000;
480480   }
r8325r8326
497497          (state->cart[cartid].mode == SNES_MODE_22) ? "ExLoROM" :
498498          (state->cart[cartid].mode == SNES_MODE_25) ? "ExHiROM" : "Other (BSX or ST)",
499499          valid_mode20, valid_mode21, valid_mode25);
500   
500
501501   return retvalue;
502502}
503503
r8325r8326
515515      case 0x02:
516516         state->has_addon_chip = HAS_NONE;
517517         break;
518         
518
519519      case 0x03:
520520         if (snes_r_bank1(space, 0x00ffd5) == 0x30)
521521            state->has_addon_chip = HAS_DSP4;
522522         else
523523            state->has_addon_chip = HAS_DSP1;
524524         break;
525         
525
526526      case 0x04:
527527         state->has_addon_chip = HAS_DSP1;
528528         break;
529         
529
530530      case 0x05:
531531         if (snes_r_bank1(space, 0x00ffd5) == 0x20)
532532            state->has_addon_chip = HAS_DSP2;
r8325r8326
536536         else
537537            state->has_addon_chip = HAS_DSP1;
538538         break;
539         
539
540540      case 0x13:   // Mario Chip 1
541541      case 0x14:   // GSU-x
542542      case 0x15:   // GSU-x
r8325r8326
544544         if (snes_r_bank1(space, 0x00ffd5) == 0x20)
545545            state->has_addon_chip = HAS_SUPERFX;
546546         break;
547         
547
548548      case 0x25:
549549         state->has_addon_chip = HAS_OBC1;
550550         break;
551         
551
552552      case 0x32:   // needed by a Sample game (according to ZSNES)
553553      case 0x34:
554554      case 0x35:
r8325r8326
559559            printf("This is a SA-1 type game, currently unsupported by the driver");
560560         }
561561         break;
562         
562
563563      case 0x43:
564564      case 0x45:
565565         if (snes_r_bank1(space, 0x00ffd5) == 0x32)
r8325r8326
567567            state->has_addon_chip = HAS_SDD1;
568568         }
569569         break;
570         
570
571571      case 0x55:
572572         if (snes_r_bank1(space, 0x00ffd5) == 0x35)
573573         {
574574            state->has_addon_chip = HAS_RTC;
575575         }
576576         break;
577         
577
578578      case 0xe3:
579579         state->has_addon_chip = HAS_Z80GB;
580580         supported_type = 0;
581581         break;
582         
582
583583      case 0xf3:
584584         state->has_addon_chip = HAS_CX4;
585585         break;
586         
586
587587      case 0xf5:
588588         if (snes_r_bank1(space, 0x00ffd5) == 0x30)
589589         {
r8325r8326
595595            state->has_addon_chip = HAS_SPC7110;
596596         }
597597         break;
598         
598
599599      case 0xf6:
600600         /* These Seta ST-01X chips have both 0x30 at 0x00ffd5,
601          they only differ for the 'size' at 0x00ffd7 */
601            they only differ for the 'size' at 0x00ffd7 */
602602         if (snes_r_bank1(space, 0x00ffd7) < 0x0a)
603603         {
604604            state->has_addon_chip = HAS_ST011;
r8325r8326
609609            state->has_addon_chip = HAS_ST010;
610610         }
611611         break;
612         
612
613613      case 0xf9:
614614         if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
615615         {
r8325r8326
617617            supported_type = 0;
618618         }
619619         break;
620         
620
621621      default:
622622         state->has_addon_chip = HAS_UNK;
623623         supported_type = 0;
624624         break;
625625   }
626   
626
627627   return supported_type;
628628}
629629
r8325r8326
633633   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
634634   char title[21], rom_id[4], company_id[2];
635635   int i, company, has_ram = 0, has_sram = 0;
636   
636
637637   /* Company */
638638   for (i = 0; i < 2; i++)
639639      company_id[i] = snes_r_bank1(space, 0x00ffb0 + i);
640640   company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]);
641641   if (company == 0)
642642      company = snes_r_bank1(space, 0x00ffda);
643   
643
644644   /* ROM ID */
645645   for( i = 0; i < 4; i++ )
646646      rom_id[i] = snes_r_bank1(space, 0x00ffb2 + i);
647   
647
648648   /* Title */
649649   for( i = 0; i < 21; i++ )
650650      title[i] = snes_r_bank1(space, 0x00ffc0 + i);
651   
651
652652   /* RAM */
653653   if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 1) ||
654654      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
655655      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 4) ||
656656      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5))
657657      has_ram = 1;
658   
658
659659   /* SRAM */
660660   if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
661661      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5) ||
662662      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 6))
663663      has_sram = 1;
664   
664
665665   logerror( "ROM DETAILS\n" );
666666   logerror( "===========\n\n" );
667667   logerror( "\tTotal blocks:  %d (%dmb)\n", total_blocks, total_blocks / (state->cart[0].mode & 5 ? 32 : 16) );
r8325r8326
672672          (state->cart[0].mode == SNES_MODE_25) ? "ExHiROM" : "Other (BSX or ST)" );
673673   logerror( "\tCompany:       %s [%.2s]\n", companies[company], company_id );
674674   logerror( "\tROM ID:        %.4s\n\n", rom_id );
675   
675
676676   logerror( "HEADER DETAILS\n" );
677677   logerror( "==============\n\n" );
678678   logerror( "\tName:          %.21s\n", title );
679679   logerror( "\tSpeed:         %s [%d]\n", ((snes_r_bank1(space, 0x00ffd5) & 0xf0)) ? "FastROM" : "SlowROM", (snes_r_bank1(space, 0x00ffd5) & 0xf0) >> 4 );
680680   logerror( "\tBank size:     %s [%d]\n", (snes_r_bank1(space, 0x00ffd5) & 0xf) ? "HiROM" : "LoROM", snes_r_bank1(space, 0x00ffd5) & 0xf );
681   
681
682682   logerror( "\tType:          %s", types[state->has_addon_chip]);
683683   if (has_ram)
684684      logerror( ", RAM");
685685   if (has_sram)
686686      logerror( ", SRAM");
687687   logerror( " [%d]\n", snes_r_bank1(space, 0x00ffd6) );
688   
688
689689   logerror( "\tSize:          %d megabits [%d]\n", 1 << (snes_r_bank1(space, 0x00ffd7) - 7), snes_r_bank1(space, 0x00ffd7) );
690690   logerror( "\tSRAM:          %d kilobits [%d]\n", state->cart[0].sram * 8, snes_ram[0xffd8] );
691691   logerror( "\tCountry:       %s [%d]\n", countries[snes_r_bank1(space, 0x00ffd9)], snes_r_bank1(space, 0x00ffd9) );
r8325r8326
695695   logerror( "\tChecksum:      %X %X\n", snes_r_bank1(space, 0x00ffdf), snes_r_bank1(space, 0x00ffde) );
696696   logerror( "\tNMI Address:   %2X%2Xh\n", snes_r_bank1(space, 0x00fffb), snes_r_bank1(space, 0x00fffa) );
697697   logerror( "\tStart Address: %2X%2Xh\n\n", snes_r_bank1(space, 0x00fffd), snes_r_bank1(space, 0x00fffc) );
698   
698
699699   logerror( "\tMode: %d\n", state->cart[0].mode);
700   
700
701701   if (!supported)
702702      logerror("WARNING: This cart type \"%s\" is not supported yet!\n", types[state->has_addon_chip]);
703703}
r8325r8326
719719
720720   /* Check for a header (512 bytes), and skip it if found */
721721   offset = snes_skip_header(image, state->cart_size);
722   
722
723723   if (image.software_entry() == NULL)
724724   {
725725      image.fseek(offset, SEEK_SET);
r8325r8326
727727   }
728728   else
729729      memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset);
730   
730
731731   if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset);
732732
733733   /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */
r8325r8326
736736   /* Then, detect BS-X carts */
737737   // Detect presence of BS-X Flash Cart
738738   if ((ROM[int_header_offs + 0x13] == 0x00 || ROM[int_header_offs + 0x13] == 0xff) &&
739         ROM[int_header_offs + 0x14] == 0x00)
739         ROM[int_header_offs + 0x14] == 0x00)
740740   {
741741      UINT8 n15 = ROM[int_header_offs + 0x15];
742      if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc)
742      if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc)
743743      {
744         if (ROM[int_header_offs + 0x1a] == 0x33 || ROM[int_header_offs + 0x1a] == 0xff)
744         if (ROM[int_header_offs + 0x1a] == 0x33 || ROM[int_header_offs + 0x1a] == 0xff)
745745         {
746746            // BS-X Flash Cart
747747            state->cart[0].mode = SNES_MODE_BSX;
748748         }
749749      }
750750   }
751   
751
752752   // Detect presence of BS-X flash cartridge connector
753753   if ((ROM[int_header_offs - 14] == 'Z') && (ROM[int_header_offs - 11] == 'J'))
754754   {
755755      UINT8 n13 = ROM[int_header_offs - 13];
756      if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9'))
756      if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9'))
757757      {
758         if (ROM[int_header_offs + 0x1a] == 0x33 ||
759            (ROM[int_header_offs - 10] == 0x00 && ROM[int_header_offs - 4] == 0x00))
758         if (ROM[int_header_offs + 0x1a] == 0x33 ||
759            (ROM[int_header_offs - 10] == 0x00 && ROM[int_header_offs - 4] == 0x00))
760760         {
761761            has_bsx_slot = 1;
762762         }
763763      }
764764   }
765   
765
766766   // If there is a BS-X connector, detect if it is the Base Cart or a compatible slotted cart
767   if (has_bsx_slot)
767   if (has_bsx_slot)
768768   {
769      if (!memcmp(ROM + int_header_offs, "Satellaview BS-X     ", 21))
769      if (!memcmp(ROM + int_header_offs, "Satellaview BS-X     ", 21))
770770      {
771771         //BS-X Base Cart
772772         state->cart[0].mode = SNES_MODE_BSX;
773773         // handle RAM
774      }
775      else
774      }
775      else
776776      {
777777         state->cart[0].mode = (int_header_offs ==0x007fc0) ? SNES_MODE_BSLO : SNES_MODE_BSHI;
778778         // handle RAM?
r8325r8326
780780   }
781781
782782   /* Then, detect Sufami Turbo carts */
783   if (!memcmp(ROM, "BANDAI SFC-ADX", 14))
783   if (!memcmp(ROM, "BANDAI SFC-ADX", 14))
784784   {
785785      state->cart[0].mode = SNES_MODE_ST;
786786      if (!memcmp(ROM + 16, "SFC-ADX BACKUP", 14))
787787         st_bios = 1;
788788   }
789   
789
790790   if (SNES_CART_DEBUG) printf("mode %d\n", state->cart[0].mode);
791   
791
792792   /* FIXME: Insert crc check here? */
793793
794794   /* How many blocks of data are available to be loaded? */
r8325r8326
955955               memcpy(&snes_ram[0x008000 + i * 0x10000], &ROM[0x000000 + i * 0x8000], 0x8000);
956956               /* Mirroring */
957957               memcpy(&snes_ram[0x808000 + i * 0x10000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
958               
958
959959               /* Additional mirrors (to fill snes_ram up to 0x1fffff) */
960960               for (j = 1; j < 4; j++)
961961               {
r8325r8326
976976         if (!has_bsx_slot)
977977         {
978978            printf("This is a BS-X flash cart and cannot be loaded in snes/snespal.\n");
979//            printf("Please use snesbsx driver to load it, instead.\n");
979//              printf("Please use snesbsx driver to load it, instead.\n");
980980            return IMAGE_INIT_FAIL;
981981         }
982982#endif
983983         break;
984         
984
985985      default:
986986      case SNES_MODE_20:
987987      /* LoROM carts load data in banks 0x00 to 0x7f at address 0x8000 (actually up to 0x7d, because 0x7e and
r8325r8326
10721072{
10731073   running_machine *machine = image.device().machine;
10741074   snes_state *state = (snes_state *)machine->driver_data;
1075   int total_blocks, read_blocks;
1075   int total_blocks, read_blocks;
10761076   int st_bios = 0, slot_id = 0;
10771077   UINT32 offset, st_data_offset = 0;
10781078   UINT8 *ROM = memory_region(image.device().machine, image.device().tag());
r8325r8326
10951095      state->cart_size = image.length();
10961096   else
10971097      state->cart_size = image.get_software_region_length("rom");
1098   
1098
10991099   /* Check for a header (512 bytes), and skip it if found */
11001100   offset = snes_skip_header(image, state->cart_size);
1101   
1101
11021102   if (image.software_entry() == NULL)
11031103   {
11041104      image.fseek(offset, SEEK_SET);
r8325r8326
11061106   }
11071107   else
11081108      memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset);
1109   
1109
11101110   if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset);
1111   
1111
11121112   /* Detect Sufami Turbo carts */
1113   if (!memcmp(ROM, "BANDAI SFC-ADX", 14))
1113   if (!memcmp(ROM, "BANDAI SFC-ADX", 14))
11141114   {
11151115      state->cart[slot_id].mode = SNES_MODE_ST;
11161116      if (!memcmp(ROM + 16, "SFC-ADX BACKUP", 14))
r8325r8326
11221122      printf("This image cannot be loaded in snesst (Use snes or snespal drivers, instead).\n");
11231123      return IMAGE_INIT_FAIL;
11241124   }
1125   
1125
11261126   if (st_bios == 1)
11271127   {
11281128      printf("This is the Sufami Turbo BIOS and not a Sufami Turbo data pack.\n");
r8325r8326
11311131   }
11321132
11331133   /* FIXME: Insert crc check here? */
1134   
1134
11351135   /* How many blocks of data are available to be loaded? */
11361136   total_blocks = (state->cart_size - offset) / 0x8000;
11371137   read_blocks = 0;
1138   
1139   if (SNES_CART_DEBUG)
1138
1139   if (SNES_CART_DEBUG)
11401140      printf("blocks %d\n", total_blocks);
1141   
1141
11421142   // actually load the cart
11431143   while (read_blocks < 32 && read_blocks < total_blocks)
11441144   {
r8325r8326
11471147      memcpy(&snes_ram[0x008000 + st_data_offset + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000);
11481148      /* Mirroring */
11491149      memcpy(&snes_ram[0x808000 + st_data_offset + read_blocks * 0x10000], &snes_ram[0x8000 + st_data_offset + (read_blocks * 0x10000)], 0x8000);
1150     
1150
11511151      read_blocks++;
11521152   }
11531153
r8325r8326
11581158      while ((read_blocks % (32 >> j)) && j < 5)
11591159         j++;
11601160      repeat_blocks = read_blocks % (32 >> (j - 1));
1161     
1161
11621162      memcpy(&snes_ram[st_data_offset + read_blocks * 0x10000], &snes_ram[st_data_offset + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
11631163      memcpy(&snes_ram[0x800000 + st_data_offset + read_blocks * 0x10000], &snes_ram[st_data_offset + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
11641164      read_blocks += repeat_blocks;
r8325r8326
11691169   state->cart[slot_id].slot_in_use = 1;   // aknowledge the cart in this slot, for saving sram at exit
11701170
11711171   auto_free(image.device().machine, ROM);
1172   
1172
11731173   return IMAGE_INIT_PASS;
11741174}
11751175
r8325r8326
11811181   int has_bsx_slot = 0;
11821182   UINT32 offset, int_header_offs;
11831183   UINT8 *ROM = memory_region(image.device().machine, "cart");
1184   
1184
11851185   if (image.software_entry() == NULL)
11861186      state->cart_size = image.length();
11871187   else
11881188      state->cart_size = image.get_software_region_length("rom");
1189   
1189
11901190   /* Check for a header (512 bytes), and skip it if found */
11911191   offset = snes_skip_header(image, state->cart_size);
1192   
1192
11931193   if (image.software_entry() == NULL)
11941194   {
11951195      image.fseek(offset, SEEK_SET);
r8325r8326
11971197   }
11981198   else
11991199      memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset);
1200   
1200
12011201   if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset);
1202   
1202
12031203   /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */
12041204   int_header_offs = snes_find_hilo_mode(image, ROM, offset, 0);
1205   
1205
12061206   // Detect presence of BS-X flash cartridge connector
12071207   if ((ROM[int_header_offs - 14] == 'Z') && (ROM[int_header_offs - 11] == 'J'))
12081208   {
12091209      UINT8 n13 = ROM[int_header_offs - 13];
1210      if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9'))
1210      if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9'))
12111211      {
1212         if (ROM[int_header_offs + 0x1a] == 0x33 ||
1213            (ROM[int_header_offs - 10] == 0x00 && ROM[int_header_offs - 4] == 0x00))
1212         if (ROM[int_header_offs + 0x1a] == 0x33 ||
1213            (ROM[int_header_offs - 10] == 0x00 && ROM[int_header_offs - 4] == 0x00))
12141214         {
12151215            has_bsx_slot = 1;
12161216         }
12171217      }
12181218   }
1219   
1219
12201220   // If there is a BS-X connector, detect if it is the Base Cart or a compatible slotted cart
1221   if (has_bsx_slot)
1221   if (has_bsx_slot)
12221222   {
1223      if (!memcmp(ROM + int_header_offs, "Satellaview BS-X     ", 21))
1223      if (!memcmp(ROM + int_header_offs, "Satellaview BS-X     ", 21))
12241224      {
12251225         //BS-X Base Cart
12261226         state->cart[0].mode = SNES_MODE_BSX;
12271227         // handle RAM
1228      }
1229      else
1228      }
1229      else
12301230      {
12311231         state->cart[0].mode = (int_header_offs ==0x007fc0) ? SNES_MODE_BSLO : SNES_MODE_BSHI;
12321232         // handle RAM?
r8325r8326
12381238      printf("This image cannot be loaded in the first cartslot of snesbsx.\n");
12391239      return IMAGE_INIT_FAIL;
12401240   }
1241   
12421241
1242
12431243   /* FIXME: Insert crc check here? */
1244   
1244
12451245   /* How many blocks of data are available to be loaded? */
12461246   total_blocks = (state->cart_size - offset) / 0x8000;
12471247   read_blocks = 0;
1248   
1248
12491249   if (SNES_CART_DEBUG) printf("blocks %d\n", total_blocks);
1250   
1250
12511251   // actually load the cart
12521252   while (read_blocks < 64 && read_blocks < total_blocks)
12531253   {
r8325r8326
12551255      memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000);
12561256      /* Mirroring */
12571257      memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
1258     
1258
12591259      read_blocks++;
12601260   }
1261   
1261
12621262   /* Filling banks up to 0x3f and their mirrors */
12631263   while (read_blocks % 64)
12641264   {
r8325r8326
12661266      while ((read_blocks % (64 >> j)) && j < 6)
12671267         j++;
12681268      repeat_blocks = read_blocks % (64 >> (j - 1));
1269     
1269
12701270      memcpy(&snes_ram[read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
12711271      memcpy(&snes_ram[0x800000 + read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
12721272      read_blocks += repeat_blocks;
r8325r8326
12811281   snes_state *state = (snes_state *)machine->driver_data;
12821282   UINT32 offset, int_header_offs;
12831283   UINT8 *ROM = memory_region(image.device().machine, "flash");
1284   
1284
12851285   if (image.software_entry() == NULL)
12861286      state->cart_size = image.length();
12871287   else
12881288      state->cart_size = image.get_software_region_length("rom");
1289   
1289
12901290   /* Check for a header (512 bytes), and skip it if found */
12911291   offset = snes_skip_header(image, state->cart_size);
1292   
1292
12931293   if (image.software_entry() == NULL)
12941294   {
12951295      image.fseek(offset, SEEK_SET);
r8325r8326
12971297   }
12981298   else
12991299      memcpy(ROM, image.get_software_region("rom") + offset, state->cart_size - offset);
1300   
1300
13011301   if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset);
1302   
1302
13031303   /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */
13041304   int_header_offs = snes_find_hilo_mode(image, ROM, offset, 1);
1305   
1305
13061306   // Detect presence of BS-X Flash Cart
13071307   if ((ROM[int_header_offs + 0x13] == 0x00 || ROM[int_header_offs + 0x13] == 0xff) &&
1308      ROM[int_header_offs + 0x14] == 0x00)
1308      ROM[int_header_offs + 0x14] == 0x00)
13091309   {
13101310      UINT8 n15 = ROM[int_header_offs + 0x15];
1311      if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc)
1311      if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc)
13121312      {
1313         if (ROM[int_header_offs + 0x1a] == 0x33 || ROM[int_header_offs + 0x1a] == 0xff)
1313         if (ROM[int_header_offs + 0x1a] == 0x33 || ROM[int_header_offs + 0x1a] == 0xff)
13141314         {
13151315            // BS-X Flash Cart
13161316            state->cart[1].mode = SNES_MODE_BSX;
r8325r8326
13241324      printf("This image cannot be loaded in the second cartslot of snesbsx.\n");
13251325      return IMAGE_INIT_FAIL;
13261326   }
1327     
1327
13281328   // actually load the cart
13291329   return IMAGE_INIT_PASS;
13301330}
r8325r8326
13531353   MDRV_CARTSLOT_INTERFACE("sufami_cart")
13541354   MDRV_CARTSLOT_LOAD(sufami_cart)
13551355
1356//   MDRV_SOFTWARE_LIST_ADD("snes")
1356//  MDRV_SOFTWARE_LIST_ADD("snes")
13571357MACHINE_DRIVER_END
13581358
13591359// This (hackily) emulates a SNES unit where you want to load a BS-X compatible cart:
1360// hence, the user can mount a SNES cart in the first slot (either a BS-X BIOS cart, or a
1361// BS-X compatible one, e.g. Same Game), and there is a second slot for the 8M data pack
1360// hence, the user can mount a SNES cart in the first slot (either a BS-X BIOS cart, or a
1361// BS-X compatible one, e.g. Same Game), and there is a second slot for the 8M data pack
13621362// (in a real SNES this would have been inserted in the smaller slot on the cart itself)
13631363MACHINE_DRIVER_START( bsx_cartslot )
13641364   MDRV_CARTSLOT_ADD("cart")
r8325r8326
13731373   MDRV_CARTSLOT_INTERFACE("bsx_cart")
13741374   MDRV_CARTSLOT_LOAD(bsx2slot_cart)
13751375
1376//   MDRV_SOFTWARE_LIST_ADD("snes")
1376//  MDRV_SOFTWARE_LIST_ADD("snes")
13771377MACHINE_DRIVER_END
13781378
13791379DRIVER_INIT( snes_mess )
r8325r8326
14011401      memcpy(&snes_ram[0x008000 + i * 0x10000], &STBIOS[0x000000 + i * 0x8000], 0x8000);
14021402      /* Mirroring */
14031403      memcpy(&snes_ram[0x808000 + i * 0x10000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
1404     
1404
14051405      /* Additional mirrors (to fill snes_ram up to 0x1fffff) */
14061406      for (j = 1; j < 4; j++)
14071407      {
r8325r8326
14091409         memcpy(&snes_ram[0x808000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
14101410      }
14111411   }
1412   
1412
14131413}
src/mess/machine/c64.c
r8325r8326
12521252      // setup Ultimax mode
12531253      c64_exrom = 1;
12541254      c64_game  = 0;
1255     
1255
12561256      roml = c64_roml;
12571257      romh = c64_romh;
1258     
1258
12591259      memset(roml, 0, 0x2000);
12601260      memset(romh, 0, 0x2000);
12611261
r8325r8326
12671267      // is there anything to load at 0xe000?
12681268      size = image.get_software_region_length("romh");
12691269      if (size)
1270         memcpy(romh, image.get_software_region("romh"), size);     
1270         memcpy(romh, image.get_software_region("romh"), size);
12711271   }
12721272
12731273   return result;
src/mess/includes/nes.h
r8325r8326
153153
154154   UINT8 mmc_latch1, mmc_latch2;
155155   UINT8 mmc_reg[16];
156   
156
157157   UINT8 mmc_dipsetting;
158158
159159   // misc mapper related variables which should be merged with the above one, where possible
r8325r8326
197197   UINT8 bmc_64in1nr_reg[4];
198198   UINT8 unl_8237_reg[3];
199199   UINT8 bmc_s24in1sc03_reg[3];
200   
200
201201   // mapper 68 needs these for NT mirroring!
202202   int m68_mirror;
203203   int m0, m1;
204   
204
205205   // Famicom Jump II is identified as Mapper 153, but it works in a completely different way.
206206   // in particular, it requires these (not needed by other Mapper 153 games)
207207   UINT8 map153_reg[8];
src/mess/video/zx.c
r8325r8326
108108   int height = screen->height();
109109   const rectangle r1 = screen->visible_area();
110110   rectangle r;
111   
111
112112   bitmap_t *bitmap = machine->generic.tmpbitmap;
113113   r.min_x = r1.min_x;
114114   r.max_x = r1.max_x;
src/mess/video/i8275.c
r8325r8326
507507   /* get the screen device */
508508   i8275->screen = device->machine->device<screen_device>(i8275->intf->screen_tag);
509509
510   
510
511511   assert(i8275->screen != NULL);
512512
513513   /* resolve callbacks */
src/mess/video/nes.c
r8325r8326
3838VIDEO_START( nes )
3939{
4040   nes_state *state = (nes_state *)machine->driver_data;
41   
41
4242   state->last_frame_flip =  0;
43   
43
4444   add_reset_callback(machine, nes_vh_reset);
4545}
4646
src/mess/video/gb.c
r8325r8326
11621162               rectangle r;
11631163               const rectangle &r1 = screen->visible_area();
11641164               r.min_x = r1.min_x;
1165               r.max_x = r1.max_x;               
1165               r.max_x = r1.max_x;
11661166               r.min_y = r.max_y = gb_lcd.current_line;
11671167               bitmap_fill( bitmap, &r , ( ! gb_lcd.gbc_mode ) ? 0 : 32767);
11681168            }
src/mess/video/smsvdp.c
r8325r8326
15841584   {
15851585      /* --- the following bits of info are returned as 64-bit signed integers --- */
15861586      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(smsvdp_t);               break;
1587     
1587
15881588      /* --- the following bits of info are returned as pointers to data or functions --- */
15891589      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(smsvdp);      break;
15901590      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
src/mess/video/ef9345.c
r8325r8326
146146         ef9345->acc_char[0x0400 + j + i +  8] |= 0x08; //aigu
147147         ef9345->acc_char[0x0600 + j + i +  4] |= 0x04; //grave
148148         ef9345->acc_char[0x0600 + j + i +  8] |= 0x08; //grave
149         
149
150150         ef9345->acc_char[0x0a00 + j + i +  4] |= 0x1c; //tilde
151151         ef9345->acc_char[0x0c00 + j + i +  4] |= 0x10; //aigu
152152         ef9345->acc_char[0x0c00 + j + i +  8] |= 0x08; //aigu
153153         ef9345->acc_char[0x0e00 + j + i +  4] |= 0x04; //grave
154154         ef9345->acc_char[0x0e00 + j + i +  8] |= 0x08; //grave
155         
155
156156         ef9345->acc_char[0x1200 + j + i +  4] |= 0x08; //point
157157         ef9345->acc_char[0x1400 + j + i +  4] |= 0x14; //trema
158158         ef9345->acc_char[0x1600 + j + i + 32] |= 0x08; //cedille
159159         ef9345->acc_char[0x1600 + j + i + 36] |= 0x04; //cedille
160         
160
161161         ef9345->acc_char[0x1a00 + j + i +  4] |= 0x08; //point
162162         ef9345->acc_char[0x1c00 + j + i +  4] |= 0x14; //trema
163163         ef9345->acc_char[0x1e00 + j + i + 32] |= 0x08; //cedille
164164         ef9345->acc_char[0x1e00 + j + i + 36] |= 0x04; //cedille
165165      }
166   
166
167167   //initialisation des pointeurs de polices fixes
168168   ef9345->char_ptr[0x00] = ef9345->charset;          //G0
169169   ef9345->char_ptr[0x01] = ef9345->charset + 0x0800; //G0 underlined
src/mess/formats/vg5k_cas.c
r8325r8326
155155          if ( data_pos > k7_size )
156156            return -1;
157157
158          sample_count += vg5k_cas_byte( buffer, sample_count, casdata[data_pos] );
158          sample_count += vg5k_cas_byte( buffer, sample_count, casdata[data_pos] );
159159
160160         /* generate the end-byte samples */
161161         sample_count += vg5k_cas_eob( buffer, sample_count);
src/mess/formats/timex_dck.c
r8325r8326
3838
3939DEVICE_IMAGE_LOAD( timex_cart )
4040{
41//   int file_size;
42//   UINT8 * file_data;
41//  int file_size;
42//  UINT8 * file_data;
4343//
44//   int chunks_in_file = 0;
44//  int chunks_in_file = 0;
4545//
46//   int i;
46//  int i;
4747//
48//   logerror ("Trying to load cart\n");
48//  logerror ("Trying to load cart\n");
4949//
50//   file_size = image_length(image);
50//  file_size = image_length(image);
5151//
52//   if (file_size < 0x09)
53//   {
54//      logerror ("Bad file size\n");
55//      return IMAGE_INIT_FAIL;
56//   }
52//  if (file_size < 0x09)
53//  {
54//      logerror ("Bad file size\n");
55//      return IMAGE_INIT_FAIL;
56//  }
5757//
58//   file_data = (UINT8 *)malloc(file_size);
59//   if (file_data == NULL)
60//   {
61//      logerror ("Memory allocating error\n");
62//      return IMAGE_INIT_FAIL;
63//   }
58//  file_data = (UINT8 *)malloc(file_size);
59//  if (file_data == NULL)
60//  {
61//      logerror ("Memory allocating error\n");
62//      return IMAGE_INIT_FAIL;
63//  }
6464//
65//   image_fread(image, file_data, file_size);
65//  image_fread(image, file_data, file_size);
6666//
67//   for (i=0; i<8; i++)
68//      if(file_data[i+1]&0x02)   chunks_in_file++;
67//  for (i=0; i<8; i++)
68//      if(file_data[i+1]&0x02) chunks_in_file++;
6969//
70//   if (chunks_in_file*0x2000+0x09 != file_size)
71//   {
72//      free (file_data);
73//      logerror ("File corrupted\n");
74//      return IMAGE_INIT_FAIL;
75//   }
70//  if (chunks_in_file*0x2000+0x09 != file_size)
71//  {
72//      free (file_data);
73//      logerror ("File corrupted\n");
74//      return IMAGE_INIT_FAIL;
75//  }
7676//
77//   switch (file_data[0x00])
78//   {
79//      case 0x00:   logerror ("DOCK cart\n");
80//            timex_cart_type = TIMEX_CART_DOCK;
81//            timex_cart_data = (UINT8*) malloc (0x10000);
82//            if (!timex_cart_data)
83//            {
84//               free (file_data);
85//               logerror ("Memory allocate error\n");
86//               return IMAGE_INIT_FAIL;
87//            }
88//            chunks_in_file = 0;
89//            for (i=0; i<8; i++)
90//            {
91//               timex_cart_chunks = timex_cart_chunks | ((file_data[i+1]&0x01)<<i);
92//               if (file_data[i+1]&0x02)
93//               {
94//                  memcpy (timex_cart_data+i*0x2000, file_data+0x09+chunks_in_file*0x2000, 0x2000);
95//                  chunks_in_file++;
96//               }
97//               else
98//               {
99//                  if (file_data[i+1]&0x01)
100//                     memset (timex_cart_data+i*0x2000, 0x00, 0x2000);
101//                  else
102//                     memset (timex_cart_data+i*0x2000, 0xff, 0x2000);
103//               }
104//            }
105//            free (file_data);
106//            break;
77//  switch (file_data[0x00])
78//  {
79//      case 0x00:  logerror ("DOCK cart\n");
80//              timex_cart_type = TIMEX_CART_DOCK;
81//              timex_cart_data = (UINT8*) malloc (0x10000);
82//              if (!timex_cart_data)
83//              {
84//                  free (file_data);
85//                  logerror ("Memory allocate error\n");
86//                  return IMAGE_INIT_FAIL;
87//              }
88//              chunks_in_file = 0;
89//              for (i=0; i<8; i++)
90//              {
91//                  timex_cart_chunks = timex_cart_chunks | ((file_data[i+1]&0x01)<<i);
92//                  if (file_data[i+1]&0x02)
93//                  {
94//                      memcpy (timex_cart_data+i*0x2000, file_data+0x09+chunks_in_file*0x2000, 0x2000);
95//                      chunks_in_file++;
96//                  }
97//                  else
98//                  {
99//                      if (file_data[i+1]&0x01)
100//                          memset (timex_cart_data+i*0x2000, 0x00, 0x2000);
101//                      else
102//                          memset (timex_cart_data+i*0x2000, 0xff, 0x2000);
103//                  }
104//              }
105//              free (file_data);
106//              break;
107107//
108//      default:   logerror ("Cart type not supported\n");
109//            free (file_data);
110//            timex_cart_type = TIMEX_CART_NONE;
111//            return IMAGE_INIT_FAIL;
112//   }
108//      default:    logerror ("Cart type not supported\n");
109//              free (file_data);
110//              timex_cart_type = TIMEX_CART_NONE;
111//              return IMAGE_INIT_FAIL;
112//  }
113113//
114//   logerror ("Cart loaded\n");
115//   logerror ("Chunks %02x\n", timex_cart_chunks);
114//  logerror ("Cart loaded\n");
115//  logerror ("Chunks %02x\n", timex_cart_chunks);
116116   return IMAGE_INIT_PASS;
117117}
118118
119119DEVICE_IMAGE_UNLOAD( timex_cart )
120120{
121//   if (timex_cart_data)
122//   {
123//      free (timex_cart_data);
124//      timex_cart_data = NULL;
125//   }
126//   timex_cart_type = TIMEX_CART_NONE;
127//   timex_cart_chunks = 0x00;
121//  if (timex_cart_data)
122//  {
123//      free (timex_cart_data);
124//      timex_cart_data = NULL;
125//  }
126//  timex_cart_type = TIMEX_CART_NONE;
127//  timex_cart_chunks = 0x00;
128128}
src/mess/messdriv.c
r8325r8326
14301430   DRIVER( newbraim )
14311431
14321432   /* Nokia Data */
1433//138u2   DRIVER( mm1m6 )
1434//138u2   DRIVER( mm1m7 )
1433//138u2 DRIVER( mm1m6 )
1434//138u2 DRIVER( mm1m7 )
14351435
14361436   /* Nuova Elettronica */
14371437   DRIVER( z80ne )    /* 1980 - Z80NE */
src/mess/drivers/jaguar.c
r8325r8326
186186/*
187187static mame_file *jaguar_nvram_fopen( running_machine *machine, UINT32 openflags)
188188{
189   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
190   astring *fname;
191   file_error filerr;
192   mame_file *file;
193   if (image->exists())
194   {
195      fname = astring_assemble_4( astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, image->basename_noext(), ".nv");
196      filerr = mame_fopen( SEARCHPATH_NVRAM, astring_c( fname), openflags, &file);
197      astring_free( fname);
198      return (filerr == FILERR_NONE) ? file : NULL;
199   }
200   else
201      return NULL;
189    device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
190    astring *fname;
191    file_error filerr;
192    mame_file *file;
193    if (image->exists())
194    {
195        fname = astring_assemble_4( astring_alloc(), machine->gamedrv->name, PATH_SEPARATOR, image->basename_noext(), ".nv");
196        filerr = mame_fopen( SEARCHPATH_NVRAM, astring_c( fname), openflags, &file);
197        astring_free( fname);
198        return (filerr == FILERR_NONE) ? file : NULL;
199    }
200    else
201        return NULL;
202202}
203203
204204static void jaguar_nvram_load(running_machine *machine)
205205{
206   mame_file *nvram_file = NULL;
207   running_device *device;
206    mame_file *nvram_file = NULL;
207    running_device *device;
208208
209   for (device = machine->devicelist.first(); device != NULL; device = device->next())
210   {
211      device_nvram_func nvram = (device_nvram_func)device->get_config_fct(DEVINFO_FCT_NVRAM);
212      if (nvram != NULL)
213      {
214         if (nvram_file == NULL)
215            nvram_file = jaguar_nvram_fopen(machine, OPEN_FLAG_READ);
216         (*nvram)(device, nvram_file, 0);
217      }
218   }
219   if (nvram_file != NULL)
220      mame_fclose(nvram_file);
209    for (device = machine->devicelist.first(); device != NULL; device = device->next())
210    {
211        device_nvram_func nvram = (device_nvram_func)device->get_config_fct(DEVINFO_FCT_NVRAM);
212        if (nvram != NULL)
213        {
214            if (nvram_file == NULL)
215                nvram_file = jaguar_nvram_fopen(machine, OPEN_FLAG_READ);
216            (*nvram)(device, nvram_file, 0);
217        }
218    }
219    if (nvram_file != NULL)
220        mame_fclose(nvram_file);
221221}
222222
223223
224224static void jaguar_nvram_save(running_machine *machine)
225225{
226   mame_file *nvram_file = NULL;
227   running_device *device;
226    mame_file *nvram_file = NULL;
227    running_device *device;
228228
229   for (device = machine->devicelist.first(); device != NULL; device = device->next())
230   {
231      device_nvram_func nvram = (device_nvram_func)device->get_config_fct(DEVINFO_FCT_NVRAM);
232      if (nvram != NULL)
233      {
234         if (nvram_file == NULL)
235            nvram_file = jaguar_nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
236         // check nvram_file to avoid crash when no image is mounted or cannot be created
237         if (nvram_file)
238            (*nvram)(device, nvram_file, 1);
239      }
240   }
229    for (device = machine->devicelist.first(); device != NULL; device = device->next())
230    {
231        device_nvram_func nvram = (device_nvram_func)device->get_config_fct(DEVINFO_FCT_NVRAM);
232        if (nvram != NULL)
233        {
234            if (nvram_file == NULL)
235                nvram_file = jaguar_nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
236            // check nvram_file to avoid crash when no image is mounted or cannot be created
237            if (nvram_file)
238                (*nvram)(device, nvram_file, 1);
239        }
240    }
241241
242   if (nvram_file != NULL)
243      mame_fclose(nvram_file);
242    if (nvram_file != NULL)
243        mame_fclose(nvram_file);
244244}
245245
246246static NVRAM_HANDLER( jaguar )
247247{
248   if (read_or_write)   {
249      jaguar_nvram_save(machine);
250   }
251   else
252   {
253      if (file)
254         jaguar_nvram_load(machine);
255   }
248    if (read_or_write)  {
249        jaguar_nvram_save(machine);
250    }
251    else
252    {
253        if (file)
254            jaguar_nvram_load(machine);
255    }
256256}
257257*/
258258static WRITE32_HANDLER( jaguar_eeprom_w )
r8325r8326
624624   MDRV_CPU_PROGRAM_MAP(gpu_map)
625625
626626   MDRV_MACHINE_RESET(jaguar)
627//   MDRV_NVRAM_HANDLER(jaguar)
627//  MDRV_NVRAM_HANDLER(jaguar)
628628
629629   MDRV_TIMER_ADD("serial_timer", jaguar_serial_callback)
630630
r8325r8326
816816
817817   /* Skip the logo */
818818   using_cart = 1;
819//   cart_base[0x102] = 1;
819//  cart_base[0x102] = 1;
820820
821821   /* Transfer control to the bios */
822822   cpu_set_reg(devtag_get_device(image.device().machine, "maincpu"), STATE_GENPC, rom_base[1]);
src/mess/drivers/cfx9850.c
r8325r8326
2525static ADDRESS_MAP_START( cfx9850, ADDRESS_SPACE_PROGRAM, 8 )
2626   AM_RANGE( 0x000000, 0x007fff ) AM_ROM
2727   AM_RANGE( 0x080000, 0x0807ff ) AM_RAM AM_BASE_MEMBER( cfx9850_state, video_ram )
28//   AM_RANGE( 0x100000, 0x10ffff ) /* some memory mapped i/o? */
29//   AM_RANGE( 0x110000, 0x11ffff ) /* some memory mapped i/o? */
28//  AM_RANGE( 0x100000, 0x10ffff ) /* some memory mapped i/o? */
29//  AM_RANGE( 0x110000, 0x11ffff ) /* some memory mapped i/o? */
3030   AM_RANGE( 0x200000, 0x27ffff ) AM_ROM AM_REGION( "bios", 0 )
3131   AM_RANGE( 0x400000, 0x40ffff ) AM_RAM
3232   AM_RANGE( 0x600000, 0x601fff ) AM_MIRROR(0xe000) AM_RAM AM_BASE_MEMBER( cfx9850_state, display_ram )
33//   AM_RANGE( 0xe10000, 0xe1ffff ) /* some memory mapped i/o? */
33//  AM_RANGE( 0xe10000, 0xe1ffff ) /* some memory mapped i/o? */
3434ADDRESS_MAP_END
3535
3636
r8325r8326
163163   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "F1 Trace" )
164164
165165   /* KO11 is not connected */
166//   PORT_START( "KO11" )
166//  PORT_START( "KO11" )
167167
168168   PORT_START( "KO12" )
169169   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME( "TEST" )
170170
171171   /* KO13 is not connected */
172//   PORT_START( "KO13" )
172//  PORT_START( "KO13" )
173173
174174   /* KO14 is not connected */
175//   PORT_START( "KO14" )
175//  PORT_START( "KO14" )
176176INPUT_PORTS_END
177177
178178
src/mess/drivers/x1.c
r8325r8326
857857
858858//static int x1_keyboard_irq_state(running_device* device)
859859//{
860//   if(key_irq_flag != 0)
861//      return Z80_DAISY_INT;
860//  if(key_irq_flag != 0)
861//      return Z80_DAISY_INT;
862862//
863//   return 0;
863//  return 0;
864864//}
865865//
866866//static int x1_keyboard_irq_ack(running_device* device)
867867//{
868//   key_irq_flag = 0;
869//   cputag_set_input_line(device->machine,"maincpu",INPUT_LINE_IRQ0,CLEAR_LINE);
870//   return key_irq_vector;
868//  key_irq_flag = 0;
869//  cputag_set_input_line(device->machine,"maincpu",INPUT_LINE_IRQ0,CLEAR_LINE);
870//  return key_irq_vector;
871871//}
872872//
873873//static DEVICE_GET_INFO( x1_keyboard_getinfo )
874874//{
875//   switch (state)
876//   {
877//      /* --- the following bits of info are returned as 64-bit signed integers --- */
878//      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
879//      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
875//  switch (state)
876//  {
877//      /* --- the following bits of info are returned as 64-bit signed integers --- */
878//      case DEVINFO_INT_TOKEN_BYTES:                   info->i = 4;                                            break;
879//      case DEVINFO_INT_INLINE_CONFIG_BYTES:           info->i = 0;                                            break;
880880//
881//      /* --- the following bits of info are returned as pointers to data or functions --- */
882//      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(x1_daisy);      break;
883//      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)x1_keyboard_irq_state;   break;
884//      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)x1_keyboard_irq_ack;      break;
881//      /* --- the following bits of info are returned as pointers to data or functions --- */
882//      case DEVINFO_FCT_START:                         info->start = DEVICE_START_NAME(x1_daisy);      break;
883//      case DEVINFO_FCT_IRQ_STATE:                     info->f = (genf *)x1_keyboard_irq_state;    break;
884//      case DEVINFO_FCT_IRQ_ACK:                       info->f = (genf *)x1_keyboard_irq_ack;      break;
885885//
886//      /* --- the following bits of info are returned as NULL-terminated strings --- */
887//      case DEVINFO_STR_NAME:                     strcpy(info->s, "X1 keyboard");      break;
888//      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "X1 daisy chain");            break;
889//      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
890//      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
891//      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
892//   }
886//      /* --- the following bits of info are returned as NULL-terminated strings --- */
887//      case DEVINFO_STR_NAME:                          strcpy(info->s, "X1 keyboard");     break;
888//      case DEVINFO_STR_FAMILY:                        strcpy(info->s, "X1 daisy chain");              break;
889//      case DEVINFO_STR_VERSION:                       strcpy(info->s, "1.0");                                 break;
890//      case DEVINFO_STR_SOURCE_FILE:                   strcpy(info->s, __FILE__);                              break;
891//      case DEVINFO_STR_CREDITS:                       strcpy(info->s, "Copyright the MESS Team");             break;
892//  }
893893//}
894894
895895/*************************************
r8325r8326
19781978
19791979static const z80_daisy_config x1_daisy[] =
19801980{
1981//   { "x1kb" },
1981//  { "x1kb" },
19821982   { "ctc" },
19831983   { NULL }
19841984};
19851985
19861986static const z80_daisy_config x1turbo_daisy[] =
19871987{
1988//   { "x1kb" },
1988//  { "x1kb" },
19891989   { "ctc" },
19901990   { "dma" },
19911991//  { "sio" },
r8325r8326
20942094   if((x1_rtc.sec & 0xf0) >= 0x60)             { x1_rtc.min++; x1_rtc.sec = 0; }
20952095   if((x1_rtc.min & 0x0f) >= 0x0a)             { x1_rtc.min+=0x10; x1_rtc.min&=0xf0; }
20962096   if((x1_rtc.min & 0xf0) >= 0x60)             { x1_rtc.hour++; x1_rtc.min = 0; }
2097   if((x1_rtc.hour & 0x0f) >= 0x0a)             { x1_rtc.hour+=0x10; x1_rtc.hour&=0xf0; }
2097   if((x1_rtc.hour & 0x0f) >= 0x0a)            { x1_rtc.hour+=0x10; x1_rtc.hour&=0xf0; }
20982098   if((x1_rtc.hour & 0xff) >= 0x24)            { x1_rtc.day++; x1_rtc.wday++; x1_rtc.hour = 0; }
20992099   if((x1_rtc.wday & 0x0f) >= 0x07)            { x1_rtc.wday = 0; }
21002100   if((x1_rtc.day & 0x0f) >= 0x0a)               { x1_rtc.day+=0x10; x1_rtc.day&=0xf0; }
21012101   /* FIXME: very crude leap year support (i.e. it treats the RTC to be with a 2000-2099 timeline), dunno how the real x1 supports this,
2102      maybe it just have a 1980-1999 timeline since year 0x00 shows as a XX on display */
2102       maybe it just have a 1980-1999 timeline since year 0x00 shows as a XX on display */
21032103   if(((x1_rtc.year % 4) == 0) && x1_rtc.month == 2)
21042104   {
21052105      if((x1_rtc.day & 0xff) >= dpm[x1_rtc.month-1]+1+1)
src/mess/drivers/tm990189.c
r8325r8326
421421static TMS9902_XMIT_CALLBACK( xmit_callback )
422422{
423423   UINT8 buf = data;
424   
424
425425   if (rs232_fp)
426426      rs232_fp->fwrite(&buf, 1);
427427}
src/mess/drivers/spectrum.c
r8325r8326
748748   MDRV_CARTSLOT_NOT_MANDATORY
749749   MDRV_CARTSLOT_LOAD(spectrum_cart)
750750   MDRV_CARTSLOT_INTERFACE("spectrum_cart")
751   MDRV_SOFTWARE_LIST_ADD("spectrum")   
751   MDRV_SOFTWARE_LIST_ADD("spectrum")
752752MACHINE_DRIVER_END
753753
754754MACHINE_DRIVER_START( spectrum )
src/mess/drivers/sg1000.c
r8325r8326
8686
8787/*
8888
89   Terebi Oekaki (TV Draw)
89    Terebi Oekaki (TV Draw)
9090
9191    Address Access  Bits
9292                    7       6   5   4   3   2   1   0
r8325r8326
143143}
144144
145145/*-------------------------------------------------
146    sg1000_joysel_r -
146    sg1000_joysel_r -
147147-------------------------------------------------*/
148148
149149static READ8_HANDLER( sg1000_joysel_r )
r8325r8326
10091009}
10101010
10111011/*-------------------------------------------------
1012    sf7000_fdc_index_callback -
1012    sf7000_fdc_index_callback -
10131013-------------------------------------------------*/
10141014
10151015static void sf7000_fdc_index_callback(running_device *controller, running_device *img, int state)
src/mess/drivers/mikromik.c
r8325r8326
794794   MDRV_CPU_PROGRAM_MAP(mm1m6_map)
795795
796796   /* video hardware */
797   MDRV_UPD7220_ADD(UPD7220_TAG, XTAL_18_720MHz/8, mm1_upd7220_intf, mm1_upd7220_map)   
797   MDRV_UPD7220_ADD(UPD7220_TAG, XTAL_18_720MHz/8, mm1_upd7220_intf, mm1_upd7220_map)
798798MACHINE_DRIVER_END
799799
800800/* ROMs */
src/mess/drivers/ql.c
r8325r8326
594594
595595static DEVICE_IMAGE_LOAD( ql_cart )
596596{
597//   UINT8 *ptr = memory_region(image.device().machine, M68008_TAG) + 0x00c000;
598//   int   filesize = image.length();
597//  UINT8 *ptr = memory_region(image.device().machine, M68008_TAG) + 0x00c000;
598//  int filesize = image.length();
599599//
600//   if (filesize <= 16 * 1024)
601//   {
602//      if (image.fread( ptr, filesize) == filesize)
603//      {
604//         memory_install_read_bank(cputag_get_address_space(image.device().machine, M68008_TAG, ADDRESS_SPACE_PROGRAM), 0x00c000, 0x00ffff, 0, 0, "bank1");
605//         memory_unmap_write(cputag_get_address_space(image.device().machine, M68008_TAG, ADDRESS_SPACE_PROGRAM), 0x00c000, 0x00ffff, 0, 0);
600//  if (filesize <= 16 * 1024)
601//  {
602//      if (image.fread( ptr, filesize) == filesize)
603//      {
604//          memory_install_read_bank(cputag_get_address_space(image.device().machine, M68008_TAG, ADDRESS_SPACE_PROGRAM), 0x00c000, 0x00ffff, 0, 0, "bank1");
605//          memory_unmap_write(cputag_get_address_space(image.device().machine, M68008_TAG, ADDRESS_SPACE_PROGRAM), 0x00c000, 0x00ffff, 0, 0);
606606//
607//         return IMAGE_INIT_PASS;
608//      }
609//   }
607//          return IMAGE_INIT_PASS;
608//      }
609//  }
610610//
611611   return IMAGE_INIT_FAIL;
612612}
src/mess/drivers/einstein.c
r8325r8326
187187
188188//static int einstein_keyboard_daisy_irq_state(running_device *device)
189189//{
190//   einstein_state *einstein = (einstein_state *)device->machine->driver_data;
190//  einstein_state *einstein = (einstein_state *)device->machine->driver_data;
191191//
192//   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_KEY_INT)
193//      return Z80_DAISY_INT;
192//  if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_KEY_INT)
193//      return Z80_DAISY_INT;
194194//
195//   return 0;
195//  return 0;
196196//}
197197//
198198//static int einstein_keyboard_daisy_irq_ack(running_device *device)
199199//{
200//   return 0xf7;
200//  return 0xf7;
201201//}
202202
203203//static DEVICE_GET_INFO( einstein_keyboard_daisy )
204204//{
205//   switch (state)
206//   {
207//      /* --- the following bits of info are returned as 64-bit signed integers --- */
208//      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
209//      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
205//  switch (state)
206//  {
207//      /* --- the following bits of info are returned as 64-bit signed integers --- */
208//      case DEVINFO_INT_TOKEN_BYTES:                   info->i = 4;                                            break;
209//      case DEVINFO_INT_INLINE_CONFIG_BYTES:           info->i = 0;                                            break;
210210//
211//      /* --- the following bits of info are returned as pointers to data or functions --- */
212//      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
213//      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_keyboard_daisy_irq_state;   break;
214//      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_keyboard_daisy_irq_ack;      break;
211//      /* --- the following bits of info are returned as pointers to data or functions --- */
212//      case DEVINFO_FCT_START:                         info->start = DEVICE_START_NAME(einstein_daisy);        break;
213//      case DEVINFO_FCT_IRQ_STATE:                     info->f = (genf *)einstein_keyboard_daisy_irq_state;    break;
214//      case DEVINFO_FCT_IRQ_ACK:                       info->f = (genf *)einstein_keyboard_daisy_irq_ack;      break;
215215//
216//      /* --- the following bits of info are returned as NULL-terminated strings --- */
217//      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein keyboard daisy chain");      break;
218//      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
219//      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
220//      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
221//      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
222//   }
216//      /* --- the following bits of info are returned as NULL-terminated strings --- */
217//      case DEVINFO_STR_NAME:                          strcpy(info->s, "Einstein keyboard daisy chain");       break;
218//      case DEVINFO_STR_FAMILY:                        strcpy(info->s, "Einstein daisy chain");                break;
219//      case DEVINFO_STR_VERSION:                       strcpy(info->s, "1.0");                                 break;
220//      case DEVINFO_STR_SOURCE_FILE:                   strcpy(info->s, __FILE__);                              break;
221//      case DEVINFO_STR_CREDITS:                       strcpy(info->s, "Copyright the MESS Team");             break;
222//  }
223223//}
224224
225225//static int einstein_adc_daisy_irq_state(running_device *device)
226226//{
227//   einstein_state *einstein = (einstein_state *)device->machine->driver_data;
227//  einstein_state *einstein = (einstein_state *)device->machine->driver_data;
228228//
229//   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_ADC_INT)
230//      return Z80_DAISY_INT;
229//  if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_ADC_INT)
230//      return Z80_DAISY_INT;
231231//
232//   return 0;
232//  return 0;
233233//}
234234//
235235//static int einstein_adc_daisy_irq_ack(running_device *device)
236236//{
237//   return 0xfb;
237//  return 0xfb;
238238//}
239239
240240//static DEVICE_GET_INFO( einstein_adc_daisy )
241241//{
242//   switch (state)
243//   {
244//      /* --- the following bits of info are returned as 64-bit signed integers --- */
245//      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
246//      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
242//  switch (state)
243//  {
244//      /* --- the following bits of info are returned as 64-bit signed integers --- */
245//      case DEVINFO_INT_TOKEN_BYTES:                   info->i = 4;                                            break;
246//      case DEVINFO_INT_INLINE_CONFIG_BYTES:           info->i = 0;                                            break;
247247//
248//      /* --- the following bits of info are returned as pointers to data or functions --- */
249//      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
250//      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_adc_daisy_irq_state;   break;
251//      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_adc_daisy_irq_ack;      break;
248//      /* --- the following bits of info are returned as pointers to data or functions --- */
249//      case DEVINFO_FCT_START:                         info->start = DEVICE_START_NAME(einstein_daisy);        break;
250//      case DEVINFO_FCT_IRQ_STATE:                     info->f = (genf *)einstein_adc_daisy_irq_state; break;
251//      case DEVINFO_FCT_IRQ_ACK:                       info->f = (genf *)einstein_adc_daisy_irq_ack;       break;
252252//
253//      /* --- the following bits of info are returned as NULL-terminated strings --- */
254//      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein ADC daisy chain");         break;
255//      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
256//      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
257//      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
258//      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
259//   }
253//      /* --- the following bits of info are returned as NULL-terminated strings --- */
254//      case DEVINFO_STR_NAME:                          strcpy(info->s, "Einstein ADC daisy chain");            break;
255//      case DEVINFO_STR_FAMILY:                        strcpy(info->s, "Einstein daisy chain");                break;
256//      case DEVINFO_STR_VERSION:                       strcpy(info->s, "1.0");                                 break;
257//      case DEVINFO_STR_SOURCE_FILE:                   strcpy(info->s, __FILE__);                              break;
258//      case DEVINFO_STR_CREDITS:                       strcpy(info->s, "Copyright the MESS Team");             break;
259//  }
260260//}
261261
262262//static int einstein_fire_daisy_irq_state(running_device *device)
263263//{
264//   einstein_state *einstein = (einstein_state *)device->machine->driver_data;
264//  einstein_state *einstein = (einstein_state *)device->machine->driver_data;
265265//
266//   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_FIRE_INT)
267//      return Z80_DAISY_INT;
266//  if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_FIRE_INT)
267//      return Z80_DAISY_INT;
268268//
269//   return 0;
269//  return 0;
270270//}
271271//
272272//static int einstein_fire_daisy_irq_ack(running_device *device)
273273//{
274//   return 0xfd;
274//  return 0xfd;
275275//}
276276
277277//static DEVICE_GET_INFO( einstein_fire_daisy )
278278//{
279//   switch (state)
280//   {
281//      /* --- the following bits of info are returned as 64-bit signed integers --- */
282//      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
283//      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
279//  switch (state)
280//  {
281//      /* --- the following bits of info are returned as 64-bit signed integers --- */
282//      case DEVINFO_INT_TOKEN_BYTES:                   info->i = 4;                                            break;
283//      case DEVINFO_INT_INLINE_CONFIG_BYTES:           info->i = 0;                                            break;
284284//
285//      /* --- the following bits of info are returned as pointers to data or functions --- */
286//      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
287//      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_fire_daisy_irq_state;      break;
288//      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_fire_daisy_irq_ack;         break;
285//      /* --- the following bits of info are returned as pointers to data or functions --- */
286//      case DEVINFO_FCT_START:                         info->start = DEVICE_START_NAME(einstein_daisy);        break;
287//      case DEVINFO_FCT_IRQ_STATE:                     info->f = (genf *)einstein_fire_daisy_irq_state;        break;
288//      case DEVINFO_FCT_IRQ_ACK:                       info->f = (genf *)einstein_fire_daisy_irq_ack;          break;
289289//
290//      /* --- the following bits of info are returned as NULL-terminated strings --- */
291//      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein fire button daisy chain");      break;
292//      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
293//      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
294//      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
295//      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
296//   }
290//      /* --- the following bits of info are returned as NULL-terminated strings --- */
291//      case DEVINFO_STR_NAME:                          strcpy(info->s, "Einstein fire button daisy chain");        break;
292//      case DEVINFO_STR_FAMILY:                        strcpy(info->s, "Einstein daisy chain");                break;
293//      case DEVINFO_STR_VERSION:                       strcpy(info->s, "1.0");                                 break;
294//      case DEVINFO_STR_SOURCE_FILE:                   strcpy(info->s, __FILE__);                              break;
295//      case DEVINFO_STR_CREDITS:                       strcpy(info->s, "Copyright the MESS Team");             break;
296//  }
297297//}
298298
299299/* int priority */
src/mess/drivers/osborne1.c
r8325r8326
162162static const z80_daisy_config osborne1_daisy_chain[] =
163163{
164164/*  { osborne1_z80_reset, osborne1_z80_irq_state, osborne1_z80_irq_ack, osborne1_z80_irq_reti, 0 }, */
165//   { "osborne1_daisy" },
165//  { "osborne1_daisy" },
166166   { NULL }
167167};
168168
r8325r8326
246246
247247   MDRV_MACHINE_RESET( osborne1 )
248248
249   //MDRV_DEVICE_ADD( "osborne1_daisy", OSBORNE1_DAISY, 0 )   
249   //MDRV_DEVICE_ADD( "osborne1_daisy", OSBORNE1_DAISY, 0 )
250250
251251   MDRV_SCREEN_ADD("screen", RASTER)
252252   MDRV_SCREEN_FORMAT( BITMAP_FORMAT_INDEXED16 )
src/mess/drivers/vtech1.c
r8325r8326
332332static void vtech1_put_track(running_machine *machine)
333333{
334334   vtech1_state *vtech1 = (vtech1_state *)machine->driver_data;
335   
336335
336
337337    /* drive selected and image file ok? */
338338   if (vtech1->drive >= 0 && floppy_get_device(machine,vtech1->drive) != NULL)
339339   {
src/mess/drivers/ng_aes.c
r8325r8326
866866
867867//static DEVICE_IMAGE_LOAD(aes_cart)
868868//{
869//   else
870//      return IMAGE_INIT_FAIL;
871   
872//   return IMAGE_INIT_PASS;
869//  else
870//      return IMAGE_INIT_FAIL;
871
872//  return IMAGE_INIT_PASS;
873873//}
874874
875875/*************************************
r8325r8326
12761276static MACHINE_DRIVER_START( aes )
12771277   MDRV_IMPORT_FROM(neogeo)
12781278   MDRV_AES_CARTRIDGE_ADD("aes_multicart")
1279//   MDRV_CARTSLOT_ADD("cart")
1280//   MDRV_CARTSLOT_MANDATORY
1281   
1282//   MDRV_CARTSLOT_LOAD(aes_cart)
1283   
1279//  MDRV_CARTSLOT_ADD("cart")
1280//  MDRV_CARTSLOT_MANDATORY
1281
1282//  MDRV_CARTSLOT_LOAD(aes_cart)
1283
12841284   MDRV_SOFTWARE_LIST_ADD("aes")
12851285MACHINE_DRIVER_END
12861286
src/mess/drivers/cdi.c
r8325r8326
29932993   visarea1.max_x = width-1;
29942994   visarea1.min_x = visarea.min_x;
29952995   visarea1.min_y = visarea.min_y;
2996   visarea1.max_y = visarea.max_y;   
2996   visarea1.max_y = visarea.max_y;
29972997
29982998   machine->primary_screen->configure(width, 262, visarea1, period);
29992999}
src/mess/drivers/x07.c
r8325r8326
22
33    Casio X-07
44
5   Driver by Sandro Ronco based on X-07 emu by J.Brigaud
5    Driver by Sandro Ronco based on X-07 emu by J.Brigaud
66
7   TODO:
8   -External video (need X-720 dump)
9   -Serial port
7    TODO:
8    -External video (need X-720 dump)
9    -Serial port
1010
11   Memory Map
11    Memory Map
1212
13   0x0000 - 0x1fff   Internal RAM
14   0x2000 - 0x3fff   External RAM Card
15   0x4000 - 0x5fff   Extension ROM/RAM
16   0x6000 - 0x7fff   ROM Card
17   0x8000 - 0x97ff   Video RAM
18   0x9800 - 0x9fff   ?
19   0xa000 - 0xafff   TV ROM (no dump)
20   0xb000 - 0xffff   ROM
13    0x0000 - 0x1fff   Internal RAM
14    0x2000 - 0x3fff   External RAM Card
15    0x4000 - 0x5fff   Extension ROM/RAM
16    0x6000 - 0x7fff   ROM Card
17    0x8000 - 0x97ff   Video RAM
18    0x9800 - 0x9fff   ?
19    0xa000 - 0xafff   TV ROM (no dump)
20    0xb000 - 0xffff   ROM
2121
22   CPU was actually a NSC800 (Z80 compatible)
23   More info: http://www.silicium.org/oldskool/calc/x07/
22    CPU was actually a NSC800 (Z80 compatible)
23    More info: http://www.silicium.org/oldskool/calc/x07/
2424
2525****************************************************************************/
2626
r8325r8326
149149      break;
150150
151151   case 0x05:   //T6834 Ram Read
152         address = state->in_data[state->in_pos++];
152      address = state->in_data[state->in_pos++];
153153      address |= state->in_data[state->in_pos++] << 8;
154154      if(address == 0xc00e)
155155         p1 = 0x0a;
r8325r8326
165165      break;
166166
167167   case 0x06:   //T6834 Ram Write
168         p1 = state->in_data[state->in_pos++];
169         address = state->in_data[state->in_pos++];
168      p1 = state->in_data[state->in_pos++];
169      address = state->in_data[state->in_pos++];
170170      address |= state->in_data[state->in_pos++] << 8;
171171
172172      if(0x200 <= address && address < 0x300)
r8325r8326
374374      break;
375375
376376   case 0x24:   //Locate
377         p1 = state->in_data[state->in_pos++];
377      p1 = state->in_data[state->in_pos++];
378378      p2 = state->in_data[state->in_pos++];
379379      p3 = state->in_data[state->in_pos++];
380380      state->loc_on = (state->loc_x != p1 || state->loc_y != p2);
r8325r8326
426426      draw_udk(machine);
427427      break;
428428
429   case 0x31:    //udk Off
429   case 0x31:   //udk Off
430430      state->udk = 0;
431431      p1 = state->in_data[state->in_pos++];
432432      for(UINT8 l = 3 * 8; l < (3 + 1) * 8; l++)
r8325r8326
592592}
593593
594594/****************************************************
595   this function emulate the color printer X-710
596   only the text functions are emulated
595    this function emulate the color printer X-710
596    only the text functions are emulated
597597****************************************************/
598598static void send_to_printer(running_machine *machine)
599599{
r8325r8326
12491249   memset(state->kb_data, 0, sizeof(state->kb_data));
12501250   memset(state->printer_buffer, 0, sizeof(state->printer_buffer));
12511251
1252   state->enable_k7 =    0;
1253   state->udk =       0;
1254   state->z80_irq =    0;
1255   state->in_size =    0;
1252   state->enable_k7 =   0;
1253   state->udk =      0;
1254   state->z80_irq =   0;
1255   state->in_size =   0;
12561256   state->in_pos =    0;
1257   state->out_size =    0;
1258   state->out_pos =    0;
1257   state->out_size =   0;
1258   state->out_pos =   0;
12591259   state->lcd_on =    0x01;
12601260   state->scroll_min = 0;
12611261   state->scroll_max = 0x03;
12621262   state->cur_on =    0;
1263   state->cur_x =       0;
1264   state->cur_y =       0;
1263   state->cur_x =      0;
1264   state->cur_y =      0;
12651265   state->loc_on =    0;
1266   state->loc_x =       0;
1267   state->loc_y =       0;
1268   state->font_code =    0;
1269   state->kb_on =       0;
1270   state->ctrl =       0;
1271   state->shift =       0;
1272   state->kana =       0;
1273   state->graph =       0;
1274   state->stick =       0x30;
1275   state->strig =       0xff;
1266   state->loc_x =      0;
1267   state->loc_y =      0;
1268   state->font_code =   0;
1269   state->kb_on =      0;
1270   state->ctrl =      0;
1271   state->shift =      0;
1272   state->kana =      0;
1273   state->graph =      0;
1274   state->stick =      0x30;
1275   state->strig =      0xff;
12761276   state->strig1 =    0xff;
12771277   state->kb_brk =    0;
1278   state->kb_wait =    0;
1279   state->kb_size =    0;
1278   state->kb_wait =   0;
1279   state->kb_size =   0;
12801280   state->send_bit =   0;
12811281   state->char_code =   0;
12821282   state->printer_size = 0;
src/mess/drivers/pv1000.c
r8325r8326
241241
242242/*
243243 plgDavid's audio implementation/analysis notes:
244
244
245245 Sound appears to be 3 50/50 pulse voices made by cutting the main clock by 1024,
246246 then by the value of the 6bit period registers.
247247 This creates a surprisingly accurate pitch range.
248
248
249249 Note: the register periods are inverted.
250250 */
251251
src/mess/drivers/mac.c
r8325r8326
8585{
8686   mac_state *mac = (mac_state *)space->machine->driver_data;
8787
88//   logerror("ASC: Read @ %x (PC %x)\n", offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu")));
88//  logerror("ASC: Read @ %x (PC %x)\n", offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu")));
8989
9090   switch (offset)
9191   {
r8325r8326
105105   INT32 i;
106106   mac_state *mac = (mac_state *)space->machine->driver_data;
107107
108//   logerror("ASC: %02x to %x (PC %x)\n", data, offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu")));
108//  logerror("ASC: %02x to %x (PC %x)\n", data, offset, cpu_get_pc(devtag_get_device(space->machine, "maincpu")));
109109
110110   mac->mac_asc_regs[offset] = data;
111111
r8325r8326
261261   int data, viaoffs;
262262   running_device *via_1 = devtag_get_device(space->machine, "via6522_1");
263263
264//   printf("v8_r: %x, mask %x (PC %x)\n", offset*2, mem_mask, cpu_get_pc(space->cpu));
264//  printf("v8_r: %x, mask %x (PC %x)\n", offset*2, mem_mask, cpu_get_pc(space->cpu));
265265
266266   viaoffs = (offset >> 8) & 0x0f;
267267
r8325r8326
283283   running_device *via_1 = devtag_get_device(space->machine, "via6522_1");
284284   int viaoffs;
285285
286//   printf("v8_w: %x to offset %x, mask %x (PC %x)\n", data, offset*2, mem_mask, cpu_get_pc(space->cpu));
286//  printf("v8_w: %x to offset %x, mask %x (PC %x)\n", data, offset*2, mem_mask, cpu_get_pc(space->cpu));
287287
288288   viaoffs = (offset >> 8) & 0x0f;
289289
r8325r8326
353353   int data, viaoffs;
354354   running_device *via_1 = devtag_get_device(space->machine, "via6522_1");
355355
356//   printf("sonora_r: %x, mask %x (PC %x)\n", offset*2, mem_mask, cpu_get_pc(space->cpu));
356//  printf("sonora_r: %x, mask %x (PC %x)\n", offset*2, mem_mask, cpu_get_pc(space->cpu));
357357
358358   viaoffs = (offset >> 8) & 0x0f;
359359
r8325r8326
375375   running_device *via_1 = devtag_get_device(space->machine, "via6522_1");
376376   int viaoffs;
377377
378//   printf("sonora_w: %x to offset %x, mask %x (PC %x)\n", data, offset*2, mem_mask, cpu_get_pc(space->cpu));
378//  printf("sonora_w: %x to offset %x, mask %x (PC %x)\n", data, offset*2, mem_mask, cpu_get_pc(space->cpu));
379379
380380   viaoffs = (offset >> 8) & 0x0f;
381381
r8325r8326
436436
437437static READ32_HANDLER(mac_lc3_id)
438438{
439//   printf("Sonora ID register read, PC=%x\n", cpu_get_pc(space->cpu));
439//  printf("Sonora ID register read, PC=%x\n", cpu_get_pc(space->cpu));
440440
441441   return 0xa55a0001;   // 25 MHz LC III
442442}
src/mess/drivers/pce220.c
r8325r8326
2525{
2626   int x, y, xi,yi;
2727   int count = 0;
28//   static int test_x,test_y;
28//  static int test_x,test_y;
2929   static UINT8 *vram = memory_region(screen->machine, "lcd_vram");
3030
3131   for (y = 0; y < 4; y++)
r8325r8326
128128static READ8_HANDLER( port15_r )
129129{
130130   /*
131   x--- ---- XIN input enabled
132   ---- ---0
133   */
131    x--- ---- XIN input enabled
132    ---- ---0
133    */
134134   return 0;
135135}
136136
137137static READ8_HANDLER( port18_r )
138138{
139139   /*
140   x--- ---- XOUT/TXD
141   ---- --x- DOUT
142   ---- ---x BUSY/CTS
143   */
140    x--- ---- XOUT/TXD
141    ---- --x- DOUT
142    ---- ---x BUSY/CTS
143    */
144144   return 0;
145145}
146146
147147static READ8_HANDLER( port1f_r )
148148{
149149   /*
150   x--- ---- ON - resp. break key status (?)
151   ---- -x-- XIN/RXD
152   ---- --x- ACK/RTS
153   ---- ---x DIN
154   */
150    x--- ---- ON - resp. break key status (?)
151    ---- -x-- XIN/RXD
152    ---- --x- ACK/RTS
153    ---- ---x DIN
154    */
155155
156156   return 0;
157157}
src/mess/drivers/lynx.c
r8325r8326
176176   memory_write_byte(space, 0x1fc, start & 0xff);
177177   memory_write_byte(space, 0x1fd, start >> 8);
178178
179   lynx_crc_keyword((device_image_interface&)*devtag_get_device(image.device().machine, "quickload"));   
179   lynx_crc_keyword((device_image_interface&)*devtag_get_device(image.device().machine, "quickload"));
180180
181181   cpu_set_reg(cpu, STATE_GENPC, start);
182182
src/mess/drivers/apexc.c
r8325r8326
262262{
263263   UINT8 reply;
264264   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
265   
265
266266   if (image->exists() && (image->fread(& reply, 1) == 1))
267267      return reply & 0x1f;
268268   else
r8325r8326
273273{
274274   UINT8 data5 = (data & 0x1f);
275275   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
276   
276
277277   if (image->exists())
278278      image->fwrite(& data5, 1);
279279
src/mess/drivers/pc2000.c
r8325r8326
100100   ADDRESS_MAP_UNMAP_HIGH
101101   AM_RANGE(0x0000, 0x3fff) AM_ROM AM_REGION("bios", 0x00000)
102102   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
103   AM_RANGE(0x8000, 0xbfff) AM_READNOP //   0x8000 - 0xbfff tests a cartridge, header is 0x55 0xaa 0x59 0x45, if it succeeds a jump at 0x8004 occurs
103   AM_RANGE(0x8000, 0xbfff) AM_READNOP //  0x8000 - 0xbfff tests a cartridge, header is 0x55 0xaa 0x59 0x45, if it succeeds a jump at 0x8004 occurs
104104   AM_RANGE(0xd000, 0xdfff) AM_RAM AM_BASE(&wram)
105105   AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION("bios", 0x10000) //tied with rom bank at I/O 3
106106ADDRESS_MAP_END
src/mess/drivers/atom.c
r8325r8326
5656
5757    http://www.xs4all.nl/~fjkraan/comp/atom/index.html
5858
59   ---
59    ---
6060
61   The Econet card for the ATOM is decoded on the ATOM PCB at memory address B400 (hex). The Econet Eurocard has decoding circuits on it which select memory address 1940 (hex).
62   There are then five significant addresses above these bases which contain the following registers: -
61    The Econet card for the ATOM is decoded on the ATOM PCB at memory address B400 (hex). The Econet Eurocard has decoding circuits on it which select memory address 1940 (hex).
62    There are then five significant addresses above these bases which contain the following registers: -
6363
64            ATOM card   Eurocard
65   6854   register 1   B400      1940
66   6854   register 2   B401      1941
67   6854   register 3   B402      1942
68   6854   Tx/Rx Data reg.   B403      1943
69   Station   identification   B404      1944
64                ATOM card   Eurocard
65    6854    register 1  B400        1940
66    6854    register 2  B401        1941
67    6854    register 3  B402        1942
68    6854    Tx/Rx Data reg. B403        1943
69    Station identification  B404        1944
7070
71   Station identification
71    Station identification
7272
73   The identity number of each station is set up in hardware by links to IC 8. IC 8 is an octal buffer which when enabled feeds the cards station ID to the computer bus.
74   Each link codes a bit in an eight bit binary number allowing any station ID in the range 0 to 255 to be set up. if a link is left open then the bit is a one, when a
75   link is made the bit is a zero. Hence all links open corresponds to station ID 255, and all links made to station ID 0. Each station must have a unique identity and
76   some indentities are associated with specific functions on the network. Station ID zero is reserved for broadcast signals and should not be used. Station ID 255 is
77   reserved at present for the file server, and 235 for the printer server. Wire links must be soldered to each network station card during installation, a sugested
78   scheme for number allocation is to number normal user stations from one upwards and to number special stations and servers from 255 downwards.
73    The identity number of each station is set up in hardware by links to IC 8. IC 8 is an octal buffer which when enabled feeds the cards station ID to the computer bus.
74    Each link codes a bit in an eight bit binary number allowing any station ID in the range 0 to 255 to be set up. if a link is left open then the bit is a one, when a
75    link is made the bit is a zero. Hence all links open corresponds to station ID 255, and all links made to station ID 0. Each station must have a unique identity and
76    some indentities are associated with specific functions on the network. Station ID zero is reserved for broadcast signals and should not be used. Station ID 255 is
77    reserved at present for the file server, and 235 for the printer server. Wire links must be soldered to each network station card during installation, a sugested
78    scheme for number allocation is to number normal user stations from one upwards and to number special stations and servers from 255 downwards.
7979
8080
8181***************************************************************************/
r8325r8326
8484
8585    TODO:
8686
87   - connect to softwarelist
88   - e000 EPROM switching
87    - connect to softwarelist
88    - e000 EPROM switching
8989    - ERROR repeats ad infinitum
9090    - display should be monochrome
9191    - ram expansion
r8325r8326
9494    - color card
9595    - CP/M card
9696    - speech synthesis card (SPO256 connected to VIA)
97   - econet
98   - teletext card
99   - Busicomputers Prophet 2
100      * The Shift and Return keys are orange and the Return key is large,
101      * There is a MODE switch to the top right of the keyboard,
102      * There is a VIDEO port in addition to the TV output,
103      * An Acorn AtomCalc ROM PCB is installed (is this standard on the Prophet2 or an upgrade?),
104      * An Acorn 32K dynamic RAM card is installed,
105      * A 5v DC input is added in addition to the standard power in (but this may be a later upgrade),
106      * The Utility ROM is labelled P2/FP is installed
97    - econet
98    - teletext card
99    - Busicomputers Prophet 2
100        * The Shift and Return keys are orange and the Return key is large,
101        * There is a MODE switch to the top right of the keyboard,
102        * There is a VIDEO port in addition to the TV output,
103        * An Acorn AtomCalc ROM PCB is installed (is this standard on the Prophet2 or an upgrade?),
104        * An Acorn 32K dynamic RAM card is installed,
105        * A 5v DC input is added in addition to the standard power in (but this may be a later upgrade),
106        * The Utility ROM is labelled P2/FP is installed
107107
108108*/
109109
r8325r8326
163163{
164164   /*
165165
166      bit      description
166        bit     description
167167
168      0      block A bit 0
169      1      block A bit 1
170      2      block A bit 2
171      3      block A bit 3
172      4     
173      5     
174      6     
175      7      block E
168        0       block A bit 0
169        1       block A bit 1
170        2       block A bit 2
171        3       block A bit 3
172        4
173        5
174        6
175        7       block E
176176
177   */
177    */
178178
179179   atom_state *state = (atom_state *)space->machine->driver_data;
180180
r8325r8326
203203   AM_RANGE(0x9800, 0x9fff) AM_RAM
204204   AM_RANGE(0xa000, 0xafff) AM_ROM AM_REGION("a000", 0)
205205   AM_RANGE(0xb000, 0xb003) AM_MIRROR(0x3fc) AM_DEVREADWRITE(INS8255_TAG, i8255a_r, i8255a_w)
206//   AM_RANGE(0xb400, 0xb403) AM_DEVREADWRITE(MC6854_TAG, mc6854_r, mc6854_w)
207//   AM_RANGE(0xb404, 0xb404) AM_READ_PORT("ECONET")
206//  AM_RANGE(0xb400, 0xb403) AM_DEVREADWRITE(MC6854_TAG, mc6854_r, mc6854_w)
207//  AM_RANGE(0xb404, 0xb404) AM_READ_PORT("ECONET")
208208   AM_RANGE(0xb800, 0xb80f) AM_MIRROR(0x3f0) AM_DEVREADWRITE(R6522_TAG, via_r, via_w)
209209   AM_RANGE(0xc000, 0xffff) AM_ROM AM_REGION(SY6502_TAG, 0)
210210ADDRESS_MAP_END
r8325r8326
766766   UINT8 *temp_copy;
767767   int mirror, i;
768768   const struct atom_cart_range *atom_cart = &atom_cart_table[0], *this_cart;
769   
769
770770   /* First, determine where this cart has to be loaded */
771771   while (atom_cart->tag)
772772   {
773773      if (strcmp(atom_cart->tag, image.device().tag()) == 0)
774774         break;
775     
775
776776      atom_cart++;
777777   }
778   
778
779779   this_cart = atom_cart;
780     
780
781781   if (image.software_entry() == NULL)
782782   {
783783      size = image.length();
784784      temp_copy = auto_alloc_array(image.device().machine, UINT8, size);
785     
785
786786      if (size > 0x1000)
787787      {
788788         image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
789789         auto_free(image.device().machine, temp_copy);
790790         return IMAGE_INIT_FAIL;
791791      }
792     
792
793793      if (image.fread(temp_copy, size) != size)
794794      {
795795         image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
r8325r8326
803803      temp_copy = auto_alloc_array(image.device().machine, UINT8, size);
804804      memcpy(temp_copy, image.get_software_region("rom"), size);
805805   }
806   
806
807807   mirror = 0x1000 / size;
808   
808
809809   /* With the following, we mirror the cart in the whole memory region */
810810   for (i = 0; i < mirror; i++)
811811      memcpy(memory_region(image.device().machine, this_cart->region) + this_cart->offset + i * size, temp_copy, size);
812   
812
813813   auto_free(image.device().machine, temp_copy);
814   
814
815815   return IMAGE_INIT_PASS;
816816}
817817
r8325r8326
950950/*    YEAR  NAME      PARENT    COMPAT  MACHINE   INPUT     INIT      COMPANY   FULLNAME */
951951COMP( 1979, atom,     0,        0,      atom,     atom,     0,        "Acorn",  "Atom" , 0)
952952COMP( 1979, atomeb,   atom,     0,      atomeb,   atom,     0,        "Acorn",  "Atom with Eprom Box" , 0)
953//COMP( 1983, prophet2, atom,     0,      atom,     atom,     0,        "Busicomputers",  "Prophet 2" , 0)
953//COMP( 1983, prophet2, atom,     0,        atom,     atom,     0,        "Busicomputers",  "Prophet 2" , 0)
src/mess/drivers/supracan.c
r8325r8326
4949In priority order from most to least important, they are:
5050
5151411 value  How acked                     Notes
520x40       read reg 0x16 of sound chip    likely timer. snd regs 0x16/0x17 are time constant, write 0 to reg 0x9f to start
520x40       read reg 0x16 of sound chip  likely timer. snd regs 0x16/0x17 are time constant, write 0 to reg 0x9f to start
53530x04       read at 0x405                 latch 1?  0xcd is magic value
54540x08       read at 0x404                 latch 2?  0xcd is magic value
55550x10       read at 0x409                 unknown, dispatched but not used in startup 6502 code
56560x20       read at 0x40a                 possible periodic like vblank?
570x80       read reg 0x14 of sound chip   depends on reg 0x14 of sound chip & 0x40: if not set writes 0x8f to reg 0x14,
570x80       read reg 0x14 of sound chip   depends on reg 0x14 of sound chip & 0x40: if not set writes 0x8f to reg 0x14,
5858                                         otherwise writes 0x4f to reg 0x14 and performs additional processing
5959
6060***************************************************************************/
src/mess/drivers/apple2.c
r8325r8326
922922   ROM_LOAD ( "341-0027-a.p5", 0x4500, 0x0100, CRC(ce7144f6) SHA1(d4181c9f046aafc3fb326b381baac809d9e38d16)) /* Disk II ROM - DOS 3.3 version */
923923
924924   ROM_REGION(0x1000, "cffa", 0)
925        ROM_LOAD( "cffa20eec02.bin", 0x000000, 0x001000, CRC(fb3726f8) SHA1(080ff88f19de22328e162954ee2b51ee65f9d5cd) )
925        ROM_LOAD( "cffa20eec02.bin", 0x000000, 0x001000, CRC(fb3726f8) SHA1(080ff88f19de22328e162954ee2b51ee65f9d5cd) )
926926ROM_END
927927
928928ROM_START(apple2ep)
r8325r8326
10281028COMP( 1980, apple2jp, apple2,   0,        apple2p,      apple2p,  0,        "Apple Computer",    "Apple ][j+", GAME_SUPPORTS_SAVE )
10291029COMP( 1982, ace100,   apple2,   0,        apple2,      apple2e,  0,        "Franklin Computer", "Franklin Ace 100", GAME_SUPPORTS_SAVE )
10301030COMP( 1983, apple2e,  0,        apple2,     apple2e,      apple2e,  0,        "Apple Computer",    "Apple //e", GAME_SUPPORTS_SAVE )
1031//COMP( 1983, apple2ez, apple2e,  0,     apple2e_z80,      apple2e,  0,        "Apple Computer",    "Apple //e (with Z80 SoftCard)", GAME_SUPPORTS_SAVE )
1031//COMP( 1983, apple2ez, apple2e,  0,      apple2e_z80,     apple2e,  0,        "Apple Computer",    "Apple //e (with Z80 SoftCard)", GAME_SUPPORTS_SAVE )
10321032COMP( 1983, mprof3,   apple2e,  0,        mprof3,      apple2e,  0,        "Multitech",         "Microprofessor III", GAME_SUPPORTS_SAVE )
10331033COMP( 1985, apple2ee, apple2e,  0,        apple2ee,      apple2e,  0,        "Apple Computer",    "Apple //e (enhanced)", GAME_SUPPORTS_SAVE )
10341034COMP( 1987, apple2ep, apple2e,  0,        apple2ep,      apple2ep, 0,        "Apple Computer",    "Apple //e (Platinum)", GAME_SUPPORTS_SAVE )
src/mess/drivers/e01.c
r8325r8326
44
55    20/05/2010 Skeleton driver.
66
7   http://acorn.chriswhy.co.uk/Network/Econet.html
8   http://acorn.chriswhy.co.uk/Network/Pics/Acorn_FileStoreE01.html
9   http://acorn.chriswhy.co.uk/8bit_Upgrades/Acorn_FileStoreE01S.html
10   http://www.heyrick.co.uk/econet/fs/emulator.html
7    http://acorn.chriswhy.co.uk/Network/Econet.html
8    http://acorn.chriswhy.co.uk/Network/Pics/Acorn_FileStoreE01.html
9    http://acorn.chriswhy.co.uk/8bit_Upgrades/Acorn_FileStoreE01S.html
10    http://www.heyrick.co.uk/econet/fs/emulator.html
1111
1212****************************************************************************/
1313
1414/*
1515
16   The FileStore E01 is an Econet station in its own right which acts as a fileserver when connected to a network. It is a single unit
17   which does not require a monitor or keyboard. Communication with the FileStore is done via another Econet station when the FileStore
18   is in one of two "maintenance modes"
16    The FileStore E01 is an Econet station in its own right which acts as a fileserver when connected to a network. It is a single unit
17    which does not require a monitor or keyboard. Communication with the FileStore is done via another Econet station when the FileStore
18    is in one of two "maintenance modes"
1919
20   The E01 can be seen as a slimmed-down BBC computer tailored for its function as a fileserver. It has a 6502 processor at its heart
21   along with a 6522 VIA just like the BBC. It requires a Master series Econet module to be plugged in and connects to the network via
22   an Econet port in the same way as any other station.
20    The E01 can be seen as a slimmed-down BBC computer tailored for its function as a fileserver. It has a 6502 processor at its heart
21    along with a 6522 VIA just like the BBC. It requires a Master series Econet module to be plugged in and connects to the network via
22    an Econet port in the same way as any other station.
2323
24   The FileStore E01S was Acorns second generation Filestore replacing the FileStore E01. The FileStore is a dedicated Econet fileserver,
25   it does not support a keyboard and monitor, instead you use an Econet attached station to logon and perform administrative tasks.
24    The FileStore E01S was Acorns second generation Filestore replacing the FileStore E01. The FileStore is a dedicated Econet fileserver,
25    it does not support a keyboard and monitor, instead you use an Econet attached station to logon and perform administrative tasks.
2626
27         Hitachi HD146818P Real Time Clock
28         Rockwell R65C102P3 CPU
29         2 x TMM27256D-20 white labelled EPROMs, TMSE01 MOS on left and E01 FS on the right
30   IC20   WD2793-APL-02 floppy disc controller
31         2 x NEC D41464C-12 64k x 4bit NMOS RAM ICs giving 64K memory
32   IC21   Rockwell RC6522AP VIA behind to the right
27            Hitachi HD146818P Real Time Clock
28            Rockwell R65C102P3 CPU
29            2 x TMM27256D-20 white labelled EPROMs, TMSE01 MOS on left and E01 FS on the right
30    IC20    WD2793-APL-02 floppy disc controller
31            2 x NEC D41464C-12 64k x 4bit NMOS RAM ICs giving 64K memory
32    IC21    Rockwell RC6522AP VIA behind to the right
3333
3434*/
3535
3636/*
3737
38   TODO:
38    TODO:
3939
40   - RTC interrupts (rewrite mc146818)
41   - ADLC interrupts
42   - ECONET device
43   - printer
44   - artwork
45   - hard disk
40    - RTC interrupts (rewrite mc146818)
41    - ADLC interrupts
42    - ECONET device
43    - printer
44    - artwork
45    - hard disk
4646
4747*/
4848
r8325r8326
123123static WRITE8_DEVICE_HANDLER( floppy_w )
124124{
125125   /*
126     
127      bit      description
128126
129      0      floppy 1 select
130      1      floppy 2 select
131      2      floppy side select
132      3      NVRAM select
133      4      floppy density
134      5      floppy master reset
135      6      floppy test
136      7      mode LED
127        bit     description
137128
138   */
129        0       floppy 1 select
130        1       floppy 2 select
131        2       floppy side select
132        3       NVRAM select
133        4       floppy density
134        5       floppy master reset
135        6       floppy test
136        7       mode LED
139137
138    */
139
140140   /* floppy 1 select */
141141   if (!BIT(data, 0))
142142   {
r8325r8326
236236   AM_RANGE(0xfc24, 0xfc24) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_disable_r, network_irq_disable_w)
237237   AM_RANGE(0xfc28, 0xfc28) AM_MIRROR(0x00c3) AM_READWRITE(network_irq_enable_r, network_irq_enable_w)
238238   AM_RANGE(0xfc2c, 0xfc2c) AM_MIRROR(0x00c3) AM_READ_PORT("FLAP")
239//   AM_RANGE(0xfc30, 0xfc30) AM_MIRROR(0x00c0) HD data
240//   AM_RANGE(0xfc31, 0xfc31) AM_MIRROR(0x00c0) HD status
241//   AM_RANGE(0xfc32, 0xfc32) AM_MIRROR(0x00c0) HD select
239//  AM_RANGE(0xfc30, 0xfc30) AM_MIRROR(0x00c0) HD data
240//  AM_RANGE(0xfc31, 0xfc31) AM_MIRROR(0x00c0) HD status
241//  AM_RANGE(0xfc32, 0xfc32) AM_MIRROR(0x00c0) HD select
242242   AM_RANGE(0xfc33, 0xfc33) AM_MIRROR(0x00c0) AM_WRITE(hdc_irq_enable_w)
243243   AM_RANGE(0xfd00, 0xffff) AM_READ_BANK("bank3") AM_WRITE_BANK("bank4")
244244ADDRESS_MAP_END
r8325r8326
272272/*
273273static WRITE_LINE_DEVICE_HANDLER( rtc_irq_w )
274274{
275   e01_state *driver_state = (e01_state *)device->machine->driver_data;
275    e01_state *driver_state = (e01_state *)device->machine->driver_data;
276276
277   driver_state->rtc_irq = state;
277    driver_state->rtc_irq = state;
278278
279   update_interrupts(device->machine);
279    update_interrupts(device->machine);
280280}
281281*/
282282static TIMER_DEVICE_CALLBACK( rtc_irq_hack )
r8325r8326
294294/*
295295static WRITE_LINE_DEVICE_HANDLER( adlc_irq_w )
296296{
297   e01_state *driver_state = (e01_state *)device->machine->driver_data;
297    e01_state *driver_state = (e01_state *)device->machine->driver_data;
298298
299   driver_state->adlc_irq = state;
299    driver_state->adlc_irq = state;
300300
301   update_interrupts(device->machine);
301    update_interrupts(device->machine);
302302}
303303*/
304static const mc6854_interface adlc_intf =
304static const mc6854_interface adlc_intf =
305305{
306306   NULL,
307307   NULL,
r8325r8326
459459   MDRV_MC6854_ADD(MC6854_TAG, adlc_intf)
460460   MDRV_WD2793_ADD(WD2793_TAG, fdc_intf)
461461   MDRV_FLOPPY_2_DRIVES_ADD(e01_floppy_config)
462//   MDRV_CENTRONICS_ADD(CENTRONICS_TAG, e01_centronics_config)
462//  MDRV_CENTRONICS_ADD(CENTRONICS_TAG, e01_centronics_config)
463463
464464   /* internal ram */
465465   MDRV_RAM_ADD("messram")
src/mess/drivers/ti89.c
r8325r8326
44
55    NVRAM works only if the calculator is turned off (2nd + ON) before closing of MESS
66
7   TODO:
8    -Link
9    -HW 3 I/O port
10    -RTC
11    -LCD contrast
7    TODO:
8     -Link
9     -HW 3 I/O port
10     -RTC
11     -LCD contrast
1212****************************************************************************/
1313
1414#include "emu.h"
src/mess/drivers/gba.c
r8325r8326
22082208      data >>= 16;
22092209   }
22102210
2211//   printf("eeprom_w: %x @ %x (state %d) (PC=%x)\n", data, offset, state->eeprom_state, cpu_get_pc(space->cpu));
2211//  printf("eeprom_w: %x @ %x (state %d) (PC=%x)\n", data, offset, state->eeprom_state, cpu_get_pc(space->cpu));
22122212
22132213   switch (state->eeprom_state)
22142214   {

Previous 15994 Revisions Next


© 1998-2018 The MESS Team