1 // license:BSD-3-Clause
2 // copyright-holders:Tomasz Slanina
3 /*************************************************************************
4 
5     Jaleco Moero Pro Yakyuu Homerun hardware
6 
7 *************************************************************************/
8 
9 #include "sound/upd7759.h"
10 #include "sound/samples.h"
11 #include "emupal.h"
12 #include "screen.h"
13 #include "tilemap.h"
14 
15 class homerun_state : public driver_device
16 {
17 public:
homerun_state(const machine_config & mconfig,device_type type,const char * tag)18 	homerun_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_maincpu(*this, "maincpu"),
21 		m_videoram(*this, "videoram"),
22 		m_spriteram(*this, "spriteram"),
23 		m_d7756(*this, "d7756"),
24 		m_samples(*this, "samples"),
25 		m_gfxdecode(*this, "gfxdecode"),
26 		m_screen(*this, "screen"),
27 		m_palette(*this, "palette"),
28 		m_mainbank(*this, "mainbank")
29 	{ }
30 
31 	void ganjaja(machine_config &config);
32 	void dynashot(machine_config &config);
33 	void homerun(machine_config &config);
34 
35 	DECLARE_READ_LINE_MEMBER(sprite0_r);
36 	DECLARE_READ_LINE_MEMBER(homerun_d7756_busy_r);
37 	DECLARE_READ_LINE_MEMBER(ganjaja_d7756_busy_r);
38 	DECLARE_CUSTOM_INPUT_MEMBER(ganjaja_hopper_status_r);
39 
40 protected:
41 	virtual void machine_start() override;
42 	virtual void machine_reset() override;
43 	virtual void video_start() override;
44 
45 private:
46 	required_device<cpu_device> m_maincpu;
47 	required_shared_ptr<u8> m_videoram;
48 	required_shared_ptr<u8> m_spriteram;
49 	optional_device<upd7756_device> m_d7756;
50 	optional_device<samples_device> m_samples;
51 	required_device<gfxdecode_device> m_gfxdecode;
52 	required_device<screen_device> m_screen;
53 	required_device<palette_device> m_palette;
54 
55 	required_memory_bank m_mainbank;
56 
57 	u8 m_control;
58 	u8 m_sample;
59 
60 	tilemap_t *m_tilemap;
61 	int m_gfx_ctrl;
62 	int m_scrollx;
63 	int m_scrolly;
64 
65 	void control_w(u8 data);
66 	void d7756_sample_w(u8 data);
67 	void videoram_w(offs_t offset, u8 data);
68 	void scrollhi_w(u8 data);
69 	void scrolly_w(u8 data);
70 	void scrollx_w(u8 data);
71 
72 	static rgb_t homerun_RGB332(u32 raw);
73 	TILE_GET_INFO_MEMBER(get_tile_info);
74 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
75 	void banking_w(u8 data);
76 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
77 	void io_map(address_map &map);
78 	void mem_map(address_map &map);
79 };
80