1 // license:BSD-3-Clause
2 // copyright-holders:Olivier Galibert
3 #ifndef MAME_INCLUDES_TAITO_L_H
4 #define MAME_INCLUDES_TAITO_L_H
5 
6 #pragma once
7 
8 #include "machine/74157.h"
9 #include "machine/bankdev.h"
10 #include "machine/tc009xlvc.h"
11 #include "machine/timer.h"
12 #include "machine/upd4701.h"
13 #include "sound/msm5205.h"
14 #include "sound/2203intf.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 
19 class taitol_state : public driver_device
20 {
21 public:
taitol_state(const machine_config & mconfig,device_type type,const char * tag)22 	taitol_state(const machine_config &mconfig, device_type type, const char *tag)
23 		: driver_device(mconfig, type, tag)
24 		, m_main_cpu(*this, "maincpu")
25 		, m_vdp(*this, "tc0090lvc")
26 		, m_upd4701(*this, "upd4701")
27 		, m_main_prg(*this, "tc0090lvc")
28 	{
29 	}
30 
31 	DECLARE_MACHINE_START(taito_l);
32 	DECLARE_MACHINE_RESET(taito_l);
33 	IRQ_CALLBACK_MEMBER(irq_callback);
34 
35 	void coin_control_w(u8 data);
36 
37 protected:
38 	/* misc */
39 	int m_last_irq_level;
40 	void irq_enable_w(u8 data);
41 
42 	void mcu_control_w(u8 data);
43 	u8 mcu_control_r();
44 	DECLARE_WRITE_LINE_MEMBER(screen_vblank_taitol);
45 	TIMER_DEVICE_CALLBACK_MEMBER(vbl_interrupt);
46 
47 	void l_system_video(machine_config &config);
48 
49 	void common_banks_map(address_map &map);
50 
51 	virtual void state_register();
52 	virtual void taito_machine_reset();
53 
54 	required_device<cpu_device>       m_main_cpu;
55 	required_device<tc0090lvc_device> m_vdp;
56 	optional_device<upd4701_device>   m_upd4701;
57 	required_memory_region            m_main_prg;
58 };
59 
60 
61 class taitol_2cpu_state : public taitol_state
62 {
63 public:
taitol_2cpu_state(const machine_config & mconfig,device_type type,const char * tag)64 	taitol_2cpu_state(const machine_config &mconfig, device_type type, const char *tag)
65 		: taitol_state(mconfig, type, tag)
66 		, m_audio_cpu(*this, "audiocpu")
67 		, m_audio_prg(*this, "audiocpu")
68 		, m_audio_bnk(*this, "audiobank")
69 	{
70 	}
71 
72 	void sound_bankswitch_w(u8 data);
73 
74 	void kurikint(machine_config &config);
75 	void evilston(machine_config &config);
76 	void raimais(machine_config &config);
77 
78 protected:
79 	virtual void state_register() override;
80 	virtual void taito_machine_reset() override;
81 
82 	void evilston_2_map(address_map &map);
83 	void evilston_map(address_map &map);
84 	void kurikint_2_map(address_map &map);
85 	void kurikint_map(address_map &map);
86 	void raimais_2_map(address_map &map);
87 	void raimais_3_map(address_map &map);
88 	void raimais_map(address_map &map);
89 
90 	required_device<cpu_device> m_audio_cpu;
91 	required_memory_region      m_audio_prg;
92 	optional_memory_bank        m_audio_bnk;
93 };
94 
95 
96 class fhawk_state : public taitol_2cpu_state
97 {
98 public:
fhawk_state(const machine_config & mconfig,device_type type,const char * tag)99 	fhawk_state(const machine_config &mconfig, device_type type, const char *tag)
100 		: taitol_2cpu_state(mconfig, type, tag)
101 		, m_slave_prg(*this, "slave")
102 		, m_slave_bnk(*this, "slavebank")
103 		, m_slave_rombank(0)
104 	{
105 	}
106 
107 	void slave_rombank_w(u8 data);
108 	u8 slave_rombank_r();
109 	void portA_w(u8 data);
110 
111 	void fhawk(machine_config &config);
112 
113 protected:
114 	virtual void state_register() override;
115 	virtual void taito_machine_reset() override;
116 
117 	void fhawk_2_map(address_map &map);
118 	void fhawk_3_map(address_map &map);
119 	void fhawk_map(address_map &map);
120 
121 	required_memory_region      m_slave_prg;
122 	required_memory_bank        m_slave_bnk;
123 
124 	u8  m_slave_rombank;
125 };
126 
127 
128 class champwr_state : public fhawk_state
129 {
130 public:
champwr_state(const machine_config & mconfig,device_type type,const char * tag)131 	champwr_state(const machine_config &mconfig, device_type type, const char *tag)
132 		: fhawk_state(mconfig, type, tag)
133 		, m_msm(*this, "msm")
134 		, m_adpcm_rgn(*this, "adpcm")
135 		, m_adpcm_pos(0)
136 		, m_adpcm_data(-1)
137 	{
138 	}
139 
140 	DECLARE_WRITE_LINE_MEMBER(msm5205_vck);
141 
142 	void msm5205_lo_w(u8 data);
143 	void msm5205_hi_w(u8 data);
144 	void msm5205_start_w(u8 data);
145 	void msm5205_stop_w(u8 data);
146 	void msm5205_volume_w(u8 data);
147 
148 	void champwr(machine_config &config);
149 
150 protected:
151 	virtual void state_register() override;
152 	virtual void taito_machine_reset() override;
153 
154 	void champwr_2_map(address_map &map);
155 	void champwr_3_map(address_map &map);
156 	void champwr_map(address_map &map);
157 
158 	required_device<msm5205_device> m_msm;
159 	required_region_ptr<u8>         m_adpcm_rgn;
160 
161 	int m_adpcm_pos;
162 	int m_adpcm_data;
163 };
164 
165 
166 class taitol_1cpu_state : public taitol_state
167 {
168 public:
taitol_1cpu_state(const machine_config & mconfig,device_type type,const char * tag)169 	taitol_1cpu_state(const machine_config &mconfig, device_type type, const char *tag)
170 		: taitol_state(mconfig, type, tag)
171 		, m_ymsnd(*this, "ymsnd")
172 		, m_mux(*this, {"dswmux", "inmux"})
173 	{
174 	}
175 
176 	u8 extport_select_and_ym2203_r(offs_t offset);
177 
178 	void init_plottinga();
179 
180 	DECLARE_MACHINE_RESET(plotting);
181 	DECLARE_MACHINE_RESET(puzznic);
182 	DECLARE_MACHINE_RESET(palamed);
183 	DECLARE_MACHINE_RESET(cachat);
184 
185 	void base(machine_config &config);
186 	void add_muxes(machine_config &config);
187 	void palamed(machine_config &config);
188 	void plotting(machine_config &config);
189 	void puzznici(machine_config &config);
190 	void cachat(machine_config &config);
191 	void puzznic(machine_config &config);
192 
193 protected:
194 	virtual void state_register() override;
195 	virtual void taito_machine_reset() override;
196 
197 	void palamed_map(address_map &map);
198 	void plotting_map(address_map &map);
199 	void puzznic_map(address_map &map);
200 	void puzznici_map(address_map &map);
201 
202 	required_device<ym2203_device>  m_ymsnd;
203 	optional_device_array<ls157_x2_device, 2> m_mux;
204 };
205 
206 
207 class horshoes_state : public taitol_1cpu_state
208 {
209 public:
horshoes_state(const machine_config & mconfig,device_type type,const char * tag)210 	horshoes_state(const machine_config &mconfig, device_type type, const char *tag)
211 		: taitol_1cpu_state(mconfig, type, tag)
212 	{
213 	}
214 
215 	void horshoes(machine_config &config);
216 
217 protected:
218 	virtual void machine_start() override;
219 	virtual void machine_reset() override;
220 
221 private:
222 	void horshoes_tile_cb(u32 &code);
223 
224 	void bankg_w(u8 data);
225 	int m_horshoes_gfxbank;
226 
227 	void horshoes_map(address_map &map);
228 };
229 
230 #endif // MAME_INCLUDES_TAITO_L_H
231