summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/video/vdc8563.c
blob: 107f806253d314d9d2dd818f4e0d9ded7208194c (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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
/***************************************************************************

  CBM Video Device Chip 8563

  Original code by PeT (peter.trauner@jk.uni-linz.ac.at)

    2010-02: converted to be a device

    TODO:
      - clean up the code
      - add RAM with an internal address map

***************************************************************************/
/*
 several graphic problems
 some are in the rastering engine and should be solved during its evalution
 rare and short documentation,
 registers and some words of description in the c128 user guide */
/* seems to be a motorola m6845 variant */


#include "emu.h"
#include "video/vdc8563.h"

typedef struct _vdc8563_state vdc8563_state;
struct _vdc8563_state
{
	screen_device *screen;

	int state;
	UINT8 reg[37];
	UINT8 index;

	UINT16 addr, src;

	UINT16 videoram_start, colorram_start, fontram_start;
	UINT16 videoram_size;

	int rastering;

	UINT8 *ram;
	UINT8 *dirty;
	UINT8 fontdirty[0x200];
	UINT16 mask, fontmask;

	double cursor_time;
	int	cursor_on;

	int changed;
};

/*****************************************************************************
    CONSTANTS
*****************************************************************************/

#define VERBOSE_LEVEL 0
#define DBG_LOG(N, M, A)      \
	do { \
		if (VERBOSE_LEVEL >= N) \
		{ \
			if (M) \
				logerror("%11.6f: %-24s",device->machine().time().as_double(),(char*)M ); \
			logerror A; \
		} \
	} while (0)


static const struct {
	int stored,
		read;
} reg_mask[]= {
	{ 0xff, 0 },
	{ 0xff, 0 },
	{ 0xff, 0 },
	{ 0xff, 0 },
	{ 0xff, 0 },
	{ 0x1f, 0 },
	{ 0xff, 0 },
	{ 0xff, 0 },
	{  0x3, 0 }, //8
	{  0x1f, 0 },
	{  0x7f, 0 },
	{  0x1f, 0 },
	{  0xff, 0xff },
	{  0xff, 0xff },
	{  0xff, 0xff },
	{  0xff, 0xff },
	{  -1, 0xff }, //0x10
	{  -1, 0xff },
	{  0xff, 0xff },
	{  0xff, 0xff },
	{  0xff, -1 },
	{  0x1f, -1 },
	{  0xff, -1 },
	{  0xff, -1 },
	{  0xff, -1 },//0x18
	{  0xff, -1 },
	{  0xff, -1 },
	{  0xff, -1 },
	{  0xf0, -1 },
	{  0x1f, -1 },
	{  0xff, -1 },
	{  0xff, -1 },
	{  0xff, -1 }, //0x20
	{  0xff, -1 },
	{  0xff, -1 },
	{  0xff, -1 },
	{  0x0f, -1 },
};
#define REG(x)          (vdc8563->reg[x] & reg_mask[x].stored)


#define CHAR_WIDTH      (((vdc8563->reg[0x16] & 0xf0) >> 4) + 1)
#define CHAR_WIDTH_VISIBLE ((vdc8563->reg[0x16] & 0x0f) + 1)

#define BLOCK_COPY      (vdc8563->reg[0x18] & 0x80)

#define MONOTEXT        ((vdc8563->reg[0x19] & 0xc0) == 0)
#define TEXT            ((vdc8563->reg[0x19] & 0xc0) == 0x40)
#define GRAPHIC         (vdc8563->reg[0x19] & 0x80)

#define FRAMECOLOR      (vdc8563->reg[0x1a] & 0x0f)
#define MONOCOLOR       (vdc8563->reg[0x1a] >> 4)

#define LINEDIFF        (vdc8563->reg[0x1b])
#define FONT_START      ((vdc8563->reg[0x1c] & 0xe0) << 8)
/* 0x1c 0x10 dram 0:4416, 1: 4164 */

/* 0x1d 0x1f counter for underlining */

#define FILLBYTE        vdc8563->reg[0x1f]

#define CLOCK_HALFING   (vdc8563->reg[25] & 0x10)


/* the regs below corresponds to the ones used by 6845, hence we borrow the macros */
#define CRTC6845_COLUMNS (REG(0) + 1)
#define CRTC6845_CHAR_COLUMNS (REG(1))
#define CRTC6845_CHAR_LINES REG(6)
#define CRTC6845_CHAR_HEIGHT ((REG(9) & 0x1f) + 1)
#define CRTC6845_LINES (REG(4) * CRTC6845_CHAR_HEIGHT + REG(5))
#define CRTC6845_VIDEO_START ((REG(0xc) << 8) | REG(0xd))
#define CRTC6845_INTERLACE_MODE (REG(8) & 3)
#define CRTC6845_INTERLACE_SIGNAL 1
#define CRTC6845_INTERLACE 3
#define CRTC6845_CURSOR_MODE (REG(0xa) & 0x60)
#define CRTC6845_CURSOR_OFF 0x20
#define CRTC6845_CURSOR_16FRAMES 0x40
#define CRTC6845_CURSOR_32FRAMES 0x60
#define CRTC6845_SKEW	(REG(8) & 15)
#define CRTC6845_CURSOR_POS ((REG(0xe) << 8) | REG(0xf))
#define CRTC6845_CURSOR_TOP	(REG(0xa) & 0x1f)
#define CRTC6845_CURSOR_BOTTOM REG(0xb)


/*****************************************************************************
    INLINE FUNCTIONS
*****************************************************************************/

INLINE vdc8563_state *get_safe_token( device_t *device )
{
	assert(device != NULL);
	assert(device->type() == VDC8563);

	return (vdc8563_state *)downcast<legacy_device_base *>(device)->token();
}

INLINE const vdc8563_interface *get_interface( device_t *device )
{
	assert(device != NULL);
	assert((device->type() == VDC8563));
	return (const vdc8563_interface *) device->static_config();
}

/*****************************************************************************
    IMPLEMENTATION
*****************************************************************************/

static void vdc_videoram_w( device_t *device, int offset, int data )
{
	vdc8563_state *vdc8563 = get_safe_token(device);

	offset &= vdc8563->mask;

	if (vdc8563->ram[offset] != data)
	{
		vdc8563->ram[offset] = data;
		vdc8563->dirty[offset] = 1;
		if ((vdc8563->fontram_start & vdc8563->fontmask) == (offset & vdc8563->fontmask))
			vdc8563->fontdirty[(offset & 0x1ff0) >> 4] = 1;
	}
}

INLINE int vdc_videoram_r( device_t *device, int offset )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	return vdc8563->ram[offset & vdc8563->mask];
}

void vdc8563_set_rastering( device_t *device, int on )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	vdc8563->rastering = on;
	vdc8563->changed |= 1;
}



/* 0x22 number of chars from start of line to positiv edge of display enable */
/* 0x23 number of chars from start of line to negativ edge of display enable */
/* 0x24 0xf number of refresh cycles per line */

WRITE8_DEVICE_HANDLER( vdc8563_port_w )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	UINT8 i;

	if (offset & 1)
	{
		if ((vdc8563->index & 0x3f) < 37)
		{
			switch (vdc8563->index & 0x3f)
			{
			case 1: case 4: case 0x1b:
				vdc8563->reg[vdc8563->index] = data;
				vdc8563->videoram_size = CRTC6845_CHAR_LINES * (CRTC6845_CHAR_COLUMNS + LINEDIFF);
				vdc8563->changed = 1;
				break;
			case 0xe: case 0xf: case 0xa: case 0xb:
				vdc8563->dirty[CRTC6845_CURSOR_POS & vdc8563->mask] = 1;
				vdc8563->reg[vdc8563->index] = data;
				break;
			case 0xc: case 0xd:
				vdc8563->reg[vdc8563->index] = data;
				vdc8563->videoram_start = CRTC6845_VIDEO_START;
				vdc8563->changed = 1;
				break;
			case 0x12:
				vdc8563->addr = (vdc8563->addr & 0x00ff) | (data << 8);
				break;
			case 0x13:
				vdc8563->addr = (vdc8563->addr & 0xff00) | data;
				break;
			case 0x20:
				vdc8563->src = (vdc8563->src & 0x00ff) | (data << 8);
				break;
			case 0x21:
				vdc8563->src = (vdc8563->src & 0xff00) | data;
				break;
			case 0x14: case 0x15:
				vdc8563->reg[vdc8563->index] = data;
				vdc8563->colorram_start = (vdc8563->reg[0x14] << 8) | vdc8563->reg[0x15];
				vdc8563->changed = 1;
				break;
			case 0x1c:
				vdc8563->reg[vdc8563->index] = data;
				vdc8563->fontram_start = FONT_START;
				vdc8563->changed = 1;
				break;
			case 0x16: case 0x19: case 0x1a:
				vdc8563->reg[vdc8563->index] = data;
				vdc8563->changed = 1;
				break;
			case 0x1e:
				vdc8563->reg[vdc8563->index] = data;
				if (BLOCK_COPY)
				{
					DBG_LOG(2, "vdc block copy", ("src:%.4x dst:%.4x size:%.2x\n", vdc8563->src, vdc8563->addr, data));
					i = data;
					do {
						vdc_videoram_w(device, vdc8563->addr++, vdc_videoram_r(device, vdc8563->src++));
					} while (--i != 0);
				}
				else
				{
					DBG_LOG(2, "vdc block set", ("dest:%.4x value:%.2x size:%.2x\n", vdc8563->addr, FILLBYTE, data));
					i = data;
					do {
						vdc_videoram_w(device, vdc8563->addr++, FILLBYTE);
					} while (--i != 0);
				}
				break;
			case 0x1f:
				DBG_LOG(2, "vdc written", ("dest:%.4x size:%.2x\n", vdc8563->addr, data));
				vdc8563->reg[vdc8563->index] = data;
				vdc_videoram_w(device, vdc8563->addr++, data);
				break;
			default:
				vdc8563->reg[vdc8563->index] = data;
				DBG_LOG(2, "vdc8563_port_w", ("%.2x:%.2x\n", vdc8563->index, data));
				break;
			}
		}
		DBG_LOG(3, "vdc8563_port_w", ("%.2x:%.2x\n", vdc8563->index, data));
	}
	else
	{
		vdc8563->index = data;
	}
}

READ8_DEVICE_HANDLER( vdc8563_port_r )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	int val;

	val = 0xff;
	if (offset & 1)
	{
		if ((vdc8563->index & 0x3f) < 37)
		{
			switch (vdc8563->index & 0x3f)
			{
			case 0x12:
				val = vdc8563->addr >> 8;
				break;
			case 0x13:
				val = vdc8563->addr & 0xff;
				break;
			case 0x1e:
				val = 0;
				break;
			case 0x1f:
				val = vdc_videoram_r(device, vdc8563->addr);
				DBG_LOG(2, "vdc read", ("%.4x %.2x\n", vdc8563->addr, val));
				break;
			case 0x20:
				val = vdc8563->src >> 8;
				break;
			case 0x21:
				val = vdc8563->src & 0xff;
				break;
			default:
				val = vdc8563->reg[vdc8563->index & 0x3f] & reg_mask[vdc8563->index & 0x3f].read;
			}
		}
		DBG_LOG(2, "vdc8563_port_r", ("%.2x:%.2x\n", vdc8563->index, val));
	}
	else
	{
		val = vdc8563->index;
		if (vdc8563->state)
			val |= 0x80;
	}
	return val;
}

static int vdc8563_clocks_in_frame( device_t *device )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	int clocks = CRTC6845_COLUMNS * CRTC6845_LINES;

	switch (CRTC6845_INTERLACE_MODE)
	{
	case CRTC6845_INTERLACE_SIGNAL: // interlace generation of video signals only
	case CRTC6845_INTERLACE: // interlace
		return clocks / 2;
	default:
		return clocks;
	}
}

static void vdc8563_time( device_t *device )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	double newtime, ftime;
	newtime = device->machine().time().as_double();

	if (vdc8563_clocks_in_frame(device) == 0.0)
		return;

	ftime = 16 * vdc8563_clocks_in_frame(device) / 2000000.0;
	if (CLOCK_HALFING)
		ftime *= 2;
	switch (CRTC6845_CURSOR_MODE)
	{
	case CRTC6845_CURSOR_OFF:
		vdc8563->cursor_on = 0;
		break;
	case CRTC6845_CURSOR_32FRAMES:
		ftime *= 2;
	case CRTC6845_CURSOR_16FRAMES:
		if (newtime - vdc8563->cursor_time > ftime)
		{
			vdc8563->cursor_time += ftime;
			vdc8563->dirty[CRTC6845_CURSOR_POS & vdc8563->mask] = 1;
			vdc8563->cursor_on ^= 1;
		}
		break;
	default:
		vdc8563->cursor_on = 1;
		break;
	}
}

static void vdc8563_monotext_screenrefresh( device_t *device, bitmap_ind16 &bitmap, int full_refresh )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	running_machine &machine = device->machine();
	int x, y, i;
	rectangle rect;
	int w = CRTC6845_CHAR_COLUMNS;
	int h = CRTC6845_CHAR_LINES;
	int height = CRTC6845_CHAR_HEIGHT;

	rect.setx(vdc8563->screen->visible_area().min_x, vdc8563->screen->visible_area().max_x);

	if (full_refresh)
		memset(vdc8563->dirty + vdc8563->videoram_start, 1, vdc8563->videoram_size);

	for (y = 0, rect.min_y = height, rect.max_y = rect.min_y + height - 1, i = vdc8563->videoram_start & vdc8563->mask; y < h;
		y++, rect.min_y += height, rect.max_y += height)
	{
		for (x = 0; x < w; x++, i = (i + 1) & vdc8563->mask)
		{
			if (vdc8563->dirty[i])
			{
				drawgfx_opaque(bitmap,rect,machine.gfx[0], vdc8563->ram[i], FRAMECOLOR | (MONOCOLOR << 4), 0, 0,
						machine.gfx[0]->width * x + 8, height * y + height);

				if ((vdc8563->cursor_on) && (i == (CRTC6845_CURSOR_POS & vdc8563->mask)))
				{
					int k = height - CRTC6845_CURSOR_TOP;
					if (CRTC6845_CURSOR_BOTTOM < height)
						k = CRTC6845_CURSOR_BOTTOM - CRTC6845_CURSOR_TOP + 1;

					if (k > 0)
						bitmap.plot_box(machine.gfx[0]->width * x + 8, height * y + height + CRTC6845_CURSOR_TOP, machine.gfx[0]->width, k, FRAMECOLOR);
				}

				vdc8563->dirty[i] = 0;
			}
		}
		i += LINEDIFF;
	}
}

static void vdc8563_text_screenrefresh( device_t *device, bitmap_ind16 &bitmap, int full_refresh )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	running_machine &machine = device->machine();
	int x, y, i, j;
	rectangle rect;
	int w = CRTC6845_CHAR_COLUMNS;
	int h = CRTC6845_CHAR_LINES;
	int height = CRTC6845_CHAR_HEIGHT;

	rect.setx(vdc8563->screen->visible_area().min_x, vdc8563->screen->visible_area().max_x);

	if (full_refresh)
		memset(vdc8563->dirty + vdc8563->videoram_start, 1, vdc8563->videoram_size);

	for (y = 0, rect.min_y = height, rect.max_y = rect.min_y + height - 1, i = vdc8563->videoram_start & vdc8563->mask,
		j = vdc8563->colorram_start & vdc8563->mask; y < h; y++, rect.min_y += height, rect.max_y += height)
	{
		for (x = 0; x < w; x++, i = (i + 1) & vdc8563->mask, j = (j + 1) & vdc8563->mask)
		{
			if (vdc8563->dirty[i] || vdc8563->dirty[j])
			{
				{
					UINT16 ch, fg, bg;
					const UINT8 *charptr;
					int v, h2;
					UINT16 *pixel;

					ch = vdc8563->ram[i] | ((vdc8563->ram[j] & 0x80) ? 0x100 : 0);
					charptr = &vdc8563->ram[(vdc8563->fontram_start + (ch * 16)) & vdc8563->mask];
					fg = ((vdc8563->ram[j] & 0x0f) >> 0) + 0x10;
					bg = ((vdc8563->ram[j] & 0x70) >> 4) + 0x10;

					for (v = 0; v < 16; v++)
					{
						for (h2 = 0; h2 < 8; h2++)
						{
							pixel = &bitmap.pix16((y * height) + height + v, (x * 8) + 8 + h2);
							*pixel = (charptr[v] & (0x80 >> h2)) ? fg : bg;
						}
					}
				}

				if ((vdc8563->cursor_on) && (i == (CRTC6845_CURSOR_POS & vdc8563->mask)))
				{
					int k = height - CRTC6845_CURSOR_TOP;
					if (CRTC6845_CURSOR_BOTTOM < height)
						k = CRTC6845_CURSOR_BOTTOM - CRTC6845_CURSOR_TOP + 1;

					if (k > 0)
						bitmap.plot_box(machine.gfx[0]->width * x + 8, height * y + height + CRTC6845_CURSOR_TOP, machine.gfx[0]->width,
								k, 0x10 | (vdc8563->ram[j] & 0x0f));
				}

				vdc8563->dirty[i] = 0;
				vdc8563->dirty[j] = 0;
			}
		}
		i += LINEDIFF;
		j += LINEDIFF;
	}
}

static void vdc8563_graphic_screenrefresh( device_t *device, bitmap_ind16 &bitmap, int full_refresh )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	running_machine &machine = device->machine();
	int x, y, i, j, k;
	rectangle rect;
	int w = CRTC6845_CHAR_COLUMNS;
	int h = CRTC6845_CHAR_LINES;
	int height = CRTC6845_CHAR_HEIGHT;

	rect.setx(vdc8563->screen->visible_area().min_x, vdc8563->screen->visible_area().max_x);

	if (full_refresh)
		memset(vdc8563->dirty, 1, vdc8563->mask + 1);

	for (y = 0, rect.min_y = height, rect.max_y = rect.min_y + height - 1, i = vdc8563->videoram_start & vdc8563->mask; y < h;
		y++, rect.min_y += height, rect.max_y += height)
	{
		for (x = 0; x < w; x++, i = (i + 1) & vdc8563->mask)
		{
			for (j = 0; j < height; j++)
			{
				k = ((i << 4) + j) & vdc8563->mask;
				if (vdc8563->dirty[k])
				{
					drawgfx_opaque(bitmap, rect, machine.gfx[1], vdc8563->ram[k], FRAMECOLOR | (MONOCOLOR << 4), 0, 0,
							machine.gfx[0]->width * x + 8, height * y + height + j);
					vdc8563->dirty[k] = 0;
				}
			}
		}
		i += LINEDIFF;
	}
}

UINT32 vdc8563_video_update( device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	int i;
	int full_refresh = 1;

	if (!vdc8563->rastering)
		return 0;

	vdc8563_time(device);

	full_refresh |= vdc8563->changed;

	if (GRAPHIC)
	{
		vdc8563_graphic_screenrefresh(device, bitmap, full_refresh);
	}
	else
	{
		for (i = 0; i < 512; i++)
		{
			if (full_refresh || vdc8563->fontdirty[i])
			{
				gfx_element_mark_dirty(device->machine().gfx[0],i);
				vdc8563->fontdirty[i] = 0;
			}
		}
		if (TEXT)
			vdc8563_text_screenrefresh(device, bitmap, full_refresh);
		else
			vdc8563_monotext_screenrefresh(device, bitmap, full_refresh);
	}

	if (full_refresh)
	{
		int w = CRTC6845_CHAR_COLUMNS;
		int h = CRTC6845_CHAR_LINES;
		int height = CRTC6845_CHAR_HEIGHT;

		bitmap.plot_box(0, 0, device->machine().gfx[0]->width * (w + 2), height, FRAMECOLOR);

		bitmap.plot_box(0, height, device->machine().gfx[0]->width, height * h, FRAMECOLOR);

		bitmap.plot_box(device->machine().gfx[0]->width * (w + 1), height, device->machine().gfx[0]->width, height * h, FRAMECOLOR);

		bitmap.plot_box(0, height * (h + 1), device->machine().gfx[0]->width * (w + 2), height, FRAMECOLOR);
	}

	vdc8563->changed = 0;
	return 0;
}

/*****************************************************************************
    DEVICE INTERFACE
*****************************************************************************/

static DEVICE_START( vdc8563 )
{
	vdc8563_state *vdc8563 = get_safe_token(device);
	const vdc8563_interface *intf = (vdc8563_interface *)device->static_config();

	vdc8563->screen = device->machine().device<screen_device>(intf->screen);

	vdc8563->ram = auto_alloc_array_clear(device->machine(), UINT8, 0x20000);
	vdc8563->dirty = vdc8563->ram + 0x10000;

	/* currently no driver uses 16k only */
	if (intf->ram16konly)
	{
		vdc8563->mask = 0x3fff;
		vdc8563->fontmask = 0x2000;
	}
	else
	{
		vdc8563->mask = 0xffff;
		vdc8563->fontmask = 0xe000;
	}

	device->save_pointer(NAME(vdc8563->ram), 0x20000);

	device->save_item(NAME(vdc8563->reg));
	device->save_item(NAME(vdc8563->state));
	device->save_item(NAME(vdc8563->index));

	device->save_item(NAME(vdc8563->addr));
	device->save_item(NAME(vdc8563->src));

	device->save_item(NAME(vdc8563->videoram_start));
	device->save_item(NAME(vdc8563->colorram_start));
	device->save_item(NAME(vdc8563->fontram_start));
	device->save_item(NAME(vdc8563->videoram_size));

	device->save_item(NAME(vdc8563->rastering));

	device->save_item(NAME(vdc8563->fontdirty));

	device->save_item(NAME(vdc8563->cursor_time));
	device->save_item(NAME(vdc8563->cursor_on));

	device->save_item(NAME(vdc8563->changed));
}


static DEVICE_RESET( vdc8563 )
{
	vdc8563_state *vdc8563 = get_safe_token(device);

	memset(vdc8563->reg, 0, ARRAY_LENGTH(vdc8563->reg));
	memset(vdc8563->fontdirty, 0, ARRAY_LENGTH(vdc8563->fontdirty));

	vdc8563->cursor_time = 0.0;
	vdc8563->state = 1;

	vdc8563->index = 0;
	vdc8563->addr = 0;
	vdc8563->src = 0;
	vdc8563->videoram_start = 0;
	vdc8563->colorram_start = 0;
	vdc8563->fontram_start = 0;
	vdc8563->videoram_size = 0;
	vdc8563->rastering = 1;
	vdc8563->cursor_on = 0;
	vdc8563->changed = 0;
}

/*-------------------------------------------------
    device definition
-------------------------------------------------*/

static const char DEVTEMPLATE_SOURCE[] = __FILE__;

#define DEVTEMPLATE_ID(p,s)				p##vdc8563##s
#define DEVTEMPLATE_FEATURES			DT_HAS_START | DT_HAS_RESET
#define DEVTEMPLATE_NAME				"8563 / 8568 VDC"
#define DEVTEMPLATE_FAMILY				"8563 / 8568 VDC"
#include "devtempl.h"

DEFINE_LEGACY_DEVICE(VDC8563, vdc8563);