1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont
3 /****************************************************************************
4 
5     drivers/flashbeats.cpp
6     Sega "Flash Beats" game
7 
8     Hardware:
9         - H8/3007 CPU
10         - 68000 + SCSP for sound effects
11         - DSB2 MPEG board with another 68000
12         - Two Sega I/O chips: 315-5338A and 315-5296
13         - Pinball-style dot matrix VFD display
14         - 5 display tubes containing an unknown number of RGB LEDs behind
15           a diffuser
16 
17 ****************************************************************************/
18 
19 #include "emu.h"
20 #include "cpu/h8/h83006.h"
21 #include "cpu/m68000/m68000.h"
22 #include "machine/eepromser.h"
23 #include "machine/315_5296.h"
24 #include "machine/315_5338a.h"
25 #include "machine/te7750.h"
26 #include "sound/scsp.h"
27 #include "screen.h"
28 #include "speaker.h"
29 
30 class flashbeats_state : public driver_device
31 {
32 public:
flashbeats_state(const machine_config & mconfig,device_type type,const char * tag)33 	flashbeats_state(const machine_config &mconfig, device_type type, const char *tag)
34 		: driver_device(mconfig, type, tag),
35 		m_maincpu(*this, "maincpu"),
36 		m_scspcpu(*this, "scspcpu"),
37 		m_scsp(*this, "scsp"),
38 		m_sound_ram(*this, "sound_ram"),
39 		m_eeprom(*this, "eeprom"),
40 		m_315_5296(*this, "segaio1"),
41 		m_315_5338a(*this, "segaio2")
42 	{
43 	}
44 
45 	void flashbeats(machine_config &config);
46 	void flashbeats_map(address_map &map);
47 	void flashbeats_io_map(address_map &map);
48 	void main_scsp_map(address_map &map);
49 	void scsp_mem(address_map &map);
50 
51 	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
52 
53 private:
54 	virtual void machine_reset() override;
55 
56 	void scsp_irq(offs_t offset, uint8_t data);
57 	uint16_t p6_r();
58 	void p6_w(uint16_t data);
59 
60 	required_device<h83007_device> m_maincpu;
61 	required_device<m68000_device> m_scspcpu;
62 	required_device<scsp_device> m_scsp;
63 	required_shared_ptr<uint16_t> m_sound_ram;
64 	required_device<eeprom_serial_93cxx_device> m_eeprom;
65 	required_device<sega_315_5296_device> m_315_5296;
66 	required_device<sega_315_5338a_device> m_315_5338a;
67 
68 	inline void ATTR_PRINTF(3,4) verboselog( int n_level, const char *s_fmt, ... );
69 };
70 
71 
72 #define VERBOSE_LEVEL ( 0 )
73 
74 #define ENABLE_VERBOSE_LOG (0)
75 
verboselog(int n_level,const char * s_fmt,...)76 inline void ATTR_PRINTF(3,4) flashbeats_state::verboselog( int n_level, const char *s_fmt, ... )
77 {
78 #if ENABLE_VERBOSE_LOG
79 	if( VERBOSE_LEVEL >= n_level )
80 	{
81 		va_list v;
82 		char buf[ 32768 ];
83 		va_start( v, s_fmt );
84 		vsprintf( buf, s_fmt, v );
85 		va_end( v );
86 		logerror("%s: %s", machine().describe_context(), buf);
87 	}
88 #endif
89 }
90 
machine_reset()91 void flashbeats_state::machine_reset()
92 {
93 	uint8_t *ROM = memregion("scspcpu")->base();
94 	memcpy(m_sound_ram, ROM, 0x400);
95 	m_scspcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
96 	m_scspcpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
97 }
98 
screen_update(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)99 uint32_t flashbeats_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
100 {
101 	return 0;
102 }
103 
p6_r()104 uint16_t flashbeats_state::p6_r()
105 {
106 	return (m_eeprom->do_read() << 3);
107 }
108 
p6_w(uint16_t data)109 void flashbeats_state::p6_w(uint16_t data)
110 {
111 	m_eeprom->clk_write((data & 0x02) ? ASSERT_LINE : CLEAR_LINE);
112 	m_eeprom->di_write((data >> 2) & 1);
113 	m_eeprom->cs_write((data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
114 }
115 
flashbeats_map(address_map & map)116 void flashbeats_state::flashbeats_map(address_map &map)
117 {
118 	map(0x000000, 0x1fffff).rom().region("maincpu", 0);
119 	map(0x200000, 0x20ffff).ram();
120 	map(0x400000, 0x40007f).rw(m_315_5296, FUNC(sega_315_5296_device::read), FUNC(sega_315_5296_device::write)).umask16(0xff00);
121 	map(0x600000, 0x60001f).rw("telio", FUNC(te7752_device::read), FUNC(te7752_device::write)).umask16(0xff00);
122 	map(0x800000, 0x80001f).rw(m_315_5338a, FUNC(sega_315_5338a_device::read), FUNC(sega_315_5338a_device::write)).umask16(0xff00);
123 	map(0xa00000, 0xa0ffff).ram();
124 	map(0xa10000, 0xa10fff).ram();
125 }
126 
flashbeats_io_map(address_map & map)127 void flashbeats_state::flashbeats_io_map(address_map &map)
128 {
129 	map(h8_device::PORT_6, h8_device::PORT_6).rw(FUNC(flashbeats_state::p6_r), FUNC(flashbeats_state::p6_w));
130 }
131 
main_scsp_map(address_map & map)132 void flashbeats_state::main_scsp_map(address_map &map)
133 {
134 	map(0x000000, 0x0fffff).ram().share("sound_ram");
135 	map(0x100000, 0x100fff).rw("scsp", FUNC(scsp_device::read), FUNC(scsp_device::write));
136 	map(0x600000, 0x67ffff).rom().region("scspcpu", 0);
137 }
138 
scsp_mem(address_map & map)139 void flashbeats_state::scsp_mem(address_map &map)
140 {
141 	map(0x000000, 0x0fffff).ram().share("sound_ram");
142 }
143 
flashbeats(machine_config & config)144 void flashbeats_state::flashbeats(machine_config &config)
145 {
146 	/* basic machine hardware */
147 	H83007(config, m_maincpu, 16_MHz_XTAL); // 16 MHz oscillator next to chip, also 16 MHz causes SCI0 and 1 rates to be 31250 (MIDI)
148 	m_maincpu->set_addrmap(AS_PROGRAM, &flashbeats_state::flashbeats_map);
149 	m_maincpu->set_addrmap(AS_IO, &flashbeats_state::flashbeats_io_map);
150 
151 	M68000(config, m_scspcpu, 11289600);
152 	m_scspcpu->set_addrmap(AS_PROGRAM, &flashbeats_state::main_scsp_map);
153 
154 	EEPROM_93C46_16BIT(config, "eeprom");
155 
156 	SEGA_315_5296(config, m_315_5296, 8_MHz_XTAL);
157 
158 	SEGA_315_5338A(config, m_315_5338a, 32_MHz_XTAL);
159 
160 	te7752_device &te7752(TE7752(config, "telio"));
161 	te7752.ios_cb().set_constant(1);
162 	//te7752.out_port2_cb().set(FUNC(flashbeats_state::te7752_port2_w));
163 	//te7752.out_port3_cb().set(FUNC(flashbeats_state::te7752_port3_w));
164 	//te7752.out_port4_cb().set(FUNC(flashbeats_state::te7752_port4_w));
165 	//te7752.out_port5_cb().set(FUNC(flashbeats_state::te7752_port5_w));
166 	//te7752.out_port6_cb().set(FUNC(flashbeats_state::te7752_port6_w));
167 	//te7752.out_port7_cb().set(FUNC(flashbeats_state::te7752_port7_w));
168 
169 	SPEAKER(config, "lspeaker").front_left();
170 	SPEAKER(config, "rspeaker").front_right();
171 
172 	SCSP(config, m_scsp, 22579200); // TODO : Unknown clock, divider
173 	m_scsp->set_addrmap(0, &flashbeats_state::scsp_mem);
174 	m_scsp->irq_cb().set(FUNC(flashbeats_state::scsp_irq));
175 	m_scsp->add_route(0, "lspeaker", 1.0);
176 	m_scsp->add_route(1, "rspeaker", 1.0);
177 }
178 
scsp_irq(offs_t offset,uint8_t data)179 void flashbeats_state::scsp_irq(offs_t offset, uint8_t data)
180 {
181 }
182 
183 static INPUT_PORTS_START( flashbeats )
184 INPUT_PORTS_END
185 
186 /***************************************************************************
187 
188   ROM definition(s)
189 
190 ***************************************************************************/
191 
192 ROM_START( flsbeats )
193 	ROM_REGION(0x200000, "maincpu", 0)
194 	ROM_LOAD16_WORD_SWAP( "epr-21609_rom1.ic18", 0x000000, 0x080000, CRC(130a0a62) SHA1(400f24304959547b188ed874653ae2e1e77092fe) )
195 
196 	ROM_REGION(0x280000, "scspcpu", 0)
197 	ROM_LOAD16_WORD_SWAP( "epr-21610_rom4.ic14", 0x000000, 0x080000, CRC(c877e0e6) SHA1(595f143fb3789852a4af9d2920cbaefabecfa45c) )
198 	ROM_LOAD16_WORD_SWAP( "epr-21611_rom3.ic4", 0x080000, 0x200000, CRC(2f5dc574) SHA1(f0b8d076b0fc8e94582de0ca17ecd5c8b90bedc4) )
199 
200 	ROM_REGION(0x20000, "dsb2", 0)
201 	ROM_LOAD16_WORD_SWAP( "epr-21612.ic2", 0x000000, 0x020000, CRC(6912e1cb) SHA1(3497d6ae0b9be00116a3278f46d738c4c6f26d20) )
202 
203 	ROM_REGION(0x2000000, "mpeg", 0)
204 	ROM_LOAD( "mpr-21601_n26_9852k7016.ic18", 0x0000000, 0x400000, CRC(d23e2b7b) SHA1(8c26a740fee0adc4d45d34786b0c28abb105324d) )
205 	ROM_LOAD( "mpr-21602_n27_9852k7017.ic19", 0x0400000, 0x400000, CRC(e143960b) SHA1(7ace5cae6f2a8868d74d4397a9c1b0a0f6f26c9f) )
206 	ROM_LOAD( "mpr-21603_n28_9852k7018.ic20", 0x0800000, 0x400000, CRC(136b69d8) SHA1(ad81be6f0383f29306c8d9f21d1e7440172ebf97) )
207 	ROM_LOAD( "mpr-21604_n29_9852k7019.ic21", 0x0c00000, 0x400000, CRC(87b15ea4) SHA1(eacc0f575926e68a195090370cb9e9e06b38e404) )
208 	ROM_LOAD( "mpr-21605_n30_9852k7023.ic22", 0x1000000, 0x400000, CRC(fb1a802e) SHA1(6fa99694973fd3cdd1a0f74a655583aadf5adc8f) )
209 	ROM_LOAD( "mpr-21606_n31_9852k7020.ic23", 0x1400000, 0x400000, CRC(d9aba5e0) SHA1(6f3f1b01174d771a56f92aeead998827da97ac22) )
210 	ROM_LOAD( "mpr-21607_n32_9852k7021.ic24", 0x1800000, 0x400000, CRC(f3dd07c6) SHA1(aa9d056e8ff5d2282917a09c42711062b8df989a) )
211 	ROM_LOAD( "mpr-21608_n33_9852k7022.ic25", 0x1c00000, 0x400000, CRC(be4db836) SHA1(93d4cbb3bb299e3cf1dda105670e3923751c28ad) )
212 ROM_END
213 
214 //    YEAR  NAME     PARENT   MACHINE       INPUT       CLASS              INIT     MONITOR   COMPANY  FULLNAME      FLAGS
215 GAME( 1998, flsbeats, 0,    flashbeats,   flashbeats, flashbeats_state,  empty_init, ROT0,    "Sega", "Flash Beats", MACHINE_NOT_WORKING|MACHINE_NO_SOUND )
216