summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/bw2/exp.cpp
blob: ae02f1f10faff4fa756fc569d6af5da529573fa9 (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
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************

    Bondwell 2 Expansion Port emulation

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

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



//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DEFINE_DEVICE_TYPE(BW2_EXPANSION_SLOT, bw2_expansion_slot_device, "bw2_expansion_slot", "Bondwell 2 expansion port")



//**************************************************************************
//  CARD INTERFACE
//**************************************************************************

//-------------------------------------------------
//  device_bw2_expansion_slot_interface - constructor
//-------------------------------------------------

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


//-------------------------------------------------
//  ~device_bw2_expansion_slot_interface - destructor
//-------------------------------------------------

device_bw2_expansion_slot_interface::~device_bw2_expansion_slot_interface()
{
}



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

//-------------------------------------------------
//  bw2_expansion_slot_device - constructor
//-------------------------------------------------

bw2_expansion_slot_device::bw2_expansion_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, BW2_EXPANSION_SLOT, tag, owner, clock),
	device_slot_interface(mconfig, *this), m_cart(nullptr)
{
}


//-------------------------------------------------
//  bw2_expansion_slot_device - destructor
//-------------------------------------------------

bw2_expansion_slot_device::~bw2_expansion_slot_device()
{
}


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

void bw2_expansion_slot_device::device_start()
{
	m_cart = dynamic_cast<device_bw2_expansion_slot_interface *>(get_card_device());
}


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

void bw2_expansion_slot_device::device_reset()
{
	if (m_cart != nullptr)
	{
		m_cart->device().reset();
	}
}


//-------------------------------------------------
//  cd_r - cartridge data read
//-------------------------------------------------

uint8_t bw2_expansion_slot_device::cd_r(address_space &space, offs_t offset, uint8_t data, int ram2, int ram3, int ram4, int ram5, int ram6)
{
	if (m_cart != nullptr)
	{
		data = m_cart->bw2_cd_r(space, offset, data, ram2, ram3, ram4, ram5, ram6);
	}

	return data;
}


//-------------------------------------------------
//  cd_w - cartridge data write
//-------------------------------------------------

void bw2_expansion_slot_device::cd_w(address_space &space, offs_t offset, uint8_t data, int ram2, int ram3, int ram4, int ram5, int ram6)
{
	if (m_cart != nullptr)
	{
		m_cart->bw2_cd_w(space, offset, data, ram2, ram3, ram4, ram5, ram6);
	}
}


//-------------------------------------------------
//  slot_r - slot read
//-------------------------------------------------

READ8_MEMBER( bw2_expansion_slot_device::slot_r )
{
	uint8_t data = 0xff;

	if (m_cart != nullptr)
	{
		data = m_cart->bw2_slot_r(space, offset);
	}

	return data;
}


//-------------------------------------------------
//  slot_w - slot write
//-------------------------------------------------

WRITE8_MEMBER( bw2_expansion_slot_device::slot_w )
{
	if (m_cart != nullptr)
	{
		m_cart->bw2_slot_w(space, offset, data);
	}
}


//-------------------------------------------------
//  modsel_r - modsel read
//-------------------------------------------------

READ8_MEMBER( bw2_expansion_slot_device::modsel_r )
{
	uint8_t data = 0xff;

	if (m_cart != nullptr)
	{
		data = m_cart->bw2_modsel_r(space, offset);
	}

	return data;
}


//-------------------------------------------------
//  modsel_w - modsel write
//-------------------------------------------------

WRITE8_MEMBER( bw2_expansion_slot_device::modsel_w )
{
	if (m_cart != nullptr)
	{
		m_cart->bw2_modsel_w(space, offset, data);
	}
}



//-------------------------------------------------
//  SLOT_INTERFACE( bw2_expansion_cards )
//-------------------------------------------------

// slot devices
#include "ramcard.h"

void bw2_expansion_cards(device_slot_interface &device)
{
	device.option_add("ramcard", BW2_RAMCARD);
}