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
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
Cumana Floppy Disk System
http://chrisacorns.computinghistory.org.uk/8bit_Upgrades/Cumana_FDsystem.html
TODO:
- add floppy format CDFS, and find original utilities disc
- confirm whether DRQ and INTRQ are connected
- add spare ROM slot
**********************************************************************/
#include "emu.h"
#include "cumana.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(ELECTRON_CUMANA, electron_cumana_device, "electron_cumana", "Cumana Floppy Disk System")
//-------------------------------------------------
// FLOPPY_FORMATS( cumana )
//-------------------------------------------------
void electron_cumana_device::floppy_formats(format_registration &fr)
{
fr.add_mfm_containers();
fr.add(FLOPPY_ACORN_SSD_FORMAT);
fr.add(FLOPPY_ACORN_DSD_FORMAT);
fr.add(FLOPPY_ACORN_ADFS_OLD_FORMAT);
}
void cumana_floppies(device_slot_interface &device)
{
device.option_add("35dd", FLOPPY_35_DD);
device.option_add("525qd", FLOPPY_525_QD);
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void electron_cumana_device::device_add_mconfig(machine_config &config)
{
/* fdc */
FD1793(config, m_fdc, DERIVED_CLOCK(1, 16)); // TODO: Not known whether DRQ and INTRQ are connected
FLOPPY_CONNECTOR(config, m_floppy0, cumana_floppies, "525qd", electron_cumana_device::floppy_formats).enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppy1, cumana_floppies, nullptr, electron_cumana_device::floppy_formats).enable_sound(true);
/* rtc */
MC146818(config, m_rtc, 32.768_kHz_XTAL);
m_rtc->irq().set(DEVICE_SELF_OWNER, FUNC(electron_cartslot_device::irq_w));
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// electron_cumana_device - constructor
//-------------------------------------------------
electron_cumana_device::electron_cumana_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, ELECTRON_CUMANA, tag, owner, clock)
, device_electron_cart_interface(mconfig, *this)
, m_fdc(*this, "fdc")
, m_floppy0(*this, "fdc:0")
, m_floppy1(*this, "fdc:1")
, m_rtc(*this, "rtc")
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void electron_cumana_device::device_start()
{
}
//-------------------------------------------------
// read - cartridge data read
//-------------------------------------------------
uint8_t electron_cumana_device::read(offs_t offset, int infc, int infd, int romqa, int oe, int oe2)
{
uint8_t data = 0xff;
if (infc)
{
switch (offset & 0xfc)
{
case 0x90:
data = m_fdc->read(offset & 0x03);
break;
case 0x94:
break;
case 0x98:
case 0x9c:
data = m_rtc->read(BIT(offset, 2));
break;
}
}
else if (oe)
{
switch (romqa)
{
case 0:
if (offset < 0x3800)
{
data = m_rom[offset & 0x3fff];
}
else
{
data = m_nvram[offset & 0x07ff];
}
break;
case 1:
// TODO: rom slot not implemented
break;
}
}
return data;
}
//-------------------------------------------------
// write - cartridge data write
//-------------------------------------------------
void electron_cumana_device::write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2)
{
if (infc)
{
switch (offset & 0xfc)
{
case 0x90:
m_fdc->write(offset & 0x03, data);
break;
case 0x94:
wd1793_control_w(data);
break;
case 0x98:
case 0x9c:
m_rtc->write(BIT(offset, 2), data);
break;
}
}
else if (oe)
{
if (romqa == 0 && offset >= 0x3800)
{
m_nvram[offset & 0x07ff] = data;
}
}
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
void electron_cumana_device::wd1793_control_w(uint8_t data)
{
floppy_image_device *floppy = nullptr;
// bit 1, 2: drive select
if (BIT(data, 1)) floppy = m_floppy0->get_device();
if (BIT(data, 2)) floppy = m_floppy1->get_device();
m_fdc->set_floppy(floppy);
// bit 0: side select
if (floppy)
floppy->ss_w(BIT(data, 0));
// bit 3: density
m_fdc->dden_w(BIT(data, 3));
// bit 4: motor on
if (floppy)
floppy->mon_w(!BIT(data, 4));
// bit 5: head load
}
|