1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #ifndef MAME_INCLUDES_XMEN_H
4 #define MAME_INCLUDES_XMEN_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "machine/timer.h"
10 #include "sound/k054539.h"
11 #include "video/k053246_k053247_k055673.h"
12 #include "video/k053251.h"
13 #include "video/k052109.h"
14 #include "video/konami_helper.h"
15 #include "machine/k054321.h"
16 #include "screen.h"
17 
18 class xmen_state : public driver_device
19 {
20 public:
xmen_state(const machine_config & mconfig,device_type type,const char * tag)21 	xmen_state(const machine_config &mconfig, device_type type, const char *tag) :
22 		driver_device(mconfig, type, tag),
23 		m_xmen6p_spriteram(*this, "spriteram%u", 0),
24 		m_xmen6p_tilemap(*this, "tilemap%u", 0),
25 		m_maincpu(*this, "maincpu"),
26 		m_audiocpu(*this, "audiocpu"),
27 		m_k054539(*this, "k054539"),
28 		m_k052109(*this, "k052109"),
29 		m_k053246(*this, "k053246"),
30 		m_k053251(*this, "k053251"),
31 		m_screen(*this, "screen"),
32 		m_k054321(*this, "k054321"),
33 		m_z80bank(*this, "z80bank")
34 	{ }
35 
36 	void xmen(machine_config &config);
37 	void xmen6p(machine_config &config);
38 
39 	DECLARE_READ_LINE_MEMBER(xmen_frame_r);
40 
41 private:
42 	/* video-related */
43 	int        m_layer_colorbase[3];
44 	int        m_sprite_colorbase;
45 	int        m_layerpri[3];
46 
47 	/* for xmen6p */
48 	std::unique_ptr<bitmap_ind16> m_screen_right;
49 	std::unique_ptr<bitmap_ind16> m_screen_left;
50 	optional_shared_ptr_array<uint16_t, 2> m_xmen6p_spriteram;
51 	optional_shared_ptr_array<uint16_t, 4> m_xmen6p_tilemap;
52 	uint16_t * m_k053247_ram;
53 	bool       m_xmen6p_tilemap_select;
54 
55 	/* misc */
56 	uint8_t    m_vblank_irq_mask;
57 
58 	/* devices */
59 	required_device<cpu_device> m_maincpu;
60 	required_device<cpu_device> m_audiocpu;
61 	required_device<k054539_device> m_k054539;
62 	required_device<k052109_device> m_k052109;
63 	required_device<k053247_device> m_k053246;
64 	required_device<k053251_device> m_k053251;
65 	required_device<screen_device> m_screen;
66 	required_device<k054321_device> m_k054321;
67 
68 	required_memory_bank m_z80bank;
69 	void eeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
70 	void xmen_18fa00_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
71 	void sound_bankswitch_w(uint8_t data);
72 
73 	virtual void machine_start() override;
74 	virtual void machine_reset() override;
75 	DECLARE_VIDEO_START(xmen6p);
76 	uint32_t screen_update_xmen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
77 	uint32_t screen_update_xmen6p_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
78 	uint32_t screen_update_xmen6p_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
79 	DECLARE_WRITE_LINE_MEMBER(screen_vblank_xmen6p);
80 	TIMER_DEVICE_CALLBACK_MEMBER(xmen_scanline);
81 	K052109_CB_MEMBER(tile_callback);
82 	K053246_CB_MEMBER(sprite_callback);
83 
84 	void _6p_main_map(address_map &map);
85 	void main_map(address_map &map);
86 	void sound_map(address_map &map);
87 };
88 
89 #endif // MAME_INCLUDES_XMEN_H
90