1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4 
5     Green Beret
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_GBERET_H
9 #define MAME_INCLUDES_GBERET_H
10 
11 #pragma once
12 
13 #include "machine/timer.h"
14 #include "sound/sn76496.h"
15 #include "emupal.h"
16 #include "tilemap.h"
17 
18 class gberet_state : public driver_device
19 {
20 public:
gberet_state(const machine_config & mconfig,device_type type,const char * tag)21 	gberet_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_colorram(*this, "colorram"),
24 		m_videoram(*this, "videoram"),
25 		m_spriteram2(*this, "spriteram2"),
26 		m_spriteram(*this, "spriteram"),
27 		m_scrollram(*this, "scrollram"),
28 		m_soundlatch(*this, "soundlatch"),
29 		m_sn(*this, "snsnd") ,
30 		m_maincpu(*this, "maincpu"),
31 		m_gfxdecode(*this, "gfxdecode"),
32 		m_palette(*this, "palette")
33 	{ }
34 
35 	void gberetb(machine_config &config);
36 	void mrgoemon(machine_config &config);
37 	void gberet(machine_config &config);
38 
39 	void init_mrgoemon();
40 
41 private:
42 	/* memory pointers */
43 	required_shared_ptr<uint8_t> m_colorram;
44 	required_shared_ptr<uint8_t> m_videoram;
45 	optional_shared_ptr<uint8_t> m_spriteram2;
46 	required_shared_ptr<uint8_t> m_spriteram;
47 	optional_shared_ptr<uint8_t> m_scrollram;
48 	optional_shared_ptr<uint8_t> m_soundlatch;
49 
50 	/* devices */
51 	required_device<sn76489a_device> m_sn;
52 
53 	/* video-related */
54 	tilemap_t * m_bg_tilemap;
55 	uint8_t       m_spritebank;
56 
57 	/* misc */
58 	uint8_t       m_interrupt_mask;
59 	uint8_t       m_interrupt_ticks;
60 	void gberet_coin_counter_w(uint8_t data);
61 	void mrgoemon_coin_counter_w(uint8_t data);
62 	void gberet_flipscreen_w(uint8_t data);
63 	void gberet_sound_w(uint8_t data);
64 	void gberetb_flipscreen_w(uint8_t data);
65 	uint8_t gberetb_irq_ack_r();
66 	void gberetb_nmi_ack_w(uint8_t data);
67 	void gberet_videoram_w(offs_t offset, uint8_t data);
68 	void gberet_colorram_w(offs_t offset, uint8_t data);
69 	void gberet_scroll_w(offs_t offset, uint8_t data);
70 	void gberet_sprite_bank_w(uint8_t data);
71 	void gberetb_scroll_w(offs_t offset, uint8_t data);
72 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
73 	DECLARE_MACHINE_START(gberet);
74 	DECLARE_MACHINE_RESET(gberet);
75 	DECLARE_VIDEO_START(gberet);
76 	void gberet_palette(palette_device &palette) const;
77 	uint32_t screen_update_gberet(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
78 	uint32_t screen_update_gberetb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
79 	TIMER_DEVICE_CALLBACK_MEMBER(gberet_interrupt_tick);
80 	void gberet_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
81 	void gberetb_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
82 	required_device<cpu_device> m_maincpu;
83 	required_device<gfxdecode_device> m_gfxdecode;
84 	required_device<palette_device> m_palette;
85 	void gberet_map(address_map &map);
86 	void gberetb_map(address_map &map);
87 	void mrgoemon_map(address_map &map);
88 };
89 
90 #endif // MAME_INCLUDES_GBERET_H
91