diff options
Diffstat (limited to 'src/emu/driver.cpp')
-rw-r--r-- | src/emu/driver.cpp | 103 |
1 files changed, 38 insertions, 65 deletions
diff --git a/src/emu/driver.cpp b/src/emu/driver.cpp index 8dde7622da6..9b0dd9c5e59 100644 --- a/src/emu/driver.cpp +++ b/src/emu/driver.cpp @@ -2,7 +2,7 @@ // copyright-holders:Aaron Giles /*************************************************************************** - driver.c + driver.cpp Core driver device base class. @@ -24,10 +24,19 @@ driver_device::driver_device(const machine_config &mconfig, device_type type, const char *tag) : device_t(mconfig, type, tag, nullptr, 0) - , m_system(nullptr) + , m_system(mconfig.gamedrv()) , m_flip_screen_x(0) , m_flip_screen_y(0) { + // set the search path to include all parents and cache it because devices search system paths + m_searchpath.emplace_back(m_system.name); + std::set<game_driver const *> seen; + for (int ancestor = driver_list::clone(m_system); 0 <= ancestor; ancestor = driver_list::clone(ancestor)) + { + if (!seen.insert(&driver_list::driver(ancestor)).second) + throw emu_fatalerror("driver_device(%s): parent/clone relationships form a loop", m_system.name); + m_searchpath.emplace_back(driver_list::driver(ancestor).name); + } } @@ -41,37 +50,13 @@ driver_device::~driver_device() //------------------------------------------------- -// set_game_driver - set the game in the device -// configuration -//------------------------------------------------- - -void driver_device::set_game_driver(const game_driver &game) -{ - assert(!m_system); - - // set the system - m_system = &game; - - // and set the search path to include all parents - m_searchpath = game.name; - std::set<game_driver const *> seen; - for (int parent = driver_list::clone(game); parent != -1; parent = driver_list::clone(parent)) - { - if (!seen.insert(&driver_list::driver(parent)).second) - throw emu_fatalerror("driver_device::set_game_driver(%s): parent/clone relationships form a loop", game.name); - m_searchpath.append(";").append(driver_list::driver(parent).name); - } -} - - -//------------------------------------------------- // static_set_callback - set the a callback in // the device configuration //------------------------------------------------- void driver_device::static_set_callback(device_t &device, callback_type type, driver_callback_delegate callback) { - downcast<driver_device &>(device).m_callbacks[type] = callback; + downcast<driver_device &>(device).m_callbacks[type] = std::move(callback); } @@ -82,17 +67,16 @@ void driver_device::static_set_callback(device_t &device, callback_type type, dr void driver_device::empty_init() { - driver_init(); } //------------------------------------------------- -// driver_init - default implementation which -// does nothing +// searchpath - return cached search path //------------------------------------------------- -void driver_device::driver_init() +std::vector<std::string> driver_device::searchpath() const { + return m_searchpath; } @@ -183,8 +167,7 @@ void driver_device::video_reset() const tiny_rom_entry *driver_device::device_rom_region() const { - assert(m_system); - return m_system->rom; + return m_system.rom; } @@ -194,8 +177,7 @@ const tiny_rom_entry *driver_device::device_rom_region() const void driver_device::device_add_mconfig(machine_config &config) { - assert(m_system); - m_system->machine_creator(config, *this); + m_system.machine_creator(config, *this); } @@ -206,7 +188,7 @@ void driver_device::device_add_mconfig(machine_config &config) ioport_constructor driver_device::device_input_ports() const { - return m_system->ipt; + return m_system.ipt; } @@ -218,12 +200,12 @@ ioport_constructor driver_device::device_input_ports() const void driver_device::device_start() { // reschedule ourselves to be last - for (device_t &test : device_iterator(*this)) + for (device_t &test : device_enumerator(*this)) if (&test != this && !test.started()) throw device_missing_dependencies(); // call the game-specific init - m_system->driver_init(*this); + m_system.driver_init(*this); // finish image devices init process machine().image().postdevice_init(); @@ -236,10 +218,7 @@ void driver_device::device_start() else machine_start(); - if (!m_callbacks[CB_SOUND_START].isnull()) - m_callbacks[CB_SOUND_START](); - else - sound_start(); + sound_start(); if (!m_callbacks[CB_VIDEO_START].isnull()) m_callbacks[CB_VIDEO_START](); @@ -268,15 +247,9 @@ void driver_device::device_reset_after_children() else machine_reset(); - if (!m_callbacks[CB_SOUND_RESET].isnull()) - m_callbacks[CB_SOUND_RESET](); - else - sound_reset(); + sound_reset(); - if (!m_callbacks[CB_VIDEO_RESET].isnull()) - m_callbacks[CB_VIDEO_RESET](); - else - video_reset(); + video_reset(); } @@ -341,16 +314,16 @@ void driver_device::updateflip() // flip_screen_set - set global flip //------------------------------------------------- -void driver_device::flip_screen_set(u32 on) +void driver_device::flip_screen_set(int state) { // normalize to all 1 - if (on) - on = ~0; + if (state) + state = 0xff; // if something's changed, handle it - if (m_flip_screen_x != on || m_flip_screen_y != on) + if (m_flip_screen_x != state || m_flip_screen_y != state) { - m_flip_screen_x = m_flip_screen_y = on; + m_flip_screen_x = m_flip_screen_y = state; updateflip(); } } @@ -360,16 +333,16 @@ void driver_device::flip_screen_set(u32 on) // flip_screen_x_set - set global horizontal flip //------------------------------------------------- -void driver_device::flip_screen_x_set(u32 on) +void driver_device::flip_screen_x_set(int state) { // normalize to all 1 - if (on) - on = ~0; + if (state) + state = 0xff; // if something's changed, handle it - if (m_flip_screen_x != on) + if (m_flip_screen_x != state) { - m_flip_screen_x = on; + m_flip_screen_x = state; updateflip(); } } @@ -379,16 +352,16 @@ void driver_device::flip_screen_x_set(u32 on) // flip_screen_y_set - set global vertical flip //------------------------------------------------- -void driver_device::flip_screen_y_set(u32 on) +void driver_device::flip_screen_y_set(int state) { // normalize to all 1 - if (on) - on = ~0; + if (state) + state = 0xff; // if something's changed, handle it - if (m_flip_screen_y != on) + if (m_flip_screen_y != state) { - m_flip_screen_y = on; + m_flip_screen_y = state; updateflip(); } } |