Previous 15994 Revisions Next

r12256 Sunday 17th July, 2011 at 11:25:20 UTC by Miodrag Milanović
Update support for slot devices based softlists (no whatsnew)
[hash]coco_cart.xml
[src/emu]diimage.c softlist.c softlist.h
[src/mess/machine]cococart.c

hash/coco_cart.xml
r12255r12256
127127      <publisher>Tandy</publisher>
128128      <info name="serial" value="26-3149" />
129129      <part name="cart" interface="coco_cart">
130         <feature name="slot" value="pak" />
130131         <dataarea name="rom" size="16384">
131132            <rom name="atom (1983)(26-3149)(tandy).rom" size="16384" crc="04d9cfe4" sha1="654b989c4ca40d5acc78dca701cd3004293bf334" offset="0" />
132133         </dataarea>
src/emu/diimage.c
r12255r12256
811811   /* Check if there's a software list defined for this device and use that if we're not creating an image */
812812   if (!filename_has_period)
813813   {
814      softload = load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name );
814      softload = load_software_part( device().machine().options(), this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name );
815815      // if we had launched from softlist with a specified part, e.g. "shortname:part"
816816      // we would have recorded the wrong name, so record it again based on software_info
817817      if (m_software_info_ptr && m_software_info_ptr->shortname)
src/emu/softlist.c
r12255r12256
120120    from the global pool. So they should be global_free'ed
121121    when they are not used anymore.
122122-------------------------------------------------*/
123static void software_name_split(running_machine& machine, const char *swlist_swname, char **swlist_name, char **swname, char **swpart )
123
124#define global_strdup(s)            strcpy(global_alloc_array(char, strlen(s) + 1), s)
125
126static void software_name_split(const char *swlist_swname, char **swlist_name, char **swname, char **swpart )
124127{
125128   const char *split_1st_loc = strchr( swlist_swname, ':' );
126129   const char *split_2nd_loc = ( split_1st_loc ) ? strchr( split_1st_loc + 1, ':' ) : NULL;
r12255r12256
134137      if ( split_2nd_loc )
135138      {
136139         int size = split_1st_loc - swlist_swname;
137         *swlist_name = auto_alloc_array_clear(machine,char,size+1);
140         *swlist_name = global_alloc_array_clear(char,size+1);
138141         memcpy( *swlist_name, swlist_swname, size );
139142
140143         size = split_2nd_loc - ( split_1st_loc + 1 );
141         *swname = auto_alloc_array_clear(machine,char,size+1);
144         *swname = global_alloc_array_clear(char,size+1);
142145         memcpy( *swname, split_1st_loc + 1, size );
143146
144147         size = strlen( swlist_swname ) - ( split_2nd_loc + 1 - swlist_swname );
145         *swpart = auto_alloc_array_clear(machine,char,size+1);
148         *swpart = global_alloc_array_clear(char,size+1);
146149         memcpy( *swpart, split_2nd_loc + 1, size );
147150      }
148151      else
149152      {
150153         int size = split_1st_loc - swlist_swname;
151         *swname = auto_alloc_array_clear(machine,char,size+1);
154         *swname = global_alloc_array_clear(char,size+1);
152155         memcpy( *swname, swlist_swname, size );
153156
154157         size = strlen( swlist_swname ) - ( split_1st_loc + 1 - swlist_swname );
155         *swpart = auto_alloc_array_clear(machine,char,size+1);
158         *swpart = global_alloc_array_clear(char,size+1);
156159         memcpy( *swpart, split_1st_loc + 1, size );
157160      }
158161   }
159162   else
160163   {
161      *swname = auto_strdup(machine,swlist_swname);
164      *swname = global_strdup(swlist_swname);
162165   }
163166}
164167
r12255r12256
13721375      }
13731376   }
13741377}
1375/*-------------------------------------------------
1376    load_software_part
13771378
1378    Load a software part for a device. The part to
1379    load is determined by the "path", software lists
1380    configured for a driver, and the interface
1381    supported by the device.
1382
1383    returns true if the software could be loaded,
1384    false otherwise. If the software could be loaded
1385    sw_info and sw_part are also set.
1386-------------------------------------------------*/
1387
1388bool load_software_part(device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name)
1379static void find_software_item(emu_options &options, const device_image_interface *image, const char *path, software_list **software_list_ptr, software_info **software_info_ptr,software_part **software_part_ptr, const char **sw_list_name)
13891380{
13901381   char *swlist_name, *swname, *swpart, *swname_bckp;
1391   bool result = false;
1392   software_list *software_list_ptr = NULL;
1393   software_info *software_info_ptr = NULL;
1394   software_part *software_part_ptr = NULL;
1382   *software_list_ptr = NULL;
1383   *software_info_ptr = NULL;
1384   *software_part_ptr = NULL;
13951385
1396   *sw_info = NULL;
1397   *sw_part = NULL;
1398
13991386   /* Split full software name into software list name and short software name */
1400   software_name_split( image->device().machine(), path, &swlist_name, &swname, &swpart );
1387   software_name_split(path, &swlist_name, &swname, &swpart );
14011388   swname_bckp = swname;
14021389
14031390   const char *interface = image->image_interface();
14041391
1392   machine_config config(*options.system(), options);
1393   
14051394   if ( swlist_name )
14061395   {
14071396      /* Try to open the software list xml file explicitly named by the user */
1408      software_list_ptr = software_list_open( image->device().machine().options(), swlist_name, FALSE, NULL );
1397      *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
14091398
1410      if ( software_list_ptr )
1399      if ( *software_list_ptr )
14111400      {
1412         software_info_ptr = software_list_find( software_list_ptr, swname, NULL );
1401         *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
14131402
1414         if ( software_info_ptr )
1403         if ( *software_info_ptr )
14151404         {
1416            software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
1405            *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
14171406         }
14181407      }
14191408   }
14201409   else
14211410   {
14221411      /* Loop through all the software lists named in the driver */
1423      for (device_t *swlists = image->device().machine().devicelist().first(SOFTWARE_LIST); swlists != NULL; swlists = swlists->typenext())
1412      for (device_t *swlists = config.devicelist().first(SOFTWARE_LIST); swlists != NULL; swlists = swlists->typenext())
14241413      {
14251414         if ( swlists )
14261415         {
r12255r12256
14281417            software_list_config *swlist = (software_list_config *)downcast<const legacy_device_base *>(swlists)->inline_config();
14291418            UINT32 i = DEVINFO_STR_SWLIST_0;
14301419
1431            while ( ! software_part_ptr && i <= DEVINFO_STR_SWLIST_MAX )
1420            while ( ! *software_part_ptr && i <= DEVINFO_STR_SWLIST_MAX )
14321421            {
14331422               swlist_name = swlist->list_name[i-DEVINFO_STR_SWLIST_0];
14341423
14351424               if ( swlist_name && *swlist_name && (swlist->list_type == SOFTWARE_LIST_ORIGINAL_SYSTEM))
14361425               {
1437                  if ( software_list_ptr )
1426                  if ( *software_list_ptr )
14381427                  {
1439                     software_list_close( software_list_ptr );
1428                     software_list_close( *software_list_ptr );
14401429                  }
14411430
1442                  software_list_ptr = software_list_open( image->device().machine().options(), swlist_name, FALSE, NULL );
1431                  *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
14431432
14441433                  if ( software_list_ptr )
14451434                  {
1446                     software_info_ptr = software_list_find( software_list_ptr, swname, NULL );
1435                     *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
14471436
1448                     if ( software_info_ptr )
1437                     if ( *software_info_ptr )
14491438                     {
1450                        software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
1439                        *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
14511440                     }
14521441                  }
14531442               }
r12255r12256
14571446      }
14581447
14591448      /* If not found try to load the software list using the driver name */
1460      if ( ! software_part_ptr )
1449      if ( ! *software_part_ptr )
14611450      {
1462         swlist_name = (char *)image->device().machine().system().name;
1451         swlist_name = (char *)options.system()->name;
14631452
1464         if ( software_list_ptr )
1453         if ( *software_list_ptr )
14651454         {
1466            software_list_close( software_list_ptr );
1455            software_list_close( *software_list_ptr );
14671456         }
14681457
1469         software_list_ptr = software_list_open( image->device().machine().options(), swlist_name, FALSE, NULL );
1458         *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
14701459
1471         if ( software_list_ptr )
1460         if ( *software_list_ptr )
14721461         {
1473            software_info_ptr = software_list_find( software_list_ptr, swname, NULL );
1462            *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
14741463
1475            if ( software_info_ptr )
1464            if ( *software_info_ptr )
14761465            {
1477               software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
1466               *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
14781467            }
14791468         }
14801469      }
14811470
14821471      /* If not found try to load the software list using the software name as software */
14831472      /* list name and software part name as software name. */
1484      if ( ! software_part_ptr )
1473      if ( ! *software_part_ptr )
14851474      {
14861475         swlist_name = swname;
14871476         swname = swpart;
14881477         swpart = NULL;
14891478
1490         if ( software_list_ptr )
1479         if ( *software_list_ptr )
14911480         {
1492            software_list_close( software_list_ptr );
1481            software_list_close( *software_list_ptr );
14931482         }
14941483
1495         software_list_ptr = software_list_open( image->device().machine().options(), swlist_name, FALSE, NULL );
1484         *software_list_ptr = software_list_open( options, swlist_name, FALSE, NULL );
14961485
14971486         if ( software_list_ptr )
14981487         {
1499            software_info_ptr = software_list_find( software_list_ptr, swname, NULL );
1488            *software_info_ptr = software_list_find( *software_list_ptr, swname, NULL );
15001489
1501            if ( software_info_ptr )
1490            if ( *software_info_ptr )
15021491            {
1503               software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
1492               *software_part_ptr = software_find_part( *software_info_ptr, swpart, interface );
15041493            }
15051494
1506            if ( ! software_part_ptr )
1495            if ( ! *software_part_ptr )
15071496            {
1508               software_list_close( software_list_ptr );
1509               software_list_ptr = NULL;
1497               software_list_close( *software_list_ptr );
1498               *software_list_ptr = NULL;
15101499            }
15111500         }
15121501      }
15131502   }
1503   *sw_list_name = global_strdup(swlist_name);
1504   
1505   global_free( swlist_name );
1506   global_free( swname );
1507   global_free( swpart );
1508}
15141509
1510/*-------------------------------------------------
1511    load_software_part
1512
1513    Load a software part for a device. The part to
1514    load is determined by the "path", software lists
1515    configured for a driver, and the interface
1516    supported by the device.
1517
1518    returns true if the software could be loaded,
1519    false otherwise. If the software could be loaded
1520    sw_info and sw_part are also set.
1521-------------------------------------------------*/
1522
1523bool load_software_part(emu_options &options, device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name)
1524{
1525   software_list *software_list_ptr = NULL;
1526   software_info *software_info_ptr = NULL;
1527   software_part *software_part_ptr = NULL;
1528   const char *swlist_name = NULL;
1529   
1530   bool result = false;
1531   *sw_info = NULL;
1532   *sw_part = NULL;
1533
1534   find_software_item(options, image, path, &software_list_ptr, &software_info_ptr, &software_part_ptr, &swlist_name);
1535   
15151536   // if no match has been found, we suggest similar shortnames
15161537   if (software_info_ptr == NULL)
1517   {
1518      software_display_matches(image->device().machine().devicelist(),image->device().machine().options(), image->image_interface(), swname_bckp);
1538   {     
1539      machine_config config(*options.system(), options);
1540      software_display_matches(config.devicelist(), options, image->image_interface(), path);
15191541   }
15201542
15211543   if ( software_part_ptr )
r12255r12256
15271549      catch (emu_fatalerror &fatal)
15281550      {
15291551         software_list_close( software_list_ptr );
1552         global_free(swlist_name);
15301553         throw fatal;
15311554      }
15321555
r12255r12256
15811604      software_info_ptr = NULL;
15821605      software_list_ptr = NULL;
15831606   }
1584   auto_free( image->device().machine(), swlist_name );
1585   auto_free( image->device().machine(), swname );
1586   auto_free( image->device().machine(), swpart );
1587
1607   global_free(swlist_name);
15881608   return result;
15891609}
15901610
r12255r12256
16101630
16111631}
16121632
1633/*-------------------------------------------------
1634    software_get_default_slot
1635 -------------------------------------------------*/
16131636
1637 const char *software_get_default_slot(emu_options &options, const device_image_interface *image, const char *default_card, const char* default_card_slot)
1638{
1639   const char* retVal = default_card;
1640   const char* path = options.value(image->instance_name());
1641   software_list *software_list_ptr = NULL;
1642   software_info *software_info_ptr = NULL;
1643   software_part *software_part_ptr = NULL;
1644   const char *swlist_name = NULL;
1645   
1646   if (strlen(path)>0) {
1647      retVal = default_card_slot;
1648      find_software_item(options, image, path, &software_list_ptr, &software_info_ptr, &software_part_ptr, &swlist_name);
1649      if (software_part_ptr!=NULL) {
1650         const char *slot = software_part_get_feature(software_part_ptr, "slot");
1651         if (slot!=NULL) {
1652            retVal = core_strdup(slot);
1653         }
1654      }
1655      software_list_close(software_list_ptr);
1656      global_free(swlist_name);
1657   }
1658   return retVal;   
1659}
1660
16141661/***************************************************************************
16151662    DEVICE INTERFACE
16161663***************************************************************************/
src/emu/softlist.h
r12255r12256
112112UINT32 software_get_support(emu_options &options, char *swlist, const char *swname);
113113const char *software_part_get_feature(software_part *part, const char *feature_name);
114114
115bool load_software_part(device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name);
115bool load_software_part(emu_options &options, device_image_interface *image, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name);
116116
117117void software_display_matches(const device_list &devlist, emu_options &options,const char *interface,const char *swname_bckp);
118118
119const char *software_get_default_slot(emu_options &options, const device_image_interface *image, const char *default_card, const char* default_card_slot);
120
119121/*********************************************************************
120122
121123    Driver software list configuration
src/mess/machine/cococart.c
r12255r12256
338338
339339const char * cococart_slot_device::get_default_card(emu_options &options) const
340340{
341   if (strlen(options.value(m_instance_name))>0) {
342      return "pak";
343   }
344   return m_default_card;   
341   return software_get_default_slot(options, this, m_default_card, "pak");
345342}
346343
347344//**************************************************************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team