1 /*
2  *	Beatmania DJ Main Board (GX753)
3  *
4  *	Product numbers:
5  *	GQ753 beatmania (first release in 1997)
6  *	Gx853 beatmania 2nd MIX (1998)
7  *	Gx825 beatmania 3rd MIX
8  *	Gx858 beatmania complete MIX (1999)
9  *	Gx847 beatmania 4th MIX
10  *	Gx981 beatmania 5th MIX
11  *	Gx993 beatmania Club MIX (2000)
12  *	Gx988 beatmania complete MIX 2
13  *	Gx995 beatmania featuring Dreams Come True
14  *	GxA05 beatmania CORE REMIX
15  *	GxA21 beatmania 6th MIX (2001)
16  *	GxB07 beatmania 7th MIX
17  *	GxC01 beatmania THE FINAL (2002)
18  *
19  *	Gx803 Pop'n Music 1 (1998)
20  *	Gx831 Pop'n Music 2
21  *	Gx980 Pop'n Music 3 (1999)
22  *
23  *	????? Pop'n Stage
24  *	Gx970 Pop'n Stage EX (1999)
25  *
26  *	Chips:
27  *	15a:	MC68EC020FG25
28  *	25b:	001642
29  *	18d:	055555 (priority encoder)
30  *	 5f:	056766 (sprites)
31  *	18f:	056832 (tiles)
32  *	22f:	058143 = 054156 (tiles)
33  *	12j:	058141 = 054539 (x2) (2 sound chips in one)
34  *
35  *	TODO:
36  *	- correct FPS
37  *
38  */
39 
40 #include "driver.h"
41 #include "state.h"
42 #include "artwork.h"
43 #include "cpu/m68000/m68000.h"
44 #include "machine/idectrl.h"
45 #include "sound/k054539.h"
46 #include "vidhrdw/konamiic.h"
47 
48 
49 extern data32_t *djmain_obj_ram;
50 
51 VIDEO_UPDATE( djmain );
52 VIDEO_START( djmain );
53 
54 
55 static enum {
56 	BEATMANIA,
57 	POPNMUSIC,
58 	POPNSTAGE
59 } game_type;
60 
61 static int sndram_bank;
62 static data8_t *sndram;
63 
64 static int scratch_select;
65 static data8_t scratch_data[2];
66 
67 static int pending_vb_int;
68 static data16_t v_ctrl;
69 static data32_t obj_regs[0xa0/4];
70 
71 #define DISABLE_VB_INT	(!(v_ctrl & 0x8000))
72 
73 
74 /*************************************
75  *
76  *	68k CPU memory handlers
77  *
78  *************************************/
79 
WRITE32_HANDLER(paletteram32_w)80 static WRITE32_HANDLER( paletteram32_w )
81 {
82 	int r,g,b;
83 
84 	COMBINE_DATA(&paletteram32[offset]);
85 	data = paletteram32[offset];
86 
87  	r = (data >>  0) & 0xff;
88 	g = (data >>  8) & 0xff;
89 	b = (data >> 16) & 0xff;
90 
91 	palette_set_color(offset, r, g, b);
92 }
93 
94 
95 //---------
96 
sndram_set_bank(void)97 static void sndram_set_bank(void)
98 {
99 	sndram = memory_region(REGION_SOUND1) + 0x80000 * sndram_bank;
100 }
101 
WRITE32_HANDLER(sndram_bank_w)102 static WRITE32_HANDLER( sndram_bank_w )
103 {
104 	if (ACCESSING_MSW32)
105 	{
106 		sndram_bank = (data >> 16) & 0x1f;
107 		sndram_set_bank();
108 	}
109 }
110 
READ32_HANDLER(sndram_r)111 static READ32_HANDLER( sndram_r )
112 {
113 	data32_t data = 0;
114 
115 	if ((mem_mask & 0xff000000) == 0)
116 		data |= sndram[offset * 4] << 24;
117 
118 	if ((mem_mask & 0x00ff0000) == 0)
119 		data |= sndram[offset * 4 + 1] << 16;
120 
121 	if ((mem_mask & 0x0000ff00) == 0)
122 		data |= sndram[offset * 4 + 2] << 8;
123 
124 	if ((mem_mask & 0x000000ff) == 0)
125 		data |= sndram[offset * 4 + 3];
126 
127 	return data;
128 }
129 
WRITE32_HANDLER(sndram_w)130 static WRITE32_HANDLER( sndram_w )
131 {
132 	if ((mem_mask & 0xff000000) == 0)
133 		sndram[offset * 4] = data >> 24;
134 
135 	if ((mem_mask & 0x00ff0000) == 0)
136 		sndram[offset * 4 + 1] = data >> 16;
137 
138 	if ((mem_mask & 0x0000ff00) == 0)
139 		sndram[offset * 4 + 2] = data >> 8;
140 
141 	if ((mem_mask & 0x000000ff) == 0)
142 		sndram[offset * 4 + 3] = data;
143 }
144 
145 
146 //---------
147 
READ16_HANDLER(dual539_16_r)148 static READ16_HANDLER( dual539_16_r )
149 {
150 	data16_t ret = 0;
151 
152 	if (ACCESSING_LSB16)
153 		ret |= K054539_1_r(offset);
154 	if (ACCESSING_MSB16)
155 		ret |= K054539_0_r(offset)<<8;
156 
157 	return ret;
158 }
159 
WRITE16_HANDLER(dual539_16_w)160 static WRITE16_HANDLER( dual539_16_w )
161 {
162 	if (ACCESSING_LSB16)
163 		K054539_1_w(offset, data);
164 	if (ACCESSING_MSB16)
165 		K054539_0_w(offset, data>>8);
166 }
167 
READ32_HANDLER(dual539_r)168 static READ32_HANDLER( dual539_r )
169 {
170 	data32_t data = 0;
171 
172 	if (~mem_mask & 0xffff0000)
173 		data |= dual539_16_r(offset * 2, mem_mask >> 16) << 16;
174 	if (~mem_mask & 0x0000ffff)
175 		data |= dual539_16_r(offset * 2 + 1, mem_mask);
176 
177 	return data;
178 }
179 
WRITE32_HANDLER(dual539_w)180 static WRITE32_HANDLER( dual539_w )
181 {
182 	if (~mem_mask & 0xffff0000)
183 		dual539_16_w(offset * 2, data >> 16, mem_mask >> 16);
184 	if (~mem_mask & 0x0000ffff)
185 		dual539_16_w(offset * 2 + 1, data, mem_mask);
186 }
187 
188 
189 //---------
190 
READ32_HANDLER(obj_ctrl_r)191 static READ32_HANDLER( obj_ctrl_r )
192 {
193 	// read obj_regs[0x0c/4]: unknown
194 	// read obj_regs[0x24/4]: unknown
195 
196 	return obj_regs[offset];
197 }
198 
WRITE32_HANDLER(obj_ctrl_w)199 static WRITE32_HANDLER( obj_ctrl_w )
200 {
201 	// write obj_regs[0x28/4]: bank for rom readthrough
202 
203 	COMBINE_DATA(&obj_regs[offset]);
204 }
205 
READ32_HANDLER(obj_rom_r)206 static READ32_HANDLER( obj_rom_r )
207 {
208 	data8_t *mem8 = memory_region(REGION_GFX1);
209 	int bank = obj_regs[0x28/4] >> 16;
210 
211 	offset += bank * 0x200;
212 	offset *= 4;
213 
214 	if (~mem_mask & 0x0000ffff)
215 		offset += 2;
216 
217 	if (~mem_mask & 0xff00ff00)
218 		offset++;
219 
220 	return mem8[offset] * 0x01010101;
221 }
222 
223 
224 //---------
225 
WRITE32_HANDLER(v_ctrl_w)226 static WRITE32_HANDLER( v_ctrl_w )
227 {
228 	if (ACCESSING_MSW32)
229 	{
230 		data >>= 16;
231 		mem_mask >>= 16;
232 		COMBINE_DATA(&v_ctrl);
233 
234 		if (pending_vb_int && !DISABLE_VB_INT)
235 		{
236 			pending_vb_int = 0;
237 			cpu_set_irq_line(0, MC68000_IRQ_4, HOLD_LINE);
238 		}
239 	}
240 }
241 
READ32_HANDLER(v_rom_r)242 static READ32_HANDLER( v_rom_r )
243 {
244 	data8_t *mem8 = memory_region(REGION_GFX2);
245 	int bank = K056832_word_r(0x34/2, 0xffff);
246 
247 	offset *= 2;
248 
249 	if (!ACCESSING_MSB32)
250 		offset += 1;
251 
252 	offset += bank * 0x800 * 4;
253 
254 	if (v_ctrl & 0x020)
255 		offset += 0x800 * 2;
256 
257 	return mem8[offset] * 0x01010000;
258 }
259 
260 
261 //---------
262 
READ32_HANDLER(inp1_r)263 static READ32_HANDLER( inp1_r )
264 {
265 	data32_t result = (input_port_5_r(0)<<24) | (input_port_2_r(0)<<16) | (input_port_1_r(0)<<8) | input_port_0_r(0);
266 
267 	return result;
268 }
269 
READ32_HANDLER(inp2_r)270 static READ32_HANDLER( inp2_r )
271 {
272 	return (input_port_3_r(0)<<24) | (input_port_4_r(0)<<16) | 0xffff;
273 }
274 
READ32_HANDLER(scratch_r)275 static READ32_HANDLER( scratch_r )
276 {
277 	data32_t result = 0;
278 
279 	if (!(mem_mask & 0x0000ff00))
280 	{
281 		if (input_port_6_r(0) & (1 << scratch_select))
282 			scratch_data[scratch_select]++;
283 		if (input_port_6_r(0) & (4 << scratch_select))
284 			scratch_data[scratch_select]--;
285 
286 		result |= scratch_data[scratch_select] << 8;
287 	}
288 
289 	return result;
290 }
291 
WRITE32_HANDLER(scratch_w)292 static WRITE32_HANDLER( scratch_w )
293 {
294 	if (!(mem_mask & 0x00ff0000))
295 		scratch_select = (data >> 19) & 1;
296 }
297 
298 
299 //---------
300 
301 #define IDE_STD_OFFSET	(0x1f0/2)
302 #define IDE_ALT_OFFSET	(0x3f6/2)
303 
READ32_HANDLER(ide_std_r)304 static READ32_HANDLER( ide_std_r )
305 {
306 	if (ACCESSING_LSB32)
307 		return ide_controller16_0_r(IDE_STD_OFFSET + offset, 0x00ff) >> 8;
308 	else
309 		return ide_controller16_0_r(IDE_STD_OFFSET + offset, 0x0000) << 16;
310 }
311 
WRITE32_HANDLER(ide_std_w)312 static WRITE32_HANDLER( ide_std_w )
313 {
314 	if (ACCESSING_LSB32)
315 		ide_controller16_0_w(IDE_STD_OFFSET + offset, data << 8, 0x00ff);
316 	else
317 		ide_controller16_0_w(IDE_STD_OFFSET + offset, data >> 16, 0x0000);
318 }
319 
320 
READ32_HANDLER(ide_alt_r)321 static READ32_HANDLER( ide_alt_r )
322 {
323 	if (offset == 0)
324 		return ide_controller16_0_r(IDE_ALT_OFFSET, 0xff00) << 24;
325 
326 	return 0;
327 }
328 
WRITE32_HANDLER(ide_alt_w)329 static WRITE32_HANDLER( ide_alt_w )
330 {
331 	if (offset == 0 && !(mem_mask & 0x00ff0000))
332 		ide_controller16_0_w(IDE_ALT_OFFSET, data >> 24, 0xff00);
333 }
334 
335 
336 //---------
337 
338 // light/coin blocker control
339 
340 /*
341  beatmania/hiphopmania
342 	0x5d0000 (MSW16):
343 	bit 0: 1P button 1 LED
344 	    1: 1P button 2 LED
345 	    2: 1P button 3 LED
346 	    3: 1P button 4 LED
347 	    4: 1P button 5 LED
348 	    5: Right blue HIGHLIGHT	(active low)
349 	    6: 2P button 1 LED
350 	    7: 2P button 2 LED
351 	    8: 2P button 3 LED
352 	    9: Left blue HIGHLIGHT	(active low)
353 	   10: Left red HIGHLIGHT	(active low)
354 	   11: Right red HIGHLIGHT	(active low)
355 	12-15: not used?		(always low)
356 
357 	0x5d2000 (MSW16):
358 	    0: 1P START button LED
359 	    1: 2P START button LED
360 	    2: EFFECT button LED
361 	 3-10: not used?		(always low)
362 	   11: SSR
363 	   12: 2P button 4 LED
364 	   13: 2P button 5 LED
365 	   14: COIN BLOCKER		(active low)
366 	   15: not used?		(always low)
367 
368 
369  Pop'n Music
370 	0x5d0000 (MSW16):
371 	bit 0: Button 1 LED
372 	    1: Button 2 LED
373 	    2: Button 3 LED
374 	    3: Button 4 LED
375 	    4: Button 5 LED
376 	    5: Button 6 LED
377 	    6: Button 7 LED
378 	    7: Button 8 LED
379 	    8: Button 9 LED
380 	 9-15: not used?		(always low)
381 
382 	0x5d2000 (MSW16):
383 	    0: Left blue HIGHLIGHT
384 	    1: Left red HIGHLIGHT
385 	    2: Right blue HIGHLIGHT
386 	    3: Right red HIGHLIGHT
387 	  4-5: not used?		(always low)
388 	    6: EQUALIZER 1
389 	    7: EQUALIZER 2
390 	    8: EQUALIZER 3
391 	    9: EQUALIZER 4
392 	   10: EQUALIZER 5
393 	11-13: not used?		(always low)
394 	   14: COIN BLOCKER		(active low)
395 	   15: not used?		(always low)
396 
397 
398  Pop'n Stage
399 	0x5d0000 (MSW16):
400 	bit 0: Right R and G HIGHLIGHT
401 	    1: Right Y and B HIGHLIGHT
402 	    2: Left R and G HIGHLIGHT
403 	    3: Left Y and B HIGHLIGHT
404 	 4-15: not used?		(always low)
405 
406 	0x5d2000 (MSW16):
407 	bit 0: Button 1 LED
408 	    1: Button 2 LED
409 	    2: Button 3 LED
410 	    3: Button 4 LED
411 	    4: Button 5 LED
412 	    5: Button 6 LED
413 	    6: Button 7 LED
414 	    7: Button 8 LED
415 	    8: Button 9 LED
416 	    9: Button 9 LED
417 	   10: Button 10 LED
418 	   11: Left selection button LED
419 	   12: Middle selection button LED
420 	   13: Right selection button LED
421 	   14: COIN BLOCKER		(active low)
422 	   15: not used?		(always low)
423 */
424 
WRITE32_HANDLER(light_ctrl_1_w)425 static WRITE32_HANDLER( light_ctrl_1_w )
426 {
427 	if (ACCESSING_MSW32)
428 	{
429 		switch (game_type)
430 		{
431 		case BEATMANIA:
432 			artwork_show("right-red-hlt",  !(data & 0x08000000));	// Right red HIGHLIGHT
433 			artwork_show("left-red-hlt",   !(data & 0x04000000));	// Left red HIGHLIGHT
434 			artwork_show("left-blue-hlt",  !(data & 0x02000000));	// Left blue HIGHLIGHT
435 			artwork_show("right-blue-hlt", !(data & 0x00200000));	// Right blue HIGHLIGHT
436 			break;
437 		case POPNMUSIC:
438 			set_led_status(0, data & 0x00080000);			// Button 4
439 			set_led_status(1, data & 0x00100000);			// Button 5
440 			set_led_status(2, data & 0x00400000);			// Button 6
441 			break;
442 		case POPNSTAGE:
443 			artwork_show("right-rg-hlt",   data & 0x00010000);	// Left R&G HIGHLIGHT
444 			artwork_show("right-yb-hlt",   data & 0x00020000);	// Left Y&B HIGHLIGHT
445 			artwork_show("left-rg-hlt",    data & 0x00040000);	// Right R&G HIGHLIGHT
446 			artwork_show("left-yb-hlt",    data & 0x00080000);	// Right Y&B HIGHLIGHT
447 			break;
448 		}
449 	}
450 }
451 
WRITE32_HANDLER(light_ctrl_2_w)452 static WRITE32_HANDLER( light_ctrl_2_w )
453 {
454 	if (ACCESSING_MSW32)
455 	{
456 		switch (game_type)
457 		{
458 		case BEATMANIA:
459 			artwork_show("left-ssr",       data & 0x08000000);	// SSR
460 			artwork_show("right-ssr",      data & 0x08000000);	// SSR
461 			set_led_status(0, data & 0x00010000);			// 1P START
462 			set_led_status(1, data & 0x00020000);			// 2P START
463 			set_led_status(2, data & 0x00040000);			// EFFECT
464 			break;
465 		case POPNMUSIC:
466 			artwork_show("left-blue-hlt",  data & 0x00010000);	// Left blue HIGHLIGHT
467 			artwork_show("left-red-hlt",   data & 0x00020000);	// Left red HIGHLIGHT
468 			artwork_show("right-blue-hlt", data & 0x00040000);	// Right blue HIGHLIGHT
469 			artwork_show("right-red-hlt",  data & 0x00080000);	// Right red HIGHLIGHT
470 			break;
471 		case POPNSTAGE:
472 			set_led_status(0, data & 0x04000000);			// Left selection
473 			set_led_status(1, data & 0x08000000);			// Middle selection
474 			set_led_status(2, data & 0x10000000);			// Right selection
475 			break;
476 		}
477 	}
478 }
479 
480 
481 //---------
482 
483 // unknown ports :-(
484 
WRITE32_HANDLER(unknown590000_w)485 static WRITE32_HANDLER( unknown590000_w )
486 {
487 	//logerror("%08X: unknown 590000 write %08X: %08X & %08X\n", activecpu_get_previouspc(), offset, data, ~mem_mask);
488 }
489 
WRITE32_HANDLER(unknown802000_w)490 static WRITE32_HANDLER( unknown802000_w )
491 {
492 	//logerror("%08X: unknown 802000 write %08X: %08X & %08X\n", activecpu_get_previouspc(), offset, data, ~mem_mask);
493 }
494 
WRITE32_HANDLER(unknownc02000_w)495 static WRITE32_HANDLER( unknownc02000_w )
496 {
497 	//logerror("%08X: unknown c02000 write %08X: %08X & %08X\n", activecpu_get_previouspc(), offset, data, ~mem_mask);
498 }
499 
500 
501 
502 /*************************************
503  *
504  *	Interrupt handlers
505  *
506  *************************************/
507 
INTERRUPT_GEN(vb_interrupt)508 static INTERRUPT_GEN( vb_interrupt )
509 {
510 	pending_vb_int = 0;
511 
512 	if (DISABLE_VB_INT)
513 	{
514 		pending_vb_int = 1;
515 		return;
516 	}
517 
518 	//logerror("V-Blank interrupt\n");
519 	cpu_set_irq_line(0, MC68000_IRQ_4, HOLD_LINE);
520 }
521 
522 
ide_interrupt(int state)523 static void ide_interrupt(int state)
524 {
525 	if (state != CLEAR_LINE)
526 	{
527 		//logerror("IDE interrupt asserted\n");
528 		cpu_set_irq_line(0, MC68000_IRQ_1, HOLD_LINE);
529 	}
530 	else
531 	{
532 		//logerror("IDE interrupt cleared\n");
533 		cpu_set_irq_line(0, MC68000_IRQ_1, CLEAR_LINE);
534 	}
535 }
536 
537 
538 
539 
540 /*************************************
541  *
542  *	Memory definitions
543  *
544  *************************************/
545 
MEMORY_READ32_START(readmem)546 static MEMORY_READ32_START( readmem )
547 	{ 0x000000, 0x0fffff, MRA32_ROM },		// PRG ROM
548 	{ 0x400000, 0x40ffff, MRA32_RAM },		// WORK RAM
549 	{ 0x480000, 0x48443f, paletteram32_r },		// COLOR RAM (tilemap)
550 	{ 0x500000, 0x57ffff, sndram_r },		// SOUND RAM
551 	{ 0x580000, 0x58003f, K056832_long_r },		// VIDEO REG (tilemap)
552 	{ 0x5b0000, 0x5b04ff, dual539_r },		// SOUND regs
553 	{ 0x5c0000, 0x5c0003, inp1_r },			// input port
554 	{ 0x5c8000, 0x5c8003, inp2_r },			// input port
555 	{ 0x5e0000, 0x5e0003, scratch_r },		// scratch input port
556 	{ 0x600000, 0x601fff, v_rom_r },		// VIDEO ROM readthrough (for POST)
557 	{ 0x801000, 0x8017ff, MRA32_RAM },		// OBJECT RAM
558 	{ 0x803000, 0x80309f, obj_ctrl_r },		// OBJECT REGS
559 	{ 0x803800, 0x803fff, obj_rom_r },		// OBJECT ROM readthrough (for POST)
560 	{ 0xc00000, 0xc01fff, K056832_ram_long_r },	// VIDEO RAM (tilemap) (beatmania)
561 	{ 0xd00000, 0xd0000f, ide_std_r },		// IDE control regs (hiphopmania)
562 	{ 0xd4000c, 0xd4000f, ide_alt_r },		// IDE status control reg (hiphopmania)
563 	{ 0xe00000, 0xe01fff, K056832_ram_long_r },	// VIDEO RAM (tilemap) (hiphopmania)
564 	{ 0xf00000, 0xf0000f, ide_std_r },		// IDE control regs (beatmania)
565 	{ 0xf4000c, 0xf4000f, ide_alt_r },		// IDE status control reg (beatmania)
566 MEMORY_END
567 
568 static MEMORY_WRITE32_START( writemem )
569 	{ 0x000000, 0x0fffff, MWA32_ROM },		// PRG ROM
570 	{ 0x400000, 0x40ffff, MWA32_RAM },		// WORK RAM
571 	{ 0x480000, 0x48443f, paletteram32_w, &paletteram32 },	// COLOR RAM
572 	{ 0x500000, 0x57ffff, sndram_w },		// SOUND RAM
573 	{ 0x580000, 0x58003f, K056832_long_w },		// VIDEO REG (tilemap)
574 	{ 0x590000, 0x590007, unknown590000_w },	// ??
575 	{ 0x5a0000, 0x5a005f, K055555_long_w },		// 055555: priority encoder
576 	{ 0x5b0000, 0x5b04ff, dual539_w },		// SOUND regs
577 	{ 0x5d0000, 0x5d0003, light_ctrl_1_w },		// light/coin blocker control 1
578 	{ 0x5d2000, 0x5d2003, light_ctrl_2_w },		// light/coin blocker control 2
579 	{ 0x5d4000, 0x5d4003, v_ctrl_w },		// VIDEO control
580 	{ 0x5d6000, 0x5d6003, sndram_bank_w },		// SOUND RAM bank
581 	{ 0x5e0000, 0x5e0003, scratch_w },		// scratch input port
582 	{ 0x801000, 0x8017ff, MWA32_RAM, &djmain_obj_ram },	// OBJECT RAM
583 	{ 0x802000, 0x802fff, unknown802000_w },	// ??
584 	{ 0x803000, 0x80309f, obj_ctrl_w },		// OBJECT REGS
585 	{ 0xc00000, 0xc01fff, K056832_ram_long_w },	// VIDEO RAM (tilemap) (beatmania)
586 	{ 0xc02000, 0xc02047, unknownc02000_w },	// ??
587 	{ 0xd00000, 0xd0000f, ide_std_w },		// IDE control regs (hiphopmania)
588 	{ 0xd4000c, 0xd4000f, ide_alt_w },		// IDE status control reg (hiphopmania)
589 	{ 0xe00000, 0xe01fff, K056832_ram_long_w },	// VIDEO RAM (tilemap) (hiphopmania)
590 	{ 0xf00000, 0xf0000f, ide_std_w },		// IDE control regs (beatmania)
591 	{ 0xf4000c, 0xf4000f, ide_alt_w },		// IDE status control reg (beatmania)
592 MEMORY_END
593 
594 
595 
596 /*************************************
597  *
598  *	Port definitions
599  *
600  *************************************/
601 
602 #define BEATMANIA_INPUT \
603 	PORT_START      /* IN 0 */ \
604 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) \
605 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) \
606 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 ) \
607 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 ) \
608 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON5 | IPF_PLAYER1 ) \
609 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
610 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) \
611 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) \
612  \
613 	PORT_START      /* IN 1 */ \
614 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 ) \
615 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 ) \
616 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON5 | IPF_PLAYER2 ) \
617 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
618 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) \
619 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) \
620 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START3 )	/* EFFECT */ \
621 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) \
622  \
623 	PORT_START      /* IN 2 */ \
624 	PORT_BITX(0x01, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )	/* TEST SW */ \
625 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )	/* SERVICE */ \
626 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE2 )	/* RESET SW */ \
627 	PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
628 
629 #define BEATMANIA_SCRATCH \
630 	PORT_START      /* IN 6: fake port for scratch */ \
631 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON6 | IPF_PLAYER1 )	/* +R */ \
632 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 | IPF_PLAYER2 )	/* +R */ \
633 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON7 | IPF_PLAYER1 )	/* -L */ \
634 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON7 | IPF_PLAYER2 )	/* -L */
635 
636 #define BEATMANIA_DSW1(base,mask) \
637 	PORT_START      /* IN 3 */ \
638 	PORT_DIPNAME( 0xff, (0xff & mask) | base, DEF_STR( Coinage ) ) \
639 	PORT_DIPSETTING(    (0xe0 & mask) | base, "1P 8C / 2P 16C / Continue 8C" ) \
640 	PORT_DIPSETTING(    (0xe1 & mask) | base, "1P 8C / 2P 16C / Continue 7C" ) \
641 	PORT_DIPSETTING(    (0xe2 & mask) | base, "1P 8C / 2P 16C / Continue 6C" ) \
642 	PORT_DIPSETTING(    (0xe3 & mask) | base, "1P 7C / 2P 14C / Continue 7C" ) \
643 	PORT_DIPSETTING(    (0xe4 & mask) | base, "1P 7C / 2P 14C / Continue 6C" ) \
644 	PORT_DIPSETTING(    (0xe5 & mask) | base, "1P 7C / 2P 14C / Continue 5C" ) \
645 	PORT_DIPSETTING(    (0xe6 & mask) | base, "1P 6C / 2P 12C / Continue 6C" ) \
646 	PORT_DIPSETTING(    (0xe7 & mask) | base, "1P 6C / 2P 12C / Continue 5C" ) \
647 	PORT_DIPSETTING(    (0xe8 & mask) | base, "1P 6C / 2P 12C / Continue 4C" ) \
648 	PORT_DIPSETTING(    (0xe9 & mask) | base, "1P 5C / 2P 10C / Continue 5C" ) \
649 	PORT_DIPSETTING(    (0xeb & mask) | base, "1P 5C / 2P 10C / Continue 3C" ) \
650 	PORT_DIPSETTING(    (0xea & mask) | base, "1P 5C / 2P 10C / Continue 4C" ) \
651 	PORT_DIPSETTING(    (0xec & mask) | base, "1P 4C / 2P 8C / Continue 4C" ) \
652 	PORT_DIPSETTING(    (0xed & mask) | base, "1P 4C / 2P 8C / Continue 3C" ) \
653 	PORT_DIPSETTING(    (0xee & mask) | base, "1P 4C / 2P 8C / Continue 2C" ) \
654 	PORT_DIPSETTING(    (0xef & mask) | base, "1P 3C / 2P 6C / Continue 3C" ) \
655 	PORT_DIPSETTING(    (0xf0 & mask) | base, "1P 3C / 2P 6C / Continue 2C" ) \
656 	PORT_DIPSETTING(    (0xf1 & mask) | base, "1P 3C / 2P 6C / Continue 1C" ) \
657 	PORT_DIPSETTING(    (0xf2 & mask) | base, "1P 3C / 2P 4C / Continue 3C" ) \
658 	PORT_DIPSETTING(    (0xf3 & mask) | base, "1P 3C / 2P 4C / Continue 2C" ) \
659 	PORT_DIPSETTING(    (0xf4 & mask) | base, "1P 3C / 2P 4C / Continue 1C" ) \
660 	PORT_DIPSETTING(    (0xf5 & mask) | base, "1P 3C / 2P 3C / Continue 3C" ) \
661 	PORT_DIPSETTING(    (0xf6 & mask) | base, "1P 3C / 2P 3C / Continue 2C" ) \
662 	PORT_DIPSETTING(    (0xf7 & mask) | base, "1P 3C / 2P 3C / Continue 1C" ) \
663 	PORT_DIPSETTING(    (0xfa & mask) | base, "1P 2C / 2P 3C / Continue 2C" ) \
664 	PORT_DIPSETTING(    (0xfb & mask) | base, "1P 2C / 2P 3C / Continue 1C" ) \
665 	PORT_DIPSETTING(    (0xf8 & mask) | base, "1P 2C / 2P 4C / Continue 2C" ) \
666 	PORT_DIPSETTING(    (0xff & mask) | base, "1P 2C / 2P 4C / Continue 1C" ) \
667 	PORT_DIPSETTING(    (0xfc & mask) | base, "1P 2C / 2P 2C / Continue 2C" ) \
668 	PORT_DIPSETTING(    (0xfd & mask) | base, "1P 2C / 2P 2C / Continue 1C" ) \
669 	PORT_DIPSETTING(    (0xfe & mask) | base, "1P 1C / 2P 2C / Continue 1C" ) \
670 	PORT_DIPSETTING(    (0xf9 & mask) | base, "1P 1C / 2P 1C / Continue 1C" ) \
671 	PORT_DIPSETTING(    (0x00 & mask) | base, DEF_STR( Free_Play ) )
672 
673 #define BEATMANIA_DSW2 \
674 	PORT_START      /* IN 4 */ \
675 	PORT_DIPNAME( 0x80, 0x80, "Score Display" ) \
676 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) ) \
677 	PORT_DIPSETTING(    0x80, DEF_STR( On ) ) \
678 	PORT_DIPNAME( 0x60, 0x60, DEF_STR( Demo_Sounds ) ) \
679 	PORT_DIPSETTING(    0x60, "Loud" ) \
680 	PORT_DIPSETTING(    0x20, "Medium" ) \
681 	PORT_DIPSETTING(    0x40, "Low" ) \
682 	PORT_DIPSETTING(    0x00, "Silent" ) \
683 	PORT_DIPNAME( 0x10, 0x10, "Level Display" ) \
684 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) ) \
685 	PORT_DIPSETTING(    0x10, DEF_STR( On ) ) \
686 	PORT_DIPNAME( 0x0c, 0x0c, "Normal Difficulty" ) \
687 	PORT_DIPSETTING(    0x08, "Level 0" ) \
688 	PORT_DIPSETTING(    0x0c, "Level 1" ) \
689 	PORT_DIPSETTING(    0x04, "Level 2" ) \
690 	PORT_DIPSETTING(    0x00, "Level 3" ) \
691 	PORT_DIPNAME( 0x03, 0x03, "Expert Difficulty" ) \
692 	PORT_DIPSETTING(    0x02, "Level 0" ) \
693 	PORT_DIPSETTING(    0x03, "Level 1" ) \
694 	PORT_DIPSETTING(    0x01, "Level 2" ) \
695 	PORT_DIPSETTING(    0x00, "Level 3" )
696 
697 #define BEATMANIA_DSW2_OLD_LEVEL \
698 	PORT_START      /* IN 4 */ \
699 	PORT_DIPNAME( 0x80, 0x80, "Score Display" ) \
700 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) ) \
701 	PORT_DIPSETTING(    0x80, DEF_STR( On ) ) \
702 	PORT_DIPNAME( 0x60, 0x60, DEF_STR( Demo_Sounds ) ) \
703 	PORT_DIPSETTING(    0x60, "Loud" ) \
704 	PORT_DIPSETTING(    0x20, "Medium" ) \
705 	PORT_DIPSETTING(    0x40, "Low" ) \
706 	PORT_DIPSETTING(    0x00, "Silent" ) \
707 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 2-4 */ \
708 	PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Difficulty ) ) \
709 	PORT_DIPSETTING(    0x0a, "Level 0" ) \
710 	PORT_DIPSETTING(    0x0e, "Level 1" ) \
711 	PORT_DIPSETTING(    0x0d, "Level 2" ) \
712 	PORT_DIPSETTING(    0x0c, "Level 3" ) \
713 	PORT_DIPSETTING(    0x0b, "Level 4" ) \
714 	PORT_DIPSETTING(    0x0f, "Level 5" ) \
715 	PORT_DIPSETTING(    0x09, "Level 6" ) \
716 	PORT_DIPSETTING(    0x08, "Level 7" ) \
717 	PORT_DIPSETTING(    0x07, "Level 8" ) \
718 	PORT_DIPSETTING(    0x06, "Level 9" ) \
719 	PORT_DIPSETTING(    0x05, "Level 10" ) \
720 	PORT_DIPSETTING(    0x04, "Level 11" ) \
721 	PORT_DIPSETTING(    0x03, "Level 12" ) \
722 	PORT_DIPSETTING(    0x02, "Level 13" ) \
723 	PORT_DIPSETTING(    0x01, "Level 14" ) \
724 	PORT_DIPSETTING(    0x00, "Level 15" )
725 
726 #define BMCOMPMX_DSW2 \
727 	PORT_START      /* IN 4 */ \
728 	PORT_DIPNAME( 0x80, 0x80, "Score Display" ) \
729 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) ) \
730 	PORT_DIPSETTING(    0x80, DEF_STR( On ) ) \
731 	PORT_DIPNAME( 0x60, 0x60, DEF_STR( Demo_Sounds ) ) \
732 	PORT_DIPSETTING(    0x60, "Loud" ) \
733 	PORT_DIPSETTING(    0x20, "Medium" ) \
734 	PORT_DIPSETTING(    0x40, "Low" ) \
735 	PORT_DIPSETTING(    0x00, "Silent" ) \
736 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )		/* DSW 2-4 */ \
737 	PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Difficulty ) ) \
738 	PORT_DIPSETTING(    0x0a, "Level 0" ) \
739 	PORT_DIPSETTING(    0x0e, "Level 1" ) \
740 	PORT_DIPSETTING(    0x0d, "Level 2" ) \
741 	PORT_DIPSETTING(    0x0c, "Level 3" ) \
742 	PORT_DIPSETTING(    0x0b, "Level 4" ) \
743 	PORT_DIPSETTING(    0x0f, "Level 5" ) \
744 	PORT_DIPSETTING(    0x09, "Level 6" ) \
745 	PORT_DIPSETTING(    0x08, "Level 7" ) \
746 	PORT_DIPSETTING(    0x07, "Level 8" ) \
747 	PORT_DIPSETTING(    0x06, "Level 9" ) \
748 	PORT_DIPSETTING(    0x05, "Level 10" ) \
749 	PORT_DIPSETTING(    0x04, "Level 11" ) \
750 	PORT_DIPSETTING(    0x03, "Level 12" ) \
751 	PORT_DIPSETTING(    0x02, "Level 13" ) \
752 	PORT_DIPSETTING(    0x01, "Level 14" ) \
753 	PORT_DIPSETTING(    0x00, "Level 15" )
754 
755 #define BEATMANIA_DSW3 \
756 	PORT_START      /* IN 5 */ \
757 	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
758 	PORT_DIPNAME( 0x20, 0x20, "Event Mode" ) \
759 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) ) \
760 	PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
761 	PORT_DIPNAME( 0x1c, 0x1c, "Normal Mode Stages" ) \
762 	PORT_DIPSETTING(    0x10, "3" ) \
763 	PORT_DIPSETTING(    0x1c, "4" ) \
764 	PORT_DIPSETTING(    0x08, "5" ) \
765 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-5 */ \
766 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-6 */
767 
768 #define BM1STMIX_DSW3 \
769 	PORT_START      /* IN 5 */ \
770 	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
771 	PORT_DIPNAME( 0x20, 0x20, "Event Mode" ) \
772 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) ) \
773 	PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
774 	PORT_DIPNAME( 0x1c, 0x14, "Normal Mode Stages" ) \
775 	PORT_DIPSETTING(    0x10, "3" ) \
776 	PORT_DIPSETTING(    0x14, "4" ) \
777 	PORT_DIPSETTING(    0x00, "5" ) \
778 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-5 */ \
779 	PORT_DIPNAME( 0x01, 0x01, "Free Hidden Songs" )		/* DSW 3-6 */ \
780 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) ) \
781 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
782 
783 #define BMCOMPMX_DSW3 \
784 	PORT_START      /* IN 5 */ \
785 	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
786 	PORT_DIPNAME( 0x20, 0x20, "Event Mode" ) \
787 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) ) \
788 	PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
789 	PORT_DIPNAME( 0x1c, 0x1c, "Normal Mode Stages" ) \
790 	PORT_DIPSETTING(    0x10, "3" ) \
791 	PORT_DIPSETTING(    0x1c, "4" ) \
792 	PORT_DIPSETTING(    0x08, "5" ) \
793 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-5 */ \
794 	PORT_DIPNAME( 0x01, 0x01, "Secret Expert Course" )	/* DSW 3-6 */ \
795 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) ) \
796 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
797 
798 #define BM4THMIX_DSW3 \
799 	PORT_START      /* IN 5 */ \
800 	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
801 	PORT_DIPNAME( 0x20, 0x20, "Event Mode" ) \
802 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) ) \
803 	PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
804 	PORT_DIPNAME( 0x1c, 0x1c, "Normal Mode Stages" ) \
805 	PORT_DIPSETTING(    0x10, "3" ) \
806 	PORT_DIPSETTING(    0x1c, "4" ) \
807 	PORT_DIPSETTING(    0x08, "5" ) \
808 	PORT_DIPNAME( 0x02, 0x02, "Secret Expert Course" )	/* DSW 3-5 */ \
809 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) ) \
810 	PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
811 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-6 */
812 
813 #define HMCOMPM2_DSW3 \
814 	PORT_START      /* IN 5 */ \
815 	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
816 	PORT_DIPNAME( 0x20, 0x20, "Event Mode" ) \
817 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) ) \
818 	PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
819 	PORT_DIPNAME( 0x1c, 0x1c, "Normal Mode Stages" ) \
820 	PORT_DIPSETTING(    0x10, "3" ) \
821 	PORT_DIPSETTING(    0x1c, "4" ) \
822 	PORT_DIPSETTING(    0x08, "5" ) \
823 	PORT_DIPNAME( 0x02, 0x02, "Game Over Mode" ) \
824 	PORT_DIPSETTING(    0x02, "On Stage Middle" ) \
825 	PORT_DIPSETTING(    0x00, "On Stage Last" ) \
826 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-6 */
827 
828 #define BMDCT_DSW3 \
829 	PORT_START      /* IN 5 */ \
830 	PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
831 	PORT_DIPNAME( 0x20, 0x20, "Event Mode" ) \
832 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) ) \
833 	PORT_DIPSETTING(    0x00, DEF_STR( On ) ) \
834 	PORT_DIPNAME( 0x1c, 0x1c, "Normal / Event Mode Stages" ) \
835 	PORT_DIPSETTING(    0x0c, "3 / 1" ) \
836 	PORT_DIPSETTING(    0x14, "3 / 2" ) \
837 	PORT_DIPSETTING(    0x10, "4 / 3" ) \
838 	PORT_DIPSETTING(    0x1c, "3 / 4" ) \
839 	PORT_DIPSETTING(    0x08, "3 / 5" ) \
840 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-5 */ \
841 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )		/* DSW 3-6 */
842 
843 
844 INPUT_PORTS_START( beatmania )
845 	BEATMANIA_INPUT			/* IN 0-2 */
846 	BEATMANIA_DSW1(0x00, 0xff)	/* IN 3 */
847 	BEATMANIA_DSW2			/* IN 4 */
848 	BEATMANIA_DSW3			/* IN 5 */
849 	BEATMANIA_SCRATCH		/* IN 6 */
850 INPUT_PORTS_END
851 
852 INPUT_PORTS_START( bm1stmix )
853 	BEATMANIA_INPUT			/* IN 0-2 */
854 	BEATMANIA_DSW1(0x00, 0xff)	/* IN 3 */
855 	BEATMANIA_DSW2_OLD_LEVEL	/* IN 4 */
856 	BM1STMIX_DSW3			/* IN 5 */
857 	BEATMANIA_SCRATCH		/* IN 6 */
858 INPUT_PORTS_END
859 
860 INPUT_PORTS_START( bmcompmx )
861 	BEATMANIA_INPUT			/* IN 0-2 */
862 	BEATMANIA_DSW1(0x80, 0x3f)	/* IN 3 */
863 	BMCOMPMX_DSW2			/* IN 4 */
864 	BMCOMPMX_DSW3			/* IN 5 */
865 	BEATMANIA_SCRATCH		/* IN 6 */
866 INPUT_PORTS_END
867 
868 INPUT_PORTS_START( bm4thmix )
869 	BEATMANIA_INPUT			/* IN 0-2 */
870 	BEATMANIA_DSW1(0x40, 0x3f)	/* IN 3 */
871 	BEATMANIA_DSW2			/* IN 4 */
872 	BM4THMIX_DSW3			/* IN 5 */
873 	BEATMANIA_SCRATCH		/* IN 6 */
874 INPUT_PORTS_END
875 
876 INPUT_PORTS_START( hmcompm2 )
877 	BEATMANIA_INPUT			/* IN 0-2 */
878 	BEATMANIA_DSW1(0x00, 0xff)	/* IN 3 */
879 	BEATMANIA_DSW2			/* IN 4 */
880 	HMCOMPM2_DSW3			/* IN 5 */
881 	BEATMANIA_SCRATCH		/* IN 6 */
882 INPUT_PORTS_END
883 
884 INPUT_PORTS_START( bmdct )
885 	BEATMANIA_INPUT			/* IN 0-2 */
886 	BEATMANIA_DSW1(0x00, 0xff)	/* IN 3 */
887 	BEATMANIA_DSW2			/* IN 4 */
888 	BMDCT_DSW3			/* IN 5 */
889 	BEATMANIA_SCRATCH		/* IN 6 */
890 INPUT_PORTS_END
891 
892 
893 
894 /*************************************
895  *
896  *	Graphics layouts
897  *
898  *************************************/
899 
900 static struct GfxLayout spritelayout =
901 {
902 	16, 16,	/* 16x16 characters */
903 	0x200000 / 128,	/* 16384 characters */
904 	4,	/* bit planes */
905 	{ 0, 1, 2, 3 },
906 	{ 4, 0, 12, 8, 20, 16, 28, 24,
907 	  4+256, 0+256, 12+256, 8+256, 20+256, 16+256, 28+256, 24+256 },
908 	{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
909 	  0*32+512, 1*32+512, 2*32+512, 3*32+512, 4*32+512, 5*32+512, 6*32+512, 7*32+512 },
910 	16*16*4
911 };
912 
913 static struct GfxDecodeInfo gfxdecodeinfo[] =
914 {
915 	{ REGION_GFX1, 0, &spritelayout, 0,  (0x4440/4)/16 },
916 	{ -1 } /* end of array */
917 };
918 
919 
920 
921 /*************************************
922  *
923  *	IDE interfaces
924  *
925  *************************************/
926 
927 static struct ide_interface ide_intf =
928 {
929 	ide_interrupt,
930 };
931 
932 
933 
934 /*************************************
935  *
936  *	Sound interfaces
937  *
938  *************************************/
939 
940 static struct K054539interface k054539_interface =
941 {
942 	2,			/* 2 chips */
943 	48000,
944 	{ REGION_SOUND1, REGION_SOUND1 },
945 	{ { 100, 100 }, { 100, 100 } },
946 	{ NULL }
947 };
948 
949 
950 
951 /*************************************
952  *
953  *	Machine-specific init
954  *
955  *************************************/
956 
MACHINE_INIT(djmain)957 static MACHINE_INIT( djmain )
958 {
959 	/* reset sound ram bank */
960 	sndram_bank = 0;
961 	sndram_set_bank();
962 
963 	/* reset the IDE controller */
964 	ide_controller_reset(0);
965 
966 	/* reset LEDs */
967 	set_led_status(0, 1);
968 	set_led_status(1, 1);
969 	set_led_status(2, 1);
970 }
971 
972 
973 
974 /*************************************
975  *
976  *	Machine driver
977  *
978  *************************************/
979 
980 static MACHINE_DRIVER_START( djmain )
981 
982 	/* basic machine hardware */
983 	// popn3 works 9.6 MHz or slower in some songs */
984 	//MDRV_CPU_ADD(M68EC020, 18432000/2)	/*  9.216 MHz!? */
985 	MDRV_CPU_ADD(M68EC020, 32000000/4)	/*  8.000 MHz!? */
MDRV_CPU_MEMORY(readmem,writemem)986 	MDRV_CPU_MEMORY(readmem,writemem)
987 	MDRV_CPU_VBLANK_INT(vb_interrupt, 1)
988 
989 	MDRV_FRAMES_PER_SECOND(58)
990 	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)
991 
992 	MDRV_MACHINE_INIT(djmain)
993 
994 	/* video hardware */
995 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_NEEDS_6BITS_PER_GUN | VIDEO_RGB_DIRECT)
996 	MDRV_SCREEN_SIZE(64*8, 64*8)
997 	MDRV_VISIBLE_AREA(12, 512-12-1, 0, 384-1)
998 	MDRV_PALETTE_LENGTH(0x4440/4)
999 	MDRV_GFXDECODE(gfxdecodeinfo)
1000 	MDRV_VIDEO_START(djmain)
1001 	MDRV_VIDEO_UPDATE(djmain)
1002 
1003 	/* sound hardware */
1004 	MDRV_SOUND_ATTRIBUTES(SOUND_SUPPORTS_STEREO)
1005 	MDRV_SOUND_ADD(K054539, k054539_interface)
1006 MACHINE_DRIVER_END
1007 
1008 
1009 
1010 /*************************************
1011  *
1012  *	ROM definitions
1013  *
1014  *************************************/
1015 
1016 ROM_START( bm1stmix )
1017 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1018 	ROM_LOAD16_BYTE( "753jab01.6a", 0x000000, 0x80000, CRC(25BF8629) SHA1(2be73f9dd25cae415c6443f221cc7d38d5555ae5) )
1019 	ROM_LOAD16_BYTE( "753jab02.8a", 0x000001, 0x80000, CRC(6AB951DE) SHA1(a724ede03b74e9422c120fcc263e2ebcc3a3e110) )
1020 
1021 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1022 	ROM_LOAD16_BYTE( "753jaa03.19a", 0x000000, 0x80000, CRC(F2B2BCE8) SHA1(61d31b111f35e7dde89965fa43ba627c12aff11c) )
1023 	ROM_LOAD16_BYTE( "753jaa04.20a", 0x000001, 0x80000, CRC(85A18F9D) SHA1(ecd0ab4f53e882b00176dacad5fac35345fbea66) )
1024 	ROM_LOAD16_BYTE( "753jaa05.22a", 0x100000, 0x80000, CRC(749B1E87) SHA1(1c771c19f152ae95171e4fd51da561ba4ec5ea87) )
1025 	ROM_LOAD16_BYTE( "753jaa06.24a", 0x100001, 0x80000, CRC(6D86B0FD) SHA1(74a255dbb1c83131717ea1fe335f12aef81d9fcc) )
1026 
1027 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1028 	ROM_LOAD16_BYTE( "753jaa07.22d", 0x000000, 0x80000, CRC(F03AB5D8) SHA1(2ad902547908208714855aa0f2b7ed493452ee5f) )
1029 	ROM_LOAD16_BYTE( "753jaa08.23d", 0x000001, 0x80000, CRC(6559F0C8) SHA1(0d6ec4bdc22c02cb9fb8de36b0a8f7a6c983440e) )
1030 	ROM_LOAD16_BYTE( "753jaa09.25d", 0x100000, 0x80000, CRC(B50C3DBB) SHA1(6022ea249aad0793b2279699e68087b4bc9b4ef1) )
1031 	ROM_LOAD16_BYTE( "753jaa10.27d", 0x100001, 0x80000, CRC(391F4BFD) SHA1(791c9889ea3ce639bbfb87934a1cad9aa3c9ccde) )
1032 
1033 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1034 	// There is an alternate image: MD5(260c9b72f4a03055e3abad61c6225324)
1035 	DISK_IMAGE( "753jaa11.chd", 0, MD5(d56ec7b9877d1f26d7fc1cabed404947) SHA1(71d200d1bd3f1f3a01f4daa78dc9abcca8b8a1fb) )	/* ver 1.00 JA */
1036 ROM_END
1037 
1038 ROM_START( bm2ndmix )
1039 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1040 	ROM_LOAD16_BYTE( "853jab01.6a", 0x000000, 0x80000, CRC(C8DF72C0) SHA1(6793b587ba0611bc3da8c4955d6a87e47a19a223) )
1041 	ROM_LOAD16_BYTE( "853jab02.8a", 0x000001, 0x80000, CRC(BF6ACE08) SHA1(29d3fdf1c73a73a0a66fa5a4c4ac3f293cb82e37) )
1042 
1043 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1044 	ROM_LOAD16_BYTE( "853jaa03.19a", 0x000000, 0x80000, CRC(1462ED23) SHA1(fdfda3060c8d367ac2e8e43dedaba8ab9012cc77) )
1045 	ROM_LOAD16_BYTE( "853jaa04.20a", 0x000001, 0x80000, CRC(98C9B331) SHA1(51f24b3c3773c53ff492ed9bad17c9867fd94e28) )
1046 	ROM_LOAD16_BYTE( "853jaa05.22a", 0x100000, 0x80000, CRC(0DA3FEF9) SHA1(f9ef24144c00c054ecc4650bb79e74c57c6d6b3c) )
1047 	ROM_LOAD16_BYTE( "853jaa06.24a", 0x100001, 0x80000, CRC(6A66978C) SHA1(460178a6f35e554a157742d77ed5ea6989fbcee1) )
1048 
1049 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1050 	ROM_LOAD16_BYTE( "853jaa07.22d", 0x000000, 0x80000, CRC(728C0010) SHA1(18888b402e0b7ccf63c7b3cb644673df1746dba7) )
1051 	ROM_LOAD16_BYTE( "853jaa08.23d", 0x000001, 0x80000, CRC(926FC37C) SHA1(f251cba56ca201f0e748112462116cff218b66da) )
1052 	ROM_LOAD16_BYTE( "853jaa09.25d", 0x100000, 0x80000, CRC(8584E21E) SHA1(3d1ca6de00f9ac07bbe7cd1e67093cca7bf484bb) )
1053 	ROM_LOAD16_BYTE( "853jaa10.27d", 0x100001, 0x80000, CRC(9CB92D98) SHA1(6ace4492ba0b5a8f94a9e7b4f7126b31c6254637) )
1054 
1055 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1056 	DISK_IMAGE( "853jaa11.chd", 0, MD5(37281741b748bea7dfa711a956649d1e) SHA1(03d6cc5aea5920163fbaba34c4f838ca605a87e3) )	/* ver 1.00 JA */
1057 ROM_END
1058 
1059 ROM_START( bm2ndmxa )
1060 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1061 	ROM_LOAD16_BYTE( "853jaa01.6a", 0x000000, 0x80000, CRC(4F0BF5D0) SHA1(4793bb411e85f2191eb703a170c16cf163ea79e7) )
1062 	ROM_LOAD16_BYTE( "853jaa02.8a", 0x000001, 0x80000, CRC(E323925B) SHA1(1f9f52a7ab6359b617e87f8b3d7ac4269885c621) )
1063 
1064 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1065 	ROM_LOAD16_BYTE( "853jaa03.19a", 0x000000, 0x80000, CRC(1462ED23) SHA1(fdfda3060c8d367ac2e8e43dedaba8ab9012cc77) )
1066 	ROM_LOAD16_BYTE( "853jaa04.20a", 0x000001, 0x80000, CRC(98C9B331) SHA1(51f24b3c3773c53ff492ed9bad17c9867fd94e28) )
1067 	ROM_LOAD16_BYTE( "853jaa05.22a", 0x100000, 0x80000, CRC(0DA3FEF9) SHA1(f9ef24144c00c054ecc4650bb79e74c57c6d6b3c) )
1068 	ROM_LOAD16_BYTE( "853jaa06.24a", 0x100001, 0x80000, CRC(6A66978C) SHA1(460178a6f35e554a157742d77ed5ea6989fbcee1) )
1069 
1070 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1071 	ROM_LOAD16_BYTE( "853jaa07.22d", 0x000000, 0x80000, CRC(728C0010) SHA1(18888b402e0b7ccf63c7b3cb644673df1746dba7) )
1072 	ROM_LOAD16_BYTE( "853jaa08.23d", 0x000001, 0x80000, CRC(926FC37C) SHA1(f251cba56ca201f0e748112462116cff218b66da) )
1073 	ROM_LOAD16_BYTE( "853jaa09.25d", 0x100000, 0x80000, CRC(8584E21E) SHA1(3d1ca6de00f9ac07bbe7cd1e67093cca7bf484bb) )
1074 	ROM_LOAD16_BYTE( "853jaa10.27d", 0x100001, 0x80000, CRC(9CB92D98) SHA1(6ace4492ba0b5a8f94a9e7b4f7126b31c6254637) )
1075 
1076 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1077 	DISK_IMAGE( "853jaa11.chd", 0, MD5(37281741b748bea7dfa711a956649d1e) SHA1(03d6cc5aea5920163fbaba34c4f838ca605a87e3) )	/* ver 1.00 JA */
1078 ROM_END
1079 
1080 ROM_START( bmcompmx )
1081 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1082 	ROM_LOAD16_BYTE( "858jab01.6a", 0x000000, 0x80000, CRC(92841EB5) SHA1(3a9d90a9c4b16cb7118aed2cadd3ab32919efa96) )
1083 	ROM_LOAD16_BYTE( "858jab02.8a", 0x000001, 0x80000, CRC(7B19969C) SHA1(3545acabbf53bacc5afa72a3c5af3cd648bc2ae1) )
1084 
1085 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1086 	ROM_LOAD16_BYTE( "858jaa03.19a", 0x000000, 0x80000, CRC(8559F457) SHA1(133092994087864a6c29e9d51dcdbef2e2c2a123) )
1087 	ROM_LOAD16_BYTE( "858jaa04.20a", 0x000001, 0x80000, CRC(770824D3) SHA1(5c21bc39f8128957d76be85bc178c96976987f5f) )
1088 	ROM_LOAD16_BYTE( "858jaa05.22a", 0x100000, 0x80000, CRC(9CE769DA) SHA1(1fe2999f786effdd5e3e74475e8431393eb9403d) )
1089 	ROM_LOAD16_BYTE( "858jaa06.24a", 0x100001, 0x80000, CRC(0CDE6584) SHA1(fb58d2b4f58144b71703431740c0381bb583f581) )
1090 
1091 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1092 	ROM_LOAD16_BYTE( "858jaa07.22d", 0x000000, 0x80000, CRC(7D183F46) SHA1(7a1b0ccb0407b787af709bdf038d886727199e4e) )
1093 	ROM_LOAD16_BYTE( "858jaa08.23d", 0x000001, 0x80000, CRC(C731DC8F) SHA1(1a937d76c02711b7f73743c9999456d4408ad284) )
1094 	ROM_LOAD16_BYTE( "858jaa09.25d", 0x100000, 0x80000, CRC(0B4AD843) SHA1(c01e15053dd1975dc68db9f4e6da47062d8f9b54) )
1095 	ROM_LOAD16_BYTE( "858jaa10.27d", 0x100001, 0x80000, CRC(00B124EE) SHA1(435d28a327c2707833a8ddfe841104df65ffa3f8) )
1096 
1097 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1098 	DISK_IMAGE( "858jaa11.chd", 0, MD5(e7b26f6f03f807a32b2e5e291324d582) SHA1(86f8bb393d3db3c3f492f007a5b4eaec58dfca09) )	/* ver 1.00 JA */
1099 ROM_END
1100 
1101 ROM_START( hmcompmx )
1102 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1103 	ROM_LOAD16_BYTE( "858uab01.6a", 0x000000, 0x80000, CRC(F9C16675) SHA1(f2b50a3544f43af6fd987256a8bd4125b95749ef) )
1104 	ROM_LOAD16_BYTE( "858uab02.8a", 0x000001, 0x80000, CRC(4E8F1E78) SHA1(88d654de4377b584ff8a5e1f8bc81ffb293ec8a5) )
1105 
1106 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1107 	ROM_LOAD16_BYTE( "858uaa03.19a", 0x000000, 0x80000, CRC(52B51A5E) SHA1(9f01e2fcbe5a9d7f80b377c5e10f18da2c9dcc8e) )
1108 	ROM_LOAD16_BYTE( "858uaa04.20a", 0x000001, 0x80000, CRC(A336CEE9) SHA1(0e62c0c38d86868c909b4c1790fbb7ecb2de137d) )
1109 	ROM_LOAD16_BYTE( "858uaa05.22a", 0x100000, 0x80000, CRC(2E14CF83) SHA1(799b2162f7b11678d1d260f7e1eb841abda55a60) )
1110 	ROM_LOAD16_BYTE( "858uaa06.24a", 0x100001, 0x80000, CRC(2BE07788) SHA1(5cc2408f907ca6156efdcbb2c10a30e9b81797f8) )
1111 
1112 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1113 	ROM_LOAD16_BYTE( "858uaa07.22d", 0x000000, 0x80000, CRC(9D7C8EA0) SHA1(5ef773ade7ab12a5dc10484e8b7711c9d76fe2a1) )
1114 	ROM_LOAD16_BYTE( "858uaa08.23d", 0x000001, 0x80000, CRC(F21C3F45) SHA1(1d7ff2c4161605b382d07900142093192aa93a48) )
1115 	ROM_LOAD16_BYTE( "858uaa09.25d", 0x100000, 0x80000, CRC(99519886) SHA1(664f6bd953201a6e2fc123cb8b3facf72766107d) )
1116 	ROM_LOAD16_BYTE( "858uaa10.27d", 0x100001, 0x80000, CRC(20AA7145) SHA1(eeff87eb9a9864985d751f45e843ee6e73db8cfd) )
1117 
1118 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1119 	DISK_IMAGE( "858jaa11.chd", 0, MD5(e7b26f6f03f807a32b2e5e291324d582) SHA1(86f8bb393d3db3c3f492f007a5b4eaec58dfca09) )	/* ver 1.00 JA */
1120 ROM_END
1121 
1122 ROM_START( bm4thmix )
1123 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1124 	ROM_LOAD16_BYTE( "847jaa01.6a", 0x000000, 0x80000, CRC(81138A1B) SHA1(ebe211126f871e541881e1670f56d50b058dead3) )
1125 	ROM_LOAD16_BYTE( "847jaa02.8a", 0x000001, 0x80000, CRC(4EEB0010) SHA1(942303dfb19a4a78dd74ad24576031760553a661) )
1126 
1127 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1128 	ROM_LOAD16_BYTE( "847jaa03.19a", 0x000000, 0x80000, CRC(F447D140) SHA1(cc15b80419940d127a77765508f877421ed86ee2) )
1129 	ROM_LOAD16_BYTE( "847jaa04.20a", 0x000001, 0x80000, CRC(EDC3E286) SHA1(341b1dc6ee1562b1ddf235a66ac96b94c482b67c) )
1130 	ROM_LOAD16_BYTE( "847jaa05.22a", 0x100000, 0x80000, CRC(DA165B5E) SHA1(e46110590e6ab89b55f6abfbf6c53c99d28a75a9) )
1131 	ROM_LOAD16_BYTE( "847jaa06.24a", 0x100001, 0x80000, CRC(8BFC2F28) SHA1(f8869867945d63d9f34b6228d95c5a61b193eed2) )
1132 
1133 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1134 	ROM_LOAD16_BYTE( "847jab07.22d", 0x000000, 0x80000, CRC(C159E7C4) SHA1(96af0c29b2f1fef494b2223179862d16f26bb33f) )
1135 	ROM_LOAD16_BYTE( "847jab08.23d", 0x000001, 0x80000, CRC(8FF084D6) SHA1(50cff8c701e33f2630925c1a9ae4351076912acd) )
1136 	ROM_LOAD16_BYTE( "847jab09.25d", 0x100000, 0x80000, CRC(2E4AC9FE) SHA1(bbd4c6e0c82fc0be88f851e901e5853b6bcf775f) )
1137 	ROM_LOAD16_BYTE( "847jab10.27d", 0x100001, 0x80000, CRC(C78516F5) SHA1(1adf5805c808dc55de14a9a9b20c3d2cf7bf414d) )
1138 
1139 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1140 	DISK_IMAGE( "847jaa11.chd", 0, MD5(47cb5c1b856aa11cf38f0c7ea4a7d1c3) SHA1(374d5d5340d4a8818577f9ae81021651d6ee3429) )	/* ver 1.00 JA */
1141 ROM_END
1142 
1143 ROM_START( hmcompm2 )
1144 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1145 	ROM_LOAD16_BYTE( "988uaa01.6a", 0x000000, 0x80000, CRC(5E5CC6C0) SHA1(0e7cd601d4543715cbc9f65e6fd48837179c962a) )
1146 	ROM_LOAD16_BYTE( "988uaa02.8a", 0x000001, 0x80000, CRC(E262984A) SHA1(f47662e40f91f2addb1a4b649923c1d0ee017341) )
1147 
1148 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1149 	ROM_LOAD16_BYTE( "988uaa03.19a", 0x000000, 0x80000, CRC(D0F204C8) SHA1(866baac5a6d301d5b9cf0c14e9937ee5f435db77) )
1150 	ROM_LOAD16_BYTE( "988uaa04.20a", 0x000001, 0x80000, CRC(74C6B3ED) SHA1(7d9b064bab3f29fc6435f6430c71208abbf9d861) )
1151 	ROM_LOAD16_BYTE( "988uaa05.22a", 0x100000, 0x80000, CRC(6B9321CB) SHA1(449e5f85288a8c6724658050fa9521c7454a1e46) )
1152 	ROM_LOAD16_BYTE( "988uaa06.24a", 0x100001, 0x80000, CRC(DA6E0C1E) SHA1(4ef37db6c872bccff8c27fc53cccc0b269c7aee4) )
1153 
1154 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1155 	ROM_LOAD16_BYTE( "988uaa07.22d", 0x000000, 0x80000, CRC(9217870D) SHA1(d0536a8a929c41b49cdd053205165bfb8150e0c5) )
1156 	ROM_LOAD16_BYTE( "988uaa08.23d", 0x000001, 0x80000, CRC(77777E59) SHA1(33b5508b961a04b82c9967a3326af6bbd838b85e) )
1157 	ROM_LOAD16_BYTE( "988uaa09.25d", 0x100000, 0x80000, CRC(C2AD6810) SHA1(706388c5acf6718297fd90e10f8a673463a0893b) )
1158 	ROM_LOAD16_BYTE( "988uaa10.27d", 0x100001, 0x80000, CRC(DAB0F3C9) SHA1(6fd899e753e32f60262c54ab8553c686c7ef28de) )
1159 
1160 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1161 	DISK_IMAGE( "988jaa11.chd", 0, MD5(cc21d58d6bee58f1c4baf08f345fe2c5) SHA1(9ccc04973b035d20dada83842c8ee5387472870e) )	/* ver 1.00 JA */
1162 ROM_END
1163 
1164 ROM_START( bmdct )
1165 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1166 	ROM_LOAD16_BYTE( "995jaa01.6a", 0x000000, 0x80000, CRC(2C224169) SHA1(0608469fa0a15026f461be5141ed29bf740144ca) )
1167 	ROM_LOAD16_BYTE( "995jaa02.8a", 0x000001, 0x80000, CRC(A2EDB472) SHA1(795e44e56dfee6c5eceb28172bc20ba5b31c366b) )
1168 
1169 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1170 	ROM_LOAD16_BYTE( "995jaa03.19a", 0x000000, 0x80000, CRC(77A7030C) SHA1(8f7988ca5c248d0846ec22c0975ae008d85e8d72) )
1171 	ROM_LOAD16_BYTE( "995jaa04.20a", 0x000001, 0x80000, CRC(A12EA45D) SHA1(9bd48bc25c17f885d74e859de153ec49012a4e39) )
1172 	ROM_LOAD16_BYTE( "995jaa05.22a", 0x100000, 0x80000, CRC(1493FD98) SHA1(4cae2ebccc79b21d7e21b984dc6fe10ab3013a2d) )
1173 	ROM_LOAD16_BYTE( "995jaa06.24a", 0x100001, 0x80000, CRC(86BFF0BB) SHA1(658280f78987eaee31b60a7826db6df105601f0a) )
1174 
1175 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1176 	ROM_LOAD16_BYTE( "995jaa07.22d", 0x000000, 0x80000, CRC(CE030EDF) SHA1(1e2594a6a04559d70b09750bb665d8cd3d0288ea) )
1177 	ROM_LOAD16_BYTE( "995jaa08.23d", 0x000001, 0x80000, CRC(375D3D17) SHA1(180cb5ad4497b3745aa9317764f237b30a678b31) )
1178 	ROM_LOAD16_BYTE( "995jaa09.25d", 0x100000, 0x80000, CRC(1510A9C2) SHA1(daf1ab26b7b6b0fe0123b3fbee68684157c2ce51) )
1179 	ROM_LOAD16_BYTE( "995jaa10.27d", 0x100001, 0x80000, CRC(F9E4E9F2) SHA1(fe91badf6b0baeea690d75399d8c66fabcf6d352) )
1180 
1181 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1182 	DISK_IMAGE( "995jaa11.chd", 0, MD5(8f5936d2b0b0914b5c88f5432c6cac21) SHA1(deed0fca533f3e56e04f9967f3f76145ca106f06) )	/* ver 1.00 JA */
1183 ROM_END
1184 
1185 ROM_START( bmcorerm )
1186 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* MC68EC020FG25 MPU */
1187 	ROM_LOAD16_BYTE( "a05jaa01.6a", 0x000000, 0x80000, CRC(CD6F1FC5) SHA1(237cbc17a693efb6bffffd6afb24f0944c29330c) )
1188 	ROM_LOAD16_BYTE( "a05jaa02.8a", 0x000001, 0x80000, CRC(FE07785E) SHA1(14c652008cb509b5206fb515aad7dfe36a6fe6f4) )
1189 
1190 	ROM_REGION( 0x200000, REGION_GFX1, 0)		/* SPRITE */
1191 	ROM_LOAD16_BYTE( "a05jaa03.19a", 0x000000, 0x80000, CRC(8B88932A) SHA1(df20f8323adb02d07b835da98f4a29b3142175c9) )
1192 	ROM_LOAD16_BYTE( "a05jaa04.20a", 0x000001, 0x80000, CRC(CC72629F) SHA1(f95d06f409c7d6422d66a55c0452eb3feafc6ef0) )
1193 	ROM_LOAD16_BYTE( "a05jaa05.22a", 0x100000, 0x80000, CRC(E241B22B) SHA1(941a76f6ac821e0984057ec7df7862b12fa657b8) )
1194 	ROM_LOAD16_BYTE( "a05jaa06.24a", 0x100001, 0x80000, CRC(77EB08A3) SHA1(fd339aaec06916abfc928e850e33480707b5450d) )
1195 
1196 	ROM_REGION( 0x200000, REGION_GFX2, 0 )		/* TILEMAP */
1197 	ROM_LOAD16_BYTE( "a05jaa07.22d", 0x000000, 0x80000, CRC(4D79646D) SHA1(5f1237bbd3cb09b27babf1c5359ef6c0d80ae3a9) )
1198 	ROM_LOAD16_BYTE( "a05jaa08.23d", 0x000001, 0x80000, CRC(F067494F) SHA1(ef031b5501556c1aa047a51604a44551b35a8b99) )
1199 	ROM_LOAD16_BYTE( "a05jaa09.25d", 0x100000, 0x80000, CRC(1504D62C) SHA1(3c31c6625bc089235a96fe21021239f2d0c0f6e1) )
1200 	ROM_LOAD16_BYTE( "a05jaa10.27d", 0x100001, 0x80000, CRC(99D75C36) SHA1(9599420863aa0a9492d3caeb03f8ac5fd4c3cdb2) )
1201 
1202 	DISK_REGION( REGION_DISKS )			/* IDE HARD DRIVE */
1203 	DISK_IMAGE( "a05jaa11.chd", 0, MD5(180f7b1b2145fab2d2ba717780f2ca26) SHA1(1a45e99667c158517d8edcd66453cd56631b5f6a) )	/* ver 1.00 JA */
1204 ROM_END
1205 
1206 
1207 
1208 /*************************************
1209  *
1210  *	Driver-specific init
1211  *
1212  *************************************/
1213 
1214 static void init_djmain_common(void)
1215 {
1216 	if (new_memory_region(REGION_SOUND1, 0x80000 * 32, 0))
1217 		return;
1218 
1219 	/* spin up the hard disk */
1220 	ide_controller_init(0, &ide_intf);
1221 
1222 	state_save_register_int   ("djmain", 0, "sndram_bank",    &sndram_bank);
1223 	state_save_register_UINT8 ("djmain", 0, "sndram",         memory_region(REGION_SOUND1), 0x80000 * 32);
1224 	state_save_register_int   ("djmain", 0, "pending_vb_int", &pending_vb_int);
1225 	state_save_register_UINT16("djmain", 0, "v_ctrl",         &v_ctrl,  1);
1226 	state_save_register_UINT32("djmain", 0, "obj_regs",       obj_regs, sizeof (obj_regs) / sizeof (UINT32));
1227 
1228 	state_save_register_func_postload(sndram_set_bank);
1229 }
1230 
DRIVER_INIT(beatmania)1231 static DRIVER_INIT( beatmania )
1232 {
1233 	init_djmain_common();
1234 
1235 	game_type = BEATMANIA;
1236 }
1237 
1238 static UINT8 beatmania_master_password[2 + 32] =
1239 {
1240 	0x01, 0x00,
1241 	0x4d, 0x47, 0x43, 0x28, 0x4b, 0x29, 0x4e, 0x4f,
1242 	0x4d, 0x41, 0x20, 0x49, 0x4c, 0x41, 0x20, 0x4c,
1243 	0x49, 0x52, 0x48, 0x47, 0x53, 0x54, 0x52, 0x20,
1244 	0x53, 0x45, 0x52, 0x45, 0x45, 0x56, 0x2e, 0x44
1245 };
1246 
DRIVER_INIT(hmcompmx)1247 static DRIVER_INIT( hmcompmx )
1248 {
1249 	static UINT8 hmcompmx_user_password[2 + 32] =
1250 	{
1251 		0x00, 0x00,
1252 		0x44, 0x42, 0x56, 0x4b, 0x3a, 0x34, 0x38, 0x2a,
1253 		0x5a, 0x4d, 0x78, 0x3e, 0x74, 0x61, 0x6c, 0x0a,
1254 		0x7a, 0x63, 0x19, 0x77, 0x73, 0x7d, 0x0d, 0x12,
1255 		0x6b, 0x09, 0x02, 0x0f, 0x05, 0x00, 0x7d, 0x1b
1256 	};
1257 
1258 	init_beatmania();
1259 
1260 	ide_set_master_password(0, beatmania_master_password);
1261 	ide_set_user_password(0, hmcompmx_user_password);
1262 }
1263 
DRIVER_INIT(bm4thmix)1264 static DRIVER_INIT( bm4thmix )
1265 {
1266 	static UINT8 bm4thmix_user_password[2 + 32] =
1267 	{
1268 		0x00, 0x00,
1269 		0x44, 0x42, 0x29, 0x4b, 0x2f, 0x2c, 0x4c, 0x32,
1270 		0x48, 0x5d, 0x0c, 0x3e, 0x62, 0x6f, 0x7e, 0x73,
1271 		0x67, 0x10, 0x19, 0x79, 0x6c, 0x7d, 0x00, 0x01,
1272 		0x18, 0x06, 0x1e, 0x07, 0x77, 0x1a, 0x7d, 0x77
1273 	};
1274 
1275 	init_beatmania();
1276 
1277 	ide_set_user_password(0, bm4thmix_user_password);
1278 }
1279 
DRIVER_INIT(hmcompm2)1280 static DRIVER_INIT( hmcompm2 )
1281 {
1282 	static UINT8 hmcompm2_user_password[2 + 32] =
1283 	{
1284 		0x00, 0x00,
1285 		0x3b, 0x39, 0x24, 0x3e, 0x4e, 0x59, 0x5c, 0x32,
1286 		0x3b, 0x4c, 0x72, 0x57, 0x69, 0x04, 0x79, 0x65,
1287 		0x76, 0x10, 0x6a, 0x77, 0x1f, 0x65, 0x0a, 0x16,
1288 		0x09, 0x68, 0x71, 0x0b, 0x77, 0x15, 0x17, 0x1e
1289 	};
1290 
1291 	init_beatmania();
1292 
1293 	ide_set_master_password(0, beatmania_master_password);
1294 	ide_set_user_password(0, hmcompm2_user_password);
1295 }
1296 
DRIVER_INIT(bmdct)1297 static DRIVER_INIT( bmdct )
1298 {
1299 	static UINT8 bmdct_user_password[2 + 32] =
1300 	{
1301 		0x00, 0x00,
1302 		0x52, 0x47, 0x30, 0x3f, 0x2f, 0x39, 0x54, 0x5e,
1303 		0x4f, 0x4b, 0x65, 0x3e, 0x07, 0x6e, 0x6c, 0x67,
1304 		0x7d, 0x79, 0x7b, 0x16, 0x6d, 0x73, 0x65, 0x06,
1305 		0x0e, 0x0a, 0x05, 0x0f, 0x13, 0x74, 0x09, 0x19
1306 	};
1307 
1308 	init_beatmania();
1309 
1310 	ide_set_master_password(0, beatmania_master_password);
1311 	ide_set_user_password(0, bmdct_user_password);
1312 }
1313 
DRIVER_INIT(bmcorerm)1314 static DRIVER_INIT( bmcorerm )
1315 {
1316 	static UINT8 bmcorerm_user_password[2 + 32] =
1317 	{
1318 		0x00, 0x00,
1319 		0x44, 0x42, 0x56, 0x4b, 0x3f, 0x4d, 0x4a, 0x27,
1320 		0x5a, 0x52, 0x0c, 0x3e, 0x6a, 0x04, 0x63, 0x6f,
1321 		0x72, 0x64, 0x72, 0x7f, 0x1f, 0x73, 0x17, 0x04,
1322 		0x05, 0x09, 0x14, 0x0d, 0x7a, 0x74, 0x7d, 0x7a
1323 	};
1324 
1325 	init_beatmania();
1326 
1327 	ide_set_master_password(0, beatmania_master_password);
1328 	ide_set_user_password(0, bmcorerm_user_password);
1329 }
1330 
1331 
1332 
1333 /*************************************
1334  *
1335  *	Game drivers
1336  *
1337  *************************************/
1338 
1339 GAME( 1997, bm1stmix, 0,        djmain,   bm1stmix,  beatmania, ROT0, "Konami", "beatmania (ver JA-B)" )
1340 GAME( 1998, bm2ndmix, 0,        djmain,   bm1stmix,  beatmania, ROT0, "Konami", "beatmania 2nd MIX (ver JA-B)" )
1341 GAME( 1998, bm2ndmxa, bm2ndmix, djmain,   bm1stmix,  beatmania, ROT0, "Konami", "beatmania 2nd MIX (ver JA-A)" )
1342 GAME( 1999, bmcompmx, 0,        djmain,   bmcompmx,  beatmania, ROT0, "Konami", "beatmania complete MIX (ver JA-B)" )
1343 GAME( 1999, hmcompmx, bmcompmx, djmain,   bmcompmx,  hmcompmx,  ROT0, "Konami", "hiphopmania complete MIX (ver UA-B)" )
1344 GAME( 1999, bm4thmix, 0,        djmain,   bm4thmix,  bm4thmix,  ROT0, "Konami", "beatmania 4th MIX (ver JA-A)" )
1345 GAME( 2000, hmcompm2, 0,        djmain,   hmcompm2,  hmcompm2,  ROT0, "Konami", "hiphopmania complete MIX 2 (ver UA-A)" )
1346 GAME( 2000, bmdct,    0,        djmain,   bmdct,     bmdct,     ROT0, "Konami", "beatmania f. Dreams Come True (ver JA-A)" )
1347 GAME( 2000, bmcorerm, 0,        djmain,   beatmania, bmcorerm,  ROT0, "Konami", "beatmania CORE REMIX (ver JA-A)" )
1348