1 // license:BSD-3-Clause
2 // copyright-holders:AJR
3 /****************************************************************************
4 
5     Skeleton driver for Korg DSS-1 synthesizer.
6 
7 ****************************************************************************/
8 
9 #include "emu.h"
10 #include "bus/midi/midi.h"
11 #include "bus/nscsi/devices.h"
12 #include "cpu/i8085/i8085.h"
13 #include "cpu/m6800/m6801.h"
14 #include "cpu/nec/v5x.h"
15 #include "imagedev/floppy.h"
16 #include "machine/gen_latch.h"
17 #include "machine/i8155.h"
18 #include "machine/i8255.h"
19 #include "machine/ncr5380n.h"
20 #include "machine/nscsi_bus.h"
21 #include "machine/pit8253.h"
22 #include "machine/upd765.h"
23 #include "video/hd44780.h"
24 #include "emupal.h"
25 #include "screen.h"
26 
27 class korg_dss1_state : public driver_device
28 {
29 public:
korg_dss1_state(const machine_config & mconfig,device_type type,const char * tag)30 	korg_dss1_state(const machine_config &mconfig, device_type type, const char *tag)
31 		: driver_device(mconfig, type, tag)
32 		, m_cpu1(*this, "cpu1")
33 		, m_cpu2(*this, "cpu2")
34 		, m_io1(*this, "io1")
35 		, m_io2(*this, "io2")
36 		, m_latch(*this, "latch%u", 1U)
37 		, m_pit(*this, "pit%u", 1U)
38 		, m_fdc(*this, "fdc")
39 		, m_lcdc(*this, "lcdc")
40 		, m_rombank(*this, "rombank")
41 	{
42 	}
43 
44 	void dss1(machine_config &config);
45 
46 protected:
47 	virtual void machine_start() override;
48 	virtual void machine_reset() override;
49 
50 	u8 klm782_ga1_r(offs_t offset);
51 	void klm782_ga1_w(offs_t offset, u8 data);
52 	u8 klm782_ga2_1_r(offs_t offset);
53 	void klm782_ga2_1_w(offs_t offset, u8 data);
54 	u8 klm782_ga2_2_r(offs_t offset);
55 	void klm782_ga2_2_w(offs_t offset, u8 data);
56 	u8 klm782_ga3_1_r(offs_t offset);
57 	void klm782_ga3_1_w(offs_t offset, u8 data);
58 	u8 klm782_ga3_2_r(offs_t offset);
59 	void klm782_ga3_2_w(offs_t offset, u8 data);
60 	void dmaram_lsb_w(u8 data);
61 	void dmaram_msb_w(u8 data);
62 	u8 dmaram_lsb_r();
63 	u8 dmaram_msb_r();
64 	void mode_select_w(u8 data);
65 
66 	void klm780(machine_config &config);
67 	void klm781(machine_config &config);
68 	void klm782(machine_config &config);
69 
70 private:
71 	HD44780_PIXEL_UPDATE(lcd_pixel_update);
72 
73 	void bank_switch_w(u8 data);
74 	void panel_led_w(u8 data);
75 	DECLARE_WRITE_LINE_MEMBER(fdc_tc_w);
76 	DECLARE_WRITE_LINE_MEMBER(sed9420c_trgin_w);
77 	u8 fdc_r(offs_t offset);
78 	void fdc_w(offs_t offset, u8 data);
79 
80 	void vcf_vca_ef_w(u8 data);
81 	u8 cpu2_p5_r();
82 	void ad_select_w(u8 data);
83 	void da_lsb_w(u8 data);
84 	void da_msb_w(u8 data);
85 	u8 kbd_r();
86 	void kbd_w(u8 data);
87 
88 	void cpu1_map(address_map &map);
89 	void cpu2_map(address_map &map);
90 
91 	void palette_init_dss1(palette_device &palette);
92 
93 protected:
94 	optional_device<cpu_device> m_cpu1;
95 	required_device<hd6303x_cpu_device> m_cpu2;
96 	required_device<i8155_device> m_io1;
97 	required_device<i8255_device> m_io2;
98 	required_device_array<generic_latch_8_device, 2> m_latch;
99 	required_device_array<pit8253_device, 6> m_pit;
100 	required_device<upd765a_device> m_fdc;
101 	required_device<hd44780_device> m_lcdc;
102 	optional_memory_bank m_rombank;
103 };
104 
105 class korg_dssmsrk_state : public korg_dss1_state
106 {
107 public:
korg_dssmsrk_state(const machine_config & mconfig,device_type type,const char * tag)108 	korg_dssmsrk_state(const machine_config &mconfig, device_type type, const char *tag)
109 		: korg_dss1_state(mconfig, type, tag)
110 		, m_msrkcpu(*this, "msrkcpu")
111 		, m_scsic(*this, "scsi:7:scsic")
112 	{
113 	}
114 
115 	void dssmsrk(machine_config &config);
116 
117 private:
118 	void msrk_map(address_map &map);
119 	void msrk_io_map(address_map &map);
120 
121 	u8 fdc_r(offs_t offset);
122 	void fdc_w(offs_t offset, u8 data);
123 
124 	required_device<v40_device> m_msrkcpu;
125 	required_device<ncr53c80_device> m_scsic;
126 };
127 
machine_start()128 void korg_dss1_state::machine_start()
129 {
130 	if (m_rombank.found())
131 		m_rombank->configure_entries(0, 2, memregion("klm780")->base(), 0x8000);
132 }
133 
machine_reset()134 void korg_dss1_state::machine_reset()
135 {
136 	if (m_rombank.found())
137 		m_rombank->set_entry(0);
138 }
139 
HD44780_PIXEL_UPDATE(korg_dss1_state::lcd_pixel_update)140 HD44780_PIXEL_UPDATE(korg_dss1_state::lcd_pixel_update)
141 {
142 	if (x < 5 && y < 8 && line < 2 && pos < 20)
143 		bitmap.pix(line * 8 + y, pos * 6 + x) = state;
144 }
145 
146 
bank_switch_w(u8 data)147 void korg_dss1_state::bank_switch_w(u8 data)
148 {
149 	m_rombank->set_entry(data & 0x01);
150 }
151 
panel_led_w(u8 data)152 void korg_dss1_state::panel_led_w(u8 data)
153 {
154 	// TODO
155 	// TODO
156 }
157 
WRITE_LINE_MEMBER(korg_dss1_state::fdc_tc_w)158 WRITE_LINE_MEMBER(korg_dss1_state::fdc_tc_w)
159 {
160 	if (m_cpu1.found())
161 		m_fdc->tc_w(state);
162 	else
163 	{
164 		// TODO: MSRK rejumpers this to control SED9420C's MIN/STD input instead
165 	}
166 }
167 
WRITE_LINE_MEMBER(korg_dss1_state::sed9420c_trgin_w)168 WRITE_LINE_MEMBER(korg_dss1_state::sed9420c_trgin_w)
169 {
170 	// TODO
171 }
172 
fdc_r(offs_t offset)173 u8 korg_dss1_state::fdc_r(offs_t offset)
174 {
175 	if (!machine().side_effects_disabled())
176 		m_cpu1->adjust_icount(-1);
177 
178 	if (BIT(offset, 0))
179 		return m_fdc->fifo_r();
180 	else
181 		return m_fdc->msr_r();
182 }
183 
fdc_r(offs_t offset)184 u8 korg_dssmsrk_state::fdc_r(offs_t offset)
185 {
186 	if (!machine().side_effects_disabled())
187 		m_msrkcpu->adjust_icount(-1);
188 
189 	if (BIT(offset, 0))
190 		return m_fdc->fifo_r();
191 	else
192 		return m_fdc->msr_r();
193 }
194 
fdc_w(offs_t offset,u8 data)195 void korg_dss1_state::fdc_w(offs_t offset, u8 data)
196 {
197 	if (!machine().side_effects_disabled())
198 		m_cpu1->adjust_icount(-1);
199 
200 	if (BIT(offset, 0))
201 		m_fdc->fifo_w(data);
202 }
203 
fdc_w(offs_t offset,u8 data)204 void korg_dssmsrk_state::fdc_w(offs_t offset, u8 data)
205 {
206 	if (!machine().side_effects_disabled())
207 		m_msrkcpu->adjust_icount(-1);
208 
209 	if (BIT(offset, 0))
210 		m_fdc->fifo_w(data);
211 }
212 
vcf_vca_ef_w(u8 data)213 void korg_dss1_state::vcf_vca_ef_w(u8 data)
214 {
215 	// TODO
216 }
217 
cpu2_p5_r()218 u8 korg_dss1_state::cpu2_p5_r()
219 {
220 	// TODO: other bits
221 	return m_latch[0]->pending_r() | (m_latch[1]->pending_r() << 1);
222 }
223 
ad_select_w(u8 data)224 void korg_dss1_state::ad_select_w(u8 data)
225 {
226 	// TODO
227 }
228 
da_lsb_w(u8 data)229 void korg_dss1_state::da_lsb_w(u8 data)
230 {
231 	// TODO
232 }
233 
da_msb_w(u8 data)234 void korg_dss1_state::da_msb_w(u8 data)
235 {
236 	// TODO
237 }
238 
kbd_r()239 u8 korg_dss1_state::kbd_r()
240 {
241 	// TODO
242 	return 0;
243 }
244 
kbd_w(u8 data)245 void korg_dss1_state::kbd_w(u8 data)
246 {
247 	// TODO
248 }
249 
klm782_ga1_r(offs_t offset)250 u8 korg_dss1_state::klm782_ga1_r(offs_t offset)
251 {
252 	// TODO
253 	return 0;
254 }
255 
klm782_ga1_w(offs_t offset,u8 data)256 void korg_dss1_state::klm782_ga1_w(offs_t offset, u8 data)
257 {
258 	// TODO
259 }
260 
klm782_ga2_1_r(offs_t offset)261 u8 korg_dss1_state::klm782_ga2_1_r(offs_t offset)
262 {
263 	// TODO
264 	return 0;
265 }
266 
klm782_ga2_1_w(offs_t offset,u8 data)267 void korg_dss1_state::klm782_ga2_1_w(offs_t offset, u8 data)
268 {
269 	// TODO
270 }
271 
klm782_ga2_2_r(offs_t offset)272 u8 korg_dss1_state::klm782_ga2_2_r(offs_t offset)
273 {
274 	// TODO
275 	return 0;
276 }
277 
klm782_ga2_2_w(offs_t offset,u8 data)278 void korg_dss1_state::klm782_ga2_2_w(offs_t offset, u8 data)
279 {
280 	// TODO
281 }
282 
klm782_ga3_1_r(offs_t offset)283 u8 korg_dss1_state::klm782_ga3_1_r(offs_t offset)
284 {
285 	// TODO
286 	return 0;
287 }
288 
klm782_ga3_1_w(offs_t offset,u8 data)289 void korg_dss1_state::klm782_ga3_1_w(offs_t offset, u8 data)
290 {
291 	// TODO
292 }
293 
klm782_ga3_2_r(offs_t offset)294 u8 korg_dss1_state::klm782_ga3_2_r(offs_t offset)
295 {
296 	// TODO
297 	return 0;
298 }
299 
klm782_ga3_2_w(offs_t offset,u8 data)300 void korg_dss1_state::klm782_ga3_2_w(offs_t offset, u8 data)
301 {
302 	// TODO
303 }
304 
dmaram_lsb_w(u8 data)305 void korg_dss1_state::dmaram_lsb_w(u8 data)
306 {
307 	// TODO
308 }
309 
dmaram_msb_w(u8 data)310 void korg_dss1_state::dmaram_msb_w(u8 data)
311 {
312 	// TODO
313 }
314 
dmaram_lsb_r()315 u8 korg_dss1_state::dmaram_lsb_r()
316 {
317 	// TODO
318 	return 0;
319 }
320 
dmaram_msb_r()321 u8 korg_dss1_state::dmaram_msb_r()
322 {
323 	// TODO
324 	return 0;
325 }
326 
mode_select_w(u8 data)327 void korg_dss1_state::mode_select_w(u8 data)
328 {
329 	// TODO
330 }
331 
cpu1_map(address_map & map)332 void korg_dss1_state::cpu1_map(address_map &map)
333 {
334 	map(0x0000, 0x7fff).bankr("rombank");
335 	map(0x8000, 0x9fff).rom().region("klm780", 0x10000);
336 	map(0xa000, 0xbfff).ram();
337 	map(0xc000, 0xc0ff).mirror(0x200).rw(m_io1, FUNC(i8155_device::memory_r), FUNC(i8155_device::memory_w));
338 	map(0xc100, 0xc107).mirror(0x2f8).rw(m_io1, FUNC(i8155_device::io_r), FUNC(i8155_device::io_w));
339 	map(0xc400, 0xc403).mirror(0x3fc).rw(m_io2, FUNC(i8255_device::read), FUNC(i8255_device::write));
340 	map(0xc800, 0xc800).mirror(0x3ff).w(FUNC(korg_dss1_state::bank_switch_w));
341 	map(0xd000, 0xd003).mirror(0x300).rw(m_pit[0], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
342 	map(0xd004, 0xd007).mirror(0x300).rw(m_pit[1], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
343 	map(0xd008, 0xd00b).mirror(0x300).rw(m_pit[2], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
344 	map(0xd00c, 0xd00f).mirror(0x300).rw(m_pit[3], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
345 	map(0xd010, 0xd013).mirror(0x300).rw(m_pit[4], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
346 	map(0xd014, 0xd017).mirror(0x300).rw(m_pit[5], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
347 	map(0xd018, 0xd018).mirror(0x303).w(FUNC(korg_dssmsrk_state::dmaram_lsb_w));
348 	map(0xd01c, 0xd01c).mirror(0x303).w(FUNC(korg_dssmsrk_state::dmaram_msb_w));
349 	map(0xd020, 0xd027).mirror(0x318).rw(FUNC(korg_dssmsrk_state::klm782_ga3_1_r), FUNC(korg_dssmsrk_state::klm782_ga3_1_w));
350 	map(0xd040, 0xd047).mirror(0x318).rw(FUNC(korg_dssmsrk_state::klm782_ga3_2_r), FUNC(korg_dssmsrk_state::klm782_ga3_2_w));
351 	map(0xd060, 0xd061).mirror(0x31e).rw(FUNC(korg_dssmsrk_state::klm782_ga1_r), FUNC(korg_dssmsrk_state::klm782_ga1_w));
352 	map(0xd080, 0xd08f).mirror(0x310).rw(FUNC(korg_dssmsrk_state::klm782_ga2_1_r), FUNC(korg_dssmsrk_state::klm782_ga2_1_w));
353 	map(0xd0a0, 0xd0af).mirror(0x310).rw(FUNC(korg_dssmsrk_state::klm782_ga2_2_r), FUNC(korg_dssmsrk_state::klm782_ga2_2_w));
354 	map(0xd0c0, 0xd0c0).mirror(0x31f).r(FUNC(korg_dssmsrk_state::dmaram_lsb_r));
355 	map(0xd0e0, 0xd0e0).mirror(0x31f).r(FUNC(korg_dssmsrk_state::dmaram_msb_r));
356 	map(0xd400, 0xd400).mirror(0x3fe).w(m_latch[0], FUNC(generic_latch_8_device::write));
357 	map(0xd800, 0xd800).mirror(0x3fe).r(m_latch[1], FUNC(generic_latch_8_device::read));
358 	map(0xdc00, 0xdc01).mirror(0x3fe).rw(FUNC(korg_dss1_state::fdc_r), FUNC(korg_dss1_state::fdc_w));
359 	map(0xe000, 0xffff).ram();
360 }
361 
msrk_map(address_map & map)362 void korg_dssmsrk_state::msrk_map(address_map &map)
363 {
364 	map.global_mask(0x3ffff);
365 	map(0x00000, 0x07fff).rom().region("klm780", 0);
366 	map(0x08000, 0x0bfff).ram();
367 	map(0x0c000, 0x0c0ff).mirror(0x200).rw(m_io1, FUNC(i8155_device::memory_r), FUNC(i8155_device::memory_w));
368 	map(0x0c100, 0x0c107).mirror(0x2f8).rw(m_io1, FUNC(i8155_device::io_r), FUNC(i8155_device::io_w));
369 	map(0x0c400, 0x0c403).mirror(0x3fc).rw(m_io2, FUNC(i8255_device::read), FUNC(i8255_device::write));
370 	//map(0x0cc00, 0x0cc1f).mirror(0x3e0).w(FUNC(korg_dssmsrk_state::msrk_ga_w));
371 	map(0x0d000, 0x0d003).mirror(0x300).rw(m_pit[0], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
372 	map(0x0d004, 0x0d007).mirror(0x300).rw(m_pit[1], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
373 	map(0x0d008, 0x0d00b).mirror(0x300).rw(m_pit[2], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
374 	map(0x0d00c, 0x0d00f).mirror(0x300).rw(m_pit[3], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
375 	map(0x0d010, 0x0d013).mirror(0x300).rw(m_pit[4], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
376 	map(0x0d014, 0x0d017).mirror(0x300).rw(m_pit[5], FUNC(pit8253_device::read), FUNC(pit8253_device::write));
377 	map(0x0d018, 0x0d018).mirror(0x303).w(FUNC(korg_dssmsrk_state::dmaram_lsb_w));
378 	map(0x0d01c, 0x0d01c).mirror(0x303).w(FUNC(korg_dssmsrk_state::dmaram_msb_w));
379 	map(0x0d020, 0x0d027).mirror(0x318).rw(FUNC(korg_dssmsrk_state::klm782_ga3_1_r), FUNC(korg_dssmsrk_state::klm782_ga3_1_w));
380 	map(0x0d040, 0x0d047).mirror(0x318).rw(FUNC(korg_dssmsrk_state::klm782_ga3_2_r), FUNC(korg_dssmsrk_state::klm782_ga3_2_w));
381 	map(0x0d060, 0x0d061).mirror(0x31e).rw(FUNC(korg_dssmsrk_state::klm782_ga1_r), FUNC(korg_dssmsrk_state::klm782_ga1_w));
382 	map(0x0d080, 0x0d08f).mirror(0x310).rw(FUNC(korg_dssmsrk_state::klm782_ga2_1_r), FUNC(korg_dssmsrk_state::klm782_ga2_1_w));
383 	map(0x0d0a0, 0x0d0af).mirror(0x310).rw(FUNC(korg_dssmsrk_state::klm782_ga2_2_r), FUNC(korg_dssmsrk_state::klm782_ga2_2_w));
384 	map(0x0d0c0, 0x0d0c0).mirror(0x31f).r(FUNC(korg_dssmsrk_state::dmaram_lsb_r));
385 	map(0x0d0e0, 0x0d0e0).mirror(0x31f).r(FUNC(korg_dssmsrk_state::dmaram_msb_r));
386 	map(0x0d400, 0x0d400).mirror(0x3fe).w(m_latch[0], FUNC(generic_latch_8_device::write));
387 	map(0x0d800, 0x0d800).mirror(0x3fe).r(m_latch[1], FUNC(generic_latch_8_device::read));
388 	map(0x0e000, 0x0ffff).ram();
389 	map(0x10000, 0x17fff).mirror(0x8000).rom().region("klm780", 0x8000);
390 	map(0x30000, 0x3ffff).rom().region("msrk", 0);
391 }
392 
msrk_io_map(address_map & map)393 void korg_dssmsrk_state::msrk_io_map(address_map &map)
394 {
395 	map(0xc800, 0xc807).mirror(0x3f8).rw(m_scsic, FUNC(ncr53c80_device::read), FUNC(ncr53c80_device::write));
396 	map(0xdc00, 0xdc01).mirror(0x3fe).rw(FUNC(korg_dssmsrk_state::fdc_r), FUNC(korg_dssmsrk_state::fdc_w));
397 }
398 
cpu2_map(address_map & map)399 void korg_dss1_state::cpu2_map(address_map &map)
400 {
401 	map(0x0000, 0x001f).m(m_cpu2, FUNC(hd6303x_cpu_device::hd6301x_io)); // FIXME: internalize this
402 	map(0x0040, 0x00ff).ram(); // FIXME: internalize this
403 	map(0x0100, 0x0100).mirror(0x3cff).w(FUNC(korg_dss1_state::da_lsb_w));
404 	map(0x0200, 0x0200).mirror(0x3cff).w(FUNC(korg_dss1_state::da_msb_w));
405 	map(0x0300, 0x0300).mirror(0x3cff).r(m_latch[0], FUNC(generic_latch_8_device::read));
406 	map(0x0300, 0x0300).mirror(0x3cff).w(m_latch[1], FUNC(generic_latch_8_device::write));
407 	map(0x4000, 0x4000).mirror(0x3fff).rw(FUNC(korg_dss1_state::kbd_r), FUNC(korg_dss1_state::kbd_w));
408 	map(0x8000, 0x9fff).mirror(0x2000).ram();
409 	map(0xc000, 0xffff).rom().region("klm781", 0);
410 }
411 
412 
INPUT_PORTS_START(dss1)413 static INPUT_PORTS_START(dss1)
414 INPUT_PORTS_END
415 
416 static void dss1_floppies(device_slot_interface &device)
417 {
418 	device.option_add("35dd", FLOPPY_35_DD);
419 }
420 
palette_init_dss1(palette_device & palette)421 void korg_dss1_state::palette_init_dss1(palette_device &palette)
422 {
423 	palette.set_pen_color(0, rgb_t(131, 136, 139));
424 	palette.set_pen_color(1, rgb_t( 92,  83,  88));
425 }
426 
klm780(machine_config & config)427 void korg_dss1_state::klm780(machine_config &config)
428 {
429 	I8085A(config, m_cpu1, 10_MHz_XTAL); // uPD8085AC-2
430 	m_cpu1->set_addrmap(AS_PROGRAM, &korg_dss1_state::cpu1_map);
431 
432 	I8155(config, m_io1, 10_MHz_XTAL / 2); // uPD8155HC-2
433 	m_io1->out_to_callback().set_inputline(m_cpu1, I8085_RST75_LINE);
434 	m_io1->in_pa_callback().set(m_lcdc, FUNC(hd44780_device::db_r));
435 	m_io1->out_pa_callback().set(m_lcdc, FUNC(hd44780_device::db_w));
436 	m_io1->out_pb_callback().set(FUNC(korg_dss1_state::panel_led_w));
437 	m_io1->out_pc_callback().set(m_lcdc, FUNC(hd44780_device::e_w)).bit(0);
438 	m_io1->out_pc_callback().append(m_lcdc, FUNC(hd44780_device::rw_w)).bit(1);
439 	m_io1->out_pc_callback().append(m_lcdc, FUNC(hd44780_device::rs_w)).bit(2);
440 	m_io1->out_pc_callback().append(m_fdc, FUNC(upd765a_device::reset_w)).bit(3).invert();
441 	m_io1->out_pc_callback().append(FUNC(korg_dss1_state::fdc_tc_w)).bit(4);
442 	m_io1->out_pc_callback().append(FUNC(korg_dss1_state::sed9420c_trgin_w)).bit(5);
443 
444 	I8255(config, m_io2); // uPD8255AC-2
445 	m_io2->out_pc_callback().set(FUNC(korg_dss1_state::mode_select_w));
446 
447 	UPD765A(config, m_fdc, 16_MHz_XTAL / 4, true, true); // uPD765AC; clocked through SED9420C
448 	m_fdc->intrq_wr_callback().set_inputline(m_cpu1, I8085_INTR_LINE);
449 	FLOPPY_CONNECTOR(config, "fdc:0", dss1_floppies, "35dd", floppy_image_device::default_floppy_formats).enable_sound(true);
450 	FLOPPY_CONNECTOR(config, "fdc:1", dss1_floppies, nullptr, floppy_image_device::default_floppy_formats).enable_sound(true);
451 
452 	GENERIC_LATCH_8(config, m_latch[0]);
453 	m_latch[0]->data_pending_callback().set_inputline(m_cpu1, I8085_RST65_LINE).invert();
454 
455 	GENERIC_LATCH_8(config, m_latch[1]);
456 	m_latch[1]->data_pending_callback().set_inputline(m_cpu1, I8085_RST55_LINE);
457 
458 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD));
459 	screen.set_refresh_hz(60);
460 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
461 	screen.set_screen_update("lcdc", FUNC(hd44780_device::screen_update));
462 	screen.set_size(6*20, 8*2);
463 	screen.set_visarea_full();
464 	screen.set_palette("palette");
465 
466 	PALETTE(config, "palette", FUNC(korg_dss1_state::palette_init_dss1), 2);
467 
468 	HD44780(config, m_lcdc, 0);
469 	m_lcdc->set_lcd_size(2, 20);
470 	m_lcdc->set_pixel_update_cb(FUNC(korg_dss1_state::lcd_pixel_update));
471 }
472 
klm781(machine_config & config)473 void korg_dss1_state::klm781(machine_config &config)
474 {
475 	HD6303X(config, m_cpu2, 8_MHz_XTAL); // HD63B03X
476 	m_cpu2->set_addrmap(AS_PROGRAM, &korg_dss1_state::cpu2_map);
477 	m_cpu2->out_p2_cb().set(FUNC(korg_dss1_state::vcf_vca_ef_w));
478 	m_cpu2->in_p5_cb().set(FUNC(korg_dss1_state::cpu2_p5_r));
479 	m_cpu2->out_p6_cb().set(FUNC(korg_dss1_state::ad_select_w));
480 	m_cpu2->out_ser_tx_cb().set("midi_out", FUNC(midi_port_device::write_txd));
481 
482 	MIDI_PORT(config, "midi_in", midiin_slot, "midiin");
483 	MIDI_PORT(config, "midi_out", midiout_slot, "midiout");
484 }
485 
klm782(machine_config & config)486 void korg_dss1_state::klm782(machine_config &config)
487 {
488 	PIT8253(config, m_pit[0]);
489 	PIT8253(config, m_pit[1]);
490 	PIT8253(config, m_pit[2]);
491 	PIT8253(config, m_pit[3]);
492 	PIT8253(config, m_pit[4]);
493 	PIT8253(config, m_pit[5]);
494 }
495 
dss1(machine_config & config)496 void korg_dss1_state::dss1(machine_config &config)
497 {
498 	klm780(config);
499 	klm781(config);
500 	klm782(config);
501 }
502 
dssmsrk(machine_config & config)503 void korg_dssmsrk_state::dssmsrk(machine_config &config)
504 {
505 	V40(config, m_msrkcpu, 16_MHz_XTAL); // uPD70208
506 	m_msrkcpu->set_addrmap(AS_PROGRAM, &korg_dssmsrk_state::msrk_map);
507 	m_msrkcpu->set_addrmap(AS_IO, &korg_dssmsrk_state::msrk_io_map);
508 	m_msrkcpu->out_hreq_cb().set_inputline(m_msrkcpu, INPUT_LINE_HALT);
509 	m_msrkcpu->out_hreq_cb().append(m_msrkcpu, FUNC(v40_device::hack_w));
510 	m_msrkcpu->in_ior_cb<0>().set(m_fdc, FUNC(upd765a_device::dma_r));
511 	m_msrkcpu->out_iow_cb<0>().set(m_fdc, FUNC(upd765a_device::dma_w));
512 	m_msrkcpu->in_ior_cb<1>().set(m_scsic, FUNC(ncr53c80_device::dma_r));
513 	m_msrkcpu->out_iow_cb<1>().set(m_scsic, FUNC(ncr53c80_device::dma_w));
514 	m_msrkcpu->out_eop_cb().set(m_fdc, FUNC(upd765a_device::tc_line_w));
515 	//m_msrkcpu->out_eop_cb().append(m_scsic, FUNC(ncr53c80_device::eop_w));
516 	m_msrkcpu->out_handler<1>().set(m_msrkcpu, FUNC(v40_device::tclk_w));
517 
518 	klm780(config);
519 	config.device_remove("cpu1");
520 	m_io1->set_clock(16_MHz_XTAL / 4); // CLKOUT divider not verified
521 	m_io1->out_to_callback().set_inputline(m_msrkcpu, INPUT_LINE_IRQ1);
522 	m_fdc->intrq_wr_callback().set_inputline(m_msrkcpu, INPUT_LINE_IRQ6);
523 	m_fdc->drq_wr_callback().set(m_msrkcpu, FUNC(v40_device::dreq_w<0>)); // FIXME: delayed by 74HCT164
524 	m_latch[0]->data_pending_callback().set_inputline(m_msrkcpu, INPUT_LINE_IRQ2).invert();
525 	m_latch[1]->data_pending_callback().set_inputline(m_msrkcpu, INPUT_LINE_IRQ3);
526 
527 	klm781(config);
528 	klm782(config);
529 
530 	NSCSI_BUS(config, "scsi");
531 	NSCSI_CONNECTOR(config, "scsi:0", default_scsi_devices, nullptr);
532 	NSCSI_CONNECTOR(config, "scsi:1", default_scsi_devices, nullptr);
533 	NSCSI_CONNECTOR(config, "scsi:2", default_scsi_devices, nullptr);
534 	NSCSI_CONNECTOR(config, "scsi:3", default_scsi_devices, nullptr);
535 	NSCSI_CONNECTOR(config, "scsi:4", default_scsi_devices, nullptr);
536 	NSCSI_CONNECTOR(config, "scsi:5", default_scsi_devices, nullptr);
537 	NSCSI_CONNECTOR(config, "scsi:6", default_scsi_devices, nullptr);
538 	NSCSI_CONNECTOR(config, "scsi:7").option_set("scsic", NCR53C80).machine_config([this] (device_t *device) {
539 		auto &scsic = downcast<ncr53c80_device &>(*device); // 48-pin DIP
540 		scsic.irq_handler().set_inputline(m_msrkcpu, INPUT_LINE_IRQ4);
541 		scsic.drq_handler().set(m_msrkcpu, FUNC(v40_device::dreq_w<1>));
542 	});
543 }
544 
545 
546 ROM_START(dss1)
547 	ROM_REGION(0x12000, "klm780", 0)
548 	ROM_SYSTEM_BIOS(0, "v36", "Version 36")
549 	ROM_SYSTEM_BIOS(1, "v34", "Version 34")
550 	ROM_SYSTEM_BIOS(2, "v31", "Version 31")
551 	ROMX_LOAD("860336.ic19", 0x00000, 0x8000, CRC(44515595) SHA1(f4873c219cda4158506acbfb06abb8a72224049d), ROM_BIOS(0)) // 27256 (bank 0)
552 	ROMX_LOAD("860334.ic19", 0x00000, 0x8000, CRC(076c5956) SHA1(752a26761c63e46f1a6efa1b19a60bafa7a5bc42), ROM_BIOS(1))
553 	ROMX_LOAD("860331.ic19", 0x00000, 0x8000, CRC(fcefcc79) SHA1(2332ffcbbe61d460d1929e65cbaa01e0766ba51f), ROM_BIOS(2))
554 	ROMX_LOAD("860436.ic18", 0x08000, 0x8000, CRC(c8830cf9) SHA1(2bcdcfd9afc9e6b2078afdf9c027622b705780a9), ROM_BIOS(0)) // 27256 (bank 1)
555 	ROMX_LOAD("860434.ic18", 0x08000, 0x8000, CRC(5b253cac) SHA1(20507004ead025b03b2f7a31af87c9dae968e8eb), ROM_BIOS(1))
556 	ROMX_LOAD("860431.ic18", 0x08000, 0x8000, CRC(ed0e4238) SHA1(b7e56a3f414dd13bb6b9ef40262c6b93e52f5254), ROM_BIOS(2))
557 	ROMX_LOAD("860536.ic12", 0x10000, 0x2000, CRC(547388a1) SHA1(4c3dfaebe48f441955f2a6bd42dd4d30eb63b913), ROM_BIOS(0)) // 2764 (not banked)
558 	ROMX_LOAD("860534.ic12", 0x10000, 0x2000, CRC(9b5792b7) SHA1(e031d7f3a5c4f67399a75050bd02343ed6f8926d), ROM_BIOS(1))
559 	ROMX_LOAD("860531.ic12", 0x10000, 0x2000, CRC(a8173858) SHA1(e1d898594ad9e65a95478cf1ec14b9b3cafd0159), ROM_BIOS(2))
560 
561 	ROM_REGION(0x4000, "klm781", 0)
562 	ROMX_LOAD("860236.ic15", 0x0000, 0x4000, CRC(b4ea379a) SHA1(66b3586b6fb7fa5edf70a933e49f626452ffe006), ROM_BIOS(0))
563 	ROMX_LOAD("860234.ic15", 0x0000, 0x4000, CRC(5766cdb5) SHA1(ded6c5758fbf90fd65b80d5b08e72349d38555d2), ROM_BIOS(1))
564 	ROMX_LOAD("860231.ic15", 0x0000, 0x4000, CRC(2559b3aa) SHA1(8b7998ffc24405d0ca08a93c23c18f97aff74d16), ROM_BIOS(2))
565 ROM_END
566 
567 ROM_START(dssmsrk)
568 	ROM_REGION(0x10000, "klm780", 0)
569 	ROM_LOAD("113000.ic18", 0x00000, 0x8000, CRC(6fa13d52) SHA1(8de0e4e8ac4afe0d0fb116b6c8b64739ba81a722))
570 	ROM_LOAD("113001.ic19", 0x08000, 0x8000, CRC(ec7e2473) SHA1(dacea4a545ce3ed1fc11d9025e86dfd1d32a222c))
571 	// EPROM at IC12 is replaced with D4364C-15 SRAM
572 
573 	ROM_REGION(0x4000, "klm781", 0)
574 	ROM_LOAD("860236.ic15", 0x0000, 0x4000, CRC(b4ea379a) SHA1(66b3586b6fb7fa5edf70a933e49f626452ffe006))
575 
576 	ROM_REGION(0x10000, "msrk", 0)
577 	ROM_LOAD("113003.u30", 0x00000, 0x10000, CRC(81b17db3) SHA1(af8a3167e06641d41b9b9e6e024335c2eb827274))
578 ROM_END
579 
580 SYST(1986, dss1,    0,    0, dss1,    dss1, korg_dss1_state,    empty_init, "Korg",               "DSS-1 Digital Sampling Synthesizer",                        MACHINE_IS_SKELETON)
581 SYST(1987, dssmsrk, dss1, 0, dssmsrk, dss1, korg_dssmsrk_state, empty_init, "Korg / Sound Logic", "DSS-1 Digital Sampling Synthesizer (Memory/SCSI Retrofit)", MACHINE_IS_SKELETON)
582