1 // license:GPL-2.0+
2 // copyright-holders:Dirk Best,Paul Danials
3 /******************************************************************************************************
4 
5 Nascom 1/2/3
6 
7 Single board computer
8 
9 
10 To Do:
11 - TTY
12 - Nascom2 has two dipswitch banks, and a memory control header
13 - Nascom3 (Gemini), nothing usable found
14 
15 Cassette (nascom1):
16   It outputs a string of pulses at 1953.125Hz to indicate a 1, and blank tape for 0. This means that
17   no tape will present a 0 to the UART instead of the expected 1 (idle). Part of the cassette
18   schematic is missing, so a few liberties have been taken. The result is you can save a file and
19   load it back. Haven't found wav files on the net to test with.
20 
21 Cassette (nascom2):
22   Standard Kansas City format, switchable (with a real switch) between 300 and 1200 baud.
23 
24 *****************************************************************************************************/
25 
26 #include "emu.h"
27 
28 #include "cpu/z80/z80.h"
29 #include "imagedev/cassette.h"
30 #include "imagedev/snapquik.h"
31 #include "machine/ay31015.h"
32 #include "machine/clock.h"
33 #include "machine/ram.h"
34 #include "machine/z80pio.h"
35 
36 #include "machine/timer.h"
37 #include "speaker.h"
38 
39 #include "bus/generic/slot.h"
40 #include "bus/generic/carts.h"
41 #include "bus/nasbus/nasbus.h"
42 
43 #include "emupal.h"
44 #include "softlist.h"
45 #include "screen.h"
46 
47 
48 //**************************************************************************
49 //  TYPE DEFINITIONS
50 //**************************************************************************
51 
52 class nascom_state : public driver_device
53 {
54 public:
nascom_state(const machine_config & mconfig,device_type type,const char * tag)55 	nascom_state(const machine_config &mconfig, device_type type, const char *tag)
56 		: driver_device(mconfig, type, tag)
57 		, m_maincpu(*this, "maincpu")
58 		, m_ram(*this, RAM_TAG)
59 		, m_hd6402(*this, "hd6402")
60 		, m_cass(*this, "cassette")
61 		, m_screen(*this, "screen")
62 		, m_gfxdecode(*this, "gfxdecode")
63 		, m_palette(*this, "palette")
64 		, m_videoram(*this, "videoram")
65 		, m_gfx1_region(*this, "gfx1")
66 		, m_keyboard(*this, "KEY.%u", 0)
67 	{ }
68 
69 	void nascom(machine_config &config);
70 
71 	void init_nascom();
72 
73 protected:
74 	required_device<cpu_device> m_maincpu;
75 	required_device<ram_device> m_ram;
76 
77 	virtual void machine_reset() override;
78 
79 	uint8_t nascom1_port_00_r();
80 	void nascom1_port_00_w(uint8_t data);
81 	uint8_t nascom1_port_01_r();
82 	void nascom1_port_01_w(uint8_t data);
83 	uint8_t nascom1_port_02_r();
84 	DECLARE_READ_LINE_MEMBER(hd6402_si);
85 	DECLARE_WRITE_LINE_MEMBER(hd6402_so);
86 
87 	void screen_update(bitmap_ind16 &bitmap, const rectangle &cliprect, int char_height);
88 
89 	required_device<ay31015_device> m_hd6402;
90 	required_device<cassette_image_device> m_cass;
91 	required_device<screen_device> m_screen;
92 	required_device<gfxdecode_device> m_gfxdecode;
93 	required_device<palette_device> m_palette;
94 	required_shared_ptr<uint8_t> m_videoram;
95 	required_memory_region m_gfx1_region;
96 	required_ioport_array<8> m_keyboard;
97 
98 	int m_tape_size;
99 	uint8_t *m_tape_image;
100 	int m_tape_index;
101 	uint8_t m_kb_select;
102 	uint8_t m_kb_control;
103 	bool m_cassinbit, m_cassoutbit, m_cassold;
104 	u8 m_port00;
105 
106 	DECLARE_DEVICE_IMAGE_LOAD_MEMBER( load_nascom1_cassette );
107 	DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( unload_nascom1_cassette );
108 	template<int Dest> DECLARE_SNAPSHOT_LOAD_MEMBER( snapshot_cb );
109 };
110 
111 class nascom1_state : public nascom_state
112 {
113 public:
nascom1_state(const machine_config & mconfig,device_type type,const char * tag)114 	nascom1_state(const machine_config &mconfig, device_type type, const char *tag)
115 		: nascom_state(mconfig, type, tag)
116 	{ }
117 
118 	void nascom1(machine_config &config);
119 	uint32_t screen_update_nascom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
120 
121 private:
122 	void nascom1_io(address_map &map);
123 	void nascom1_mem(address_map &map);
124 	TIMER_DEVICE_CALLBACK_MEMBER(nascom1_kansas_r);
125 	DECLARE_WRITE_LINE_MEMBER(nascom1_kansas_w);
126 	u16 m_cass_cnt[2];
127 };
128 
129 class nascom2_state : public nascom_state
130 {
131 public:
nascom2_state(const machine_config & mconfig,device_type type,const char * tag)132 	nascom2_state(const machine_config &mconfig, device_type type, const char *tag)
133 		: nascom_state(mconfig, type, tag)
134 		, m_clock(*this, "uart_clock")
135 		, m_nasbus(*this, "nasbus")
136 		, m_socket1(*this, "socket1")
137 		, m_socket2(*this, "socket2")
138 		, m_lsw1(*this, "lsw1")
139 	{ }
140 
141 	void nascom2(machine_config &config);
142 	void nascom2c(machine_config &config);
143 
144 	void init_nascom2c();
145 
146 	DECLARE_INPUT_CHANGED_MEMBER(cass_speed);
147 
148 private:
149 	TIMER_DEVICE_CALLBACK_MEMBER(nascom2_kansas_r);
150 	DECLARE_MACHINE_RESET(nascom2);
151 	DECLARE_WRITE_LINE_MEMBER(nascom2_kansas_w);
152 	DECLARE_WRITE_LINE_MEMBER(ram_disable_w);
153 	DECLARE_WRITE_LINE_MEMBER(ram_disable_cpm_w);
154 	uint32_t screen_update_nascom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
155 
156 	image_init_result load_cart(device_image_interface &image, generic_slot_device *slot, int slot_id);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(socket1_load)157 	DECLARE_DEVICE_IMAGE_LOAD_MEMBER(socket1_load) { return load_cart(image, m_socket1, 1); }
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(socket2_load)158 	DECLARE_DEVICE_IMAGE_LOAD_MEMBER(socket2_load) { return load_cart(image, m_socket2, 2); }
159 
160 	void nascom2_io(address_map &map);
161 	void nascom2_mem(address_map &map);
162 	void nascom2c_mem(address_map &map);
163 
164 	required_device<clock_device> m_clock;
165 	required_device<nasbus_device> m_nasbus;
166 	required_device<generic_slot_device> m_socket1;
167 	required_device<generic_slot_device> m_socket2;
168 	required_ioport m_lsw1;
169 	u8 m_cass_data[4];
170 	bool m_cass_speed;
171 };
172 
173 
174 //**************************************************************************
175 //  KEYBOARD
176 //**************************************************************************
177 
nascom1_port_00_r()178 uint8_t nascom_state::nascom1_port_00_r()
179 {
180 	return m_keyboard[m_kb_select]->read() | ~0x7f;
181 }
182 
nascom1_port_00_w(uint8_t data)183 void nascom_state::nascom1_port_00_w(uint8_t data)
184 {
185 	u8 bits = data ^ m_port00;
186 
187 	if (BIT(bits, 4))
188 		m_cass->change_state(BIT(data, 4) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
189 
190 	// d0 falling edge: increment keyboard matrix column select counter
191 	if (m_kb_control & ~data & 1)
192 		m_kb_select = (m_kb_select + 1) & 7;
193 
194 	// d1 falling edge: reset it
195 	if (m_kb_control & ~data & 2)
196 		m_kb_select = 0;
197 
198 	m_kb_control = data & 3;
199 }
200 
201 
202 //**************************************************************************
203 //  CASSETTE
204 //**************************************************************************
205 
nascom1_port_01_r()206 uint8_t nascom_state::nascom1_port_01_r()
207 {
208 	return m_hd6402->receive();
209 }
210 
nascom1_port_01_w(uint8_t data)211 void nascom_state::nascom1_port_01_w(uint8_t data)
212 {
213 	m_hd6402->transmit(data);
214 }
215 
nascom1_port_02_r()216 uint8_t nascom_state::nascom1_port_02_r()
217 {
218 	uint8_t data = 0x31; // bits 0,4,5 not used
219 
220 	m_hd6402->write_swe(0);
221 	data |= m_hd6402->or_r(  ) ? 0x02 : 0;
222 	data |= m_hd6402->pe_r(  ) ? 0x04 : 0;
223 	data |= m_hd6402->fe_r(  ) ? 0x08 : 0;
224 	data |= m_hd6402->tbmt_r() ? 0x40 : 0;
225 	data |= m_hd6402->dav_r( ) ? 0x80 : 0;
226 	m_hd6402->write_swe(1);
227 
228 	return data;
229 }
230 
READ_LINE_MEMBER(nascom_state::hd6402_si)231 READ_LINE_MEMBER( nascom_state::hd6402_si )
232 {
233 	return m_cassinbit;
234 }
235 
WRITE_LINE_MEMBER(nascom_state::hd6402_so)236 WRITE_LINE_MEMBER( nascom_state::hd6402_so )
237 {
238 	m_cassoutbit = state;
239 }
240 
WRITE_LINE_MEMBER(nascom1_state::nascom1_kansas_w)241 WRITE_LINE_MEMBER( nascom1_state::nascom1_kansas_w )
242 {
243 	// incoming 3906.25Hz
244 	if (state)
245 	{
246 		if (m_cassoutbit)
247 			m_cass->output(BIT(m_cass_cnt[0], 0) ? -1.0 : +1.0); // 1953.125Hz
248 		else
249 			m_cass->output(1.0);
250 
251 		m_cass_cnt[0]++;
252 	}
253 	m_hd6402->write_tcp(state);
254 }
255 
TIMER_DEVICE_CALLBACK_MEMBER(nascom1_state::nascom1_kansas_r)256 TIMER_DEVICE_CALLBACK_MEMBER( nascom1_state::nascom1_kansas_r )
257 {
258 	// cassette - pulses = 1; no pulses = 0
259 	m_cass_cnt[1]++;
260 	bool cass_ws = (m_cass->input() > +0.04) ? 1 : 0;
261 
262 	if (cass_ws != m_cassold)
263 	{
264 		m_cassold = cass_ws;
265 		m_cassinbit = 1;
266 		m_cass_cnt[1] = 0;
267 	}
268 	else
269 	if (m_cass_cnt[1] > 10)
270 	{
271 		m_cass_cnt[1] = 10;
272 		m_cassinbit = !cass_ws;
273 	}
274 }
275 
WRITE_LINE_MEMBER(nascom2_state::nascom2_kansas_w)276 WRITE_LINE_MEMBER( nascom2_state::nascom2_kansas_w )
277 {
278 	// incoming @19230Hz
279 	u8 twobit = m_cass_data[3] & 3;
280 
281 	if (state)
282 	{
283 		if (twobit == 0)
284 			m_cassold = m_cassoutbit;
285 
286 		if (m_cassold)
287 			m_cass->output(BIT(m_cass_data[3], 2) ? -1.0 : +1.0); // 2400Hz
288 		else
289 			m_cass->output(BIT(m_cass_data[3], 3) ? -1.0 : +1.0); // 1200Hz
290 
291 		m_cass_data[3]++;
292 	}
293 
294 	if (m_cass_speed || !twobit)
295 	{
296 		m_hd6402->write_tcp(state);
297 		m_hd6402->write_rcp(state);
298 	}
299 }
300 
TIMER_DEVICE_CALLBACK_MEMBER(nascom2_state::nascom2_kansas_r)301 TIMER_DEVICE_CALLBACK_MEMBER( nascom2_state::nascom2_kansas_r )
302 {
303 	/* cassette - turn 1200/2400Hz to a bit */
304 	m_cass_data[1]++;
305 	uint8_t cass_ws = (m_cass->input() > +0.04) ? 1 : 0;
306 
307 	if (cass_ws != m_cass_data[0])
308 	{
309 		m_cass_data[0] = cass_ws;
310 		m_cassinbit = (m_cass_data[1] < 12) ? 1 : 0;
311 		m_cass_data[1] = 0;
312 	}
313 }
314 
315 // This stuff has never been connected up - what's it for?
DEVICE_IMAGE_LOAD_MEMBER(nascom_state::load_nascom1_cassette)316 DEVICE_IMAGE_LOAD_MEMBER( nascom_state::load_nascom1_cassette )
317 {
318 	m_tape_size = image.length();
319 	m_tape_image = (uint8_t*)image.ptr();
320 
321 	if (!m_tape_image)
322 		return image_init_result::FAIL;
323 
324 	m_tape_index = 0;
325 	return image_init_result::PASS;
326 }
327 
DEVICE_IMAGE_UNLOAD_MEMBER(nascom_state::unload_nascom1_cassette)328 DEVICE_IMAGE_UNLOAD_MEMBER( nascom_state::unload_nascom1_cassette )
329 {
330 	m_tape_image = nullptr;
331 	m_tape_size = m_tape_index = 0;
332 }
333 
334 
335 //**************************************************************************
336 //  SNAPSHOTS
337 //**************************************************************************
338 
339 template<int Dest>
SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb)340 SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb)
341 {
342 	uint8_t line[29];
343 
344 	while (image.fread(&line, sizeof(line)) == sizeof(line))
345 	{
346 		unsigned int addr, b[8], dummy;
347 
348 		if (sscanf((char *)line, "%4x %x %x %x %x %x %x %x %x",
349 			&addr, &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6], &b[7]) == 9)
350 		{
351 			for (int i = 0; i < 8; i++)
352 			{
353 				switch (Dest)
354 				{
355 				case 0: // snapshot
356 					m_maincpu->space(AS_PROGRAM).write_byte(addr++, b[i]);
357 					break;
358 				case 1: // character rom
359 					m_gfx1_region->base()[addr++] = b[i];
360 					break;
361 				}
362 			}
363 		}
364 		else
365 		{
366 			image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported file format");
367 			return image_init_result::FAIL;
368 		}
369 		dummy = 0x00;
370 		while (!image.image_feof() && dummy != 0x0a && dummy != 0x1f)
371 		{
372 			image.fread(&dummy, 1);
373 		}
374 	}
375 
376 	return image_init_result::PASS;
377 }
378 
379 
380 //**************************************************************************
381 //  SOCKETS
382 //**************************************************************************
383 
load_cart(device_image_interface & image,generic_slot_device * slot,int slot_id)384 image_init_result nascom2_state::load_cart(device_image_interface &image, generic_slot_device *slot, int slot_id)
385 {
386 	// loading directly from file
387 	if (!image.loaded_through_softlist())
388 	{
389 		if (slot->length() > 0x1000)
390 		{
391 			image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported file size");
392 			return image_init_result::FAIL;
393 		}
394 
395 		slot->rom_alloc(slot->length(), GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE);
396 		slot->fread(slot->get_rom_base(), slot->length());
397 
398 		// we just assume that socket1 should be loaded to 0xc000 and socket2 to 0xd000
399 		switch (slot_id)
400 		{
401 		case 1:
402 			m_maincpu->space(AS_PROGRAM).install_rom(0xc000, 0xc000 + slot->length() - 1, slot->get_rom_base());
403 			break;
404 		case 2:
405 			m_maincpu->space(AS_PROGRAM).install_rom(0xd000, 0xd000 + slot->length() - 1, slot->get_rom_base());
406 			break;
407 		}
408 	}
409 
410 	// loading from software list. this supports multiple regions to load to
411 	else
412 	{
413 		uint8_t *region_b000 = image.get_software_region("b000");
414 		uint8_t *region_c000 = image.get_software_region("c000");
415 		uint8_t *region_d000 = image.get_software_region("d000");
416 
417 		if (region_b000 != nullptr)
418 		{
419 			uint32_t size = image.get_software_region_length("b000");
420 			m_maincpu->space(AS_PROGRAM).install_rom(0xb000, 0xb000 + size - 1, region_b000);
421 		}
422 
423 		if (region_c000 != nullptr)
424 		{
425 			uint32_t size = image.get_software_region_length("c000");
426 			m_maincpu->space(AS_PROGRAM).install_rom(0xc000, 0xc000 + size - 1, region_c000);
427 		}
428 
429 		if (region_d000 != nullptr)
430 		{
431 			uint32_t size = image.get_software_region_length("d000");
432 			m_maincpu->space(AS_PROGRAM).install_rom(0xd000, 0xd000 + size - 1, region_d000);
433 		}
434 	}
435 
436 	return image_init_result::PASS;
437 }
438 
439 
440 //**************************************************************************
441 //  DRIVER INIT
442 //**************************************************************************
443 
machine_reset()444 void nascom_state::machine_reset()
445 {
446 	m_kb_select = 0;
447 	m_kb_control = 0;
448 	m_port00 = 0;
449 
450 	// Set up hd6402 pins
451 	m_hd6402->write_swe(1);
452 
453 	m_hd6402->write_cs(0);
454 	m_hd6402->write_np(1);
455 	m_hd6402->write_nb1(1);
456 	m_hd6402->write_nb2(1);
457 	m_hd6402->write_eps(1);
458 	m_hd6402->write_tsb(1);
459 	m_hd6402->write_cs(1);
460 }
461 
MACHINE_RESET_MEMBER(nascom2_state,nascom2)462 MACHINE_RESET_MEMBER(nascom2_state, nascom2)
463 {
464 	machine_reset();
465 
466 	// nascom2: restore speed at machine start
467 	m_cass_speed = ioport("DSW0")->read();
468 
469 	// base machine reset
470 	nascom_state::machine_reset();
471 
472 	// restart address (on the real system, a12 to a15 are forced to 1 for one memory cycle)
473 	m_maincpu->set_state_int(Z80_PC, m_lsw1->read() << 12);
474 }
475 
init_nascom()476 void nascom_state::init_nascom()
477 {
478 	// install extra memory
479 	if (m_ram->size() > 0)
480 	{
481 		m_maincpu->space(AS_PROGRAM).install_ram(0x1000, 0x1000 + m_ram->size() - 1, m_ram->pointer());
482 	}
483 }
484 
485 
486 // since we don't know for which regions we should disable ram, we just let other devices
487 // overwrite the region they need, and re-install our ram when they are disabled
WRITE_LINE_MEMBER(nascom2_state::ram_disable_w)488 WRITE_LINE_MEMBER( nascom2_state::ram_disable_w )
489 {
490 	if (state)
491 	{
492 		// enable ram again
493 		m_maincpu->space(AS_PROGRAM).install_ram(0x1000, 0x1000 + m_ram->size() - 1, m_ram->pointer());
494 	}
495 }
496 
init_nascom2c()497 void nascom2_state::init_nascom2c()
498 {
499 	// install memory
500 	m_maincpu->space(AS_PROGRAM).install_ram(0x0000, 0x0000 + m_ram->size() - 1, m_ram->pointer());
501 }
502 
WRITE_LINE_MEMBER(nascom2_state::ram_disable_cpm_w)503 WRITE_LINE_MEMBER( nascom2_state::ram_disable_cpm_w )
504 {
505 	if (state)
506 	{
507 		// enable ram again
508 		m_maincpu->space(AS_PROGRAM).install_ram(0x0000, 0x0000 + m_ram->size() - 1, m_ram->pointer());
509 	}
510 }
511 
512 
513 //**************************************************************************
514 //  VIDEO
515 //**************************************************************************
516 
517 static const gfx_layout nascom1_charlayout =
518 {
519 	8, 16,
520 	128,
521 	1,
522 	{ 0 },
523 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
524 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
525 		8*8, 9*8,10*8,11*8,12*8,13*8,14*8,15*8 },
526 	8 * 16
527 };
528 
529 static GFXDECODE_START( gfx_nascom1 )
530 	GFXDECODE_ENTRY("gfx1", 0x0000, nascom1_charlayout, 0, 1)
531 GFXDECODE_END
532 
screen_update_nascom(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)533 uint32_t nascom1_state::screen_update_nascom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
534 {
535 	screen_update(bitmap, cliprect, 16);
536 	return 0;
537 }
538 
539 static const gfx_layout nascom2_charlayout =
540 {
541 	8, 14,
542 	256,
543 	1,
544 	{ 0 },
545 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
546 	{ 0*8, 1*8, 2*8,  3*8,  4*8,  5*8,  6*8,
547 		7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8 },
548 	8 * 16
549 };
550 
551 static GFXDECODE_START( gfx_nascom2 )
552 	GFXDECODE_ENTRY("gfx1", 0x0000, nascom2_charlayout, 0, 1)
553 GFXDECODE_END
554 
screen_update_nascom(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)555 uint32_t nascom2_state::screen_update_nascom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
556 {
557 	screen_update(bitmap, cliprect, 14);
558 	return 0;
559 }
560 
screen_update(bitmap_ind16 & bitmap,const rectangle & cliprect,int char_height)561 void nascom_state::screen_update(bitmap_ind16 &bitmap, const rectangle &cliprect, int char_height)
562 {
563 	for (int sx = 0; sx < 48; sx++)
564 	{
565 		m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_videoram[0x03ca + sx], 1, 0, 0, sx * 8, 0);
566 	}
567 
568 	for (int sy = 0; sy < 15; sy++)
569 	{
570 		for (int sx = 0; sx < 48; sx++)
571 		{
572 			m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, m_videoram[0x000a + (sy * 64) + sx], 1, 0, 0, sx * 8, (sy + 1) * char_height);
573 		}
574 	}
575 }
576 
577 
578 //**************************************************************************
579 //  ADDRESS MAPS
580 //**************************************************************************
581 
nascom1_mem(address_map & map)582 void nascom1_state::nascom1_mem(address_map &map)
583 {
584 	map(0x0000, 0x07ff).rom(); // MONITOR
585 	map(0x0800, 0x0bff).ram().share("videoram");
586 	map(0x0c00, 0x0fff).ram(); // WRAM
587 }
588 
nascom1_io(address_map & map)589 void nascom1_state::nascom1_io(address_map &map)
590 {
591 	map.global_mask(0x0f);
592 	map(0x00, 0x00).rw(FUNC(nascom1_state::nascom1_port_00_r), FUNC(nascom1_state::nascom1_port_00_w));
593 	map(0x01, 0x01).rw(FUNC(nascom1_state::nascom1_port_01_r), FUNC(nascom1_state::nascom1_port_01_w));
594 	map(0x02, 0x02).r(FUNC(nascom1_state::nascom1_port_02_r));
595 	map(0x04, 0x07).rw("z80pio", FUNC(z80pio_device::read), FUNC(z80pio_device::write));
596 }
597 
nascom2_mem(address_map & map)598 void nascom2_state::nascom2_mem(address_map &map)
599 {
600 	map(0x0000, 0x07ff).rom(); // MONITOR
601 	map(0x0800, 0x0bff).ram().share("videoram");
602 	map(0x0c00, 0x0fff).ram(); // WRAM
603 	map(0xe000, 0xffff).rom().region("basic", 0);
604 }
605 
nascom2_io(address_map & map)606 void nascom2_state::nascom2_io(address_map &map)
607 {
608 	map.global_mask(0xff);
609 	map(0x00, 0x00).rw(FUNC(nascom2_state::nascom1_port_00_r), FUNC(nascom2_state::nascom1_port_00_w));
610 	map(0x01, 0x01).rw(FUNC(nascom2_state::nascom1_port_01_r), FUNC(nascom2_state::nascom1_port_01_w));
611 	map(0x02, 0x02).r(FUNC(nascom2_state::nascom1_port_02_r));
612 	map(0x04, 0x07).rw("z80pio", FUNC(z80pio_device::read), FUNC(z80pio_device::write));
613 }
614 
nascom2c_mem(address_map & map)615 void nascom2_state::nascom2c_mem(address_map &map)
616 {
617 	map(0xf000, 0xf7ff).rom().region("maincpu", 0);
618 	map(0xf800, 0xfbff).ram().share("videoram");
619 	map(0xfc00, 0xffff).ram(); // WRAM
620 }
621 
622 
623 //**************************************************************************
624 //  INPUT PORTS
625 //**************************************************************************
626 
627 static INPUT_PORTS_START( nascom1 )
628 	PORT_START("KEY.0")
PORT_CODE(KEYCODE_CLOSEBRACE)629 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Backspace ClearScreen") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(8)
630 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("New Line")              PORT_CODE(KEYCODE_ENTER)      PORT_CHAR(13)
631 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
632 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
633 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE)  PORT_CHAR(0xff) PORT_CHAR('@')  // have to press shift to get @
634 	PORT_BIT(0x48, IP_ACTIVE_LOW, IPT_UNUSED)
635 
636 	PORT_START("KEY.1")
637 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H)  PORT_CHAR('H') PORT_CHAR('h')
638 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B)  PORT_CHAR('B') PORT_CHAR('b')
639 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5)  PORT_CHAR('5') PORT_CHAR('%')
640 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F)  PORT_CHAR('F') PORT_CHAR('f')
641 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X)  PORT_CHAR('X') PORT_CHAR('x')
642 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T)  PORT_CHAR('T') PORT_CHAR('t')
643 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
644 
645 	PORT_START("KEY.2")
646 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J)    PORT_CHAR('J') PORT_CHAR('j')
647 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N)    PORT_CHAR('N') PORT_CHAR('n')
648 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6)    PORT_CHAR('6') PORT_CHAR('&')
649 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D)    PORT_CHAR('D') PORT_CHAR('d')
650 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z)    PORT_CHAR('Z') PORT_CHAR('z')
651 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y)    PORT_CHAR('Y') PORT_CHAR('y')
652 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
653 
654 	PORT_START("KEY.3")
655 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K)    PORT_CHAR('K') PORT_CHAR('k')
656 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M)    PORT_CHAR('M') PORT_CHAR('m')
657 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7)    PORT_CHAR('7') PORT_CHAR('\'')
658 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E)    PORT_CHAR('E') PORT_CHAR('e')
659 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S)    PORT_CHAR('S') PORT_CHAR('s')
660 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U)    PORT_CHAR('U') PORT_CHAR('u')
661 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
662 
663 	PORT_START("KEY.4")
664 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L)     PORT_CHAR('L') PORT_CHAR('l')
665 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
666 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8)     PORT_CHAR('8') PORT_CHAR('(')
667 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W)     PORT_CHAR('W') PORT_CHAR('w')
668 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A)     PORT_CHAR('A') PORT_CHAR('a')
669 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I)     PORT_CHAR('I') PORT_CHAR('i')
670 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
671 
672 	PORT_START("KEY.5")
673 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
674 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP)  PORT_CHAR('.') PORT_CHAR('>') // > nascom2 only
675 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9)     PORT_CHAR('9') PORT_CHAR(')')
676 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3)     PORT_CHAR('3') PORT_CHAR(0xA3)
677 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q)     PORT_CHAR('Q') PORT_CHAR('q')
678 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O)     PORT_CHAR('O') PORT_CHAR('o')
679 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
680 
681 	PORT_START("KEY.6")
682 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
683 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
684 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0)     PORT_CHAR('0') PORT_CHAR('^')
685 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2)     PORT_CHAR('2') PORT_CHAR('\"')
686 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1)     PORT_CHAR('1') PORT_CHAR('!')
687 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P)     PORT_CHAR('P') PORT_CHAR('p')
688 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
689 
690 	PORT_START("KEY.7")
691 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G)     PORT_CHAR('G') PORT_CHAR('g')
692 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V)     PORT_CHAR('V') PORT_CHAR('v')
693 	PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4)     PORT_CHAR('4') PORT_CHAR('$')
694 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C)     PORT_CHAR('C') PORT_CHAR('c')
695 	PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
696 	PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R)     PORT_CHAR('R') PORT_CHAR('r')
697 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
698 INPUT_PORTS_END
699 
700 static INPUT_PORTS_START( nascom2 )
701 	PORT_INCLUDE(nascom1)
702 	PORT_MODIFY("KEY.0")
703 	PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Back CS")       PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(8)
704 	PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Enter  Escape") PORT_CODE(KEYCODE_ENTER)      PORT_CHAR(13)  PORT_CHAR(27)
705 	PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)  PORT_CHAR(UCHAR_SHIFT_2)
706 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
707 
708 	PORT_MODIFY("KEY.6")
709 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)                            PORT_CODE(KEYCODE_EQUALS)     PORT_CHAR('[') PORT_CHAR('\\')
710 
711 	PORT_MODIFY("KEY.7")
712 	PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)                            PORT_CODE(KEYCODE_BACKSPACE)  PORT_CHAR(']') PORT_CHAR('_')
713 
714 	PORT_START("DSW0")
715 	PORT_DIPNAME(0x01, 0x00, "Cassette Baud Rate") PORT_CHANGED_MEMBER(DEVICE_SELF, nascom2_state, cass_speed, 0)
716 	PORT_DIPSETTING(0x00, "300")
717 	PORT_DIPSETTING(0x01, "1200")
718 
719 	// link switch on board
720 	PORT_START("lsw1")
721 	PORT_DIPNAME(0x0f, 0x00, "Restart address")
722 	PORT_DIPLOCATION("LSW1:1,2,3,4")
723 	PORT_DIPSETTING(0x00, "0000H")
724 	PORT_DIPSETTING(0x01, "1000H")
725 	PORT_DIPSETTING(0x02, "2000H")
726 	PORT_DIPSETTING(0x03, "3000H")
727 	PORT_DIPSETTING(0x04, "4000H")
728 	PORT_DIPSETTING(0x05, "5000H")
729 	PORT_DIPSETTING(0x06, "6000H")
730 	PORT_DIPSETTING(0x07, "7000H")
731 	PORT_DIPSETTING(0x08, "8000H")
732 	PORT_DIPSETTING(0x09, "9000H")
733 	PORT_DIPSETTING(0x0a, "A000H")
734 	PORT_DIPSETTING(0x0b, "B000H")
735 	PORT_DIPSETTING(0x0c, "C000H")
736 	PORT_DIPSETTING(0x0d, "D000H")
737 	PORT_DIPSETTING(0x0e, "E000H")
738 	PORT_DIPSETTING(0x0f, "F000H")
739 INPUT_PORTS_END
740 
741 static INPUT_PORTS_START( nascom2c )
742 	PORT_INCLUDE(nascom2)
743 
744 	PORT_MODIFY("lsw1")
745 	PORT_DIPNAME(0x0f, 0x0f, "Restart address")
746 	PORT_DIPLOCATION("LSW1:1,2,3,4")
747 	PORT_DIPSETTING(0x00, "0000H")
748 	PORT_DIPSETTING(0x01, "1000H")
749 	PORT_DIPSETTING(0x02, "2000H")
750 	PORT_DIPSETTING(0x03, "3000H")
751 	PORT_DIPSETTING(0x04, "4000H")
752 	PORT_DIPSETTING(0x05, "5000H")
753 	PORT_DIPSETTING(0x06, "6000H")
754 	PORT_DIPSETTING(0x07, "7000H")
755 	PORT_DIPSETTING(0x08, "8000H")
756 	PORT_DIPSETTING(0x09, "9000H")
757 	PORT_DIPSETTING(0x0a, "A000H")
758 	PORT_DIPSETTING(0x0b, "B000H")
759 	PORT_DIPSETTING(0x0c, "C000H")
760 	PORT_DIPSETTING(0x0d, "D000H")
761 	PORT_DIPSETTING(0x0e, "E000H")
762 	PORT_DIPSETTING(0x0f, "F000H")
763 INPUT_PORTS_END
764 
765 INPUT_CHANGED_MEMBER(nascom2_state::cass_speed)
766 {
767 	m_cass_speed = newval ? 1 : 0;
768 }
769 
770 
771 //**************************************************************************
772 //  MACHINE DRIVERS
773 //**************************************************************************
774 
nascom(machine_config & config)775 void nascom_state::nascom(machine_config &config)
776 {
777 	// video hardware
778 	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
779 	m_screen->set_refresh_hz(50);
780 	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
781 	m_screen->set_size(48 * 8, 16 * 16);
782 	m_screen->set_visarea(0, 48 * 8 - 1, 0, 16 * 16 - 1);
783 	m_screen->set_screen_update(FUNC(nascom1_state::screen_update_nascom));
784 	m_screen->set_palette(m_palette);
785 
786 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_nascom1);
787 	PALETTE(config, m_palette, palette_device::MONOCHROME);
788 
789 	// pio
790 	Z80PIO(config, "z80pio", 16_MHz_XTAL / 8);
791 
792 	// internal extra ram
793 	RAM(config, m_ram).set_default_size("48K").set_extra_options("8K,16K,32K");
794 
795 	// uart
796 	AY31015(config, m_hd6402);
797 	m_hd6402->read_si_callback().set(FUNC(nascom_state::hd6402_si));
798 	m_hd6402->write_so_callback().set(FUNC(nascom_state::hd6402_so));
799 	m_hd6402->set_auto_rdav(true);
800 
801 	// cassette is connected to the uart
802 	CASSETTE(config, m_cass);
803 	m_cass->set_interface("nascom_cass");
804 	m_cass->set_default_state(CASSETTE_STOPPED | CASSETTE_SPEAKER_ENABLED | CASSETTE_MOTOR_ENABLED);
805 	SPEAKER(config, "mono").front_center();
806 	m_cass->add_route(ALL_OUTPUTS, "mono", 0.05);
807 
808 	// devices
809 	snapshot_image_device &snapshot(SNAPSHOT(config, "snapshot", "nas", attotime::from_msec(500)));
810 	snapshot.set_load_callback(FUNC(nascom_state::snapshot_cb<0>));
811 	snapshot.set_interface("nascom_snap");
812 	snapshot_image_device &snapchar(SNAPSHOT(config, "snapchar", "chr", attotime::from_msec(500)));
813 	snapchar.set_load_callback(FUNC(nascom_state::snapshot_cb<1>));
814 	snapchar.set_interface("nascom_char");
815 }
816 
nascom1(machine_config & config)817 void nascom1_state::nascom1(machine_config &config)
818 {
819 	nascom(config);
820 
821 	Z80(config, m_maincpu, 16_MHz_XTAL / 8);
822 	m_maincpu->set_addrmap(AS_PROGRAM, &nascom1_state::nascom1_mem);
823 	m_maincpu->set_addrmap(AS_IO, &nascom1_state::nascom1_io);
824 
825 	// software
826 	SOFTWARE_LIST(config, "snap_list").set_original("nascom_snap").set_filter("NASCOM1");
827 
828 	clock_device &uart_clock(CLOCK(config, "uart_clock", (16_MHz_XTAL / 16) / 256));
829 	uart_clock.signal_handler().set(FUNC(nascom1_state::nascom1_kansas_w));
830 	uart_clock.signal_handler().append(m_hd6402, FUNC(ay31015_device::write_rcp));
831 	TIMER(config, "kansas_r").configure_periodic(FUNC(nascom1_state::nascom1_kansas_r), attotime::from_hz(40000));
832 }
833 
nascom2(machine_config & config)834 void nascom2_state::nascom2(machine_config &config)
835 {
836 	nascom(config);
837 
838 	Z80(config, m_maincpu, 16_MHz_XTAL / 4);
839 	m_maincpu->set_addrmap(AS_PROGRAM, &nascom2_state::nascom2_mem);
840 	m_maincpu->set_addrmap(AS_IO, &nascom2_state::nascom2_io);
841 
842 	MCFG_MACHINE_RESET_OVERRIDE(nascom2_state, nascom2 )
843 
844 	// video hardware
845 	m_screen->set_size(48 * 8, 16 * 14);
846 	m_screen->set_visarea(0, 48 * 8 - 1, 0, 16 * 14 - 1);
847 	m_screen->set_screen_update(FUNC(nascom2_state::screen_update_nascom));
848 
849 	m_gfxdecode->set_info(gfx_nascom2);
850 
851 	// generic sockets for ram/rom (todo: support ram here)
852 	GENERIC_SOCKET(config, m_socket1, generic_plain_slot, "nascom_socket", "bin,rom");
853 	m_socket1->set_device_load(FUNC(nascom2_state::socket1_load));
854 	GENERIC_SOCKET(config, m_socket2, generic_plain_slot, "nascom_socket", "bin,rom");
855 	m_socket2->set_device_load(FUNC(nascom2_state::socket2_load));
856 
857 	// nasbus expansion bus
858 	NASBUS(config, m_nasbus);
859 	m_nasbus->ram_disable().set(FUNC(nascom2_state::ram_disable_w));
860 	m_nasbus->set_program_space(m_maincpu, AS_PROGRAM);
861 	m_nasbus->set_io_space(m_maincpu, AS_IO);
862 	NASBUS_SLOT(config, "nasbus1", m_nasbus, nasbus_slot_cards, nullptr);
863 	NASBUS_SLOT(config, "nasbus2", m_nasbus, nasbus_slot_cards, nullptr);
864 	NASBUS_SLOT(config, "nasbus3", m_nasbus, nasbus_slot_cards, nullptr);
865 	NASBUS_SLOT(config, "nasbus4", m_nasbus, nasbus_slot_cards, nullptr);
866 
867 	// software
868 	SOFTWARE_LIST(config, "snap_list").set_original("nascom_snap").set_filter("NASCOM2");
869 	SOFTWARE_LIST(config, "socket_list").set_original("nascom_socket");
870 	SOFTWARE_LIST(config, "floppy_list").set_original("nascom_flop");
871 
872 	CLOCK(config, m_clock, (16_MHz_XTAL / 32) / 26);
873 	m_clock->signal_handler().set(FUNC(nascom2_state::nascom2_kansas_w));
874 	TIMER(config, "kansas_r").configure_periodic(FUNC(nascom2_state::nascom2_kansas_r), attotime::from_hz(40000));
875 }
876 
nascom2c(machine_config & config)877 void nascom2_state::nascom2c(machine_config &config)
878 {
879 	nascom2(config);
880 
881 	m_maincpu->set_addrmap(AS_PROGRAM, &nascom2_state::nascom2c_mem);
882 
883 	m_ram->set_default_size("60K");
884 
885 	m_nasbus->ram_disable().set(FUNC(nascom2_state::ram_disable_cpm_w));
886 	subdevice<nasbus_slot_device>("nasbus1")->set_default_option("floppy");
887 }
888 
889 
890 //**************************************************************************
891 //  ROM DEFINITIONS
892 //**************************************************************************
893 
894 ROM_START( nascom1 )
895 	ROM_REGION(0x0800, "maincpu", 0)
896 	ROM_DEFAULT_BIOS("t4")
897 	ROM_SYSTEM_BIOS(0, "t1", "NasBug T1")
898 	ROMX_LOAD("nasbugt1.ic38", 0x0000, 0x0400, CRC(8ea07054) SHA1(3f9a8632826003d6ea59d2418674d0fb09b83a4c), ROM_BIOS(0))
899 	ROM_SYSTEM_BIOS(1, "t2", "NasBug T2")
900 	ROMX_LOAD("nasbugt2.ic38", 0x0000, 0x0400, CRC(e371b58a) SHA1(485b20a560b587cf9bb4208ba203b12b3841689b), ROM_BIOS(1))
901 	ROM_SYSTEM_BIOS(2, "t4", "NasBug T4")
902 	ROMX_LOAD("nasbugt4.rom", 0x0000, 0x0800, CRC(f391df68) SHA1(00218652927afc6360c57e77d6a4fd32d4e34566), ROM_BIOS(2)) // should really be split in halves for ic38 and ic39
903 	ROM_SYSTEM_BIOS(3, "bbug", "B-Bug") // by Viewfax 1978
904 	ROMX_LOAD("bbug.rom",     0x0000, 0x0800, CRC(1b1a340d) SHA1(99ce4d771871b3d797cc465d6245c40e41acef3e), ROM_BIOS(3))
905 
906 	ROM_REGION(0x0800, "gfx1", 0)
907 	ROM_LOAD("nascom1.ic16",   0x0000, 0x0800, CRC(33e92a04) SHA1(be6e1cc80e7f95a032759f7df19a43c27ff93a52)) // MCM6576P
908 ROM_END
909 
910 ROM_START( nascom2 )
911 	ROM_REGION(0x0800, "maincpu", 0)
912 	ROM_DEFAULT_BIOS("ns3")
913 	ROM_SYSTEM_BIOS(0, "ns1", "Nas-Sys 1")
914 	ROMX_LOAD("nassys1.ic34", 0x0000, 0x0800, CRC(b6300716) SHA1(29da7d462ba3f569f70ed3ecd93b981f81c7adfa), ROM_BIOS(0))
915 	ROM_SYSTEM_BIOS(1, "ns3", "Nas-Sys 3")
916 	ROMX_LOAD("nassys3.ic34", 0x0000, 0x0800, CRC(6804e675) SHA1(d55dccec2d1da992a39c38b0b6d24e3809073513), ROM_BIOS(1))
917 	ROM_SYSTEM_BIOS(2, "ns3a", "Nas-Sys 3 (AVC)")
918 	ROMX_LOAD("nassys3a.ic34", 0x0000, 0x0800, CRC(39d24a05) SHA1(7bfb574c1f8ce0f460a53b9a6c11c711aabccbb8), ROM_BIOS(2))
919 	ROM_SYSTEM_BIOS(3, "ns3n", "Nas-Sys 3 (NET)")
920 	ROMX_LOAD("nassys3n.ic34", 0x0000, 0x0800, CRC(87ef62bb) SHA1(dab81511925be36044b3e8b0ba26a0c717fe83ae), ROM_BIOS(3))
921 
922 	ROM_REGION(0x2000, "basic", 0)
923 	ROM_LOAD("basic.ic43", 0x0000, 0x2000, CRC(5cb5197b) SHA1(c41669c2b6d6dea808741a2738426d97bccc9b07))
924 
925 	ROM_REGION(0x1000, "gfx1", 0)
926 	ROM_LOAD("nascom1.ic66", 0x0000, 0x0800, CRC(33e92a04) SHA1(be6e1cc80e7f95a032759f7df19a43c27ff93a52))
927 	ROM_LOAD("nasgra.ic54",  0x0800, 0x0800, CRC(2bc09d32) SHA1(d384297e9b02cbcb283c020da51b3032ff62b1ae))
928 ROM_END
929 
930 ROM_START( nascom2c )
931 	ROM_REGION(0x0800, "maincpu", 0)
932 	ROM_DEFAULT_BIOS("cpm32")
933 	ROM_SYSTEM_BIOS(0, "cpm21", "CP/M boot v2.1")
934 	ROMX_LOAD("cpmbt21.ic34", 0x0000, 0x0800, CRC(44b67ffc) SHA1(60c8335f24798f8de7ad48a4cd03e56a60d87b63), ROM_BIOS(0))
935 	ROM_SYSTEM_BIOS(1, "cpm32", "CP/M boot v3.2")
936 	ROMX_LOAD("cpmbt32.ic34", 0x0000, 0x0800, CRC(724f03ba) SHA1(d0958c231e5b121b6c4c97d03c76c207acf90f5a), ROM_BIOS(1))
937 
938 	ROM_REGION(0x1000, "gfx1", 0)
939 	ROM_LOAD("nascom1.ic66", 0x0000, 0x0800, CRC(33e92a04) SHA1(be6e1cc80e7f95a032759f7df19a43c27ff93a52))
940 	ROM_LOAD("nasgra.ic54",  0x0800, 0x0800, CRC(2bc09d32) SHA1(d384297e9b02cbcb283c020da51b3032ff62b1ae))
941 ROM_END
942 
943 
944 //**************************************************************************
945 //  GAME DRIVERS
946 //**************************************************************************
947 
948 //    YEAR  NAME      PARENT   COMPAT  MACHINE   INPUT     CLASS          INIT           COMPANY                  FULLNAME           FLAGS
949 COMP( 1978, nascom1,  0,       0,      nascom1,  nascom1,  nascom1_state, init_nascom,   "Nascom Microcomputers", "Nascom 1",        MACHINE_NO_SOUND_HW )
950 COMP( 1979, nascom2,  0,       0,      nascom2,  nascom2,  nascom2_state, init_nascom,   "Nascom Microcomputers", "Nascom 2",        MACHINE_NO_SOUND_HW )
951 COMP( 1980, nascom2c, nascom2, 0,      nascom2c, nascom2c, nascom2_state, init_nascom2c, "Nascom Microcomputers", "Nascom 2 (CP/M)", MACHINE_NO_SOUND_HW )
952