summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/crt.h
blob: 34c546107f356d0f377d8cdc1fcc2ef67315991d (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
// license:GPL-2.0+
// copyright-holders:Raphael Nabet
/*************************************************************************

    video/crt.h

    CRT video emulation for TX-0 and PDP-1

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

#ifndef MAME_VIDEO_CRT_H
#define MAME_VIDEO_CRT_H

#pragma once


//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

#define MCFG_CRT_NUM_LEVELS(_lev) \
	crt_device::set_num_levels(*device, _lev);

#define MCFG_CRT_OFFSETS(_xoffs, _yoffs) \
	crt_device::set_offsets(*device, _xoffs, _yoffs);

#define MCFG_CRT_SIZE(_width, _height) \
	crt_device::set_size(*device, _width, _height);


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

// ======================> crt_device

class crt_device : public device_t
{
public:
	crt_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	static void set_num_levels(device_t &device, int levels) { downcast<crt_device &>(device).m_num_intensity_levels = levels; }
	static void set_offsets(device_t &device, int x_offset, int y_offset)
	{
		crt_device &dev = downcast<crt_device &>(device);
		dev.m_window_offset_x = x_offset;
		dev.m_window_offset_y = y_offset;
	}
	static void set_size(device_t &device, int width, int height)
	{
		crt_device &dev = downcast<crt_device &>(device);
		dev.m_window_width = width;
		dev.m_window_height = height;
	}

	void plot(int x, int y);
	void eof();
	void update(bitmap_ind16 &bitmap);

protected:
	// device-level overrides
	virtual void device_start() override;

private:
	struct crt_point
	{
		crt_point() { }

		int intensity = 0;  /* current intensity of the pixel */
							/* a node is not in the list when (intensity == -1) */
		int next = 0;       /* index of next pixel in list */
	};

	crt_point *m_list; /* array of (crt_window_width*crt_window_height) point */
	std::unique_ptr<int[]> m_list_head;  /* head of the list of lit pixels (index in the array) */
						/* keep a separate list for each display line (makes the video code slightly faster) */

	int m_decay_counter;  /* incremented each frame (tells for how many frames the CRT has decayed between two screen refresh) */

	/* CRT window */
	int m_num_intensity_levels;
	int m_window_offset_x;
	int m_window_offset_y;
	int m_window_width;
	int m_window_height;
};

DECLARE_DEVICE_TYPE(CRT, crt_device)



#endif // MAME_VIDEO_CRT_H