1 // license:LGPL-2.1+
2 // copyright-holders:Angelo Salese
3 /***************************************************************************
4 
5     Seibu CRTC device
6 
7 ***************************************************************************/
8 
9 #ifndef MAME_VIDEO_SEIBU_CRTC_H
10 #define MAME_VIDEO_SEIBU_CRTC_H
11 
12 #pragma once
13 
14 
15 //**************************************************************************
16 //  TYPE DEFINITIONS
17 //**************************************************************************
18 
19 // ======================> seibu_crtc_device
20 
21 class seibu_crtc_device : public device_t,
22 							public device_memory_interface,
23 							public device_video_interface
24 {
25 public:
26 	// construction/destruction
27 	seibu_crtc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
28 
decrypt_key_callback()29 	auto decrypt_key_callback() { return m_decrypt_key_cb.bind(); }
layer_en_callback()30 	auto layer_en_callback() { return m_layer_en_cb.bind(); }
layer_scroll_callback()31 	auto layer_scroll_callback() { return m_layer_scroll_cb.bind(); }
reg_1a_callback()32 	auto reg_1a_callback() { return m_reg_1a_cb.bind(); }
layer_scroll_base_callback()33 	auto layer_scroll_base_callback() { return m_layer_scroll_base_cb.bind(); }
34 
35 	// I/O operations
36 	void write(offs_t offset, uint16_t data);
37 	void write_alt(offs_t offset, uint16_t data);
38 	uint16_t read(offs_t offset);
39 	uint16_t read_alt(offs_t offset);
40 	void decrypt_key_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
41 	void layer_en_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
42 	uint16_t reg_1a_r();
43 	void reg_1a_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
44 	void layer_scroll_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
45 	void layer_scroll_base_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
46 
47 	void seibu_crtc_vregs(address_map &map);
48 protected:
49 	// device-level overrides
50 	virtual void device_validity_check(validity_checker &valid) const override;
51 	virtual void device_start() override;
52 	virtual void device_reset() override;
53 	virtual space_config_vector memory_space_config() const override;
54 
55 private:
56 	devcb_write16       m_decrypt_key_cb;
57 	devcb_write16       m_layer_en_cb;
58 	devcb_write16       m_layer_scroll_cb;
59 	devcb_write16       m_reg_1a_cb;
60 	devcb_write16       m_layer_scroll_base_cb;
61 	const address_space_config      m_space_config;
62 	inline uint16_t read_word(offs_t address);
63 	inline void write_word(offs_t address, uint16_t data);
64 
65 	uint16_t m_reg_1a;
66 };
67 
68 
69 // device type definition
70 DECLARE_DEVICE_TYPE(SEIBU_CRTC, seibu_crtc_device)
71 
72 #endif // MAME_VIDEO_SEIBU_CRTC_H
73