1 // license:BSD-3-Clause
2 // copyright-holders:Pierpaolo Prazzoli, Tomasz Slanina
3 /*
4 
5   Limenko Power System 2
6 
7   driver by Pierpaolo Prazzoli and Tomasz Slanina
8 
9   Power System 2 General specs:
10   - Cartridge Based System
11   - Hyperstone E1-32XN CPU
12   - QDSP QS1000 Sound Hardware
13 
14   Games Supported:
15   - Dynamite Bomber (Korea) (Rev 1.5)
16   - Legend of Heroes
17   - Super Bubble 2003 (2 sets)
18 
19   Known Games Not Dumped:
20   - Happy Hunter (shooting themed prize game)
21 
22   To Do:
23   - Legend of Heroes link up, 2 cabinets can be linked for a 4 player game
24 
25 */
26 
27 #include "emu.h"
28 #include "cpu/e132xs/e132xs.h"
29 #include "machine/eepromser.h"
30 #include "machine/gen_latch.h"
31 #include "sound/okim6295.h"
32 #include "sound/qs1000.h"
33 #include "emupal.h"
34 #include "screen.h"
35 #include "speaker.h"
36 #include "tilemap.h"
37 
38 
39 class limenko_state : public driver_device
40 {
41 public:
limenko_state(const machine_config & mconfig,device_type type,const char * tag)42 	limenko_state(const machine_config &mconfig, device_type type, const char *tag)
43 		: driver_device(mconfig, type, tag)
44 		, m_maincpu(*this, "maincpu")
45 		, m_qs1000(*this, "qs1000")
46 		, m_oki(*this, "oki")
47 		, m_gfxdecode(*this, "gfxdecode")
48 		, m_palette(*this, "palette")
49 		, m_soundlatch(*this, "soundlatch")
50 		, m_mainram(*this, "mainram")
51 		, m_fg_videoram(*this, "fg_videoram")
52 		, m_md_videoram(*this, "md_videoram")
53 		, m_bg_videoram(*this, "bg_videoram")
54 		, m_spriteram(*this, "spriteram")
55 		, m_videoreg(*this, "videoreg")
56 		, m_gfx_region(*this, "gfx")
57 	{
58 	}
59 
60 	void limenko(machine_config &config);
61 	void spotty(machine_config &config);
62 
63 	void init_common();
64 	void init_sb2003();
65 	void init_dynabomb();
66 	void init_legendoh();
67 	void init_spotty();
68 
69 	DECLARE_READ_LINE_MEMBER(spriteram_bit_r);
70 
71 protected:
72 	virtual void video_start() override;
73 
74 private:
75 	required_device<cpu_device> m_maincpu;
76 	optional_device<qs1000_device> m_qs1000;
77 	optional_device<okim6295_device> m_oki;
78 	required_device<gfxdecode_device> m_gfxdecode;
79 	required_device<palette_device> m_palette;
80 	required_device<generic_latch_8_device> m_soundlatch;
81 
82 	required_shared_ptr<u32> m_mainram;
83 	required_shared_ptr<u32> m_fg_videoram;
84 	required_shared_ptr<u32> m_md_videoram;
85 	required_shared_ptr<u32> m_bg_videoram;
86 	required_shared_ptr<u32> m_spriteram;
87 	required_shared_ptr<u32> m_videoreg;
88 	required_region_ptr<u8> m_gfx_region;
89 
90 	tilemap_t *m_bg_tilemap;
91 	tilemap_t *m_md_tilemap;
92 	tilemap_t *m_fg_tilemap;
93 
94 	int m_spriteram_bit;
95 	bitmap_ind16 m_sprites_bitmap;
96 	bitmap_ind8 m_sprites_bitmap_pri;
97 	int m_prev_sprites_count;
98 
99 	void coincounter_w(u32 data);
100 	void bg_videoram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
101 	void md_videoram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
102 	void fg_videoram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
103 	void spriteram_buffer_w(u32 data);
104 
105 	u32 dynabomb_speedup_r();
106 	u32 legendoh_speedup_r();
107 	u32 sb2003_speedup_r();
108 	u32 spotty_speedup_r();
109 
110 	void qs1000_p1_w(u8 data);
111 	void qs1000_p2_w(u8 data);
112 	void qs1000_p3_w(u8 data);
113 
114 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
115 	TILE_GET_INFO_MEMBER(get_md_tile_info);
116 	TILE_GET_INFO_MEMBER(get_fg_tile_info);
117 
118 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
119 	void draw_single_sprite(bitmap_ind16 &dest_bmp,const rectangle &clip,u8 width,u8 height,u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
120 							u8 transparent_color, u8 priority);
121 	void draw_sprites();
122 	void copy_sprites(bitmap_ind16 &bitmap, bitmap_ind16 &sprites_bitmap, bitmap_ind8 &priority_bitmap, const rectangle &cliprect);
123 
124 	void limenko_io_map(address_map &map);
125 	void limenko_map(address_map &map);
126 	void spotty_io_map(address_map &map);
127 	void spotty_map(address_map &map);
128 
129 	// spotty audiocpu
130 	uint8_t audiocpu_p1_r();
131 	void audiocpu_p1_w(uint8_t data);
132 	uint8_t audiocpu_p3_r();
133 	void audiocpu_p3_w(uint8_t data);
134 
135 	uint8_t m_audiocpu_p1;
136 	uint8_t m_audiocpu_p3;
137 };
138 
139 /*****************************************************************************************************
140   MISC FUNCTIONS
141 *****************************************************************************************************/
142 
coincounter_w(u32 data)143 void limenko_state::coincounter_w(u32 data)
144 {
145 	machine().bookkeeping().coin_counter_w(0,data & 0x10000);
146 }
147 
148 
bg_videoram_w(offs_t offset,u32 data,u32 mem_mask)149 void limenko_state::bg_videoram_w(offs_t offset, u32 data, u32 mem_mask)
150 {
151 	COMBINE_DATA(&m_bg_videoram[offset]);
152 	m_bg_tilemap->mark_tile_dirty(offset);
153 }
154 
md_videoram_w(offs_t offset,u32 data,u32 mem_mask)155 void limenko_state::md_videoram_w(offs_t offset, u32 data, u32 mem_mask)
156 {
157 	COMBINE_DATA(&m_md_videoram[offset]);
158 	m_md_tilemap->mark_tile_dirty(offset);
159 }
160 
fg_videoram_w(offs_t offset,u32 data,u32 mem_mask)161 void limenko_state::fg_videoram_w(offs_t offset, u32 data, u32 mem_mask)
162 {
163 	COMBINE_DATA(&m_fg_videoram[offset]);
164 	m_fg_tilemap->mark_tile_dirty(offset);
165 }
166 
READ_LINE_MEMBER(limenko_state::spriteram_bit_r)167 READ_LINE_MEMBER(limenko_state::spriteram_bit_r)
168 {
169 	return m_spriteram_bit;
170 }
171 
spriteram_buffer_w(u32 data)172 void limenko_state::spriteram_buffer_w(u32 data)
173 {
174 	// toggle spriterams location in the memory map
175 	m_spriteram_bit ^= 1;
176 
177 	// draw the sprites to the frame buffer
178 	draw_sprites();
179 
180 	// buffer the next number of sprites to draw
181 	m_prev_sprites_count = (m_videoreg[0] & 0x1ff0000) >> 16;
182 }
183 
184 /*****************************************************************************************************
185  SOUND FUNCTIONS
186  *****************************************************************************************************/
187 
qs1000_p1_w(u8 data)188 void limenko_state::qs1000_p1_w(u8 data)
189 {
190 }
191 
qs1000_p2_w(u8 data)192 void limenko_state::qs1000_p2_w(u8 data)
193 {
194 	// Unknown. Often written with 0
195 }
196 
qs1000_p3_w(u8 data)197 void limenko_state::qs1000_p3_w(u8 data)
198 {
199 	// .... .xxx - Data ROM bank (64kB)
200 	// ...x .... - ?
201 	// ..x. .... - /IRQ clear
202 
203 	membank("qs1000:bank")->set_entry(data & 0x07);
204 
205 	if (!BIT(data, 5))
206 		m_soundlatch->acknowledge_w();
207 }
208 
209 // spotty audio
210 
audiocpu_p1_r()211 uint8_t limenko_state::audiocpu_p1_r()
212 {
213 	return m_audiocpu_p1;
214 }
215 
audiocpu_p1_w(uint8_t data)216 void limenko_state::audiocpu_p1_w(uint8_t data)
217 {
218 	m_audiocpu_p1 = data;
219 }
220 
221 // 7-------  msm select
222 // -654----  unused
223 // ----3---  read latch maincpu
224 // -----2--  latch maincpu new data available
225 // ------1-  write msm
226 // -------0  read msm
227 
audiocpu_p3_r()228 uint8_t limenko_state::audiocpu_p3_r()
229 {
230 	return (m_soundlatch->pending_r() ? 0 : 1) << 2;
231 }
232 
audiocpu_p3_w(uint8_t data)233 void limenko_state::audiocpu_p3_w(uint8_t data)
234 {
235 	if (BIT(m_audiocpu_p3, 0) == 1 && BIT(data, 0) == 0 && BIT(data, 7) == 0)
236 		m_audiocpu_p1 = m_oki->read();
237 
238 	if (BIT(m_audiocpu_p3, 1) == 1 && BIT(data, 1) == 0 && BIT(data, 7) == 0)
239 		m_oki->write(m_audiocpu_p1);
240 
241 	if (BIT(m_audiocpu_p3, 3) == 1 && BIT(data, 3) == 0)
242 		m_audiocpu_p1 = m_soundlatch->read();
243 
244 	m_audiocpu_p3 = data;
245 }
246 
247 /*****************************************************************************************************
248   MEMORY MAPS
249 *****************************************************************************************************/
250 
limenko_map(address_map & map)251 void limenko_state::limenko_map(address_map &map)
252 {
253 	map(0x00000000, 0x001fffff).ram().share("mainram");
254 	map(0x40000000, 0x403fffff).rom().region("maindata", 0);
255 	map(0x80000000, 0x80007fff).ram().w(FUNC(limenko_state::fg_videoram_w)).share("fg_videoram");
256 	map(0x80008000, 0x8000ffff).ram().w(FUNC(limenko_state::md_videoram_w)).share("md_videoram");
257 	map(0x80010000, 0x80017fff).ram().w(FUNC(limenko_state::bg_videoram_w)).share("bg_videoram");
258 	map(0x80018000, 0x80019fff).ram().share("spriteram");
259 	map(0x8001c000, 0x8001dfff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette");
260 	map(0x8001e000, 0x8001ebff).ram(); // ? not used
261 	map(0x8001ffec, 0x8001ffff).ram().share("videoreg");
262 	map(0x8003e000, 0x8003e003).w(FUNC(limenko_state::spriteram_buffer_w));
263 	map(0xffe00000, 0xffffffff).rom().region("maincpu", 0);
264 }
265 
limenko_io_map(address_map & map)266 void limenko_state::limenko_io_map(address_map &map)
267 {
268 	map(0x0000, 0x0003).portr("IN0");
269 	map(0x0800, 0x0803).portr("IN1");
270 	map(0x1000, 0x1003).portr("IN2");
271 	map(0x4000, 0x4003).w(FUNC(limenko_state::coincounter_w));
272 	map(0x4800, 0x4803).portw("EEPROMOUT");
273 	map(0x5000, 0x5003).w(m_soundlatch, FUNC(generic_latch_8_device::write)).umask32(0x00ff0000).cswidth(32);
274 }
275 
276 
277 /* Spotty memory map */
278 
spotty_map(address_map & map)279 void limenko_state::spotty_map(address_map &map)
280 {
281 	map(0x00000000, 0x001fffff).ram().share("mainram");
282 	map(0x40002000, 0x400024d3).ram(); //?
283 	map(0x80000000, 0x80007fff).ram().w(FUNC(limenko_state::fg_videoram_w)).share("fg_videoram");
284 	map(0x80008000, 0x8000ffff).ram().w(FUNC(limenko_state::md_videoram_w)).share("md_videoram");
285 	map(0x80010000, 0x80017fff).ram().w(FUNC(limenko_state::bg_videoram_w)).share("bg_videoram");
286 	map(0x80018000, 0x80019fff).ram().share("spriteram");
287 	map(0x8001c000, 0x8001dfff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette");
288 	map(0x8001e000, 0x8001ebff).ram(); // ? not used
289 	map(0x8001ffec, 0x8001ffff).ram().share("videoreg");
290 	map(0x8003e000, 0x8003e003).w(FUNC(limenko_state::spriteram_buffer_w));
291 	map(0xfff00000, 0xffffffff).rom().region("maincpu", 0);
292 }
293 
spotty_io_map(address_map & map)294 void limenko_state::spotty_io_map(address_map &map)
295 {
296 	map(0x0000, 0x0003).portr("IN0");
297 	map(0x0800, 0x0803).portr("IN1");
298 	map(0x0800, 0x0803).nopw(); // hopper related
299 	map(0x1000, 0x1003).portr("IN2");
300 	map(0x4800, 0x4803).portw("EEPROMOUT");
301 	map(0x5000, 0x5003).w(m_soundlatch, FUNC(generic_latch_8_device::write)).umask32(0x00ff0000).cswidth(32);
302 }
303 
304 
305 /*****************************************************************************************************
306   VIDEO HARDWARE EMULATION
307 *****************************************************************************************************/
308 
TILE_GET_INFO_MEMBER(limenko_state::get_bg_tile_info)309 TILE_GET_INFO_MEMBER(limenko_state::get_bg_tile_info)
310 {
311 	const u32 tile  = m_bg_videoram[tile_index] & 0x7ffff;
312 	const u32 color = (m_bg_videoram[tile_index]>>28) & 0xf;
313 	tileinfo.set(0, tile, color, 0);
314 }
315 
TILE_GET_INFO_MEMBER(limenko_state::get_md_tile_info)316 TILE_GET_INFO_MEMBER(limenko_state::get_md_tile_info)
317 {
318 	const u32 tile  = m_md_videoram[tile_index] & 0x7ffff;
319 	const u32 color = (m_md_videoram[tile_index]>>28) & 0xf;
320 	tileinfo.set(0, tile, color, 0);
321 }
322 
TILE_GET_INFO_MEMBER(limenko_state::get_fg_tile_info)323 TILE_GET_INFO_MEMBER(limenko_state::get_fg_tile_info)
324 {
325 	const u32 tile  = m_fg_videoram[tile_index] & 0x7ffff;
326 	const u32 color = (m_fg_videoram[tile_index]>>28) & 0xf;
327 	tileinfo.set(0, tile, color, 0);
328 }
329 
draw_single_sprite(bitmap_ind16 & dest_bmp,const rectangle & clip,u8 width,u8 height,u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,u8 transparent_color,u8 priority)330 void limenko_state::draw_single_sprite(bitmap_ind16 &dest_bmp,const rectangle &clip,u8 width, u8 height,
331 							u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
332 							u8 transparent_color, u8 priority)
333 {
334 	/* Start drawing */
335 	const u16 pal = color << 8;
336 	const u8 *source_base = &m_gfx_region[code];
337 
338 	int xinc = flipx ? -1 : 1;
339 	int yinc = flipy ? -1 : 1;
340 
341 	int x_index_base = flipx ? width - 1 : 0;
342 	int y_index = flipy ? height - 1 : 0;
343 
344 	// start coordinates
345 	int sx = offsx;
346 	int sy = offsy;
347 
348 	// end coordinates
349 	int ex = sx + width;
350 	int ey = sy + height;
351 
352 	if (sx < clip.min_x)
353 	{ // clip left
354 		int pixels = clip.min_x - sx;
355 		sx += pixels;
356 		x_index_base += xinc * pixels;
357 	}
358 	if (sy < clip.min_y)
359 	{ // clip top
360 		int pixels = clip.min_y - sy;
361 		sy += pixels;
362 		y_index += yinc * pixels;
363 	}
364 	// NS 980211 - fixed incorrect clipping
365 	if (ex > clip.max_x + 1)
366 	{ // clip right
367 		ex = clip.max_x + 1;
368 	}
369 	if (ey > clip.max_y + 1)
370 	{ // clip bottom
371 		ey = clip.max_y + 1;
372 	}
373 
374 	if (ex > sx)
375 	{ // skip if inner loop doesn't draw anything
376 		for (int y = sy; y < ey; y++)
377 		{
378 			u8 const *const source = source_base + y_index * width;
379 			u16 *const dest = &dest_bmp.pix(y);
380 			u8 *const pri = &m_sprites_bitmap_pri.pix(y);
381 			int x_index = x_index_base;
382 			for (int x = sx; x < ex; x++)
383 			{
384 				const u8 c = source[x_index];
385 				if (c != transparent_color)
386 				{
387 						if (pri[x] < priority)
388 						{
389 							dest[x] = pal + c;
390 							pri[x] = priority;
391 						}
392 				}
393 				x_index += xinc;
394 			}
395 			y_index += yinc;
396 		}
397 	}
398 }
399 
400 // sprites aren't tile based (except for 8x8 ones)
draw_sprites()401 void limenko_state::draw_sprites()
402 {
403 	const rectangle cliprect(0,511,0,511);
404 	m_sprites_bitmap_pri.fill(0, cliprect);
405 	m_sprites_bitmap.fill(0, cliprect);
406 
407 	u32 *sprites = m_spriteram + (0x200 * 2 * m_spriteram_bit);
408 
409 	for (int i = 0; i <= m_prev_sprites_count * 2; i += 2)
410 	{
411 		if (~sprites[i] & 0x80000000) continue;
412 
413 		const int x      =  ((sprites[i + 0] & 0x01ff0000) >> 16);
414 		const int width  = (((sprites[i + 0] & 0x0e000000) >> 25) + 1) * 8;
415 		const bool flipx =    sprites[i + 0] & 0x10000000;
416 		const int y      =    sprites[i + 0] & 0x000001ff;
417 		const int height = (((sprites[i + 0] & 0x00000e00) >> 9) + 1) * 8;
418 		const bool flipy =    sprites[i + 0] & 0x00001000;
419 		const u32 code   =   (sprites[i + 1] & 0x0007ffff) << 6;
420 		const u32 color  =   (sprites[i + 1] & 0xf0000000) >> 28;
421 
422 		int pri = 0;
423 		if (sprites[i + 1] & 0x04000000)
424 		{
425 			// below fg
426 			pri = 1;
427 		}
428 		else
429 		{
430 			// above everything
431 			pri = 2;
432 		}
433 
434 		/* Bounds checking */
435 		if ((code + (width * height)) > m_gfx_region.length())
436 			continue;
437 
438 		draw_single_sprite(m_sprites_bitmap,cliprect,width,height,code,color,flipx,flipy,x,y,0,pri);
439 
440 		// wrap around x
441 		draw_single_sprite(m_sprites_bitmap,cliprect,width,height,code,color,flipx,flipy,x-512,y,0,pri);
442 
443 		// wrap around y
444 		draw_single_sprite(m_sprites_bitmap,cliprect,width,height,code,color,flipx,flipy,x,y-512,0,pri);
445 
446 		// wrap around x and y
447 		draw_single_sprite(m_sprites_bitmap,cliprect,width,height,code,color,flipx,flipy,x-512,y-512,0,pri);
448 	}
449 }
450 
copy_sprites(bitmap_ind16 & bitmap,bitmap_ind16 & sprites_bitmap,bitmap_ind8 & priority_bitmap,const rectangle & cliprect)451 void limenko_state::copy_sprites(bitmap_ind16 &bitmap, bitmap_ind16 &sprites_bitmap, bitmap_ind8 &priority_bitmap, const rectangle &cliprect)
452 {
453 	for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
454 	{
455 		u16 const *const source = &sprites_bitmap.pix(y);
456 		u16 *const dest = &bitmap.pix(y);
457 		u8 const *const dest_pri = &priority_bitmap.pix(y);
458 		u8 const *const source_pri = &m_sprites_bitmap_pri.pix(y);
459 
460 		for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
461 		{
462 			if (source[x] != 0)
463 			{
464 				if (dest_pri[x] < source_pri[x])
465 					dest[x] = source[x];
466 			}
467 		}
468 	}
469 }
470 
video_start()471 void limenko_state::video_start()
472 {
473 	m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(limenko_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8,8,128,64);
474 	m_md_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(limenko_state::get_md_tile_info)), TILEMAP_SCAN_ROWS, 8,8,128,64);
475 	m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(limenko_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8,8,128,64);
476 
477 	m_md_tilemap->set_transparent_pen(0);
478 	m_fg_tilemap->set_transparent_pen(0);
479 
480 	m_sprites_bitmap.allocate(512,512);
481 	m_sprites_bitmap_pri.allocate(512,512);
482 
483 	save_item(NAME(m_spriteram_bit));
484 	save_item(NAME(m_prev_sprites_count));
485 }
486 
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)487 u32 limenko_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
488 {
489 	// m_videoreg[4] ???? It always has this value: 0xffeffff8 (2 signed bytes? values: -17 and -8 ?)
490 
491 	screen.priority().fill(0, cliprect);
492 
493 	m_bg_tilemap->enable(m_videoreg[0] & 4);
494 	m_md_tilemap->enable(m_videoreg[0] & 2);
495 	m_fg_tilemap->enable(m_videoreg[0] & 1);
496 
497 	m_bg_tilemap->set_scrolly(0, m_videoreg[3] & 0xffff);
498 	m_md_tilemap->set_scrolly(0, m_videoreg[2] & 0xffff);
499 	m_fg_tilemap->set_scrolly(0, m_videoreg[1] & 0xffff);
500 
501 	m_bg_tilemap->set_scrollx(0, (m_videoreg[3] & 0xffff0000) >> 16);
502 	m_md_tilemap->set_scrollx(0, (m_videoreg[2] & 0xffff0000) >> 16);
503 	m_fg_tilemap->set_scrollx(0, (m_videoreg[1] & 0xffff0000) >> 16);
504 
505 	m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0);
506 	m_md_tilemap->draw(screen, bitmap, cliprect, 0,0);
507 	m_fg_tilemap->draw(screen, bitmap, cliprect, 0,1);
508 
509 	if (m_videoreg[0] & 8)
510 		copy_sprites(bitmap, m_sprites_bitmap, screen.priority(), cliprect);
511 
512 	return 0;
513 }
514 
515 /*****************************************************************************************************
516   INPUT PORTS
517 *****************************************************************************************************/
518 
519 static INPUT_PORTS_START(legendoh)
520 	PORT_START("IN0")
521 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)    PORT_PLAYER(1)
522 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN)  PORT_PLAYER(1)
523 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT)  PORT_PLAYER(1)
524 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1)
525 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
526 	PORT_BIT(0x00200000, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1)
527 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(1)
528 	PORT_BIT(0x00800000, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(1)
529 	PORT_BIT(0x01000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)    PORT_PLAYER(3)
530 	PORT_BIT(0x02000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN)  PORT_PLAYER(3)
531 	PORT_BIT(0x04000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT)  PORT_PLAYER(3)
532 	PORT_BIT(0x08000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(3)
533 	PORT_BIT(0x10000000, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(3)
534 	PORT_BIT(0x20000000, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(3)
535 	PORT_BIT(0x40000000, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(3)
536 	PORT_BIT(0x80000000, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(3)
537 	PORT_BIT(0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED)
538 
539 	PORT_START("IN1")
540 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)    PORT_PLAYER(2)
541 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN)  PORT_PLAYER(2)
542 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT)  PORT_PLAYER(2)
543 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2)
544 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2)
545 	PORT_BIT(0x00200000, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(2)
546 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(2)
547 	PORT_BIT(0x00800000, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(2)
548 	PORT_BIT(0x01000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)    PORT_PLAYER(4)
549 	PORT_BIT(0x02000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN)  PORT_PLAYER(4)
550 	PORT_BIT(0x04000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT)  PORT_PLAYER(4)
551 	PORT_BIT(0x08000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(4)
552 	PORT_BIT(0x10000000, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(4)
553 	PORT_BIT(0x20000000, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(4)
554 	PORT_BIT(0x40000000, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(4)
555 	PORT_BIT(0x80000000, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(4)
556 	PORT_BIT(0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED)
557 
558 	PORT_START("IN2")
559 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_START1)
560 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_START2)
561 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_COIN1)
562 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_COIN2)
563 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_SERVICE1)
564 	PORT_SERVICE_NO_TOGGLE(0x00200000, IP_ACTIVE_LOW)
565 	PORT_BIT(0x00400000, IP_ACTIVE_HIGH, IPT_CUSTOM) //security bit
566 	PORT_BIT(0x00800000, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read)
567 	PORT_BIT(0x01000000, IP_ACTIVE_LOW, IPT_START3)
568 	PORT_BIT(0x02000000, IP_ACTIVE_LOW, IPT_START4)
569 	PORT_BIT(0x04000000, IP_ACTIVE_LOW, IPT_COIN3)
570 	PORT_BIT(0x08000000, IP_ACTIVE_LOW, IPT_COIN4)
571 	PORT_BIT(0x10000000, IP_ACTIVE_LOW, IPT_SERVICE2)
572 	PORT_DIPNAME(0x20000000, 0x00000000, "Sound Enable")
DEF_STR(Off)573 	PORT_DIPSETTING(         0x20000000, DEF_STR(Off))
574 	PORT_DIPSETTING(         0x00000000, DEF_STR(On))
575 	PORT_BIT(0x80000000, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_READ_LINE_MEMBER(limenko_state, spriteram_bit_r) //changes spriteram location
576 	PORT_BIT(0x4000ffff, IP_ACTIVE_LOW, IPT_UNUSED)
577 
578 	PORT_START("EEPROMOUT")
579 	PORT_BIT(0x00010000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, cs_write)
580 	PORT_BIT(0x00020000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, clk_write)
581 	PORT_BIT(0x00040000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, di_write)
582 //  PORT_BIT(0x00080000, IP_ACTIVE_HIGH, IPT_UNKNOWN) // 0x80000 -> video disabled?
583 INPUT_PORTS_END
584 
585 static INPUT_PORTS_START(sb2003)
586 	PORT_START("IN0")
587 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)    PORT_PLAYER(1)
588 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN)  PORT_PLAYER(1)
589 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT)  PORT_PLAYER(1)
590 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1)
591 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(1)
592 	PORT_BIT(0x00200000, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
593 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(1)
594 	PORT_BIT(0x00800000, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(1)
595 	PORT_BIT(0xff00ffff, IP_ACTIVE_LOW, IPT_UNUSED)
596 
597 	PORT_START("IN1")
598 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)    PORT_PLAYER(2)
599 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN)  PORT_PLAYER(2)
600 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT)  PORT_PLAYER(2)
601 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2)
602 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_PLAYER(2)
603 	PORT_BIT(0x00200000, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2)
604 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_PLAYER(2)
605 	PORT_BIT(0x00800000, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_PLAYER(2)
606 	PORT_BIT(0xff00ffff, IP_ACTIVE_LOW, IPT_UNUSED)
607 
608 	PORT_START("IN2")
609 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_START1)
610 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_START2)
611 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_COIN1)
612 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_COIN2)
613 	PORT_SERVICE_NO_TOGGLE(0x00200000, IP_ACTIVE_LOW)
614 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_CUSTOM) //security bit
615 	PORT_BIT(0x00800000, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read)
616 	PORT_DIPNAME(0x20000000, 0x00000000, "Sound Enable")
617 	PORT_DIPSETTING(         0x20000000, DEF_STR(Off))
618 	PORT_DIPSETTING(         0x00000000, DEF_STR(On))
619 	PORT_BIT(0x80000000, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_READ_LINE_MEMBER(limenko_state, spriteram_bit_r) //changes spriteram location
620 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_SERVICE1) // checked in dynabomb I/O test, but doesn't work in game
621 	PORT_BIT(0x5f00ffff, IP_ACTIVE_LOW, IPT_UNUSED)
622 
623 	PORT_START("EEPROMOUT")
624 	PORT_BIT(0x00010000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, cs_write)
625 	PORT_BIT(0x00020000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, clk_write)
626 	PORT_BIT(0x00040000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, di_write)
627 //  PORT_BIT(0x00080000, IP_ACTIVE_HIGH, IPT_UNKNOWN) // 0x80000 -> video disabled?
628 INPUT_PORTS_END
629 
630 static INPUT_PORTS_START(spotty)
631 	PORT_START("IN0")
632 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP)    PORT_NAME("Hold 1")
633 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN)  PORT_NAME("Hold 2")
634 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT)  PORT_NAME("Hold 3")
635 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_NAME("Hold 4")
636 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Bet")
637 	PORT_BIT(0x00200000, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("Stop")
638 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_NAME("Change")
639 	PORT_BIT(0x00800000, IP_ACTIVE_LOW, IPT_UNUSED)
640 	PORT_BIT(0xff00ffff, IP_ACTIVE_LOW, IPT_UNUSED)
641 
642 	PORT_START("IN1")
643 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_UNUSED)
644 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_UNUSED)
645 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_UNUSED)
646 	PORT_BIT(0x00080000, IP_ACTIVE_LOW, IPT_UNUSED)
647 	PORT_BIT(0x00100000, IP_ACTIVE_LOW, IPT_BUTTON4) PORT_NAME("Prize Hopper 1")
648 	PORT_BIT(0x00200000, IP_ACTIVE_LOW, IPT_BUTTON5) PORT_NAME("Prize Hopper 2")
649 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_BUTTON6) PORT_NAME("Prize Hopper 3")
650 	PORT_BIT(0x00800000, IP_ACTIVE_LOW, IPT_UNUSED)
651 	PORT_BIT(0xff00ffff, IP_ACTIVE_LOW, IPT_UNUSED)
652 
653 	PORT_START("IN2")
654 	PORT_BIT(0x00010000, IP_ACTIVE_LOW, IPT_START1)
655 	PORT_BIT(0x00020000, IP_ACTIVE_LOW, IPT_UNUSED)
656 	PORT_BIT(0x00040000, IP_ACTIVE_LOW, IPT_COIN1)
657 	PORT_BIT(0x00080000, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_READ_LINE_MEMBER(limenko_state, spriteram_bit_r) //changes spriteram location
658 	PORT_SERVICE_NO_TOGGLE(0x00200000, IP_ACTIVE_LOW)
659 	PORT_BIT(0x00400000, IP_ACTIVE_LOW, IPT_CUSTOM) //security bit
660 	PORT_BIT(0x00800000, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read)
661 	PORT_DIPNAME(0x20000000, 0x20000000, DEF_STR(Demo_Sounds))
662 	PORT_DIPSETTING(         0x00000000, DEF_STR(Off))
663 	PORT_DIPSETTING(         0x20000000, DEF_STR(On))
664 	PORT_BIT(0x80000000, IP_ACTIVE_LOW, IPT_UNUSED)
665 	PORT_BIT(0x5f10ffff, IP_ACTIVE_LOW, IPT_UNUSED)
666 
667 	PORT_START("EEPROMOUT")
668 	PORT_BIT(0x00010000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, cs_write)
669 	PORT_BIT(0x00020000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, clk_write)
670 	PORT_BIT(0x00040000, IP_ACTIVE_HIGH, IPT_OUTPUT) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, di_write)
671 //  PORT_BIT(0x00080000, IP_ACTIVE_HIGH, IPT_UNKNOWN) // 0x80000 -> video disabled?
672 INPUT_PORTS_END
673 
674 /*****************************************************************************************************
675   GRAPHICS DECODES
676 *****************************************************************************************************/
677 
678 
679 static GFXDECODE_START(gfx_limenko)
680 	GFXDECODE_ENTRY("gfx", 0, gfx_8x8x8_raw, 0, 16) /* tiles */
681 GFXDECODE_END
682 
683 
684 /*****************************************************************************************************
685   MACHINE DRIVERS
686 *****************************************************************************************************/
687 
688 void limenko_state::limenko(machine_config &config)
689 {
690 	E132XN(config, m_maincpu, 20000000*4); /* 4x internal multiplier */
691 	m_maincpu->set_addrmap(AS_PROGRAM, &limenko_state::limenko_map);
692 	m_maincpu->set_addrmap(AS_IO, &limenko_state::limenko_io_map);
693 	m_maincpu->set_vblank_int("screen", FUNC(limenko_state::irq0_line_hold));
694 
695 	EEPROM_93C46_16BIT(config, "eeprom");
696 
697 	/* video hardware */
698 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
699 	screen.set_refresh_hz(60);
700 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
701 	screen.set_size(384, 240);
702 	screen.set_visarea(0, 383, 0, 239);
703 	screen.set_screen_update(FUNC(limenko_state::screen_update));
704 	screen.set_palette(m_palette);
705 
706 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_limenko);
707 	PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x1000);
708 
709 	/* sound hardware */
710 	SPEAKER(config, "lspeaker").front_left();
711 	SPEAKER(config, "rspeaker").front_right();
712 
713 	GENERIC_LATCH_8(config, m_soundlatch);
714 	m_soundlatch->data_pending_callback().set(m_qs1000, FUNC(qs1000_device::set_irq));
715 	m_soundlatch->set_separate_acknowledge(true);
716 
717 	QS1000(config, m_qs1000, XTAL(24'000'000));
718 	m_qs1000->set_external_rom(true);
719 	m_qs1000->p1_in().set("soundlatch", FUNC(generic_latch_8_device::read));
720 	m_qs1000->p1_out().set(FUNC(limenko_state::qs1000_p1_w));
721 	m_qs1000->p2_out().set(FUNC(limenko_state::qs1000_p2_w));
722 	m_qs1000->p3_out().set(FUNC(limenko_state::qs1000_p3_w));
723 	m_qs1000->add_route(0, "lspeaker", 1.0);
724 	m_qs1000->add_route(1, "rspeaker", 1.0);
725 }
726 
spotty(machine_config & config)727 void limenko_state::spotty(machine_config &config)
728 {
729 	GMS30C2232(config, m_maincpu, 20000000);   /* 20 MHz, no internal multiplier */
730 	m_maincpu->set_addrmap(AS_PROGRAM, &limenko_state::spotty_map);
731 	m_maincpu->set_addrmap(AS_IO, &limenko_state::spotty_io_map);
732 	m_maincpu->set_vblank_int("screen", FUNC(limenko_state::irq0_line_hold));
733 
734 	at89c4051_device &audiocpu(AT89C4051(config, "audiocpu", 4000000));
735 	audiocpu.port_in_cb<1>().set(FUNC(limenko_state::audiocpu_p1_r));
736 	audiocpu.port_out_cb<1>().set(FUNC(limenko_state::audiocpu_p1_w));
737 	audiocpu.port_in_cb<3>().set(FUNC(limenko_state::audiocpu_p3_r));
738 	audiocpu.port_out_cb<3>().set(FUNC(limenko_state::audiocpu_p3_w));
739 
740 	EEPROM_93C46_16BIT(config, "eeprom");
741 
742 	/* video hardware */
743 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
744 	screen.set_refresh_hz(60);
745 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
746 	screen.set_size(384, 240);
747 	screen.set_visarea(0, 383, 0, 239);
748 	screen.set_screen_update(FUNC(limenko_state::screen_update));
749 	screen.set_palette(m_palette);
750 
751 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_limenko);
752 	PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x1000);
753 
754 	/* sound hardware */
755 	SPEAKER(config, "mono").front_center();
756 
757 	GENERIC_LATCH_8(config, m_soundlatch);
758 
759 	OKIM6295(config, m_oki, 4000000 / 4 , okim6295_device::PIN7_HIGH); //?
760 	m_oki->add_route(ALL_OUTPUTS, "mono", 1.0);
761 }
762 
763 
764 /*****************************************************************************************************
765   ROM LOADING
766 *****************************************************************************************************/
767 
768 /*
769 
770 Dynamite Bomber
771 Limenko
772 
773 The main board is identical to the one used on the other Limenko games.
774 The ROM board is slightly different (much simpler)
775 
776 REV : LMSYS_B
777 SEL : B1-06-00
778 |-----------------------------------------------------------|
779 |        U4+                 U20(DIP40)&                    |
780 ||-|                                           U19+&     |-||
781 || |                                                     | ||
782 || |                                                     | ||
783 || |     U3+                     U6+                     | ||
784 || |                                                     | ||
785 || |                                         U18(DIP32)  | ||
786 || |                             U5+                     | ||
787 || |     U2+                                             | ||
788 || |                                         U17(DIP32)  | ||
789 || |                                                     | ||
790 || |                                                     | ||
791 ||-|     U1+                                 U16(DIP32)  |-||
792 |                                                           |
793 |-----------------------------------------------------------|
794 Notes:
795        + - These ROMs surface mounted, type MX29F1610 16MBit SOP44
796        & - These locations not populated
797 
798 */
799 
800 ROM_START(dynabomb)
801 	ROM_REGION32_BE(0x200000, "maincpu", 0) /* Hyperstone CPU Code */
802 	ROM_LOAD16_WORD_SWAP("rom.u6", 0x000000, 0x200000, CRC(457e015d) SHA1(3afb56cdf903c9084c1f283dc50ec504ce3e199f))
803 
804 	ROM_REGION32_BE(0x400000, "maindata", ROMREGION_ERASEFF)
805 	ROM_LOAD16_WORD_SWAP("rom.u5", 0x000000, 0x200000, CRC(7e837adf) SHA1(8613fa187b8d4574b3935aa439aec2515033d64c))
806 
807 	ROM_REGION(0x80000, "qs1000:cpu", 0) /* QS1000 CPU */
CRC(f66d7e4d)808 	ROM_LOAD("rom.u16", 0x00000, 0x20000, CRC(f66d7e4d) SHA1(44f1851405ba525f1ed53521f4de12545ea9c46a))
809 	ROM_FILL(           0x20000, 0x60000, 0xff)
810 
811 	ROM_REGION(0x800000, "gfx", 0)
812 	ROM_LOAD32_BYTE("rom.u1", 0x000000, 0x200000, CRC(bf33eff6) SHA1(089b6d88d6d744bcfa036c6869f0444d6ceb26c9))
813 	ROM_LOAD32_BYTE("rom.u2", 0x000001, 0x200000, CRC(790bbcd5) SHA1(fc52c15fffc77dc3b3bc89a9606223c4fbaa578c))
814 	ROM_LOAD32_BYTE("rom.u3", 0x000002, 0x200000, CRC(ec094b12) SHA1(13c105df066ff308cc7e1842907644790946e5b5))
815 	ROM_LOAD32_BYTE("rom.u4", 0x000003, 0x200000, CRC(88b24e3c) SHA1(5f267f08144b413b55ef5e15c52e9cda096b80e7))
816 
817 	ROM_REGION(0x1000000, "qs1000", 0) /* QDSP wavetable ROMs */
818 	ROM_LOAD("rom.u18",  0x000000, 0x080000, CRC(50d76732) SHA1(6179c7365b62df620a10a1253d524807408821de))
819 	ROM_LOAD("rom.u17",  0x080000, 0x080000, CRC(20f2417c) SHA1(1bdc0b03215f5002eed4c25d670bbb5411189907))
820 	ROM_LOAD("qs1003.u4",0x200000, 0x200000, CRC(19e4b469) SHA1(9460e5b6a0fbf3fdd6a9fa0dcbf5062a2e07fe02))
821 	// U19 empty
822 	// U20 empty
823 ROM_END
824 
825 ROM_START(sb2003) /* No specific Country/Region */
826 	ROM_REGION32_BE(0x200000, "maincpu", 0) /* Hyperstone CPU Code */
827 	ROM_LOAD16_WORD_SWAP("sb2003_05.u6", 0x00000000, 0x200000, CRC(8aec4554) SHA1(57a12b142eb7bf08dd1e78d3c79222001bbaa636))
828 
829 	ROM_REGION32_BE(0x400000, "maindata", ROMREGION_ERASEFF)
830 	// u5 empty
831 
832 	ROM_REGION(0x80000, "qs1000:cpu", 0) /* QS1000 CPU */
833 	ROM_LOAD("07.u16", 0x00000, 0x20000, CRC(78acc607) SHA1(30a1aed40d45233dce88c6114989c71aa0f99ff7))
834 	ROM_FILL(          0x20000, 0x60000, 0xff)
835 
836 	ROM_REGION(0x800000, "gfx", 0)
837 	ROM_LOAD32_BYTE("01.u1", 0x000000, 0x200000, CRC(d2c7091a) SHA1(deff050eb0aee89f60d5ad13053e4f1bd4d35961))
838 	ROM_LOAD32_BYTE("02.u2", 0x000001, 0x200000, CRC(a0734195) SHA1(8947f351434e2f750c4bdf936238815baaeb8402))
839 	ROM_LOAD32_BYTE("03.u3", 0x000002, 0x200000, CRC(0f020280) SHA1(2c10baec8dbb201ee5e1c4c9d6b962e2ed02df7d))
840 	ROM_LOAD32_BYTE("04.u4", 0x000003, 0x200000, CRC(fc2222b9) SHA1(c7ee8cffbbee1673a9f107f3f163d029c3900230))
841 
842 	ROM_REGION(0x1000000, "qs1000", 0) /* QDSP wavetable ROMs */
843 	ROM_LOAD("06.u18",    0x000000, 0x200000, CRC(b6ad0d32) SHA1(33e73963ea25e131801dc11f25be6ab18bef03ed))
844 	ROM_LOAD("qs1003.u4", 0x200000, 0x200000, CRC(19e4b469) SHA1(9460e5b6a0fbf3fdd6a9fa0dcbf5062a2e07fe02))
845 	// U17 empty
846 	// U19 empty
847 	// U20 (S-ROM) empty
848 ROM_END
849 
850 ROM_START(sb2003a) /* Asia Region */
851 	ROM_REGION32_BE(0x200000, "maincpu", 0) /* Hyperstone CPU Code */
852 	ROM_LOAD16_WORD_SWAP("sb2003a_05.u6", 0x000000, 0x200000, CRC(265e45a7) SHA1(b9c8b63aa89c08f3d9d404621e301b122f85389a))
853 
854 	ROM_REGION32_BE(0x400000, "maindata", ROMREGION_ERASEFF)
855 	// u5 empty
856 
857 	ROM_REGION(0x80000, "qs1000:cpu", 0) /* QS1000 CPU */
858 	ROM_LOAD("07.u16", 0x00000, 0x20000, CRC(78acc607) SHA1(30a1aed40d45233dce88c6114989c71aa0f99ff7))
859 	ROM_FILL(          0x20000, 0x60000, 0xff)
860 
861 	ROM_REGION(0x800000, "gfx", 0)
862 	ROM_LOAD32_BYTE("01.u1", 0x000000, 0x200000, CRC(d2c7091a) SHA1(deff050eb0aee89f60d5ad13053e4f1bd4d35961))
863 	ROM_LOAD32_BYTE("02.u2", 0x000001, 0x200000, CRC(a0734195) SHA1(8947f351434e2f750c4bdf936238815baaeb8402))
864 	ROM_LOAD32_BYTE("03.u3", 0x000002, 0x200000, CRC(0f020280) SHA1(2c10baec8dbb201ee5e1c4c9d6b962e2ed02df7d))
865 	ROM_LOAD32_BYTE("04.u4", 0x000003, 0x200000, CRC(fc2222b9) SHA1(c7ee8cffbbee1673a9f107f3f163d029c3900230))
866 
867 	ROM_REGION(0x1000000, "qs1000", 0) /* QDSP wavetable ROM */
868 	ROM_LOAD("06.u18",   0x000000, 0x200000, CRC(b6ad0d32) SHA1(33e73963ea25e131801dc11f25be6ab18bef03ed))
869 	ROM_LOAD("qs1003.u4",0x200000, 0x200000, CRC(19e4b469) SHA1(9460e5b6a0fbf3fdd6a9fa0dcbf5062a2e07fe02))
870 	// U17 empty
871 	// U19 empty
872 	// U20 (S-ROM) empty
873 ROM_END
874 
875 /*
876 
877 Legend Of Heroes
878 Limenko, 2000
879 
880 This game runs on a cartridge-based system with Hyperstone E1-32XN CPU and
881 QDSP QS1000 sound hardware.
882 
883 PCB Layout
884 ----------
885 
886 LIMENKO MAIN BOARD SYSTEM
887 MODEL : LMSYS
888 REV : LM-003B
889 SEL : B3-06-00
890 |-----------------------------------------------------------|
891 |                                                           |
892 ||-|                 IS61C256    |--------| IS41C16256   |-||
893 || |                             |SYS     |              | ||
894 || |           |------|          |L2D_HYP |              | ||
895 || | QS1003    |QS1000|          |VER1.0  |              | ||
896 || |           |      |24MHz     |--------| IC41C16256   | ||
897 || |           |------|                                  | ||
898 || |                             32MHz     20MHz         | ||
899 || |                                                     | ||
900 || |              PAL                                    | ||
901 || |DA1311                       |--------| IS41C16105   | ||
902 || |               IS61C6416     |E1-32XN |              | ||
903 ||-|                             |        |              |-||
904 |  TL084                         |        |                 |
905 |                                |--------| IC41C16105      |
906 |                                                           |
907 |  TL082         93C46                               PWR_LED|
908 |                                                    RUN_LED|
909 |VOL                                                        |
910 | KIA6280                                           RESET_SW|
911 |                                                    TEST_SW|
912 |                                                           |
913 |---|          JAMMA            |------|    22-WAY      |---|
914     |---------------------------|      |----------------|
915 
916 
917 ROM Board
918 ---------
919 
920 REV : LMSYS_D
921 SEL : D2-09-00
922 |-----------------------------------------------------------|
923 |   +&*SYS_ROM7              SOU_ROM2      SOU_PRG          |
924 ||-|+&*SYS_ROM8                                          |-||
925 || |  +SYS_ROM6              SOU_ROM1                    | ||
926 || |  +SYS_ROM5                           +CG_ROM10      | ||
927 || |  &SYS_ROM1              CG_ROM12    +*CG_ROM11      | ||
928 || |                                                     | ||
929 || |                                      +CG_ROM20      | ||
930 || |  &SYS_ROM2              CG_ROM22    +*CG_ROM21      | ||
931 || |                                                     | ||
932 || |                                      +CG_ROM30      | ||
933 || |  &SYS_ROM3              CG_ROM32    +*CG_ROM31      | ||
934 || |                                                     | ||
935 ||-|                                      +CG_ROM40      |-||
936 |      SYS_ROM4              CG_ROM42    +*CG_ROM41         |
937 |-----------------------------------------------------------|
938 Notes:
939       * - These ROMs located on the other side of the PCB
940       + - These ROMs surface mounted, type MX29F1610 16MBit SOP44
941       & - These locations not populated
942 
943 Link up 2 cabinets, up to 4 players can play at a time as a team
944 
945 */
946 
947 ROM_START(legendoh)
948 	ROM_REGION32_BE(0x200000, "maincpu", ROMREGION_ERASEFF) /* Hyperstone CPU Code */
949 	/* sys_rom1 empty */
950 	/* sys_rom2 empty */
951 	/* sys_rom3 empty */
952 	ROM_LOAD16_WORD_SWAP("01.sys_rom4", 0x180000, 0x80000, CRC(49b4a91f) SHA1(21619e8cd0b2fba8c2e08158497575a1760f52c5))
953 
954 	ROM_REGION32_BE(0x400000, "maindata", 0)
955 	ROM_LOAD16_WORD_SWAP("sys_rom6", 0x000000, 0x200000, CRC(5c13d467) SHA1(ed07b7e1b22293e256787ab079d00c2fb070bf4f))
956 	ROM_LOAD16_WORD_SWAP("sys_rom5", 0x200000, 0x200000, CRC(19dc8d23) SHA1(433687c6aa24b9456436eecb1dcb57814af3009d))
957 	/* sys_rom8 empty */
958 	/* sys_rom7 empty */
959 
960 	ROM_REGION(0x1200000, "gfx", 0)
961 	ROM_LOAD32_BYTE("cg_rom10",     0x0000000, 0x200000, CRC(93a48489) SHA1(a14157d31b4e9c8eb7ebe1b2f1b707ec8c8561a0))
962 	ROM_LOAD32_BYTE("cg_rom20",     0x0000001, 0x200000, CRC(1a6c0258) SHA1(ac7c3b8c2fdfb542103032144a30293d44759fd1))
963 	ROM_LOAD32_BYTE("cg_rom30",     0x0000002, 0x200000, CRC(a0559ef4) SHA1(6622f7107b374c9da816b9814fe93347e7422190))
964 	ROM_LOAD32_BYTE("cg_rom40",     0x0000003, 0x200000, CRC(a607b2b5) SHA1(9a6b867d6a777cbc910b98d505367819e0c20077))
965 	ROM_LOAD32_BYTE("cg_rom11",     0x0800000, 0x200000, CRC(a9fd5a50) SHA1(d15fc4d1697c1505aa98979af09bcfbbc2521145))
966 	ROM_LOAD32_BYTE("cg_rom21",     0x0800001, 0x200000, CRC(b05cdeb2) SHA1(43115146496ee3a820278ffc0b5f0325d6af6335))
967 	ROM_LOAD32_BYTE("cg_rom31",     0x0800002, 0x200000, CRC(a9a0d386) SHA1(501af14ea1af70be4862172701af4850750d3f36))
968 	ROM_LOAD32_BYTE("cg_rom41",     0x0800003, 0x200000, CRC(1c014f45) SHA1(a76246e90b41cc892575f3a3dc26d8d674e3fc3a))
969 	ROM_LOAD32_BYTE("02.cg_rom12",  0x1000000, 0x080000, CRC(8b2e8cbc) SHA1(6ed6db843e27d715e473752dd3853a28bb81a368))
970 	ROM_LOAD32_BYTE("03.cg_rom22",  0x1000001, 0x080000, CRC(a35960c8) SHA1(86914701930512cae81d1ad892d482264f80f695))
971 	ROM_LOAD32_BYTE("04.cg_rom32",  0x1000002, 0x080000, CRC(3f486cab) SHA1(6507d4bb9b4aa7d43f1026e932c82629d4fa44dd))
972 	ROM_LOAD32_BYTE("05.cg_rom42",  0x1000003, 0x080000, CRC(5d807bec) SHA1(c72c77ed0478f705018519cf68a54d22524d05fd))
973 
974 	ROM_REGION(0x80000, "qs1000:cpu", 0) /* QS1000 CPU */
975 	ROM_LOAD("sou_prg.06", 0x000000, 0x80000, CRC(bfafe7aa) SHA1(3e65869fe0970bafb59a0225642834042fdedfa6))
976 
977 	ROM_REGION(0x1000000, "qs1000", 0) /* QDSP wavetable ROMs */
978 	ROM_LOAD("sou_rom.07", 0x000000, 0x080000, CRC(4c6eb6d2) SHA1(58bced7bd944e03b0e3dfe1107c01819a33b2b31))
979 	ROM_LOAD("sou_rom.08", 0x080000, 0x080000, CRC(42c32dd5) SHA1(4702771288ba40119de63feb67eed85667235d81))
980 	ROM_LOAD("qs1003.u4",  0x200000, 0x200000, CRC(19e4b469) SHA1(9460e5b6a0fbf3fdd6a9fa0dcbf5062a2e07fe02))
981 ROM_END
982 
983 /*
984 
985 Spotty
986 
987 +---------------------------------+
988 |               GMS30C2232  16256 |
989 |                           16256 |
990 |J        M6295 SOU_ROM1 20MHz    |
991 |A             AT89C4051          |
992 |M       GAL      4MHz  SYS_ROM1* |
993 |M 93C46                SYS_ROM2  |
994 |A        16256x3       CG_ROM1   |
995 |          L2DHYP       CG_ROM2*  |
996 | SW1 SW2         32MHz CG_ROM3   |
997 +---------------------------------+
998 
999 Hyundia GMS30C2232 (Hyperstone core)
1000 Atmel AT89C4051 (8051 MCU with internal code)
1001 SYS L2D HYP Ver 1.0 ASIC Express
1002 EEPROM 93C46
1003 SW1 = Test
1004 SW2 = Reset
1005 * Unpopulated
1006 
1007 */
1008 
1009 ROM_START(spotty)
1010 	ROM_REGION32_BE(0x100000, "maincpu", ROMREGION_ERASEFF) /* Hyperstone CPU Code */
1011 	/* sys_rom1 empty */
1012 	ROM_LOAD16_WORD_SWAP("sys_rom2",     0x080000, 0x80000, CRC(6ded8d9b) SHA1(547c532f4014d818c4412244b60dbc439496de20))
1013 
1014 	ROM_REGION(0x01000, "audiocpu", 0)
1015 	ROM_LOAD("at89c4051.mcu", 0x000000, 0x01000, CRC(82ceab26) SHA1(9bbc454bdcbc70dc01f10a13c9fc01c884918fe8))
1016 
1017 	/* Expand the gfx roms here */
1018 	ROM_REGION(0x200000, "gfx", ROMREGION_ERASE00)
1019 
1020 	ROM_REGION(0x200000, "maindata", ROMREGION_ERASE00)
1021 	ROM_LOAD32_BYTE("gc_rom1",      0x000000, 0x80000, CRC(ea03f9c5) SHA1(5038c03c519c774da253f9ae4fa205e7eeaa2780))
1022 	ROM_LOAD32_BYTE("gc_rom3",      0x000001, 0x80000, CRC(0ddac0b9) SHA1(f4ac8e6dd7f1cbdeb97139008982e6c17a3d18b9))
1023 	/* gc_rom2 empty */
1024 
1025 	ROM_REGION(0x40000, "oki", 0)
1026 	ROM_LOAD("sou_rom1",     0x000000, 0x40000, CRC(5791195b) SHA1(de0df8f89f395cbf3508b01aeea05675e110ad04))
1027 ROM_END
1028 
1029 
1030 
1031 u32 limenko_state::dynabomb_speedup_r()
1032 {
1033 	if (m_maincpu->pc() == 0xc25b8)
1034 	{
1035 		m_maincpu->eat_cycles(50);
1036 	}
1037 
1038 	return m_mainram[0xe2784/4];
1039 }
1040 
legendoh_speedup_r()1041 u32 limenko_state::legendoh_speedup_r()
1042 {
1043 	if (m_maincpu->pc() == 0x23e32)
1044 	{
1045 		m_maincpu->eat_cycles(50);
1046 	}
1047 
1048 	return m_mainram[0x32ab0/4];
1049 }
1050 
sb2003_speedup_r()1051 u32 limenko_state::sb2003_speedup_r()
1052 {
1053 	if (m_maincpu->pc() == 0x26da4)
1054 	{
1055 		m_maincpu->eat_cycles(50);
1056 	}
1057 
1058 	return m_mainram[0x135800/4];
1059 }
1060 
spotty_speedup_r()1061 u32 limenko_state::spotty_speedup_r()
1062 {
1063 	if (m_maincpu->pc() == 0x8560)
1064 	{
1065 		m_maincpu->eat_cycles(50);
1066 	}
1067 
1068 	return m_mainram[0x6626c/4];
1069 }
1070 
init_common()1071 void limenko_state::init_common()
1072 {
1073 	// Set up the QS1000 program ROM banking, taking care not to overlap the internal RAM
1074 	m_qs1000->cpu().space(AS_IO).install_read_bank(0x0100, 0xffff, "bank");
1075 	membank("qs1000:bank")->configure_entries(0, 8, memregion("qs1000:cpu")->base()+0x100, 0x10000);
1076 
1077 	m_spriteram_bit = 1;
1078 }
1079 
init_dynabomb()1080 void limenko_state::init_dynabomb()
1081 {
1082 	m_maincpu->space(AS_PROGRAM).install_read_handler(0xe2784, 0xe2787, read32smo_delegate(*this, FUNC(limenko_state::dynabomb_speedup_r)));
1083 
1084 	init_common();
1085 }
1086 
init_legendoh()1087 void limenko_state::init_legendoh()
1088 {
1089 	m_maincpu->space(AS_PROGRAM).install_read_handler(0x32ab0, 0x32ab3, read32smo_delegate(*this, FUNC(limenko_state::legendoh_speedup_r)));
1090 
1091 	init_common();
1092 }
1093 
init_sb2003()1094 void limenko_state::init_sb2003()
1095 {
1096 	m_maincpu->space(AS_PROGRAM).install_read_handler(0x135800, 0x135803, read32smo_delegate(*this, FUNC(limenko_state::sb2003_speedup_r)));
1097 
1098 	init_common();
1099 }
1100 
1101 
init_spotty()1102 void limenko_state::init_spotty()
1103 {
1104 	u8 *dst    = memregion("gfx")->base();
1105 	u8 *src    = memregion("maindata")->base();
1106 
1107 	/* expand 4bpp roms to 8bpp space */
1108 	for (int x = 0; x < 0x200000; x += 4)
1109 	{
1110 		dst[x+1] = (src[x+0]&0xf0) >> 4;
1111 		dst[x+0] = (src[x+0]&0x0f) >> 0;
1112 		dst[x+3] = (src[x+1]&0xf0) >> 4;
1113 		dst[x+2] = (src[x+1]&0x0f) >> 0;
1114 	}
1115 
1116 	m_maincpu->space(AS_PROGRAM).install_read_handler(0x6626c, 0x6626f, read32smo_delegate(*this, FUNC(limenko_state::spotty_speedup_r)));
1117 
1118 	m_spriteram_bit = 1;
1119 
1120 	save_item(NAME(m_audiocpu_p1));
1121 	save_item(NAME(m_audiocpu_p3));
1122 }
1123 
1124 GAME(2000, dynabomb, 0,      limenko, sb2003,   limenko_state, init_dynabomb, ROT0, "Limenko",    "Dynamite Bomber (Korea, Rev 1.5)",   MACHINE_SUPPORTS_SAVE)
1125 GAME(2000, legendoh, 0,      limenko, legendoh, limenko_state, init_legendoh, ROT0, "Limenko",    "Legend of Heroes",                   MACHINE_SUPPORTS_SAVE)
1126 GAME(2003, sb2003,   0,      limenko, sb2003,   limenko_state, init_sb2003,   ROT0, "Limenko",    "Super Bubble 2003 (World, Ver 1.0)", MACHINE_SUPPORTS_SAVE)
1127 GAME(2003, sb2003a,  sb2003, limenko, sb2003,   limenko_state, init_sb2003,   ROT0, "Limenko",    "Super Bubble 2003 (Asia, Ver 1.0)",  MACHINE_SUPPORTS_SAVE)
1128 
1129 // this game only uses the same graphics chip used in Limenko's system
1130 GAME(2001, spotty,   0,      spotty,  spotty,   limenko_state, init_spotty,   ROT0, "Prince Co.", "Spotty (Ver. 2.0.2)",                MACHINE_SUPPORTS_SAVE)
1131