summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/mos6529.c
blob: 5faadccb4f13a47b5f37a2ed3ece6a98a3c7d837 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**********************************************************************

    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



//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

// device type definition
const device_type MOS6529 = &device_creator<mos6529_device>;

//-------------------------------------------------
//  mos6529_device - constructor
//-------------------------------------------------

mos6529_device::mos6529_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
    : device_t(mconfig, MOS6529, "MOS6529", tag, owner, clock)
{
}


//-------------------------------------------------
//  device_config_complete - perform any
//  operations now that the configuration is
//  complete
//-------------------------------------------------

void mos6529_device::device_config_complete()
{
	// inherit a copy of the static data
	const mos6529_interface *intf = reinterpret_cast<const mos6529_interface *>(static_config());
	if (intf != NULL)
		*static_cast<mos6529_interface *>(this) = *intf;

	// or initialize to defaults if none provided
	else
	{
		memset(&m_in_p_cb, 0, sizeof(m_in_p_cb));
		memset(&m_out_p_cb, 0, sizeof(m_out_p_cb));
	}
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void mos6529_device::device_start()
{
	// resolve callbacks
	m_in_p_func.resolve(m_in_p_cb, *this);
	m_out_p_func.resolve(m_out_p_cb, *this);
}


//-------------------------------------------------
//  read -
//-------------------------------------------------

READ8_MEMBER( mos6529_device::read )
{
	return m_in_p_func(0);
}


//-------------------------------------------------
//  write -
//-------------------------------------------------

WRITE8_MEMBER( mos6529_device::write )
{
	m_out_p_func(0, data);
}