summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/video/crt9021.c
blob: 13844f4808f429ba8bc167bbbf6434d2888056a5 (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
/**********************************************************************

    SMC CRT9021 Video Attributes Controller (VAC) emulation

    Copyright MESS Team.
    Visit http://mamedev.org for licensing and usage restrictions.

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

/*

    TODO:

    - attributes
        - reverse video
        - character blank
        - character blink
        - underline
        - full/half intensity
    - operation modes
        - wide graphics
        - thin graphics
        - character mode w/o underline
        - character mode w/underline
    - double height characters
    - double width characters
    - parallel scan line
    - serial scan line
    - cursor
        - underline
        - blinking underline
        - reverse video
        - blinking reverse video
    - programmable character blink rate (75/25 duty)
    - programmable cursor blink rate (50/50 duty)
    - data/attribute latches

*/

#include "emu.h"
#include "crt9021.h"



//**************************************************************************
//  MACROS / CONSTANTS
//**************************************************************************

#define LOG 1


// attributes
enum
{
	ATTRIBUTE_REVID = 0x80,
	ATTRIBUTE_INT   = 0x40,
	ATTRIBUTE_BLINK = 0x20,
	ATTRIBUTE_MS1   = 0x10,
	ATTRIBUTE_MS0   = 0x08,
	ATTRIBUTE_CHABL = 0x04,
	ATTRIBUTE_BKC   = 0x02,
	ATTRIBUTE_BLC   = 0x01
};


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

// devices
const device_type CRT9021 = crt9021_device_config::static_alloc_device_config;



//**************************************************************************
//  DEVICE CONFIGURATION
//**************************************************************************

//-------------------------------------------------
//  crt9021_device_config - constructor
//-------------------------------------------------

crt9021_device_config::crt9021_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
	: device_config(mconfig, static_alloc_device_config, "SMC CRT9021", tag, owner, clock)
{
}


//-------------------------------------------------
//  static_alloc_device_config - allocate a new
//  configuration object
//-------------------------------------------------

device_config *crt9021_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
{
	return global_alloc(crt9021_device_config(mconfig, tag, owner, clock));
}


//-------------------------------------------------
//  alloc_device - allocate a new device object
//-------------------------------------------------

device_t *crt9021_device_config::alloc_device(running_machine &machine) const
{
	return auto_alloc(&machine, crt9021_device(machine, *this));
}


//-------------------------------------------------
//  device_config_complete - perform any
//  operations now that the configuration is
//  complete
//-------------------------------------------------

void crt9021_device_config::device_config_complete()
{
	// inherit a copy of the static data
	const crt9021_interface *intf = reinterpret_cast<const crt9021_interface *>(static_config());
	if (intf != NULL)
		*static_cast<crt9021_interface *>(this) = *intf;

	// or initialize to defaults if none provided
	else
	{
		memset(&in_data_func, 0, sizeof(in_data_func));
		memset(&in_attr_func, 0, sizeof(in_attr_func));
		memset(&in_atten_func, 0, sizeof(in_atten_func));
	}
}



//**************************************************************************
//  INLINE HELPERS
//**************************************************************************



//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  crt9021_device - constructor
//-------------------------------------------------

crt9021_device::crt9021_device(running_machine &_machine, const crt9021_device_config &config)
    : device_t(_machine, config),
      m_config(config)
{
}


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

void crt9021_device::device_start()
{
	// allocate timers

	// resolve callbacks
	devcb_resolve_read8(&m_in_data_func, &m_config.in_data_func, this);
	devcb_resolve_read8(&m_in_attr_func, &m_config.in_attr_func, this);
	devcb_resolve_read_line(&m_in_atten_func, &m_config.in_atten_func, this);

	// get the screen device
	m_screen = machine->device<screen_device>(m_config.screen_tag);
	assert(m_screen != NULL);

	// register for state saving
	save_item(NAME(m_slg));
	save_item(NAME(m_sld));
	save_item(NAME(m_cursor));
	save_item(NAME(m_retbl));
	save_item(NAME(m_vsync));
}


//-------------------------------------------------
//  device_clock_changed - handle clock change
//-------------------------------------------------

void crt9021_device::device_clock_changed()
{
}


//-------------------------------------------------
//  device_timer - handle timer events
//-------------------------------------------------

void crt9021_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
}


//-------------------------------------------------
//  slg_w - scan line gate
//-------------------------------------------------

WRITE_LINE_MEMBER( crt9021_device::slg_w )
{
	if (LOG) logerror("CRT9021 '%s' SLG: %u\n", tag(), state);

	m_slg = state;
}


//-------------------------------------------------
//  sld_w - scan line data
//-------------------------------------------------

WRITE_LINE_MEMBER( crt9021_device::sld_w )
{
	if (LOG) logerror("CRT9021 '%s' SLG: %u\n", tag(), state);

	if (!m_slg)
	{
		m_sld <<= 1;
		m_sld |= state;
	}
}


//-------------------------------------------------
//  cursor_w - cursor
//-------------------------------------------------

WRITE_LINE_MEMBER( crt9021_device::cursor_w )
{
	if (LOG) logerror("CRT9021 '%s' CURSOR: %u\n", tag(), state);

	m_cursor = state;
}


//-------------------------------------------------
//  retbl_w - retrace blank
//-------------------------------------------------

WRITE_LINE_MEMBER( crt9021_device::retbl_w )
{
	if (LOG) logerror("CRT9021 '%s' RETBL: %u\n", tag(), state);

	m_retbl = state;
}


//-------------------------------------------------
//  vsync_w - vertical sync
//-------------------------------------------------

WRITE_LINE_MEMBER( crt9021_device::vsync_w )
{
	if (LOG) logerror("CRT9021 '%s' VSYNC: %u\n", tag(), state);

	m_vsync = state;
}


//-------------------------------------------------
//  update_screen - update screen
//-------------------------------------------------

void crt9021_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect)
{
}