diff --git a/.gitattributes b/.gitattributes index e9d5b143d8a..14e363729ff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -835,6 +835,8 @@ src/emu/machine/mc68901.c svneol=native#text/plain src/emu/machine/mc68901.h svneol=native#text/plain src/emu/machine/microtch.c svneol=native#text/plain src/emu/machine/microtch.h svneol=native#text/plain +src/emu/machine/mos6529.c svneol=native#text/plain +src/emu/machine/mos6529.h svneol=native#text/plain src/emu/machine/msm6242.c svneol=native#text/plain src/emu/machine/msm6242.h svneol=native#text/plain src/emu/machine/nmc9306.c svneol=native#text/plain diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 04b4bc0640d..5bbf48b00b0 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -194,6 +194,7 @@ EMUMACHINEOBJS = \ $(EMUMACHINE)/mc6852.o \ $(EMUMACHINE)/mc68901.o \ $(EMUMACHINE)/microtch.o \ + $(EMUMACHINE)/mos6529.o \ $(EMUMACHINE)/msm6242.o \ $(EMUMACHINE)/nmc9306.o \ $(EMUMACHINE)/nvram.o \ diff --git a/src/emu/machine/mos6529.c b/src/emu/machine/mos6529.c new file mode 100644 index 00000000000..1e42295f434 --- /dev/null +++ b/src/emu/machine/mos6529.c @@ -0,0 +1,107 @@ +/********************************************************************** + + MOS Technology 6529 Single Port Interface Adapter emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +#include "mos6529.h" +#include "devhelpr.h" + + + +//************************************************************************** +// MACROS / CONSTANTS +//************************************************************************** + +#define LOG 0 + + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// devices +const device_type MOS6529 = mos6529_device_config::static_alloc_device_config; + + + + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +GENERIC_DEVICE_CONFIG_SETUP(mos6529, "MOS6529") + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void mos6529_device_config::device_config_complete() +{ + // inherit a copy of the static data + const mos6529_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + memset(&m_in_p_func, 0, sizeof(m_in_p_func)); + memset(&m_out_p_func, 0, sizeof(m_out_p_func)); + } +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// mos6529_device - constructor +//------------------------------------------------- + +mos6529_device::mos6529_device(running_machine &_machine, const mos6529_device_config &config) + : device_t(_machine, config), + m_config(config) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void mos6529_device::device_start() +{ + // resolve callbacks + devcb_resolve_read8(&m_in_p_func, &m_config.m_in_p_func, this); + devcb_resolve_write8(&m_out_p_func, &m_config.m_out_p_func, this); +} + + +//------------------------------------------------- +// read - +//------------------------------------------------- + +READ8_MEMBER( mos6529_device::read ) +{ + return devcb_call_read8(&m_in_p_func, 0); +} + + +//------------------------------------------------- +// write - +//------------------------------------------------- + +WRITE8_MEMBER( mos6529_device::write ) +{ + devcb_call_write8(&m_out_p_func, 0, data); +} diff --git a/src/emu/machine/mos6529.h b/src/emu/machine/mos6529.h new file mode 100644 index 00000000000..b4545a1eb7f --- /dev/null +++ b/src/emu/machine/mos6529.h @@ -0,0 +1,109 @@ +/********************************************************************** + + MOS Technology 6529 Single Port Interface Adapter emulation + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +********************************************************************** + _____ _____ + R/W 1 |* \_/ | 20 Vdd + P0 2 | | 19 _CS + P1 3 | | 18 D0 + P2 4 | | 17 D1 + P3 5 | MOS6529 | 16 D2 + P4 6 | | 15 D3 + P5 7 | | 14 D4 + P6 8 | | 13 D5 + P7 9 | | 12 D6 + Vss 10 |_____________| 11 D7 + +**********************************************************************/ + +#pragma once + +#ifndef __MOS6529__ +#define __MOS6529__ + +#include "emu.h" + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_MOS6529_ADD(_tag, _clock, _config) \ + MCFG_DEVICE_ADD(_tag, MOS6529, _clock) \ + MCFG_DEVICE_CONFIG(_config) + +#define MOS6529_INTERFACE(name) \ + const mos6529_interface (name) = + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> mos6529_interface + +struct mos6529_interface +{ + devcb_read8 m_in_p_func; + devcb_write8 m_out_p_func; +}; + + +// ======================> mos6529_device_config + +class mos6529_device_config : public device_config, + public mos6529_interface +{ + friend class mos6529_device; + + // construction/destruction + mos6529_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + +protected: + // device_config overrides + virtual void device_config_complete(); +}; + + +// ======================> mos6529_device + +class mos6529_device : public device_t +{ + friend class mos6529_device_config; + + // construction/destruction + mos6529_device(running_machine &_machine, const mos6529_device_config &_config); + +public: + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + +protected: + // device-level overrides + virtual void device_start(); + +private: + devcb_resolved_read8 m_in_p_func; + devcb_resolved_write8 m_out_p_func; + + const mos6529_device_config &m_config; +}; + + +// device type definition +extern const device_type MOS6529; + + + +#endif