1 // license:BSD-3-Clause
2 // copyright-holders:David Graves, Angelo Salese, David Haywood, Tomasz Slanina
3 #ifndef MAME_INCLUDES_LEGIONNA_H
4 #define MAME_INCLUDES_LEGIONNA_H
5 
6 #pragma once
7 
8 #include "sound/okim6295.h"
9 #include "audio/seibu.h"
10 #include "machine/gen_latch.h"
11 #include "machine/seibucop.h"
12 #include "video/seibu_crtc.h"
13 #include "emupal.h"
14 #include "tilemap.h"
15 
16 #include <algorithm>
17 
18 class legionna_state : public driver_device, public seibu_sound_common
19 {
20 public:
legionna_state(const machine_config & mconfig,device_type type,const char * tag)21 	legionna_state(const machine_config &mconfig, device_type type, const char *tag)
22 		: driver_device(mconfig, type, tag)
23 		, m_spriteram(*this, "spriteram")
24 		, m_swappal(*this, "swappal")
25 		, m_layer_disable(0)
26 		, m_back_gfx_bank(0)
27 		, m_fore_gfx_bank(0)
28 		, m_mid_gfx_bank(0)
29 		, m_maincpu(*this, "maincpu")
30 		, m_audiocpu(*this, "audiocpu")
31 		, m_seibu_sound(*this, "seibu_sound")
32 		, m_oki(*this, "oki")
33 		, m_gfxdecode(*this, "gfxdecode")
34 		, m_palette(*this, "palette")
35 		, m_crtc(*this, "crtc")
36 		, m_raiden2cop(*this, "raiden2cop")
37 	{
38 		std::fill(std::begin(m_scrollvals), std::end(m_scrollvals), 0);
39 	}
40 
41 	void cupsocs(machine_config &config);
42 	void heatbrl(machine_config &config);
43 	void cupsoc(machine_config &config);
44 	void grainbow(machine_config &config);
45 	void legionna(machine_config &config);
46 	void godzilla(machine_config &config);
47 	void denjinmk(machine_config &config);
48 
49 	void init_legiongfx();
50 	void init_godzilla();
51 	void init_cupsoc_debug();
52 	void init_cupsoc();
53 	void init_cupsocs();
54 	void init_olysoc92();
55 
56 private:
57 	void tilemap_enable_w(offs_t offset, u16 data, u16 mem_mask = ~0);
58 	void tile_scroll_w(offs_t offset, u16 data, u16 mem_mask = ~0);
59 	void tile_scroll_base_w(offs_t offset, u16 data);
60 	void tile_vreg_1a_w(u16 data);
61 	void videowrite_cb_w(offs_t offset, u16 data);
62 	void background_w(offs_t offset, u16 data, u16 mem_mask = ~0);
63 	void midground_w(offs_t offset, u16 data, u16 mem_mask = ~0);
64 	void foreground_w(offs_t offset, u16 data, u16 mem_mask = ~0);
65 	void text_w(offs_t offset, u16 data, u16 mem_mask = ~0);
66 	u8 denjinmk_sound_comms_r(offs_t offset);
67 	void godzilla_oki_bank_w(u8 data);
68 	void denjinmk_setgfxbank(u16 data);
69 	void heatbrl_setgfxbank(u16 data);
70 	void grainbow_layer_config_w(offs_t offset, u16 data, u16 mem_mask = ~0);
71 	void palette_swap_w(offs_t offset, u16 data, u16 mem_mask = ~0);
72 
73 	TILE_GET_INFO_MEMBER(get_back_tile_info);
74 	TILE_GET_INFO_MEMBER(get_mid_tile_info_split);
75 	TILE_GET_INFO_MEMBER(get_mid_tile_info_share_bgrom);
76 	TILE_GET_INFO_MEMBER(get_fore_tile_info);
77 	TILE_GET_INFO_MEMBER(get_text_tile_info);
78 	DECLARE_VIDEO_START(legionna);
79 	DECLARE_VIDEO_START(heatbrl);
80 	DECLARE_VIDEO_START(godzilla);
81 	DECLARE_VIDEO_START(denjinmk);
82 	DECLARE_VIDEO_START(grainbow);
83 	DECLARE_VIDEO_START(cupsoc);
84 	u32 screen_update_legionna(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
85 	u32 screen_update_heatbrl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
86 	u32 screen_update_godzilla(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
87 	u32 screen_update_grainbow(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
88 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect);
89 	void descramble_legionnaire_gfx(u8* src);
90 	void common_video_start(bool split, bool has_extended_banking, bool has_extended_priority);
91 	void common_video_allocate_ptr();
92 
93 	void cupsoc_map(address_map &map);
94 	void cupsocs_map(address_map &map);
95 	void denjinmk_map(address_map &map);
96 	void godzilla_map(address_map &map);
97 	void grainbow_map(address_map &map);
98 	void heatbrl_map(address_map &map);
99 	void legionna_cop_map(address_map &map);
100 	void legionna_map(address_map &map);
101 	void godzilla_sound_io_map(address_map &map);
102 
103 	required_shared_ptr<u16> m_spriteram;
104 	optional_shared_ptr<u16> m_swappal;
105 	std::unique_ptr<u16[]> m_back_data;
106 	std::unique_ptr<u16[]> m_fore_data;
107 	std::unique_ptr<u16[]> m_mid_data;
108 	std::unique_ptr<u16[]> m_textram;
109 	std::unique_ptr<u16[]> m_scrollram16;
110 	std::unique_ptr<u16[]> m_paletteram;
111 	u16 m_layer_disable;
112 	std::unique_ptr<u16[]> m_layer_config;
113 	int m_sprite_xoffs;
114 	int m_sprite_yoffs;
115 	tilemap_t *m_background_layer;
116 	tilemap_t *m_foreground_layer;
117 	tilemap_t *m_midground_layer;
118 	tilemap_t *m_text_layer;
119 	bool m_has_extended_banking;
120 	bool m_has_extended_priority;
121 	u16 m_sprite_pri_mask[4];
122 	u16 m_back_gfx_bank;
123 	u16 m_fore_gfx_bank;
124 	u16 m_mid_gfx_bank;
125 	u16 m_scrollvals[6];
126 
127 	required_device<cpu_device> m_maincpu;
128 	required_device<cpu_device> m_audiocpu;
129 	optional_device<seibu_sound_device> m_seibu_sound;
130 	required_device<okim6295_device> m_oki;
131 	required_device<gfxdecode_device> m_gfxdecode;
132 	required_device<palette_device> m_palette;
133 	required_device<seibu_crtc_device> m_crtc;
134 	optional_device<raiden2cop_device> m_raiden2cop;
135 };
136 
137 #endif // MAME_INCLUDES_LEGIONNA_H
138