1 // license:BSD-3-Clause
2 // copyright-holders:David Graves
3 /*************************************************************************
4 
5     Top Speed / Full Throttle
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_TOPSPEED_H
9 #define MAME_INCLUDES_TOPSPEED_H
10 
11 #pragma once
12 
13 #include "sound/msm5205.h"
14 #include "sound/flt_vol.h"
15 #include "machine/taitoio.h"
16 #include "video/pc080sn.h"
17 
18 class topspeed_state : public driver_device
19 {
20 public:
topspeed_state(const machine_config & mconfig,device_type type,const char * tag)21 	topspeed_state(const machine_config &mconfig, device_type type, const char *tag)
22 		: driver_device(mconfig, type, tag)
23 		, m_spritemap(*this, "spritemap")
24 		, m_raster_ctrl(*this, "raster_ctrl")
25 		, m_spriteram(*this, "spriteram")
26 		, m_sharedram(*this, "sharedram")
27 		, m_sndbank(*this, "sndbank")
28 		, m_maincpu(*this, "maincpu")
29 		, m_audiocpu(*this, "audiocpu")
30 		, m_subcpu(*this, "subcpu")
31 		, m_msm(*this, "msm%u", 1U)
32 		, m_pc080sn(*this, "pc080sn_%u", 1U)
33 		, m_tc0040ioc(*this, "tc0040ioc")
34 		, m_filter1l(*this, "filter1l")
35 		, m_filter1r(*this, "filter1r")
36 		, m_filter2(*this, "filter2")
37 		, m_filter3(*this, "filter3")
38 		, m_gfxdecode(*this, "gfxdecode")
39 		, m_gas(*this, "GAS")
40 		, m_brake(*this, "BRAKE")
41 		, m_steer(*this, "STEER")
42 		, m_msm_rom(*this, "adpcm_%u", 0U)
43 	{ }
44 
45 	void topspeed(machine_config &config);
46 
47 	DECLARE_CUSTOM_INPUT_MEMBER(gas_pedal_r);
48 	DECLARE_CUSTOM_INPUT_MEMBER(brake_pedal_r);
49 
50 protected:
51 	virtual void machine_start() override;
52 	virtual void machine_reset() override;
53 
54 private:
55 	required_shared_ptr<u16> m_spritemap;
56 	required_shared_ptr<u16> m_raster_ctrl;
57 	required_shared_ptr<u16> m_spriteram;
58 	required_shared_ptr<u16> m_sharedram;
59 	required_memory_bank m_sndbank;
60 
61 	required_device<cpu_device> m_maincpu;
62 	required_device<cpu_device> m_audiocpu;
63 	required_device<cpu_device> m_subcpu;
64 	required_device_array<msm5205_device, 2> m_msm;
65 	required_device_array<pc080sn_device, 2> m_pc080sn;
66 	required_device<tc0040ioc_device> m_tc0040ioc;
67 	required_device<filter_volume_device> m_filter1l;
68 	required_device<filter_volume_device> m_filter1r;
69 	required_device<filter_volume_device> m_filter2;
70 	required_device<filter_volume_device> m_filter3;
71 	required_device<gfxdecode_device> m_gfxdecode;
72 	required_ioport m_gas;
73 	required_ioport m_brake;
74 	required_ioport m_steer;
75 
76 	// Misc
77 	u16  m_cpua_ctrl;
78 	s32  m_ioc220_port;
79 
80 	// ADPCM
81 	required_region_ptr_array<u8, 2> m_msm_rom;
82 	u16  m_msm_pos[2];
83 	u8   m_msm_reset[2];
84 	u8   m_msm_nibble[2];
85 	u8   m_msm2_vck;
86 	u8   m_msm2_vck2;
87 
88 #ifdef MAME_DEBUG
89 	u8   m_dislayer[5];
90 #endif
91 
92 	void msm5205_update(int chip);
93 
94 	void cpua_ctrl_w(u16 data);
95 	u8 input_bypass_r();
96 	u16 motor_r(offs_t offset);
97 	void motor_w(offs_t offset, u16 data);
98 	void coins_w(u8 data);
99 
100 	void msm5205_command_w(offs_t offset, u8 data);
101 	DECLARE_WRITE_LINE_MEMBER(msm5205_1_vck);
102 	DECLARE_WRITE_LINE_MEMBER(z80ctc_to0);
103 	void volume_w(offs_t offset, u8 data);
104 
105 	// video/topspeed.cpp
106 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
107 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
108 
109 	void cpua_map(address_map &map);
110 	void cpub_map(address_map &map);
111 	void z80_io(address_map &map);
112 	void z80_prg(address_map &map);
113 };
114 
115 #endif // MAME_INCLUDES_TOPSPEED_H
116