summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2017-03-02 20:01:17 -0500
committer AJR <ajrhacker@users.noreply.github.com>2017-03-02 20:01:17 -0500
commit3ad77eae8a3c541fd02ece252ef56a6d9e3e2a49 (patch)
treefc112d758817569a40d13ae51535b4b37642e873
parente27a978955f4a849b7c11ae0bb0fbc6a2bcdd9af (diff)
Image instance name refactoring and bug fixing (nw)
- update_names no longer takes arguments; the device type can be obtained easily, and the custom instance names are now overrides. Devices might not need to explicitly call update_names in the future. - Fix the frontend crash/assert failure resulting from instance names not being generated properly.
-rw-r--r--src/devices/bus/isa/omti8621.cpp4
-rw-r--r--src/devices/bus/isa/sc499.cpp2
-rw-r--r--src/devices/bus/isa/sc499.h2
-rw-r--r--src/devices/bus/msx_slot/cartridge.h7
-rw-r--r--src/devices/bus/nubus/nubus_image.cpp4
-rw-r--r--src/devices/bus/nubus/nubus_image.h46
-rw-r--r--src/devices/bus/psx/memcard.cpp2
-rw-r--r--src/devices/bus/sega8/sega8_slot.h7
-rw-r--r--src/devices/imagedev/bitbngr.cpp2
-rw-r--r--src/devices/imagedev/bitbngr.h2
-rw-r--r--src/emu/diimage.cpp22
-rw-r--r--src/emu/diimage.h4
-rw-r--r--src/frontend/mame/mameopts.cpp2
-rw-r--r--src/mame/includes/apollo.h2
-rw-r--r--src/mame/includes/hp48.h3
-rw-r--r--src/mame/machine/apollo.cpp2
-rw-r--r--src/mame/machine/hp48.cpp2
-rw-r--r--src/mame/machine/x68k_hdc.cpp2
-rw-r--r--src/mame/machine/x68k_hdc.h2
19 files changed, 73 insertions, 46 deletions
diff --git a/src/devices/bus/isa/omti8621.cpp b/src/devices/bus/isa/omti8621.cpp
index f6c3bfff8d8..8ffdb12843b 100644
--- a/src/devices/bus/isa/omti8621.cpp
+++ b/src/devices/bus/isa/omti8621.cpp
@@ -64,6 +64,8 @@ public:
virtual bool is_reset_on_load() const override { return 0; }
virtual bool support_command_line_image_creation() const override { return 1; }
virtual const char *file_extensions() const override { return "awd"; }
+ virtual const char *custom_instance_name() const override { return "disk"; }
+ virtual const char *custom_brief_instance_name() const override { return "disk"; }
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
protected:
@@ -1319,7 +1321,7 @@ omti_disk_image_device::omti_disk_image_device(const machine_config &mconfig, co
void omti_disk_image_device::device_config_complete()
{
- update_names(OMTI_DISK, "disk", "disk");
+ update_names();
}
diff --git a/src/devices/bus/isa/sc499.cpp b/src/devices/bus/isa/sc499.cpp
index bc5525a2809..f71c151233e 100644
--- a/src/devices/bus/isa/sc499.cpp
+++ b/src/devices/bus/isa/sc499.cpp
@@ -1311,7 +1311,7 @@ sc499_ctape_image_device::sc499_ctape_image_device(const machine_config &mconfig
void sc499_ctape_image_device::device_config_complete()
{
- update_names(SC499_CTAPE, "ctape", "ct");
+ update_names();
}
diff --git a/src/devices/bus/isa/sc499.h b/src/devices/bus/isa/sc499.h
index 727c8306cf9..833fd2a1308 100644
--- a/src/devices/bus/isa/sc499.h
+++ b/src/devices/bus/isa/sc499.h
@@ -43,6 +43,8 @@ public:
virtual bool support_command_line_image_creation() const override { return 1; }
virtual const char *image_interface() const override { return "sc499_cass"; }
virtual const char *file_extensions() const override { return "act,ct"; }
+ virtual const char *custom_instance_name() const override { return "ctape"; }
+ virtual const char *custom_brief_instance_name() const override { return "ct"; }
uint8_t *read_block(int block_num);
void write_block(int block_num, uint8_t *ptr);
diff --git a/src/devices/bus/msx_slot/cartridge.h b/src/devices/bus/msx_slot/cartridge.h
index b554eec833b..72cbcb805ac 100644
--- a/src/devices/bus/msx_slot/cartridge.h
+++ b/src/devices/bus/msx_slot/cartridge.h
@@ -39,7 +39,7 @@ public:
// device-level overrides
virtual void device_start() override;
- virtual void device_config_complete() override { update_names(MSX_SLOT_CARTRIDGE, "cartridge", "cart"); }
+ virtual void device_config_complete() override { update_names(); }
// image-level overrides
virtual image_init_result call_load() override;
@@ -53,6 +53,8 @@ public:
virtual bool is_reset_on_load() const override { return true; }
virtual const char *image_interface() const override { return "msx_cart"; }
virtual const char *file_extensions() const override { return "mx1,bin,rom"; }
+ virtual const char *custom_instance_name() const override { return "cartridge"; }
+ virtual const char *custom_brief_instance_name() const override { return "cart"; }
// slot interface overrides
virtual std::string get_default_card_software() override;
@@ -78,9 +80,10 @@ public:
msx_slot_yamaha_expansion_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual void device_start() override;
- virtual void device_config_complete() override { update_names(MSX_SLOT_YAMAHA_EXPANSION, "cartridge60pin", "cart60p"); }
virtual const char *image_interface() const override { return "msx_yamaha_60pin"; }
+ virtual const char *custom_instance_name() const override { return "cartridge60pin"; }
+ virtual const char *custom_brief_instance_name() const override { return "cart60p"; }
};
diff --git a/src/devices/bus/nubus/nubus_image.cpp b/src/devices/bus/nubus/nubus_image.cpp
index 12a16404dd0..b51feb31e97 100644
--- a/src/devices/bus/nubus/nubus_image.cpp
+++ b/src/devices/bus/nubus/nubus_image.cpp
@@ -45,6 +45,8 @@ public:
virtual bool must_be_loaded() const override { return 0; }
virtual bool is_reset_on_load() const override { return 0; }
virtual const char *file_extensions() const override { return "img"; }
+ virtual const char *custom_instance_name() const override { return "disk"; }
+ virtual const char *custom_brief_instance_name() const override { return "disk"; }
virtual image_init_result call_load() override;
virtual void call_unload() override;
@@ -72,7 +74,7 @@ messimg_disk_image_device::messimg_disk_image_device(const machine_config &mconf
void messimg_disk_image_device::device_config_complete()
{
- update_names(MESSIMG_DISK, "disk", "disk");
+ update_names();
}
diff --git a/src/devices/bus/nubus/nubus_image.h b/src/devices/bus/nubus/nubus_image.h
index db0fcf835b8..543ae8d3781 100644
--- a/src/devices/bus/nubus/nubus_image.h
+++ b/src/devices/bus/nubus/nubus_image.h
@@ -30,33 +30,33 @@ class nubus_image_device :
public device_nubus_card_interface
{
public:
- // construction/destruction
- nubus_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- nubus_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source);
+ // construction/destruction
+ nubus_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ nubus_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source);
- // optional information overrides
- virtual machine_config_constructor device_mconfig_additions() const override;
- virtual const tiny_rom_entry *device_rom_region() const override;
+ // optional information overrides
+ virtual machine_config_constructor device_mconfig_additions() const override;
+ virtual const tiny_rom_entry *device_rom_region() const override;
protected:
- // device-level overrides
- virtual void device_start() override;
- virtual void device_reset() override;
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_reset() override;
- DECLARE_READ32_MEMBER(image_status_r);
- DECLARE_WRITE32_MEMBER(image_status_w);
- DECLARE_READ32_MEMBER(image_r);
- DECLARE_WRITE32_MEMBER(image_w);
- DECLARE_READ32_MEMBER(image_super_r);
- DECLARE_WRITE32_MEMBER(image_super_w);
- DECLARE_READ32_MEMBER(file_cmd_r);
- DECLARE_WRITE32_MEMBER(file_cmd_w);
- DECLARE_READ32_MEMBER(file_data_r);
- DECLARE_WRITE32_MEMBER(file_data_w);
- DECLARE_READ32_MEMBER(file_len_r);
- DECLARE_WRITE32_MEMBER(file_len_w);
- DECLARE_READ32_MEMBER(file_name_r);
- DECLARE_WRITE32_MEMBER(file_name_w);
+ DECLARE_READ32_MEMBER(image_status_r);
+ DECLARE_WRITE32_MEMBER(image_status_w);
+ DECLARE_READ32_MEMBER(image_r);
+ DECLARE_WRITE32_MEMBER(image_w);
+ DECLARE_READ32_MEMBER(image_super_r);
+ DECLARE_WRITE32_MEMBER(image_super_w);
+ DECLARE_READ32_MEMBER(file_cmd_r);
+ DECLARE_WRITE32_MEMBER(file_cmd_w);
+ DECLARE_READ32_MEMBER(file_data_r);
+ DECLARE_WRITE32_MEMBER(file_data_w);
+ DECLARE_READ32_MEMBER(file_len_r);
+ DECLARE_WRITE32_MEMBER(file_len_w);
+ DECLARE_READ32_MEMBER(file_name_r);
+ DECLARE_WRITE32_MEMBER(file_name_w);
public:
messimg_disk_image_device *m_image;
diff --git a/src/devices/bus/psx/memcard.cpp b/src/devices/bus/psx/memcard.cpp
index 567cd615e65..a21cd6c2268 100644
--- a/src/devices/bus/psx/memcard.cpp
+++ b/src/devices/bus/psx/memcard.cpp
@@ -106,7 +106,7 @@ void psxcard_device::device_reset()
void psxcard_device::device_config_complete()
{
- update_names(PSXCARD, "memcard", "mc");
+ update_names();
}
//
diff --git a/src/devices/bus/sega8/sega8_slot.h b/src/devices/bus/sega8/sega8_slot.h
index 36181a547e7..440e27f8fa5 100644
--- a/src/devices/bus/sega8/sega8_slot.h
+++ b/src/devices/bus/sega8/sega8_slot.h
@@ -109,12 +109,14 @@ public:
// device-level overrides
virtual void device_start() override;
- virtual void device_config_complete() override { update_names(SEGA8_CART_SLOT, "cartridge", "cart"); }
+ virtual void device_config_complete() override { update_names(); }
// image-level overrides
virtual image_init_result call_load() override;
virtual void call_unload() override;
virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
+ virtual const char *custom_instance_name() const override { return "cartridge"; }
+ virtual const char *custom_brief_instance_name() const override { return "cart"; }
int get_type() { return m_type; }
int get_cart_type(uint8_t *ROM, uint32_t len);
@@ -166,7 +168,8 @@ public:
// construction/destruction
sega8_card_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void device_config_complete() override { update_names(SEGA8_CARD_SLOT, "card", "card"); }
+ virtual const char *custom_instance_name() const override { return "card"; }
+ virtual const char *custom_brief_instance_name() const override { return "card"; }
};
diff --git a/src/devices/imagedev/bitbngr.cpp b/src/devices/imagedev/bitbngr.cpp
index 40cd8f70306..2abc4b4d5cc 100644
--- a/src/devices/imagedev/bitbngr.cpp
+++ b/src/devices/imagedev/bitbngr.cpp
@@ -74,7 +74,7 @@ void bitbanger_device::device_start(void)
void bitbanger_device::device_config_complete(void)
{
- update_names(BITBANGER, "bitbngr", "bitb");
+ update_names();
}
diff --git a/src/devices/imagedev/bitbngr.h b/src/devices/imagedev/bitbngr.h
index 85992844859..76ec60ed116 100644
--- a/src/devices/imagedev/bitbngr.h
+++ b/src/devices/imagedev/bitbngr.h
@@ -32,6 +32,8 @@ public:
virtual bool is_reset_on_load() const override { return 0; }
virtual const char *image_interface() const override { return m_interface; }
virtual const char *file_extensions() const override { return ""; }
+ virtual const char *custom_instance_name() const override { return "bitbanger"; }
+ virtual const char *custom_brief_instance_name() const override { return "bitb"; }
void output(uint8_t data);
uint32_t input(void *buffer, uint32_t length);
diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp
index 591c57e2ec9..8cf72aff677 100644
--- a/src/emu/diimage.cpp
+++ b/src/emu/diimage.cpp
@@ -133,7 +133,7 @@ const image_device_type_info *device_image_interface::find_device_type(iodevice_
const char *device_image_interface::device_typename(iodevice_t type)
{
const image_device_type_info *info = find_device_type(type);
- return (info != nullptr) ? info->m_name : nullptr;
+ return (info != nullptr) ? info->m_name : "unknown";
}
//-------------------------------------------------
@@ -144,7 +144,7 @@ const char *device_image_interface::device_typename(iodevice_t type)
const char *device_image_interface::device_brieftypename(iodevice_t type)
{
const image_device_type_info *info = find_device_type(type);
- return (info != nullptr) ? info->m_shortname : nullptr;
+ return (info != nullptr) ? info->m_shortname : "unk";
}
//-------------------------------------------------
@@ -1301,7 +1301,7 @@ const util::option_guide &device_image_interface::create_option_guide() const
// update_names - update brief and instance names
//-------------------------------------------------
-void device_image_interface::update_names(const device_type device_type, const char *inst, const char *brief)
+void device_image_interface::update_names()
{
int count = 0;
int index = -1;
@@ -1309,11 +1309,17 @@ void device_image_interface::update_names(const device_type device_type, const c
{
if (this == &image)
index = count;
- if ((image.image_type() == image_type() && device_type == nullptr) || (device_type == image.device().type()))
+ if ((image.image_type() == image_type() && custom_instance_name() == nullptr) || (device().type() == image.device().type()))
count++;
}
- const char *inst_name = (device_type!=nullptr) ? inst : device_typename(image_type());
- const char *brief_name = (device_type!=nullptr) ? brief : device_brieftypename(image_type());
+
+ const char *inst_name = custom_instance_name();
+ const char *brief_name = custom_brief_instance_name();
+ if (inst_name == nullptr)
+ inst_name = device_typename(image_type());
+ if (brief_name == nullptr)
+ brief_name = device_brieftypename(image_type());
+
if (count > 1)
{
m_instance_name = string_format("%s%d", inst_name, index + 1);
@@ -1321,8 +1327,8 @@ void device_image_interface::update_names(const device_type device_type, const c
}
else
{
- m_instance_name = inst_name ? inst_name : "";
- m_brief_instance_name = brief_name ? brief_name : "";
+ m_instance_name = inst_name;
+ m_brief_instance_name = brief_name;
}
}
diff --git a/src/emu/diimage.h b/src/emu/diimage.h
index c41d3ad913a..020240bddc5 100644
--- a/src/emu/diimage.h
+++ b/src/emu/diimage.h
@@ -162,6 +162,8 @@ public:
virtual const char *image_interface() const { return nullptr; }
virtual const char *file_extensions() const = 0;
virtual const util::option_guide &create_option_guide() const;
+ virtual const char *custom_instance_name() const { return nullptr; }
+ virtual const char *custom_brief_instance_name() const { return nullptr; }
const image_device_format *device_get_indexed_creatable_format(int index) const { if (index < m_formatlist.size()) return m_formatlist.at(index).get(); else return nullptr; }
const image_device_format *device_get_named_creatable_format(const std::string &format_name);
@@ -272,7 +274,7 @@ protected:
void run_hash(void (*partialhash)(util::hash_collection &, const unsigned char *, unsigned long, const char *), util::hash_collection &hashes, const char *types);
void image_checkhash();
- void update_names(device_type device_type = nullptr, const char *inst = nullptr, const char *brief = nullptr);
+ void update_names();
const software_part *find_software_item(const std::string &identifier, bool restrict_to_interface, software_list_device **device = nullptr) const;
bool load_software_part(const std::string &identifier);
diff --git a/src/frontend/mame/mameopts.cpp b/src/frontend/mame/mameopts.cpp
index 9f489134b8d..30e3b92fa33 100644
--- a/src/frontend/mame/mameopts.cpp
+++ b/src/frontend/mame/mameopts.cpp
@@ -58,9 +58,7 @@ bool mame_options::add_slot_options(emu_options &options, std::function<void(emu
// allow opportunity to specify this value
if (value_specifier)
- {
value_specifier(options, name);
- }
}
}
return (options.options_count() != starting_count);
diff --git a/src/mame/includes/apollo.h b/src/mame/includes/apollo.h
index 4f44b57e066..db2b3c7cfaa 100644
--- a/src/mame/includes/apollo.h
+++ b/src/mame/includes/apollo.h
@@ -371,6 +371,8 @@ public:
virtual image_init_result call_load() override;
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
virtual void call_unload() override;
+ virtual const char *custom_instance_name() const override { return "node_id"; }
+ virtual const char *custom_brief_instance_name() const override { return "ni"; }
void set_node_id_from_disk();
diff --git a/src/mame/includes/hp48.h b/src/mame/includes/hp48.h
index d2b128d606f..28811422b7d 100644
--- a/src/mame/includes/hp48.h
+++ b/src/mame/includes/hp48.h
@@ -191,10 +191,13 @@ public:
virtual bool must_be_loaded() const override { return 0; }
virtual bool is_reset_on_load() const override { return 0; }
virtual const char *file_extensions() const override { return "crd"; }
+ virtual const char *custom_instance_name() const override { return "port"; }
+ virtual const char *custom_brief_instance_name() const override { return "p"; }
virtual image_init_result call_load() override;
virtual void call_unload() override;
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
+
protected:
// device-level overrides
virtual void device_config_complete() override;
diff --git a/src/mame/machine/apollo.cpp b/src/mame/machine/apollo.cpp
index 9bb870aab5a..ba5a27cf6bb 100644
--- a/src/mame/machine/apollo.cpp
+++ b/src/mame/machine/apollo.cpp
@@ -885,7 +885,7 @@ apollo_ni::~apollo_ni()
void apollo_ni::device_config_complete()
{
- update_names(APOLLO_NI, "node_id", "ni");
+ update_names();
}
//-------------------------------------------------
diff --git a/src/mame/machine/hp48.cpp b/src/mame/machine/hp48.cpp
index 8d205d50672..1a3580e4d10 100644
--- a/src/mame/machine/hp48.cpp
+++ b/src/mame/machine/hp48.cpp
@@ -1018,7 +1018,7 @@ hp48_port_image_device::hp48_port_image_device(const machine_config &mconfig, co
void hp48_port_image_device::device_config_complete()
{
- update_names(HP48_PORT, "port", "p");
+ update_names();
}
/***************************************************************************
diff --git a/src/mame/machine/x68k_hdc.cpp b/src/mame/machine/x68k_hdc.cpp
index aee064627cb..f85108f2ad8 100644
--- a/src/mame/machine/x68k_hdc.cpp
+++ b/src/mame/machine/x68k_hdc.cpp
@@ -32,7 +32,7 @@ x68k_hdc_image_device::x68k_hdc_image_device(const machine_config &mconfig, cons
void x68k_hdc_image_device::device_config_complete()
{
- update_names(X68KHDC, "sasihd", "sasi");
+ update_names();
}
void x68k_hdc_image_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
diff --git a/src/mame/machine/x68k_hdc.h b/src/mame/machine/x68k_hdc.h
index 0a4f5222531..e1f0abfb903 100644
--- a/src/mame/machine/x68k_hdc.h
+++ b/src/mame/machine/x68k_hdc.h
@@ -92,6 +92,8 @@ public:
virtual bool must_be_loaded() const override { return 0; }
virtual bool is_reset_on_load() const override { return 0; }
virtual const char *file_extensions() const override { return "hdf"; }
+ virtual const char *custom_instance_name() const override { return "sasihd"; }
+ virtual const char *custom_brief_instance_name() const override { return "sasi"; }
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
DECLARE_WRITE16_MEMBER( hdc_w );