1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood
3 
4 /*************************************************************************
5 
6     Success Joe / Ashita no Joe
7 
8 *************************************************************************/
9 #ifndef MAME_INCLUDES_ASHNOJOE_H
10 #define MAME_INCLUDES_ASHNOJOE_H
11 
12 #pragma once
13 
14 #include "machine/gen_latch.h"
15 #include "sound/msm5205.h"
16 #include "tilemap.h"
17 
18 class ashnojoe_state : public driver_device
19 {
20 public:
ashnojoe_state(const machine_config & mconfig,device_type type,const char * tag)21 	ashnojoe_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_tileram(*this, "tileram_%u", 1U),
24 		m_tilemap_reg(*this, "tilemap_reg"),
25 		m_audiobank(*this, "audiobank"),
26 		m_maincpu(*this, "maincpu"),
27 		m_audiocpu(*this, "audiocpu"),
28 		m_msm(*this, "msm"),
29 		m_gfxdecode(*this, "gfxdecode"),
30 		m_soundlatch(*this, "soundlatch")
31 	{ }
32 
33 	void init_ashnojoe();
34 
35 	void ashnojoe(machine_config &config);
36 
37 protected:
38 	virtual void machine_start() override;
39 	virtual void machine_reset() override;
40 	virtual void video_start() override;
41 
42 private:
43 	/* memory pointers */
44 	required_shared_ptr_array<u16, 7> m_tileram;
45 	required_shared_ptr<u16> m_tilemap_reg;
46 	required_memory_bank m_audiobank;
47 
48 	/* video-related */
49 	tilemap_t *m_tilemap[7];
50 
51 	/* sound-related */
52 	u8        m_adpcm_byte;
53 	int       m_msm5205_vclk_toggle;
54 
55 	/* devices */
56 	required_device<cpu_device> m_maincpu;
57 	required_device<cpu_device> m_audiocpu;
58 	required_device<msm5205_device> m_msm;
59 	required_device<gfxdecode_device> m_gfxdecode;
60 	required_device<generic_latch_8_device> m_soundlatch;
61 
62 	u16 fake_4a00a_r();
63 	void adpcm_w(u8 data);
64 	u8 sound_latch_status_r();
65 	template<unsigned Which> void tileram_8x8_w(offs_t offset, u16 data);
66 	template<unsigned Which> void tileram_16x16_w(offs_t offset, u16 data);
67 	void tilemaps_xscroll_w(offs_t offset, u16 data);
68 	void tilemaps_yscroll_w(offs_t offset, u16 data);
69 	void tilemap_regs_w(offs_t offset, u16 data, u16 mem_mask);
70 	void ym2203_write_a(u8 data);
71 	void ym2203_write_b(u8 data);
72 	TILE_GET_INFO_MEMBER(get_tile_info_highest);
73 	TILE_GET_INFO_MEMBER(get_tile_info_midlow);
74 	TILE_GET_INFO_MEMBER(get_tile_info_high);
75 	TILE_GET_INFO_MEMBER(get_tile_info_low);
76 	TILE_GET_INFO_MEMBER(get_tile_info_midhigh);
77 	TILE_GET_INFO_MEMBER(get_tile_info_lowest);
78 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
79 	DECLARE_WRITE_LINE_MEMBER(ashnojoe_vclk_cb);
80 	void ashnojoe_map(address_map &map);
81 	void sound_map(address_map &map);
82 	void sound_portmap(address_map &map);
83 };
84 
85 #endif // MAME_INCLUDES_ASHNOJOE_H
86