1 // license:BSD-3-Clause
2 // copyright-holders:Nigel Barnes
3 /**********************************************************************
4 
5     Kenda Professional DMFS
6 
7     The Kenda Professional is packaged with the board in an epoxy blob, and is
8     quite rare. The board contents are not known as no-one has attempted to
9     remove the epoxy.
10     What we do know is that it contains:
11     - 8K ROM
12     - 2K RAM
13     - FDC (definitely WD compatible, and likely a WD2793)
14 
15     The board plugs into the usual 8271 socket and has a ribbon cable with 24 pin
16     header that plugs into a ROM socket.
17 
18     The 8K ROM is mirrored to fill the 16K ROM space, and has the 2K RAM overlayed
19     from offset &3000, and also mirrored upto &4000.
20 
21 **********************************************************************/
22 
23 
24 #include "emu.h"
25 #include "kenda.h"
26 
27 
28 //**************************************************************************
29 //  DEVICE DEFINITIONS
30 //**************************************************************************
31 
32 DEFINE_DEVICE_TYPE(BBC_KENDA, bbc_kenda_device,  "bbc_kenda", "Kenda Professional DMFS")
33 
34 
35 //-------------------------------------------------
36 //  FLOPPY_FORMATS( floppy_formats )
37 //-------------------------------------------------
38 
FLOPPY_FORMATS_MEMBER(bbc_kenda_device::floppy_formats)39 FLOPPY_FORMATS_MEMBER( bbc_kenda_device::floppy_formats )
40 	FLOPPY_ACORN_SSD_FORMAT,
41 	FLOPPY_ACORN_DSD_FORMAT
42 FLOPPY_FORMATS_END
43 
44 //-------------------------------------------------
45 //  SLOT_INTERFACE( bbc_floppies_525 )
46 //-------------------------------------------------
47 
48 static void bbc_floppies_525(device_slot_interface &device)
49 {
50 	device.option_add("525sssd", FLOPPY_525_SSSD);
51 	device.option_add("525sd",   FLOPPY_525_SD);
52 	device.option_add("525ssdd", FLOPPY_525_SSDD);
53 	device.option_add("525dd",   FLOPPY_525_DD);
54 	device.option_add("525qd",   FLOPPY_525_QD);
55 }
56 
57 //-------------------------------------------------
58 //  ROM( kenda )
59 //-------------------------------------------------
60 
61 ROM_START( kenda )
62 	ROM_REGION(0x4000, "dfs_rom", 0)
63 	ROM_LOAD("kenda102.rom", 0x0000, 0x2000, CRC(430b911c) SHA1(594ae1d1aeaa20a1d5d1c64cd94d43926dda4029))
64 	ROM_RELOAD(              0x2000, 0x2000)
65 ROM_END
66 
67 
68 //-------------------------------------------------
69 //  device_add_mconfig - add device configuration
70 //-------------------------------------------------
71 
device_add_mconfig(machine_config & config)72 void bbc_kenda_device::device_add_mconfig(machine_config &config)
73 {
74 	WD2793(config, m_fdc, DERIVED_CLOCK(1, 8)); // TODO: unconfirmed FDC
75 	m_fdc->intrq_wr_callback().set(DEVICE_SELF_OWNER, FUNC(bbc_fdc_slot_device::intrq_w));
76 	m_fdc->drq_wr_callback().set(DEVICE_SELF_OWNER, FUNC(bbc_fdc_slot_device::drq_w));
77 	m_fdc->hld_wr_callback().set(FUNC(bbc_kenda_device::motor_w));
78 
79 	FLOPPY_CONNECTOR(config, m_floppy[0], bbc_floppies_525, "525qd", floppy_formats).enable_sound(true);
80 	FLOPPY_CONNECTOR(config, m_floppy[1], bbc_floppies_525, "525qd", floppy_formats).enable_sound(true);
81 }
82 
83 //-------------------------------------------------
84 //  rom_region - device-specific ROM region
85 //-------------------------------------------------
86 
device_rom_region() const87 const tiny_rom_entry *bbc_kenda_device::device_rom_region() const
88 {
89 	return ROM_NAME( kenda );
90 }
91 
92 //**************************************************************************
93 //  LIVE DEVICE
94 //**************************************************************************
95 
96 //-------------------------------------------------
97 //  bbc_kenda_device - constructor
98 //-------------------------------------------------
99 
bbc_kenda_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)100 bbc_kenda_device::bbc_kenda_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
101 	: device_t(mconfig, BBC_KENDA, tag, owner, clock)
102 	, device_bbc_fdc_interface(mconfig, *this)
103 	, m_fdc(*this, "fdc")
104 	, m_floppy(*this, "fdc:%u", 0)
105 {
106 }
107 
108 //-------------------------------------------------
109 //  device_start - device-specific startup
110 //-------------------------------------------------
111 
device_start()112 void bbc_kenda_device::device_start()
113 {
114 }
115 
116 
117 //**************************************************************************
118 //  IMPLEMENTATION
119 //**************************************************************************
120 
read(offs_t offset)121 uint8_t bbc_kenda_device::read(offs_t offset)
122 {
123 	uint8_t data;
124 
125 	if (offset & 0x04)
126 	{
127 		data = 0xfe;
128 	}
129 	else
130 	{
131 		data = m_fdc->read(offset & 0x03);
132 	}
133 
134 	return data;
135 }
136 
write(offs_t offset,uint8_t data)137 void bbc_kenda_device::write(offs_t offset, uint8_t data)
138 {
139 	if (offset & 0x04)
140 	{
141 		floppy_image_device *floppy = nullptr;
142 
143 		// bit 0: drive select
144 		floppy = m_floppy[BIT(data, 0)]->get_device();
145 		m_fdc->set_floppy(floppy);
146 
147 		// bit 1: side select
148 		if (floppy)
149 			floppy->ss_w(BIT(data, 1));
150 
151 		// other bits unknown, or unused
152 
153 		// bit 7: density
154 		m_fdc->dden_w(!BIT(data, 7));
155 	}
156 	else
157 	{
158 		m_fdc->write(offset & 0x03, data);
159 	}
160 }
161 
WRITE_LINE_MEMBER(bbc_kenda_device::motor_w)162 WRITE_LINE_MEMBER(bbc_kenda_device::motor_w)
163 {
164 	if (m_floppy[0]->get_device()) m_floppy[0]->get_device()->mon_w(!state);
165 	if (m_floppy[1]->get_device()) m_floppy[1]->get_device()->mon_w(!state);
166 }
167