summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/samcoupe/expansion/expansion.cpp
blob: a5d9457214258664c20c5c7910c9819c088cae56 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// license: GPL-2.0+
// copyright-holders: Dirk Best
/***************************************************************************

    SAM Coupe Expansion Slot

    64-pin slot

***************************************************************************/

#include "emu.h"
#include "expansion.h"


//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(SAMCOUPE_EXPANSION, samcoupe_expansion_device, "samcoupe_expansion", "SAM Coupe Expansion Bus")


//**************************************************************************
//  SLOT DEVICE
//**************************************************************************

//-------------------------------------------------
//  samcoupe_expansion_device - constructor
//-------------------------------------------------

samcoupe_expansion_device::samcoupe_expansion_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, SAMCOUPE_EXPANSION, tag, owner, clock),
	device_single_card_slot_interface<device_samcoupe_expansion_interface>(mconfig, *this),
	m_int_handler(*this),
	m_module(nullptr)
{
}

//-------------------------------------------------
//  samcoupe_expansion_device - destructor
//-------------------------------------------------

samcoupe_expansion_device::~samcoupe_expansion_device()
{
}

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

void samcoupe_expansion_device::device_start()
{
	// get inserted module
	m_module = get_card_device();

	// resolve callbacks
	m_int_handler.resolve_safe();
}

//-------------------------------------------------
//  host to module interface
//-------------------------------------------------

uint8_t samcoupe_expansion_device::mreq_r(offs_t offset)
{
	if (m_module)
		return m_module->mreq_r(offset);

	return 0xff;
}

void samcoupe_expansion_device::mreq_w(offs_t offset, uint8_t data)
{
	if (m_module)
		m_module->mreq_w(offset, data);
}

uint8_t samcoupe_expansion_device::iorq_r(offs_t offset)
{
	if (m_module)
		return m_module->iorq_r(offset);

	return 0xff;
}

void samcoupe_expansion_device::iorq_w(offs_t offset, uint8_t data)
{
	if (m_module)
		m_module->iorq_w(offset, data);
}

WRITE_LINE_MEMBER( samcoupe_expansion_device::xmem_w )
{
		if (m_module)
			m_module->xmem_w(state);
}

WRITE_LINE_MEMBER( samcoupe_expansion_device::print_w )
{
		if (m_module)
			m_module->print_w(state);
}


//**************************************************************************
//  MODULE INTERFACE
//**************************************************************************

//-------------------------------------------------
//  device_samcoupe_expansion_interface - constructor
//-------------------------------------------------

device_samcoupe_expansion_interface::device_samcoupe_expansion_interface(const machine_config &mconfig, device_t &device) :
	device_interface(device, "samcoupeexp")
{
	m_expansion = dynamic_cast<samcoupe_expansion_device *>(device.owner());
}

//-------------------------------------------------
//  ~device_samcoupe_expansion_interface - destructor
//-------------------------------------------------

device_samcoupe_expansion_interface::~device_samcoupe_expansion_interface()
{
}