Previous 15994 Revisions Next

r7696 Sunday 4th April, 2010 at 14:21:16 UTC by Wilbert Pol
Changed the software list support to use xml software lists. Removed the C per device type software list. Software lists are now defined on a driver basis.
Added the possibility of defining the hardware interface type for devices which allow mounting of software.
[src/mess]image.c image.h mess.mak messsoft.c softlist.c softlist.h software
[src/mess/devices]cartslot.c cartslot.h
[src/mess/drivers]bbcbc.c gamepock.c

src/mess/messsoft.c
r7695r7696
1/******************************************************************************
2
3  messsoft.c
4
5  The list of all available software lists. Software lists have to be included
6  here to be recognized by the executable.
7
8  To save some typing, we use a hack here. This file is recursively #included
9  twice, with different definitions of the SOFTWARE_LIST() macro. The first
10  one declares external references to the software lists; the second one builds
11  an array storing all the software lists.
12
13******************************************************************************/
14
15#include "emu.h"
16#include "softlist.h"
17
18
19#ifndef SOFTWARE_LIST_RECURSIVE
20
21#define SOFTWARE_LIST_RECURSIVE
22
23/* step 1: declare all external references */
24#define ADD_SOFTWARE_LIST(NAME) extern const software_list software_list_##NAME;
25#include "messsoft.c"
26
27/* step 2: define the software_list[] array */
28#undef ADD_SOFTWARE_LIST
29#define ADD_SOFTWARE_LIST(NAME) &software_list_##NAME,
30const software_list * const software_lists[] =
31{
32#include "messsoft.c"
33  0             /* end of array */
34};
35
36#else /* SOFTWARE_LIST_RECURSIVE */
37
38/****************SOFTWARE LISTS**********************************************/
39
40   ADD_SOFTWARE_LIST( _32x_cart )      /* Sega 32X cartridges */
41   ADD_SOFTWARE_LIST( advision_cart )  /* Entex Adventure Vision */
42   ADD_SOFTWARE_LIST( bbcbc_cart )     /* BBC Bridge Companion cartridges */
43   ADD_SOFTWARE_LIST( crvision_cart )  /* V-Tech Creativison cartridges */
44   ADD_SOFTWARE_LIST( gamecom_cart )   /* Tiger Game.com cartridges */
45   ADD_SOFTWARE_LIST( gamegear_cart )  /* Sega Game Gear cartridges */
46   ADD_SOFTWARE_LIST( gamepock_cart )  /* Epoch Game Pocket Computer cartridges */
47   ADD_SOFTWARE_LIST( gmaster_cart )   /* Hartung Game Master cartridges */
48   ADD_SOFTWARE_LIST( jaguar_cart )    /* Atari Jaguar cartridges */
49   ADD_SOFTWARE_LIST( lynx_cart )      /* Atari Lynx cartridges */
50   ADD_SOFTWARE_LIST( megadriv_cart )  /* Sega MegaDrive / Genesis cartridges */
51   ADD_SOFTWARE_LIST( megasvp_cart )   /* Sega MegaDrive / Genesis w/SVP cartridges */
52   ADD_SOFTWARE_LIST( ngp_cart )       /* SNK Neo Geo Pocket cartridges */
53   ADD_SOFTWARE_LIST( ngpc_cart )      /* SNK Neo Geo Pocket Color cartridges */
54   ADD_SOFTWARE_LIST( pasogo_cart )    /* Koei Pasogo cartridges */
55   ADD_SOFTWARE_LIST( pico_cart )      /* Sega Pico cartridges */
56   ADD_SOFTWARE_LIST( pokemini_cart )  /* Nintendo Pok??mon Mini cartridges */
57   ADD_SOFTWARE_LIST( sg1000_cart )    /* Sega SG-1000 & SG-1000 MarkII cartridges */
58   ADD_SOFTWARE_LIST( sms_cart )       /* Sega Master System cartridges */
59   ADD_SOFTWARE_LIST( spectrum_cart )  /* Sinclair ZX Spectrum cartridges */
60   ADD_SOFTWARE_LIST( supracan_cart )  /* Super A'Can cartridges */
61   ADD_SOFTWARE_LIST( svision_cart )   /* Watara Supervision cartridges */
62   ADD_SOFTWARE_LIST( vboy_cart )      /* Nintendo Virtual Boy cartridges */
63   ADD_SOFTWARE_LIST( wswan_cart )     /* Bandai WonderSwan */
64   ADD_SOFTWARE_LIST( wscolor_cart )   /* Bandai WonderSwan Color */
65
66#endif /* SOFTWARE_LIST_RECURSIVE */
src/mess/devices/cartslot.c
r7695r7696
476476            strcpy(info->s, "bin");
477477         }
478478         break;
479      case DEVINFO_STR_SOFTWARE_LIST:
480         if ( device && device->inline_config && get_config_dev(device)->software_list_name )
479      case DEVINFO_STR_INTERFACE:
480         if ( device && device->inline_config && get_config_dev(device)->interface )
481481         {
482            strcpy(info->s, get_config_dev(device)->software_list_name );
482            strcpy(info->s, get_config_dev(device)->interface );
483483         }
484484         break;
485485   }
src/mess/devices/cartslot.h
r7695r7696
5353struct _cartslot_config
5454{
5555   const char *               extensions;
56   const char *               software_list_name;
56   const char *               interface;
5757   int                        must_be_loaded;
5858   device_start_func            device_start;
5959   device_image_load_func         device_load;
r7695r7696
114114   MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(cartslot_config, pcb_types, _index, cartslot_pcb_type, name, _pcb_type_name) \
115115   MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(cartslot_config, pcb_types, _index, cartslot_pcb_type, devtype, _pcb_devtype)
116116
117#define MDRV_CARTSLOT_SOFTWARE_LIST(_listname)                     \
118   MDRV_DEVICE_CONFIG_DATAPTR(cartslot_config, software_list_name, #_listname )
117#define MDRV_CARTSLOT_INTERFACE(_interface)                     \
118   MDRV_DEVICE_CONFIG_DATAPTR(cartslot_config, interface, _interface )
119119
120120
121121/***************************************************************************
src/mess/softlist.c
r7695r7696
88***************************************************************************/
99
1010#include "emu.h"
11#include "pool.h"
12#include "expat.h"
13#include "emuopts.h"
1114#include "softlist.h"
1215
1316
17enum softlist_parse_position
18{
19   POS_ROOT,
20   POS_MAIN,
21   POS_SOFT,
22   POS_PART,
23   POS_DATA
24};
25
26
27typedef struct _parse_state
28{
29   XML_Parser   parser;
30   int         done;
31
32   void (*error_proc)(const char *message);
33   void *param;
34
35   enum softlist_parse_position pos;
36   char **text_dest;
37} parse_state;
38
39
40struct software_info_list
41{
42   software_info            info;
43   struct software_info_list   *next;
44};
45
46
47struct _software_list
48{
49   mame_file   *file;
50   object_pool   *pool;
51   parse_state   state;
52   struct software_info_list   *software_info_list;
53   struct software_info_list   *current_software_info;
54   software_info   *softinfo;
55   const char *look_for;
56   int part_entries;
57   int current_part_entry;
58   int rom_entries;
59   int current_rom_entry;
60   void (*error_proc)(const char *message);
61};
62
63
64/***************************************************************************
65    EXPAT INTERFACES
66***************************************************************************/
67
1468/*-------------------------------------------------
15    software_list_get_by_name - return a pointer to
16    a software list given its name.
69    expat_malloc/expat_realloc/expat_free -
70    wrappers for memory allocation functions so
71    that they pass through out memory tracking
72    systems
1773-------------------------------------------------*/
18const software_list* software_list_get_by_name(const char *name)
74
75static void *expat_malloc(size_t size)
1976{
20   int listnum;
77   return global_alloc_array_clear(UINT8,size);
78}
2179
22   /* scan for a match in the list of software lists */
23   for ( listnum = 0; software_lists[listnum] != NULL; listnum++ )
80static void *expat_realloc(void *ptr, size_t size)
81{
82   if (ptr) global_free(ptr);
83   return global_alloc_array_clear(UINT8,size);
84}
85
86static void expat_free(void *ptr)
87{
88   global_free(ptr);
89}
90
91
92/*-------------------------------------------------
93    parse_error
94-------------------------------------------------*/
95
96INLINE void ATTR_PRINTF(2,3) parse_error(parse_state *state, const char *fmt, ...)
97{
98   char buf[256];
99   va_list va;
100
101   if (state->error_proc)
24102   {
25      if ( mame_stricmp( software_lists[listnum]->name, name ) == 0 )
103      va_start(va, fmt);
104      vsnprintf(buf, ARRAY_LENGTH(buf), fmt, va);
105      va_end(va);
106      (*state->error_proc)(buf);
107   }
108}
109
110
111/*-------------------------------------------------
112    unknown_tag
113-------------------------------------------------*/
114
115INLINE void unknown_tag(parse_state *state, const char *tagname)
116{
117   parse_error(state, "[%lu:%lu]: Unknown tag: %s\n",
118      XML_GetCurrentLineNumber(state->parser),
119      XML_GetCurrentColumnNumber(state->parser),
120      tagname);
121}
122
123
124
125/*-------------------------------------------------
126    unknown_attribute
127-------------------------------------------------*/
128
129INLINE void unknown_attribute(parse_state *state, const char *attrname)
130{
131   parse_error(state, "[%lu:%lu]: Unknown attribute: %s\n",
132      XML_GetCurrentLineNumber(state->parser),
133      XML_GetCurrentColumnNumber(state->parser),
134      attrname);
135}
136
137
138
139/*-------------------------------------------------
140    unknown_attribute_value
141-------------------------------------------------*/
142
143INLINE void unknown_attribute_value(parse_state *state,
144   const char *attrname, const char *attrvalue)
145{
146   parse_error(state, "[%lu:%lu]: Unknown attribute value: %s\n",
147      XML_GetCurrentLineNumber(state->parser),
148      XML_GetCurrentColumnNumber(state->parser),
149      attrvalue);
150}
151
152
153/*-------------------------------------------------
154   software_name_split
155   helper; splits a software_list:software:part
156    string into seperate software_list, software,
157    and part strings.
158
159    str1:str2:str3  => swlist_name - str1, swname - str2, swpart - str3
160   str1:str2      => swlist_name - NULL, swname - str1, swpart - str2
161    str1         => swlist_name - NULL, swname - str1, swpart - NULL
162
163    swlist_namem, swnane and swpart will be global_alloc'ed
164    from the global pool. So they should be global_free'ed
165    when they are not used anymore.
166-------------------------------------------------*/
167static void software_name_split(const char *swlist_swname, char **swlist_name, char **swname, char **swpart )
168{
169   const char *split_1st_loc = strchr( swlist_swname, ':' );
170   const char *split_2nd_loc = ( split_1st_loc ) ? strchr( split_1st_loc + 1, ':' ) : NULL;
171
172   *swlist_name = NULL;
173   *swname = NULL;
174   *swpart = NULL;
175
176   if ( split_1st_loc )
177   {
178      if ( split_2nd_loc )
26179      {
27         return software_lists[listnum];
180         int size = split_1st_loc - swlist_swname;
181         *swlist_name = global_alloc_array_clear(char,size+1);
182         memcpy( *swlist_name, swlist_swname, size );
183
184         size = split_2nd_loc - ( split_1st_loc + 1 );
185         *swname = global_alloc_array_clear(char,size+1);
186         memcpy( *swname, split_1st_loc + 1, size );
187
188         size = strlen( swlist_swname ) - ( split_2nd_loc + 1 - swlist_swname );
189         *swpart = global_alloc_array_clear(char,size+1);
190         memcpy( *swpart, split_2nd_loc + 1, size );
28191      }
192      else
193      {
194         int size = split_1st_loc - swlist_swname;
195         *swname = global_alloc_array_clear(char,size+1);
196         memcpy( *swname, swlist_swname, size );
197
198         size = strlen( swlist_swname ) - ( split_1st_loc + 1 - swlist_swname );
199         *swpart = global_alloc_array_clear(char,size+1);
200         memcpy( *swpart, split_1st_loc + 1, size );
201      }
29202   }
203   else
204   {
205      int size = strlen( swlist_swname );
206      *swname = global_alloc_array_clear(char,size+1);
207      memcpy( *swname, swlist_swname, size );
208   }
209}
30210
31   return NULL;
211
212/*-------------------------------------------------
213    add_rom_entry
214-------------------------------------------------*/
215
216static void add_rom_entry(software_list *swlist, const char *name, const char *hashdata, UINT32 offset, UINT32 length, UINT32 flags)
217{
218   software_part *part = &swlist->softinfo->partdata[swlist->current_part_entry-1];
219   struct rom_entry *entry = &part->romdata[swlist->current_rom_entry];
220
221   entry->_name = name;
222   entry->_hashdata = hashdata;
223   entry->_offset = offset;
224   entry->_length = length;
225   entry->_flags = flags;
226
227   swlist->current_rom_entry += 1;
228
229   if ( swlist->current_rom_entry >= swlist->rom_entries )
230   {
231      struct rom_entry *new_entries;
232
233      swlist->rom_entries += 10;
234      new_entries = (struct rom_entry *)pool_realloc_lib(swlist->pool, part->romdata, swlist->rom_entries * sizeof(struct rom_entry) );
235
236      if ( new_entries )
237      {
238         part->romdata = new_entries;
239      }
240      else
241      {
242         /* Allocation error */
243         swlist->current_rom_entry -= 1;
244      }
245   }
32246}
33247
34248
35249/*-------------------------------------------------
36    software_get_by_name - return a pointer to
37    a software entry list given its name and a
38    software list.
250    add_software_part
39251-------------------------------------------------*/
40252
41const software_entry* software_get_by_name(const software_list* list, const char *name)
253static void add_software_part(software_list *swlist, const char *name, const char *interface, const char *feature)
42254{
43   const char *softname;
44   int entrynum;
255   software_part *part = &swlist->softinfo->partdata[swlist->current_part_entry];
45256
46   assert( name != NULL );
257   part->name = name;
258   part->interface = interface;
259   part->feature = feature;
260   part->romdata = NULL;
47261
48   softname = strrchr( name, ':' );
49   if ( softname )
50      softname++;   /* Skip ':' */
51   else
52      softname = name;
262   swlist->current_part_entry += 1;
53263
54   /* scan for a match in the software list */
55   for ( entrynum = 0; list->entries[entrynum].name != NULL; entrynum++ )
264   if ( swlist->current_part_entry >= swlist->part_entries )
56265   {
57      if ( mame_stricmp( list->entries[entrynum].name, softname ) == 0 )
266      software_part *new_parts;
267
268      swlist->part_entries += 2;
269      new_parts = (software_part *)pool_realloc_lib(swlist->pool, swlist->softinfo->partdata, swlist->part_entries * sizeof(software_part) );
270
271      if ( new_parts )
58272      {
59         return &list->entries[entrynum];
273         swlist->softinfo->partdata = new_parts;
60274      }
275      else
276      {
277         /* Allocation error */
278         swlist->current_part_entry -= 1;
279      }
61280   }
281}
282
283
284/*-------------------------------------------------
285    start_handler
286-------------------------------------------------*/
287
288static void start_handler(void *data, const char *tagname, const char **attributes)
289{
290   software_list *swlist = (software_list *) data;
291   char **text_dest;
292
293   switch(swlist->state.pos)
294   {
295      case POS_ROOT:
296         if (!strcmp(tagname, "softwarelist"))
297         {
298            for( ; attributes[0]; attributes += 2 )
299            {
300               if ( ! strcmp(attributes[0], "name" ) )
301               {
302               }
303               if ( ! strcmp(attributes[0], "description" ) )
304               {
305               }
306            }
307         }
308         else
309         {
310            unknown_tag(&swlist->state, tagname);
311         }
312         break;
313
314      case POS_MAIN:
315         if ( !strcmp( tagname, "software" ) )
316         {
317            const char *name = NULL;
318            const char *supported = NULL;
319
320            for ( ; attributes[0]; attributes += 2 )
321            {
322               if ( !strcmp( attributes[0], "name" ) )
323               {
324                  name = attributes[1];
325               }
326               if ( !strcmp( attributes[0], "supported" ) )
327               {
328                  supported = attributes[1];
329               }
330            }
331
332            if ( name && !mame_strwildcmp( swlist->look_for, name ) )
333            {
334               struct software_info_list *elem = (struct software_info_list *)pool_malloc_lib(swlist->pool,sizeof(struct software_info_list));
335
336               if ( !elem )
337                  return;
338
339               /* Clear element and add element to list */
340               memset(elem,0,sizeof(struct software_info_list));
341
342               /* Allocate space to hold the shortname and copy the short name */
343               elem->info.shortname = (const char*)pool_malloc_lib(swlist->pool, ( strlen( name ) + 1 ) * sizeof(char) );
344
345               if ( ! elem->info.shortname )
346                  return;
347
348               strcpy( (char *)elem->info.shortname, name );
349
350               /* Allocate initial space to hold part information */
351               swlist->part_entries = 2;
352               swlist->current_part_entry = 0;
353               elem->info.partdata = (software_part *)pool_malloc_lib(swlist->pool, swlist->part_entries * sizeof(software_part) );
354               if ( !elem->info.partdata )
355                  return;
356
357               /* Handle the supported flag */
358               elem->info.supported = SOFTWARE_SUPPORTED_YES;
359               if ( ! strcmp( supported, "partial" ) )
360                  elem->info.supported = SOFTWARE_SUPPORTED_PARTIAL;
361               if ( ! strcmp( supported, "no" ) )
362                  elem->info.supported = SOFTWARE_SUPPORTED_NO;
363
364               /* Add the entry to the end of the list */
365               if ( swlist->software_info_list == NULL )
366               {
367                  swlist->software_info_list = elem;
368                  swlist->current_software_info = elem;
369               }
370               else
371               {
372                  swlist->current_software_info->next = elem;
373                  swlist->current_software_info = elem;
374               }
375
376               /* Quick lookup for setting software information */
377               swlist->softinfo = &swlist->current_software_info->info;
378            }
379            else
380            {
381               swlist->softinfo = NULL;
382            }
383         }
384         else
385         {
386            unknown_tag(&swlist->state, tagname);
387         }
388         break;
389
390      case POS_SOFT:
391         text_dest = NULL;
392
393         if (!strcmp(tagname, "description"))
394            text_dest = (char **) &swlist->softinfo->longname;
395         else if (!strcmp(tagname, "year"))
396            text_dest = (char **) &swlist->softinfo->year;
397         else if (!strcmp(tagname, "publisher"))
398            text_dest = (char **) &swlist->softinfo->publisher;
399         else if ( !strcmp(tagname, "part" ) )
400         {
401            const char *str_name = NULL;
402            const char *str_interface = NULL;
403            const char *str_feature = NULL;
404
405            for ( ; attributes[0]; attributes += 2 )
406            {
407               if ( !strcmp( attributes[0], "name" ) )
408                  str_name = attributes[1];
409
410               if ( !strcmp( attributes[0], "interface" ) )
411                  str_interface = attributes[1];
412
413               if ( !strcmp( attributes[0], "feature" ) )
414                  str_feature = attributes[1];
415            }
416
417            if ( str_name && str_interface )
418            {
419               if ( swlist->softinfo )
420               {
421                  char *name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
422                  char *interface = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_interface ) + 1 ) * sizeof(char) );
423                  char *feature = NULL;
424
425                  if ( !name || !interface )
426                     return;
427
428                  strcpy( name, str_name );
429                  strcpy( interface, str_interface );
430
431                  if ( str_feature )
432                  {
433                     feature = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature ) + 1 ) * sizeof(char) );
434                     if ( !feature )
435                        return;
436                     strcpy( feature, str_feature );
437                  }
438
439                  add_software_part( swlist, name, interface, feature );
440
441                  /* Allocate initial space to hold the rom information */
442                  swlist->rom_entries = 3;
443                  swlist->current_rom_entry = 0;
444                  swlist->softinfo->partdata[swlist->current_part_entry-1].romdata = (struct rom_entry *)pool_malloc_lib(swlist->pool, swlist->rom_entries * sizeof(struct rom_entry));
445                  if ( ! swlist->softinfo->partdata[swlist->current_part_entry-1].romdata )
446                     return;
447               }
448            }
449            else
450            {
451               /* Incomplete/incorrect part definition */
452            }
453         }
454         else
455            unknown_tag(&swlist->state, tagname);
456
457         if (text_dest && swlist->softinfo)
458            swlist->state.text_dest = text_dest;
459         break;
460
461      case POS_PART:
462         if (!strcmp(tagname, "dataarea"))
463         {
464            const char *str_name = NULL;
465            const char *str_size = NULL;
466
467            for ( ; attributes[0]; attributes += 2 )
468            {
469               if ( !strcmp( attributes[0], "name" ) )
470                  str_name = attributes[1];
471
472               if ( !strcmp( attributes[0], "size") )
473                  str_size = attributes[1];
474            }
475            if ( str_name && str_size )
476            {
477               if ( swlist->softinfo )
478               {
479                  UINT32 length = strtol( str_size, NULL, 10 );
480                  char *s = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
481
482                  if ( !s )
483                     return;
484
485                  strcpy( s, str_name );
486
487                  /* ROM_REGION( length, "name", flags ) */
488                  add_rom_entry( swlist, s, NULL, 0, length, ROMENTRYTYPE_REGION );
489               }
490            }
491            else
492            {
493               /* Missing dataarea name or size */
494            }
495         }
496         else
497            unknown_tag( &swlist->state, tagname );
498         break;
499
500      case POS_DATA:
501         if (!strcmp(tagname, "rom"))
502         {
503            const char *str_name = NULL;
504            const char *str_size = NULL;
505            const char *str_crc = NULL;
506            const char *str_sha1 = NULL;
507            const char *str_offset = NULL;
508            const char *str_loadflag = NULL;
509
510            for ( ; attributes[0]; attributes += 2 )
511            {
512               if ( !strcmp( attributes[0], "name" ) )
513                  str_name = attributes[1];
514               if ( !strcmp( attributes[0], "size" ) )
515                  str_size = attributes[1];
516               if ( !strcmp( attributes[0], "crc" ) )
517                  str_crc = attributes[1];
518               if ( !strcmp( attributes[0], "sha1" ) )
519                  str_sha1 = attributes[1];
520               if ( !strcmp( attributes[0], "offset" ) )
521                  str_offset = attributes[1];
522               if ( !strcmp( attributes[0], "loadflag" ) )
523                  str_loadflag = attributes[1];
524            }
525            if ( str_name && str_size && str_crc && str_sha1 && str_offset )
526            {
527               if ( swlist->softinfo )
528               {
529                  UINT32 length = strtol( str_size, NULL, 10 );
530                  UINT32 offset = strtol( str_offset, NULL, 16 );
531                  char *s_name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
532                  char *hashdata = (char *)pool_malloc_lib( swlist->pool, sizeof(char) * ( strlen(str_crc) + strlen(str_sha1) + 7 ) );
533
534                  if ( !s_name || !hashdata )
535                     return;
536
537                  strcpy( s_name, str_name );
538                  sprintf( hashdata, "c:%s#s:%s#", str_crc, str_sha1 );
539
540                  /* ROM_LOAD( name, offset, length, hash ) */
541                  add_rom_entry( swlist, s_name, hashdata, offset, length, ROMENTRYTYPE_ROM );
542               }
543            }
544            else
545            {
546               /* Missing name, size, crc, sha1, or offset */
547            }
548         }
549         else
550            unknown_tag(&swlist->state, tagname);
551         break;
552   }
553   swlist->state.pos = (softlist_parse_position) (swlist->state.pos + 1);
554}
555
556/*-------------------------------------------------
557    end_handler
558-------------------------------------------------*/
559
560static void end_handler(void *data, const char *name)
561{
562   software_list *swlist = (software_list *) data;
563   swlist->state.text_dest = NULL;
564
565   swlist->state.pos = (softlist_parse_position) (swlist->state.pos - 1);
566   switch(swlist->state.pos)
567   {
568      case POS_ROOT:
569      case POS_SOFT:
570         break;
571
572      case POS_MAIN:
573         if ( swlist->softinfo )
574         {
575            add_software_part( swlist, NULL, NULL, NULL );
576         }
577         break;
578
579      case POS_PART:
580         if ( swlist->softinfo )
581         {
582            /* ROM_END */
583            add_rom_entry( swlist, NULL, NULL, 0, 0, ROMENTRYTYPE_END );
584         }
585         break;
586
587      case POS_DATA:
588         break;
589   }
590}
591
592
593/*-------------------------------------------------
594    data_handler
595-------------------------------------------------*/
596
597static void data_handler(void *data, const XML_Char *s, int len)
598{
599   software_list *swlist = (software_list *) data;
600   int text_len;
601   char *text;
602
603   if (swlist->state.text_dest)
604   {
605      text = *swlist->state.text_dest;
606
607      text_len = text ? strlen(text) : 0;
608      text = (char*)pool_realloc_lib(swlist->pool, text, text_len + len + 1);
609      if (!text)
610         return;
611
612      memcpy(&text[text_len], s, len);
613      text[text_len + len] = '\0';
614      *swlist->state.text_dest = text;
615   }
616}
617
618
619/*-------------------------------------------------
620    software_list_parse
621-------------------------------------------------*/
622
623static void software_list_parse(software_list *swlist,
624   void (*error_proc)(const char *message),
625   void *param)
626{
627   char buf[1024];
628   UINT32 len;
629   XML_Memory_Handling_Suite memcallbacks;
630
631   mame_fseek(swlist->file, 0, SEEK_SET);
632
633   memset(&swlist->state, 0, sizeof(swlist->state));
634   swlist->state.error_proc = error_proc;
635   swlist->state.param = param;
636
637   /* create the XML parser */
638   memcallbacks.malloc_fcn = expat_malloc;
639   memcallbacks.realloc_fcn = expat_realloc;
640   memcallbacks.free_fcn = expat_free;
641   swlist->state.parser = XML_ParserCreate_MM(NULL, &memcallbacks, NULL);
642   if (!swlist->state.parser)
643      goto done;
644
645   XML_SetUserData(swlist->state.parser, swlist);
646   XML_SetElementHandler(swlist->state.parser, start_handler, end_handler);
647   XML_SetCharacterDataHandler(swlist->state.parser, data_handler);
648
649   while(!swlist->state.done)
650   {
651      len = mame_fread(swlist->file, buf, sizeof(buf));
652      swlist->state.done = mame_feof(swlist->file);
653      if (XML_Parse(swlist->state.parser, buf, len, swlist->state.done) == XML_STATUS_ERROR)
654      {
655         parse_error(&swlist->state, "[%lu:%lu]: %s\n",
656            XML_GetCurrentLineNumber(swlist->state.parser),
657            XML_GetCurrentColumnNumber(swlist->state.parser),
658            XML_ErrorString(XML_GetErrorCode(swlist->state.parser)));
659         goto done;
660      }
661   }
662
663done:
664   if (swlist->state.parser)
665      XML_ParserFree(swlist->state.parser);
666   swlist->state.parser = NULL;
667   swlist->current_software_info = swlist->software_info_list;
668}
669
670
671/*-------------------------------------------------
672    software_list_open
673-------------------------------------------------*/
674
675software_list *software_list_open(core_options *options, const char *listname, int is_preload,
676   void (*error_proc)(const char *message))
677{
678   file_error filerr;
679   astring *fname;
680   software_list *swlist = NULL;
681   object_pool *pool = NULL;
682
683   /* create a pool for this software list file */
684   pool = pool_alloc_lib(error_proc);
685   if (!pool)
686      goto error;
687
688   /* allocate space for this software list file */
689   swlist = (software_list *) pool_malloc_lib(pool, sizeof(*swlist));
690   if (!swlist)
691      goto error;
692
693   /* set up the software_list structure */
694   memset(swlist, 0, sizeof(*swlist));
695   swlist->pool = pool;
696   swlist->error_proc = error_proc;
697
698   /* open a file */
699   fname = astring_assemble_2(astring_alloc(), listname, ".xml");
700   filerr = mame_fopen_options(options, SEARCHPATH_HASH, astring_c(fname), OPEN_FLAG_READ, &swlist->file);
701   astring_free(fname);
702
703   if (filerr != FILERR_NONE)
704      goto error;
705
706//   if (is_preload)
707//      software_list_parse(swlist, swlist->error_proc, NULL);
708
709   return swlist;
710
711error:
712   if (swlist != NULL)
713      software_list_close(swlist);
62714   return NULL;
63715}
64716
65717
66718/*-------------------------------------------------
67    software_lists_get_count - returns the amount of
68    drivers
719    software_list_close
69720-------------------------------------------------*/
70721
71int software_lists_get_count(void)
722void software_list_close(software_list *swlist)
72723{
73    int count;
724   if (swlist->file)
725      mame_fclose(swlist->file);
726   pool_free_lib(swlist->pool);
727}
74728
75    for (count = 0; software_lists[count] != NULL; count++) ;
76    return count;
729
730/*-------------------------------------------------
731    software_list_find
732-------------------------------------------------*/
733
734software_info *software_list_find(software_list *swlist, const char *software)
735{
736   swlist->look_for = software;
737   software_list_parse( swlist, swlist->error_proc, NULL );
738
739   return swlist->current_software_info ? &swlist->current_software_info->info : NULL;
77740}
741
742
743/*-------------------------------------------------
744    software_list_first
745-------------------------------------------------*/
746
747software_info *software_list_first(software_list *swlist)
748{
749   return software_list_find(swlist, "*");
750}
751
752
753/*-------------------------------------------------
754    software_list_next
755-------------------------------------------------*/
756
757software_info *software_list_next(software_list *swlist)
758{
759   if ( swlist->current_software_info )
760   {
761      swlist->current_software_info = swlist->current_software_info->next;
762   }
763   return swlist->current_software_info ? &swlist->current_software_info->info : NULL;
764}
765
766
767/*-------------------------------------------------
768    software_find_part
769-------------------------------------------------*/
770
771software_part *software_find_part(software_info *sw, const char *partname, const char *interface)
772{
773   software_part *part = sw ? sw->partdata : NULL;
774
775    /* If neither partname nor interface supplied, then we just return the first entry */
776   if ( partname || interface )
777   {
778      while( part && part->name )
779      {
780         if ( partname )
781         {
782            if ( !strcmp(partname, part->name ) )
783            {
784               if ( interface )
785               {
786                  if ( !strcmp(interface, part->interface) )
787                  {
788                     break;
789                  }
790               }
791               else
792               {
793                  break;
794               }
795            }
796         }
797         else
798         {
799            /* No specific partname supplied, find the first match based on interface */
800            if ( interface )
801            {
802               if ( !strcmp(interface, part->interface) )
803               {
804                  break;
805               }
806            }
807         }
808         part++;
809      }
810   }
811
812   if ( ! part->name )
813      part = NULL;
814
815   return part;
816}
817
818
819/*-------------------------------------------------
820    software_part_next
821-------------------------------------------------*/
822
823software_part *software_part_next(software_part *part)
824{
825   if ( part && part->name )
826   {
827      part++;
828   }
829
830   if ( ! part->name )
831      part = NULL;
832
833   return part;
834}
835
836
837/*-------------------------------------------------
838    load_software_part
839
840    Load a software part for a device. The part to
841    load is determined by the "path", software lists
842    configured for a driver, and the interface
843    supported by the device.
844
845    returns true if the software could be loaded,
846    false otherwise. If the software could be loaded
847    sw_info and sw_part are also set.
848-------------------------------------------------*/
849
850bool load_software_part(running_device *device, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name)
851{
852   char *swlist_name, *swname, *swpart;
853   const char *interface;
854   bool result = false;
855   software_list *software_list_ptr = NULL;
856   software_info *software_info_ptr = NULL;
857   software_part *software_part_ptr = NULL;
858
859   *sw_info = NULL;
860   *sw_part = NULL;
861
862   /* Split full software name into software list name and short software name */
863   software_name_split( path, &swlist_name, &swname, &swpart );
864
865   interface = device->get_config_string(DEVINFO_STR_INTERFACE);
866
867   if ( swlist_name )
868   {
869      /* Try to open the software list xml file explicitly named by the user */
870      software_list_ptr = software_list_open( mame_options(), swlist_name, FALSE, NULL );
871
872      if ( software_list_ptr )
873      {
874         software_info_ptr = software_list_find( software_list_ptr, swname );
875
876         if ( software_info_ptr )
877         {
878            software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
879         }
880      }
881   }
882   else
883   {
884      /* Loop through all the software lists named in the driver */
885      running_device *swlists = devtag_get_device( device->machine, __SOFTWARE_LIST_TAG );
886
887      if ( swlists )
888      {
889         UINT32 i = DEVINFO_STR_SWLIST_0;
890
891         while ( ! software_part_ptr && i <= DEVINFO_STR_SWLIST_MAX )
892         {
893            swlist_name = (char *)swlists->baseconfig().get_config_string( i );
894
895            if ( swlist_name && *swlist_name )
896            {
897               if ( software_list_ptr )
898               {
899                  software_list_close( software_list_ptr );
900               }
901
902               software_list_ptr = software_list_open( mame_options(), swlist_name, FALSE, NULL );
903
904               if ( software_list_ptr )
905               {
906                  software_info_ptr = software_list_find( software_list_ptr, swname );
907
908                  if ( software_info_ptr )
909                  {
910                     software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
911                  }
912               }
913            }
914
915            i++;
916         }
917      }
918
919      /* If not found try to load the software list using the driver name */
920      if ( ! software_part_ptr )
921      {
922         swlist_name = (char *)device->machine->gamedrv->name;
923
924         if ( software_list_ptr )
925         {
926            software_list_close( software_list_ptr );
927         }
928
929         software_list_ptr = software_list_open( mame_options(), swlist_name, FALSE, NULL );
930
931         if ( software_list_ptr )
932         {
933            software_info_ptr = software_list_find( software_list_ptr, swname );
934
935            if ( software_info_ptr )
936            {   
937               software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
938            }
939         }
940      }
941
942      /* If not found try to load the software list using the software name as software */
943      /* list name and software part name as software name. */
944      if ( ! software_part_ptr )
945      {
946         swlist_name = swname;
947         swname = swpart;
948         swpart = NULL;
949
950         if ( software_list_ptr )
951         {
952            software_list_close( software_list_ptr );
953         }
954
955         software_list_ptr = software_list_open( mame_options(), swlist_name, FALSE, NULL );
956
957         if ( software_list_ptr )
958         {
959            software_info_ptr = software_list_find( software_list_ptr, swname );
960
961            if ( software_info_ptr )
962            {
963               software_part_ptr = software_find_part( software_info_ptr, swpart, interface );
964            }
965
966            if ( ! software_part_ptr )
967            {
968               software_list_close( software_list_ptr );
969               software_list_ptr = NULL;
970            }
971         }
972      }
973   }
974
975   if ( software_part_ptr )
976   {
977      /* Load the software part */
978      load_software_part_region( device, (char *)swlist_name, (char *)software_info_ptr->shortname, software_part_ptr->romdata );
979
980      /* Create a copy of the software and part information */
981      *sw_info = auto_alloc_clear( device->machine, software_info );
982      (*sw_info)->shortname = auto_strdup( device->machine, software_info_ptr->shortname );
983      (*sw_info)->longname = auto_strdup( device->machine, software_info_ptr->longname );
984      if ( software_info_ptr->year )
985         (*sw_info)->year = auto_strdup( device->machine, software_info_ptr->year );
986      if ( software_info_ptr->publisher )
987         (*sw_info)->publisher = auto_strdup( device->machine, software_info_ptr->publisher );
988
989      *sw_part = auto_alloc_clear( device->machine, software_part );
990      (*sw_part)->name = auto_strdup( device->machine, software_part_ptr->name );
991      if ( software_part_ptr->interface )
992         (*sw_part)->interface = auto_strdup( device->machine, software_part_ptr->interface );
993      if ( software_part_ptr->feature )
994         (*sw_part)->feature = auto_strdup( device->machine, software_part_ptr->feature );
995
996      /* Tell the world which part we actually loaded */
997      *full_sw_name = auto_alloc_array( device->machine, char, strlen(swlist_name) + strlen(software_info_ptr->shortname) + strlen(software_part_ptr->name) + 3 );
998      sprintf( *full_sw_name, "%s:%s:%s", swlist_name, software_info_ptr->shortname, software_part_ptr->name );
999
1000      result = true;
1001   }
1002
1003   /* Close the software list if it's still open */
1004   if ( software_list_ptr )
1005   {
1006      software_list_close( software_list_ptr );
1007      software_info_ptr = NULL;
1008      software_list_ptr = NULL;
1009   }
1010   global_free( swlist_name );
1011   global_free( swname );
1012   global_free( swpart );
1013
1014   return result;
1015}
1016
1017
1018/***************************************************************************
1019    DEVICE INTERFACE
1020***************************************************************************/
1021
1022
1023static DEVICE_START( software_list )
1024{
1025}
1026
1027
1028DEVICE_GET_INFO( software_list )
1029{
1030   switch (state)
1031   {
1032      /* --- the following bits of info are returned as 64-bit signed integers --- */
1033      case DEVINFO_INT_TOKEN_BYTES:               info->i = 1;                              break;
1034      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(software_list_config);            break;
1035      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;               break;
1036
1037      /* --- the following bits of info are returned as pointers to data or functions --- */
1038      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME( software_list );   break;
1039      case DEVINFO_FCT_STOP:                     /* Nothing */                              break;
1040
1041      /* --- the following bits of info are returned as NULL-terminated strings --- */
1042      case DEVINFO_STR_NAME:                     strcpy(info->s, "Software lists");               break;
1043      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Software lists");               break;
1044      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                        break;
1045      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                     break;
1046      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");            break;
1047   }
1048
1049   if ( state >= DEVINFO_STR_SWLIST_0 && state <= DEVINFO_STR_SWLIST_MAX )
1050   {
1051      software_list_config *config = (software_list_config *)device->inline_config;
1052
1053      if ( config->list_name[ state - DEVINFO_STR_SWLIST_0 ] )
1054         strcpy(info->s, config->list_name[ state - DEVINFO_STR_SWLIST_0 ]);
1055   }
1056}
1057
src/mess/softlist.h
r7695r7696
22
33    softlist.h
44
5    Software entry and software list information.
5    Software and software list information.
66
77*********************************************************************/
88
99#ifndef __SOFTLIST_H_
1010#define __SOFTLIST_H_
1111
12#include "romload.h"
12/*********************************************************************
1313
14    Internal structures and XML file handling
1415
15/* ----- software typedef ----- */
16*********************************************************************/
1617
17typedef struct _software_entry software_entry;
18struct _software_entry
18typedef struct _software_part software_part;
19struct _software_part
1920{
20   const char *   name;            /* short name of the software */
21   const char *   parent;            /* parent */
22   const char *   fullname;         /* full name of the software */
23   const char *   release_date;      /* release date */
24   const char *   manufacturer;      /* manufacturer */
25   UINT64         userflags;         /* freely usable flags, can be used to store things like board type or pcb features */
26   UINT32         flags;            /* general flags known to the framework */
27   const rom_entry   *rom_info;         /* rom information for the software */
21   const char *name;
22   const char *interface;
23   const char *feature;
24   struct rom_entry *romdata;
2825};
2926
3027
31typedef struct _software_list software_list;
32struct _software_list
28/* The software info struct holds basic software information. Additional,
29   optional information like local software names, release dates, serial
30   numbers, etc can be maintained and stored in external recources.
31*/
32typedef struct _software_info software_info;
33struct _software_info
3334{
34   const char * source_file;
35   const char * name;
36   const char * description;
37   const software_entry *   entries;
35   const char *shortname;
36   const char *longname;
37   const char *year;         /* Copyright year on title screen, actual release dates can be tracked in external resources */
38   const char *publisher;
39   UINT32 supported;
40   software_part *partdata;
3841};
3942
4043
41/* ----- software macros ----- */
44typedef struct _software_list software_list;
4245
43#define SOFTWARE_LIST_NAME(name)               software_list_##name
44#define SOFTWARE_NAME(name)                     software_##name
45#define SOFTWARE_LIST(name,desc)               extern const software_list SOFTWARE_LIST_NAME(name) = { __FILE__, #name, desc, software_##name };
46#define SOFTWARE_LIST_START(name)   \
47   static const software_entry SOFTWARE_NAME(name)[] = {
46/* Handling a software list */
47software_list *software_list_open(core_options *options, const char *listname, int is_preload, void (*error_proc)(const char *message));
48void software_list_close(software_list *swlist);
49software_info *software_list_first(software_list *swlist);
50software_info *software_list_find(software_list *swlist, const char *software);
51software_info *software_list_next(software_list *swlist);
4852
49#define SOFTWARE_LIST_END                     { NULL, NULL, NULL, NULL, NULL, 0, 0, NULL } };
53software_part *software_find_part(software_info *sw, const char *partname, const char *interface);
54software_part *software_part_next(software_part *part);
5055
51#define SOFTWARE_ROM_NAME(name)                  software_rom_##name
52#define SOFTWARE_START(name)                  static const rom_entry SOFTWARE_ROM_NAME(name)[] = {
53#define SOFTWARE_END                        ROM_END
5456
57bool load_software_part(running_device *device, const char *path, software_info **sw_info, software_part **sw_part, char **full_sw_name);
5558
56#define SOFTWARE(name,parent,year,manufacturer,fullname,userflags,flags) \
57    { #name, #parent, fullname, #year, manufacturer, userflags, flags, SOFTWARE_ROM_NAME(name) },
5859
60/*********************************************************************
5961
60/***************************************************************************
61    GLOBAL VARIABLES
62***************************************************************************/
62    Driver software list configuration
6363
64extern const software_list * const software_lists[];
64*********************************************************************/
6565
66#define SOFTWARE_LIST      DEVICE_GET_INFO_NAME( software_list )
67#define __SOFTWARE_LIST_TAG   "software_list"
6668
67/***************************************************************************
68    FUNCTION PROTOTYPES
69***************************************************************************/
7069
71const software_list* software_list_get_by_name(const char *name);
72const software_entry* software_get_by_name(const software_list* list, const char *name);
73int software_lists_get_count(void);
70#define SOFTWARE_SUPPORTED_YES      0
71#define SOFTWARE_SUPPORTED_PARTIAL   1
72#define SOFTWARE_SUPPORTED_NO      2
7473
74
75#define SOFTWARE_LIST_CONFIG_SIZE   10
76
77DEVICE_GET_INFO( software_list );
78
79
80typedef struct _software_list_config software_list_config;
81struct _software_list_config
82{
83   char *list_name[SOFTWARE_LIST_CONFIG_SIZE];
84};
85
86
87#define DEVINFO_STR_SWLIST_0   (DEVINFO_STR_DEVICE_SPECIFIC+0)
88#define DEVINFO_STR_SWLIST_MAX   (DEVINFO_STR_SWLIST_0 + SOFTWARE_LIST_CONFIG_SIZE - 1)
89
90
91#define MDRV_SOFTWARE_LIST_CONFIG(_idx,_list)                        \
92   MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(software_list_config, list_name, _idx, _list)
93
94#define MDRV_SOFTWARE_LIST_ADD( _list )                              \
95   MDRV_DEVICE_ADD( __SOFTWARE_LIST_TAG, SOFTWARE_LIST, 0 )            \
96   MDRV_SOFTWARE_LIST_CONFIG(0,_list)
97
98
99#define MDRV_SOFTWARE_LIST_MODIFY( _list )                           \
100   MDRV_DEVICE_MODIFY( __SOFTWARE_LIST_TAG )                        \
101   MDRV_SOFTWARE_LIST_CONFIG(0,_list)
102
103
75104#endif
src/mess/image.c
r7695r7696
6464    unsigned int created : 1;
6565    unsigned int is_loading : 1;
6666
67   /* Software list and software entry information */
68   const software_list *software_list_ptr;
69   const software_entry *software_entry_ptr;
67   /* Software information */
68   char *full_software_name;
69   software_info *software_info_ptr;
70   software_part *software_part_ptr;
7071
7172    /* info read from the hash file */
7273    char *longname;
r7695r7696
218219        slot->unload = (device_image_unload_func) slot->dev->get_config_fct(DEVINFO_FCT_IMAGE_UNLOAD);
219220
220221      /* sodftware list and entry */
221      slot->software_list_ptr = software_list_get_by_name( slot->dev->get_config_string(DEVINFO_STR_SOFTWARE_LIST) );
222      slot->software_entry_ptr = NULL;
222      slot->full_software_name = NULL;
223      slot->software_info_ptr = NULL;
224      slot->software_part_ptr = NULL;
223225
224226        /* creation option guide */
225227        slot->create_option_guide = (const option_guide *) slot->dev->get_config_ptr(DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE);
r7695r7696
381383static void get_device_instance_name(const machine_config *config, const device_config *device,
382384    char *buffer, size_t buffer_len, iodevice_t type, UINT32 state, const char *(*get_dev_typename)(iodevice_t))
383385{
384    const char *result;
385    const device_config *that_device;
386    int count, index;
386   const char *result;
387   const device_config *that_device;
388   int count, index;
387389
388    /* retrieve info about the device instance */
389    result = device->get_config_string(state);
390    if ((result != NULL) && (result[0] != '\0'))
391    {
392        /* we got info directly */
393        snprintf(buffer, buffer_len, "%s", result);
394    }
395    else
396    {
397        /* not specified? default to device names based on the device type */
398        result = get_dev_typename(type);
390   /* retrieve info about the device instance */
391   result = device->get_config_string(state);
392   if ((result != NULL) && (result[0] != '\0'))
393   {
394      /* we got info directly */
395      snprintf(buffer, buffer_len, "%s", result);
396   }
397   else
398   {
399      if ( get_dev_typename )
400      {
401         /* not specified? default to device names based on the device type */
402         result = get_dev_typename(type);
399403
400        /* are there multiple devices of the same type */
401        count = 0;
402        index = -1;
404         /* are there multiple devices of the same type */
405         count = 0;
406         index = -1;
403407
404      for (that_device = config->devicelist.first(); that_device != NULL; that_device = that_device->next)
405      {
406         if (is_image_device(that_device))
408         for (that_device = config->devicelist.first(); that_device != NULL; that_device = that_device->next)
407409         {
408            if (device == that_device)
409               index = count;
410            if (that_device->get_config_int(DEVINFO_INT_IMAGE_TYPE) == type)
411               count++;
412         }
413        }
410            if (is_image_device(that_device))
411            {
412               if (device == that_device)
413                  index = count;
414               if (that_device->get_config_int(DEVINFO_INT_IMAGE_TYPE) == type)
415                  count++;
416            }
417           }
414418
415        /* need to number if there is more than one device */
416        if (count > 1)
417            snprintf(buffer, buffer_len, "%s%d", result, index + 1);
418        else
419            snprintf(buffer, buffer_len, "%s", result);
420    }
419         /* need to number if there is more than one device */
420         if (count > 1)
421            snprintf(buffer, buffer_len, "%s%d", result, index + 1);
422         else
423            snprintf(buffer, buffer_len, "%s", result);
424      }
425   }
421426}
422427
423428
r7695r7696
458463    get_device_instance_name(config, device, info.brief_instance_name, ARRAY_LENGTH(info.brief_instance_name),
459464        info.type, DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME, device_brieftypename);
460465
466   /* retrieve interface name */
467   get_device_instance_name(config, device, info.interface_name, ARRAY_LENGTH(info.interface_name),
468      info.type, DEVINFO_STR_INTERFACE, NULL);
469
461470    return info;
462471}
463472
r7695r7696
658667
659668static int is_loaded(image_slot_data *image)
660669{
661    return (image->file != NULL) || (image->ptr != NULL) || (image->software_entry_ptr != NULL);
670    return (image->file != NULL) || (image->ptr != NULL) || (image->software_info_ptr != NULL);
662671}
663672
664673
r7695r7696
802811        mame_schedule_hard_reset(machine);
803812
804813   /* Check if there's a software list defined for this device and use that if we're not creating an image */
805/* This piece below is commented out until load_region_list or something better is available in src/emu/romload */
806814#if 0
807   if ( !is_create && slot->software_list_ptr )
815   if ( is_create || !load_software_part( image, path, &slot->software_info_ptr, &slot->software_part_ptr, &slot->full_software_name ) )
816#endif
808817   {
809      slot->software_entry = software_get_by_name( slot->software_list_ptr, path );
818      /* determine open plan */
819      determine_open_plan(slot, is_create, open_plan);
810820
811      if ( slot->software_entry )
821      /* attempt to open the file in various ways */
822      for (i = 0; !slot->file && open_plan[i]; i++)
812823      {
813         char swname[256];
814
815         sprintf( swname, "%s:%s", slot->software_list_ptr->name, slot->software_entry->name );
816
817         load_software_region(slot->dev, swname, slot->software_entry->rom_info );
818
819         /* call device load or create */
820         if (image->token != NULL)
821         {
822            err = image_finish_load(image);
823            if (err)
824               goto done;
825         }
826
827         goto done;
824         /* open the file */
825         slot->err = load_image_by_path(slot, open_plan[i], path);
826         if (slot->err && (slot->err != IMAGE_ERROR_FILENOTFOUND))
827            goto done;
828828      }
829829   }
830#endif
831830
832    /* determine open plan */
833    determine_open_plan(slot, is_create, open_plan);
831   /* did we fail to find the file? */
832   if (!is_loaded(slot))
833   {
834      slot->err = IMAGE_ERROR_FILENOTFOUND;
835      goto done;
836   }
834837
835    /* attempt to open the file in various ways */
836    for (i = 0; !slot->file && open_plan[i]; i++)
837    {
838        /* open the file */
839        slot->err = load_image_by_path(slot, open_plan[i], path);
840        if (slot->err && (slot->err != IMAGE_ERROR_FILENOTFOUND))
841            goto done;
842    }
838   /* call device load or create */
839   if (image->token != NULL)
840   {
841      slot->create_format = create_format;
842      slot->create_args = create_args;
843843
844    /* did we fail to find the file? */
845    if (!is_loaded(slot))
846    {
847        slot->err = IMAGE_ERROR_FILENOTFOUND;
848        goto done;
849    }
850
851    /* call device load or create */
852    if (image->token != NULL)
853    {
854        slot->create_format = create_format;
855        slot->create_args = create_args;
856
857844      if (slot->not_init_phase) {
858845         err = (image_error_t)image_finish_load(image);
859846         if (err)
r7695r7696
14081395    image_software_entry
14091396-------------------------------------------------*/
14101397
1411const software_entry *image_software_entry(running_device *image)
1398const software_info *image_software_entry(running_device *image)
14121399{
14131400   image_slot_data *slot = find_image_slot(image);
14141401
1415   return slot->software_entry_ptr;
1402   return slot->software_info_ptr;
14161403}
14171404
14181405
r7695r7696
14261413   image_slot_data *slot = find_image_slot(image);
14271414   char full_tag[256];
14281415
1429   if ( slot->software_list_ptr == NULL || slot->software_entry_ptr == NULL )
1416   if ( slot->software_info_ptr == NULL || slot->software_part_ptr == NULL )
14301417      return NULL;
14311418
1432   sprintf( full_tag, "%s:%s:%s", slot->software_list_ptr->name, slot->software_entry_ptr->name, tag );
1419   sprintf( full_tag, "%s:%s", image->tag(), tag );
14331420   return memory_region( image->machine, full_tag );
14341421}
14351422
r7695r7696
14421429{
14431430    char full_tag[256];
14441431
1445    sprintf( full_tag, "%s:%s:%s", image->tag(), image_software_entry(image)->name, tag );
1432    sprintf( full_tag, "%s:%s:%s", image->tag(), image_software_entry(image)->shortname, tag );
14461433    return memory_region_length( image->machine, full_tag );
14471434}
14481435
src/mess/image.h
r7695r7696
8787    char file_extensions[256];
8888    char instance_name[32];
8989    char brief_instance_name[16];
90   char interface_name[64];
9091};
9192
9293typedef struct _image_device_format image_device_format;
r7695r7696
141142    DEVINFO_STR_IMAGE_CREATE_OPTNAME,
142143    DEVINFO_STR_IMAGE_CREATE_OPTDESC = DEVINFO_STR_IMAGE_CREATE_OPTNAME + DEVINFO_CREATE_OPTMAX,
143144    DEVINFO_STR_IMAGE_CREATE_OPTEXTS = DEVINFO_STR_IMAGE_CREATE_OPTDESC + DEVINFO_CREATE_OPTMAX,
144   DEVINFO_STR_SOFTWARE_LIST,
145   DEVINFO_STR_INTERFACE,
145146    DEVINFO_STR_IMAGE_LAST = DEVINFO_STR_IMAGE_FIRST + 0x0fff
146147};
147148
r7695r7696
263264
264265UINT8 *image_get_software_region(running_device *image, const char *tag);
265266UINT32 image_get_software_region_length(running_device *image, const char *tag);
266const software_entry *image_software_entry(running_device *image);
267const software_info *image_software_entry(running_device *image);
267268
268269
269270
src/mess/mess.mak
r7695r7696
324324   $(MESSOBJ)/mattel.a \
325325   $(MESSOBJ)/mchester.a \
326326   $(MESSOBJ)/memotech.a \
327   $(MESSOBJ)/messsoft.o \
328327   $(MESSOBJ)/mgu.a \
329328   $(MESSOBJ)/microkey.a \
330329   $(MESSOBJ)/mit.a \
r7695r7696
368367   $(MESSOBJ)/skeleton.a \
369368   $(MESSOBJ)/snk.a \
370369   $(MESSOBJ)/softlist.o \
371   $(MESSOBJ)/software.a \
372370   $(MESSOBJ)/sony.a \
373371   $(MESSOBJ)/sord.a \
374372   $(MESSOBJ)/special.a \
r7695r7696
17211719
17221720
17231721#-------------------------------------------------
1724# software information
1725#-------------------------------------------------
1726
1727$(MESSOBJ)/software.a:               \
1728   $(MESS_SOFTWARE)/32x_cart.o   \
1729   $(MESS_SOFTWARE)/advision_cart.o   \
1730   $(MESS_SOFTWARE)/bbcbc_cart.o      \
1731   $(MESS_SOFTWARE)/crvision_cart.o   \
1732   $(MESS_SOFTWARE)/gamecom_cart.o   \
1733   $(MESS_SOFTWARE)/gamegear_cart.o   \
1734   $(MESS_SOFTWARE)/gamepock_cart.o   \
1735   $(MESS_SOFTWARE)/gmaster_cart.o   \
1736   $(MESS_SOFTWARE)/jaguar_cart.o   \
1737   $(MESS_SOFTWARE)/lynx_cart.o   \
1738   $(MESS_SOFTWARE)/megadriv_cart.o   \
1739   $(MESS_SOFTWARE)/ngp_cart.o   \
1740   $(MESS_SOFTWARE)/pasogo_cart.o   \
1741   $(MESS_SOFTWARE)/pico_cart.o   \
1742   $(MESS_SOFTWARE)/pokemini_cart.o   \
1743   $(MESS_SOFTWARE)/sg1000_cart.o   \
1744   $(MESS_SOFTWARE)/sms_cart.o   \
1745   $(MESS_SOFTWARE)/spectrum_cart.o   \
1746   $(MESS_SOFTWARE)/supracan_cart.o   \
1747   $(MESS_SOFTWARE)/svision_cart.o   \
1748   $(MESS_SOFTWARE)/vboy_cart.o   \
1749   $(MESS_SOFTWARE)/wswan_cart.o   \
1750
1751
1752#-------------------------------------------------
17531722# MESS-specific tools
17541723#-------------------------------------------------
17551724
src/mess/drivers/gamepock.c
r7695r7696
9191
9292   /* cartridge */
9393   MDRV_CARTSLOT_ADD("cart")
94   MDRV_CARTSLOT_INTERFACE("gamepock_cart")
9495   MDRV_CARTSLOT_EXTENSION_LIST("bin")
9596   MDRV_CARTSLOT_NOT_MANDATORY
9697   MDRV_CARTSLOT_START(gamepock_cart)
9798   MDRV_CARTSLOT_LOAD(gamepock_cart)
98   MDRV_CARTSLOT_SOFTWARE_LIST(gamepock_cart)
99
100   /* Software lists */
101   MDRV_SOFTWARE_LIST_ADD("gamepock")
99102MACHINE_DRIVER_END
100103
101104
src/mess/drivers/bbcbc.c
r7695r7696
179179
180180   MDRV_CARTSLOT_ADD("cart")
181181   MDRV_CARTSLOT_NOT_MANDATORY
182   MDRV_CARTSLOT_INTERFACE("bbcbc_cart")
182183   MDRV_CARTSLOT_START( bbcbc_cart )
183184   MDRV_CARTSLOT_LOAD( bbcbc_cart )
184   MDRV_CARTSLOT_SOFTWARE_LIST( bbcbc_cart )
185
186   /* Software lists */
187   MDRV_SOFTWARE_LIST_ADD("bbcbc")
185188MACHINE_DRIVER_END
186189
187190

Previous 15994 Revisions Next


© 1998-2018 The MESS Team