diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2010-06-15 09:16:05 +0000 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2010-06-15 09:16:05 +0000 |
commit | 791a3515b9b1e2b9761d695357e5ff1e621d0224 (patch) | |
tree | 5c356f6ef1cd67248f5093c4079745b4bad14635 /src/emu/devlegcy.c | |
parent | 2a5ee186143b35358af24085537426616c4508c6 (diff) |
devlegacy.c,clifront.c,info.c [Miodrag Milanovic]
- Created legacy image device
- Moved opresolv implementation from MESS
- listmedia is option is available in MAME too
- listxml output now contains image devices
Diffstat (limited to 'src/emu/devlegcy.c')
-rw-r--r-- | src/emu/devlegcy.c | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/src/emu/devlegcy.c b/src/emu/devlegcy.c index 7bb660e5af9..19a8579cc25 100644 --- a/src/emu/devlegcy.c +++ b/src/emu/devlegcy.c @@ -344,3 +344,200 @@ void legacy_nvram_device_base::nvram_write(mame_file &file) device_nvram_func nvram_func = reinterpret_cast<device_nvram_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_NVRAM)); (*nvram_func)(this, &file, TRUE); } + +//************************************************************************** +// LEGACY IMAGE DEVICE CONFIGURATION +//************************************************************************** + +typedef struct _image_device_type_info image_device_type_info; +struct _image_device_type_info +{ + iodevice_t type; + const char *name; + const char *shortname; +}; + +static const image_device_type_info device_info_array[] = +{ + { IO_CARTSLOT, "cartridge", "cart" }, /* 0 */ + { IO_FLOPPY, "floppydisk", "flop" }, /* 1 */ + { IO_HARDDISK, "harddisk", "hard" }, /* 2 */ + { IO_CYLINDER, "cylinder", "cyln" }, /* 3 */ + { IO_CASSETTE, "cassette", "cass" }, /* 4 */ + { IO_PUNCHCARD, "punchcard", "pcrd" }, /* 5 */ + { IO_PUNCHTAPE, "punchtape", "ptap" }, /* 6 */ + { IO_PRINTER, "printer", "prin" }, /* 7 */ + { IO_SERIAL, "serial", "serl" }, /* 8 */ + { IO_PARALLEL, "parallel", "parl" }, /* 9 */ + { IO_SNAPSHOT, "snapshot", "dump" }, /* 10 */ + { IO_QUICKLOAD, "quickload", "quik" }, /* 11 */ + { IO_MEMCARD, "memcard", "memc" }, /* 12 */ + { IO_CDROM, "cdrom", "cdrm" }, /* 13 */ + { IO_MAGTAPE, "magtape", "magt" }, /* 14 */ +}; + +static const image_device_type_info *find_device_type(iodevice_t type) +{ + int i; + for (i = 0; i < ARRAY_LENGTH(device_info_array); i++) + { + if (device_info_array[i].type == type) + return &device_info_array[i]; + } + return NULL; +} + +static const char *device_typename(iodevice_t type) +{ + const image_device_type_info *info = find_device_type(type); + return (info != NULL) ? info->name : NULL; +} + + + +static const char *device_brieftypename(iodevice_t type) +{ + const image_device_type_info *info = find_device_type(type); + return (info != NULL) ? info->shortname : NULL; +} + +//------------------------------------------------- +// legacy_image_device_config_base - constructor +//------------------------------------------------- + +legacy_image_device_config_base::legacy_image_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config) + : legacy_device_config_base(mconfig, type, tag, owner, clock, get_config), + device_config_image_interface(mconfig, *this) +{ + memset(&m_config, 0, sizeof(m_config)); + m_mconfig = &mconfig; +} + +//------------------------------------------------- +// device_config_complete - update configuration +// based on completed device setup +//------------------------------------------------- + +void legacy_image_device_config_base::device_config_complete() +{ + char buffer[64]; + const device_config_image_interface *that_device; + int count = 0; + int index = -1; + image_device_format **formatptr; + image_device_format *format; + formatptr = &m_config.m_formatlist; + int cnt = 0; + + m_config.m_type = static_cast<iodevice_t>(get_legacy_config_int(DEVINFO_INT_IMAGE_TYPE)); + m_config.m_readable = get_legacy_config_int(DEVINFO_INT_IMAGE_READABLE)!=0; + m_config.m_writeable = get_legacy_config_int(DEVINFO_INT_IMAGE_WRITEABLE)!=0; + m_config.m_creatable = get_legacy_config_int(DEVINFO_INT_IMAGE_CREATABLE)!=0; + m_config.m_must_be_loaded = get_legacy_config_int(DEVINFO_INT_IMAGE_MUST_BE_LOADED)!=0; + m_config.m_reset_on_load = get_legacy_config_int(DEVINFO_INT_IMAGE_RESET_ON_LOAD)!=0; + m_config.m_has_partial_hash = get_legacy_config_int(DEVINFO_FCT_IMAGE_PARTIAL_HASH)!=0; + + m_config.m_interface_name = core_strdup(get_legacy_config_string(DEVINFO_STR_IMAGE_INTERFACE)); + char *s = global_alloc_array_clear(char,strlen(get_legacy_config_string(DEVINFO_STR_IMAGE_FILE_EXTENSIONS))+2); + strcpy(s,get_legacy_config_string(DEVINFO_STR_IMAGE_FILE_EXTENSIONS)); + m_config.m_file_extensions = s; + /* convert the comma delimited list to a NUL delimited list */ + while((s = strchr(s, ',')) != NULL) + *(s++) = '\0'; + + m_config.load = reinterpret_cast<device_image_load_func>(get_legacy_config_fct(DEVINFO_FCT_IMAGE_LOAD)); + m_config.create = reinterpret_cast<device_image_create_func>(get_legacy_config_fct(DEVINFO_FCT_IMAGE_CREATE)); + m_config.unload = reinterpret_cast<device_image_unload_func>(get_legacy_config_fct(DEVINFO_FCT_IMAGE_UNLOAD)); + m_config.display = reinterpret_cast<device_image_display_func>(get_legacy_config_fct(DEVINFO_FCT_IMAGE_DISPLAY)); + m_config.partialhash = reinterpret_cast<device_image_partialhash_func>(get_legacy_config_fct(DEVINFO_FCT_IMAGE_PARTIAL_HASH)); + m_config.get_devices = reinterpret_cast<device_image_get_devices_func>(get_legacy_config_fct(DEVINFO_FCT_IMAGE_GET_DEVICES)); + + m_config.m_create_option_guide = reinterpret_cast<const option_guide *>(get_legacy_config_ptr(DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE)); + + int format_count = get_legacy_config_int(DEVINFO_INT_IMAGE_CREATE_OPTCOUNT); + + for (int i = 0; i < format_count; i++) + { + // only add if creatable + if (get_legacy_config_string(DEVINFO_PTR_IMAGE_CREATE_OPTSPEC + i)) { + // allocate a new format + format = global_alloc_clear(image_device_format); + + // populate it + format->index = cnt; + format->name = core_strdup(get_legacy_config_string(DEVINFO_STR_IMAGE_CREATE_OPTNAME + i)); + format->description = core_strdup(get_legacy_config_string(DEVINFO_STR_IMAGE_CREATE_OPTDESC + i)); + format->extensions = core_strdup(get_legacy_config_string(DEVINFO_STR_IMAGE_CREATE_OPTEXTS + i)); + format->optspec = core_strdup(get_legacy_config_string(DEVINFO_PTR_IMAGE_CREATE_OPTSPEC + i)); + + // and append it to the list + *formatptr = format; + formatptr = &format->next; + cnt++; + } + } + + for (bool gotone = m_mconfig->devicelist.first(that_device); gotone; gotone = that_device->next(that_device)) + { + if (this == that_device) + index = count; + if (downcast<const legacy_image_device_config_base *>(that_device)->image_type_direct() == m_config.m_type) + count++; + } + if (count > 1) { + snprintf(buffer, 64, "%s%d", device_typename(m_config.m_type), index + 1); + m_config.m_instance_name = core_strdup(buffer); + snprintf(buffer, 64, "%s%d", device_brieftypename(m_config.m_type), index + 1); + m_config.m_brief_instance_name = core_strdup(buffer); + } + else + { + m_config.m_instance_name = core_strdup(device_typename(m_config.m_type)); + m_config.m_brief_instance_name = core_strdup(device_brieftypename(m_config.m_type)); + } + // Override in case of hardcoded values + if (strlen(get_legacy_config_string(DEVINFO_STR_IMAGE_INSTANCE_NAME))>0) { + m_config.m_instance_name = core_strdup(get_legacy_config_string(DEVINFO_STR_IMAGE_INSTANCE_NAME)); + } + if (strlen(get_legacy_config_string(DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME))>0) { + m_config.m_brief_instance_name = core_strdup(get_legacy_config_string(DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME)); + } +} + +const char *legacy_image_device_config_base::image_type_name() const +{ + return device_typename(m_config.m_type); +} +//------------------------------------------------- +// ~legacy_device_config_base - destructor +//------------------------------------------------- + +legacy_image_device_config_base::~legacy_image_device_config_base() +{ + global_free(m_config.m_file_extensions); + image_device_format **formatptr = &m_config.m_formatlist; + + + /* free all entries */ + while (*formatptr != NULL) + { + image_device_format *entry = *formatptr; + *formatptr = entry->next; + global_free(entry); + } +} + + +//************************************************************************** +// LIVE LEGACY IMAGE DEVICE +//************************************************************************** + +//------------------------------------------------- +// legacy_image_device_base - constructor +//------------------------------------------------- + +legacy_image_device_base::legacy_image_device_base(running_machine &machine, const device_config &config) + : legacy_device_base(machine, config), + device_image_interface(machine, config, *this) +{ +} |