mirror of
https://github.com/holub/mame
synced 2025-05-15 10:28:16 +03:00
Adding ability to support other types of software lists, so floppies, cassettes, cd-roms are now possible to be used [Miodrag Milanovic]
This commit is contained in:
parent
0910f8038a
commit
5a4b6fa9a0
@ -39,6 +39,7 @@
|
||||
|
||||
|
||||
#include "emu.h"
|
||||
#include "emuopts.h"
|
||||
#include "devlegcy.h"
|
||||
#include "hashfile.h"
|
||||
#include "zippath.h"
|
||||
@ -214,7 +215,7 @@ legacy_image_device_base::legacy_image_device_base(running_machine &machine, con
|
||||
|
||||
bool legacy_image_device_base::is_loaded()
|
||||
{
|
||||
return (m_file != NULL) || (m_software_info_ptr != NULL);
|
||||
return (m_file != NULL);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
@ -294,6 +295,50 @@ void legacy_image_device_base::determine_open_plan(int is_create, UINT32 *open_p
|
||||
open_plan[i] = 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
load_software - software image loading
|
||||
-------------------------------------------------*/
|
||||
bool legacy_image_device_base::load_software(char *swlist, char *swname, rom_entry *start)
|
||||
{
|
||||
const rom_entry *region;
|
||||
astring regiontag;
|
||||
bool retVal = FALSE;
|
||||
for (region = start; region != NULL; region = rom_next_region(region))
|
||||
{
|
||||
/* loop until we hit the end of this region */
|
||||
const rom_entry *romp = region + 1;
|
||||
while (!ROMENTRY_ISREGIONEND(romp))
|
||||
{
|
||||
/* handle files */
|
||||
if (ROMENTRY_ISFILE(romp))
|
||||
{
|
||||
UINT32 crc = 0;
|
||||
UINT8 crcbytes[4];
|
||||
file_error filerr;
|
||||
|
||||
bool has_crc = hash_data_extract_binary_checksum(ROM_GETHASHDATA(romp), HASH_CRC, crcbytes);
|
||||
if (has_crc)
|
||||
crc = (crcbytes[0] << 24) | (crcbytes[1] << 16) | (crcbytes[2] << 8) | crcbytes[3];
|
||||
|
||||
astring fname(swlist, PATH_SEPARATOR, swname, PATH_SEPARATOR, ROM_GETNAME(romp));
|
||||
if (has_crc)
|
||||
filerr = mame_fopen_crc(SEARCHPATH_ROM, fname, crc, OPEN_FLAG_READ, &m_mame_file);
|
||||
else
|
||||
filerr = mame_fopen(SEARCHPATH_ROM, fname, OPEN_FLAG_READ, &m_mame_file);
|
||||
|
||||
if (filerr == FILERR_NONE)
|
||||
{
|
||||
m_file = mame_core_file(m_mame_file);
|
||||
retVal = TRUE;
|
||||
}
|
||||
break; // load first item for start
|
||||
}
|
||||
romp++; /* something else; skip */
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
load_internal - core image loading
|
||||
-------------------------------------------------*/
|
||||
@ -320,7 +365,8 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
||||
goto done;
|
||||
|
||||
/* Check if there's a software list defined for this device and use that if we're not creating an image */
|
||||
if (is_create || !(softload=load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name )) )
|
||||
softload = load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name );
|
||||
if (is_create || (!softload && m_software_info_ptr==NULL))
|
||||
{
|
||||
/* determine open plan */
|
||||
determine_open_plan(is_create, open_plan);
|
||||
@ -461,11 +507,18 @@ bool legacy_image_device_base::create(const char *path, const image_device_forma
|
||||
|
||||
void legacy_image_device_base::clear()
|
||||
{
|
||||
if (m_file)
|
||||
if (m_mame_file)
|
||||
{
|
||||
core_fclose(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
mame_fclose(m_mame_file);
|
||||
m_mame_file = NULL;
|
||||
m_file = NULL;
|
||||
} else {
|
||||
if (m_file)
|
||||
{
|
||||
core_fclose(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
m_name.reset();
|
||||
m_writeable = FALSE;
|
||||
@ -549,4 +602,4 @@ void legacy_image_device_base::call_get_devices()
|
||||
void *legacy_image_device_base::get_device_specific_call()
|
||||
{
|
||||
return (void*) m_config.get_legacy_config_fct(DEVINFO_FCT_DEVICE_SPECIFIC);
|
||||
}
|
||||
}
|
@ -632,6 +632,7 @@ public:
|
||||
virtual bool finish_load();
|
||||
virtual void unload();
|
||||
virtual bool create(const char *path, const image_device_format *create_format, option_resolution *create_args);
|
||||
virtual bool load_software(char *swlist, char *swname, rom_entry *entry);
|
||||
|
||||
virtual int call_load();
|
||||
virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
|
||||
|
@ -177,6 +177,7 @@ device_image_interface::device_image_interface(running_machine &machine, const d
|
||||
: device_interface(machine, config, device),
|
||||
m_image_config(dynamic_cast<const device_config_image_interface &>(config)),
|
||||
m_file(NULL),
|
||||
m_mame_file(NULL),
|
||||
m_full_software_name(NULL),
|
||||
m_software_info_ptr(NULL),
|
||||
m_software_part_ptr(NULL),
|
||||
|
@ -200,6 +200,7 @@ public:
|
||||
virtual bool load(const char *path) = 0;
|
||||
virtual bool finish_load() = 0;
|
||||
virtual void unload() = 0;
|
||||
virtual bool load_software(char *swlist, char *swname, rom_entry *entry) = 0;
|
||||
|
||||
virtual int call_load() = 0;
|
||||
virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) = 0;
|
||||
@ -293,6 +294,7 @@ protected:
|
||||
|
||||
/* variables that are only non-zero when an image is mounted */
|
||||
core_file *m_file;
|
||||
mame_file *m_mame_file;
|
||||
astring m_name;
|
||||
astring m_basename;
|
||||
astring m_basename_noext;
|
||||
|
Loading…
Reference in New Issue
Block a user