mirror of
https://github.com/holub/mame
synced 2025-05-18 11:39:29 +03:00
Added per-device image softlist loading routine [Miodrag Milanovic]
Renamed feof to image_feof (in device_image_interface) in order to compile on FreeBSD [El Barto]
This commit is contained in:
parent
c13eb4d193
commit
b797437b3b
@ -303,6 +303,7 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
|||||||
image_error_t err;
|
image_error_t err;
|
||||||
UINT32 open_plan[4];
|
UINT32 open_plan[4];
|
||||||
int i;
|
int i;
|
||||||
|
bool softload = FALSE;
|
||||||
|
|
||||||
/* first unload the image */
|
/* first unload the image */
|
||||||
unload();
|
unload();
|
||||||
@ -319,7 +320,7 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Check if there's a software list defined for this device and use that if we're not creating an image */
|
/* Check if there's a software list defined for this device and use that if we're not creating an image */
|
||||||
if (is_create || !load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name ) )
|
if (is_create || !(softload=load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name )) )
|
||||||
{
|
{
|
||||||
/* determine open plan */
|
/* determine open plan */
|
||||||
determine_open_plan(is_create, open_plan);
|
determine_open_plan(is_create, open_plan);
|
||||||
@ -344,7 +345,7 @@ bool legacy_image_device_base::load_internal(const char *path, bool is_create, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* did we fail to find the file? */
|
/* did we fail to find the file? */
|
||||||
if (!is_loaded())
|
if (!is_loaded() && !softload)
|
||||||
{
|
{
|
||||||
err = IMAGE_ERROR_FILENOTFOUND;
|
err = IMAGE_ERROR_FILENOTFOUND;
|
||||||
goto done;
|
goto done;
|
||||||
@ -502,6 +503,16 @@ int legacy_image_device_base::call_load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool legacy_image_device_base::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
|
||||||
|
{
|
||||||
|
device_image_softlist_load_func func = reinterpret_cast<device_image_softlist_load_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_IMAGE_SOFTLIST_LOAD));
|
||||||
|
if (func) {
|
||||||
|
return (*func)(*this,swlist,swname,start_entry);
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int legacy_image_device_base::call_create(int format_type, option_resolution *format_options)
|
int legacy_image_device_base::call_create(int format_type, option_resolution *format_options)
|
||||||
{
|
{
|
||||||
device_image_create_func func = reinterpret_cast<device_image_create_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_IMAGE_CREATE));
|
device_image_create_func func = reinterpret_cast<device_image_create_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_IMAGE_CREATE));
|
||||||
|
@ -159,6 +159,7 @@ enum
|
|||||||
DEVINFO_FCT_IMAGE_DISPLAY, /* R/O: device_image_display_func */
|
DEVINFO_FCT_IMAGE_DISPLAY, /* R/O: device_image_display_func */
|
||||||
DEVINFO_FCT_IMAGE_PARTIAL_HASH, /* R/O: device_image_partialhash_func */
|
DEVINFO_FCT_IMAGE_PARTIAL_HASH, /* R/O: device_image_partialhash_func */
|
||||||
DEVINFO_FCT_IMAGE_GET_DEVICES, /* R/O: device_image_get_devices_func */
|
DEVINFO_FCT_IMAGE_GET_DEVICES, /* R/O: device_image_get_devices_func */
|
||||||
|
DEVINFO_FCT_IMAGE_SOFTLIST_LOAD, /* R/O: device_image_softlist_load_func */
|
||||||
DEVINFO_FCT_IMAGE_LAST = DEVINFO_FCT_FIRST + 0x0fff,
|
DEVINFO_FCT_IMAGE_LAST = DEVINFO_FCT_FIRST + 0x0fff,
|
||||||
|
|
||||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
||||||
@ -633,6 +634,7 @@ public:
|
|||||||
virtual bool create(const char *path, const image_device_format *create_format, option_resolution *create_args);
|
virtual bool create(const char *path, const image_device_format *create_format, option_resolution *create_args);
|
||||||
|
|
||||||
virtual int call_load();
|
virtual int call_load();
|
||||||
|
virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
|
||||||
virtual int call_create(int format_type, option_resolution *format_options);
|
virtual int call_create(int format_type, option_resolution *format_options);
|
||||||
virtual void call_unload();
|
virtual void call_unload();
|
||||||
virtual void call_display();
|
virtual void call_display();
|
||||||
|
@ -115,7 +115,7 @@ typedef void (*device_image_unload_func)(device_image_interface &image);
|
|||||||
typedef void (*device_image_display_func)(device_image_interface &image);
|
typedef void (*device_image_display_func)(device_image_interface &image);
|
||||||
typedef void (*device_image_partialhash_func)(char *, const unsigned char *, unsigned long, unsigned int);
|
typedef void (*device_image_partialhash_func)(char *, const unsigned char *, unsigned long, unsigned int);
|
||||||
typedef void (*device_image_get_devices_func)(device_image_interface &device);
|
typedef void (*device_image_get_devices_func)(device_image_interface &device);
|
||||||
|
typedef bool (*device_image_softlist_load_func)(device_image_interface &image, char *swlist, char *swname, rom_entry *start_entry);
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// MACROS
|
// MACROS
|
||||||
@ -141,6 +141,8 @@ typedef void (*device_image_get_devices_func)(device_image_interface &device);
|
|||||||
#define DEVICE_IMAGE_GET_DEVICES_NAME(name) device_image_get_devices_##name
|
#define DEVICE_IMAGE_GET_DEVICES_NAME(name) device_image_get_devices_##name
|
||||||
#define DEVICE_IMAGE_GET_DEVICES(name) void DEVICE_IMAGE_GET_DEVICES_NAME(name)(device_image_interface &image)
|
#define DEVICE_IMAGE_GET_DEVICES(name) void DEVICE_IMAGE_GET_DEVICES_NAME(name)(device_image_interface &image)
|
||||||
|
|
||||||
|
#define DEVICE_IMAGE_SOFTLIST_LOAD_NAME(name) device_softlist_load_##name
|
||||||
|
#define DEVICE_IMAGE_SOFTLIST_LOAD(name) bool DEVICE_IMAGE_SOFTLIST_LOAD_NAME(name)(device_image_interface &image, char *swlist, char *swname, rom_entry *start_entry)
|
||||||
|
|
||||||
// ======================> device_config_image_interface
|
// ======================> device_config_image_interface
|
||||||
|
|
||||||
@ -200,6 +202,7 @@ public:
|
|||||||
virtual void unload() = 0;
|
virtual void unload() = 0;
|
||||||
|
|
||||||
virtual int call_load() = 0;
|
virtual int call_load() = 0;
|
||||||
|
virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) = 0;
|
||||||
virtual int call_create(int format_type, option_resolution *format_options) = 0;
|
virtual int call_create(int format_type, option_resolution *format_options) = 0;
|
||||||
virtual void call_unload() = 0;
|
virtual void call_unload() = 0;
|
||||||
virtual void call_display() = 0;
|
virtual void call_display() = 0;
|
||||||
@ -234,7 +237,7 @@ public:
|
|||||||
UINT64 ftell() { check_for_file(); return core_ftell(m_file); }
|
UINT64 ftell() { check_for_file(); return core_ftell(m_file); }
|
||||||
int fgetc() { char ch; if (fread(&ch, 1) != 1) ch = '\0'; return ch; }
|
int fgetc() { char ch; if (fread(&ch, 1) != 1) ch = '\0'; return ch; }
|
||||||
char *fgets(char *buffer, UINT32 length) { check_for_file(); return core_fgets(buffer, length, m_file); }
|
char *fgets(char *buffer, UINT32 length) { check_for_file(); return core_fgets(buffer, length, m_file); }
|
||||||
int feof() { check_for_file(); return core_feof(m_file); }
|
int image_feof() { check_for_file(); return core_feof(m_file); }
|
||||||
void *ptr() {check_for_file(); return (void *) core_fbuffer(m_file); }
|
void *ptr() {check_for_file(); return (void *) core_fbuffer(m_file); }
|
||||||
// configuration access
|
// configuration access
|
||||||
const device_config_image_interface &image_config() const { return m_image_config; }
|
const device_config_image_interface &image_config() const { return m_image_config; }
|
||||||
|
@ -1087,7 +1087,7 @@ bool load_software_part(device_image_interface *image, const char *path, softwar
|
|||||||
{
|
{
|
||||||
/* Load the software part */
|
/* Load the software part */
|
||||||
try {
|
try {
|
||||||
load_software_part_region( &image->device(), (char *)swlist_name, (char *)software_info_ptr->shortname, software_part_ptr->romdata );
|
result = image->call_softlist_load((char *)swlist_name, (char *)software_info_ptr->shortname, software_part_ptr->romdata );
|
||||||
}
|
}
|
||||||
catch (emu_fatalerror &fatal)
|
catch (emu_fatalerror &fatal)
|
||||||
{
|
{
|
||||||
@ -1137,8 +1137,6 @@ bool load_software_part(device_image_interface *image, const char *path, softwar
|
|||||||
/* Tell the world which part we actually loaded */
|
/* Tell the world which part we actually loaded */
|
||||||
*full_sw_name = auto_alloc_array( image->device().machine, char, strlen(swlist_name) + strlen(software_info_ptr->shortname) + strlen(software_part_ptr->name) + 3 );
|
*full_sw_name = auto_alloc_array( image->device().machine, char, strlen(swlist_name) + strlen(software_info_ptr->shortname) + strlen(software_part_ptr->name) + 3 );
|
||||||
sprintf( *full_sw_name, "%s:%s:%s", swlist_name, software_info_ptr->shortname, software_part_ptr->name );
|
sprintf( *full_sw_name, "%s:%s:%s", swlist_name, software_info_ptr->shortname, software_part_ptr->name );
|
||||||
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the software list if it's still open */
|
/* Close the software list if it's still open */
|
||||||
|
Loading…
Reference in New Issue
Block a user