1 // license:BSD-3-Clause
2 // copyright-holders:Bryan McPhail, Charles MacDonald, David Haywood
3 #include "video/deco16ic.h"
4 #include "video/decospr.h"
5 #include "machine/deco146.h"
6 #include "emupal.h"
7 
8 class sshangha_state : public driver_device
9 {
10 public:
sshangha_state(const machine_config & mconfig,device_type type,const char * tag)11 	sshangha_state(const machine_config &mconfig, device_type type, const char *tag)
12 		: driver_device(mconfig, type, tag),
13 		m_deco146(*this, "ioprot"),
14 		m_tilegen(*this, "tilegen"),
15 		m_spriteram(*this, "spriteram"),
16 		m_spriteram2(*this, "spriteram2"),
17 		m_sound_shared_ram(*this, "sound_shared"),
18 		m_pf1_rowscroll(*this, "pf1_rowscroll"),
19 		m_pf2_rowscroll(*this, "pf2_rowscroll"),
20 		m_prot_data(*this, "prot_data"),
21 		m_sprgen1(*this, "spritegen1"),
22 		m_sprgen2(*this, "spritegen2"),
23 		m_maincpu(*this, "maincpu"),
24 		m_audiocpu(*this, "audiocpu"),
25 		m_palette(*this, "palette")
26 	{ }
27 
28 	void sshanghab(machine_config &config);
29 	void sshangha(machine_config &config);
30 
31 	void init_sshangha();
32 
33 protected:
34 	virtual void video_start() override;
35 
36 private:
37 	optional_device<deco146_device> m_deco146;
38 	required_device<deco16ic_device> m_tilegen;
39 	required_shared_ptr<uint16_t> m_spriteram;
40 	required_shared_ptr<uint16_t> m_spriteram2;
41 
42 	required_shared_ptr<uint16_t> m_sound_shared_ram;
43 	required_shared_ptr<uint16_t> m_pf1_rowscroll;
44 	required_shared_ptr<uint16_t> m_pf2_rowscroll;
45 
46 	optional_shared_ptr<uint16_t> m_prot_data;
47 
48 	required_device<decospr_device> m_sprgen1;
49 	required_device<decospr_device> m_sprgen2;
50 	required_device<cpu_device> m_maincpu;
51 	required_device<cpu_device> m_audiocpu;
52 	required_device<palette_device> m_palette;
53 
54 	int m_video_control;
55 	DECO16IC_BANK_CB_MEMBER(bank_callback);
56 	u16 mix_callback(u16 p, u16 p2);
57 
58 	uint16_t sshangha_protection_region_8_146_r(offs_t offset);
59 	void sshangha_protection_region_8_146_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
60 	uint16_t sshangha_protection_region_d_146_r(offs_t offset);
61 	void sshangha_protection_region_d_146_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
62 	uint16_t deco_71_r();
63 	uint16_t sshanghab_protection16_r(offs_t offset);
64 
65 	uint8_t sound_shared_r(offs_t offset);
66 	void sound_shared_w(offs_t offset, uint8_t data);
67 
68 	void video_w(uint16_t data);
69 
70 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
71 
72 	void sshangha_map(address_map &map);
73 	void sound_map(address_map &map);
74 	void sshanghab_map(address_map &map);
75 };
76