1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #ifndef MAME_INCLUDES_SHANGHA3_H
4 #define MAME_INCLUDES_SHANGHA3_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "sound/okim6295.h"
10 #include "emupal.h"
11 #include "screen.h"
12 
13 class shangha3_state : public driver_device
14 {
15 public:
shangha3_state(const machine_config & mconfig,device_type type,const char * tag)16 	shangha3_state(const machine_config &mconfig, device_type type, const char *tag) :
17 		driver_device(mconfig, type, tag),
18 		m_maincpu(*this, "maincpu"),
19 		m_audiocpu(*this, "audiocpu"),
20 		m_oki(*this, "oki"),
21 		m_gfxdecode(*this, "gfxdecode"),
22 		m_screen(*this, "screen"),
23 		m_palette(*this, "palette"),
24 		m_soundlatch(*this, "soundlatch"),
25 		m_ram(*this, "ram"),
26 		m_cgrom(*this, "gfx1"),
27 		m_okibank(*this, "okibank")
28 	{ }
29 
30 	void shangha3(machine_config &config);
31 	void heberpop(machine_config &config);
32 	void blocken(machine_config &config);
33 
34 	void init_shangha3();
35 	void init_heberpop();
36 	void init_blocken();
37 
38 protected:
39 	virtual void video_start() override;
40 
41 private:
42 	required_device<cpu_device> m_maincpu;
43 	optional_device<cpu_device> m_audiocpu;
44 	required_device<okim6295_device> m_oki;
45 	required_device<gfxdecode_device> m_gfxdecode;
46 	required_device<screen_device> m_screen;
47 	required_device<palette_device> m_palette;
48 	optional_device<generic_latch_8_device> m_soundlatch;
49 
50 	required_shared_ptr<uint16_t> m_ram;
51 	required_region_ptr<uint8_t> m_cgrom;
52 
53 	optional_memory_bank m_okibank;
54 
55 	// driver init configuration
56 	int m_do_shadows;
57 	uint8_t m_drawmode_table[16];
58 
59 	int m_prot_count;
60 	uint16_t m_gfxlist_addr;
61 	bitmap_ind16 m_rawbitmap;
62 
63 	// common
64 	void flipscreen_w(uint8_t data);
65 	void gfxlist_addr_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
66 	void blitter_go_w(uint16_t data);
67 	void irq_ack_w(uint16_t data);
68 	uint8_t cgrom_r(offs_t offset);
69 
70 	// shangha3 specific
71 	uint16_t shangha3_prot_r();
72 	void shangha3_prot_w(uint16_t data);
73 	void shangha3_coinctrl_w(uint8_t data);
74 
75 	// heberpop specific
76 	void heberpop_coinctrl_w(uint8_t data);
77 
78 	// blocken specific
79 	void blocken_coinctrl_w(uint8_t data);
80 
81 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
82 
83 	void blocken_map(address_map &map);
84 	void blocken_oki_map(address_map &map);
85 	void heberpop_map(address_map &map);
86 	void heberpop_sound_io_map(address_map &map);
87 	void heberpop_sound_map(address_map &map);
88 	void shangha3_map(address_map &map);
89 };
90 
91 #endif // MAME_INCLUDES_SHANGHA3_H
92