summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/dislot.h
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2013-12-16 19:31:52 +0000
committer smf- <smf-@users.noreply.github.com>2013-12-16 19:31:52 +0000
commitcc9b510f9c76edebb38e83e40439a5a75adeb2db (patch)
tree5a073dabf4d7e33e8860b4700169f767968f60c4 /src/emu/dislot.h
parent496c6d67229d0991594f5e4ff9a56d129eee18db (diff)
Slot options can now be configured inline without creating an array. Legacy support for old configuration uses MCFG_FRAGMENT_ADD, which required changing so the current device could be updated by the fragment. [smf]
Diffstat (limited to 'src/emu/dislot.h')
-rw-r--r--src/emu/dislot.h148
1 files changed, 89 insertions, 59 deletions
diff --git a/src/emu/dislot.h b/src/emu/dislot.h
index c947e2d60a4..159fa9ead43 100644
--- a/src/emu/dislot.h
+++ b/src/emu/dislot.h
@@ -9,68 +9,99 @@
#ifndef __DISLOT_H__
#define __DISLOT_H__
+//**************************************************************************
+// LEGACY MACROS
+//**************************************************************************
+
+#define MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_option, _fixed) MCFG_SLOT_OPTION_RESET MCFG_FRAGMENT_ADD(slot_options_##_slot_intf) MCFG_SLOT_DEFAULT_OPTION(_def_option) MCFG_SLOT_FIXED(_fixed)
+#define SLOT_INTERFACE_NAME(name) MACHINE_CONFIG_NAME(slot_options_##name)
+#define SLOT_INTERFACE_START(name) MACHINE_CONFIG_FRAGMENT(slot_options_##name)
+#define SLOT_INTERFACE(name,device) MCFG_SLOT_OPTION_ADD(name, device)
+#define SLOT_INTERFACE_INTERNAL(name,device) MCFG_SLOT_OPTION_ADD(name, device) MCFG_SLOT_OPTION_SELECTABLE(name, false)
+#define SLOT_INTERFACE_END MACHINE_CONFIG_END
+#define SLOT_INTERFACE_EXTERN(name) MACHINE_CONFIG_EXTERN(slot_options_##name)
+#define MCFG_DEVICE_CARD_DEFAULT_BIOS(_option, _default_bios) MCFG_SLOT_OPTION_DEFAULT_BIOS(_option, _default_bios)
+#define MCFG_DEVICE_CARD_MACHINE_CONFIG(_option, _machine_config_name) MCFG_SLOT_OPTION_MACHINE_CONFIG(_option, _machine_config_name)
+#define MCFG_DEVICE_CARD_DEVICE_INPUT_DEFAULTS(_option, _dev_inp_def) MCFG_SLOT_OPTION_DEVICE_INPUT_DEFAULTS(_option, _dev_inp_def)
+#define MCFG_DEVICE_CARD_CONFIG(_option, _config) MCFG_SLOT_OPTION_CONFIG(_option, _config)
+#define MCFG_DEVICE_CARD_CLOCK(_option, _clock) MCFG_SLOT_OPTION_CLOCK(_option, _clock)
+
//**************************************************************************
-// TYPE DEFINITIONS
+// MACROS
//**************************************************************************
-// ======================> device_slot_interface
-struct slot_interface
-{
- const char * name;
- const device_type & devtype;
- bool internal;
-};
+#define MCFG_SLOT_FIXED(_fixed) \
+ device_slot_interface::static_set_fixed(*device, _fixed);
+
+#define MCFG_SLOT_DEFAULT_OPTION(_option) \
+ device_slot_interface::static_set_default_option(*device, _option);
+
+#define MCFG_SLOT_OPTION_RESET \
+ device_slot_interface::static_option_reset(*device);
-#define MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_card, _fixed) \
- device_slot_interface::static_set_slot_info(*device, SLOT_INTERFACE_NAME(_slot_intf), _def_card, _fixed);
+#define MCFG_SLOT_OPTION_ADD(_option, _devtype) \
+ device_slot_interface::static_option_add(*device, _option, _devtype);
-#define MCFG_DEVICE_CARD_DEFAULT_BIOS(card, _default_bios) \
- device_slot_interface::static_set_card_default_bios(*device, card, _default_bios);
+#define MCFG_SLOT_OPTION_SELECTABLE(_option, _selectable) \
+ device_slot_interface::static_set_option_selectable(*device, _option, _selectable);
-#define MCFG_DEVICE_CARD_MACHINE_CONFIG(card, _machine_config_name) \
- device_slot_interface::static_set_card_machine_config(*device, card, MACHINE_CONFIG_NAME(_machine_config_name));
+#define MCFG_SLOT_OPTION_DEFAULT_BIOS(_option, _default_bios) \
+ device_slot_interface::static_set_option_default_bios(*device, _option, _default_bios);
-#define MCFG_DEVICE_CARD_DEVICE_INPUT_DEFAULTS(card, _dev_inp_def) \
- device_slot_interface::static_set_card_device_input_defaults(*device, card, DEVICE_INPUT_DEFAULTS_NAME(_dev_inp_def));
+#define MCFG_SLOT_OPTION_MACHINE_CONFIG(_option, _machine_config_name) \
+ device_slot_interface::static_set_option_machine_config(*device, _option, MACHINE_CONFIG_NAME(_machine_config_name));
-#define MCFG_DEVICE_CARD_CONFIG(card, _config) \
- device_slot_interface::static_set_card_config(*device, card, _config);
+#define MCFG_SLOT_OPTION_DEVICE_INPUT_DEFAULTS(_option, _dev_inp_def) \
+ device_slot_interface::static_set_option_device_input_defaults(*device, _option, DEVICE_INPUT_DEFAULTS_NAME(_dev_inp_def));
-#define MCFG_DEVICE_CARD_CLOCK(card, _clock) \
- device_slot_interface::static_set_card_clock(*device, card, _clock);
+#define MCFG_SLOT_OPTION_CONFIG(_option, _config) \
+ device_slot_interface::static_set_option_config(*device, _option, _config);
-#define SLOT_INTERFACE_NAME(name) slot_interface_##name
+#define MCFG_SLOT_OPTION_CLOCK(_option, _clock) \
+ device_slot_interface::static_set_option_clock(*device, _option, _clock);
-#define SLOT_INTERFACE_START(name) \
- const slot_interface slot_interface_##name[] = \
- {
-#define SLOT_INTERFACE(tag,device) \
- { tag, device, false },
-#define SLOT_INTERFACE_INTERNAL(tag,device) \
- { tag, device, true },
-#define SLOT_INTERFACE_END \
- { NULL, NULL, false } \
- };
-#define SLOT_INTERFACE_EXTERN(name) extern const slot_interface slot_interface_##name[]
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
-class device_card_options
+// ======================> device_slot_option
+
+class device_slot_option
{
friend class device_slot_interface;
- friend class simple_list<device_card_options>;
+ friend class simple_list<device_slot_option>;
+
+public:
+ device_slot_option(const char *name, const device_type &devtype);
+
+ device_slot_option *next() const { return m_next; }
+ const char *name() const { return m_name; }
+ const device_type &devtype() const { return m_devtype; }
+ const bool selectable() const { return m_selectable; }
+ const char *default_bios() const { return m_default_bios; }
+ machine_config_constructor machine_config() const { return m_machine_config; }
+ const input_device_default *input_device_defaults() const { return m_input_device_defaults; }
+ const void *static_config() const { return m_config; }
+ UINT32 clock() const { return m_clock; }
private:
+ // internal state
+ device_slot_option *m_next;
+ const char *m_name;
+ const device_type &m_devtype;
+ bool m_selectable;
const char *m_default_bios;
machine_config_constructor m_machine_config;
const input_device_default *m_input_device_defaults;
const void *m_config;
UINT32 m_clock;
-
- // internal state
- device_card_options * m_next; // link to the next reference
};
+
+// ======================> device_slot_interface
+
class device_slot_interface : public device_interface
{
public:
@@ -78,29 +109,28 @@ public:
device_slot_interface(const machine_config &mconfig, device_t &device);
virtual ~device_slot_interface();
- static void static_set_slot_info(device_t &device, const slot_interface *slots_info, const char *default_card,bool fixed);
- static device_card_options *static_alloc_card_options(device_t &device, const char *card);
- static void static_set_card_default_bios(device_t &device, const char *card, const char *default_bios);
- static void static_set_card_machine_config(device_t &device, const char *card, const machine_config_constructor machine_config);
- static void static_set_card_device_input_defaults(device_t &device, const char *card, const input_device_default *default_input);
- static void static_set_card_config(device_t &device, const char *card, const void *config);
- static void static_set_card_clock(device_t &device, const char *card, UINT32 default_clock);
- const slot_interface* get_slot_interfaces() const { return m_slot_interfaces; };
- const char * get_default_card() const { return m_default_card; };
- virtual const char * get_default_card_software(const machine_config &config, emu_options &options) { return NULL; };
- const char *card_default_bios(const char *card) const;
- const machine_config_constructor card_machine_config(const char *card) const;
- const input_device_default *card_input_device_defaults(const char *card) const;
- const void *card_config(const char *card) const;
- const UINT32 card_clock(const char *card) const;
+ static void static_set_fixed(device_t &device, bool fixed) { dynamic_cast<device_slot_interface &>(device).m_fixed = fixed; }
+ static void static_set_default_option(device_t &device, const char *option) { dynamic_cast<device_slot_interface &>(device).m_default_option = option; }
+ static void static_option_reset(device_t &device);
+ static void static_option_add(device_t &device, const char *option, const device_type &devtype);
+ static void static_set_option_selectable(device_t &device, const char *option, bool selectable){ static_option(device, option)->m_selectable = selectable; }
+ static void static_set_option_default_bios(device_t &device, const char *option, const char *default_bios) { static_option(device, option)->m_default_bios = default_bios; }
+ static void static_set_option_machine_config(device_t &device, const char *option, const machine_config_constructor machine_config) { static_option(device, option)->m_machine_config = machine_config; }
+ static void static_set_option_device_input_defaults(device_t &device, const char *option, const input_device_default *default_input) { static_option(device, option)->m_input_device_defaults = default_input; }
+ static void static_set_option_config(device_t &device, const char *option, const void *config) { static_option(device, option)->m_config = config; }
+ static void static_set_option_clock(device_t &device, const char *option, UINT32 default_clock) { static_option(device, option)->m_clock = default_clock; }
const bool fixed() const { return m_fixed; }
- const bool all_internal() const;
- bool is_internal_option(const char *option) const;
- device_t* get_card_device();
-protected:
- const slot_interface *m_slot_interfaces;
- const char *m_default_card;
- tagged_list<device_card_options> m_card_options;
+ const char *default_option() const { return m_default_option; }
+ device_slot_option *first_option() const { return m_options.first(); }
+ device_slot_option *option(const char *name) const { if (name) return m_options.find(name); return NULL; }
+ virtual const char *get_default_card_software(const machine_config &config, emu_options &options) { return NULL; }
+ device_t *get_card_device();
+
+private:
+ // internal state
+ static device_slot_option *static_option(device_t &device, const char *option);
+ tagged_list<device_slot_option> m_options;
+ const char *m_default_option;
bool m_fixed;
};