1 // license:BSD-3-Clause
2 // copyright-holders: 68bit
3 /******************************************************************************
4 
5 Motorola Evaluation Kit 6802 D5 - MEK6802D5
6 
7 Memory map
8 
9 Range    Short  Description
10 
11 0000-dfff RAM   Either 128 bytes on board, or external
12 
13 e000-e3ff RAM   Static RAM, 1K.
14 e400-e47f RAM   System RAM
15 e480-e483 PIA   User PIA
16 e484-e487 PIA   System PIA
17 
18 e700-e701 ACIA  System ACIA.
19 
20 e800-efff ROM   Optional user ROM
21 f000-f7ff ROM   D5BUG monitor ROM
22 f800-ffff ROM   D5BUG (mirror), or optional user ROM.
23 
24 
25 A 1K or 2K optional user ROM or EPROM can be installed and mapped to either
26 0xe800-0xefff, or to 0xf800-0xffff, set via jumper 3.
27 TODO implement this user ROM.
28 
29 The board has provision for an ACIA, and the documentation mentions that it is
30 not used when there is a keypad, and the keypad is removable. However the
31 D5BUG monitor has no support for this ACIA. Was there an alternative official
32 monitor that used this ACIA?
33 
34 
35 Keypad commands:
36 
37 RS (Reset)  Reset, wired to the CPU reset line
38 EX (Escape) Typically aborts user program.
39 M (Memory display/change)
40   Digits 5 and 6 show the actual data at the address.
41   G  - increase the address.
42   M  - decreases the address.
43   FS - Offset calculation. Enter address, then press 'GO'.
44     GO - stores the offset and returns to memory display and increased the address.
45     FC - return to memory display, without storing the offset.
46     M  - return to memory display, after a BAD offset.
47   EX - exits memory display.
48 RD (Register display/alter)
49   G   - advance to next register.
50   M   - previous register.
51   T/B - trace a single instruction
52   EX  - exits register display.
53 GO to user program.
54   If no address if entered then it uses the pseudo PC, it continues.
55   Enter the address and press 'Go' to use that entered address.
56   It firstly checks that there is RAM at the stack pointer.
57 FS T/B - Breakpoint editor
58   GO - advance to next breakpoing, up to 8, then loops.
59   FS - insert a breakpoint
60   FC - deactivate breakpoint
61   EX - exits breakpoing editor.
62 P/L (Punch tape)
63   At the 'bb' prompt enter the beginning address of the data, then 'GO'.
64   At the 'EE' prompt enter the last address of the data.
65   Start the tape and press GO. There is a 30 second leader of $ff.
66 FS P/L (Load from tape)
67 FS RD (Verify from tape)
68 FS 0 to F
69   One of 16 user defined functions. Press FS then one number key 0 to F.
70   A pointer to a table of 16 function addresses should be set at 0xe43f.
71 
72 ******************************************************************************/
73 
74 #include "emu.h"
75 #include "cpu/m6800/m6800.h"
76 #include "machine/input_merger.h"
77 #include "machine/6821pia.h"
78 #include "machine/6850acia.h"
79 #include "machine/mc14411.h"
80 #include "machine/clock.h"
81 #include "machine/timer.h"
82 #include "video/pwm.h"
83 #include "sound/wave.h"
84 #include "speaker.h"
85 #include "bus/rs232/rs232.h"
86 #include "machine/terminal.h"
87 #include "imagedev/cassette.h"
88 #include "imagedev/snapquik.h"
89 #include "render.h"
90 #include "mekd5.lh"
91 
92 #define XTAL_MEKD5 3.579545_MHz_XTAL
93 
94 class mekd5_state : public driver_device
95 {
96 public:
97 	enum
98 	{
99 		TIMER_TRACE
100 	};
101 
mekd5_state(const machine_config & mconfig,device_type type,const char * tag)102 	mekd5_state(const machine_config &mconfig, device_type type, const char *tag)
103 		: driver_device(mconfig, type, tag)
104 		, m_maincpu(*this, "maincpu")
105 		, m_kpd_pia(*this, "kpd_pia")
106 		, m_user_pia(*this, "user_pia")
107 		, m_display(*this, "display")
108 		, m_brg(*this, "brg")
109 		, m_baud_rate(*this, "BAUD_RATE")
110 		, m_acia(*this, "acia")
111 		, m_cass(*this, "cassette")
112 		, m_keypad_columns(*this, "COL%u", 0)
113 	{ }
114 
115 	void mekd5(machine_config &config);
116 	void init_mekd5();
117 
118 	DECLARE_WRITE_LINE_MEMBER(reset_key_w);
119 	DECLARE_INPUT_CHANGED_MEMBER(keypad_changed);
120 
121 private:
122 	DECLARE_WRITE_LINE_MEMBER(trace_timer_clear_w);
123 
124 	DECLARE_READ_LINE_MEMBER(keypad_cb1_r);
125 	uint8_t keypad_key_r();
126 	void led_digit_w(uint8_t data);
127 	void led_segment_w(uint8_t data);
128 	DECLARE_READ_LINE_MEMBER(kansas_r);
129 
130 	// Clocks
131 	DECLARE_WRITE_LINE_MEMBER(write_f1_clock);
132 	DECLARE_WRITE_LINE_MEMBER(write_f3_clock);
133 	DECLARE_WRITE_LINE_MEMBER(write_f5_clock);
134 	DECLARE_WRITE_LINE_MEMBER(write_f7_clock);
135 	DECLARE_WRITE_LINE_MEMBER(write_f9_clock);
136 	DECLARE_WRITE_LINE_MEMBER(write_f13_clock);
137 
138 	void mekd5_mem(address_map &map);
139 
140 	bool keypad_key_pressed();
141 
142 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
143 	uint8_t m_segment;
144 	uint8_t m_digit;
145 	virtual void machine_start() override;
146 	virtual void machine_reset() override;
147 	required_device<m6802_cpu_device> m_maincpu;
148 	required_device<pia6821_device> m_kpd_pia;
149 	required_device<pia6821_device> m_user_pia;
150 	required_device<pwm_display_device> m_display;
151 	required_device<mc14411_device> m_brg;
152 	required_ioport m_baud_rate;
153 	required_device<acia6850_device> m_acia;
154 	required_device<cassette_image_device> m_cass;
155 	required_ioport_array<4> m_keypad_columns;
156 };
157 
158 
159 
160 /***********************************************************
161 
162     Address Map
163 
164 ************************************************************/
165 
mekd5_mem(address_map & map)166 void mekd5_state::mekd5_mem(address_map &map)
167 {
168 	map(0x0000, 0xdfff).ram();
169 	map(0xe000, 0xe3ff).ram();
170 	map(0xe400, 0xe47f).ram();
171 
172 	map(0xe480, 0xe483).mirror(0x0378).rw(m_user_pia, FUNC(pia6821_device::read), FUNC(pia6821_device::write));
173 	map(0xe484, 0xe487).mirror(0x0378).rw(m_kpd_pia, FUNC(pia6821_device::read), FUNC(pia6821_device::write));
174 
175 	map(0xe700, 0xe701).mirror(0x003e).rw(m_acia, FUNC(acia6850_device::read), FUNC(acia6850_device::write));
176 
177 	/* D5BUG ROM */
178 	map(0xf000, 0xf7ff).rom().mirror(0x0800);
179 }
180 
181 /***********************************************************
182 
183     Keys
184 
185 ************************************************************/
186 
187 static INPUT_PORTS_START(mekd5)
188 
189 	// RESET is not wired to the key matrix.
190 	PORT_START("RESET")
PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF,mekd5_state,reset_key_w)191 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("RS") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, mekd5_state, reset_key_w)
192 
193 	PORT_START("COL0")
194 	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("M") PORT_CODE(KEYCODE_M)
195 	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("FS") PORT_CODE(KEYCODE_S)
196 	PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("7") PORT_CODE(KEYCODE_7)
197 	PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("4") PORT_CODE(KEYCODE_4)
198 	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("1") PORT_CODE(KEYCODE_1)
199 	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("0") PORT_CODE(KEYCODE_0)
200 
201 	PORT_START("COL1")
202 	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("EX") PORT_CODE(KEYCODE_X)
203 	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("FC") PORT_CODE(KEYCODE_W)
204 	PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("8") PORT_CODE(KEYCODE_8)
205 	PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("5") PORT_CODE(KEYCODE_5)
206 	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("2") PORT_CODE(KEYCODE_2)
207 	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("F") PORT_CODE(KEYCODE_F)
208 
209 	PORT_START("COL2")
210 	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("RD") PORT_CODE(KEYCODE_R)
211 	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("P/L") PORT_CODE(KEYCODE_P)
212 	PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("9") PORT_CODE(KEYCODE_9)
213 	PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("6") PORT_CODE(KEYCODE_6)
214 	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("3") PORT_CODE(KEYCODE_3)
215 	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("E") PORT_CODE(KEYCODE_E)
216 
217 	PORT_START("COL3")
218 	PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("GO") PORT_CODE(KEYCODE_G)
219 	PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("T/B") PORT_CODE(KEYCODE_T)
220 	PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("A") PORT_CODE(KEYCODE_A)
221 	PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("B") PORT_CODE(KEYCODE_B)
222 	PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("C") PORT_CODE(KEYCODE_C)
223 	PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, mekd5_state, keypad_changed, 0) PORT_NAME("D") PORT_CODE(KEYCODE_D)
224 
225 	/* RS232 baud rates available via J5. */
226 	PORT_START("BAUD_RATE")
227 	PORT_CONFNAME(0x3f, 1, "RS232 Baud Rate")
228 	PORT_CONFSETTING(0x20, "110")
229 	PORT_CONFSETTING(0x10, "300")
230 	PORT_CONFSETTING(0x08, "1200")
231 	PORT_CONFSETTING(0x04, "2400")
232 	PORT_CONFSETTING(0x02, "4800")
233 	PORT_CONFSETTING(0x01, "9600")
234 
235 INPUT_PORTS_END
236 
237 /***********************************************************
238 
239     Trace timer
240 
241 ************************************************************/
242 
243 void mekd5_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
244 {
245 	switch (id)
246 	{
247 	case TIMER_TRACE:
248 		// CB2 is programmed to trigger on the falling edge, so after
249 		// a count of 16. CB2 input comes from a counter, so the duty
250 		// cycle should be 50/50, but it makes no difference to rise
251 		// and fall here.
252 		m_kpd_pia->cb2_w(1);
253 		m_kpd_pia->cb2_w(0);
254 		break;
255 	default:
256 		throw emu_fatalerror("Unknown id in mekd5_state::device_timer");
257 	}
258 }
259 
260 
261 // Expect a delay of 16 cycles.  However the 6800 cycle model appears to
262 // account for the store that writes here as occuring at the start of that
263 // instruction adding 5 cycles to give an effective 21 cycles. TODO adjust
264 // this back to 16 cycles when the 6800 cycle timing becomes more accurate.
WRITE_LINE_MEMBER(mekd5_state::trace_timer_clear_w)265 WRITE_LINE_MEMBER(mekd5_state::trace_timer_clear_w)
266 {
267 	if (state)
268 		m_kpd_pia->cb2_w(0);
269 	else
270 		timer_set(attotime::from_ticks(21, XTAL_MEKD5 / 4), TIMER_TRACE);
271 }
272 
273 /***********************************************************
274 
275     Keypad
276 
277 ************************************************************/
278 
279 // Keypad input is disable on views with the RS232 input.
280 
WRITE_LINE_MEMBER(mekd5_state::reset_key_w)281 WRITE_LINE_MEMBER(mekd5_state::reset_key_w)
282 {
283 	uint8_t view = machine().render().first_target()->view();
284 	if (view > 1) return;
285 
286 	m_maincpu->set_input_line(INPUT_LINE_RESET, state ? CLEAR_LINE : ASSERT_LINE);
287 
288 	// TODO reset other devices.
289 }
290 
291 
keypad_key_pressed()292 bool mekd5_state::keypad_key_pressed()
293 {
294 	uint8_t view = machine().render().first_target()->view();
295 	if (view > 1) return 0;
296 
297 	return (m_keypad_columns[0]->read() & m_digit) ||
298 		(m_keypad_columns[1]->read() & m_digit) ||
299 		(m_keypad_columns[2]->read() & m_digit) ||
300 		(m_keypad_columns[3]->read() & m_digit);
301 }
302 
INPUT_CHANGED_MEMBER(mekd5_state::keypad_changed)303 INPUT_CHANGED_MEMBER(mekd5_state::keypad_changed)
304 {
305 	m_kpd_pia->cb1_w(mekd5_state::keypad_key_pressed());
306 }
307 
READ_LINE_MEMBER(mekd5_state::keypad_cb1_r)308 READ_LINE_MEMBER(mekd5_state::keypad_cb1_r)
309 {
310 	return mekd5_state::keypad_key_pressed();
311 }
312 
keypad_key_r()313 uint8_t mekd5_state::keypad_key_r()
314 {
315 	uint8_t view = machine().render().first_target()->view();
316 	if (view > 1) return m_segment;
317 
318 	uint8_t mux = (m_digit & 0xc0) >> 6;
319 	uint8_t i = (m_keypad_columns[mux]->read() & m_digit) ? 0 : 0x80;
320 
321 	return i | m_segment;
322 }
323 
324 /***********************************************************
325 
326     Seven segment LED display, and cassette
327 
328 ************************************************************/
329 
330 // PA
led_segment_w(uint8_t data)331 void mekd5_state::led_segment_w(uint8_t data)
332 {
333 	m_segment = data & 0x7f;
334 	m_display->matrix(m_digit & 0x3f, ~m_segment);
335 }
336 
337 // PB
led_digit_w(uint8_t data)338 void mekd5_state::led_digit_w(uint8_t data)
339 {
340 	m_digit = data;
341 	m_display->matrix(m_digit & 0x3f, ~m_segment);
342 	// PB7 also drives the cassette output.
343 	m_cass->output(BIT(data, 7) ? -1.0 : +1.0);
344 	// Update the keypad pressed output which depends on m_digit.
345 	m_kpd_pia->cb1_w(mekd5_state::keypad_key_pressed());
346 }
347 
READ_LINE_MEMBER(mekd5_state::kansas_r)348 READ_LINE_MEMBER(mekd5_state::kansas_r)
349 {
350 	uint8_t data = m_cass->input() > +0.0;
351 	return data;
352 }
353 
354 
355 /***********************************************************
356 
357   ACIA clocks
358 
359 ************************************************************/
360 
WRITE_LINE_MEMBER(mekd5_state::write_f1_clock)361 WRITE_LINE_MEMBER(mekd5_state::write_f1_clock)
362 {
363 	if (BIT(m_baud_rate->read(), 0))
364 	{
365 		m_acia->write_txc(state);
366 		m_acia->write_rxc(state);
367 	}
368 }
369 
WRITE_LINE_MEMBER(mekd5_state::write_f3_clock)370 WRITE_LINE_MEMBER(mekd5_state::write_f3_clock)
371 {
372 	if (BIT(m_baud_rate->read(), 1))
373 	{
374 		m_acia->write_txc(state);
375 		m_acia->write_rxc(state);
376 	}
377 }
378 
WRITE_LINE_MEMBER(mekd5_state::write_f5_clock)379 WRITE_LINE_MEMBER(mekd5_state::write_f5_clock)
380 {
381 	if (BIT(m_baud_rate->read(), 2))
382 	{
383 		m_acia->write_txc(state);
384 		m_acia->write_rxc(state);
385 	}
386 }
387 
WRITE_LINE_MEMBER(mekd5_state::write_f7_clock)388 WRITE_LINE_MEMBER(mekd5_state::write_f7_clock)
389 {
390 	if (BIT(m_baud_rate->read(), 3))
391 	{
392 		m_acia->write_txc(state);
393 		m_acia->write_rxc(state);
394 	}
395 }
396 
WRITE_LINE_MEMBER(mekd5_state::write_f9_clock)397 WRITE_LINE_MEMBER(mekd5_state::write_f9_clock)
398 {
399 	if (BIT(m_baud_rate->read(), 4))
400 	{
401 		m_acia->write_txc(state);
402 		m_acia->write_rxc(state);
403 	}
404 }
405 
WRITE_LINE_MEMBER(mekd5_state::write_f13_clock)406 WRITE_LINE_MEMBER(mekd5_state::write_f13_clock)
407 {
408 	if (BIT(m_baud_rate->read(), 5))
409 	{
410 		m_acia->write_txc(state);
411 		m_acia->write_rxc(state);
412 	}
413 }
414 
415 
416 /***********************************************************
417 
418 ************************************************************/
419 
init_mekd5()420 void mekd5_state::init_mekd5()
421 {
422 }
423 
machine_start()424 void mekd5_state::machine_start()
425 {
426 	save_item(NAME(m_segment));
427 	save_item(NAME(m_digit));
428 }
429 
machine_reset()430 void mekd5_state::machine_reset()
431 {
432 	// Trace timer out low.
433 	m_kpd_pia->cb2_w(0);
434 
435 	m_brg->rsa_w(CLEAR_LINE);
436 	m_brg->rsb_w(ASSERT_LINE);
437 
438 	// /DCD and /CTS are wired low.
439 	m_acia->write_dcd(CLEAR_LINE);
440 	m_acia->write_cts(CLEAR_LINE);
441 }
442 
443 /***********************************************************
444 
445     Machine
446 
447 ************************************************************/
448 
449 static DEVICE_INPUT_DEFAULTS_START(terminal)
450 	DEVICE_INPUT_DEFAULTS("RS232_RXBAUD", 0xff, RS232_BAUD_9600)
451 	DEVICE_INPUT_DEFAULTS("RS232_TXBAUD", 0xff, RS232_BAUD_9600)
452 	DEVICE_INPUT_DEFAULTS("RS232_STARTBITS", 0xff, RS232_STARTBITS_1)
453 	DEVICE_INPUT_DEFAULTS("RS232_DATABITS", 0xff, RS232_DATABITS_8)
454 	DEVICE_INPUT_DEFAULTS("RS232_PARITY", 0xff, RS232_PARITY_NONE)
455 	DEVICE_INPUT_DEFAULTS("RS232_STOPBITS", 0xff, RS232_STOPBITS_1)
456 DEVICE_INPUT_DEFAULTS_END
457 
mekd5(machine_config & config)458 void mekd5_state::mekd5(machine_config &config)
459 {
460 	M6802(config, m_maincpu, XTAL_MEKD5);        /* 894.8 kHz clock */
461 	m_maincpu->set_ram_enable(false);
462 	m_maincpu->set_addrmap(AS_PROGRAM, &mekd5_state::mekd5_mem);
463 
464 	INPUT_MERGER_ANY_HIGH(config, "mainirq").output_handler().set_inputline(m_maincpu, M6802_IRQ_LINE);
465 	INPUT_MERGER_ANY_HIGH(config, "mainnmi").output_handler().set_inputline(m_maincpu, INPUT_LINE_NMI);
466 
467 	// LED display
468 	PWM_DISPLAY(config, m_display).set_size(6, 7);
469 	m_display->set_segmask(0x3f, 0x7f);
470 
471 	config.set_default_layout(layout_mekd5);
472 
473 	SPEAKER(config, "mono").front_center();
474 
475 	CASSETTE(config, m_cass);
476 	m_cass->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED);
477 	m_cass->add_route(ALL_OUTPUTS, "mono", 0.05);
478 
479 	// Keypad and display PIA (U23). IRQA is NC. CB2 is trace timer input.
480 	PIA6821(config, m_kpd_pia, 0);
481 	m_kpd_pia->readpa_handler().set(FUNC(mekd5_state::keypad_key_r));
482 	m_kpd_pia->writepa_handler().set(FUNC(mekd5_state::led_segment_w));
483 	m_kpd_pia->writepb_handler().set(FUNC(mekd5_state::led_digit_w));
484 	m_kpd_pia->readca1_handler().set(FUNC(mekd5_state::kansas_r));
485 	m_kpd_pia->ca2_handler().set(FUNC(mekd5_state::trace_timer_clear_w));
486 	m_kpd_pia->readcb1_handler().set(FUNC(mekd5_state::keypad_cb1_r));
487 	m_kpd_pia->irqb_handler().set("mainnmi", FUNC(input_merger_device::in_w<1>));
488 
489 	// User PIA (U9).
490 	// IRQA and IRQB can be independently jumpered to IRQ or NMI via J1.
491 	// All the I/O lines are available at the User I/O connector.
492 	PIA6821(config, m_user_pia, 0);
493 
494 	// IRQ is NC. RX and TX clk are wired together. RTS is available.
495 	// /DCD and /CTS and wired low.
496 	ACIA6850(config, m_acia, 0);
497 	m_acia->txd_handler().set("rs232", FUNC(rs232_port_device::write_txd));
498 
499 	MC14411(config, m_brg, XTAL(1'843'200));
500 	m_brg->out_f<1>().set(FUNC(mekd5_state::write_f1_clock));
501 	m_brg->out_f<3>().set(FUNC(mekd5_state::write_f3_clock));
502 	m_brg->out_f<5>().set(FUNC(mekd5_state::write_f5_clock));
503 	m_brg->out_f<7>().set(FUNC(mekd5_state::write_f7_clock));
504 	m_brg->out_f<9>().set(FUNC(mekd5_state::write_f9_clock));
505 	m_brg->out_f<13>().set(FUNC(mekd5_state::write_f13_clock));
506 
507 	rs232_port_device &rs232(RS232_PORT(config, "rs232", default_rs232_devices, "terminal"));
508 	rs232.rxd_handler().set(m_acia, FUNC(acia6850_device::write_rxd));
509 	rs232.set_option_device_input_defaults("terminal", DEVICE_INPUT_DEFAULTS_NAME(terminal));
510 }
511 
512 /***********************************************************
513 
514     ROMS
515 
516 ************************************************************/
517 
518 ROM_START(mekd5)
519 	ROM_REGION(0x10000,"maincpu",0)
520 	ROM_LOAD("d5bug.rom", 0xf000, 0x0800, CRC(67c00a2c) SHA1(ae321dbca0baf4b67d62bfec77266d9132b973bf))
521 ROM_END
522 
523 /***************************************************************************
524 
525   Game driver(s)
526 
527 ***************************************************************************/
528 
529 //    YEAR  NAME    PARENT  COMPAT  MACHINE   INPUT  CLASS        INIT        COMPANY     FULLNAME      FLAGS
530 COMP( 1980, mekd5,  0,      0,      mekd5,    mekd5, mekd5_state, init_mekd5, "Motorola", "MEK6802D5" , MACHINE_NO_SOUND )
531