Previous 15994 Revisions Next

r9978 Monday 10th January, 2011 at 12:41:57 UTC by Miodrag Milanović
Added support for CHD full support in softlists, and updated CDI list as such.
[hash]cdi.xml softwarelist.dtd
[src/emu]audit.c romload.c romload.h softlist.c
[src/emu/imagedev]chd_cd.c

hash/softwarelist.dtd
r9977r9978
88      <!ELEMENT description (#PCDATA)>
99      <!ELEMENT year (#PCDATA)>
1010      <!ELEMENT publisher (#PCDATA)>
11      <!ELEMENT part (feature*, dataarea*, dipswitch*)>
11      <!ELEMENT part (feature*, dataarea*, diskarea*, dipswitch*)>
1212         <!ATTLIST part name CDATA #REQUIRED>
1313         <!ATTLIST part interface CDATA #REQUIRED>
1414         <!-- feature is used to store things like pcb-type, mapper type, etc. Specific values depend on the system. -->
r9977r9978
3030               <!ATTLIST rom value CDATA #IMPLIED>
3131               <!ATTLIST rom status (baddump|nodump|good) "good">
3232               <!ATTLIST rom loadflag (load16_byte|load16_word|load16_word_swap|load32_byte|load32_word|load32_word_swap|load32_dword|load64_word|load64_word_swap|reload|fill|continue) #IMPLIED>
33         <!ELEMENT diskarea (disk*)>
34            <!ATTLIST diskarea name CDATA #REQUIRED>
35            <!ELEMENT disk EMPTY>
36               <!ATTLIST disk name CDATA #IMPLIED>
37               <!ATTLIST disk md5 CDATA #IMPLIED>
38               <!ATTLIST disk sha1 CDATA #IMPLIED>
39               <!ATTLIST disk status (baddump|nodump|good) "good">
3340         <!ELEMENT dipswitch (dipvalue*)>
3441            <!ATTLIST dipswitch name CDATA #REQUIRED>
3542            <!ATTLIST dipswitch tag CDATA #REQUIRED>
hash/cdi.xml
r9977r9978
66      <year>2000</year>
77      <publisher>????</publisher>
88      <part name="cdrom" interface="cdi_cdrom">
9         <dataarea name="cdrom" size="0">
10            <rom name="Frog Feast.chd" size="124700" crc="97a96d1f" sha1="f18634a157321e566c6809c6e106a2d6579c33ae" offset="000000" />
11         </dataarea>
9         <diskarea name="cdrom">
10            <disk name="Frog Feast" sha1="1ab1eb988458c39e171c8704176617df5730f56e"/>
11         </diskarea>
1212      </part>
1313   </software>
1414</softwarelist>
src/emu/romload.c
r9977r9978
949949    up the parent and loading by checksum
950950-------------------------------------------------*/
951951
952chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd)
952chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd,const char *locationtag)
953953{
954   return open_disk_image_options(mame_options(), gamedrv, romp, image_file, image_chd);
954   return open_disk_image_options(mame_options(), gamedrv, romp, image_file, image_chd, locationtag);
955955}
956956
957957
r9977r9978
961961    checksum
962962-------------------------------------------------*/
963963
964chd_error open_disk_image_options(core_options *options, const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd)
964chd_error open_disk_image_options(core_options *options, const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd,const char *locationtag)
965965{
966966   const game_driver *drv, *searchdrv;
967967   const rom_entry *region, *rom;
r9977r9978
986986      filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
987987   }
988988
989   if (filerr != FILERR_NONE && locationtag!=NULL)
990   {
991      astring fname(locationtag, PATH_SEPARATOR, ROM_GETNAME(romp), ".chd");
992      filerr = mame_fopen_options(options, SEARCHPATH_IMAGE, fname, OPEN_FLAG_READ, image_file);
993   }
994
989995   /* did the file open succeed? */
990996   if (filerr == FILERR_NONE)
991997   {
r9977r9978
11011107    for a region
11021108-------------------------------------------------*/
11031109
1104static void process_disk_entries(rom_load_data *romdata, const char *regiontag, const rom_entry *romp)
1110static void process_disk_entries(rom_load_data *romdata, const char *regiontag, const rom_entry *romp, const char *locationtag)
11051111{
11061112   /* loop until we hit the end of this region */
11071113   for ( ; !ROMENTRY_ISREGIONEND(romp); romp++)
r9977r9978
11221128
11231129         /* first open the source drive */
11241130         LOG(("Opening disk image: %s\n", filename.cstr()));
1125         err = open_disk_image(romdata->machine->gamedrv, romp, &chd.origfile, &chd.origchd);
1131         err = open_disk_image(romdata->machine->gamedrv, romp, &chd.origfile, &chd.origchd, locationtag);
11261132         if (err != CHDERR_NONE)
11271133         {
11281134            if (err == CHDERR_FILE_NOT_FOUND)
r9977r9978
12831289      if (ROMREGION_ISROMDATA(region))
12841290         process_rom_entries(romdata, locationtag, region + 1);
12851291      else if (ROMREGION_ISDISKDATA(region))
1286         process_disk_entries(romdata, locationtag, region + 1);
1292         process_disk_entries(romdata, core_strdup(regiontag.cstr()), region + 1, locationtag);
12871293   }
12881294
12891295   /* now go back and post-process all the regions */
r9977r9978
13461352            process_rom_entries(romdata, ROMREGION_ISLOADBYNAME(region) ? ROMREGION_GETTAG(region) : NULL, region + 1);
13471353         }
13481354         else if (ROMREGION_ISDISKDATA(region))
1349            process_disk_entries(romdata, ROMREGION_GETTAG(region), region + 1);
1355            process_disk_entries(romdata, ROMREGION_GETTAG(region), region + 1, NULL);
13501356      }
13511357
13521358   /* now go back and post-process all the regions */
src/emu/imagedev/chd_cd.c
r9977r9978
7979   dev_cdrom_t   *cdrom = get_safe_token(&image.device());
8080   chd_error   err = (chd_error)0;
8181   chd_file   *chd = NULL;
82   astring tempstring;   
8283
83   err = chd_open_file( image.image_core_file(), CHD_OPEN_READ, NULL, &chd );   /* CDs are never writeable */
84   if ( err )
85      goto error;
84   if (image.software_entry() == NULL)
85   {
86      err = chd_open_file( image.image_core_file(), CHD_OPEN_READ, NULL, &chd );   /* CDs are never writeable */
87      if ( err )
88         goto error;
89   } else {
90      chd  = get_disk_handle(image.device().machine, image.device().subtag(tempstring,"cdrom"));
91   }
8692
8793   /* open the CHD file */
8894   cdrom->cdrom_handle = cdrom_open( chd );
r9977r9978
141147-------------------------------------------------*/
142148static DEVICE_IMAGE_SOFTLIST_LOAD(cdrom)
143149{
144   return image.load_software(swlist, swname, start_entry);
150   load_software_part_region( &image.device(), swlist, swname, start_entry );
151   return TRUE;   
145152}
146153
147154/*-------------------------------------------------
src/emu/romload.h
r9977r9978
313313/* ----- disk handling ----- */
314314
315315/* open a disk image, searching up the parent and loading by checksum */
316chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd);
316chd_error open_disk_image(const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd,const char *locationtag);
317317
318318/* open a disk image, searching up the parent and loading by checksum */
319chd_error open_disk_image_options(core_options *options, const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd);
319chd_error open_disk_image_options(core_options *options, const game_driver *gamedrv, const rom_entry *romp, mame_file **image_file, chd_file **image_chd,const char *locationtag);
320320
321321/* return a pointer to the CHD file associated with the given region */
322322chd_file *get_disk_handle(running_machine *machine, const char *region);
src/emu/softlist.c
r9977r9978
530530               /* Missing dataarea name or size */
531531            }
532532         }
533         else if (!strcmp(tagname, "diskarea"))
534         {
535            const char *str_name = NULL;
536
537            for ( ; attributes[0]; attributes += 2 )
538            {
539               if ( !strcmp( attributes[0], "name" ) )
540                  str_name = attributes[1];
541            }
542            if ( str_name )
543            {
544               if ( swlist->softinfo )
545               {
546                  char *s = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
547
548                  if ( !s )
549                     return;
550
551                  strcpy( s, str_name );
552
553                  /* ROM_REGION( length, "name", flags ) */
554                  add_rom_entry( swlist, s, NULL, 0, 1, ROMENTRYTYPE_REGION | ROMREGION_DATATYPEDISK);
555               }
556            }
557            else
558            {
559               /* Missing dataarea name or size */
560            }
561         }         
533562         else if ( !strcmp(tagname, "feature") )
534563         {
535564            const char *str_feature_name = NULL;
r9977r9978
663692            }
664693         }
665694         else
695         if (!strcmp(tagname, "disk"))
696         {
697            const char *str_name = NULL;
698            const char *str_sha1 = NULL;
699            const char *str_status = NULL;
700
701            for ( ; attributes[0]; attributes += 2 )
702            {
703               if ( !strcmp( attributes[0], "name" ) )
704                  str_name = attributes[1];
705               if ( !strcmp( attributes[0], "sha1" ) )
706                  str_sha1 = attributes[1];
707               if ( !strcmp( attributes[0], "status" ) )
708                  str_status = attributes[1];                 
709            }
710            if ( swlist->softinfo )
711            {
712               if ( str_name && str_sha1 )
713               {
714                  char *s_name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_name ) + 1 ) * sizeof(char) );
715                  char *hashdata = (char *)pool_malloc_lib( swlist->pool, sizeof(char) * ( strlen(str_sha1) + 7 + 4 ) );
716                  int baddump = ( str_status && !strcmp(str_status, "baddump") ) ? 1 : 0;
717                  int nodump = ( str_status && !strcmp(str_status, "nodump" ) ) ? 1 : 0;
718
719                  if ( !s_name || !hashdata )
720                     return;
721
722                  strcpy( s_name, str_name );
723                  sprintf( hashdata, "s:%s#%s", str_sha1, ( nodump ? NO_DUMP : ( baddump ? BAD_DUMP : "" ) ) );
724
725                  add_rom_entry( swlist, s_name, hashdata, 0, 0, ROMENTRYTYPE_ROM | DISK_READONLY );
726               }
727            }
728         }
729         else
666730            unknown_tag(&swlist->state, tagname);
667731         break;
668732   }
src/emu/audit.c
r9977r9978
456456   record->exphash = ROM_GETHASHDATA(rom);
457457
458458   /* open the disk */
459   err = open_disk_image_options(options, gamedrv, rom, &source_file, &source);
459   err = open_disk_image_options(options, gamedrv, rom, &source_file, &source, NULL);
460460
461461   /* if we failed, report the error */
462462   if (err != CHDERR_NONE)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team