1 // license:BSD-3-Clause
2 // copyright-holders:Dirk Best
3 /***************************************************************************
4 
5     Intel 82730
6 
7     Text Coprocessor
8 
9 ***************************************************************************/
10 
11 #ifndef MAME_VIDEO_I82730_H
12 #define MAME_VIDEO_I82730_H
13 
14 #pragma once
15 
16 //**************************************************************************
17 //  TYPE DEFINITIONS
18 //**************************************************************************
19 
20 #define I82730_UPDATE_ROW(name) \
21 	   void name(bitmap_rgb32 &bitmap, uint16_t *data, uint8_t lc, uint16_t y, int x_count)
22 
23 // ======================> i82730_device
24 
25 class i82730_device : public device_t, public device_video_interface
26 {
27 public:
28 	typedef device_delegate<void (bitmap_rgb32 &bitmap, uint16_t *data, uint8_t lc, uint16_t y, int x_count)> update_row_delegate;
29 
30 	// construction/destruction
31 	template <typename T>
i82730_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock,T && cpu_tag)32 	i82730_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag)
33 		: i82730_device(mconfig, tag, owner, clock)
34 	{
35 		m_cpu.set_tag(std::forward<T>(cpu_tag));
36 	}
37 	i82730_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
38 
39 	// callbacks
sint()40 	auto sint() { return m_sint_handler.bind(); }
41 
42 	// inline configuration
set_update_row_callback(T &&...args)43 	template <typename... T> void set_update_row_callback(T &&... args) { m_update_row_cb.set(std::forward<T>(args)...); }
44 
45 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
46 
47 	DECLARE_WRITE_LINE_MEMBER(ca_w);
48 	DECLARE_WRITE_LINE_MEMBER(irst_w);
49 
50 protected:
51 	virtual void device_start() override;
52 	virtual void device_reset() override;
53 
54 private:
55 	// status
56 	enum
57 	{
58 		DUR  = 0x001,  // data underrun
59 		LPU  = 0x002,  // light pen update
60 		DBOR = 0x004,  // data buffer overrun
61 		EONF = 0x008,  // end of n frames
62 		FDE  = 0x010,  // frame data error
63 		RCC  = 0x020,  // reserved channel command executed
64 		RDC  = 0x040,  // reserved data stream command executed
65 		DIP  = 0x080,  // display in progress
66 		VDIP = 0x100   // virtual display in progress
67 	};
68 
69 	static const char *const s_command_names[];
70 
sysbus_16bit()71 	bool sysbus_16bit() { return BIT(m_sysbus, 0); }
72 
73 	uint8_t read_byte(offs_t address);
74 	uint16_t read_word(offs_t address);
75 	void write_byte(offs_t address, uint8_t data);
76 	void write_word(offs_t address, uint16_t data);
77 
78 	void update_interrupts();
79 	void mode_set();
80 	void execute_command();
81 	void load_row();
82 
83 	TIMER_CALLBACK_MEMBER(row_update);
84 
85 	devcb_write_line m_sint_handler;
86 	update_row_delegate m_update_row_cb;
87 
88 	required_device<cpu_device> m_cpu;
89 	address_space *m_program;
90 
91 	emu_timer *m_row_timer;
92 
93 	bitmap_rgb32 m_bitmap;
94 
95 	bool m_initialized;
96 	bool m_mode_set;
97 
98 	int m_ca;
99 
100 	// internal registers
101 	uint8_t m_sysbus;
102 	uint32_t m_ibp;
103 	uint32_t m_cbp;
104 	uint16_t m_intmask;
105 	uint16_t m_status;
106 
107 	int m_list_switch;
108 	int m_auto_line_feed;
109 	uint8_t m_max_dma_count;
110 
111 	uint32_t m_lptr;
112 	uint32_t m_sptr;
113 
114 	int m_dma_burst_space;
115 	int m_dma_burst_length;
116 
117 	// display parameters
118 	int m_hfldstrt;
119 	int m_margin;
120 	int m_lpr;
121 	uint16_t m_field_attribute_mask;
122 	int m_vsyncstp;
123 	int m_vfldstrt;
124 	int m_vfldstp;
125 
126 	int m_frame_int_count;
127 
128 	// row buffers
129 	struct row_buffer
130 	{
131 		uint16_t data[200];
132 		int count;
133 	};
134 
135 	row_buffer m_row[2];
136 	int m_row_index;
137 };
138 
139 // device type definition
140 DECLARE_DEVICE_TYPE(I82730, i82730_device)
141 
142 #endif // MAME_VIDEO_I82730_H
143