summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/mconfig.c
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2011-05-06 23:55:53 +0000
committer smf- <smf-@users.noreply.github.com>2011-05-06 23:55:53 +0000
commitd1b109625d83ccb7176129ff4311dbe5e7c587f4 (patch)
treee2ec65577044f7ad776094f7e429a22028f9bbd2 /src/emu/mconfig.c
parentedd7394ca88261e95a8532c4fccbdc5492642b1a (diff)
"You have taken your first step into a larger world." ―Obi-Wan Kenobi
Converted PlayStation DMA to an internal device to the CPU core. DMA to external devices can be set in the machine config, the old calls are still there until the rest of the code is converted. [smf] The following MAME core changes have been required to allow internal devices to be configurable by the main machine config & to work with internal memory maps. device.machine_config_additions() are now processed as soon as the device is added, so sub devices can be configured straight away. replacing or removing a device removes any devices owned by the device being removed, as now they are added straight away. device_t::subdevice() uses the machine config device list instead of the machine to find the device as the machine is not created until after all the devices have been created. devices in an internal address map are assumed to be owned by the CPU, while devices in a standard address maps are assumed to be siblings of the CPU. A code review and regression test would be a good idea.
Diffstat (limited to 'src/emu/mconfig.c')
-rw-r--r--src/emu/mconfig.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c
index 5b7e70ba07c..5e90a05b618 100644
--- a/src/emu/mconfig.c
+++ b/src/emu/mconfig.c
@@ -88,15 +88,6 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
throw emu_fatalerror("Machine configuration missing driver_device");
driver_device::static_set_game(*root, gamedrv);
- // process any device-specific machine configurations
- for (device_t *device = m_devicelist.first(); device != NULL; device = device->next())
- if (!device->configured())
- {
- machine_config_constructor additions = device->machine_config_additions();
- if (additions != NULL)
- (*additions)(*this, device);
- }
-
// then notify all devices that their configuration is complete
for (device_t *device = m_devicelist.first(); device != NULL; device = device->next())
if (!device->configured())
@@ -125,6 +116,43 @@ screen_device *machine_config::first_screen() const
//-------------------------------------------------
+// device_add_subdevices - helper to add
+// devices owned by the device
+//-------------------------------------------------
+
+void machine_config::device_add_subdevices(device_t *device)
+{
+ machine_config_constructor additions = device->machine_config_additions();
+ if (additions != NULL)
+ (*additions)(*this, device);
+}
+
+
+//-------------------------------------------------
+// device_remove_subdevices - helper to remove
+// devices owned by the device
+//-------------------------------------------------
+
+void machine_config::device_remove_subdevices(const device_t *device)
+{
+ if (device != NULL)
+ {
+ device_t *sub_device = m_devicelist.first();
+ while (sub_device != NULL)
+ {
+ device_t *next_device = sub_device->next();
+ if (sub_device->owner() == device)
+ {
+ device_remove_subdevices(sub_device);
+ m_devicelist.remove(sub_device->tag());
+ }
+ sub_device = next_device;
+ }
+ }
+}
+
+
+//-------------------------------------------------
// device_add - configuration helper to add a
// new device
//-------------------------------------------------
@@ -133,7 +161,9 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty
{
astring tempstring;
const char *fulltag = owner->subtag(tempstring, tag);
- return &m_devicelist.append(fulltag, *(*type)(*this, fulltag, owner, clock));
+ device_t *device = &m_devicelist.append(fulltag, *(*type)(*this, fulltag, owner, clock));
+ device_add_subdevices(device);
+ return device;
}
@@ -146,7 +176,10 @@ device_t *machine_config::device_replace(device_t *owner, const char *tag, devic
{
astring tempstring;
const char *fulltag = owner->subtag(tempstring, tag);
- return &m_devicelist.replace_and_remove(fulltag, *(*type)(*this, fulltag, owner, clock));
+ device_remove_subdevices(m_devicelist.find(fulltag));
+ device_t *device = &m_devicelist.replace_and_remove(fulltag, *(*type)(*this, fulltag, owner, clock));
+ device_add_subdevices(device);
+ return device;
}
@@ -159,6 +192,7 @@ device_t *machine_config::device_remove(device_t *owner, const char *tag)
{
astring tempstring;
const char *fulltag = owner->subtag(tempstring, tag);
+ device_remove_subdevices(m_devicelist.find(fulltag));
m_devicelist.remove(fulltag);
return NULL;
}