1 // license:BSD-3-Clause
2 // copyright-holders:Olivier Galibert
3 /***************************************************************************
4 
5     MSM6222B
6 
7     A somewhat hd44780-compatible LCD controller.
8 
9     The -01 variant has a fixed cgrom, the other variants are mask-programmed.
10 
11 ***************************************************************************/
12 
13 #ifndef MAME_VIDEO_MSM6222B_H
14 #define MAME_VIDEO_MSM6222B_H
15 
16 #pragma once
17 
18 
19 class msm6222b_device : public device_t {
20 public:
21 	msm6222b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
22 
23 	void control_w(uint8_t data);
24 	uint8_t control_r();
25 	void data_w(uint8_t data);
26 
27 	// Character n bits are at bytes n*16..n*16+7 when 8-high, +10 when 11-high.  Only the low 5 bits are used.
28 	// In one line mode n = 0..79.  In two line mode first line is 0..39 and second is 40..79.
29 	const uint8_t *render();
30 
31 protected:
32 	msm6222b_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
33 
34 	virtual void device_start() override;
35 
36 	optional_region_ptr<uint8_t> m_cgrom;
37 
38 	void cursor_step(bool direction);
39 	void shift_step(bool direction);
40 	bool blink_on() const;
41 
42 private:
43 	uint8_t cgram[8*8];
44 	uint8_t ddram[80];
45 	uint8_t render_buf[80*16];
46 	bool cursor_direction, cursor_blinking, two_line, shift_on_write, double_height, cursor_on, display_on;
47 	uint8_t adc, shift;
48 };
49 
50 class msm6222b_01_device : public msm6222b_device {
51 public:
52 	msm6222b_01_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
53 
54 protected:
55 	virtual const tiny_rom_entry *device_rom_region() const override;
56 };
57 
58 DECLARE_DEVICE_TYPE(MSM6222B,    msm6222b_device)
59 DECLARE_DEVICE_TYPE(MSM6222B_01, msm6222b_01_device)
60 
61 #endif // MAME_VIDEO_MSM6222B_H
62