1 // license:BSD-3-Clause
2 // copyright-holders:Yochizo, Takahiro Nogi
3 #ifndef MAME_INCLUDES_SRMP2_H
4 #define MAME_INCLUDES_SRMP2_H
5 
6 #pragma once
7 
8 #include "sound/msm5205.h"
9 #include "video/seta001.h"
10 #include "emupal.h"
11 
12 class srmp2_state : public driver_device
13 {
14 public:
15 	struct iox_t
16 	{
17 		int reset,ff_event,ff_1,protcheck[4],protlatch[4];
18 		uint8_t data;
19 		uint8_t mux;
20 		uint8_t ff;
21 	};
22 
srmp2_state(const machine_config & mconfig,device_type type,const char * tag)23 	srmp2_state(const machine_config &mconfig, device_type type, const char *tag) :
24 		driver_device(mconfig, type, tag),
25 		m_maincpu(*this, "maincpu"),
26 		m_seta001(*this, "spritegen"),
27 		m_msm(*this, "msm"),
28 		m_adpcm_rom(*this, "adpcm"),
29 		m_mainbank(*this, "mainbank")
30 	{ }
31 
32 	void mjyuugi(machine_config &config);
33 	void srmp2(machine_config &config);
34 	void rmgoldyh(machine_config &config);
35 	void srmp3(machine_config &config);
36 
37 private:
38 	required_device<cpu_device> m_maincpu;
39 	required_device<seta001_device> m_seta001;
40 	required_device<msm5205_device> m_msm;
41 	required_region_ptr<uint8_t> m_adpcm_rom;
42 	optional_memory_bank m_mainbank;
43 
44 	int m_color_bank;
45 	int m_gfx_bank;
46 	int m_adpcm_bank;
47 	int m_adpcm_data;
48 	uint32_t m_adpcm_sptr;
49 	uint32_t m_adpcm_eptr;
50 	iox_t m_iox;
51 
52 	// common
53 	uint8_t vox_status_r();
54 	uint8_t iox_mux_r();
55 	uint8_t iox_status_r();
56 	void iox_command_w(uint8_t data);
57 	void iox_data_w(uint8_t data);
58 	DECLARE_WRITE_LINE_MEMBER(adpcm_int);
59 
60 	// mjuugi
61 	void mjyuugi_flags_w(uint16_t data);
62 	void mjyuugi_adpcm_bank_w(uint16_t data);
63 	uint8_t mjyuugi_irq2_ack_r();
64 	uint8_t mjyuugi_irq4_ack_r();
65 
66 	// rmgoldyh
67 	void rmgoldyh_rombank_w(uint8_t data);
68 
69 	// srmp2
70 	void srmp2_irq2_ack_w(uint8_t data);
71 	void srmp2_irq4_ack_w(uint8_t data);
72 	void srmp2_flags_w(uint16_t data);
73 	void adpcm_code_w(uint8_t data);
74 
75 	// srmp3
76 	void srmp3_rombank_w(uint8_t data);
77 	void srmp3_flags_w(uint8_t data);
78 	void srmp3_irq_ack_w(uint8_t data);
79 
80 	virtual void machine_start() override;
81 	DECLARE_MACHINE_START(srmp2);
82 	void srmp2_palette(palette_device &palette) const;
83 	DECLARE_MACHINE_START(srmp3);
84 	void srmp3_palette(palette_device &palette) const;
85 	DECLARE_MACHINE_START(rmgoldyh);
86 	DECLARE_MACHINE_START(mjyuugi);
87 
88 	uint32_t screen_update_srmp2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
89 	uint32_t screen_update_srmp3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
90 	uint32_t screen_update_mjyuugi(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
91 	SETA001_SPRITE_GFXBANK_CB_MEMBER(srmp3_gfxbank_callback);
92 
93 	uint8_t iox_key_matrix_calc(uint8_t p_side);
94 
95 	void mjyuugi_map(address_map &map);
96 	void rmgoldyh_io_map(address_map &map);
97 	void rmgoldyh_map(address_map &map);
98 	void srmp2_map(address_map &map);
99 	void srmp3_io_map(address_map &map);
100 	void srmp3_map(address_map &map);
101 };
102 
103 #endif // MAME_INCLUDES_SRMP2_H
104