1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont, Phil Stroffolino, Acho A. Tang, Nicola Salmoria
3 
4 #include "includes/konamigx.h"
5 #include "video/k053246_k053247_k055673.h"
6 
7 #include "sound/k054539.h"
8 #include "machine/k053252.h"
9 #include "video/k055555.h"
10 #include "video/k054000.h"
11 #include "machine/k054321.h"
12 #include "machine/timer.h"
13 #include "tilemap.h"
14 
15 class mystwarr_state : public konamigx_state
16 {
17 public:
mystwarr_state(const machine_config & mconfig,device_type type,const char * tag)18 	mystwarr_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		konamigx_state(mconfig, type, tag),
20 		m_k054321(*this, "k054321"),
21 		m_gx_workram(*this, "gx_workram"),
22 		m_spriteram(*this, "spriteram")
23 	{ }
24 
25 	void martchmp(machine_config &config);
26 	void mystwarr(machine_config &config);
27 	void dadandrn(machine_config &config);
28 	void viostorm(machine_config &config);
29 	void gaiapols(machine_config &config);
30 	void metamrph(machine_config &config);
31 
32 private:
33 	required_device<k054321_device> m_k054321;
34 	required_shared_ptr<uint16_t> m_gx_workram;
35 	optional_shared_ptr<uint16_t> m_spriteram;
36 	std::unique_ptr<uint8_t[]> m_decoded;
37 
38 	uint8_t m_mw_irq_control;
39 	int m_cur_sound_region;
40 	int m_layer_colorbase[6];
41 	int m_oinprion;
42 	int m_cbparam;
43 	int m_sprite_colorbase;
44 	int m_sub1_colorbase;
45 	int m_last_psac_colorbase;
46 	int m_gametype;
47 	int m_roz_enable;
48 	int m_roz_rombank;
49 	tilemap_t *m_ult_936_tilemap;
50 	uint16_t m_clip;
51 
52 	uint8_t m_sound_ctrl;
53 	uint8_t m_sound_nmi_clk;
54 
55 	uint16_t eeprom_r(offs_t offset, uint16_t mem_mask = ~0);
56 	void mweeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
57 	uint16_t dddeeprom_r(offs_t offset, uint16_t mem_mask = ~0);
58 	void mmeeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
59 	void sound_irq_w(uint16_t data);
60 	void irq_ack_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
61 	uint16_t k053247_scattered_word_r(offs_t offset);
62 	void k053247_scattered_word_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
63 	uint16_t k053247_martchmp_word_r(offs_t offset);
64 	void k053247_martchmp_word_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
65 	void mceeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
66 	uint16_t mccontrol_r();
67 	void mccontrol_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
68 	void sound_ctrl_w(uint8_t data);
69 
70 	void ddd_053936_enable_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
71 	void ddd_053936_clip_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
72 	uint16_t gai_053936_tilerom_0_r(offs_t offset);
73 	uint16_t ddd_053936_tilerom_0_r(offs_t offset);
74 	uint16_t ddd_053936_tilerom_1_r(offs_t offset);
75 	uint16_t gai_053936_tilerom_2_r(offs_t offset);
76 	uint16_t ddd_053936_tilerom_2_r(offs_t offset);
77 	TILE_GET_INFO_MEMBER(get_gai_936_tile_info);
78 	TILE_GET_INFO_MEMBER(get_ult_936_tile_info);
79 	DECLARE_MACHINE_START(mystwarr);
80 	DECLARE_MACHINE_RESET(mystwarr);
81 	DECLARE_VIDEO_START(mystwarr);
82 	DECLARE_MACHINE_RESET(viostorm);
83 	DECLARE_VIDEO_START(viostorm);
84 	DECLARE_MACHINE_RESET(metamrph);
85 	DECLARE_VIDEO_START(metamrph);
86 	DECLARE_MACHINE_RESET(dadandrn);
87 	DECLARE_VIDEO_START(dadandrn);
88 	DECLARE_MACHINE_RESET(gaiapols);
89 	DECLARE_VIDEO_START(gaiapols);
90 	DECLARE_MACHINE_RESET(martchmp);
91 	DECLARE_VIDEO_START(martchmp);
92 	uint32_t screen_update_mystwarr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
93 	uint32_t screen_update_metamrph(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
94 	uint32_t screen_update_dadandrn(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
95 	uint32_t screen_update_martchmp(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
96 	INTERRUPT_GEN_MEMBER(ddd_interrupt);
97 	DECLARE_WRITE_LINE_MEMBER(k054539_nmi_gen);
98 	TIMER_DEVICE_CALLBACK_MEMBER(mystwarr_interrupt);
99 	TIMER_DEVICE_CALLBACK_MEMBER(metamrph_interrupt);
100 	TIMER_DEVICE_CALLBACK_MEMBER(mchamp_interrupt);
101 	K056832_CB_MEMBER(mystwarr_tile_callback);
102 	K056832_CB_MEMBER(game5bpp_tile_callback);
103 	K056832_CB_MEMBER(game4bpp_tile_callback);
104 	K055673_CB_MEMBER(mystwarr_sprite_callback);
105 	K055673_CB_MEMBER(metamrph_sprite_callback);
106 	K055673_CB_MEMBER(gaiapols_sprite_callback);
107 	K055673_CB_MEMBER(martchmp_sprite_callback);
108 	void decode_tiles();
109 	void dadandrn_map(address_map &map);
110 	void gaiapols_map(address_map &map);
111 	void martchmp_map(address_map &map);
112 	void martchmp_sound_map(address_map &map);
113 	void metamrph_map(address_map &map);
114 	void mystwarr_map(address_map &map);
115 	void mystwarr_sound_map(address_map &map);
116 	void viostorm_map(address_map &map);
117 };
118