diff options
author | 2011-04-27 05:11:18 +0000 | |
---|---|---|
committer | 2011-04-27 05:11:18 +0000 | |
commit | 919913f118760c0ca41ab63512bd5c106f6fd840 (patch) | |
tree | cd6c115c8e9c5280ac4bd16eabfe69c7341151c2 /src/emu/machine/i8155.c | |
parent | 84f2c31f7d6f6c667427b1d60c83e6dc9f420d60 (diff) |
Collapsed device_config and device_t into one class. Updated all
existing modern devices and the legacy wrappers to work in this
environment. This in general greatly simplifies writing a modern
device. [Aaron Giles]
General notes:
* some more cleanup probably needs to happen behind this change,
but I needed to get it in before the next device modernization
or import from MESS :)
* new template function device_creator which automatically defines
the static function that creates the device; use this instead of
creating a static_alloc_device_config function
* added device_stop() method which is called at around the time
the previous device_t's destructor was called; if you auto_free
anything, do it here because the machine is gone when the
destructor is called
* changed the static_set_* calls to pass a device_t & instead of
a device_config *
* for many devices, the static config structure member names over-
lapped the device's names for devcb_* functions; in these cases
the members in the interface were renamed to have a _cb suffix
* changed the driver_enumerator to only cache 100 machine_configs
because caching them all took a ton of memory; fortunately this
implementation detail is completely hidden behind the
driver_enumerator interface
* got rid of the macros for creating derived classes; doing it
manually is now clean enough that it isn't worth hiding the
details in a macro
Diffstat (limited to 'src/emu/machine/i8155.c')
-rw-r--r-- | src/emu/machine/i8155.c | 143 |
1 files changed, 52 insertions, 91 deletions
diff --git a/src/emu/machine/i8155.c b/src/emu/machine/i8155.c index 3726e766029..f103a70561d 100644 --- a/src/emu/machine/i8155.c +++ b/src/emu/machine/i8155.c @@ -19,6 +19,9 @@ #include "i8155.h" +// device type definition +const device_type I8155 = &device_creator<i8155_device>; + //************************************************************************** // MACROS / CONSTANTS @@ -94,10 +97,6 @@ enum // GLOBAL VARIABLES //************************************************************************** -// devices -const device_type I8155 = i8155_device_config::static_alloc_device_config; - - // default address map static ADDRESS_MAP_START( i8155, AS_0, 8 ) AM_RANGE(0x00, 0xff) AM_RAM @@ -106,82 +105,6 @@ ADDRESS_MAP_END //************************************************************************** -// DEVICE CONFIGURATION -//************************************************************************** - -//------------------------------------------------- -// i8155_device_config - constructor -//------------------------------------------------- - -i8155_device_config::i8155_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) - : device_config(mconfig, static_alloc_device_config, "Intel 8155", tag, owner, clock), - device_config_memory_interface(mconfig, *this), - m_space_config("ram", ENDIANNESS_LITTLE, 8, 8, 0, NULL, *ADDRESS_MAP_NAME(i8155)) -{ -} - - -//------------------------------------------------- -// static_alloc_device_config - allocate a new -// configuration object -//------------------------------------------------- - -device_config *i8155_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) -{ - return global_alloc(i8155_device_config(mconfig, tag, owner, clock)); -} - - -//------------------------------------------------- -// alloc_device - allocate a new device object -//------------------------------------------------- - -device_t *i8155_device_config::alloc_device(running_machine &machine) const -{ - return auto_alloc(machine, i8155_device(machine, *this)); -} - - -//------------------------------------------------- -// memory_space_config - return a description of -// any address spaces owned by this device -//------------------------------------------------- - -const address_space_config *i8155_device_config::memory_space_config(address_spacenum spacenum) const -{ - return (spacenum == AS_0) ? &m_space_config : NULL; -} - - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void i8155_device_config::device_config_complete() -{ - // inherit a copy of the static data - const i8155_interface *intf = reinterpret_cast<const i8155_interface *>(static_config()); - if (intf != NULL) - *static_cast<i8155_interface *>(this) = *intf; - - // or initialize to defaults if none provided - else - { - memset(&in_pa_func, 0, sizeof(in_pa_func)); - memset(&out_pa_func, 0, sizeof(out_pa_func)); - memset(&in_pb_func, 0, sizeof(in_pb_func)); - memset(&out_pb_func, 0, sizeof(out_pb_func)); - memset(&in_pc_func, 0, sizeof(in_pc_func)); - memset(&out_pc_func, 0, sizeof(out_pc_func)); - memset(&out_to_func, 0, sizeof(out_to_func)); - } -} - - - -//************************************************************************** // INLINE HELPERS //************************************************************************** @@ -291,12 +214,39 @@ inline void i8155_device::write_port(int port, UINT8 data) // i8155_device - constructor //------------------------------------------------- -i8155_device::i8155_device(running_machine &_machine, const i8155_device_config &config) - : device_t(_machine, config), - device_memory_interface(_machine, config, *this), - m_config(config) +i8155_device::i8155_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, I8155, "Intel 8155", tag, owner, clock), + device_memory_interface(mconfig, *this), + m_space_config("ram", ENDIANNESS_LITTLE, 8, 8, 0, NULL, *ADDRESS_MAP_NAME(i8155)) +{ + +} + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void i8155_device::device_config_complete() { + // inherit a copy of the static data + const i8155_interface *intf = reinterpret_cast<const i8155_interface *>(static_config()); + if (intf != NULL) + *static_cast<i8155_interface *>(this) = *intf; + // or initialize to defaults if none provided + else + { + memset(&in_pa_cb, 0, sizeof(in_pa_cb)); + memset(&out_pa_cb, 0, sizeof(out_pa_cb)); + memset(&in_pb_cb, 0, sizeof(in_pb_cb)); + memset(&out_pb_cb, 0, sizeof(out_pb_cb)); + memset(&in_pc_cb, 0, sizeof(in_pc_cb)); + memset(&out_pc_cb, 0, sizeof(out_pc_cb)); + memset(&out_to_cb, 0, sizeof(out_to_cb)); + } } @@ -307,13 +257,13 @@ i8155_device::i8155_device(running_machine &_machine, const i8155_device_config void i8155_device::device_start() { // resolve callbacks - devcb_resolve_read8(&m_in_port_func[0], &m_config.in_pa_func, this); - devcb_resolve_read8(&m_in_port_func[1], &m_config.in_pb_func, this); - devcb_resolve_read8(&m_in_port_func[2], &m_config.in_pc_func, this); - devcb_resolve_write8(&m_out_port_func[0], &m_config.out_pa_func, this); - devcb_resolve_write8(&m_out_port_func[1], &m_config.out_pb_func, this); - devcb_resolve_write8(&m_out_port_func[2], &m_config.out_pc_func, this); - devcb_resolve_write_line(&m_out_to_func, &m_config.out_to_func, this); + devcb_resolve_read8(&m_in_port_func[0], &in_pa_cb, this); + devcb_resolve_read8(&m_in_port_func[1], &in_pb_cb, this); + devcb_resolve_read8(&m_in_port_func[2], &in_pc_cb, this); + devcb_resolve_write8(&m_out_port_func[0], &out_pa_cb, this); + devcb_resolve_write8(&m_out_port_func[1], &out_pb_cb, this); + devcb_resolve_write8(&m_out_port_func[2], &out_pc_cb, this); + devcb_resolve_write_line(&m_out_to_func, &out_to_cb, this); // allocate timers m_timer = timer_alloc(); @@ -417,6 +367,17 @@ void i8155_device::device_timer(emu_timer &timer, device_timer_id id, int param, //------------------------------------------------- +// memory_space_config - return a description of +// any address spaces owned by this device +//------------------------------------------------- + +const address_space_config *i8155_device::memory_space_config(address_spacenum spacenum) const +{ + return (spacenum == AS_0) ? &m_space_config : NULL; +} + + +//------------------------------------------------- // io_r - register read //------------------------------------------------- |