summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/crt9028.cpp
blob: 94cc2429e13da797aeef62a12364d7e433fff000 (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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
// license:BSD-3-Clause
// copyright-holders:AJR
/**********************************************************************

    Standard Microsystems CRT9028/9128 Video Terminal Logic Controller

    The CRT 9028 and CRT 9128 are single-chip terminal-oriented video
    processors. The two differ from each other in their bus protocol
    for accessing the address, data and status registers: the 9028 has
    separate RD and WR strobes for an 8051 or similar microcontroller,
    while the 9128 replaces these with DS and R/W inputs that are more
    Z8-oriented. A separate address/data bus connects to a 2Kx8 static
    RAM or similar as display memory.

    The internal 128-character set is mask-programmed, as are all
    screen timings, with alternate vertical timings to allow operation
    at either 60 Hz or 50 Hz. Mask parameters also determine the
    polarity of the sync signals, the positioning of the underline
    attribute and cursor and the dot patterns used for 6-segment wide
    (block) graphics and 4-segment thin (line) graphics.

    TODO: implement timing and display functions

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

#include "emu.h"
#include "video/crt9028.h"
#include "screen.h"

//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

// device type definition
DEFINE_DEVICE_TYPE(CRT9028_000, crt9028_000_device, "crt9028_000", "CRT9028-000 VTLC")

//**************************************************************************
//  DEVICE IMPLEMENTATION
//**************************************************************************

//-------------------------------------------------
//  crt9028_device - constructor
//-------------------------------------------------

crt9028_device::crt9028_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock,
							int dots_per_char, int chars_per_row, int horiz_blanking, int hsync_delay, int hsync_width, bool hsync_active,
							int char_rows, int scans_per_char, bool vsync_active,
							int vert_blanking, int vsync_delay, int vsync_width,
							int alt_vert_blanking, int alt_vsync_delay, int alt_vsync_width,
							int csync_delay, int csync_width, int underline,
							u16 wide_gfx_seg1_4, u16 wide_gfx_seg2_5, u16 wide_gfx_seg3_6, u8 wide_gfx_pattern,
							u16 thin_gfx_seg1, u16 thin_gfx_seg2, u16 thin_gfx_seg3, u16 thin_gfx_seg4,
							u8 thin_gfx_dots1, u8 thin_gfx_dots2, u8 thin_gfx_dots3, u8 thin_gfx_dots4)
	: device_t(mconfig, type, tag, owner, clock)
	, device_memory_interface(mconfig, *this)
	, device_video_interface(mconfig, *this)
	, m_space_config("charram", ENDIANNESS_LITTLE, 8, 11, 0)
	, m_charset(*this, "charset")
	, m_hsync_callback(*this)
	, m_vsync_callback(*this)
	, m_dots_per_char(dots_per_char)
	, m_chars_per_row(chars_per_row)
	, m_horiz_blanking(horiz_blanking)
	, m_hsync_delay(hsync_delay)
	, m_hsync_width(hsync_width)
	, m_hsync_active(hsync_active)
	, m_char_rows(char_rows)
	, m_scans_per_char(scans_per_char)
	, m_vsync_active(vsync_active)
	, m_vert_blanking{vert_blanking, alt_vert_blanking}
	, m_vsync_delay{vsync_delay, alt_vsync_delay}
	, m_vsync_width{vsync_width, alt_vsync_width}
	, m_csync_delay(csync_delay)
	, m_csync_width(csync_width)
	, m_underline(underline)
	, m_wide_gfx_seg{wide_gfx_seg1_4, wide_gfx_seg2_5, wide_gfx_seg3_6}
	, m_wide_gfx_pattern(wide_gfx_pattern)
	, m_thin_gfx_seg{thin_gfx_seg1, thin_gfx_seg2, thin_gfx_seg3, thin_gfx_seg4}
	, m_thin_gfx_dots{thin_gfx_dots1, thin_gfx_dots2, thin_gfx_dots3, thin_gfx_dots4}
	, m_address_register(0)
{
	// Mostly unused now
	(void)m_hsync_delay;
	(void)m_hsync_width;
	(void)m_hsync_active;
	(void)m_vsync_active;
	(void)m_vsync_delay;
	(void)m_vsync_width;
	(void)m_csync_delay;
	(void)m_csync_width;
	(void)m_underline;
	(void)m_wide_gfx_seg;
	(void)m_wide_gfx_pattern;
	(void)m_thin_gfx_seg;
	(void)m_thin_gfx_dots;
}


//-------------------------------------------------
//  crt9028_000_device - constructor
//-------------------------------------------------

crt9028_000_device::crt9028_000_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: crt9028_device(mconfig, CRT9028_000, tag, owner, clock,
						7, 80, 20, 4, 8, false,
						24, 10, false,
						20, 4, 8,
						72, 30, 10,
						2, 8, 9,
						0x3c0, 0x038, 0x007, 0x0f,
						0x3e0, 0x020, 0x03f, 0x020,
						0x10, 0xff, 0x10, 0xff)
{
}


//-------------------------------------------------
//  device_config_complete - finalise device
//  configuration
//-------------------------------------------------

void crt9028_device::device_config_complete()
{
	if (!has_screen())
		return;

	if (screen().refresh_attoseconds() == 0)
	{
		int visible_scan_lines = m_char_rows * m_scans_per_char;
		screen().set_raw(clock(), m_dots_per_char * (m_chars_per_row + m_horiz_blanking), 0, m_dots_per_char * m_chars_per_row,
			visible_scan_lines + m_vert_blanking[0], 0, visible_scan_lines);
	}

	if (!screen().has_screen_update())
		screen().set_screen_update(*this, FUNC(crt9028_device::screen_update));
}


//-------------------------------------------------
//  memory_space_config - return the configuration
//  for the address spaces
//-------------------------------------------------

device_memory_interface::space_config_vector crt9028_device::memory_space_config() const
{
	return space_config_vector{std::make_pair(0, &m_space_config)};
}


//-------------------------------------------------
//  device_resolve_objects - resolve objects that
//  may be needed for other devices to set
//  initial conditions at start time
//-------------------------------------------------

void crt9028_device::device_resolve_objects()
{
	m_hsync_callback.resolve_safe();
	m_vsync_callback.resolve_safe();
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void crt9028_device::device_start()
{
	m_space = &space(0);

	save_item(NAME(m_address_register));
}


//-------------------------------------------------
//  screen_update - screen update method
//-------------------------------------------------

u32 crt9028_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
	return 0;
}


//-------------------------------------------------
//  chip_reset - software reset command
//-------------------------------------------------

void crt9028_device::chip_reset()
{
	logerror("%s: Chip reset\n", machine().describe_context());
}


//-------------------------------------------------
//  status_r - read status register
//-------------------------------------------------

u8 crt9028_device::status_r()
{
	return 0x80;
}


//-------------------------------------------------
//  filadd_w - set fill address register
//-------------------------------------------------

void crt9028_device::filadd_w(u8 data)
{
	logerror("%s: Fill address = %03X\n", machine().describe_context(), data << 4);
}


//-------------------------------------------------
//  tosadd_w - set top of screen address register
//-------------------------------------------------

void crt9028_device::tosadd_w(u8 data)
{
	logerror("%s: Top of screen address = %03X\n", machine().describe_context(), data << 4);
}


//-------------------------------------------------
//  curlo_w - set cursor low register
//-------------------------------------------------

void crt9028_device::curlo_w(u8 data)
{
	logerror("%s: Cursor low = %02X\n", machine().describe_context(), data);
}


//-------------------------------------------------
//  curhi_w - set cursor high/scroll register
//-------------------------------------------------

void crt9028_device::curhi_w(u8 data)
{
	logerror("%s: Cursor high = %02X\n", machine().describe_context(), data);
}


//-------------------------------------------------
//  attdat_w - set attribute data register
//-------------------------------------------------

void crt9028_device::attdat_w(u8 data)
{
	logerror("%s: Attribute data = %02X\n", machine().describe_context(), data);
}


//-------------------------------------------------
//  mode_w - set mode register
//-------------------------------------------------

void crt9028_device::mode_w(u8 data)
{
	logerror("%s: Auto increment %sabled\n", machine().describe_context(), BIT(data, 7) ? "en" : "dis");
}


//-------------------------------------------------
//  character_r - read character from memory
//-------------------------------------------------

u8 crt9028_device::character_r()
{
	return 0;
}


//-------------------------------------------------
//  character_w - write character to memory
//-------------------------------------------------

void crt9028_device::character_w(u8 data)
{
	logerror("%s: Character = %02X\n", machine().describe_context(), data);
}


//-------------------------------------------------
//  read - read from data or status register
//-------------------------------------------------

u8 crt9028_device::read(offs_t offset)
{
	if (BIT(offset, 0))
		return status_r();
	else if (m_address_register == 0xe)
		return character_r();
	else
	{
		if (!machine().side_effects_disabled())
			logerror("Read from unknown or write-only register %X\n", m_address_register);
		return 0;
	}
}


//-------------------------------------------------
//  write - write to data or address register
//-------------------------------------------------

void crt9028_device::write(offs_t offset, u8 data)
{
	if (BIT(offset, 0))
		m_address_register = data & 0x0f;
	else switch (m_address_register)
	{
	case 0x6:
		chip_reset();
		break;

	case 0x8:
		tosadd_w(data);
		break;

	case 0x9:
		curlo_w(data);
		break;

	case 0xa:
		curhi_w(data);
		break;

	case 0xb:
		filadd_w(data);
		break;

	case 0xc:
		attdat_w(data);
		break;

	case 0xd:
		character_w(data);
		break;

	case 0xe:
		mode_w(data);
		break;

	default:
		logerror("%s: Unknown register %X = %02X\n", machine().describe_context(), m_address_register, data);
		break;
	}
}


//**************************************************************************
//  INTERNAL ROM
//**************************************************************************

ROM_START(crt9028_000)
	ROM_REGION(0x400, "charset", 0)
	ROM_LOAD("crt9028_000.bin", 0x000, 0x400, NO_DUMP)
ROM_END


//-------------------------------------------------
//  rom_region - return a pointer to the implicit
//  rom region description for this device
//-------------------------------------------------

const tiny_rom_entry *crt9028_000_device::device_rom_region() const
{
	return ROM_NAME(crt9028_000);
}