summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/informer_207_376.cpp
blob: 964363dc0e8686e9fb2b3f8bf282dff9e254da3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
// license: BSD-3-Clause
// copyright-holders: Dirk Best
/***************************************************************************

    Informer 207/376

    IBM 3270 compatible terminal

    Hardware:
    - M6809
    - Z80SCC 8530
    - 6850 ACIA (up to 4)
    - X2212P NVRAM

    TODO:
	- Redump bad ROMs
	- Dump keyboard controller and emulate it (currently HLE'd)
	- Problably needs improvements to at least the Z80SCC to
	  properly support synchrous modes
    - Figure out unknown reads/writes to the memory
	- Verify NMI hookup
	- Verify clock speeds

    Notes:
    - Thanks to charcole and his zmachine3270 project at
      https://github.com/charcole/zmachine3270

***************************************************************************/

#include "emu.h"
#include "cpu/m6809/m6809.h"
#include "machine/6850acia.h"
#include "machine/pit8253.h"
#include "machine/clock.h"
#include "machine/input_merger.h"
#include "machine/nvram.h"
#include "machine/z80scc.h"
#include "video/mc6845.h"
#include "sound/beep.h"
#include "bus/rs232/rs232.h"
#include "bus/rs232/printer.h"
#include "machine/informer_207_376_kbd.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

class informer_207_376_state : public driver_device
{
public:
	informer_207_376_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, "maincpu"),
		m_crtc(*this, "crtc"),
		m_screen(*this, "screen"),
		m_palette(*this, "palette"),
		m_pit(*this, "pit"),
		m_scc(*this, "scc"),
		m_acia(*this, "acia%u", 0U),
		m_beep(*this, "beep"),
		m_ram(*this, "ram"),
		m_chargen(*this, "chargen"),
		m_nmi_enabled(false)
	{ }

	void informer_207_376(machine_config &config);

protected:
	void machine_start() override;
	void machine_reset() override;

private:
	required_device<cpu_device> m_maincpu;
	required_device<mc6845_device> m_crtc;
	required_device<screen_device> m_screen;
	required_device<palette_device> m_palette;
	required_device<pit8253_device> m_pit;
	required_device<scc85c30_device> m_scc;
	required_device_array<acia6850_device, 2> m_acia;
	required_device<beep_device> m_beep;
	required_shared_ptr<uint8_t> m_ram;
	required_region_ptr<uint8_t> m_chargen;

	void mem_map(address_map &map);

	MC6845_UPDATE_ROW(crtc_update_row);

	void vsync_w(int state);
	void nmi_control_w(uint8_t data);
	void unk_8400_w(uint8_t data);

	bool m_nmi_enabled;
};


//**************************************************************************
//  ADDRESS MAPS
//**************************************************************************

void informer_207_376_state::mem_map(address_map &map)
{
	map(0x0000, 0x7fff).ram().share("ram");
	map(0x8000, 0x8000).rw(m_crtc, FUNC(mc6845_device::status_r), FUNC(mc6845_device::address_w));
	map(0x8001, 0x8001).rw(m_crtc, FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w));
	map(0x8400, 0x8400).lr8(NAME([] () { return 0xff; })).w(FUNC(informer_207_376_state::unk_8400_w)); // ?
	map(0x8802, 0x8803).rw(m_acia[0], FUNC(acia6850_device::read), FUNC(acia6850_device::write));
	map(0x8804, 0x8805).rw(m_acia[1], FUNC(acia6850_device::read), FUNC(acia6850_device::write));
	map(0x8c00, 0x8c00).w(FUNC(informer_207_376_state::nmi_control_w));
	map(0x9000, 0x9003).rw(m_pit, FUNC(pit8253_device::read), FUNC(pit8253_device::write));
	map(0x9400, 0x9403).rw(m_scc, FUNC(scc85c30_device::ab_dc_r), FUNC(scc85c30_device::ab_dc_w));
	map(0x9c00, 0x9cff).ram().share("nvram");
	map(0xa000, 0xffff).rom().region("maincpu", 0);
}


//**************************************************************************
//  INPUT PORT DEFINITIONS
//**************************************************************************

static INPUT_PORTS_START( informer_207_376 )
INPUT_PORTS_END


//**************************************************************************
//  VIDEO EMULATION
//**************************************************************************

void informer_207_376_state::vsync_w(int state)
{
	if (m_nmi_enabled && state == 1)
	{
		m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
		m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
	}
}

MC6845_UPDATE_ROW( informer_207_376_state::crtc_update_row )
{
	const pen_t *pen = m_palette->pens();

	for (int x = 0; x < x_count; x++)
	{
		uint8_t code = m_ram[ma + x];
		uint8_t data = m_chargen[(code << 4) + ra];

		if (x == cursor_x)
			data = 0xff;

		// draw 8 pixels of the character
		bitmap.pix32(y, x * 8 + 7) = pen[BIT(data, 0)];
		bitmap.pix32(y, x * 8 + 6) = pen[BIT(data, 1)];
		bitmap.pix32(y, x * 8 + 5) = pen[BIT(data, 2)];
		bitmap.pix32(y, x * 8 + 4) = pen[BIT(data, 3)];
		bitmap.pix32(y, x * 8 + 3) = pen[BIT(data, 4)];
		bitmap.pix32(y, x * 8 + 2) = pen[BIT(data, 5)];
		bitmap.pix32(y, x * 8 + 1) = pen[BIT(data, 6)];
		bitmap.pix32(y, x * 8 + 0) = pen[BIT(data, 7)];
	}
}

static const gfx_layout char_layout =
{
	8,11,
	RGN_FRAC(1,1),
	1,
	{ 0 },
	{ 0, 1, 2, 3, 4, 5, 6, 7 },
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8 },
	8*16
};

static GFXDECODE_START(chars)
	GFXDECODE_ENTRY("chargen", 0, char_layout, 0, 1)
GFXDECODE_END


//**************************************************************************
//  MACHINE EMULATION
//**************************************************************************

void informer_207_376_state::nmi_control_w(uint8_t data)
{
	// 76543---  unused?
	// -----21-  nmi enable?
	// -------0  unused?

	m_nmi_enabled = bool(data & 0x06);
}

void informer_207_376_state::unk_8400_w(uint8_t data)
{
	// 7-------  beeper
	// -6------  unknown
	// --5-----  1=internal modem, 0=host rs232
	// ---43210  unknown

	m_beep->set_state(BIT(data, 7));
}

void informer_207_376_state::machine_start()
{
	// register for save states
	save_item(NAME(m_nmi_enabled));
}

void informer_207_376_state::machine_reset()
{
	m_nmi_enabled = false;
}


//**************************************************************************
//  MACHINE DEFINTIONS
//**************************************************************************

void printer_devices(device_slot_interface &device)
{
	device.option_add("printer", SERIAL_PRINTER);
}

void informer_207_376_state::informer_207_376(machine_config &config)
{
	MC6809(config, m_maincpu, 36_MHz_XTAL / 4); // unknown clock
	m_maincpu->set_addrmap(AS_PROGRAM, &informer_207_376_state::mem_map);

	input_merger_device &cpu_irq(INPUT_MERGER_ANY_HIGH(config, "cpu_irq"));
	cpu_irq.output_handler().set_inputline(m_maincpu, M6809_IRQ_LINE);

	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // 2x X2212P

	PIT8253(config, m_pit);
	m_pit->set_clk<0>(4915200 / 2);
	m_pit->out_handler<0>().set(m_acia[1], FUNC(acia6850_device::write_txc));
	m_pit->out_handler<0>().append(m_acia[1], FUNC(acia6850_device::write_rxc));
	m_pit->set_clk<1>(4915200 / 2);
	m_pit->out_handler<1>().set(m_acia[0], FUNC(acia6850_device::write_txc));
	m_pit->out_handler<1>().append(m_acia[0], FUNC(acia6850_device::write_rxc));

	SCC85C30(config, m_scc, 4915200);
	m_scc->out_txda_callback().set("com1", FUNC(rs232_port_device::write_txd));
	m_scc->out_dtra_callback().set("com1", FUNC(rs232_port_device::write_dtr));
	m_scc->out_rtsa_callback().set("com1", FUNC(rs232_port_device::write_rts));
	m_scc->out_txdb_callback().set("com2", FUNC(rs232_port_device::write_txd));
	m_scc->out_dtrb_callback().set("com2", FUNC(rs232_port_device::write_dtr));
	m_scc->out_rtsb_callback().set("com2", FUNC(rs232_port_device::write_rts));
	m_scc->out_int_callback().set("cpu_irq", FUNC(input_merger_device::in_w<0>));

	ACIA6850(config, m_acia[0], 0); // unknown clock
	m_acia[0]->txd_handler().set("kbd", FUNC(informer_207_376_kbd_hle_device::rx_w));
	m_acia[0]->irq_handler().set("cpu_irq", FUNC(input_merger_device::in_w<1>));

	ACIA6850(config, m_acia[1], 0); // unknown clock
	m_acia[1]->txd_handler().set("printer", FUNC(rs232_port_device::write_txd));

	rs232_port_device &com1(RS232_PORT(config, "com1", default_rs232_devices, nullptr));
	com1.rxd_handler().set(m_scc, FUNC(scc85c30_device::rxa_w));
	com1.dcd_handler().set(m_scc, FUNC(scc85c30_device::dcda_w));
	com1.cts_handler().set(m_scc, FUNC(scc85c30_device::ctsa_w));

	rs232_port_device &com2(RS232_PORT(config, "com2", default_rs232_devices, nullptr));
	com2.rxd_handler().set(m_scc, FUNC(scc85c30_device::rxb_w));
	com2.dcd_handler().set(m_scc, FUNC(scc85c30_device::dcdb_w));
	com2.cts_handler().set(m_scc, FUNC(scc85c30_device::ctsb_w));

	RS232_PORT(config, "printer", printer_devices, nullptr);

	informer_207_376_kbd_hle_device &kbd(INFORMER_207_376_KBD_HLE(config, "kbd"));
	kbd.tx_handler().set(m_acia[0], FUNC(acia6850_device::write_rxd));

	// video
	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	m_screen->set_color(rgb_t::green());
	m_screen->set_raw(14400000, 800, 0, 640, 300, 0, 286); // unknown clock
	m_screen->set_screen_update("crtc", FUNC(mc6845_device::screen_update));

	PALETTE(config, m_palette, palette_device::MONOCHROME);

	GFXDECODE(config, "gfxdecode", m_palette, chars);

	MC6845(config, m_crtc, 1800000); // unknown clock
	m_crtc->set_screen("screen");
	m_crtc->set_show_border_area(false);
	m_crtc->set_char_width(8);
	m_crtc->set_update_row_callback(FUNC(informer_207_376_state::crtc_update_row));
	m_crtc->out_vsync_callback().set(FUNC(informer_207_376_state::vsync_w));

	// sound
	SPEAKER(config, "mono").front_center();
	BEEP(config, "beep", 500).add_route(ALL_OUTPUTS, "mono", 0.50); // frequency unknown
}


//**************************************************************************
//  ROM DEFINITIONS
//**************************************************************************

ROM_START( in207376 )
	ROM_REGION(0x6000, "maincpu", 0)
	// M2764A F1
	// 79590-023  376SNA V1.00  201C 7224  (our checksum: 7264)
	ROM_LOAD("79590-023.z37", 0x0000, 0x2000, BAD_DUMP CRC(ed4ff488) SHA1(fdd95c520d0288ea483b5d2e8e6c8eecb04063c1))
	// M27128AF1
	// 79589-023  376 SNAV1.00  201C E86F  (checksum matches)
	ROM_LOAD("79589-023.z36", 0x2000, 0x4000, CRC(cdfaf629) SHA1(1f21ef6848020726ef3d7ab05166ac8590d58476))

	ROM_REGION(0x1000, "chargen", 0)
	// TMS2732AGL-25
	// 79573-001 V1.00 376/8 CHAR. GEN.
	ROM_LOAD("79573-001.z6", 0x0000, 0x1000, CRC(f704b827) SHA1(bcc56eeb8681c2bebe3a9f4b6b78c0373c06d875))
ROM_END


//**************************************************************************
//  SYSTEM DRIVERS
//**************************************************************************

//    YEAR  NAME      PARENT   COMPAT  MACHINE           INPUT             CLASS                   INIT        COMPANY     FULLNAME            FLAGS
COMP( 1986, in207376, 0,       0,      informer_207_376, informer_207_376, informer_207_376_state, empty_init, "Informer", "Informer 207/376", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE )