1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4 
5     VideoBrain UV201/UV202 video chip emulation
6 
7 **********************************************************************
8                             _____   _____
9                    GND   1 |*    \_/     | 40  DMAREQ
10                      G   2 |             | 39  /CE
11                      I   3 |             | 38  RESET
12                      B   4 |             | 37  BISTROBE
13                      R   5 |             | 36  UMIREQ0
14                    BA0   6 |             | 35  BRCLK
15                    BA1   7 |             | 34  HBLANK
16                    BA2   8 |             | 33  VBLANK
17                    BA3   9 |             | 32  R/W
18                    BA4  10 |    UV201    | 31  keypad column 8
19                    BA5  11 |             | 30  EXT INT
20                    BA6  12 |             | 29  FIELD
21                    BA7  13 |             | 28  BD7
22                    BA8  14 |             | 27  BD6
23                    BA9  15 |             | 26  BD5
24                   BA10  16 |             | 25  BD4
25                   BA11  17 |             | 24  BD3
26                   BA12  18 |             | 23  BD2
27                    +5V  19 |             | 22  BD1
28                   +12V  20 |_____________| 21  BD0
29 
30                             _____   _____
31                UMIREQ1   1 |*    \_/     | 40  BISTROBE
32                UMIREQ0   2 |             | 39  CPUREQ1
33                CPUREQ0   3 |             | 38  GND
34                    XIN   4 |             | 37  /800-BFF
35                   XOUT   5 |             | 36  RST
36                DMAREQ0   6 |             | 35  DMAREQ1
37                CPU CLK   7 |             | 34  COLCLK
38                   WACK   8 |             | 33  BRCLK
39                     D0   9 |             | 32  D7
40                    BD0  10 |    UV202    | 31  BD7
41                     D1  11 |             | 30  D6
42                    BD1  12 |             | 29  BD6
43                     D2  13 |             | 28  D5
44                    BD2  14 |             | 27  BD5
45                     D3  15 |             | 26  D4
46                    BD3  16 |             | 25  BD4
47                 HBLANK  17 |             | 24  FIELD
48                 VBLANK  18 |             | 23  SCANLINE
49                  BURST  19 |             | 22  +12V
50                 CSYNCH  20 |_____________| 21  +5V
51 
52 **********************************************************************/
53 
54 #ifndef MAME_VIDEO_UV201_H
55 #define MAME_VIDEO_UV201_H
56 
57 #pragma once
58 
59 
60 #include "screen.h"
61 
62 
63 //**************************************************************************
64 //  TYPE DEFINITIONS
65 //**************************************************************************
66 
67 // ======================> uv201_device
68 
69 class uv201_device :    public device_t,
70 						public device_video_interface
71 {
72 public:
73 	// construction/destruction
74 	uv201_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
75 
ext_int_wr_callback()76 	auto ext_int_wr_callback() { return m_write_ext_int.bind(); }
hblank_wr_callback()77 	auto hblank_wr_callback() { return m_write_hblank.bind(); }
db_rd_callback()78 	auto db_rd_callback() { return m_read_db.bind(); }
79 
80 	uint8_t read(offs_t offset);
81 	void write(offs_t offset, uint8_t data);
82 
83 	DECLARE_WRITE_LINE_MEMBER( ext_int_w );
84 	DECLARE_READ_LINE_MEMBER( kbd_r );
85 
86 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
87 
88 protected:
89 	// device-level overrides
90 	virtual void device_start() override;
91 	virtual void device_reset() override;
92 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
93 
94 private:
95 	enum
96 	{
97 		TIMER_Y_ODD,
98 		TIMER_Y_EVEN,
99 		TIMER_HBLANK_ON,
100 		TIMER_HBLANK_OFF
101 	};
102 
103 	void initialize_palette();
104 	int get_field_vpos();
105 	int get_field();
106 	void set_y_interrupt();
107 	void do_partial_update();
108 
109 	devcb_write_line   m_write_ext_int;
110 	devcb_write_line   m_write_hblank;
111 	devcb_read8        m_read_db;
112 
113 	rgb_t m_palette_val[32];
114 	uint8_t m_ram[0x90];
115 	uint8_t m_y_int;
116 	uint8_t m_fmod;
117 	uint8_t m_bg;
118 	uint8_t m_cmd;
119 	uint8_t m_freeze_x;
120 	uint16_t m_freeze_y;
121 	int m_field;
122 
123 	// timers
124 	emu_timer *m_timer_y_odd;
125 	emu_timer *m_timer_y_even;
126 	emu_timer *m_timer_hblank_on;
127 	emu_timer *m_timer_hblank_off;
128 };
129 
130 
131 // device type definition
132 DECLARE_DEVICE_TYPE(UV201, uv201_device)
133 
134 #endif // MAME_VIDEO_UV201_H
135