1 // license:BSD-3-Clause
2 // copyright-holders:Luca Elia, David Haywood
3 /***************************************************************************
4 
5     ESD 16 Bit Games
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_ESD16_H
9 #define MAME_INCLUDES_ESD16_H
10 
11 #pragma once
12 
13 #include "machine/eepromser.h"
14 #include "machine/gen_latch.h"
15 #include "video/decospr.h"
16 #include "tilemap.h"
17 
18 class esd16_state : public driver_device
19 {
20 public:
esd16_state(const machine_config & mconfig,device_type type,const char * tag)21 	esd16_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_vram(*this, "vram_%u", 0U),
24 		m_scroll(*this, "scroll_%u", 0U),
25 		m_spriteram(*this, "spriteram"),
26 		m_head_layersize(*this, "head_layersize"),
27 		m_headpanic_platform_x(*this, "platform_x"),
28 		m_headpanic_platform_y(*this, "platform_y"),
29 		m_audiobank(*this, "audiobank"),
30 		m_io_eepromout(*this, "EEPROMOUT"),
31 		m_maincpu(*this, "maincpu"),
32 		m_audiocpu(*this, "audiocpu"),
33 		m_gfxdecode(*this, "gfxdecode"),
34 		m_sprgen(*this, "spritegen"),
35 		m_eeprom(*this, "eeprom"),
36 		m_soundlatch(*this, "soundlatch")
37 	{ }
38 
39 	void jumppop(machine_config &config);
40 	void esd16_nosound(machine_config &config);
41 	void esd16(machine_config &config);
42 	void tangtang(machine_config &config);
43 	void mchampdx(machine_config &config);
44 	void hedpanio(machine_config &config);
45 	void hedpanic(machine_config &config);
46 	void fantstry(machine_config &config);
47 	void fantstrya(machine_config &config);
48 
49 protected:
50 	virtual void machine_start() override;
51 	virtual void machine_reset() override;
52 	virtual void video_start() override;
53 
54 private:
55 	/* memory pointers */
56 	required_shared_ptr_array<u16, 2> m_vram;
57 	required_shared_ptr_array<u16, 2> m_scroll;
58 	required_shared_ptr<u16> m_spriteram;
59 	required_shared_ptr<u16> m_head_layersize;
60 	required_shared_ptr<u16> m_headpanic_platform_x;
61 	required_shared_ptr<u16> m_headpanic_platform_y;
62 
63 	optional_memory_bank m_audiobank;
64 	optional_ioport m_io_eepromout;
65 
66 	/* video-related */
67 	tilemap_t       *m_tilemap_16x16[2];
68 	tilemap_t       *m_tilemap[2];
69 	int             m_tilemap_color[2];
70 
71 	/* devices */
72 	required_device<cpu_device> m_maincpu;
73 	optional_device<cpu_device> m_audiocpu;
74 	required_device<gfxdecode_device> m_gfxdecode;
75 	optional_device<decospr_device> m_sprgen;
76 	optional_device<eeprom_serial_93cxx_device> m_eeprom;
77 	optional_device<generic_latch_8_device> m_soundlatch;
78 
79 	void sound_command_w(u8 data);
80 	void hedpanic_platform_w(u16 data);
81 	u8 eeprom_r();
82 	void eeprom_w(u8 data);
83 	void sound_rombank_w(u8 data);
84 	template<unsigned Layer> void vram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
85 	void tilemap0_color_w(u16 data);
86 	void tilemap0_color_jumppop_w(u16 data);
87 	template<unsigned Layer> TILE_GET_INFO_MEMBER(get_tile_info);
88 	template<unsigned Layer> TILE_GET_INFO_MEMBER(get_tile_info_16x16);
89 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
90 	DECOSPR_PRIORITY_CB_MEMBER(pri_callback);
91 	void fantstrya_map(address_map &map);
92 	void hedpanic_map(address_map &map);
93 	void jumppop_map(address_map &map);
94 	void mchampdx_map(address_map &map);
95 	void multchmp_map(address_map &map);
96 	void sound_io_map(address_map &map);
97 	void sound_map(address_map &map);
98 	void tangtang_map(address_map &map);
99 
100 	void io_area_dsw(address_map &map, u32 base);
101 	void io_area_eeprom(address_map &map, u32 base);
102 	void palette_area(address_map &map, u32 base);
103 	void sprite_area(address_map &map, u32 base);
104 	void vid_attr_area(address_map &map, u32 base);
105 	void vram_area(address_map &map, u32 base);
106 };
107 
108 #endif // MAME_INCLUDES_ESD16_H
109