From c071305f4d9127df985bad95fa5856eedfaac910 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 5 May 2021 05:27:04 +1000 Subject: emu/machine.cpp: Get rid of the dummy space device. --- src/emu/emumem.cpp | 2 -- src/emu/machine.cpp | 67 +++++-------------------------------------- src/emu/machine.h | 31 -------------------- src/mame/machine/midwayic.cpp | 18 ++++++++---- src/mame/machine/midwayic.h | 1 + 5 files changed, 21 insertions(+), 98 deletions(-) diff --git a/src/emu/emumem.cpp b/src/emu/emumem.cpp index 30e6141e3e9..efca8ea0c73 100644 --- a/src/emu/emumem.cpp +++ b/src/emu/emumem.cpp @@ -309,8 +309,6 @@ void memory_manager::initialize() allocate(memory); } - allocate(m_machine.m_dummy_space); - // construct and preprocess the address_map for each space for (auto const memory : memories) memory->prepare_maps(); diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index aecaf26ed15..5568bb48e85 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -133,14 +133,10 @@ running_machine::running_machine(const machine_config &_config, machine_manager m_memory(*this), m_ioport(*this), m_parameters(*this), - m_scheduler(*this), - m_dummy_space(_config, "dummy_space", &root_device(), 0) + m_scheduler(*this) { memset(&m_base_time, 0, sizeof(m_base_time)); - m_dummy_space.set_machine(*this); - m_dummy_space.config_complete(); - // set the machine on all devices device_enumerator iter(root_device()); for (device_t &device : iter) @@ -1037,11 +1033,9 @@ void running_machine::logfile_callback(const char *buffer) void running_machine::start_all_devices() { - m_dummy_space.start(); - // iterate through the devices int last_failed_starts = -1; - while (last_failed_starts != 0) + do { // iterate over all devices int failed_starts = 0; @@ -1052,29 +1046,27 @@ void running_machine::start_all_devices() try { // if the device doesn't have a machine yet, set it first - if (device.m_machine == nullptr) + if (!device.m_machine) device.set_machine(*this); // now start the device osd_printf_verbose("Starting %s '%s'\n", device.name(), device.tag()); device.start(); } - - // handle missing dependencies by moving the device to the end - catch (device_missing_dependencies &) + catch (device_missing_dependencies const &) { - // if we're the end, fail + // handle missing dependencies by moving the device to the end osd_printf_verbose(" (missing dependencies; rescheduling)\n"); failed_starts++; } } - // each iteration should reduce the number of failed starts; error if - // this doesn't happen + // each iteration should reduce the number of failed starts; error if this doesn't happen if (failed_starts == last_failed_starts) throw emu_fatalerror("Circular dependency in device startup!"); last_failed_starts = failed_starts; } + while (last_failed_starts); } @@ -1333,51 +1325,6 @@ void system_time::full_time::set(struct tm &t) -//************************************************************************** -// DUMMY ADDRESS SPACE -//************************************************************************** - -u8 dummy_space_device::read(offs_t offset) -{ - throw emu_fatalerror("Attempted to read from generic address space (offs %X)\n", offset); -} - -void dummy_space_device::write(offs_t offset, u8 data) -{ - throw emu_fatalerror("Attempted to write to generic address space (offs %X = %02X)\n", offset, data); -} - -void dummy_space_device::dummy(address_map &map) -{ - map(0x00000000, 0xffffffff).rw(FUNC(dummy_space_device::read), FUNC(dummy_space_device::write)); -} - -DEFINE_DEVICE_TYPE(DUMMY_SPACE, dummy_space_device, "dummy_space", "Dummy Space") - -dummy_space_device::dummy_space_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - device_t(mconfig, DUMMY_SPACE, tag, owner, clock), - device_memory_interface(mconfig, *this), - m_space_config("dummy", ENDIANNESS_LITTLE, 8, 32, 0, address_map_constructor(FUNC(dummy_space_device::dummy), this)) -{ -} - -void dummy_space_device::device_start() -{ -} - -//------------------------------------------------- -// memory_space_config - return a description of -// any address spaces owned by this device -//------------------------------------------------- - -device_memory_interface::space_config_vector dummy_space_device::memory_space_config() const -{ - return space_config_vector { - std::make_pair(0, &m_space_config) - }; -} - - //************************************************************************** // JAVASCRIPT PORT-SPECIFIC //************************************************************************** diff --git a/src/emu/machine.h b/src/emu/machine.h index 37a5702c72e..e7988010d89 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -109,33 +109,6 @@ public: -// ======================> dummy_space_device - -// a dummy address space for passing to handlers outside of the memory system - -class dummy_space_device : public device_t, - public device_memory_interface -{ -public: - dummy_space_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - - u8 read(offs_t offset); - void write(offs_t offset, u8 data); - - void dummy(address_map &map); -protected: - // device-level overrides - virtual void device_start() override; - - // device_memory_interface overrides - virtual space_config_vector memory_space_config() const override; - -private: - const address_space_config m_space_config; -}; - - - // ======================> running_machine typedef delegate machine_notify_delegate; @@ -248,7 +221,6 @@ public: void set_rtc_datetime(const system_time &systime); // misc - address_space &dummy_space() const { return m_dummy_space.space(AS_PROGRAM); } void popmessage() const { popmessage(static_cast(nullptr)); } template void popmessage(Format &&fmt, Params &&... args) const; template void logerror(Format &&fmt, Params &&... args) const; @@ -400,9 +372,6 @@ private: // string formatting buffer mutable util::ovectorstream m_string_buffer; - // configuration state - dummy_space_device m_dummy_space; - #if defined(__EMSCRIPTEN__) private: static running_machine *emscripten_running_machine; diff --git a/src/mame/machine/midwayic.cpp b/src/mame/machine/midwayic.cpp index 8045c6cb69c..9db6471d4d3 100644 --- a/src/mame/machine/midwayic.cpp +++ b/src/mame/machine/midwayic.cpp @@ -807,7 +807,7 @@ void midway_ioasic_device::ioasic_reset() void midway_ioasic_device::update_ioasic_irq() { - uint16_t fifo_state = fifo_status_r(machine().dummy_space()); + uint16_t fifo_state = get_fifo_status(); uint16_t irqbits = 0x2000; uint8_t new_state; @@ -908,7 +908,7 @@ uint16_t midway_ioasic_device::fifo_r() } -uint16_t midway_ioasic_device::fifo_status_r(address_space &space) +uint16_t midway_ioasic_device::get_fifo_status() { uint16_t result = 0; @@ -919,9 +919,17 @@ uint16_t midway_ioasic_device::fifo_status_r(address_space &space) if (m_fifo_bytes >= FIFO_SIZE || m_force_fifo_full) result |= 0x20; - /* kludge alert: if we're reading this from the DCS CPU itself, and we recently cleared */ - /* the FIFO, and we're within 16 instructions of the read that cleared the FIFO, make */ - /* sure the FIFO clear bit is set */ + return result; +} + + +uint16_t midway_ioasic_device::fifo_status_r(address_space &space) +{ + uint16_t result = get_fifo_status(); + + // kludge alert: if we're reading this from the DCS CPU itself, and we recently cleared + // the FIFO, and we're within 16 instructions of the read that cleared the FIFO, make + // sure the FIFO clear bit is set if (m_fifo_force_buffer_empty_pc && &space.device() == m_dcs_cpu) { offs_t currpc = m_dcs_cpu->pc(); diff --git a/src/mame/machine/midwayic.h b/src/mame/machine/midwayic.h index a10988714b0..a0979d99b36 100644 --- a/src/mame/machine/midwayic.h +++ b/src/mame/machine/midwayic.h @@ -195,6 +195,7 @@ protected: private: void ioasic_register_state(); void update_ioasic_irq(); + uint16_t get_fifo_status(); required_ioport m_io_dips; required_ioport m_io_system; -- cgit v1.2.3