summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2018-04-28 16:34:09 +1000
committer Vas Crabb <vas@vastheman.com>2018-04-28 16:34:09 +1000
commitf2568bb918b8e551c1b95d4a86cf07ae192cbe80 (patch)
treefef1efb042ea6ccfcd24e7e39b988e0fea43b14f /src
parentbecec753bcb2c8c47c910034294e7cb31d3a7b53 (diff)
Make devopt menu localisable.
Make machine_config aware of device being configured so owner doesn't need to be passed everywhere.
Diffstat (limited to 'src')
-rw-r--r--src/emu/device.cpp13
-rw-r--r--src/emu/device.h4
-rw-r--r--src/emu/mconfig.cpp76
-rw-r--r--src/emu/mconfig.h65
-rw-r--r--src/emu/validity.cpp41
-rw-r--r--src/frontend/mame/clifront.cpp10
-rw-r--r--src/frontend/mame/info.cpp25
-rw-r--r--src/frontend/mame/media_ident.cpp5
-rw-r--r--src/frontend/mame/ui/devopt.cpp148
-rw-r--r--src/mame/audio/timeplt.cpp27
-rw-r--r--src/mame/audio/timeplt.h28
-rw-r--r--src/mame/drivers/pooyan.cpp1
-rw-r--r--src/mame/drivers/popeye.cpp2
-rw-r--r--src/mame/drivers/rallyx.cpp3
-rw-r--r--src/mame/drivers/rocnrope.cpp1
-rw-r--r--src/mame/drivers/timeplt.cpp1
-rw-r--r--src/mame/drivers/tranz330.cpp2
-rw-r--r--src/mame/drivers/tutankhm.cpp1
18 files changed, 278 insertions, 175 deletions
diff --git a/src/emu/device.cpp b/src/emu/device.cpp
index 7fa09a20974..a816067c535 100644
--- a/src/emu/device.cpp
+++ b/src/emu/device.cpp
@@ -208,6 +208,19 @@ std::string device_t::parameter(const char *tag) const
//-------------------------------------------------
+// add_machine_configuration - add device-
+// specific machine configuration
+//-------------------------------------------------
+
+void device_t::add_machine_configuration(machine_config &config)
+{
+ assert(&config == &m_machine_config);
+ machine_config::token const token(config.begin_configuration(*this));
+ device_add_mconfig(config);
+}
+
+
+//-------------------------------------------------
// set_clock - set/change the clock on
// a device
//-------------------------------------------------
diff --git a/src/emu/device.h b/src/emu/device.h
index 36e701eaa16..8ff57dcc83f 100644
--- a/src/emu/device.h
+++ b/src/emu/device.h
@@ -264,7 +264,7 @@ class device_type_impl : public device_type_impl_base
{
public:
using device_type_impl_base::device_type_impl_base;
- template <typename... Params> DeviceClass &operator()(machine_config &config, device_t *owner, char const *tag, Params &&... args) const;
+ template <typename... Params> DeviceClass &operator()(machine_config &config, char const *tag, Params &&... args) const;
};
@@ -514,7 +514,7 @@ public:
std::string parameter(const char *tag) const;
// configuration helpers
- void add_machine_configuration(machine_config &config) { device_add_mconfig(config); }
+ void add_machine_configuration(machine_config &config);
void set_clock(u32 clock);
void set_clock(const XTAL &xtal) { set_clock(xtal.value()); }
void set_input_default(const input_device_default *config) { m_input_defaults = config; }
diff --git a/src/emu/mconfig.cpp b/src/emu/mconfig.cpp
index c5ee4d92655..eef4a143969 100644
--- a/src/emu/mconfig.cpp
+++ b/src/emu/mconfig.cpp
@@ -19,18 +19,32 @@
// MACHINE CONFIGURATIONS
//**************************************************************************
+class machine_config::current_device_stack
+{
+public:
+ current_device_stack(current_device_stack const &) = delete;
+ current_device_stack(machine_config &host) : m_host(host), m_device(host.m_current_device) { m_host.m_current_device = nullptr; }
+ ~current_device_stack() { assert(!m_host.m_current_device); m_host.m_current_device = m_device; }
+private:
+ machine_config &m_host;
+ device_t *const m_device;
+};
+
+
//-------------------------------------------------
// machine_config - constructor
//-------------------------------------------------
machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
- : m_minimum_quantum(attotime::zero),
- m_default_layout(nullptr),
- m_gamedrv(gamedrv),
- m_options(options)
+ : m_minimum_quantum(attotime::zero)
+ , m_default_layout(nullptr)
+ , m_gamedrv(gamedrv)
+ , m_options(options)
+ , m_root_device()
+ , m_current_device(nullptr)
{
// add the root device
- device_add(nullptr, "root", gamedrv.type, 0);
+ device_add("root", gamedrv.type, 0);
// intialize slot devices - make sure that any required devices have been allocated
for (device_slot_interface &slot : slot_interface_iterator(root_device()))
@@ -63,7 +77,8 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
if (option && (is_default || option->selectable()))
{
// create the device
- device_t *new_dev = device_add(&owner, option->name(), option->devtype(), option->clock());
+ token const tok(begin_configuration(owner));
+ device_t *const new_dev = device_add(option->name(), option->devtype(), option->clock());
slot.set_card_device(new_dev);
char const *const default_bios = option->default_bios();
@@ -104,9 +119,11 @@ machine_config::~machine_config()
// new device
//-------------------------------------------------
-device_t *machine_config::device_add(device_t *owner, const char *tag, device_type type, u32 clock)
+device_t *machine_config::device_add(const char *tag, device_type type, u32 clock)
{
+ assert(bool(m_current_device) == bool(m_root_device));
char const *const orig_tag = tag;
+ device_t *owner(m_current_device);
// if the device path is absolute, start from the root
if (tag[0] == ':')
@@ -128,6 +145,7 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty
}
assert(tag[0] != '\0');
+ current_device_stack context(*this);
if (owner)
{
// allocate the new device and append it to the owner's list
@@ -154,38 +172,39 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty
// replace one device with a new device
//-------------------------------------------------
-device_t *machine_config::device_replace(device_t *owner, const char *tag, device_type type, u32 clock)
+device_t *machine_config::device_replace(const char *tag, device_type type, u32 clock)
{
// find the original device by relative tag (must exist)
- assert(owner != nullptr);
- device_t *old_device = owner->subdevice(tag);
- if (old_device == nullptr)
+ assert(m_current_device);
+ device_t *old_device = m_current_device->subdevice(tag);
+ if (!old_device)
{
osd_printf_warning("Warning: attempting to replace non-existent device '%s'\n", tag);
- return device_add(owner, tag, type, clock);
+ return device_add(tag, type, clock);
}
else
{
// make sure we have the old device's actual owner
- owner = old_device->owner();
- assert(owner != nullptr);
+ device_t *const owner = old_device->owner();
+ assert(owner);
// remove references to the old device
remove_references(*old_device);
// allocate the new device and substitute it for the old one in the owner's list
device_t *const new_device = &owner->subdevices().m_list.replace_and_remove(*type(*this, tag, owner, clock).release(), *old_device);
+ current_device_stack context(*this);
new_device->add_machine_configuration(*this);
return new_device;
}
}
-device_t *machine_config::device_replace(device_t *owner, const char *tag, device_type type, const XTAL &clock)
+device_t *machine_config::device_replace(const char *tag, device_type type, const XTAL &clock)
{
std::string msg = std::string("Replacing device ") + tag;
clock.validate(msg);
- return device_replace(owner, tag, type, clock.value());
+ return device_replace(tag, type, clock.value());
}
@@ -194,26 +213,27 @@ device_t *machine_config::device_replace(device_t *owner, const char *tag, devic
// remove a device
//-------------------------------------------------
-device_t *machine_config::device_remove(device_t *owner, const char *tag)
+device_t *machine_config::device_remove(const char *tag)
{
// find the original device by relative tag (must exist)
- assert(owner != nullptr);
- device_t *device = owner->subdevice(tag);
+ assert(m_current_device);
+ device_t *const device = m_current_device->subdevice(tag);
if (device == nullptr)
{
osd_printf_warning("Warning: attempting to remove non-existent device '%s'\n", tag);
- return nullptr;
}
+ else
+ {
+ // make sure we have the old device's actual owner
+ device_t *const owner = device->owner();
+ assert(owner);
- // make sure we have the old device's actual owner
- owner = device->owner();
- assert(owner != nullptr);
-
- // remove references to the old device
- remove_references(*device);
+ // remove references to the old device
+ remove_references(*device);
- // let the device's owner do the work
- owner->subdevices().m_list.remove(*device);
+ // let the device's owner do the work
+ owner->subdevices().m_list.remove(*device);
+ }
return nullptr;
}
diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h
index 03a35fb4773..317acc91309 100644
--- a/src/emu/mconfig.h
+++ b/src/emu/mconfig.h
@@ -48,6 +48,34 @@ class machine_config
friend class running_machine;
public:
+ class token
+ {
+ public:
+ token(machine_config &host, device_t &device) : m_host(host), m_device(&device)
+ {
+ assert(m_device == m_host.m_current_device);
+ }
+ token(token &&that) : m_host(that.m_host), m_device(that.m_device)
+ {
+ that.m_device = nullptr;
+ assert(!m_device || (m_device == m_host.m_current_device));
+ }
+ token(token const &) = delete;
+ token &operator=(token &&) = delete;
+ token &operator=(token const &) = delete;
+ ~token()
+ {
+ if (m_device)
+ {
+ assert(m_device == m_host.m_current_device);
+ m_host.m_current_device = nullptr;
+ }
+ }
+ private:
+ machine_config &m_host;
+ device_t *m_device;
+ };
+
// construction/destruction
machine_config(const game_driver &gamedrv, emu_options &options);
~machine_config();
@@ -67,35 +95,44 @@ public:
const internal_layout * m_default_layout; // default layout for this machine
// helpers during configuration; not for general use
- device_t *device_add(device_t *owner, const char *tag, device_type type, u32 clock);
+ token begin_configuration(device_t &device)
+ {
+ assert(!m_current_device);
+ m_current_device = &device;
+ return token(*this, device);
+ }
+ device_t *device_add(const char *tag, device_type type, u32 clock);
template <typename... Params>
- device_t *device_add(device_t *owner, const char *tag, device_type type, const XTAL &clock, Params &&... args)
+ device_t *device_add(const char *tag, device_type type, const XTAL &clock, Params &&... args)
{
clock.validate(std::string("Instantiating device ") + tag);
- return device_add(owner, tag, type, clock.value(), std::forward<Params>(args)...);
+ return device_add(tag, type, clock.value(), std::forward<Params>(args)...);
}
- device_t *device_replace(device_t *owner, const char *tag, device_type type, u32 clock);
- device_t *device_replace(device_t *owner, const char *tag, device_type type, const XTAL &xtal);
- device_t *device_remove(device_t *owner, const char *tag);
+ device_t *device_replace(const char *tag, device_type type, u32 clock);
+ device_t *device_replace(const char *tag, device_type type, const XTAL &xtal);
+ device_t *device_remove(const char *tag);
device_t *device_find(device_t *owner, const char *tag);
private:
+ class current_device_stack;
+
// internal helpers
void remove_references(ATTR_UNUSED device_t &device);
// internal state
- const game_driver & m_gamedrv;
- emu_options & m_options;
- std::unique_ptr<device_t> m_root_device;
+ game_driver const & m_gamedrv;
+ emu_options & m_options;
+ std::unique_ptr<device_t> m_root_device;
+ device_t * m_current_device;
};
namespace emu { namespace detail {
template <class DeviceClass> template <typename... Params>
-DeviceClass &device_type_impl<DeviceClass>::operator()(machine_config &config, device_t *owner, char const *tag, Params &&... args) const
+DeviceClass &device_type_impl<DeviceClass>::operator()(machine_config &config, char const *tag, Params &&... args) const
{
- return dynamic_cast<DeviceClass &>(*config.device_add(owner, tag, *this, std::forward<Params>(args)...));
+ return dynamic_cast<DeviceClass &>(*config.device_add(tag, *this, std::forward<Params>(args)...));
}
} } // namespace emu::detail
@@ -143,11 +180,11 @@ Ends a machine_config.
// add/remove devices
#define MCFG_DEVICE_ADD(_tag, _type, _clock) \
- device = config.device_add(this, _tag, _type, _clock);
+ device = config.device_add(_tag, _type, _clock);
#define MCFG_DEVICE_REPLACE(_tag, _type, _clock) \
- device = config.device_replace(this, _tag, _type, _clock);
+ device = config.device_replace(_tag, _type, _clock);
#define MCFG_DEVICE_REMOVE(_tag) \
- device = config.device_remove(this, _tag);
+ device = config.device_remove(_tag);
#define MCFG_DEVICE_MODIFY(_tag) \
device = config.device_find(this, _tag);
diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp
index b16426a3675..456cd5656b0 100644
--- a/src/emu/validity.cpp
+++ b/src/emu/validity.cpp
@@ -1963,7 +1963,7 @@ void validity_checker::validate_devices()
// if it's a slot, iterate over possible cards (don't recurse, or you'll stack infinite tee connectors)
device_slot_interface *const slot = dynamic_cast<device_slot_interface *>(&device);
- if (slot != nullptr && !slot->fixed() && !duplicate)
+ if (slot && !slot->fixed() && !duplicate)
{
for (auto &option : slot->option_list())
{
@@ -1971,14 +1971,18 @@ void validity_checker::validate_devices()
if (slot->default_option() != nullptr && option.first == slot->default_option())
continue;
- device_t *const card = m_current_config->device_add(&slot->device(), option.second->name(), option.second->devtype(), option.second->clock());
-
- const char *const def_bios = option.second->default_bios();
- if (def_bios)
- card->set_default_bios_tag(def_bios);
- auto additions = option.second->machine_config();
- if (additions)
- additions(card);
+ device_t *card;
+ {
+ machine_config::token const tok(m_current_config->begin_configuration(slot->device()));
+ card = m_current_config->device_add(option.second->name(), option.second->devtype(), option.second->clock());
+
+ const char *const def_bios = option.second->default_bios();
+ if (def_bios)
+ card->set_default_bios_tag(def_bios);
+ auto additions = option.second->machine_config();
+ if (additions)
+ additions(card);
+ }
for (device_slot_interface &subslot : slot_interface_iterator(*card))
{
@@ -1987,7 +1991,8 @@ void validity_checker::validate_devices()
device_slot_option const *const suboption = subslot.option(subslot.default_option());
if (suboption)
{
- device_t *const sub_card = m_current_config->device_add(&subslot.device(), suboption->name(), suboption->devtype(), suboption->clock());
+ machine_config::token const tok(m_current_config->begin_configuration(subslot.device()));
+ device_t *const sub_card = m_current_config->device_add(suboption->name(), suboption->devtype(), suboption->clock());
const char *const sub_bios = suboption->default_bios();
if (sub_bios)
sub_card->set_default_bios_tag(sub_bios);
@@ -2011,7 +2016,8 @@ void validity_checker::validate_devices()
m_current_device = nullptr;
}
- m_current_config->device_remove(&slot->device(), option.second->name());
+ machine_config::token const tok(m_current_config->begin_configuration(slot->device()));
+ m_current_config->device_remove(option.second->name());
}
}
}
@@ -2034,9 +2040,10 @@ void validity_checker::validate_device_types()
std::unordered_map<std::string, std::add_pointer_t<device_type> > device_name_map, device_shortname_map;
machine_config config(GAME_NAME(___empty), m_drivlist.options());
+ machine_config::token const tok(config.begin_configuration(config.root_device()));
for (device_type type : registered_device_types)
{
- device_t *const dev = config.device_add(&config.root_device(), "_tmp", type, 0);
+ device_t *const dev = config.device_add("_tmp", type, 0);
char const *name((dev->shortname() && *dev->shortname()) ? dev->shortname() : type.type().name());
std::string const description((dev->source() && *dev->source()) ? util::string_format("%s(%s)", core_filename_extract_base(dev->source()).c_str(), name) : name);
@@ -2073,9 +2080,9 @@ void validity_checker::validate_device_types()
}
else if (!devname.second)
{
- device_t *const dup = config.device_add(&config.root_device(), "_dup", *devname.first->second, 0);
+ device_t *const dup = config.device_add("_dup", *devname.first->second, 0);
osd_printf_error("Device %s short name is a duplicate of %s(%s)\n", description.c_str(), core_filename_extract_base(dup->source()).c_str(), dup->shortname());
- config.device_remove(&config.root_device(), "_dup");
+ config.device_remove("_dup");
}
}
@@ -2097,9 +2104,9 @@ void validity_checker::validate_device_types()
}
else if (!devdesc.second)
{
- device_t *const dup = config.device_add(&config.root_device(), "_dup", *devdesc.first->second, 0);
+ device_t *const dup = config.device_add("_dup", *devdesc.first->second, 0);
osd_printf_error("Device %s name '%s' is a duplicate of %s(%s)\n", description.c_str(), dev->name(), core_filename_extract_base(dup->source()).c_str(), dup->shortname());
- config.device_remove(&config.root_device(), "_dup");
+ config.device_remove("_dup");
}
}
@@ -2121,7 +2128,7 @@ void validity_checker::validate_device_types()
if (unemulated & imperfect)
osd_printf_error("Device cannot have features that are both unemulated and imperfect (0x%08lX)\n", static_cast<unsigned long>(unemulated & imperfect));
- config.device_remove(&config.root_device(), "_tmp");
+ config.device_remove("_tmp");
}
// if we had warnings or errors, output
diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp
index 8cfd8875393..937d07b5ab6 100644
--- a/src/frontend/mame/clifront.cpp
+++ b/src/frontend/mame/clifront.cpp
@@ -679,13 +679,14 @@ void cli_frontend::listroms(const std::vector<std::string> &args)
if (iswild || first)
{
machine_config config(GAME_NAME(___empty), m_options);
+ machine_config::token const tok(config.begin_configuration(config.root_device()));
for (device_type type : registered_device_types)
{
if (included(type.shortname()))
{
- device_t *const dev = config.device_add(&config.root_device(), "_tmp", type, 0);
+ device_t *const dev = config.device_add("_tmp", type, 0);
list_system_roms(*dev, "device");
- config.device_remove(&config.root_device(), "_tmp");
+ config.device_remove("_tmp");
// if it wasn't a wildcard, there can only be one
if (!iswild)
@@ -1017,12 +1018,13 @@ void cli_frontend::verifyroms(const std::vector<std::string> &args)
if (iswild || !matchcount)
{
machine_config config(GAME_NAME(___empty), m_options);
+ machine_config::token const tok(config.begin_configuration(config.root_device()));
for (device_type type : registered_device_types)
{
if (included(type.shortname()))
{
// audit the ROMs in this set
- device_t *const dev = config.device_add(&config.root_device(), "_tmp", type, 0);
+ device_t *const dev = config.device_add("_tmp", type, 0);
media_auditor::summary summary = auditor.audit_device(*dev, AUDIT_VALIDATE_FAST);
print_summary(
@@ -1030,7 +1032,7 @@ void cli_frontend::verifyroms(const std::vector<std::string> &args)
"rom", dev->shortname(), nullptr,
correct, incorrect, notfound,
summary_string);
- config.device_remove(&config.root_device(), "_tmp");
+ config.device_remove("_tmp");
// if it wasn't a wildcard, there can only be one
if (!iswild)
diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp
index 38135aa2c05..d3e7e36cfb1 100644
--- a/src/frontend/mame/info.cpp
+++ b/src/frontend/mame/info.cpp
@@ -563,15 +563,8 @@ void info_xml_creator::output_one_device(machine_config &config, device_t &devic
//-------------------------------------------------
-// output_devices - print the XML info for devices
-// with roms and for devices that can be mounted
-// in slots
-// The current solution works to some extent, but
-// it is limited by the fact that devices are only
-// acknowledged when attached to a driver (so that
-// for instance sub-sub-devices could never appear
-// in the xml input if they are not also attached
-// directly to a driver as device or sub-device)
+// output_devices - print the XML info for
+// registered device types
//-------------------------------------------------
void info_xml_creator::output_devices(device_type_set const *filter)
@@ -582,7 +575,11 @@ void info_xml_creator::output_devices(device_type_set const *filter)
auto const action = [this, &config] (device_type type)
{
// add it at the root of the machine config
- device_t *const dev = config.device_add(&config.root_device(), "_tmp", type, 0);
+ device_t *dev;
+ {
+ machine_config::token const tok(config.begin_configuration(config.root_device()));
+ dev = config.device_add("_tmp", type, 0);
+ }
// notify this device and all its subdevices that they are now configured
for (device_t &device : device_iterator(*dev))
@@ -591,7 +588,8 @@ void info_xml_creator::output_devices(device_type_set const *filter)
// print details and remove it
output_one_device(config, *dev, dev->tag());
- config.device_remove(&config.root_device(), "_tmp");
+ machine_config::token const tok(config.begin_configuration(config.root_device()));
+ config.device_remove("_tmp");
};
// run through devices
@@ -1756,6 +1754,7 @@ void info_xml_creator::output_slots(machine_config &config, device_t &device, co
if (devtypes || listed)
{
+ machine_config::token const tok(config.begin_configuration(slot.device()));
std::string newtag(slot.device().tag()), oldtag(":");
newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());
@@ -1767,7 +1766,7 @@ void info_xml_creator::output_slots(machine_config &config, device_t &device, co
{
if (devtypes || (listed && option.second->selectable()))
{
- device_t *const dev = config.device_add(&slot.device(), "_dummy", option.second->devtype(), option.second->clock());
+ device_t *const dev = config.device_add("_dummy", option.second->devtype(), option.second->clock());
if (!dev->configured())
dev->config_complete();
@@ -1783,7 +1782,7 @@ void info_xml_creator::output_slots(machine_config &config, device_t &device, co
fprintf(m_output, "/>\n");
}
- config.device_remove(&slot.device(), "_dummy");
+ config.device_remove("_dummy");
}
}
diff --git a/src/frontend/mame/media_ident.cpp b/src/frontend/mame/media_ident.cpp
index 277ef2bc959..d15bee95dae 100644
--- a/src/frontend/mame/media_ident.cpp
+++ b/src/frontend/mame/media_ident.cpp
@@ -382,10 +382,11 @@ void media_identifier::match_hashes(std::vector<file_info> &info)
// iterator over devices
machine_config config(GAME_NAME(___empty), m_drivlist.options());
+ machine_config::token const tok(config.begin_configuration(config.root_device()));
for (device_type type : registered_device_types)
{
// iterate over regions and files within the region
- device_t *const device = config.device_add(&config.root_device(), "_tmp", type, 0);
+ device_t *const device = config.device_add("_tmp", type, 0);
for (romload::region const &region : romload::entries(device->rom_region()).get_regions())
{
for (romload::file const &rom : region.get_files())
@@ -398,7 +399,7 @@ void media_identifier::match_hashes(std::vector<file_info> &info)
}
}
}
- config.device_remove(&config.root_device(), "_tmp");
+ config.device_remove("_tmp");
}
}
diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp
index 71ccb6d9a40..32b860f3eba 100644
--- a/src/frontend/mame/ui/devopt.cpp
+++ b/src/frontend/mame/ui/devopt.cpp
@@ -28,25 +28,24 @@ menu_device_config::menu_device_config(mame_ui_manager &mui, render_container &c
void menu_device_config::populate(float &customtop, float &custombottom)
{
- std::ostringstream str;
- device_t *dev;
-
- util::stream_format(str, "[This option is%s currently mounted in the running system]\n\n", m_mounted ? "" : " NOT");
- util::stream_format(str, "Option: %s\n", m_option->name());
+ machine_config &mconfig(const_cast<machine_config &>(machine().config()));
+ machine_config::token const tok(mconfig.begin_configuration(mconfig.root_device()));
+ device_t *const dev = mconfig.device_add(m_option->name(), m_option->devtype(), 0);
- dev = const_cast<machine_config &>(machine().config()).device_add(&machine().config().root_device(), m_option->name(), m_option->devtype(), 0);
-
- util::stream_format(str, "Device: %s\n", dev->name());
- if (!m_mounted)
- str << "\nIf you select this option, the following items will be enabled:\n";
- else
- str << "\nThe selected option enables the following items:\n";
+ std::ostringstream str;
+ util::stream_format(
+ str,
+ m_mounted
+ ? _("[This option is currently mounted in the running system]\n\nOption: %1$s\nDevice: %1$s\n\nThe selected option enables the following items:\n")
+ : _("[This option is NOT currently mounted in the running system]\n\nOption: %1$s\nDevice: %1$s\n\nIf you select this option, the following items will be enabled:\n"),
+ m_option->name(),
+ dev->name());
// loop over all CPUs
execute_interface_iterator execiter(*dev);
if (execiter.count() > 0)
{
- str << "* CPU:\n";
+ str << _("* CPU:\n");
std::unordered_set<std::string> exectags;
for (device_execute_interface &exec : execiter)
{
@@ -66,18 +65,16 @@ void menu_device_config::populate(float &customtop, float &custombottom)
count++;
}
- // if more than one, prepend a #x in front of the CPU name
- if (count > 1)
- util::stream_format(str, " %d" UTF8_MULTIPLY, count);
- else
- str << " ";
- str << name;
-
- // display clock in kHz or MHz
- if (clock >= 1000000)
- util::stream_format(str, " %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
- else
- util::stream_format(str, " %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
+ // if more than one, prepend a #x in front of the CPU name and display clock in kHz or MHz
+ util::stream_format(
+ str,
+ (count > 1)
+ ? ((clock >= 1000000) ? _(" %1$d\xC3\x97%2$s %3$d.%4$06d\xC2\xA0MHz\n") : _(" %1$d\xC3\x97%2$s %5$d.%6$03d\xC2\xA0kHz\n"))
+ : ((clock >= 1000000) ? _(" %2$s %3$d.%4$06d\xC2\xA0MHz\n") : _(" %2$s %5$d.%6$03d\xC2\xA0kHz\n")),
+ count,
+ name,
+ clock / 1000000, clock % 1000000,
+ clock / 1000, clock % 1000);
}
}
@@ -85,21 +82,26 @@ void menu_device_config::populate(float &customtop, float &custombottom)
screen_device_iterator scriter(*dev);
if (scriter.count() > 0)
{
- str << "* Video:\n";
+ str << _("* Video:\n");
for (screen_device &screen : scriter)
{
- util::stream_format(str, " Screen '%s': ", screen.tag());
-
if (screen.screen_type() == SCREEN_TYPE_VECTOR)
- str << "Vector\n";
+ {
+ util::stream_format(str, _(" Screen '%1$s': Vector\n"), screen.tag());
+ }
else
{
const rectangle &visarea = screen.visible_area();
- util::stream_format(str, "%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n",
- visarea.width(), visarea.height(),
- (machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",
- ATTOSECONDS_TO_HZ(screen.frame_period().attoseconds()));
+ util::stream_format(
+ str,
+ (machine().system().flags & ORIENTATION_SWAP_XY)
+ ? _(" Screen '%1$s': %2$d \xC3\x97 %3$d (V) %4$f\xC2\xA0Hz\n")
+ : _(" Screen '%1$s': %2$d \xC3\x97 %3$d (H) %4$f\xC2\xA0Hz\n"),
+ screen.tag(),
+ visarea.width(),
+ visarea.height(),
+ ATTOSECONDS_TO_HZ(screen.frame_period().attoseconds()));
}
}
}
@@ -108,7 +110,7 @@ void menu_device_config::populate(float &customtop, float &custombottom)
sound_interface_iterator snditer(*dev);
if (snditer.count() > 0)
{
- str << "* Sound:\n";
+ str << _("* Sound:\n");
std::unordered_set<std::string> soundtags;
for (device_sound_interface &sound : snditer)
{
@@ -123,21 +125,17 @@ void menu_device_config::populate(float &customtop, float &custombottom)
if (soundtags.insert(scan.device().tag()).second)
count++;
}
- // if more than one, prepend a #x in front of the CPU name
- if (count > 1)
- util::stream_format(str," %d" UTF8_MULTIPLY, count);
- else
- str << " ";
- str << sound.device().name();
-
- // display clock in kHz or MHz
- int clock = sound.device().clock();
- if (clock >= 1000000)
- util::stream_format(str," %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000);
- else if (clock != 0)
- util::stream_format(str," %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000);
- else
- str << '\n';
+ // if more than one, prepend a #x in front of the name and display clock in kHz or MHz
+ int const clock = sound.device().clock();
+ util::stream_format(
+ str,
+ (count > 1)
+ ? ((clock >= 1000000) ? _(" %1$d\xC3\x97%2$s %3$d.%4$06d\xC2\xA0MHz\n") : clock ? _(" %1$d\xC3\x97%2$s %5$d.%6$03d\xC2\xA0kHz\n") : _(" %1$d\xC3\x97%2$s\n"))
+ : ((clock >= 1000000) ? _(" %2$s %3$d.%4$06d\xC2\xA0MHz\n") : clock ? _(" %2$s %5$d.%6$03d\xC2\xA0kHz\n") : _(" %2$s\n")),
+ count,
+ sound.device().name(),
+ clock / 1000000, clock % 1000000,
+ clock / 1000, clock % 1000);
}
}
@@ -163,7 +161,7 @@ void menu_device_config::populate(float &customtop, float &custombottom)
}
if (bios)
- util::stream_format(str, "* BIOS settings:\n %d options [default: %s]\n", bios, bios_desc ? bios_desc : bios_str ? bios_str : "");
+ util::stream_format(str, _("* BIOS settings:\n %1$d options [default: %2$s]\n"), bios, bios_desc ? bios_desc : bios_str ? bios_str : "");
}
int input = 0, input_mj = 0, input_hana = 0, input_gamble = 0, input_analog = 0, input_adjust = 0;
@@ -197,75 +195,81 @@ void menu_device_config::populate(float &customtop, float &custombottom)
else if (field.type() == IPT_DIPSWITCH)
{
dips++;
- dips_opt << " " << field.name();
+ bool def(false);
for (ioport_setting &setting : field.settings())
{
if (setting.value() == field.defvalue())
{
- util::stream_format(dips_opt, " [default: %s]\n", setting.name());
+ def = true;
+ util::stream_format(dips_opt, _(" %1$s [default: %2$s]\n"), field.name(), setting.name());
break;
}
}
+ if (!def)
+ util::stream_format(dips_opt, _(" %1$s\n"), field.name());
}
else if (field.type() == IPT_CONFIG)
{
confs++;
- confs_opt << " " << field.name();
+ bool def(false);
for (ioport_setting &setting : field.settings())
{
if (setting.value() == field.defvalue())
{
- util::stream_format(confs_opt, " [default: %s]\n", setting.name());
+ def = true;
+ util::stream_format(confs_opt, _(" %1$s [default: %2$s]\n"), field.name(), setting.name());
break;
}
}
+ if (!def)
+ util::stream_format(confs_opt, _(" %1$s\n"), field.name());
}
}
if (dips)
- str << "* Dispwitch settings:\n" << dips_opt.str();
+ str << _("* DIP switch settings:\n") << dips_opt.str();
if (confs)
- str << "* Configuration settings:\n" << confs_opt.str();
- if (input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard)
- str << "* Input device(s):\n";
+ str << _("* Configuration settings:\n") << confs_opt.str();
+ if (input || input_mj || input_hana || input_gamble || input_analog || input_adjust || input_keypad || input_keyboard)
+ str << _("* Input device(s):\n");
if (input)
- util::stream_format(str, " User inputs [%d inputs]\n", input);
+ util::stream_format(str, _(" User inputs [%1$d inputs]\n"), input);
if (input_mj)
- util::stream_format(str, " Mahjong inputs [%d inputs]\n", input_mj);
+ util::stream_format(str, _(" Mahjong inputs [%1$d inputs]\n"), input_mj);
if (input_hana)
- util::stream_format(str, " Hanafuda inputs [%d inputs]\n", input_hana);
+ util::stream_format(str, _(" Hanafuda inputs [%1$d inputs]\n"), input_hana);
if (input_gamble)
- util::stream_format(str, " Gambling inputs [%d inputs]\n", input_gamble);
+ util::stream_format(str, _(" Gambling inputs [%1$d inputs]\n"), input_gamble);
if (input_analog)
- util::stream_format(str, " Analog inputs [%d inputs]\n", input_analog);
+ util::stream_format(str, _(" Analog inputs [%1$d inputs]\n"), input_analog);
if (input_adjust)
- util::stream_format(str, " Adjuster inputs [%d inputs]\n", input_adjust);
+ util::stream_format(str, _(" Adjuster inputs [%1$d inputs]\n"), input_adjust);
if (input_keypad)
- util::stream_format(str, " Keypad inputs [%d inputs]\n", input_keypad);
+ util::stream_format(str, _(" Keypad inputs [%1$d inputs]\n"), input_keypad);
if (input_keyboard)
- util::stream_format(str, " Keyboard inputs [%d inputs]\n", input_keyboard);
+ util::stream_format(str, _(" Keyboard inputs [%1$d inputs]\n"), input_keyboard);
image_interface_iterator imgiter(*dev);
if (imgiter.count() > 0)
{
- str << "* Media Options:\n";
+ str << _("* Media Options:\n");
for (const device_image_interface &imagedev : imgiter)
- util::stream_format(str, " %s [tag: %s]\n", imagedev.image_type_name(), imagedev.device().tag());
+ util::stream_format(str, _(" %1$s [tag: %2$s]\n"), imagedev.image_type_name(), imagedev.device().tag());
}
slot_interface_iterator slotiter(*dev);
if (slotiter.count() > 0)
{
- str << "* Slot Options:\n";
+ str << _("* Slot Options:\n");
for (const device_slot_interface &slot : slotiter)
- util::stream_format(str, " %s [default: %s]\n", slot.device().tag(), slot.default_option() ? slot.default_option() : "----");
+ util::stream_format(str, _(" %1$s [default: %2$s]\n"), slot.device().tag(), slot.default_option() ? slot.default_option() : "----");
}
if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + bios + dips + confs
+ input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) == 0)
- str << "[None]\n";
+ str << _("[None]\n");
- const_cast<machine_config &>(machine().config()).device_remove(&machine().config().root_device(), m_option->name());
+ mconfig.device_remove(m_option->name());
item_append(str.str(), "", FLAG_MULTILINE, nullptr);
}
diff --git a/src/mame/audio/timeplt.cpp b/src/mame/audio/timeplt.cpp
index 8662021e5e6..ec44bc0c4a4 100644
--- a/src/mame/audio/timeplt.cpp
+++ b/src/mame/audio/timeplt.cpp
@@ -20,13 +20,24 @@
#include "speaker.h"
-#define MASTER_CLOCK XTAL(14'318'181)
+static constexpr XTAL MASTER_CLOCK(14'318'181);
DEFINE_DEVICE_TYPE(TIMEPLT_AUDIO, timeplt_audio_device, "timplt_audio", "Time Pilot Audio")
+DEFINE_DEVICE_TYPE(LOCOMOTN_AUDIO, locomotn_audio_device, "locomotn_audio", "Loco-Motion Audio")
timeplt_audio_device::timeplt_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, TIMEPLT_AUDIO, tag, owner, clock)
+ : timeplt_audio_device(mconfig, TIMEPLT_AUDIO, tag, owner, clock)
+{
+}
+
+locomotn_audio_device::locomotn_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : timeplt_audio_device(mconfig, LOCOMOTN_AUDIO, tag, owner, clock)
+{
+}
+
+timeplt_audio_device::timeplt_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, type, tag, owner, clock)
, device_sound_interface(mconfig, *this)
, m_soundcpu(*this, "tpsound")
, m_soundlatch(*this, "soundlatch")
@@ -163,11 +174,11 @@ void timeplt_audio_device::timeplt_sound_map(address_map &map)
}
-void timeplt_audio_device::locomotn_sound_map(address_map &map)
+void locomotn_audio_device::locomotn_sound_map(address_map &map)
{
map(0x0000, 0x1fff).rom();
map(0x2000, 0x23ff).mirror(0x0c00).ram();
- map(0x3000, 0x3fff).w(this, FUNC(timeplt_audio_device::filter_w));
+ map(0x3000, 0x3fff).w(this, FUNC(locomotn_audio_device::filter_w));
map(0x4000, 0x4000).mirror(0x0fff).rw("ay1", FUNC(ay8910_device::data_r), FUNC(ay8910_device::data_w));
map(0x5000, 0x5000).mirror(0x0fff).w("ay1", FUNC(ay8910_device::address_w));
map(0x6000, 0x6000).mirror(0x0fff).rw("ay2", FUNC(ay8910_device::data_r), FUNC(ay8910_device::data_w));
@@ -181,10 +192,10 @@ void timeplt_audio_device::locomotn_sound_map(address_map &map)
*
*************************************/
-MACHINE_CONFIG_START(timeplt_audio_device::timeplt_sound)
+MACHINE_CONFIG_START(timeplt_audio_device::device_add_mconfig)
/* basic machine hardware */
- MCFG_CPU_ADD("tpsound",Z80,MASTER_CLOCK/8)
+ MCFG_CPU_ADD("tpsound", Z80, MASTER_CLOCK/8)
MCFG_CPU_PROGRAM_MAP(timeplt_sound_map)
/* sound hardware */
@@ -220,8 +231,8 @@ MACHINE_CONFIG_START(timeplt_audio_device::timeplt_sound)
MACHINE_CONFIG_END
-MACHINE_CONFIG_START(timeplt_audio_device::locomotn_sound)
- timeplt_sound(config);
+MACHINE_CONFIG_START(locomotn_audio_device::device_add_mconfig)
+ timeplt_audio_device::device_add_mconfig(config);
/* basic machine hardware */
MCFG_CPU_MODIFY("tpsound")
diff --git a/src/mame/audio/timeplt.h b/src/mame/audio/timeplt.h
index 329a703c1c8..ca63eeb6942 100644
--- a/src/mame/audio/timeplt.h
+++ b/src/mame/audio/timeplt.h
@@ -18,21 +18,22 @@ public:
DECLARE_WRITE8_MEMBER(sound_data_w);
DECLARE_WRITE_LINE_MEMBER(sh_irqtrigger_w);
DECLARE_WRITE_LINE_MEMBER(mute_w);
- DECLARE_WRITE8_MEMBER(filter_w);
- DECLARE_READ8_MEMBER(portB_r);
-
- void timeplt_sound(machine_config &config);
- void locomotn_sound(machine_config &config);
- void locomotn_sound_map(address_map &map);
- void timeplt_sound_map(address_map &map);
protected:
+ timeplt_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
// device-level overrides
+ virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
+ DECLARE_WRITE8_MEMBER(filter_w);
+ DECLARE_READ8_MEMBER(portB_r);
+
+ void timeplt_sound_map(address_map &map);
+
private:
// internal state
required_device<cpu_device> m_soundcpu;
@@ -45,6 +46,19 @@ private:
void filter_w(filter_rc_device &device, int data);
};
+class locomotn_audio_device : public timeplt_audio_device
+{
+public:
+ locomotn_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+protected:
+ // device-level overrides
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ void locomotn_sound_map(address_map &map);
+};
+
DECLARE_DEVICE_TYPE(TIMEPLT_AUDIO, timeplt_audio_device)
+DECLARE_DEVICE_TYPE(LOCOMOTN_AUDIO, locomotn_audio_device)
#endif // MAME_AUDIO_TIMEPLT_H
diff --git a/src/mame/drivers/pooyan.cpp b/src/mame/drivers/pooyan.cpp
index 8d289b4538c..f41073c7cd5 100644
--- a/src/mame/drivers/pooyan.cpp
+++ b/src/mame/drivers/pooyan.cpp
@@ -227,7 +227,6 @@ MACHINE_CONFIG_START(pooyan_state::pooyan)
/* sound hardware */
MCFG_SOUND_ADD("timeplt_audio", TIMEPLT_AUDIO, 0)
- downcast<timeplt_audio_device *>(device)->timeplt_sound(config);
MACHINE_CONFIG_END
diff --git a/src/mame/drivers/popeye.cpp b/src/mame/drivers/popeye.cpp
index 6d8fa3f1c53..5ff43821de9 100644
--- a/src/mame/drivers/popeye.cpp
+++ b/src/mame/drivers/popeye.cpp
@@ -310,7 +310,7 @@ public:
virtual void config(machine_config &config) override
{
T::config(config);
- config.device_add(this, "eeprom", EEPROM_SERIAL_93C46_8BIT, 0);
+ config.device_add("eeprom", EEPROM_SERIAL_93C46_8BIT, 0);
}
protected:
diff --git a/src/mame/drivers/rallyx.cpp b/src/mame/drivers/rallyx.cpp
index 649a6ce9e1f..12f7b9bbaf2 100644
--- a/src/mame/drivers/rallyx.cpp
+++ b/src/mame/drivers/rallyx.cpp
@@ -918,8 +918,7 @@ MACHINE_CONFIG_START(rallyx_state::jungler)
MCFG_VIDEO_START_OVERRIDE(rallyx_state,jungler)
/* sound hardware */
- MCFG_SOUND_ADD("timeplt_audio", TIMEPLT_AUDIO, 0)
- downcast<timeplt_audio_device *>(device)->locomotn_sound(config);
+ MCFG_SOUND_ADD("timeplt_audio", LOCOMOTN_AUDIO, 0)
MACHINE_CONFIG_END
diff --git a/src/mame/drivers/rocnrope.cpp b/src/mame/drivers/rocnrope.cpp
index 08081b9bf94..d4683225f34 100644
--- a/src/mame/drivers/rocnrope.cpp
+++ b/src/mame/drivers/rocnrope.cpp
@@ -240,7 +240,6 @@ MACHINE_CONFIG_START(rocnrope_state::rocnrope)
/* sound hardware */
MCFG_SOUND_ADD("timeplt_audio", TIMEPLT_AUDIO, 0)
- downcast<timeplt_audio_device *>(device)->timeplt_sound(config);
MACHINE_CONFIG_END
/*************************************
diff --git a/src/mame/drivers/timeplt.cpp b/src/mame/drivers/timeplt.cpp
index 00b5f3c72da..531fc85ae01 100644
--- a/src/mame/drivers/timeplt.cpp
+++ b/src/mame/drivers/timeplt.cpp
@@ -460,7 +460,6 @@ MACHINE_CONFIG_START(timeplt_state::timeplt)
/* sound hardware */
MCFG_SOUND_ADD("timeplt_audio", TIMEPLT_AUDIO, 0)
- downcast<timeplt_audio_device *>(device)->timeplt_sound(config);
MACHINE_CONFIG_END
diff --git a/src/mame/drivers/tranz330.cpp b/src/mame/drivers/tranz330.cpp
index 168bf0712cb..49f19d6ff5d 100644
--- a/src/mame/drivers/tranz330.cpp
+++ b/src/mame/drivers/tranz330.cpp
@@ -140,7 +140,7 @@ static const z80_daisy_config tranz330_daisy_chain[] =
// * - check clocks
// ? - check purported RS232 hookup, inconsistent information found at the relevant webpage vs. user-submitted errata
MACHINE_CONFIG_START(tranz330_state::tranz330)
- z80_device &cpu = Z80(config, this, CPU_TAG, XTAL(7'159'090)/2); //*
+ z80_device &cpu = Z80(config, CPU_TAG, XTAL(7'159'090)/2); //*
cpu.set_addrmap(AS_PROGRAM, address_map_constructor(&tranz330_state::tranz330_mem, tag(), this));
cpu.set_addrmap(AS_IO, address_map_constructor(&tranz330_state::tranz330_io, tag(), this));
cpu.set_daisy_config(tranz330_daisy_chain);
diff --git a/src/mame/drivers/tutankhm.cpp b/src/mame/drivers/tutankhm.cpp
index f42de2e554e..7a55db6252a 100644
--- a/src/mame/drivers/tutankhm.cpp
+++ b/src/mame/drivers/tutankhm.cpp
@@ -262,7 +262,6 @@ MACHINE_CONFIG_START(tutankhm_state::tutankhm)
/* sound hardware */
MCFG_SOUND_ADD("timeplt_audio", TIMEPLT_AUDIO, 0)
- downcast<timeplt_audio_device *>(device)->timeplt_sound(config);
MACHINE_CONFIG_END