Previous 15994 Revisions Next

r10463 Wednesday 16th February, 2011 at 09:10:38 UTC by Fabio Priuli
softlist: proof of concept implementation of "compatibility" info for TV standard, additional CPUs, etc.
[hash]megadriv.xml
[src/emu]softlist.c softlist.h
[src/mame/machine]md_cart.c

hash/megadriv.xml
r10462r10463
2593325933      <description>Virtua Racing (Euro)</description>
2593425934      <year>1994</year>
2593525935      <publisher>Sega</publisher>
25936      <info name="compatibility" value="PAL" />
25937      <info name="addon" value="SVP" />
2593625938      <part name="cart" interface="megadriv_cart">
2593725939         <dataarea name="rom" size="2097152">
2593825940            <rom name="mpr-16420.bin" size="2097152" crc="9624d4ef" sha1="2c3812f8a010571e51269a33a989598787d27c2d" offset="000000" loadflag="load16_word_swap" />
r10462r10463
2594625948      <description>Virtua Racing (Jpn)</description>
2594725949      <year>1994</year>
2594825950      <publisher>Sega</publisher>
25951      <info name="compatibility" value="EUR-JPN" />
25952      <info name="addon" value="SVP" />
2594925953      <part name="cart" interface="megadriv_cart">
2595025954         <dataarea name="rom" size="2097152">
2595125955            <rom name="mpr-16389.bin" size="2097152" crc="53a293b5" sha1="0ad38a3ab1cc99edac72184f8ae420e13df5cac6" offset="000000" loadflag="load16_word_swap" />
r10462r10463
2595825962      <description>Virtua Racing (USA)</description>
2595925963      <year>1994</year>
2596025964      <publisher>Sega</publisher>
25965      <info name="compatibility" value="NTSC-U" />
25966      <info name="addon" value="SVP" />
2596125967      <part name="cart" interface="megadriv_cart">
2596225968         <dataarea name="rom" size="2097152">
2596325969            <rom name="virtua racing (usa).bin" size="2097152" crc="7e1a324a" sha1="ff969ae53120cc4e7cb1a8a7e47458f2eb8a2165" offset="000000" loadflag="load16_word_swap" />
src/mame/machine/md_cart.c
r10462r10463
18321832}
18331833
18341834
1835static void megadrive_check_compat_list(device_image_interface &image)
1836{
1837   const char *compatibility = image.get_feature("compatibility");
1838   const char *chips = image.get_feature("addon");
1839   int md_region = megadrive_region_export + (megadrive_region_pal << 1);
1840
1841   if (chips)
1842   {
1843      if(!strcmp(chips, "SVP") && (image.device().machine->device<cpu_device>("svp") == NULL))
1844      {
1845         mame_printf_warning("This software requires emulation of the SVP CPU to work.\n");
1846         mame_printf_warning("It might not work in the system you are using.\n");
1847      }
1848   }
1849
1850   if (compatibility)
1851   {
1852      if(!strcmp(compatibility, "PAL") && (md_region != 3))
1853      {
1854         mame_printf_warning("This software requires a PAL console to work.\n");
1855         mame_printf_warning("It might not work in the system you are using.\n");
1856      }
1857      if(!strcmp(compatibility, "NTSC-J") && (md_region != 0))
1858      {
1859         mame_printf_warning("This software requires a JPN console to work.\n");
1860         mame_printf_warning("It might not work in the system you are using.\n");
1861      }
1862      if(!strcmp(compatibility, "NTSC-U") && (md_region != 1))
1863      {
1864         mame_printf_warning("This software requires a USA console to work.\n");
1865         mame_printf_warning("It might not work in the system you are using.\n");
1866      }     
1867      if(!strcmp(compatibility, "EUR-JPN") && (md_region != 0 && md_region != 3))
1868      {
1869         mame_printf_warning("This software requires a PAL or a JPN console to work.\n");
1870         mame_printf_warning("It might not work in the system you are using.\n");
1871      }     
1872   }   
1873}
1874
18351875/*************************************
18361876 *  Loading a cart image from softlist
18371877 *************************************/
r10462r10463
18511891   else
18521892      state->md_cart.type = md_get_pcb_id(pcb_name);
18531893
1894   megadrive_check_compat_list(image);
1895   
18541896   memcpy(&ROM[VIRGIN_COPY_GEN], &ROM[0x000000], MAX_MD_CART_SIZE);  /* store a copy of data */
18551897
18561898   return IMAGE_INIT_PASS;
src/emu/softlist.c
r10462r10463
282282}
283283
284284/*-------------------------------------------------
285 add_info (same as add_feature, but its target
286 is softinfo->other_info)
287 -------------------------------------------------*/
288
289static void add_info(software_list *swlist, char *feature_name, char *feature_value)
290{
291   software_info *info = swlist->softinfo;
292   feature_list *new_entry;
293
294   /* First allocate the new entry */
295   new_entry = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
296   
297   if ( new_entry )
298   {
299      new_entry->next = NULL;
300      new_entry->name = feature_name;
301      new_entry->value = feature_value ? feature_value : feature_name;
302
303      /* Add new feature to end of feature list */
304      if ( info->other_info )
305      {
306         feature_list *list = info->other_info;
307         while ( list->next != NULL )
308         {
309            list = list->next;
310         }
311         list->next = new_entry;
312      }
313      else
314      {
315         info->other_info = new_entry;
316      }
317   }
318   else
319   {
320      /* Unable to allocate memory */
321   }
322}
323
324/*-------------------------------------------------
285325    add_software_part
286326-------------------------------------------------*/
287327
r10462r10463
405445               elem->partdata = (software_part *)pool_malloc_lib(swlist->pool, swlist->part_entries * sizeof(software_part) );
406446               if ( !elem->partdata )
407447                  return;
408
448               elem->other_info = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
449               if ( !elem->other_info )
450                  return;
451               else
452               {
453                  elem->other_info->next = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
454                  elem->other_info->next = NULL;
455                  elem->other_info->name = NULL;
456                  elem->other_info->value = NULL;
457               }
458               
409459               /* Handle the supported flag */
410460               elem->supported = SOFTWARE_SUPPORTED_YES;
411461               if ( supported && ! strcmp( supported, "partial" ) )
r10462r10463
448498            text_dest = (char **) &swlist->softinfo->year;
449499         else if (!strcmp(tagname, "publisher"))
450500            text_dest = (char **) &swlist->softinfo->publisher;
501         else if ( !strcmp(tagname, "info") )
502         {
503            const char *str_feature_name = NULL;
504            const char *str_feature_value = NULL;
505           
506            for ( ; attributes[0]; attributes += 2 )
507            {
508               if ( !strcmp( attributes[0], "name" ) )
509                  str_feature_name = attributes[1];
510               
511               if ( !strcmp( attributes[0], "value" ) )
512                  str_feature_value = attributes[1];
513            }
514           
515            /* Prepare for adding feature to feature list */
516            if ( str_feature_name && swlist->softinfo )
517            {
518               char *name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_name ) + 1 ) * sizeof(char) );
519               char *value = NULL;
520               
521               if ( !name )
522                  return;
523               
524               strcpy( name, str_feature_name );
525               
526               if ( str_feature_value )
527               {
528                  value = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_value ) + 1 ) * sizeof(char) );
529                 
530                  if ( !value )
531                     return;
532                 
533                  strcpy( value, str_feature_value );
534               }
535               
536               add_info( swlist, name, value );
537            }
538         }
451539         else if ( !strcmp(tagname, "part" ) )
452540         {
453541            const char *str_name = NULL;
r10462r10463
770858         break;
771859
772860      case POS_PART:
861         /* Add other_info inherited from the software_info level, if any */
862         if ( swlist->softinfo && swlist->softinfo->other_info )
863         {
864            feature_list *list = swlist->softinfo->other_info;
865           
866            while( list->next )
867            {
868               add_feature( swlist, list->next->name, list->next->value );
869               list = list->next;
870            }
871         }
773872         break;
774873
775874      case POS_DATA:
src/emu/softlist.h
r10462r10463
4646   const char *parentname;
4747   const char *year;         /* Copyright year on title screen, actual release dates can be tracked in external resources */
4848   const char *publisher;
49   feature_list *other_info;
4950   UINT32 supported;
5051   software_part *partdata;
5152   struct software_info *next;   /* Used internally */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team