mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
Moved device_memory_interface from driver_device to dummy_space_device. Exposed the dummy_space_device as machine().dummy_space(), with a trampoline in driver_device for existing callers. Debugger no longer needs to special case root_device() to avoid showing the dummy address space. [smf]
This commit is contained in:
parent
093609dc0c
commit
e125186e15
@ -137,14 +137,13 @@ void debug_view_memory::enumerate_sources()
|
||||
|
||||
// first add all the devices' address spaces
|
||||
for (device_memory_interface &memintf : memory_interface_iterator(machine().root_device()))
|
||||
if (&memintf.device() != &machine().root_device())
|
||||
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
|
||||
if (memintf.has_space(spacenum))
|
||||
{
|
||||
address_space &space = memintf.space(spacenum);
|
||||
name = string_format("%s '%s' %s space memory", memintf.device().name(), memintf.device().tag(), space.name());
|
||||
m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), space)));
|
||||
}
|
||||
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
|
||||
if (memintf.has_space(spacenum))
|
||||
{
|
||||
address_space &space = memintf.space(spacenum);
|
||||
name = string_format("%s '%s' %s space memory", memintf.device().name(), memintf.device().tag(), space.name());
|
||||
m_source_list.append(*global_alloc(debug_view_memory_source(name.c_str(), space)));
|
||||
}
|
||||
|
||||
// then add all the memory regions
|
||||
for (auto ®ion : machine().memory().regions())
|
||||
|
@ -13,17 +13,6 @@
|
||||
#include "drivenum.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// ADDRESS_MAPS
|
||||
//**************************************************************************
|
||||
|
||||
// default address map
|
||||
static ADDRESS_MAP_START( generic, AS_0, 8, driver_device )
|
||||
AM_RANGE(0x00000000, 0xffffffff) AM_DEVREADWRITE(":", driver_device, fatal_generic_read, fatal_generic_write)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DRIVER DEVICE
|
||||
//**************************************************************************
|
||||
@ -34,8 +23,6 @@ ADDRESS_MAP_END
|
||||
|
||||
driver_device::driver_device(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: device_t(mconfig, type, "Driver Device", tag, nullptr, 0, "", __FILE__),
|
||||
device_memory_interface(mconfig, *this),
|
||||
m_space_config("generic", ENDIANNESS_LITTLE, 8, 32, 0, nullptr, *ADDRESS_MAP_NAME(generic)),
|
||||
m_system(nullptr),
|
||||
m_flip_screen_x(0),
|
||||
m_flip_screen_y(0)
|
||||
@ -261,17 +248,6 @@ void driver_device::device_reset_after_children()
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// memory_space_config - return a description of
|
||||
// any address spaces owned by this device
|
||||
//-------------------------------------------------
|
||||
|
||||
const address_space_config *driver_device::memory_space_config(address_spacenum spacenum) const
|
||||
{
|
||||
return (spacenum == 0) ? &m_space_config : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERRUPT ENABLE AND VECTOR HELPERS
|
||||
@ -476,22 +452,3 @@ CUSTOM_INPUT_MEMBER(driver_device::custom_port_read)
|
||||
const char *tag = (const char *)param;
|
||||
return ioport(tag)->read();
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MISC READ/WRITE HANDLERS
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// generic space fatal error handlers
|
||||
//-------------------------------------------------
|
||||
|
||||
READ8_MEMBER( driver_device::fatal_generic_read )
|
||||
{
|
||||
throw emu_fatalerror("Attempted to read from generic address space (offs %X)\n", offset);
|
||||
}
|
||||
|
||||
WRITE8_MEMBER( driver_device::fatal_generic_write )
|
||||
{
|
||||
throw emu_fatalerror("Attempted to write to generic address space (offs %X = %02X)\n", offset, data);
|
||||
}
|
||||
|
@ -97,8 +97,7 @@ typedef delegate<void ()> driver_callback_delegate;
|
||||
// ======================> driver_device
|
||||
|
||||
// base class for machine driver-specific devices
|
||||
class driver_device : public device_t,
|
||||
public device_memory_interface
|
||||
class driver_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
@ -135,7 +134,7 @@ public:
|
||||
void init_0() { }
|
||||
|
||||
// memory helpers
|
||||
address_space &generic_space() const { return space(AS_PROGRAM); }
|
||||
address_space &generic_space() const { return machine().dummy_space(); }
|
||||
|
||||
// output heler
|
||||
output_manager &output() const { return machine().output(); }
|
||||
@ -192,10 +191,6 @@ public:
|
||||
// generic input port helpers
|
||||
DECLARE_CUSTOM_INPUT_MEMBER( custom_port_read );
|
||||
|
||||
// general fatal error handlers
|
||||
DECLARE_READ8_MEMBER( fatal_generic_read );
|
||||
DECLARE_WRITE8_MEMBER( fatal_generic_write );
|
||||
|
||||
protected:
|
||||
// helpers called at startup
|
||||
virtual void driver_start();
|
||||
@ -215,16 +210,11 @@ protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset_after_children() override;
|
||||
|
||||
// device_memory_interface overrides
|
||||
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override;
|
||||
private:
|
||||
// helpers
|
||||
void irq_pulse_clear(void *ptr, int32_t param);
|
||||
void updateflip();
|
||||
|
||||
// configuration state
|
||||
const address_space_config m_space_config;
|
||||
|
||||
// internal state
|
||||
const game_driver * m_system; // pointer to the game driver
|
||||
driver_callback_delegate m_callbacks[CB_COUNT]; // start/reset callbacks
|
||||
|
@ -1553,6 +1553,20 @@ memory_manager::memory_manager(running_machine &machine)
|
||||
memset(m_bank_ptr, 0, sizeof(m_bank_ptr));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// allocate - allocate memory spaces
|
||||
//-------------------------------------------------
|
||||
|
||||
void memory_manager::allocate(device_memory_interface &memory)
|
||||
{
|
||||
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
|
||||
{
|
||||
// if there is a configuration for this space, we need an address space
|
||||
const address_space_config *spaceconfig = memory.space_config(spacenum);
|
||||
if (spaceconfig != nullptr)
|
||||
address_space::allocate(m_spacelist, *this, *spaceconfig, memory, spacenum);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// initialize - initialize the memory system
|
||||
@ -1563,13 +1577,9 @@ void memory_manager::initialize()
|
||||
// loop over devices and spaces within each device
|
||||
memory_interface_iterator iter(machine().root_device());
|
||||
for (device_memory_interface &memory : iter)
|
||||
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
|
||||
{
|
||||
// if there is a configuration for this space, we need an address space
|
||||
const address_space_config *spaceconfig = memory.space_config(spacenum);
|
||||
if (spaceconfig != nullptr)
|
||||
address_space::allocate(m_spacelist,*this, *spaceconfig, memory, spacenum);
|
||||
}
|
||||
allocate(memory);
|
||||
|
||||
allocate(m_machine.m_dummy_space);
|
||||
|
||||
// construct and preprocess the address_map for each space
|
||||
for (auto &space : m_spacelist)
|
||||
|
@ -734,6 +734,7 @@ public:
|
||||
private:
|
||||
// internal helpers
|
||||
void bank_reattach();
|
||||
void allocate(device_memory_interface &memory);
|
||||
|
||||
// internal state
|
||||
running_machine & m_machine; // reference to the machine
|
||||
|
@ -130,10 +130,13 @@ running_machine::running_machine(const machine_config &_config, machine_manager
|
||||
m_memory(*this),
|
||||
m_ioport(*this),
|
||||
m_parameters(*this),
|
||||
m_scheduler(*this)
|
||||
m_scheduler(*this),
|
||||
m_dummy_space(_config, "dummy_space", &root_device(), 0)
|
||||
{
|
||||
memset(&m_base_time, 0, sizeof(m_base_time));
|
||||
|
||||
m_dummy_space.set_machine(*this);
|
||||
|
||||
// set the machine on all devices
|
||||
device_iterator iter(root_device());
|
||||
for (device_t &device : iter)
|
||||
@ -963,6 +966,8 @@ 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)
|
||||
@ -1227,6 +1232,48 @@ void system_time::full_time::set(struct tm &t)
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DUMMY ADDRESS SPACE
|
||||
//**************************************************************************
|
||||
|
||||
READ8_MEMBER(dummy_space_device::read)
|
||||
{
|
||||
throw emu_fatalerror("Attempted to read from generic address space (offs %X)\n", offset);
|
||||
}
|
||||
|
||||
WRITE8_MEMBER(dummy_space_device::write)
|
||||
{
|
||||
throw emu_fatalerror("Attempted to write to generic address space (offs %X = %02X)\n", offset, data);
|
||||
}
|
||||
|
||||
static ADDRESS_MAP_START(dummy, AS_0, 8, dummy_space_device)
|
||||
AM_RANGE(0x00000000, 0xffffffff) AM_READWRITE(read, write)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
const device_type DUMMY_SPACE = &device_creator<dummy_space_device>;
|
||||
|
||||
dummy_space_device::dummy_space_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, DUMMY_SPACE, "Dummy Space", tag, owner, clock, "dummy_space", __FILE__),
|
||||
device_memory_interface(mconfig, *this),
|
||||
m_space_config("dummy", ENDIANNESS_LITTLE, 8, 32, 0, nullptr, *ADDRESS_MAP_NAME(dummy))
|
||||
{
|
||||
}
|
||||
|
||||
void dummy_space_device::device_start()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// memory_space_config - return a description of
|
||||
// any address spaces owned by this device
|
||||
//-------------------------------------------------
|
||||
|
||||
const address_space_config *dummy_space_device::memory_space_config(address_spacenum spacenum) const
|
||||
{
|
||||
return (spacenum == 0) ? &m_space_config : nullptr;
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// JAVASCRIPT PORT-SPECIFIC
|
||||
//**************************************************************************
|
||||
|
@ -132,6 +132,32 @@ 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, uint32_t clock);
|
||||
|
||||
DECLARE_READ8_MEMBER(read);
|
||||
DECLARE_WRITE8_MEMBER(write);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
|
||||
// device_memory_interface overrides
|
||||
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override;
|
||||
|
||||
private:
|
||||
const address_space_config m_space_config;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ======================> running_machine
|
||||
|
||||
typedef delegate<void ()> machine_notify_delegate;
|
||||
@ -142,6 +168,7 @@ class running_machine
|
||||
DISABLE_COPYING(running_machine);
|
||||
|
||||
friend class sound_manager;
|
||||
friend class memory_manager;
|
||||
|
||||
typedef std::function<void(const char*)> logerror_callback;
|
||||
|
||||
@ -230,6 +257,7 @@ 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<char const *>(nullptr)); }
|
||||
template <typename Format, typename... Params> void popmessage(Format &&fmt, Params &&... args) const;
|
||||
template <typename Format, typename... Params> void logerror(Format &&fmt, Params &&... args) const;
|
||||
@ -356,6 +384,9 @@ private:
|
||||
|
||||
// string formatting buffer
|
||||
mutable util::ovectorstream m_string_buffer;
|
||||
|
||||
// configuration state
|
||||
dummy_space_device m_dummy_space;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user