1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #ifndef MAME_INCLUDES_MAPPY_H
4 #define MAME_INCLUDES_MAPPY_H
5 
6 #pragma once
7 
8 #include "machine/namcoio.h"
9 #include "sound/dac.h"
10 #include "sound/namco.h"
11 #include "emupal.h"
12 #include "screen.h"
13 #include "tilemap.h"
14 
15 class mappy_state : public driver_device
16 {
17 public:
mappy_state(const machine_config & mconfig,device_type type,const char * tag)18 	mappy_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_videoram(*this, "videoram"),
21 		m_spriteram(*this, "spriteram"),
22 		m_maincpu(*this, "maincpu"),
23 		m_subcpu(*this, "sub"),
24 		m_subcpu2(*this, "sub2"),
25 		m_namcoio(*this, "namcoio_%u", 1),
26 		m_namco_15xx(*this, "namco"),
27 		m_dac(*this, "dac"),
28 		m_gfxdecode(*this, "gfxdecode"),
29 		m_screen(*this, "screen"),
30 		m_palette(*this, "palette"),
31 		m_leds(*this, "led%u", 0U)
32 	{ }
33 
34 	void mappy_common(machine_config &config);
35 	void mappy(machine_config &config);
36 	void phozon(machine_config &config);
37 	void motos(machine_config &config);
38 	void grobda(machine_config &config);
39 	void digdug2(machine_config &config);
40 	void pacnpal(machine_config &config);
41 	void superpac_common(machine_config &config);
42 	void superpac(machine_config &config);
43 	void todruaga(machine_config &config);
44 
45 	void init_digdug2();
46 
47 protected:
48 	virtual void machine_start() override;
49 
50 private:
51 	required_shared_ptr<uint8_t> m_videoram;
52 	required_shared_ptr<uint8_t> m_spriteram;
53 
54 	required_device<cpu_device> m_maincpu;
55 	required_device<cpu_device> m_subcpu;
56 	optional_device<cpu_device> m_subcpu2;
57 	required_device_array<namcoio_device, 2> m_namcoio;
58 	required_device<namco_15xx_device> m_namco_15xx;
59 	optional_device<dac_byte_interface> m_dac;
60 	required_device<gfxdecode_device> m_gfxdecode;
61 	required_device<screen_device> m_screen;
62 	required_device<palette_device> m_palette;
63 	output_finder<2> m_leds;
64 
65 	tilemap_t *m_bg_tilemap;
66 	bitmap_ind16 m_sprite_bitmap;
67 
68 	uint8_t m_scroll;
69 
70 	uint8_t m_main_irq_mask;
71 	uint8_t m_sub_irq_mask;
72 	uint8_t m_sub2_irq_mask;
73 
74 	emu_timer *m_namcoio_run_timer[2];
75 
76 	DECLARE_WRITE_LINE_MEMBER(int_on_w);
77 	DECLARE_WRITE_LINE_MEMBER(int_on_2_w);
78 	DECLARE_WRITE_LINE_MEMBER(int_on_3_w);
79 	DECLARE_WRITE_LINE_MEMBER(mappy_flip_w);
80 	void superpac_videoram_w(offs_t offset, uint8_t data);
81 	void mappy_videoram_w(offs_t offset, uint8_t data);
82 	void superpac_flipscreen_w(uint8_t data);
83 	uint8_t superpac_flipscreen_r();
84 	void mappy_scroll_w(offs_t offset, uint8_t data);
85 	void out_lamps(uint8_t data);
86 	TILEMAP_MAPPER_MEMBER(superpac_tilemap_scan);
87 	TILEMAP_MAPPER_MEMBER(mappy_tilemap_scan);
88 	TILE_GET_INFO_MEMBER(superpac_get_tile_info);
89 	TILE_GET_INFO_MEMBER(phozon_get_tile_info);
90 	TILE_GET_INFO_MEMBER(mappy_get_tile_info);
91 	template<uint8_t Chip> TIMER_CALLBACK_MEMBER(namcoio_run_timer);
92 
93 	DECLARE_VIDEO_START(superpac);
94 	void superpac_palette(palette_device &palette) const;
95 	DECLARE_VIDEO_START(phozon);
96 	void phozon_palette(palette_device &palette) const;
97 	DECLARE_VIDEO_START(mappy);
98 	void mappy_palette(palette_device &palette) const;
99 	uint32_t screen_update_superpac(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
100 	uint32_t screen_update_phozon(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
101 	uint32_t screen_update_mappy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
102 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
103 	void mappy_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t *spriteram_base);
104 	void phozon_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t *spriteram_base);
105 
106 	void grobda_cpu2_map(address_map &map);
107 	void mappy_cpu1_map(address_map &map);
108 	void mappy_cpu2_map(address_map &map);
109 	void phozon_cpu1_map(address_map &map);
110 	void phozon_cpu2_map(address_map &map);
111 	void phozon_cpu3_map(address_map &map);
112 	void superpac_cpu1_map(address_map &map);
113 	void superpac_cpu2_map(address_map &map);
114 };
115 
116 #endif // MAME_INCLUDES_MAPPY_H
117