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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/***************************************************************************
The Dragon's Claw from Lucidata
http://archive.worldofdragon.org/index.php?title=The_Dragon%27s_Claw
The Dragon's Claw is an extension cartridge for the Dragon by Lucidata.
It features two parallel I/O ports. One with the BBC User Port pinout,
and the second with a Centronics Printer Port pinout.
***************************************************************************/
#include "emu.h"
#include "dragon_claw.h"
#include "bus/bbc/userport/userport.h"
#include "bus/centronics/ctronics.h"
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
DEFINE_DEVICE_TYPE_PRIVATE(DRAGON_CLAW, device_cococart_interface, dragon_claw_device, "dragon_claw", "The Dragon's Claw")
//-------------------------------------------------
// INPUT_PORTS( claw )
//-------------------------------------------------
INPUT_PORTS_START(claw)
PORT_START("LINKS")
PORT_CONFNAME(0x03, 0x00, "L1 Address Selection")
PORT_CONFSETTING(0x00, "$FF80")
PORT_CONFSETTING(0x01, "$FF90")
PORT_CONFSETTING(0x02, "$FFA0")
PORT_CONFSETTING(0x03, "$FFB0")
PORT_CONFNAME(0x04, 0x00, "L2 Interrupt Line")
PORT_CONFSETTING(0x00, "NMI")
PORT_CONFSETTING(0x04, "CART")
INPUT_PORTS_END
//-------------------------------------------------
// input_ports - device-specific input ports
//-------------------------------------------------
ioport_constructor dragon_claw_device::device_input_ports() const
{
return INPUT_PORTS_NAME(claw);
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// dragon_claw_device - constructor
//-------------------------------------------------
dragon_claw_device::dragon_claw_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
: device_t(mconfig, DRAGON_CLAW, tag, owner, clock)
, device_cococart_interface(mconfig, *this )
, m_via(*this, "via")
, m_slot(*this, "slot")
, m_links(*this, "LINKS")
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void dragon_claw_device::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void dragon_claw_device::device_reset()
{
uint8_t addr = (m_links->read() & 0x03) << 8;
install_readwrite_handler(0xff80 | addr, 0xff8f | addr, read8sm_delegate(*m_via, FUNC(via6522_device::read)), write8sm_delegate(*m_via, FUNC(via6522_device::write)));
}
static void dragon_cart(device_slot_interface &device)
{
dragon_cart_add_basic_devices(device);
dragon_cart_add_fdcs(device);
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void dragon_claw_device::device_add_mconfig(machine_config &config)
{
MOS6522(config, m_via, DERIVED_CLOCK(1, 1));
m_via->writepa_handler().set("cent_data_out", FUNC(output_latch_device::write));
m_via->readpb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_r));
m_via->writepb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_w));
m_via->ca2_handler().set("centronics", FUNC(centronics_device::write_strobe));
m_via->cb1_handler().set("userport", FUNC(bbc_userport_slot_device::write_cb1));
m_via->cb2_handler().set("userport", FUNC(bbc_userport_slot_device::write_cb2));
m_via->irq_handler().set(FUNC(dragon_claw_device::irq_w)); // link L2 selects either NMI or CART line
bbc_userport_slot_device &userport(BBC_USERPORT_SLOT(config, "userport", bbc_userport_devices, nullptr));
userport.cb1_handler().set(m_via, FUNC(via6522_device::write_cb1));
userport.cb2_handler().set(m_via, FUNC(via6522_device::write_cb2));
centronics_device ¢ronics(CENTRONICS(config, "centronics", centronics_devices, nullptr));
centronics.ack_handler().set(m_via, FUNC(via6522_device::write_ca1));
output_latch_device &latch(OUTPUT_LATCH(config, "cent_data_out"));
centronics.set_output_latch(latch);
COCOCART_SLOT(config, m_slot, DERIVED_CLOCK(1, 1), dragon_cart, nullptr);
m_slot->cart_callback().set([this](int state) { set_line_value(line::CART, state); });
m_slot->nmi_callback().set([this](int state) { set_line_value(line::NMI, state); });
m_slot->halt_callback().set([this](int state) { set_line_value(line::HALT, state); });
}
WRITE_LINE_MEMBER(dragon_claw_device::irq_w)
{
if (m_links->read() & 0x04)
set_line_value(line::CART, state);
else
set_line_value(line::NMI, state);
}
//-------------------------------------------------
// set_sound_enable
//-------------------------------------------------
void dragon_claw_device::set_sound_enable(bool sound_enable)
{
m_slot->set_line_value(line::SOUND_ENABLE, sound_enable ? line_value::ASSERT : line_value::CLEAR);
}
//-------------------------------------------------
// get_cart_base
//-------------------------------------------------
u8 *dragon_claw_device::get_cart_base()
{
return m_slot->get_cart_base();
}
//-------------------------------------------------
// get_cart_size
//-------------------------------------------------
u32 dragon_claw_device::get_cart_size()
{
return m_slot->get_cart_size();
}
//-------------------------------------------------
// cts_read
//-------------------------------------------------
u8 dragon_claw_device::cts_read(offs_t offset)
{
return m_slot->cts_read(offset);
}
//-------------------------------------------------
// cts_write
//-------------------------------------------------
void dragon_claw_device::cts_write(offs_t offset, u8 data)
{
m_slot->cts_write(offset, data);
}
//-------------------------------------------------
// scs_read
//-------------------------------------------------
u8 dragon_claw_device::scs_read(offs_t offset)
{
return m_slot->scs_read(offset);
}
//-------------------------------------------------
// scs_write
//-------------------------------------------------
void dragon_claw_device::scs_write(offs_t offset, u8 data)
{
m_slot->scs_write(offset, data);
}
//-------------------------------------------------
// cartridge_space
//-------------------------------------------------
address_space &dragon_claw_device::cartridge_space()
{
return device_cococart_interface::cartridge_space();
}
|