summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/spectrum/exp.cpp
blob: 06a338ffd8ae20cec46665428416dd5ee57c6aa9 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

        ZX Spectrum Expansion Port emulation

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

#include "emu.h"
#include "exp.h"


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

DEFINE_DEVICE_TYPE(SPECTRUM_EXPANSION_SLOT, spectrum_expansion_slot_device, "spectrum_expansion_slot", "ZX Spectrum Expansion port")


//**************************************************************************
//  DEVICE SPECTRUM_EXPANSION CARD INTERFACE
//**************************************************************************

//-------------------------------------------------
//  device_spectrum_expansion_interface - constructor
//-------------------------------------------------

device_spectrum_expansion_interface::device_spectrum_expansion_interface(const machine_config &mconfig, device_t &device)
	: device_slot_card_interface(mconfig, device)
{
	m_slot = dynamic_cast<spectrum_expansion_slot_device *>(device.owner());
}


//-------------------------------------------------
//  ~device_spectrum_expansion_interface - destructor
//-------------------------------------------------

device_spectrum_expansion_interface::~device_spectrum_expansion_interface()
{
}


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

//-------------------------------------------------
//  spectrum_expansion_slot_device - constructor
//-------------------------------------------------

spectrum_expansion_slot_device::spectrum_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, SPECTRUM_EXPANSION_SLOT, tag, owner, clock),
	device_slot_interface(mconfig, *this),
	m_card(nullptr),
	m_irq_handler(*this),
	m_nmi_handler(*this)
{
}


//-------------------------------------------------
//  expansion_slot_device - destructor
//-------------------------------------------------

spectrum_expansion_slot_device::~spectrum_expansion_slot_device()
{
}


//-------------------------------------------------
//  device_validity_check - device-specific checks
//-------------------------------------------------

void spectrum_expansion_slot_device::device_validity_check(validity_checker &valid) const
{
	device_t *const card(get_card_device());
	if (card && !dynamic_cast<device_spectrum_expansion_interface *>(card))
		osd_printf_error("Card device %s (%s) does not implement device_spectrum_expansion_interface\n", card->tag(), card->name());
}

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

void spectrum_expansion_slot_device::device_start()
{
	device_t *const card_device(get_card_device());
	m_card = dynamic_cast<device_spectrum_expansion_interface *>(card_device);
	if (card_device && !m_card)
		throw emu_fatalerror("spectrum_expansion_slot_device: card device %s (%s) does not implement device_spectrum_expansion_interface\n", card_device->tag(), card_device->name());

	// resolve callbacks
	m_irq_handler.resolve_safe();
	m_nmi_handler.resolve_safe();
}

//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void spectrum_expansion_slot_device::device_reset()
{
}

//-------------------------------------------------
//  port_fe_r
//-------------------------------------------------

READ8_MEMBER(spectrum_expansion_slot_device::port_fe_r)
{
	if (m_card)
		return m_card->port_fe_r(space, offset);
	else
		return 0xff;
}

//-------------------------------------------------
//  romcs
//-------------------------------------------------

READ_LINE_MEMBER(spectrum_expansion_slot_device::romcs)
{
	if (m_card)
		return m_card->romcs();
	else
		return 0;
}

//-------------------------------------------------
//  mreq_r
//-------------------------------------------------

READ8_MEMBER(spectrum_expansion_slot_device::mreq_r)
{
	if (m_card)
		return m_card->mreq_r(space, offset);
	else
		return 0xff;
}

//-------------------------------------------------
//  mreq_w
//-------------------------------------------------

WRITE8_MEMBER(spectrum_expansion_slot_device::mreq_w)
{
	if (m_card)
		m_card->mreq_w(space, offset, data);
}


//-------------------------------------------------
//  SLOT_INTERFACE( spectrum_expansion_devices )
//-------------------------------------------------


// slot devices
#include "intf1.h"
#include "intf2.h"
#include "fuller.h"
#include "kempjoy.h"
#include "melodik.h"
#include "mikroplus.h"
#include "plus2test.h"
#include "protek.h"
#include "uslot.h"
#include "usource.h"
#include "uspeech.h"


SLOT_INTERFACE_START( spectrum_expansion_devices )
	SLOT_INTERFACE("intf1", SPECTRUM_INTF1)
	SLOT_INTERFACE("intf2", SPECTRUM_INTF2)
	SLOT_INTERFACE("fuller", SPECTRUM_FULLER)
	SLOT_INTERFACE("kempjoy", SPECTRUM_KEMPJOY)
	SLOT_INTERFACE("melodik", SPECTRUM_MELODIK)
	SLOT_INTERFACE("mikroplus", SPECTRUM_MIKROPLUS)
	SLOT_INTERFACE("protek", SPECTRUM_PROTEK)
	SLOT_INTERFACE("uslot", SPECTRUM_USLOT)
	SLOT_INTERFACE("usource", SPECTRUM_USOURCE)
	SLOT_INTERFACE("uspeech", SPECTRUM_USPEECH)
SLOT_INTERFACE_END

SLOT_INTERFACE_START( spec128_expansion_devices )
	SLOT_INTERFACE("intf1", SPECTRUM_INTF1)
	SLOT_INTERFACE("intf2", SPECTRUM_INTF2)
	SLOT_INTERFACE("kempjoy", SPECTRUM_KEMPJOY)
	SLOT_INTERFACE("mikroplus", SPECTRUM_MIKROPLUS)
	SLOT_INTERFACE("plus2test", SPECTRUM_PLUS2TEST)
	SLOT_INTERFACE("protek", SPECTRUM_PROTEK)
SLOT_INTERFACE_END

SLOT_INTERFACE_START( specpls3_expansion_devices )
SLOT_INTERFACE_END