1 // license:BSD-3-Clause
2 // copyright-holders:Bryan McPhail, David Haywood
3 #ifndef MAME_INCLUDES_DEADANG_H
4 #define MAME_INCLUDES_DEADANG_H
5 
6 #pragma once
7 
8 #include "audio/seibu.h"
9 #include "machine/timer.h"
10 #include "sound/ym2151.h"
11 #include "emupal.h"
12 #include "screen.h"
13 #include "tilemap.h"
14 
15 class deadang_state : public driver_device
16 {
17 public:
deadang_state(const machine_config & mconfig,device_type type,const char * tag)18 	deadang_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_scroll_ram(*this, "scroll_ram"),
21 		m_videoram(*this, "videoram"),
22 		m_video_data(*this, "video_data"),
23 		m_spriteram(*this, "spriteram"),
24 		m_gfxdecode(*this, "gfxdecode"),
25 		m_screen(*this, "screen"),
26 		m_palette(*this, "palette"),
27 		m_seibu_sound(*this, "seibu_sound"),
28 		m_maincpu(*this, "maincpu"),
29 		m_subcpu(*this, "sub"),
30 		m_audiocpu(*this, "audiocpu"),
31 		m_adpcm1(*this, "adpcm1"),
32 		m_adpcm2(*this, "adpcm2")
33 	{ }
34 
35 	void deadang(machine_config &config);
36 
37 	void init_deadang();
38 	void init_ghunter();
39 
40 	void foreground_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
41 
42 	TILEMAP_MAPPER_MEMBER(bg_scan);
43 	TILE_GET_INFO_MEMBER(get_pf1_tile_info);
44 	TILE_GET_INFO_MEMBER(get_pf3_tile_info);
45 	TILE_GET_INFO_MEMBER(get_pf2_tile_info);
46 	TILE_GET_INFO_MEMBER(get_text_tile_info);
47 
48 protected:
49 	virtual void video_start() override;
50 
51 	void main_map(address_map &map);
52 
53 	required_shared_ptr<uint16_t> m_scroll_ram;
54 	required_shared_ptr<uint16_t> m_videoram;
55 	required_shared_ptr<uint16_t> m_video_data;
56 	required_shared_ptr<uint16_t> m_spriteram;
57 	required_device<gfxdecode_device> m_gfxdecode;
58 	required_device<screen_device> m_screen;
59 	required_device<palette_device> m_palette;
60 	required_device<seibu_sound_device> m_seibu_sound;
61 
62 	int m_tilebank;
63 	int m_oldtilebank;
64 
65 	tilemap_t *m_pf3_layer;
66 	tilemap_t *m_pf2_layer;
67 	tilemap_t *m_pf1_layer;
68 	tilemap_t *m_text_layer;
69 
70 	void text_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
71 	void bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
72 
73 	void sound_decrypted_opcodes_map(address_map &map);
74 	void sound_map(address_map &map);
75 
76 	required_device<cpu_device> m_maincpu;
77 	required_device<cpu_device> m_subcpu;
78 	required_device<cpu_device> m_audiocpu;
79 	optional_device<seibu_adpcm_device> m_adpcm1;
80 	optional_device<seibu_adpcm_device> m_adpcm2;
81 
82 	uint16_t ghunter_trackball_low_r();
83 	uint16_t ghunter_trackball_high_r();
84 
85 
86 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
87 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
88 
89 	TIMER_DEVICE_CALLBACK_MEMBER(main_scanline);
90 	TIMER_DEVICE_CALLBACK_MEMBER(sub_scanline);
91 	void sub_map(address_map &map);
92 };
93 
94 class popnrun_state : public deadang_state
95 {
96 public:
popnrun_state(const machine_config & mconfig,device_type type,const char * tag)97 	popnrun_state(const machine_config &mconfig, device_type type, const char *tag) :
98 		deadang_state(mconfig, type, tag)
99 	{ }
100 
101 	void popnrun(machine_config &config);
102 
103 	void init_popnrun();
104 
105 protected:
106 	virtual void video_start() override;
107 
108 private:
109 	TILE_GET_INFO_MEMBER(get_popnrun_text_tile_info);
110 	void popnrun_text_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
111 	void popnrun_main_map(address_map &map);
112 	void popnrun_sub_map(address_map &map);
113 	void popnrun_sound_map(address_map &map);
114 
115 	uint32_t popnrun_screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
116 	void popnrun_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
117 };
118 
119 #endif // MAME_INCLUDES_DEADANG_H
120