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
|
// license: GPL-2.0+
// copyright-holders: Dirk Best
/***************************************************************************
VTech Laser/VZ Memory Expansion Slot
44-pin slot
***************************************************************************/
#include "emu.h"
#include "memexp.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(VTECH_MEMEXP_SLOT, vtech_memexp_slot_device, "vtech_memexp_slot", "Laser/VZ Memory Expansion Slot")
//**************************************************************************
// SLOT DEVICE
//**************************************************************************
//-------------------------------------------------
// vtech_memexp_slot_device - constructor
//-------------------------------------------------
vtech_memexp_slot_device::vtech_memexp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
device_t(mconfig, VTECH_MEMEXP_SLOT, tag, owner, clock),
device_single_card_slot_interface<device_vtech_memexp_interface>(mconfig, *this),
m_memspace(*this, finder_base::DUMMY_TAG, -1),
m_iospace(*this, finder_base::DUMMY_TAG, -1),
m_int_handler(*this),
m_nmi_handler(*this),
m_reset_handler(*this)
{
option_reset();
vtech_memexp_carts(*this);
set_default_option(nullptr);
set_fixed(false);
}
//-------------------------------------------------
// vtech_memexp_slot_device - destructor
//-------------------------------------------------
vtech_memexp_slot_device::~vtech_memexp_slot_device()
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void vtech_memexp_slot_device::device_start()
{
// get inserted module
m_module = get_card_device();
// install memory access taps
m_memspace->install_readwrite_tap
(
0x0000, 0xffff, "mem_tap",
[this](offs_t offset, uint8_t &data, uint8_t mem_mask)
{
if (m_module)
data &= m_module->mreq_r(offset);
},
[this](offs_t offset, uint8_t &data, uint8_t mem_mask)
{
if (m_module)
m_module->mreq_w(offset, data);
}
);
// install io access taps
m_iospace->install_readwrite_tap
(
0x00, 0xff, "io_tap",
[this](offs_t offset, uint8_t &data, uint8_t mem_mask)
{
if (m_module)
data &= m_module->iorq_r(offset);
},
[this](offs_t offset, uint8_t &data, uint8_t mem_mask)
{
if (m_module)
m_module->iorq_w(offset, data);
}
);
// resolve callbacks
m_int_handler.resolve_safe();
m_nmi_handler.resolve_safe();
m_reset_handler.resolve_safe();
}
//**************************************************************************
// CARTRIDGE INTERFACE
//**************************************************************************
//-------------------------------------------------
// device_vtech_memexp_interface - constructor
//-------------------------------------------------
device_vtech_memexp_interface::device_vtech_memexp_interface(const machine_config &mconfig, device_t &device) :
device_interface(device, "vtechmemexp")
{
m_slot = dynamic_cast<vtech_memexp_slot_device *>(device.owner());
}
//-------------------------------------------------
// ~device_vtech_memexp_interface - destructor
//-------------------------------------------------
device_vtech_memexp_interface::~device_vtech_memexp_interface()
{
}
//**************************************************************************
// BASE DEVICE
//**************************************************************************
//-------------------------------------------------
// vtech_memexp_device - constructor
//-------------------------------------------------
vtech_memexp_device::vtech_memexp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock) :
device_t(mconfig, type, tag, owner, clock),
device_vtech_memexp_interface(mconfig, *this),
m_mem(*this, "memspace"),
m_io(*this, "iospace")
{
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void vtech_memexp_device::device_add_mconfig(machine_config &config)
{
ADDRESS_MAP_BANK(config, m_mem);
m_mem->set_addrmap(AS_PROGRAM, &vtech_memexp_device::mem_map);
m_mem->set_data_width(8);
m_mem->set_addr_width(16);
ADDRESS_MAP_BANK(config, m_io);
m_io->set_addrmap(AS_PROGRAM, &vtech_memexp_device::io_map);
m_io->set_data_width(8);
m_io->set_addr_width(16);
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void vtech_memexp_device::device_start()
{
// silence unmapped warnings, or we'll get them for everything the
// expansion device doesn't handle
m_mem->set_log_unmap(false);
m_io->set_log_unmap(false);
}
uint8_t vtech_memexp_device::mreq_r(offs_t offset)
{
return m_mem->read8(offset);
}
void vtech_memexp_device::mreq_w(offs_t offset, uint8_t data)
{
m_mem->write8(offset, data);
}
uint8_t vtech_memexp_device::iorq_r(offs_t offset)
{
return m_io->read8(offset);
}
void vtech_memexp_device::iorq_w(offs_t offset, uint8_t data)
{
m_io->write8(offset, data);
}
|