Previous 15994 Revisions Next

r8446 Thursday 8th July, 2010 at 12:58:19 UTC by Miodrag Milanović
Added support for other softlist items, I have tested floppies only locally but it should make no difference to cassette and cdrom's. So start adding softlists :)
This require full recompile since image device class has been changed.
[src/emu]devimage.c devlegcy.h diimage.c diimage.h
[src/mess/devices]cassette.c chd_cd.c flopdrv.c

src/emu/diimage.c
r8445r8446
177177   : device_interface(machine, config, device),
178178     m_image_config(dynamic_cast<const device_config_image_interface &>(config)),
179179     m_file(NULL),
180     m_mame_file(NULL),
180181     m_full_software_name(NULL),
181182     m_software_info_ptr(NULL),
182183     m_software_part_ptr(NULL),
src/emu/diimage.h
r8445r8446
200200   virtual bool load(const char *path) = 0;
201201   virtual bool finish_load() = 0;
202202   virtual void unload() = 0;
203   virtual bool load_software(char *swlist, char *swname, rom_entry *entry) = 0;
203204
204205   virtual int call_load() = 0;
205206   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) = 0;
r8445r8446
293294
294295    /* variables that are only non-zero when an image is mounted */
295296   core_file *m_file;
297   mame_file *m_mame_file;
296298   astring m_name;
297299   astring m_basename;
298300   astring m_basename_noext;
src/emu/devlegcy.h
r8445r8446
632632   virtual bool finish_load();
633633   virtual void unload();
634634   virtual bool create(const char *path, const image_device_format *create_format, option_resolution *create_args);
635   virtual bool load_software(char *swlist, char *swname, rom_entry *entry);
635636
636637   virtual int call_load();
637638   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
src/emu/devimage.c
r8445r8446
3939
4040
4141#include "emu.h"
42#include "emuopts.h"
4243#include "devlegcy.h"
4344#include "hashfile.h"
4445#include "zippath.h"
r8445r8446
214215
215216bool legacy_image_device_base::is_loaded()
216217{
217    return (m_file != NULL) || (m_software_info_ptr != NULL);
218    return (m_file != NULL);
218219}
219220
220221/*-------------------------------------------------
r8445r8446
295296}
296297
297298/*-------------------------------------------------
299    load_software - software image loading
300-------------------------------------------------*/
301bool legacy_image_device_base::load_software(char *swlist, char *swname, rom_entry *start)
302{
303   const rom_entry *region;
304   astring regiontag;
305   bool retVal = FALSE;
306   for (region = start; region != NULL; region = rom_next_region(region))
307   {
308      /* loop until we hit the end of this region */
309      const rom_entry *romp = region + 1;
310      while (!ROMENTRY_ISREGIONEND(romp))
311      {
312         /* handle files */
313         if (ROMENTRY_ISFILE(romp))
314         {
315            UINT32 crc = 0;
316            UINT8 crcbytes[4];
317            file_error filerr;
318           
319            bool has_crc = hash_data_extract_binary_checksum(ROM_GETHASHDATA(romp), HASH_CRC, crcbytes);
320            if (has_crc)
321               crc = (crcbytes[0] << 24) | (crcbytes[1] << 16) | (crcbytes[2] << 8) | crcbytes[3];
322               
323            astring fname(swlist, PATH_SEPARATOR, swname, PATH_SEPARATOR, ROM_GETNAME(romp));
324            if (has_crc)
325               filerr = mame_fopen_crc(SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ, &m_mame_file);
326            else
327               filerr = mame_fopen(SEARCHPATH_ROM, fname, OPEN_FLAG_READ, &m_mame_file);
328               
329            if (filerr == FILERR_NONE)
330            {
331               m_file = mame_core_file(m_mame_file);
332               retVal = TRUE;
333            }
334            break; // load first item for start
335         }
336         romp++;   /* something else; skip */
337      }
338   }
339   return retVal;
340}
341
342/*-------------------------------------------------
298343    load_internal - core image loading
299344-------------------------------------------------*/
300345
r8445r8446
320365        goto done;
321366
322367   /* Check if there's a software list defined for this device and use that if we're not creating an image */
323   if (is_create || !(softload=load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name )) )
368   softload = load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name );
369   if (is_create || (!softload  && m_software_info_ptr==NULL))
324370   {
325371      /* determine open plan */
326372      determine_open_plan(is_create, open_plan);
r8445r8446
461507
462508void legacy_image_device_base::clear()
463509{
464   if (m_file)
510   if (m_mame_file)
465511    {
466        core_fclose(m_file);
467        m_file = NULL;
468    }
512      mame_fclose(m_mame_file);
513      m_mame_file = NULL;
514      m_file = NULL;
515   } else {
516      if (m_file)
517      {
518         core_fclose(m_file);
519         m_file = NULL;
520      }
521   }
469522
470523    m_name.reset();
471524    m_writeable = FALSE;
r8445r8446
549602void *legacy_image_device_base::get_device_specific_call()
550603{
551604   return (void*) m_config.get_legacy_config_fct(DEVINFO_FCT_DEVICE_SPECIFIC);
552}
605}
No newline at end of file
src/mess/devices/cassette.c
r8445r8446
401401-------------------------------------------------*/
402402static DEVICE_IMAGE_SOFTLIST_LOAD(cassette)
403403{
404   return FALSE;
404   return image.load_software(swlist, swname, start_entry);
405405}
406406
407407DEVICE_GET_INFO(cassette)
src/mess/devices/flopdrv.c
r8445r8446
998998-------------------------------------------------*/
999999static DEVICE_IMAGE_SOFTLIST_LOAD(floppy)
10001000{
1001   return FALSE;
1001   return image.load_software(swlist, swname, start_entry);
10021002}
10031003
10041004/*************************************
src/mess/devices/chd_cd.c
r8445r8446
141141-------------------------------------------------*/
142142static DEVICE_IMAGE_SOFTLIST_LOAD(cdrom)
143143{
144   return FALSE;
144   return image.load_software(swlist, swname, start_entry);
145145}
146146
147147/*-------------------------------------------------

Previous 15994 Revisions Next


© 1998-2018 The MESS Team