diff options
author | Olivier Galibert <galibert@pobox.com> | 2018-02-13 10:53:20 +0100 |
---|---|---|
committer | Olivier Galibert <galibert@pobox.com> | 2018-02-13 10:55:23 +0100 |
commit | 5f215ff7d4100851fefc74bbfb8a2e89474a7fab (patch) | |
tree | 80c2a52520e3250015b47f7b98a0f39b8423b6f1 | |
parent | 3b421603ec3dcd85df4074cd9ad3dc75ac70f59f (diff) |
Fixes (nw)
-rw-r--r-- | src/devices/bus/isa/mcd.cpp | 2 | ||||
-rw-r--r-- | src/emu/devfind.h | 21 | ||||
-rw-r--r-- | src/emu/device.cpp | 58 | ||||
-rw-r--r-- | src/emu/device.h | 5 | ||||
-rw-r--r-- | src/emu/machine.cpp | 12 | ||||
-rw-r--r-- | src/emu/validity.cpp | 6 | ||||
-rw-r--r-- | src/mame/drivers/astrcorp.cpp | 3 |
7 files changed, 75 insertions, 32 deletions
diff --git a/src/devices/bus/isa/mcd.cpp b/src/devices/bus/isa/mcd.cpp index 7075d9e8f28..67bd1dc6c1c 100644 --- a/src/devices/bus/isa/mcd.cpp +++ b/src/devices/bus/isa/mcd.cpp @@ -51,7 +51,7 @@ void mcd_isa_device::device_start() cdrom_image_device::device_start(); set_isa_device(); m_isa->set_dma_channel(5, this, false); - m_isa->install_device(0x0310, 0x0311, *this, &mcd_isa_device::map, 16); + m_isa->install_device(0x0310, 0x0311, *this, &mcd_isa_device::map); } //------------------------------------------------- diff --git a/src/emu/devfind.h b/src/emu/devfind.h index 63efc179834..2ba7303239d 100644 --- a/src/emu/devfind.h +++ b/src/emu/devfind.h @@ -264,6 +264,17 @@ public: /// valid until resolution time. void set_tag(char const *tag) { m_tag = tag; } + /// \brief Is the object to be resolved before memory maps? + /// + /// Some objects must be resolved before memory maps are loaded + /// (devices for instance), some after (memory shares for + /// instance). + /// + /// \return True if the target object has to be resolved before + /// memory maps are loaded + + virtual bool is_pre_map() const { return false; } + /// \brief Dummy tag always treated as not found constexpr static char DUMMY_TAG[17] = "finder_dummy_tag"; @@ -460,6 +471,16 @@ public: /// remains valid until resolution time. device_finder(device_t &base, char const *tag) : object_finder_base<DeviceClass, Required>(base, tag) { } + /// \brief Is the object to be resolved before memory maps? + /// + /// Some objects must be resolved before memory maps are loaded + /// (devices for instance), some after (memory shares for + /// instance). + /// + /// \return True if the target object has to be resolved before + /// memory maps are loaded + virtual bool is_pre_map() const override { return true; } + private: /// \brief Find device /// diff --git a/src/emu/device.cpp b/src/emu/device.cpp index e03e09e8dac..4a2dd9c9081 100644 --- a/src/emu/device.cpp +++ b/src/emu/device.cpp @@ -422,52 +422,66 @@ void device_t::set_machine(running_machine &machine) // list and return status //------------------------------------------------- -bool device_t::findit(bool isvalidation) const +bool device_t::findit(bool pre_map, bool isvalidation) const { bool allfound = true; for (finder_base *autodev = m_auto_finder_list; autodev != nullptr; autodev = autodev->next()) - { - if (isvalidation) + if (autodev->is_pre_map() == pre_map) { - // sanity checking - const char *tag = autodev->finder_tag(); - if (tag == nullptr) - { - osd_printf_error("Finder tag is null!\n"); - allfound = false; - continue; - } - if (tag[0] == '^' && tag[1] == ':') + if (isvalidation) { - osd_printf_error("Malformed finder tag: %s\n", tag); - allfound = false; - continue; + // sanity checking + const char *tag = autodev->finder_tag(); + if (tag == nullptr) + { + osd_printf_error("Finder tag is null!\n"); + allfound = false; + continue; + } + if (tag[0] == '^' && tag[1] == ':') + { + osd_printf_error("Malformed finder tag: %s\n", tag); + allfound = false; + continue; + } } + allfound &= autodev->findit(isvalidation); } - allfound &= autodev->findit(isvalidation); - } return allfound; } //------------------------------------------------- -// resolve_objects - find objects referenced in -// configuration +// resolve_pre_map - find objects that may be used +// in memory maps //------------------------------------------------- -void device_t::resolve_objects() +void device_t::resolve_pre_map() { // prepare the logerror buffer if (m_machine->allow_logging()) m_string_buffer.reserve(1024); - // find all the registered devices - if (!findit(false)) + // find all the registered pre-map objects + if (!findit(true, false)) + throw emu_fatalerror("Missing some required devices, unable to proceed"); +} + +//------------------------------------------------- +// resolve_post_map - find objects that are created +// in memory maps +//------------------------------------------------- + +void device_t::resolve_post_map() +{ + // find all the registered post-map objects + if (!findit(false, false)) throw emu_fatalerror("Missing some required objects, unable to proceed"); // allow implementation to do additional setup device_resolve_objects(); } + //------------------------------------------------- // start - start a device //------------------------------------------------- diff --git a/src/emu/device.h b/src/emu/device.h index d385534cd00..b77d4877bc8 100644 --- a/src/emu/device.h +++ b/src/emu/device.h @@ -534,7 +534,7 @@ public: void set_default_bios(u8 bios) { m_default_bios = bios; } void set_system_bios(u8 bios) { m_system_bios = bios; } - bool findit(bool isvalidation = false) const; + bool findit(bool pre_map, bool isvalidation) const; // misc template <typename Format, typename... Params> void popmessage(Format &&fmt, Params &&... args) const; @@ -543,7 +543,8 @@ public: protected: // miscellaneous helpers void set_machine(running_machine &machine); - void resolve_objects(); + void resolve_pre_map(); + void resolve_post_map(); void start(); void stop(); void debug_setup(); diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 2fa926afb15..a1bd50bc3d1 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -223,6 +223,10 @@ void running_machine::start() // initialize the streams engine before the sound devices start m_sound = std::make_unique<sound_manager>(*this); + // resolve objects that can be used by memory maps + for (device_t &device : device_iterator(root_device())) + device.resolve_pre_map(); + // configure the address spaces, load ROMs (which needs // width/endianess of the spaces), then populate memory (which // needs rom bases), and finally initialize CPUs (which needs @@ -251,6 +255,10 @@ void running_machine::start() manager().create_custom(*this); + // resolve objects that are created by memory maps + for (device_t &device : device_iterator(root_device())) + device.resolve_post_map(); + // register callbacks for the devices, then start them add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&running_machine::reset_all_devices, this)); add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&running_machine::stop_all_devices, this)); @@ -1007,10 +1015,6 @@ void running_machine::logfile_callback(const char *buffer) void running_machine::start_all_devices() { - // resolve objects first to avoid messy start order dependencies - for (device_t &device : device_iterator(root_device())) - device.resolve_objects(); - m_dummy_space.start(); // iterate through the devices diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp index 2b6235f1a95..f88018fe59c 100644 --- a/src/emu/validity.cpp +++ b/src/emu/validity.cpp @@ -1919,7 +1919,8 @@ void validity_checker::validate_devices() m_current_device = &device; // validate auto-finders - device.findit(true); + device.findit(true, true); + device.findit(false, true); // validate the device tag validate_tag(device.basetag()); @@ -1979,7 +1980,8 @@ void validity_checker::validate_devices() for (device_t &card_dev : device_iterator(*card)) { m_current_device = &card_dev; - card_dev.findit(true); + card_dev.findit(true, true); + card_dev.findit(false, true); card_dev.validity_check(*this); m_current_device = nullptr; } diff --git a/src/mame/drivers/astrcorp.cpp b/src/mame/drivers/astrcorp.cpp index 23cb9090c0e..534341bac92 100644 --- a/src/mame/drivers/astrcorp.cpp +++ b/src/mame/drivers/astrcorp.cpp @@ -339,7 +339,8 @@ ADDRESS_MAP_START(astrocorp_state::showhanc_map) AM_RANGE( 0x08e000, 0x08e001 ) AM_READ_PORT("EEPROMIN") AM_RANGE( 0x090000, 0x093fff ) AM_RAM AM_SHARE("nvram") // battery AM_RANGE( 0x0a0000, 0x0a0001 ) AM_WRITE(astrocorp_screen_enable_w) - AM_RANGE( 0x0e0000, 0x0e0001 ) AM_READ(astrocorp_unk_r) AM_DEVWRITE8("oki", okim6295_device, write, 0xff00) + AM_RANGE( 0x0e0000, 0x0e0001 ) AM_READ(astrocorp_unk_r) + AM_RANGE( 0x0e0000, 0x0e0001 ) AM_DEVWRITE8("oki", okim6295_device, write, 0xff00) ADDRESS_MAP_END ADDRESS_MAP_START(astrocorp_state::skilldrp_map) |