1 // license:BSD-3-Clause
2 // copyright-holders:Roberto Fresca, Peter Ferrie
3 #ifndef MAME_INCLUDES_FUNWORLD_H
4 #define MAME_INCLUDES_FUNWORLD_H
5 
6 #pragma once
7 
8 #include "emupal.h"
9 #include "machine/i2cmem.h"
10 #include "sound/ay8910.h"
11 #include "video/mc6845.h"
12 #include "tilemap.h"
13 
14 class funworld_state : public driver_device
15 {
16 public:
funworld_state(const machine_config & mconfig,device_type type,const char * tag)17 	funworld_state(const machine_config &mconfig, device_type type, const char *tag) :
18 		driver_device(mconfig, type, tag),
19 		m_maincpu(*this, "maincpu"),
20 		m_gfxdecode(*this, "gfxdecode"),
21 		m_videoram(*this, "videoram"),
22 		m_colorram(*this, "colorram"),
23 		m_palette(*this, "palette"),
24 		m_i2cmem(*this, "i2cmem"),
25 		m_lamps(*this, "lamp%u", 0U)
26 	{ }
27 
28 	void royalcd1(machine_config &config);
29 	void royalcd2(machine_config &config);
30 	void fw1stpal(machine_config &config);
31 	void fw2ndpal(machine_config &config);
32 	void saloon(machine_config &config);
33 	void cuoreuno(machine_config &config);
34 	void funquiz(machine_config &config);
35 	void witchryl(machine_config &config);
36 	void fw_brick_1(machine_config &config);
37 	void fw_brick_2(machine_config &config);
38 	void gratispk(machine_config &config);
39 
40 	void init_saloon();
41 	void init_mongolnw();
42 	void init_soccernw();
43 	void init_tabblue();
44 	void init_dino4();
45 	void init_ctunk();
46 	void init_jolycdig();
47 	void init_impera16();
48 
49 protected:
50 	void funworld_videoram_w(offs_t offset, uint8_t data);
51 	void funworld_colorram_w(offs_t offset, uint8_t data);
52 	void funworld_lamp_a_w(uint8_t data);
53 	void funworld_lamp_b_w(uint8_t data);
54 
machine_start()55 	virtual void machine_start() override { m_lamps.resolve(); }
56 	virtual void video_start() override;
57 	void funworld_palette(palette_device &palette) const;
58 	uint32_t screen_update_funworld(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
59 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
60 
61 	void magicrd2_map(address_map &map);
62 
63 	required_device<cpu_device> m_maincpu;
64 	required_device<gfxdecode_device> m_gfxdecode;
65 	tilemap_t *m_bg_tilemap = nullptr;
66 
67 private:
68 	uint8_t questions_r(offs_t offset);
69 	void question_bank_w(uint8_t data);
70 	DECLARE_WRITE_LINE_MEMBER(pia1_ca2_w);
71 	uint8_t funquiz_ay8910_a_r();
72 	uint8_t funquiz_ay8910_b_r();
73 
74 	void cuoreuno_map(address_map &map);
75 	void funquiz_map(address_map &map);
76 	void funworld_map(address_map &map);
77 	void fw_brick_map(address_map &map);
78 	void saloon_map(address_map &map);
79 	void witchryl_map(address_map &map);
80 	void gratispk_map(address_map &map);
81 
82 	required_shared_ptr<uint8_t> m_videoram;
83 	required_shared_ptr<uint8_t> m_colorram;
84 	required_device<palette_device> m_palette;
85 	optional_device<i2cmem_device> m_i2cmem;
86 	output_finder<8> m_lamps;
87 };
88 
89 
90 class magicrd2_state : public funworld_state
91 {
92 public:
93 	using funworld_state::funworld_state;
94 
95 	void magicrd2(machine_config &config);
96 
97 	void init_magicd2b();
98 	void init_magicd2c();
99 
100 protected:
101 	virtual void video_start() override;
102 };
103 
104 
105 class lunapark_state : public funworld_state
106 {
107 public:
108 	using funworld_state::funworld_state;
109 
110 	void lunapark(machine_config &config);
111 
112 protected:
113 	virtual void machine_start() override;
114 	virtual void machine_reset() override;
115 
116 private:
117 	void lunapark_map(address_map &map);
118 };
119 
120 
121 class chinatow_state : public funworld_state
122 {
123 public:
124 	using funworld_state::funworld_state;
125 
126 	void chinatow(machine_config &config);
127 	void rcdino4(machine_config &config);
128 
129 	void init_rcdino4();
130 	void init_rcdinch();
131 
132 protected:
133 	virtual void video_start() override;
134 
135 private:
136 	uint8_t chinatow_r_32f0(offs_t offset);
137 
138 	void chinatow_map(address_map &map);
139 };
140 
141 
142 class multiwin_state : public funworld_state
143 {
144 public:
145 
146 	using funworld_state::funworld_state;
147 
148 	void multiwin(machine_config& config);
149 
150 	void driver_init() override;
151 
152 protected:
153 	virtual void video_start() override;
154 
155 private:
156 	cpu_device* _maincpu {};
157 	uint8_t multiwin_opcode_r(offs_t offset);
158 
159 	void multiwin_opcodes_map(address_map& map);
160 };
161 
162 class royalcrdf_state : public funworld_state
163 {
164 public:
165 	using funworld_state::funworld_state;
166 
167 	void royalcrdf(machine_config& config);
168 
169 	void driver_init() override;
170 
171 private:
172 	cpu_device* _maincpu {};
173 	uint8_t royalcrdf_opcode_r(offs_t offset);
174 
175 	void royalcrdf_map(address_map& map);
176 	void royalcrdf_opcodes_map(address_map& map);
177 };
178 
179 class intergames_state : public funworld_state
180 {
181 public:
intergames_state(const machine_config & mconfig,device_type type,const char * tag)182 	intergames_state(const machine_config &mconfig, device_type type, const char *tag) :
183 		funworld_state(mconfig, type, tag),
184 		m_crtc(*this, "crtc"),
185 		m_ay8910(*this, "ay8910"),
186 		m_crtc_selected(false)
187 	{ }
188 
189 	void intrgmes(machine_config &config);
190 
191 protected:
192 	virtual void driver_init() override;
193 	virtual void machine_reset() override;
194 
195 private:
196 	uint8_t crtc_or_psg_r(offs_t offset);
197 	void crtc_or_psg_w(offs_t offset, uint8_t data);
198 	uint8_t prot_r(offs_t offset);
199 	void prot_w(offs_t offset, uint8_t data);
200 
201 	void intergames_map(address_map &map);
202 
203 	required_device<mc6845_device> m_crtc;
204 	required_device<ay8910_device> m_ay8910;
205 
206 	bool m_crtc_selected;
207 };
208 
209 #endif // MAME_INCLUDES_FUNWORLD_H
210