summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/dp8510.h
blob: 04a0c2b167684120b65508d6dad1d0715de3d4b7 (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
// license:BSD-3-Clause
// copyright-holders:Patrick Mackinlay
#ifndef MAME_VIDEO_DP8510_H
#define MAME_VIDEO_DP8510_H

#pragma once


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

	static const char *const BITBLT_OP[];
	static const int FIFO_SIZE = 16;

	DECLARE_WRITE_LINE_MEMBER(line_drawing) { m_line_drawing = state; }
	DECLARE_WRITE_LINE_MEMBER(barrel_input_select) { m_barrel_input_select = state; }
	DECLARE_WRITE_LINE_MEMBER(pixel_data_input) { m_pixel_data_input = state; }
	DECLARE_WRITE_LINE_MEMBER(data_output_select) { m_data_output_select = state; }
	DECLARE_WRITE_LINE_MEMBER(left_mask_enable) { m_left_mask = state; }
	DECLARE_WRITE_LINE_MEMBER(right_mask_enable) { m_right_mask = state; }

	enum control_mask : u16
	{
		CONTROL_RM = 0x000f, // right mask
		CONTROL_LM = 0x00f0, // left mask
		CONTROL_SN = 0x0f00, // shift number
		CONTROL_FS = 0xf000  // function select
	};

	enum control_fs_mask : u16
	{
		FS_0           = 0x1000,
		FS_1           = 0x2000,
		FS_2           = 0x4000,
		FS_3           = 0x8000
	};

	void control_w(const u16 data);

	void source_w(const u16 data, const bool fifo_write = true);
	void destination_w(const u16 data, const bool fifo_write = false);

	u16 output_r() const;
	u8 pixel_r(const offs_t pixel_address) const;

protected:
	virtual void device_start() override;
	virtual void device_reset() override;

	u16 logic_unit(const u16 src, const u16 dst) const;

	u16 fifo_r();
	void fifo_w(const u16 data);

private:
	// input lines
	int m_line_drawing;
	int m_barrel_input_select;
	int m_pixel_data_input;
	int m_data_output_select;
	int m_left_mask;
	int m_right_mask;

	// registers and latches
	u16 m_control;
	u16 m_barrel_input_latch;
	u16 m_logic_output;
	u16 m_fifo_output_latch;

	// fifo
	u16 m_fifo[FIFO_SIZE];
	u8 m_fifo_head;
	u8 m_fifo_tail;

	// helper internal state
	u16 m_f0;
	u16 m_f1;
	u16 m_f2;
	u16 m_f3;
};

// device type definition
DECLARE_DEVICE_TYPE(DP8510, dp8510_device)

#endif // MAME_VIDEO_DP8510_H