summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2010-07-08 12:59:21 +0000
committer Miodrag Milanovic <mmicko@gmail.com>2010-07-08 12:59:21 +0000
commit5a4b6fa9a0a655df2ac4464a54402f9391aeeab9 (patch)
tree42166dfbce38fc03e9f518370239f67890d9bc74 /src
parent0910f8038a1abf7d80007a24604aba1127477ea2 (diff)
Adding ability to support other types of software lists, so floppies, cassettes, cd-roms are now possible to be used [Miodrag Milanovic]
Diffstat (limited to 'src')
-rw-r--r--src/emu/devimage.c67
-rw-r--r--src/emu/devlegcy.h1
-rw-r--r--src/emu/diimage.c1
-rw-r--r--src/emu/diimage.h2
4 files changed, 64 insertions, 7 deletions
diff --git a/src/emu/devimage.c b/src/emu/devimage.c
index 8afe752f044..06cc7a72bf7 100644
--- a/src/emu/devimage.c
+++ b/src/emu/devimage.c
@@ -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);
}
/*-------------------------------------------------
@@ -295,6 +296,50 @@ void legacy_image_device_base::determine_open_plan(int is_create, UINT32 *open_p
}
/*-------------------------------------------------
+ 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);
-}
+} \ No newline at end of file
diff --git a/src/emu/devlegcy.h b/src/emu/devlegcy.h
index d58d41c6e3b..bd4c432e6f3 100644
--- a/src/emu/devlegcy.h
+++ b/src/emu/devlegcy.h
@@ -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);
diff --git a/src/emu/diimage.c b/src/emu/diimage.c
index fa50ccf7703..4a0bcac3417 100644
--- a/src/emu/diimage.c
+++ b/src/emu/diimage.c
@@ -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),
diff --git a/src/emu/diimage.h b/src/emu/diimage.h
index ef2bd496910..e0e1dc156a7 100644
--- a/src/emu/diimage.h
+++ b/src/emu/diimage.h
@@ -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;