1 // license:BSD-3-Clause
2 // copyright-holders:Miodrag Milanovic, Robbbert
3 /********************************************************************************
4 
5 EC-65 (also known as Octopus)
6 
7 2009-07-16 Initial driver.
8 
9 No sound. Storage is floppy disk. No software has been found.
10 Modules are constructed on separate eurocards and plug into a common backplane.
11 
12 EC65 -  Disk controller module uses 6821 and 6850. Needs to be emulated.
13         When done, .b to boot disk
14 
15 EC65K - To be developed from scratch. Similar design to EC65, but 6522
16         replaced with 6821. Contains extra RTC. Particulars of video and
17         universal FDC not known.
18       - Extra 256KB card
19       - Extra Z80 card with ROM, 2x PIA, 64 or 256KB RAM, for CP/M use.
20       - Currently runs into the weeds soon after start, at F070
21 
22 
23 ********************************************************************************/
24 
25 #include "emu.h"
26 #include "cpu/m6502/m6502.h"
27 #include "cpu/g65816/g65816.h"
28 #include "video/mc6845.h"
29 #include "machine/6821pia.h"
30 #include "machine/6522via.h"
31 #include "machine/mos6551.h"
32 #include "machine/6850acia.h"
33 #include "machine/keyboard.h"
34 #include "machine/mc146818.h"
35 #include "emupal.h"
36 #include "screen.h"
37 
38 
39 class ec65_common : public driver_device
40 {
41 public:
ec65_common(const machine_config & mconfig,device_type type,const char * tag)42 	ec65_common(const machine_config &mconfig, device_type type, const char *tag)
43 		: driver_device(mconfig, type, tag)
44 		, m_vram(*this, "videoram")
45 		, m_p_chargen(*this, "chargen")
46 		, m_maincpu(*this, "maincpu")
47 		, m_palette(*this, "palette")
48 	{ }
49 
50 	MC6845_UPDATE_ROW(crtc_update_row);
51 
52 protected:
53 	required_shared_ptr<u8> m_vram;
54 	required_region_ptr<u8> m_p_chargen;
55 	required_device<cpu_device> m_maincpu;
56 	required_device<palette_device> m_palette;
57 
58 };
59 
60 class ec65_state : public ec65_common
61 {
62 public:
ec65_state(const machine_config & mconfig,device_type type,const char * tag)63 	ec65_state(const machine_config &mconfig, device_type type, const char *tag)
64 		: ec65_common(mconfig, type, tag)
65 		, m_via0(*this, "via0")
66 		, m_via1(*this, "via1")
67 	{ }
68 
69 	void ec65(machine_config &config);
70 
71 private:
72 	void machine_reset() override;
73 	void ec65_mem(address_map &map);
74 	void kbd_put(u8 data);
75 	required_device<via6522_device> m_via0;
76 	required_device<via6522_device> m_via1;
77 };
78 
79 class ec65k_state : public ec65_common
80 {
81 public:
ec65k_state(const machine_config & mconfig,device_type type,const char * tag)82 	ec65k_state(const machine_config &mconfig, device_type type, const char *tag)
83 		: ec65_common(mconfig, type, tag)
84 		, m_rtc(*this, "rtc")
85 		, m_pia0(*this, "pia0")
86 		, m_pia1(*this, "pia1")
87 	{ }
88 
89 	void ec65k(machine_config &config);
90 
91 private:
92 	void ec65k_mem(address_map &map);
93 	void kbd_put(u8 data);
94 	required_device<mc146818_device> m_rtc;
95 	required_device<pia6821_device> m_pia0;
96 	required_device<pia6821_device> m_pia1;
97 };
98 
ec65_mem(address_map & map)99 void ec65_state::ec65_mem(address_map &map)
100 {
101 	map.unmap_value_high();
102 	map(0x0000, 0xdfff).ram();
103 	map(0xe000, 0xe003).rw("pia", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // FDC card
104 	map(0xe010, 0xe011).rw("fdc", FUNC(acia6850_device::read), FUNC(acia6850_device::write)); // FDC card
105 	map(0xe100, 0xe10f).m(m_via0, FUNC(via6522_device::map));
106 	map(0xe110, 0xe11f).m(m_via1, FUNC(via6522_device::map));
107 	map(0xe130, 0xe133).rw("uart", FUNC(mos6551_device::read), FUNC(mos6551_device::write));
108 	map(0xe140, 0xe140).rw("crtc", FUNC(mc6845_device::status_r), FUNC(mc6845_device::address_w));
109 	map(0xe141, 0xe141).rw("crtc", FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w));
110 	map(0xe400, 0xe7ff).ram(); // 1KB on-board RAM
111 	map(0xe800, 0xefff).ram().share("videoram");
112 	map(0xf000, 0xffff).rom().region("maincpu",0);
113 }
114 
ec65k_mem(address_map & map)115 void ec65k_state::ec65k_mem(address_map &map)
116 {
117 	map.unmap_value_high();
118 	map(0x000000, 0x00dfff).ram();   // D000-DFFF = System RAM
119 	map(0x00e000, 0x00e003).rw("pia", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // old FDC card
120 	map(0x00e010, 0x00e011).rw("fdc", FUNC(acia6850_device::read), FUNC(acia6850_device::write)); // old FDC card
121 	//map(0x00e150,             colorator CRTC (no info)
122 	//map(0x00e280,             basicode interface (no info)
123 	//map(0x00e300,             Z80 board
124 	map(0x00e400, 0x00e403).rw(m_pia0, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); //  PIA0 porta=keyboard; portb=parallel port
125 	map(0x00e410, 0x00e413).rw("uart", FUNC(mos6551_device::read), FUNC(mos6551_device::write));
126 	map(0x00e420, 0x00e423).rw(m_pia1, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); //  PIA1 porta=centronics control; portb=centronics data
127 	map(0x00e430, 0x00e430).lw8(NAME([this] (u8 data) { m_rtc->write(0, data); }));  //  RTC 146818 - has battery backup
128 	map(0x00e431, 0x00e431).lr8(NAME([this] () { return m_rtc->read(1); }));
129 	map(0x00e431, 0x00e431).lw8(NAME([this] (u8 data) { m_rtc->write(1, data); }));
130 	//map(0x00e500, 0x00e5ff)   universal disk controller (no info)
131 	map(0x00e800, 0x00efff).ram().share("videoram");
132 	map(0x00f000, 0x00ffff).rom().region("maincpu",0);
133 	map(0x010000, 0x0fffff).ram();
134 }
135 
136 /* Input ports */
INPUT_PORTS_START(ec65)137 static INPUT_PORTS_START( ec65 )
138 INPUT_PORTS_END
139 
140 void ec65_state::kbd_put(u8 data)
141 {
142 	if (data)
143 	{
144 		m_via0->write_pa(data);
145 		m_via0->write_ca1(1);
146 		m_via0->write_ca1(0);
147 	}
148 }
149 
kbd_put(u8 data)150 void ec65k_state::kbd_put(u8 data)
151 {
152 	if (data)
153 	{
154 		m_pia0->porta_w(data);
155 		m_pia0->ca1_w(1);
156 		m_pia0->ca1_w(0);
157 	}
158 }
159 
machine_reset()160 void ec65_state::machine_reset()
161 {
162 	m_via1->write_pb(0xff);
163 }
164 
MC6845_UPDATE_ROW(ec65_common::crtc_update_row)165 MC6845_UPDATE_ROW( ec65_common::crtc_update_row )
166 {
167 	rgb_t const *const palette = m_palette->palette()->entry_list_raw();
168 	u32 *p = &bitmap.pix(y);
169 
170 	for (u16 x = 0; x < x_count; x++)
171 	{
172 		u8 const inv = (x == cursor_x) ? 0xff : 0;
173 		u16 const mem = (ma + x) & 0x7ff;
174 		u8 const chr = m_vram[mem];
175 
176 		/* get pattern of pixels for that character scanline */
177 		u8 const gfx = m_p_chargen[(chr<<4) | (ra & 0x0f)] ^ inv;
178 
179 		/* Display a scanline of a character */
180 		*p++ = palette[BIT(gfx, 7)];
181 		*p++ = palette[BIT(gfx, 6)];
182 		*p++ = palette[BIT(gfx, 5)];
183 		*p++ = palette[BIT(gfx, 4)];
184 		*p++ = palette[BIT(gfx, 3)];
185 		*p++ = palette[BIT(gfx, 2)];
186 		*p++ = palette[BIT(gfx, 1)];
187 		*p++ = palette[BIT(gfx, 0)];
188 	}
189 }
190 
191 /* F4 Character Displayer */
192 static const gfx_layout charlayout =
193 {
194 	8, 8,                   /* 8 x 8 characters */
195 	256,                    /* 256 characters */
196 	1,                  /* 1 bits per pixel */
197 	{ 0 },                  /* no bitplanes */
198 	/* x offsets */
199 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
200 	/* y offsets */
201 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
202 	8*16                    /* every char takes 16 bytes */
203 };
204 
205 static GFXDECODE_START( gfx_ec65 )
206 	GFXDECODE_ENTRY( "chargen", 0x0000, charlayout, 0, 1 )
207 GFXDECODE_END
208 
ec65(machine_config & config)209 void ec65_state::ec65(machine_config &config)
210 {
211 	/* basic machine hardware */
212 	M6502(config, m_maincpu, XTAL(4'000'000) / 4);
213 	m_maincpu->set_addrmap(AS_PROGRAM, &ec65_state::ec65_mem);
214 
215 	/* video hardware */
216 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
217 	screen.set_refresh_hz(60);
218 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
219 	screen.set_size(640, 200);
220 	screen.set_visarea_full();
221 	screen.set_screen_update("crtc", FUNC(mc6845_device::screen_update));
222 
223 	GFXDECODE(config, "gfxdecode", m_palette, gfx_ec65);
224 	PALETTE(config, "palette", palette_device::MONOCHROME);
225 
226 	mc6845_device &crtc(MC6845(config, "crtc", XTAL(16'000'000) / 8));
227 	crtc.set_screen("screen");
228 	crtc.set_show_border_area(false);
229 	crtc.set_char_width(8); /*?*/
230 	crtc.set_update_row_callback(FUNC(ec65_state::crtc_update_row));
231 
232 	/* devices */
233 	ACIA6850(config, "fdc", 0); // used as a FDC on separate card
234 	PIA6821(config, "pia", 0);   // assists 6850
235 
236 	VIA6522(config, m_via0, XTAL(4'000'000) / 4);
237 
238 	VIA6522(config, m_via1, XTAL(4'000'000) / 4);
239 
240 	mos6551_device &uart(MOS6551(config, "uart", 0));
241 	uart.set_xtal(XTAL(1'843'200));
242 
243 	generic_keyboard_device &keyboard(GENERIC_KEYBOARD(config, "keyboard", 0));
244 	keyboard.set_keyboard_callback(FUNC(ec65_state::kbd_put));
245 }
246 
ec65k(machine_config & config)247 void ec65k_state::ec65k(machine_config &config)
248 {
249 	/* basic machine hardware */
250 	g65816_device &maincpu(G65816(config, "maincpu", XTAL(4'000'000))); // can use 4,2 or 1 MHz
251 	maincpu.set_addrmap(AS_PROGRAM, &ec65k_state::ec65k_mem);
252 
253 	/* video hardware */
254 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
255 	screen.set_refresh_hz(60);
256 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
257 	screen.set_size(640, 200);
258 	screen.set_visarea_full();
259 	screen.set_screen_update("crtc", FUNC(mc6845_device::screen_update));
260 
261 	GFXDECODE(config, "gfxdecode", "palette", gfx_ec65);
262 	PALETTE(config, "palette", palette_device::MONOCHROME);
263 
264 	mc6845_device &crtc(MC6845(config, "crtc", XTAL(16'000'000) / 8));
265 	crtc.set_screen("screen");
266 	crtc.set_show_border_area(false);
267 	crtc.set_char_width(8); /*?*/
268 	crtc.set_update_row_callback(FUNC(ec65k_state::crtc_update_row));
269 
270 	/* devices */
271 	ACIA6850(config, "fdc", 0); // used as a FDC on separate card
272 	PIA6821(config, "pia", 0);   // assists 6850
273 
274 	MC146818(config, m_rtc, 32.768_kHz_XTAL);
275 	//m_rtc->irq().set(FUNC(micronic_state::mc146818_irq));   Connects to common irq line used by below PIAs and UART
276 
277 	PIA6821(config, m_pia0, 0);
278 	PIA6821(config, m_pia1, 0);
279 
280 	mos6551_device &uart(MOS6551(config, "uart", 0));
281 	uart.set_xtal(XTAL(1'843'200));
282 
283 	generic_keyboard_device &keyboard(GENERIC_KEYBOARD(config, "keyboard", 0));
284 	keyboard.set_keyboard_callback(FUNC(ec65k_state::kbd_put));
285 }
286 
287 /* ROM definition */
288 ROM_START( ec65 )
289 	ROM_REGION( 0x1000, "maincpu", 0 )
290 	ROM_LOAD( "ec65.ic6", 0x0000, 0x1000, CRC(acd928ed) SHA1(e02a688a057ff77294717cf7b887425fed0b1153))
291 
292 	ROM_REGION( 0x1000, "chargen", 0 )
293 	ROM_LOAD( "chargen.ic19", 0x0000, 0x1000, CRC(9b56a28d) SHA1(41c04fd9fb542c50287bc0e366358a61fc4b0cd4)) // Located on VDU card
294 ROM_END
295 
296 ROM_START( ec65k )
297 	ROM_REGION( 0x1000, "maincpu", 0 )
298 	ROM_LOAD( "ec65k.ic19",  0x0000, 0x1000, CRC(5e5a890a) SHA1(daa006f2179fd156833e11c73b37881cafe5dede))
299 
300 	ROM_REGION( 0x1000, "chargen", 0 )
301 	ROM_LOAD( "chargen.ic19", 0x0000, 0x1000, CRC(9b56a28d) SHA1(41c04fd9fb542c50287bc0e366358a61fc4b0cd4)) // Located on VDU card
302 ROM_END
303 /* Driver */
304 
305 /*    YEAR  NAME   PARENT  COMPAT  MACHINE  INPUT  CLASS        INIT        COMPANY    FULLNAME  FLAGS */
306 COMP( 1985, ec65,  0,      0,      ec65,    ec65,  ec65_state,  empty_init, "Elektor", "EC-65",  MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE )
307 COMP( 1986, ec65k, ec65,   0,      ec65k,   ec65,  ec65k_state, empty_init, "Elektor", "EC-65K", MACHINE_NOT_WORKING | MACHINE_NO_SOUND_HW | MACHINE_SUPPORTS_SAVE )
308