1 // license:BSD-3-Clause
2 // copyright-holders:David Graves
3 /*************************************************************************
4 
5 
6     Taito Z system
7 
8 *************************************************************************/
9 #ifndef MAME_INCLUDES_TAITO_Z_H
10 #define MAME_INCLUDES_TAITO_Z_H
11 
12 #pragma once
13 
14 #include "audio/taitosnd.h"
15 #include "machine/eepromser.h"
16 #include "machine/taitoio.h"
17 #include "sound/flt_vol.h"
18 #include "video/tc0100scn.h"
19 #include "video/tc0110pcr.h"
20 #include "video/tc0150rod.h"
21 #include "video/tc0480scp.h"
22 #include "screen.h"
23 
24 
25 class taitoz_state : public driver_device
26 {
27 public:
taitoz_state(const machine_config & mconfig,device_type type,const char * tag)28 	taitoz_state(const machine_config &mconfig, device_type type, const char *tag) :
29 		driver_device(mconfig, type, tag),
30 		m_spriteram(*this, "spriteram"),
31 		m_spritemap(*this, "spritemap"),
32 		m_z80bank(*this, "z80bank"),
33 		m_maincpu(*this, "maincpu"),
34 		m_audiocpu(*this, "audiocpu"),
35 		m_subcpu(*this, "sub"),
36 		m_eeprom(*this, "eeprom"),
37 		m_tc0480scp(*this, "tc0480scp"),
38 		m_tc0150rod(*this, "tc0150rod"),
39 		m_tc0100scn(*this, "tc0100scn"),
40 		m_tc0110pcr(*this, "tc0110pcr"),
41 		m_tc0040ioc(*this, "tc0040ioc"),
42 		m_tc0220ioc(*this, "tc0220ioc"),
43 		m_tc0510nio(*this, "tc0510nio"),
44 		m_tc0140syt(*this, "tc0140syt"),
45 		m_screen(*this, "screen"),
46 		m_gfxdecode(*this, "gfxdecode"),
47 		m_filter(*this, {"2610.1.r", "2610.1.l", "2610.2.r", "2610.2.l"}),
48 		m_gas(*this, "GAS"),
49 		m_brake(*this, "BRAKE"),
50 		m_steer(*this, "STEER"),
51 		m_stickx(*this, "STICKX"),
52 		m_sticky(*this, "STICKY"),
53 		m_io_eepromout(*this, "EEPROMOUT"),
54 		m_lamps(*this, "lamp%u", 0U)
55 	{ }
56 
57 	DECLARE_CUSTOM_INPUT_MEMBER(gas_pedal_r);
58 	DECLARE_CUSTOM_INPUT_MEMBER(brake_pedal_r);
59 	template <int axis> DECLARE_CUSTOM_INPUT_MEMBER(adstick_r);
60 
61 	void bshark_base(machine_config &config);
62 	void sci(machine_config &config);
63 	void spacegun(machine_config &config);
64 	void chasehq(machine_config &config);
65 	void dblaxle(machine_config &config);
66 	void bshark(machine_config &config);
67 	void aquajack(machine_config &config);
68 	void nightstr(machine_config &config);
69 	void contcirc(machine_config &config);
70 	void racingb(machine_config &config);
71 	void bsharkjjs(machine_config &config);
72 	void enforce(machine_config &config);
73 
74 	void init_bshark();
75 
76 protected:
77 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
78 	virtual void device_post_load() override;
79 	virtual void machine_start() override;
80 	virtual void machine_reset() override;
81 	void screen_config(machine_config &config, int vdisp_start, int vdisp_end);
82 
83 private:
84 	enum
85 	{
86 		TIMER_TAITOZ_INTERRUPT6,
87 	};
88 
89 	/* memory pointers */
90 	required_shared_ptr<u16> m_spriteram;
91 	required_region_ptr<u16> m_spritemap;
92 
93 	optional_memory_bank m_z80bank;
94 
95 	/* video-related */
96 	int      m_sci_spriteframe;
97 	int      m_road_palbank;
98 
99 	/* misc */
100 	u16      m_cpua_ctrl;
101 	s32      m_sci_int6;
102 	s32      m_ioc220_port;
103 	u8       m_eep_latch;
104 
105 	/* devices */
106 	required_device<cpu_device> m_maincpu;
107 	optional_device<cpu_device> m_audiocpu;
108 	required_device<cpu_device> m_subcpu;
109 	optional_device<eeprom_serial_93cxx_device> m_eeprom;
110 	optional_device<tc0480scp_device> m_tc0480scp;
111 	optional_device<tc0150rod_device> m_tc0150rod;
112 	optional_device<tc0100scn_device> m_tc0100scn;
113 	optional_device<tc0110pcr_device> m_tc0110pcr;
114 	optional_device<tc0040ioc_device> m_tc0040ioc;
115 	optional_device<tc0220ioc_device> m_tc0220ioc;
116 	optional_device<tc0510nio_device> m_tc0510nio;
117 	optional_device<tc0140syt_device> m_tc0140syt;  // bshark & spacegun miss the CPUs which shall use TC0140
118 	required_device<screen_device> m_screen;
119 	required_device<gfxdecode_device> m_gfxdecode;
120 	optional_device_array<filter_volume_device, 4> m_filter;
121 	optional_ioport m_gas;
122 	optional_ioport m_brake;
123 	optional_ioport m_steer;
124 	optional_ioport m_stickx;
125 	optional_ioport m_sticky;
126 	optional_ioport m_io_eepromout;
127 	output_finder<2> m_lamps;
128 
129 	void cpua_ctrl_w(offs_t offset, u16 data, u16 mem_mask = ~0);
130 	void chasehq_cpua_ctrl_w(offs_t offset, u16 data, u16 mem_mask = ~0);
131 	void dblaxle_cpua_ctrl_w(offs_t offset, u16 data, u16 mem_mask = ~0);
132 	void spacegun_eeprom_w(u8 data);
133 	u8 contcirc_input_bypass_r();
134 	u8 chasehq_input_bypass_r();
135 	u16 sci_steer_input_r(offs_t offset);
136 	void spacegun_gun_output_w(u16 data);
137 	u16 dblaxle_steer_input_r(offs_t offset);
138 	u16 chasehq_motor_r(offs_t offset);
139 	void chasehq_motor_w(offs_t offset, u16 data);
140 	void nightstr_motor_w(offs_t offset, u16 data);
141 	void coin_control_w(u8 data);
142 	u16 aquajack_unknown_r();
143 	void sound_bankswitch_w(u8 data);
144 	void pancontrol_w(offs_t offset, u8 data);
145 	u16 sci_spriteframe_r();
146 	void sci_spriteframe_w(u16 data);
147 	void contcirc_out_w(u8 data);
148 	DECLARE_VIDEO_START(taitoz);
149 	DECLARE_MACHINE_START(chasehq);
150 	u32 screen_update_contcirc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
151 	u32 screen_update_chasehq(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
152 	u32 screen_update_bshark(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
153 	u32 screen_update_sci(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
154 	u32 screen_update_aquajack(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
155 	u32 screen_update_spacegun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
156 	u32 screen_update_dblaxle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
157 	u32 screen_update_racingb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
158 	INTERRUPT_GEN_MEMBER(sci_interrupt);
159 	void contcirc_draw_sprites_16x8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs);
160 	void chasehq_draw_sprites_16x16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs);
161 	void bshark_draw_sprites_16x8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs);
162 	void sci_draw_sprites_16x8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs);
163 	void aquajack_draw_sprites_16x8(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs);
164 	void spacegun_draw_sprites_16x8(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,int y_offs);
165 	void parse_cpu_control();
166 
167 	void aquajack_cpub_map(address_map &map);
168 	void aquajack_map(address_map &map);
169 	void bshark_cpub_map(address_map &map);
170 	void bshark_map(address_map &map);
171 	void bsharkjjs_map(address_map &map);
172 	void chasehq_map(address_map &map);
173 	void chq_cpub_map(address_map &map);
174 	void contcirc_cpub_map(address_map &map);
175 	void contcirc_map(address_map &map);
176 	void dblaxle_cpub_map(address_map &map);
177 	void dblaxle_map(address_map &map);
178 	void enforce_cpub_map(address_map &map);
179 	void enforce_map(address_map &map);
180 	void nightstr_cpub_map(address_map &map);
181 	void nightstr_map(address_map &map);
182 	void racingb_cpub_map(address_map &map);
183 	void racingb_map(address_map &map);
184 	void sci_cpub_map(address_map &map);
185 	void sci_map(address_map &map);
186 	void spacegun_cpub_map(address_map &map);
187 	void spacegun_map(address_map &map);
188 	void z80_sound_map(address_map &map);
189 };
190 
191 #endif // MAME_INCLUDES_TAITO_Z_H
192