1 // license:BSD-3-Clause
2 // copyright-holders:Manuel Abadia, David Haywood
3 #ifndef MAME_INCLUDES_SPLASH_H
4 #define MAME_INCLUDES_SPLASH_H
5 
6 #pragma once
7 
8 #include "machine/eepromser.h"
9 #include "machine/gen_latch.h"
10 #include "machine/74259.h"
11 #include "sound/msm5205.h"
12 #include "emupal.h"
13 #include "tilemap.h"
14 
15 class splash_state : public driver_device
16 {
17 public:
splash_state(const machine_config & mconfig,device_type type,const char * tag)18 	splash_state(const machine_config &mconfig, device_type type, const char *tag) :
19 		driver_device(mconfig, type, tag),
20 		m_maincpu(*this, "maincpu"),
21 		m_audiocpu(*this, "audiocpu"),
22 		m_msm(*this, "msm"),
23 		m_gfxdecode(*this, "gfxdecode"),
24 		m_palette(*this, "palette"),
25 		m_soundlatch(*this, "soundlatch"),
26 		m_outlatch(*this, "outlatch"),
27 		m_pixelram(*this, "pixelram"),
28 		m_videoram(*this, "videoram"),
29 		m_vregs(*this, "vregs"),
30 		m_spriteram(*this, "spriteram"),
31 		m_protdata(*this, "protdata"),
32 		m_bitmap_mode(*this, "bitmap_mode")
33 	{ }
34 
35 	void roldfrog(machine_config &config);
36 	void splash(machine_config &config);
37 
38 	void init_splash10();
39 	void init_roldfrog();
40 	void init_splash();
41 	void init_rebus();
42 
43 protected:
44 	required_device<cpu_device> m_maincpu;
45 	required_device<cpu_device> m_audiocpu;
46 	optional_device<msm5205_device> m_msm;
47 	required_device<gfxdecode_device> m_gfxdecode;
48 	required_device<palette_device> m_palette;
49 	required_device<generic_latch_8_device> m_soundlatch;
50 	optional_device<ls259_device> m_outlatch;
51 
52 	required_shared_ptr<uint16_t> m_pixelram;
53 	required_shared_ptr<uint16_t> m_videoram;
54 	required_shared_ptr<uint16_t> m_vregs;
55 	required_shared_ptr<uint16_t> m_spriteram;
56 	optional_shared_ptr<uint16_t> m_protdata;
57 	optional_shared_ptr<uint16_t> m_bitmap_mode;
58 
59 	// driver init configuration
60 	int m_bitmap_type;
61 	int m_sprite_attr2_shift;
62 
63 	tilemap_t *m_bg_tilemap[2];
64 
65 	// splash specific
66 	int m_adpcm_data;
67 
68 	//roldfrog specific
69 	int m_ret;
70 	int m_vblank_irq;
71 	int m_sound_irq;
72 
73 	// common
74 	void vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
75 	DECLARE_WRITE_LINE_MEMBER(coin1_lockout_w);
76 	DECLARE_WRITE_LINE_MEMBER(coin2_lockout_w);
77 	DECLARE_WRITE_LINE_MEMBER(coin1_counter_w);
78 	DECLARE_WRITE_LINE_MEMBER(coin2_counter_w);
79 
80 	// splash specific
81 	DECLARE_WRITE_LINE_MEMBER(splash_msm5205_int);
82 	void splash_adpcm_data_w(uint8_t data);
83 	void splash_adpcm_control_w(uint8_t data);
84 
85 	// roldfrog specific
86 	uint16_t roldfrog_bombs_r();
87 	void roldfrog_vblank_ack_w(uint8_t data);
88 	uint8_t roldfrog_unk_r();
89 	DECLARE_WRITE_LINE_MEMBER(ym_irq);
90 
91 	//roldfrog and funystrp specific
92 	void sound_bank_w(uint8_t data);
93 
94 	virtual void video_start() override;
95 	DECLARE_MACHINE_START(splash);
96 	DECLARE_MACHINE_START(roldfrog);
97 	DECLARE_MACHINE_RESET(splash);
98 
99 	TILE_GET_INFO_MEMBER(get_tile_info_tilemap0);
100 	TILE_GET_INFO_MEMBER(get_tile_info_tilemap1);
101 
102 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
103 	void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect);
104 	void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
105 
106 	INTERRUPT_GEN_MEMBER(roldfrog_interrupt);
107 	void roldfrog_update_irq(  );
108 
109 	void funystrp_sound_map(address_map &map);
110 	void roldfrog_map(address_map &map);
111 	void roldfrog_sound_io_map(address_map &map);
112 	void roldfrog_sound_map(address_map &map);
113 	void splash_map(address_map &map);
114 	void splash_sound_map(address_map &map);
115 };
116 
117 class funystrp_state : public splash_state
118 {
119 public:
funystrp_state(const machine_config & mconfig,device_type type,const char * tag)120 	funystrp_state(const machine_config &mconfig, device_type type, const char *tag) :
121 		splash_state(mconfig, type, tag),
122 		m_msm1(*this, "msm1"),
123 		m_msm2(*this, "msm2"),
124 		m_eeprom(*this, "eeprom"),
125 		m_funystrp_val(0),
126 		m_funystrp_ff3cc7_val(0),
127 		m_funystrp_ff3cc8_val(0)
128 	{ }
129 
130 	void funystrp(machine_config &config);
131 	void ringball(machine_config &config);
132 
133 	void init_funystrp();
134 	void init_ringball();
135 
136 protected:
137 	virtual void machine_start() override;
138 
139 private:
140 	uint16_t spr_read(offs_t offset);
141 	void spr_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
142 	uint8_t int_source_r();
143 	void msm1_data_w(uint8_t data);
144 	void msm1_interrupt_w(uint8_t data);
145 	void msm2_interrupt_w(uint8_t data);
146 	void msm2_data_w(uint8_t data);
147 	DECLARE_WRITE_LINE_MEMBER(adpcm_int1);
148 	DECLARE_WRITE_LINE_MEMBER(adpcm_int2);
149 	void protection_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
150 	uint16_t protection_r(offs_t offset);
151 	void eeprom_w(uint8_t data);
152 
153 	uint32_t screen_update_funystrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
154 	void funystrp_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
155 
156 	void funystrp_map(address_map &map);
157 	void funystrp_sound_io_map(address_map &map);
158 	void ringball_map(address_map &map);
159 
160 	required_device<msm5205_device> m_msm1;
161 	required_device<msm5205_device> m_msm2;
162 	required_device<eeprom_serial_93cxx_device> m_eeprom;
163 
164 	uint8_t m_funystrp_val;
165 	uint8_t m_funystrp_ff3cc7_val;
166 	uint8_t m_funystrp_ff3cc8_val;
167 	int m_msm_data1;
168 	int m_msm_data2;
169 	int m_msm_toggle1;
170 	int m_msm_toggle2;
171 	int m_msm_source;
172 	int m_snd_interrupt_enable1;
173 	int m_snd_interrupt_enable2;
174 };
175 
176 #endif // MAME_INCLUDES_SPLASH_H
177