1 // license:BSD-3-Clause
2 // copyright-holders:Pierpaolo Prazzoli
3 /*************************************************************************
4 
5     Ghosts'n Goblins
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_GNG_H
9 #define MAME_INCLUDES_GNG_H
10 
11 #pragma once
12 
13 #include "sound/2203intf.h"
14 #include "video/bufsprite.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class gng_state : public driver_device
19 {
20 public:
gng_state(const machine_config & mconfig,device_type type,const char * tag)21 	gng_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_spriteram(*this, "spriteram"),
24 		m_fgvideoram(*this, "fgvideoram"),
25 		m_bgvideoram(*this, "bgvideoram"),
26 		m_maincpu(*this, "maincpu"),
27 		m_ym(*this, "ym%u", 1),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_palette(*this, "palette")
30 	{ }
31 
32 	void gng(machine_config &config);
33 	void diamond(machine_config &config);
34 
35 private:
36 	void gng_bankswitch_w(uint8_t data);
37 	DECLARE_WRITE_LINE_MEMBER(ym_reset_w);
38 	uint8_t diamond_hack_r();
39 	void gng_fgvideoram_w(offs_t offset, uint8_t data);
40 	void gng_bgvideoram_w(offs_t offset, uint8_t data);
41 	void gng_bgscrollx_w(offs_t offset, uint8_t data);
42 	void gng_bgscrolly_w(offs_t offset, uint8_t data);
43 	DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
44 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
45 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
46 	virtual void machine_start() override;
47 	virtual void machine_reset() override;
48 	virtual void video_start() override;
49 	uint32_t screen_update_gng(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
50 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
51 
52 	void diamond_map(address_map &map);
53 	void gng_map(address_map &map);
54 	void sound_map(address_map &map);
55 
56 	/* memory pointers */
57 	required_device<buffered_spriteram8_device> m_spriteram;
58 	required_shared_ptr<uint8_t> m_fgvideoram;
59 	required_shared_ptr<uint8_t> m_bgvideoram;
60 
61 	/* video-related */
62 	tilemap_t    *m_bg_tilemap;
63 	tilemap_t    *m_fg_tilemap;
64 	uint8_t      m_scrollx[2];
65 	uint8_t      m_scrolly[2];
66 
67 	required_device<cpu_device> m_maincpu;
68 	required_device_array<ym2203_device, 2> m_ym;
69 	required_device<gfxdecode_device> m_gfxdecode;
70 	required_device<palette_device> m_palette;
71 };
72 
73 #endif // MAME_INCLUDES_GNG_H
74