1 // license:BSD-3-Clause
2 // copyright-holders:Paul Hampson, Nicola Salmoria
3 /*************************************************************************
4 
5     Super Dodge Ball hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_SPDODGEB_H
9 #define MAME_INCLUDES_SPDODGEB_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "machine/timer.h"
15 #include "sound/msm5205.h"
16 #include "emupal.h"
17 #include "screen.h"
18 #include "tilemap.h"
19 
20 class spdodgeb_state : public driver_device
21 {
22 public:
spdodgeb_state(const machine_config & mconfig,device_type type,const char * tag)23 	spdodgeb_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_maincpu(*this,"maincpu"),
26 		m_audiocpu(*this, "audiocpu"),
27 		m_mcu(*this, "mcu"),
28 		m_msm1(*this, "msm1"),
29 		m_msm2(*this, "msm2"),
30 		m_gfxdecode(*this, "gfxdecode"),
31 		m_screen(*this, "screen"),
32 		m_palette(*this, "palette"),
33 		m_soundlatch(*this, "soundlatch"),
34 		m_videoram(*this, "videoram"),
35 		m_spriteram(*this, "spriteram")
36 	{ }
37 
38 	void spdodgeb(machine_config &config);
39 
40 	DECLARE_READ_LINE_MEMBER(mcu_busy_r);
41 
42 protected:
43 	virtual void machine_start() override;
44 	virtual void machine_reset() override;
45 	virtual void video_start() override;
46 
47 private:
48 	required_device<cpu_device> m_maincpu;
49 	required_device<cpu_device> m_audiocpu;
50 	required_device<cpu_device> m_mcu;
51 	required_device<msm5205_device> m_msm1;
52 	required_device<msm5205_device> m_msm2;
53 	required_device<gfxdecode_device> m_gfxdecode;
54 	required_device<screen_device> m_screen;
55 	required_device<palette_device> m_palette;
56 	required_device<generic_latch_8_device> m_soundlatch;
57 
58 	required_shared_ptr<uint8_t> m_videoram;
59 	required_shared_ptr<uint8_t> m_spriteram;
60 
61 	int m_adpcm_pos[2];
62 	int m_adpcm_end[2];
63 	int m_adpcm_idle[2];
64 	int m_adpcm_data[2];
65 	uint8_t m_mcu_status;
66 	uint8_t m_inputs[5];
67 
68 	int m_tile_palbank;
69 	int m_sprite_palbank;
70 	tilemap_t *m_bg_tilemap;
71 	int m_lastscroll;
72 
73 	void spd_adpcm_w(offs_t offset, uint8_t data);
74 	uint8_t mcu63701_r(offs_t offset);
75 	void mcu_data_w(offs_t offset, uint8_t data);
76 	void mcu_status_w(uint8_t data);
77 	void mcu_nmi_w(uint8_t data);
78 
79 	void scrollx_lo_w(uint8_t data);
80 	void ctrl_w(uint8_t data);
81 	void videoram_w(offs_t offset, uint8_t data);
82 	DECLARE_WRITE_LINE_MEMBER(spd_adpcm_int_1);
83 	DECLARE_WRITE_LINE_MEMBER(spd_adpcm_int_2);
84 
85 	TILEMAP_MAPPER_MEMBER(background_scan);
86 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
87 
88 	void spdodgeb_palette(palette_device &palette) const;
89 
90 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
91 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect );
92 
93 	TIMER_DEVICE_CALLBACK_MEMBER(interrupt);
94 
95 	void spd_adpcm_int(msm5205_device *device, int chip);
96 	void spdodgeb_map(address_map &map);
97 	void spdodgeb_sound_map(address_map &map);
98 	void mcu_map(address_map &map);
99 };
100 
101 #endif // MAME_INCLUDES_SPDODGEB_H
102