1 // license:BSD-3-Clause
2 // copyright-holders:Dan Boris, Mirko Buffoni
3 /*************************************************************************
4 
5     Atari Cloak & Dagger hardware
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_CLOAK_H
9 #define MAME_INCLUDES_CLOAK_H
10 
11 #pragma once
12 
13 #include "emupal.h"
14 #include "screen.h"
15 #include "tilemap.h"
16 
17 class cloak_state : public driver_device
18 {
19 public:
cloak_state(const machine_config & mconfig,device_type type,const char * tag)20 	cloak_state(const machine_config &mconfig, device_type type, const char *tag)
21 		: driver_device(mconfig, type, tag),
22 		m_videoram(*this, "videoram"),
23 		m_spriteram(*this, "spriteram"),
24 		m_maincpu(*this, "maincpu"),
25 		m_slave(*this, "slave"),
26 		m_gfxdecode(*this, "gfxdecode"),
27 		m_screen(*this, "screen"),
28 		m_palette(*this, "palette")
29 	{ }
30 
31 	void cloak(machine_config &config);
32 
33 protected:
34 	DECLARE_WRITE_LINE_MEMBER(coin_counter_l_w);
35 	DECLARE_WRITE_LINE_MEMBER(coin_counter_r_w);
36 	void cloak_custom_w(uint8_t data);
37 	void cloak_irq_reset_0_w(uint8_t data);
38 	void cloak_irq_reset_1_w(uint8_t data);
39 	void cloak_nvram_enable_w(uint8_t data);
40 	void cloak_paletteram_w(offs_t offset, uint8_t data);
41 	void cloak_clearbmp_w(uint8_t data);
42 	uint8_t graph_processor_r(offs_t offset);
43 	void graph_processor_w(offs_t offset, uint8_t data);
44 	void cloak_videoram_w(offs_t offset, uint8_t data);
45 	DECLARE_WRITE_LINE_MEMBER(cocktail_w);
46 	void set_current_bitmap_videoram_pointer();
47 	void adjust_xy(int offset);
48 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
49 	virtual void video_start() override;
50 	uint32_t screen_update_cloak(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
51 	void set_pen(int i);
52 	void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);
53 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
54 	void master_map(address_map &map);
55 	void slave_map(address_map &map);
56 
57 private:
58 	required_shared_ptr<uint8_t> m_videoram;
59 	required_shared_ptr<uint8_t> m_spriteram;
60 	int m_nvram_enabled;
61 	uint8_t m_bitmap_videoram_selected;
62 	uint8_t m_bitmap_videoram_address_x;
63 	uint8_t m_bitmap_videoram_address_y;
64 	std::unique_ptr<uint8_t[]> m_bitmap_videoram1;
65 	std::unique_ptr<uint8_t[]> m_bitmap_videoram2;
66 	uint8_t *m_current_bitmap_videoram_accessed;
67 	uint8_t *m_current_bitmap_videoram_displayed;
68 	std::unique_ptr<uint16_t[]>  m_palette_ram;
69 	tilemap_t *m_bg_tilemap;
70 
71 	required_device<cpu_device> m_maincpu;
72 	required_device<cpu_device> m_slave;
73 	required_device<gfxdecode_device> m_gfxdecode;
74 	required_device<screen_device> m_screen;
75 	required_device<palette_device> m_palette;
76 };
77 
78 #endif // MAME_INCLUDES_CLOAK_H
79