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
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
CMS Floppy Disc Controller Board
Part No. CMS 0015-1
**********************************************************************/
#include "emu.h"
#include "fdc.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(CMS_FDC, cms_fdc_device, "cms_fdc", "CMS Floppy Disc Controller Board")
//-------------------------------------------------
// MACHINE_DRIVER( cms_fdc )
//-------------------------------------------------
void cms_fdc_device::floppy_formats(format_registration &fr)
{
fr.add_mfm_containers();
fr.add(FLOPPY_ACORN_SSD_FORMAT);
fr.add(FLOPPY_ACORN_DSD_FORMAT);
}
static void cms_floppies(device_slot_interface &device)
{
device.option_add("35dd", FLOPPY_35_DD);
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void cms_fdc_device::device_add_mconfig(machine_config &config)
{
WD1770(config, m_fdc, 8_MHz_XTAL);
FLOPPY_CONNECTOR(config, m_floppy[0], cms_floppies, "35dd", floppy_formats).enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppy[1], cms_floppies, "35dd", floppy_formats).enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppy[2], cms_floppies, nullptr, floppy_formats).enable_sound(true);
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// cms_fdc_device - constructor
//-------------------------------------------------
cms_fdc_device::cms_fdc_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
: device_t(mconfig, CMS_FDC, tag, owner, clock)
, device_acorn_bus_interface(mconfig, *this)
, m_fdc(*this, "wd1770")
, m_floppy(*this, "wd1770:%u", 0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void cms_fdc_device::device_start()
{
address_space &space = m_bus->memspace();
space.install_readwrite_handler(0xfc50, 0xfc5f, read8smo_delegate(*this, FUNC(cms_fdc_device::wd1770_state_r)), write8smo_delegate(*this, FUNC(cms_fdc_device::wd1770_control_w)));
space.install_readwrite_handler(0xfc40, 0xfc4f, read8sm_delegate(*m_fdc, FUNC(wd1770_device::read)), write8sm_delegate(*m_fdc, FUNC(wd1770_device::write)));
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
uint8_t cms_fdc_device::wd1770_state_r()
{
uint8_t data = 0x3f;
data |= m_fdc->intrq_r() << 6;
data |= m_fdc->drq_r() << 7;
return data;
}
void cms_fdc_device::wd1770_control_w(uint8_t data)
{
floppy_image_device *floppy = nullptr;
// bit 0, 1, 2: drive select
if (BIT(data, 0)) floppy = m_floppy[0]->get_device();
if (BIT(data, 1)) floppy = m_floppy[1]->get_device();
if (BIT(data, 2)) floppy = m_floppy[2]->get_device();
m_fdc->set_floppy(floppy);
// bit 3: side select
if (floppy)
floppy->ss_w(BIT(data, 3));
// bit 7: density ??
m_fdc->dden_w(BIT(data, 7));
}
|