diff options
author | 2017-04-02 18:57:02 -0400 | |
---|---|---|
committer | 2017-04-06 11:20:45 +1000 | |
commit | fbb7d927d3a58de18850ad3079621e0a78e5e6bd (patch) | |
tree | 81616193556f6466a00d2c05142d1ba89b9cc693 /src/emu/dislot.cpp | |
parent | 694a7812155927f89df046b585836ce872929e72 (diff) |
Refactoring in response to MT#6531
Prior to this change, options for images and slots were stored in the emu_options collection. Anything that might restart the emulation (such as slot changes and images that reset on load) had to manipulate the emu_options structure directly. The dynamic nature of images and slots meant that some elaborate conventions for setting up this collection had to be understood by clients.
After this change, emu_options has two new members (image_options and slot_options) that expose image and slot selections via an std::map. Anything that changes images or slots in a fashion that needs to persist across sessions needs to modify these data structures. Additionally, some of the hairly logic (e.g. - get_default_card_software) now records its data here rather than trying to subvert the core_options system.
This is how MT#6531 was fixed; now when diimage.cpp sees an image that resets on load, it just modifies the image_options structure and forces a reset. This allowed some further cleanups to happen within diimage.
This should be considered a very risky change, and scrutiny/feedback is welcome. In particular, there seems to be functionality surrounding device bioses that I'm not 100% sure how it works; the syntax seems to imply that it only works on slot devices.
Diffstat (limited to 'src/emu/dislot.cpp')
-rw-r--r-- | src/emu/dislot.cpp | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/src/emu/dislot.cpp b/src/emu/dislot.cpp index 7174293098c..9546884eccc 100644 --- a/src/emu/dislot.cpp +++ b/src/emu/dislot.cpp @@ -9,17 +9,32 @@ #include "emu.h" #include "emuopts.h" +// ------------------------------------------------- +// ctor +// ------------------------------------------------- + device_slot_interface::device_slot_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "slot"), m_default_option(nullptr), - m_fixed(false) + m_fixed(false), + m_card_device(nullptr) { } + +// ------------------------------------------------- +// dtor +// ------------------------------------------------- + device_slot_interface::~device_slot_interface() { } + +// ------------------------------------------------- +// device_slot_option ctor +// ------------------------------------------------- + device_slot_option::device_slot_option(const char *name, const device_type &devtype): m_name(name), m_devtype(devtype), @@ -31,6 +46,11 @@ device_slot_option::device_slot_option(const char *name, const device_type &devt { } + +// ------------------------------------------------- +// static_option_reset +// ------------------------------------------------- + void device_slot_interface::static_option_reset(device_t &device) { device_slot_interface &intf = dynamic_cast<device_slot_interface &>(device); @@ -38,6 +58,11 @@ void device_slot_interface::static_option_reset(device_t &device) intf.m_options.clear(); } + +// ------------------------------------------------- +// static_option_add +// ------------------------------------------------- + void device_slot_interface::static_option_add(device_t &device, const char *name, const device_type &devtype) { device_slot_interface &intf = dynamic_cast<device_slot_interface &>(device); @@ -49,6 +74,11 @@ void device_slot_interface::static_option_add(device_t &device, const char *name intf.m_options.emplace(std::make_pair(name, std::make_unique<device_slot_option>(name, devtype))); } + +// ------------------------------------------------- +// static_option +// ------------------------------------------------- + device_slot_option *device_slot_interface::static_option(device_t &device, const char *name) { device_slot_interface &intf = dynamic_cast<device_slot_interface &>(device); @@ -60,22 +90,10 @@ device_slot_option *device_slot_interface::static_option(device_t &device, const return option; } -device_t* device_slot_interface::get_card_device() -{ - std::string subtag; - device_t *dev = nullptr; - if (device().mconfig().options().exists(device().tag()+1)) - subtag = device().mconfig().options().main_value(device().tag()+1); - else if (m_default_option != nullptr) - subtag.assign(m_default_option); - if (!subtag.empty()) { - device_slot_card_interface *intf = nullptr; - dev = device().subdevice(subtag.c_str()); - if (dev!=nullptr && !dev->interface(intf)) - throw emu_fatalerror("get_card_device called for device '%s' with no slot card interface", dev->tag()); - } - return dev; -} + +// ------------------------------------------------- +// has_selectable_options +// ------------------------------------------------- bool device_slot_interface::has_selectable_options() const { @@ -89,6 +107,23 @@ bool device_slot_interface::has_selectable_options() const } +// ------------------------------------------------- +// option +// ------------------------------------------------- + +device_slot_option *device_slot_interface::option(const char *name) const +{ + device_slot_option *result = nullptr; + if (name) + { + auto search = m_options.find(name); + if (search != m_options.end()) + result = search->second.get(); + } + return result; +} + + device_slot_card_interface::device_slot_card_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "slot") { |