1 /****************************************************************************
2 
3 Mazer Blazer by Stern (c) 1983
4 Great Guns by Stern (c) 1983
5 
6 
7 Driver by Jarek Burczynski
8 2003.03.19
9 
10 
11 Issues:
12 ======
13 Sprites leave trails in both ganes
14 Sprites should be transparent (color 0x0f)
15 Screen flickers heavily in Great Guns (double buffer issue?).
16 
17 
18 TO DO:
19 =====
20 - handle page flipping
21 
22 - figure out the VCU modes used in "clr_r":
23   0x13 -? sprites related
24   0x03 -? could be collision detection (if there is such a thing)
25 
26 - figure out how the palette is handled (partially done)
27 
28 - find out if there are any CLUTs (might be the other unknown cases in mode 7)
29 
30 - figure out what really should happen during VCU test in Great Guns (patched
31   out at the moment) (btw. Mazer Blazer doesn't test VCU)
32 
33 - add sound to Mazer Blazer - Speech processor is unknown chip
34 
35 
36 ****************************************************************************/
37 
38 #include "driver.h"
39 #include "vidhrdw/generic.h"
40 
41 static data8_t *cfb_ram;
42 
43 static UINT32 VCU_gfx_addr = 0;
44 static UINT32 VCU_gfx_param_addr = 0;
45 static UINT32 xpos=0, ypos=0, pix_xsize=0, pix_ysize=0;
46 static UINT8 color=0, color2=0, mode=0, plane=0;
47 static UINT8 vbank = 0; /* video page select signal, likely for double buffering ?*/
48 
49 static UINT32 gfx_rom_bank = 0xff;	/* graphics ROMs are banked */
50 
51 
52 
53 
54 #define MAZERBLA 0x01
55 #define GREATGUN 0x02
56 static UINT8 game_id = 0; /* hacks per game */
57 
58 
59 
60 static UINT8 lookup_RAM[0x100*4];
61 
62 
63 
64 #include "vidhrdw/res_net.h"
65 /***************************************************************************
66 
67   Convert the color PROMs into a more useable format.
68 
69 
70   bit 0 -- 10.0Kohm resistor--\
71   bit 1 -- 4.7 Kohm resistor --+-- 3.6 Kohm pulldown resistor -- BLUE
72   bit 2 -- 2.2 Kohm resistor --/
73 
74   bit 3 -- 10.0Kohm resistor--\
75   bit 4 -- 4.7 Kohm resistor --+-- 3.6 Kohm pulldown resistor -- GREEN
76   bit 5 -- 2.2 Kohm resistor --/
77 
78   bit 6 -- 4.7 Kohm resistor --+-- 3.6 Kohm pulldown resistor -- RED
79   bit 7 -- 2.2 Kohm resistor --/
80 
81 ***************************************************************************/
82 
83 static double weights_r[2], weights_g[3], weights_b[3];
84 
PALETTE_INIT(mazerbla)85 static PALETTE_INIT( mazerbla )
86 {
87 
88 	const int resistances_r[2]  = { 4700, 2200 };
89 	const int resistances_gb[3] = { 10000, 4700, 2200 };
90 
91 
92 /* just to calculate coefficients for later use */
93 
94 	compute_resistor_weights(0,	255,	-1.0,
95 			3,	resistances_gb,	weights_g,	3600,	0,
96 			3,	resistances_gb,	weights_b,	3600,	0,
97 			2,	resistances_r,	weights_r,	3600,	0);
98 
99 }
100 
101 
102 static struct mame_bitmap * tmpbitmaps[4];
103 
VIDEO_START(mazerbla)104 VIDEO_START( mazerbla )
105 {
106 	tmpbitmaps[0] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
107 	tmpbitmaps[1] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
108 	tmpbitmaps[2] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
109 	tmpbitmaps[3] = auto_bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height);
110 
111 	if ((tmpbitmaps[0]==0) || (tmpbitmaps[1]==0) || (tmpbitmaps[2]==0) || (tmpbitmaps[3]==0))
112 	{
113 		logerror("too bad - run out of memory in video_start() ");
114 		return 1;
115 	}
116 
117 	return 0;
118 }
119 
120 #if 0
121 static int dbg_info = 1;
122 static int dbg_gfx_e = 1;
123 static int dbg_clr_e = 0;
124 static int dbg_vbank = 1;
125 static int dbg_lookup = 4;	//4= off
126 
127 static int planes_enabled[4] = {1,1,1,1}; //all enabled
128 #endif
129 
130 #if 0
131 VIDEO_UPDATE( test_vcu )
132 {
133 	int j,trueorientation;
134 	char buf[128];
135 
136 	UINT32 color_base=0;
137 
138 	if (game_id==MAZERBLA)
139 		color_base = 0x80;	/* 0x80 constant: matches Mazer Blazer movie */
140 
141 	if (game_id==GREATGUN)
142 		color_base = 0x0;
143 
144 
145 	fillbitmap(bitmap,0,NULL);
146 //logerror("-->frame\n");
147 
148 
149 	if (planes_enabled[3])
150 		copybitmap(bitmap,tmpbitmaps[3],0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE, 0 );
151 
152 
153 	if (planes_enabled[2])
154 		copybitmap(bitmap,tmpbitmaps[2],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[color_base] );
155 	fillbitmap(tmpbitmaps[2],Machine->pens[color_base],NULL);
156 
157 
158 	if (planes_enabled[1])
159 		copybitmap(bitmap,tmpbitmaps[1],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[color_base] );
160 	fillbitmap(tmpbitmaps[1],Machine->pens[color_base],NULL);
161 
162 
163 	if (planes_enabled[0])
164 		copybitmap(bitmap,tmpbitmaps[0],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[color_base] );
165 	fillbitmap(tmpbitmaps[0],Machine->pens[color_base],NULL);
166 
167 	if (keyboard_pressed_memory(KEYCODE_1))	/* plane 1 */
168 	{
169 		planes_enabled[0] ^= 1;
170 	}
171 	if (keyboard_pressed_memory(KEYCODE_2))	/* plane 2 */
172 	{
173 		planes_enabled[1] ^= 1;
174 	}
175 	if (keyboard_pressed_memory(KEYCODE_3))	/* plane 3 */
176 	{
177 		planes_enabled[2] ^= 1;
178 	}
179 	if (keyboard_pressed_memory(KEYCODE_4))	/* plane 4 */
180 	{
181 		planes_enabled[3] ^= 1;
182 	}
183 
184 	if (keyboard_pressed_memory(KEYCODE_I))	/* show/hide debug info */
185 	{
186 		dbg_info = !dbg_info;
187 	}
188 
189 	if (keyboard_pressed_memory(KEYCODE_G))	/* enable gfx area handling */
190 	{
191 		dbg_gfx_e = !dbg_gfx_e;
192 	}
193 
194 	if (keyboard_pressed_memory(KEYCODE_C))	/* enable color area handling */
195 	{
196 		dbg_clr_e = !dbg_clr_e;
197 	}
198 
199 	if (keyboard_pressed_memory(KEYCODE_V))	/* draw only when vbank==dbg_vbank */
200 	{
201 		dbg_vbank ^= 1;
202 	}
203 
204 	if (keyboard_pressed_memory(KEYCODE_L))	/* showlookup ram */
205 	{
206 		dbg_lookup = (dbg_lookup+1)%5;//0,1,2,3, 4-off
207 	}
208 
209 
210 	if (dbg_info)
211 	{
212 		trueorientation = Machine->orientation;
213 		Machine->orientation = ROT0;
214 
215 		sprintf(buf,"I-info, G-gfx, C-color, V-vbank, 1-4 enable planes");
216 		for (j = 0;j < 52;j++)
217 			drawgfx(bitmap,Machine->uifont,buf[j],0,0,0,10+6*j,4,0,TRANSPARENCY_NONE,0);
218 
219 		sprintf(buf,"g:%1i c:%1i v:%1i vbk=%1i  planes=%1i%1i%1i%1i  ", dbg_gfx_e&1, dbg_clr_e&1, dbg_vbank, vbank&1,
220 			planes_enabled[0],
221 			planes_enabled[1],
222 			planes_enabled[2],
223 			planes_enabled[3] );
224 
225 		for (j = 0;j < 32;j++)
226 			drawgfx(bitmap,Machine->uifont,buf[j],0,0,0,10+6*j,16,0,TRANSPARENCY_NONE,0);
227 
228 		if (dbg_lookup!=4)
229 		{
230 			int lookup_offs = (dbg_lookup)*256; //=0,1,2,3*256
231 			int y,x;
232 
233 			for (y=0; y<16; y++)
234 			{
235 				memset(buf,0,128);
236 				sprintf( buf+strlen(buf), "%04x ", lookup_offs+y*16 );
237 				for (x=0; x<16; x++)
238 				{
239 					sprintf( buf+strlen(buf), "%02x ", lookup_RAM[ lookup_offs+x+y*16 ] );
240 				}
241 				for (j = 0;j < 55;j++)
242 					drawgfx(bitmap,Machine->uifont,buf[j],0,0,0,6*j,30+y*8,0,TRANSPARENCY_NONE,0);
243 			}
244 		}
245 
246 		Machine->orientation = trueorientation;
247 	}
248 
249 }
250 #endif
251 
252 
253 /* these two VIDEO_UPDATE()s will be joined one day */
VIDEO_UPDATE(greatgun)254 VIDEO_UPDATE( greatgun )
255 {
256 
257 	UINT32 color_base=0;
258 
259 	if (game_id==MAZERBLA)
260 		color_base = 0x80;	/* 0x80 constant: matches Mazer Blazer movie */
261 
262 	if (game_id==GREATGUN)
263 		color_base = 0x0;
264 
265 //fillbitmap(bitmap,0,NULL);
266 
267 	copybitmap(bitmap,tmpbitmaps[3],0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE, 0 );
268 	copybitmap(bitmap,tmpbitmaps[2],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[color_base] );
269 	copybitmap(bitmap,tmpbitmaps[1],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[color_base] );
270 	copybitmap(bitmap,tmpbitmaps[0],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[color_base] );
271 }
272 
VIDEO_UPDATE(mazerbla)273 VIDEO_UPDATE( mazerbla )
274 {
275 
276 	UINT32 color_base=0;
277 
278 	if (game_id==MAZERBLA)
279 		color_base = 0x80;	/* 0x80 constant: matches Mazer Blazer movie */
280 
281 	if (game_id==GREATGUN)
282 		color_base = 0x0;
283 
284 //fillbitmap(bitmap,0,NULL);
285 
286 	copybitmap(bitmap,tmpbitmaps[3],0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE, 0 ); //text
287 	copybitmap(bitmap,tmpbitmaps[2],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[0] );
288 	copybitmap(bitmap,tmpbitmaps[1],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[0] ); //haircross
289 	copybitmap(bitmap,tmpbitmaps[0],0,0,0,0,&Machine->visible_area,TRANSPARENCY_PEN, Machine->pens[0] ); //sprites
290 }
291 
292 
293 static UINT8 zpu_int_vector;
294 
WRITE_HANDLER(cfb_zpu_int_req_set_w)295 static WRITE_HANDLER( cfb_zpu_int_req_set_w )
296 {
297 	zpu_int_vector &= ~2;	/* clear D1 on INTA (interrupt acknowledge) */
298 
299 	cpu_set_irq_line(0, 0, ASSERT_LINE);	/* main cpu interrupt (comes from CFB (generated at the start of INT routine on CFB) - vblank?) */
300 }
301 
READ_HANDLER(cfb_zpu_int_req_clr)302 static READ_HANDLER( cfb_zpu_int_req_clr )
303 {
304 	zpu_int_vector |= 2;
305 
306 	/* clear the INT line when there are no more interrupt requests */
307 	if (zpu_int_vector==0xff)
308 		cpu_set_irq_line(0, 0, CLEAR_LINE);
309 
310 	return 0;
311 }
312 
313 
irq_callback(int irqline)314 static int irq_callback(int irqline)
315 {
316 /* all data lines are tied to +5V via 10K resistors */
317 /* D1 is set to GND when INT comes from CFB */
318 /* D2 is set to GND when INT comes from ZPU board - from 6850 on schematics (RS232 controller) */
319 
320 /* resulting vectors:
321 1111 11000 (0xf8)
322 1111 11010 (0xfa)
323 1111 11100 (0xfc)
324 
325 note:
326 1111 11110 (0xfe) - cannot happen and is not handled by game */
327 
328 	return (zpu_int_vector & ~1);	/* D0->GND is performed on CFB board */
329 }
330 
331 
332 
333 static data8_t *cfb_zpu_sharedram;
WRITE_HANDLER(sharedram_CFB_ZPU_w)334 static WRITE_HANDLER ( sharedram_CFB_ZPU_w )
335 {
336 	cfb_zpu_sharedram[offset] = data;
337 }
READ_HANDLER(sharedram_CFB_ZPU_r)338 static READ_HANDLER ( sharedram_CFB_ZPU_r )
339 {
340 	return cfb_zpu_sharedram[offset];
341 }
342 
343 
344 
345 static UINT8 ls670_0[4];
346 static UINT8 ls670_1[4];
347 
READ_HANDLER(ls670_0_r)348 static READ_HANDLER( ls670_0_r )
349 {
350 	/* set a timer to force synchronization after the read */
351 	timer_set(TIME_NOW, 0, NULL);
352 
353 	return ls670_0[offset];
354 }
355 
deferred_ls670_0_w(int param)356 static void deferred_ls670_0_w(int param )
357 {
358 	int offset = (param>>8) & 255;
359 	int data = param & 255;
360 
361 	ls670_0[offset] = data;
362 }
363 
WRITE_HANDLER(ls670_0_w)364 static WRITE_HANDLER( ls670_0_w )
365 {
366 	/* do this on a timer to let the CPUs synchronize */
367 	timer_set(TIME_NOW, (offset<<8) | data, deferred_ls670_0_w);
368 }
369 
370 
371 
READ_HANDLER(ls670_1_r)372 static READ_HANDLER( ls670_1_r )
373 {
374 	/* set a timer to force synchronization after the read */
375 	timer_set(TIME_NOW, 0, NULL);
376 
377 	return ls670_1[offset];
378 }
379 
deferred_ls670_1_w(int param)380 static void deferred_ls670_1_w(int param )
381 {
382 	int offset = (param>>8) & 255;
383 	int data = param & 255;
384 
385 	ls670_1[offset] = data;
386 }
387 
WRITE_HANDLER(ls670_1_w)388 static WRITE_HANDLER( ls670_1_w )
389 {
390 	/* do this on a timer to let the CPUs synchronize */
391 	timer_set(TIME_NOW, (offset<<8) | data, deferred_ls670_1_w);
392 }
393 
394 
395 /* bcd decoder used a input select (a mux) for reads from port 0x62 */
396 static UINT8 bcd_7445 = 0;
397 
WRITE_HANDLER(zpu_bcd_decoder_w)398 static WRITE_HANDLER(zpu_bcd_decoder_w)
399 {
400 
401 /*
402 name:			Strobe(bcd_value)	BIT
403 ---------------------------------------
404 ZPU switch 1	0					6
405 ZPU switch 2	0					7
406 
407 dipsw 35		1					7
408 dipsw 34		1					6
409 dipsw 33		1					5
410 dipsw 32		1					4
411 dipsw 31		1					3
412 dipsw 30		1					2
413 dipsw 29		1					1
414 dipsw 28		1					0
415 dipsw 27		2					7
416 dipsw 26		2					6
417 ...
418 dipsw 8			4					4
419 dipsw 7			4					3
420 dipsw 6			4					2
421 dipsw 5			4					1
422 dipsw 4			4					0
423 
424 Right Coin Sw.	5					0
425 Left Coin Sw.	5					1
426 Player One		5					2
427 Player Two		5					3
428 Fire Button		5					4
429 
430 Horizontal movement of gun is Strobe 6, Bits 0-7.
431 	Movement is from 0000 0000 to 1111 1111
432 
433 Vertical movement of gun is Strobe 7, Bits 0-7.
434 	Movement is from 0000 0000 to 1111 1111
435 
436 
437 Great Guns has two guns and here is necessary support for second gun:
438 
439 Horizontal movement of gun is Strobe 8, Bits 0-7.
440 	Movement is from 0000 0000 to 1111 1111
441 
442 Vertical movement of gun is Strobe 9, Bits 0-7.
443 	Movement is from 0000 0000 to 1111 1111
444 
445 */
446 	bcd_7445 = data & 15;
447 }
448 
READ_HANDLER(zpu_inputs_r)449 static READ_HANDLER( zpu_inputs_r )
450 {
451 	UINT8 ret = 0;
452 
453 	if (bcd_7445<10)
454 	{
455 		ret = readinputport( bcd_7445 );
456 	}
457 	return ret;
458 }
459 
460 
461 
462 
463 
WRITE_HANDLER(zpu_led_w)464 static WRITE_HANDLER(zpu_led_w)
465 {
466 	/* 0x6e - reset (offset = 0)*/
467 	/* 0x6f - set */
468 	set_led_status(0, offset&1 );
469 }
WRITE_HANDLER(zpu_lamps_w)470 static WRITE_HANDLER(zpu_lamps_w)
471 {
472 	/* bit 4 = /LAMP0 */
473 	/* bit 5 = /LAMP1 */
474 
475 	/*set_led_status(0, (data&0x10)>>4 );*/
476 	/*set_led_status(1, (data&0x20)>>4 );*/
477 }
478 
WRITE_HANDLER(zpu_coin_counter_w)479 static WRITE_HANDLER(zpu_coin_counter_w)
480 {
481 	/* bit 6 = coin counter */
482 	coin_counter_w(offset, (data&0x40)>>6 );
483 }
484 
PORT_READ_START(readport)485 static PORT_READ_START( readport )
486 	{ 0x4c, 0x4f, ls670_1_r },
487 	{ 0x62, 0x62, zpu_inputs_r },
488 PORT_END
489 
490 static PORT_WRITE_START( writeport )
491 	{ 0x4c, 0x4f, ls670_0_w },
492 	{ 0x60, 0x60, zpu_bcd_decoder_w },
493 	{ 0x68, 0x68, zpu_coin_counter_w },
494 	{ 0x6a, 0x6a, zpu_lamps_w },
495 	{ 0x6e, 0x6f, zpu_led_w },
496 PORT_END
497 
498 static MEMORY_READ_START( readmem )
499 	{ 0x0000, 0x7fff, MRA_ROM },
500 	{ 0xc000, 0xc7ff, sharedram_CFB_ZPU_r },
501 	{ 0xd800, 0xd800, cfb_zpu_int_req_clr },
502 	{ 0xe000, 0xe7ff, MRA_RAM },
503 	{ 0xe800, 0xefff, MRA_RAM },
504 MEMORY_END
505 
506 static MEMORY_WRITE_START( writemem )
507 	{ 0x0000, 0x7fff, MWA_ROM },
508 	{ 0xc000, 0xc7ff, sharedram_CFB_ZPU_w },
509 	{ 0xe000, 0xe7ff, MWA_RAM, &videoram, &videoram_size },
510 	{ 0xe800, 0xefff, MWA_RAM },
511 MEMORY_END
512 
513 
514 
515 static UINT8 vsb_ls273;
WRITE_HANDLER(vsb_ls273_audio_control_w)516 static WRITE_HANDLER( vsb_ls273_audio_control_w )
517 {
518 	vsb_ls273 = data;
519 
520 	/* bit 5 - led on */
521 	set_led_status(1,(data&0x20)>>5);
522 }
523 
524 
PORT_READ_START(readport_cpu2)525 static PORT_READ_START( readport_cpu2 )
526 	{ 0x80, 0x83, ls670_0_r },
527 PORT_END
528 
529 static PORT_WRITE_START( writeport_cpu2 )
530 	{ 0x00, 0x00, vsb_ls273_audio_control_w },
531 	{ 0x80, 0x83, ls670_1_w },
532 PORT_END
533 
534 static MEMORY_READ_START( readmem_cpu2 )
535 	{ 0x0000, 0x1fff, MRA_ROM },
536 	{ 0x4000, 0x43ff, MRA_RAM },
537 	{ 0x8000, 0x83ff, MRA_RAM },
538 MEMORY_END
539 
540 static MEMORY_WRITE_START( writemem_cpu2 )
541 	{ 0x0000, 0x1fff, MWA_ROM },
542 	{ 0x4000, 0x43ff, MWA_RAM }, /* main RAM (stack) */
543 	{ 0x8000, 0x83ff, MWA_RAM }, /* waveform ???*/
544 MEMORY_END
545 
546 
547 
548 
549 
550 /* Color Frame Buffer PCB */
551 static WRITE_HANDLER ( cfb_ram_w )
552 {
553 	cfb_ram[offset] = data;
554 }
READ_HANDLER(cfb_ram_r)555 static READ_HANDLER ( cfb_ram_r )
556 {
557 	return cfb_ram[offset];
558 }
559 
560 
WRITE_HANDLER(cfb_led_w)561 static WRITE_HANDLER(cfb_led_w)
562 {
563 	/* bit 7 - led on */
564 	set_led_status(2,(data&0x80)>>7);
565 }
566 
567 
568 static UINT8 bknd_col = 0xaa;
WRITE_HANDLER(cfb_backgnd_color_w)569 static WRITE_HANDLER(cfb_backgnd_color_w)
570 {
571 
572 	if (bknd_col != data)
573 	{
574 		int r,g,b, bit0, bit1, bit2;
575 
576 		bknd_col = data;
577 
578 		/* red component */
579 		bit1 = (data >> 7) & 0x01;
580 		bit0 = (data >> 6) & 0x01;
581 		r = combine_2_weights(weights_r, bit0, bit1);
582 
583 		/* green component */
584 		bit2 = (data >> 5) & 0x01;
585 		bit1 = (data >> 4) & 0x01;
586 		bit0 = (data >> 3) & 0x01;
587 		g = combine_3_weights(weights_g, bit0, bit1, bit2);
588 
589 		/* blue component */
590 		bit2 = (data >> 2) & 0x01;
591 		bit1 = (data >> 1) & 0x01;
592 		bit0 = (data >> 0) & 0x01;
593 		b = combine_3_weights(weights_b, bit0, bit1, bit2);
594 
595 		palette_set_color(255, r, g, b);
596 		//logerror("background color (port 01) write=%02x\n",data);
597 	}
598 }
599 
600 
WRITE_HANDLER(cfb_vbank_w)601 static WRITE_HANDLER(cfb_vbank_w)
602 {
603 	data = (data & 0x40)>>6;	/* only bit 6 connected */
604 	if (vbank != data)
605 	{
606 		vbank = data;
607 		//logerror("vbank=%1x\n",vbank);
608 	}
609 }
610 
611 
WRITE_HANDLER(cfb_rom_bank_sel_w)612 static WRITE_HANDLER(cfb_rom_bank_sel_w)	/* mazer blazer */
613 {
614 	gfx_rom_bank = data;
615 
616 	cpu_setbank( 1, memory_region(REGION_CPU3) + (gfx_rom_bank * 0x2000) + 0x10000 );
617 }
WRITE_HANDLER(cfb_rom_bank_sel_w_gg)618 static WRITE_HANDLER(cfb_rom_bank_sel_w_gg)	/* great guns */
619 {
620 	gfx_rom_bank = data>>1;
621 
622 	cpu_setbank( 1, memory_region(REGION_CPU3) + (gfx_rom_bank * 0x2000) + 0x10000 );
623 }
624 
625 
626 /* ????????????? */
627 static UINT8 port02_status = 0;
READ_HANDLER(cfb_port_02_r)628 static READ_HANDLER( cfb_port_02_r )
629 {
630 	port02_status ^= 0xff;
631 	return (port02_status);
632 }
633 
PORT_READ_START(readport_cpu3)634 static PORT_READ_START( readport_cpu3 )
635 	{ 0x02, 0x02, cfb_port_02_r },	/* VCU status ? */
636 PORT_END
637 
638 static PORT_WRITE_START( writeport_cpu3_mb )
639 	{ 0x01, 0x01, cfb_backgnd_color_w },
640 	{ 0x02, 0x02, cfb_led_w },
641 	{ 0x03, 0x03, cfb_zpu_int_req_set_w },
642 	{ 0x04, 0x04, cfb_rom_bank_sel_w },
643 	{ 0x05, 0x05, cfb_vbank_w },	//visible/writable videopage select?
644 PORT_END
645 
646 /* Great Guns has a little different banking layout */
647 static PORT_WRITE_START( writeport_cpu3_gg )
648 	{ 0x00, 0x00, IOWP_NOP },
649 	{ 0x01, 0x01, cfb_backgnd_color_w },
650 	{ 0x02, 0x02, cfb_led_w },
651 	{ 0x03, 0x03, cfb_zpu_int_req_set_w },
652 	{ 0x04, 0x04, cfb_rom_bank_sel_w_gg },
653 	{ 0x05, 0x05, cfb_vbank_w },	//visible/writable videopage select?
654 PORT_END
655 
656 
657 
658 static UINT8 VCU_video_reg[4];
WRITE_HANDLER(VCU_video_reg_w)659 static WRITE_HANDLER( VCU_video_reg_w )
660 {
661 	if (VCU_video_reg[offset] != data)
662 	{
663 		VCU_video_reg[offset] = data;
664 		//usrintf_showmessage("video_reg= %02x %02x %02x %02x", VCU_video_reg[0], VCU_video_reg[1], VCU_video_reg[2], VCU_video_reg[3] );
665 		//logerror("video_reg= %02x %02x %02x %02x\n", VCU_video_reg[0], VCU_video_reg[1], VCU_video_reg[2], VCU_video_reg[3] );
666 	}
667 }
668 
READ_HANDLER(VCU_set_cmd_param_r)669 static READ_HANDLER( VCU_set_cmd_param_r )
670 {
671 	VCU_gfx_param_addr = offset;
672 
673 								/* offset  = 0 is not known */
674 	xpos      = cfb_ram[VCU_gfx_param_addr + 1] | (cfb_ram[VCU_gfx_param_addr + 2]<<8);
675 	ypos      = cfb_ram[VCU_gfx_param_addr + 3] | (cfb_ram[VCU_gfx_param_addr + 4]<<8);
676 	color     = cfb_ram[VCU_gfx_param_addr + 5];
677 	color2    = cfb_ram[VCU_gfx_param_addr + 6];
678 	mode      = cfb_ram[VCU_gfx_param_addr + 7];
679 	pix_xsize = cfb_ram[VCU_gfx_param_addr + 8];
680 	pix_ysize = cfb_ram[VCU_gfx_param_addr + 9];
681 
682 	plane = mode & 3;
683 
684 	return 0;
685 }
686 
687 
READ_HANDLER(VCU_set_gfx_addr_r)688 static READ_HANDLER( VCU_set_gfx_addr_r )
689 {
690 int offs;
691 int x,y;
692 int bits = 0;
693 
694 UINT8 color_base=0;
695 
696 unsigned char * rom = memory_region(REGION_CPU3) + (gfx_rom_bank * 0x2000) + 0x10000;
697 
698 /*
699 	if ((mode<=0x07) || (mode>=0x10))
700 	{
701 		logerror("paradr=");
702 		logerror("%3x ",VCU_gfx_param_addr );
703 
704 		logerror("%02x ", cfb_ram[VCU_gfx_param_addr + 0] );
705 		logerror("x=%04x ", xpos );					//1,2
706 		logerror("y=%04x ", ypos );					//3,4
707 		logerror("color=%02x ", color);				//5
708 		logerror("color2=%02x ", color2);			//6
709 		logerror("mode=%02x ", mode );				//7
710 		logerror("xpix=%02x ", pix_xsize );			//8
711 		logerror("ypix=%02x ", pix_ysize );			//9
712 
713 		logerror("addr=%4i bank=%1i\n", offset, gfx_rom_bank);
714 	}
715 */
716 
717 	VCU_gfx_addr = offset;
718 
719 
720 /* draw */
721 	offs = VCU_gfx_addr;
722 
723 	switch(mode)
724 	{
725 	/* 2 bits per pixel */
726 	case 0x0f:
727 	case 0x0e:
728 	case 0x0d:
729 	case 0x0c:
730 //if (dbg_gfx_e)
731 //{
732 	//if (vbank==dbg_vbank)
733 	{
734 		if (game_id==MAZERBLA)
735 			color_base = 0x80;	/* 0x80 constant: matches Mazer Blazer movie */
736 
737 		if (game_id==GREATGUN)
738 			color_base = 0x0;
739 
740 		for (y = 0; y <= pix_ysize; y++)
741 		{
742 			for (x = 0; x <= pix_xsize; x++)
743 			{
744 				UINT8 pixeldata = rom[offs + (bits>>3)];
745 				UINT8 data = (pixeldata>>(6-(bits&7))) & 3;
746 				UINT8 col = 0;
747 
748 				switch(data)
749 				{
750 				case 0:
751 					col = color_base | ((color &0x0f));		//background PEN
752 					break;
753 				case 1:
754 					col = color_base | ((color &0xf0)>>4);	//foreground PEN
755 					break;
756 				case 2:
757 					col = color_base | ((color2 &0x0f));	//background PEN2
758 					break;
759 				case 3:
760 					col = color_base | ((color2 &0xf0)>>4);	//foreground PEN2
761 					break;
762 				}
763 
764 				if ( ((xpos+x)<256) && ((ypos+y)<256) )
765 				{
766 					plot_pixel(tmpbitmaps[plane], xpos+x, ypos+y, col );
767 				}
768 
769 				bits+=2;
770 			}
771 		}
772 	}
773 //}
774 	break;
775 
776 	/* 1 bit per pixel */
777 	case 0x0b:/* verified - 1bpp ; used for 'cleaning' using color 0xff */
778 	case 0x0a:/* verified - 1bpp */
779 	case 0x09:/* verified - 1bpp: gun crosshair */
780 	case 0x08:/* */
781 //if (dbg_gfx_e)
782 //{
783 	//if (vbank==dbg_vbank)
784 	{
785 		if (game_id==MAZERBLA)
786 			color_base = 0x80;	/* 0x80 - good for Mazer Blazer: (only in game, CRT test mode is bad) */
787 
788 		if (game_id==GREATGUN)
789 			color_base = 0x0;	/* 0x00 - good for Great Guns: (both in game and CRT test mode) */
790 		for (y = 0; y <= pix_ysize; y++)
791 		{
792 			for (x = 0; x <= pix_xsize; x++)
793 			{
794 				UINT8 pixeldata = rom[offs + (bits>>3)];
795 				UINT8 data = (pixeldata>>(7-(bits&7))) & 1;
796 
797 				/* color = 4 MSB = front PEN, 4 LSB = background PEN */
798 
799 				if ( ((xpos+x)<256) && ((ypos+y)<256) )
800 				{
801 					plot_pixel(tmpbitmaps[plane], xpos+x, ypos+y, data? color_base | ((color&0xf0)>>4): color_base | ((color&0x0f)) );
802 				}
803 
804 				bits+=1;
805 			}
806 		}
807 	}
808 //}
809 	break;
810 
811 	/* 4 bits per pixel */
812 	case 0x03:
813 	case 0x01:
814 	case 0x00:
815 //if (dbg_gfx_e)
816 //{
817 	//if (vbank==dbg_vbank)
818 	{
819 		if (game_id==MAZERBLA)
820 			color_base = 0x80;	/* 0x80 - good for Mazer Blazer: (only in game, CRT test mode is bad) */
821 
822 		if (game_id==GREATGUN)
823 			color_base = 0x0;	/* 0x00 - good for Great Guns: (both in game and CRT test mode) */
824 
825 		for (y = 0; y <= pix_ysize; y++)
826 		{
827 			for (x = 0; x <= pix_xsize; x++)
828 			{
829 				UINT8 pixeldata = rom[offs + (bits>>3)];
830 				UINT8 data = (pixeldata>>(4-(bits&7))) & 15;
831 				UINT8 col = 0;
832 
833 				col = color_base | data;
834 
835 				if ( ((xpos+x)<256) && ((ypos+y)<256) )
836 				{
837 					plot_pixel(tmpbitmaps[plane], xpos+x, ypos+y, col );
838 				}
839 
840 				bits+=4;
841 			}
842 		}
843 	}
844 //}
845 	break;
846 	default:
847 		usrintf_showmessage("not supported VCU drawing mode=%2x", mode);
848 	break;
849 	}
850 	return 0;
851 }
852 
READ_HANDLER(VCU_set_clr_addr_r)853 static READ_HANDLER( VCU_set_clr_addr_r )
854 {
855 int offs;
856 int x,y;
857 int bits = 0;
858 
859 UINT8 color_base=0;
860 
861 unsigned char * rom = memory_region(REGION_CPU3) + (gfx_rom_bank * 0x2000) + 0x10000;
862 
863 /*
864 	//if (0) //(mode != 0x07)
865 	{
866 		logerror("paladr=");
867 		logerror("%3x ",VCU_gfx_param_addr );
868 
869 		logerror("%02x ", cfb_ram[VCU_gfx_param_addr + 0] );
870 		logerror("x=%04x ", xpos );					//1,2
871 		logerror("y=%04x ", ypos );					//3,4
872 		logerror("color=%02x ", color);				//5
873 		logerror("color2=%02x ", color2 );			//6
874 		logerror("mode=%02x ", mode );				//7
875 		logerror("xpix=%02x ", pix_xsize );			//8
876 		logerror("ypix=%02x ", pix_ysize );			//9
877 
878 		logerror("addr=%4i bank=%1i\n", offset, gfx_rom_bank);
879 
880 		for (y=0; y<16; y++)
881 		{
882 			logerror("%04x: ",offset+y*16);
883 			for (x=0; x<16; x++)
884 			{
885 				logerror("%02x ",cfb_ram[offset+x+y*16]);
886 			}
887 			logerror("\n");
888 		}
889 	}
890 
891 */
892 
893 /* copy palette / CLUT(???) */
894 
895 
896 	switch(mode)
897 	{
898 	case 0x13: /* draws sprites?? in mazer blazer and ... wrong sprite in place of targeting-cross and UFO laser */
899 	case 0x03:
900 /* ... this may proove that there is really only one area and that
901  the draw command/palette selector is done via the 'mode' only ... */
902 	//if (dbg_clr_e)
903 	{
904 		offs = VCU_gfx_addr;
905 
906 		if (game_id==MAZERBLA)
907 			color_base = 0x80;	/* 0x80 constant: matches Mazer Blazer movie */
908 
909 		if (game_id==GREATGUN)
910 			color_base = 0x0;
911 
912 		for (y = 0; y <= pix_ysize; y++)
913 		{
914 			for (x = 0; x <= pix_xsize; x++)
915 			{
916 				UINT8 pixeldata = rom[offs + (bits>>3)];
917 				UINT8 data = (pixeldata>>(6-(bits&7))) & 3;
918 				UINT8 col = 0;
919 
920 				switch(data)
921 				{
922 				case 0:
923 					col = color_base | ((color &0x0f));		//background PEN
924 					break;
925 				case 1:
926 					col = color_base | ((color &0xf0)>>4);	//foreground PEN
927 					break;
928 				case 2:
929 					col = color_base | ((color2 &0x0f));	//background PEN2
930 					break;
931 				case 3:
932 					col = color_base | ((color2 &0xf0)>>4);	//foreground PEN2
933 					break;
934 				}
935 
936 				if ( ((xpos+x)<256) && ((ypos+y)<256) )
937 				{
938 					plot_pixel(tmpbitmaps[plane], xpos+x, ypos+y, col );
939 				}
940 
941 				bits+=2;
942 			}
943 		}
944 	}
945 	break;
946 
947 /* Palette / "something else" write mode */
948 	case 0x07:
949 
950 		offs = offset;
951 
952 		switch(ypos)
953 		{
954 		case 6: //seems to encode palete write
955 			{
956 				int r,g,b, bit0, bit1, bit2;
957 
958 //pix_xsize and pix_ysize seem to be related to palette length ? (divide by 2)
959 				int lookup_offs = (ypos>>1)*256; //=3*256
960 
961 				for (y=0; y<16; y++)
962 				{
963 					for (x=0; x<16; x++)
964 					{
965 						UINT8 colour = cfb_ram[ offs + x + y*16 ];
966 
967 						/* red component */
968 						bit1 = (colour >> 7) & 0x01;
969 						bit0 = (colour >> 6) & 0x01;
970 						r = combine_2_weights(weights_r, bit0, bit1);
971 
972 						/* green component */
973 						bit2 = (colour >> 5) & 0x01;
974 						bit1 = (colour >> 4) & 0x01;
975 						bit0 = (colour >> 3) & 0x01;
976 						g = combine_3_weights(weights_g, bit0, bit1, bit2);
977 
978 						/* blue component */
979 						bit2 = (colour >> 2) & 0x01;
980 						bit1 = (colour >> 1) & 0x01;
981 						bit0 = (colour >> 0) & 0x01;
982 						b = combine_3_weights(weights_b, bit0, bit1, bit2);
983 
984 						if ((x+y*16)<255)//keep color 255 free for use as background color
985 							palette_set_color(x+y*16, r, g, b);
986 
987 						lookup_RAM[ lookup_offs + x + y*16 ] = colour;
988 					}
989 				}
990 			}
991 		break;
992 		case 4: //seems to encode lookup???? table write
993 			{
994 				int lookup_offs = (ypos>>1)*256; //=2*256
995 
996 				for (y=0; y<16; y++)
997 				{
998 					for (x=0; x<16; x++)
999 					{
1000 						UINT8 dat = cfb_ram[ offs + x + y*16 ];
1001 						lookup_RAM[ lookup_offs + x + y*16 ] = dat;
1002 					}
1003 				}
1004 			}
1005 		break;
1006 		case 2: //seems to encode lookup???? table write
1007 			{
1008 				int lookup_offs = (ypos>>1)*256; //=1*256
1009 
1010 				for (y=0; y<16; y++)
1011 				{
1012 					for (x=0; x<16; x++)
1013 					{
1014 						UINT8 dat = cfb_ram[ offs + x + y*16 ];
1015 						lookup_RAM[ lookup_offs + x + y*16 ] = dat;
1016 					}
1017 				}
1018 			}
1019 		break;
1020 		case 0: //seems to encode lookup???? table write
1021 			{
1022 				int lookup_offs = (ypos>>1)*256; //=0*256
1023 
1024 				for (y=0; y<16; y++)
1025 				{
1026 					for (x=0; x<16; x++)
1027 					{
1028 						UINT8 dat = cfb_ram[ offs + x + y*16 ];
1029 						lookup_RAM[ lookup_offs + x + y*16 ] = dat;
1030 					}
1031 				}
1032 			}
1033 		break;
1034 
1035 		default:
1036 			usrintf_showmessage("not supported lookup/color write mode=%2x", ypos);
1037 		break;
1038 	}
1039 	break;
1040 
1041 	default:
1042 		usrintf_showmessage("not supported VCU color mode=%2x", mode);
1043 	break;
1044 
1045 	}
1046 
1047 	return 0;
1048 }
1049 
MEMORY_READ_START(readmem_cpu3)1050 static MEMORY_READ_START( readmem_cpu3 )
1051 	{ 0x0000, 0x37ff, MRA_ROM },
1052 	{ 0x3800, 0x3fff, sharedram_CFB_ZPU_r },
1053 	{ 0x4000, 0x5fff, MRA_BANK1 },				/* GFX roms */
1054 	{ 0x6000, 0x67ff, cfb_ram_r },				/* RAM for VCU commands and parameters */
1055 
1056 	{ 0xa000, 0xa7ff, VCU_set_cmd_param_r },	/* VCU command and parameters LOAD */
1057 	{ 0xc000, 0xdfff, VCU_set_gfx_addr_r },		/* gfx LOAD (blit) */
1058 	{ 0xe000, 0xffff, VCU_set_clr_addr_r },		/* palette? LOAD */
1059 MEMORY_END
1060 
1061 static MEMORY_WRITE_START( writemem_cpu3 )
1062 	{ 0x0000, 0x37ff, MWA_ROM },
1063 	{ 0x3800, 0x3fff, sharedram_CFB_ZPU_w, &cfb_zpu_sharedram },
1064 	{ 0x4000, 0x4003, VCU_video_reg_w },
1065 	{ 0x6000, 0x67ff, cfb_ram_w, &cfb_ram },
1066 MEMORY_END
1067 
1068 
1069 
1070 
1071 
1072 
1073 /* Great Guns */
1074 
1075 static UINT8 soundlatch;
1076 
READ_HANDLER(soundcommand_r)1077 static READ_HANDLER( soundcommand_r )
1078 {
1079 	return soundlatch;
1080 }
1081 
delayed_sound_w(int param)1082 static void delayed_sound_w(int param)
1083 {
1084 	soundlatch = param;
1085 
1086 	/* cause NMI on sound CPU */
1087 	cpu_set_nmi_line(1, ASSERT_LINE);
1088 }
1089 
1090 
WRITE_HANDLER(main_sound_w)1091 static WRITE_HANDLER( main_sound_w )
1092 {
1093 	timer_set(TIME_NOW, data & 0xff, delayed_sound_w);
1094 }
1095 
1096 
PORT_READ_START(gg_readport)1097 static PORT_READ_START( gg_readport )
1098 	{ 0x62, 0x62, zpu_inputs_r },
1099 PORT_END
1100 static PORT_WRITE_START( gg_writeport )
1101 	{ 0x4c, 0x4c, main_sound_w },
1102 	{ 0x60, 0x60, zpu_bcd_decoder_w },
1103 	{ 0x66, 0x66, IOWP_NOP },
1104 	{ 0x68, 0x68, IOWP_NOP },
1105 
1106 	{ 0x6e, 0x6f, zpu_led_w },
1107 PORT_END
1108 
1109 
1110 
1111 
1112 /* frequency is 14.318 MHz/16/16/16/16 */
1113 static INTERRUPT_GEN( sound_interrupt )
1114 {
1115 	cpu_set_irq_line(1, 0, ASSERT_LINE);
1116 }
1117 
WRITE_HANDLER(sound_int_clear_w)1118 static WRITE_HANDLER( sound_int_clear_w )
1119 {
1120 	cpu_set_irq_line(1, 0, CLEAR_LINE);
1121 }
WRITE_HANDLER(sound_nmi_clear_w)1122 static WRITE_HANDLER( sound_nmi_clear_w )
1123 {
1124 	cpu_set_nmi_line(1, CLEAR_LINE);
1125 }
1126 
WRITE_HANDLER(gg_led_ctrl_w)1127 static WRITE_HANDLER( gg_led_ctrl_w )
1128 {
1129 	/* bit 0, bit 1 - led on */
1130 	set_led_status(1,data&0x01);
1131 }
1132 
MEMORY_READ_START(sound_readmem)1133 static MEMORY_READ_START( sound_readmem )
1134 	{ 0x0000, 0x1fff, MRA_ROM },
1135 	{ 0x2000, 0x27ff, MRA_RAM },
1136 	{ 0x4000, 0x4000, AY8910_read_port_0_r },
1137 MEMORY_END
1138 
1139 static MEMORY_WRITE_START( sound_writemem )
1140 	{ 0x0000, 0x1fff, MWA_ROM },
1141 	{ 0x2000, 0x27ff, MWA_RAM }, /* main RAM (stack) */
1142 
1143 	{ 0x4000, 0x4000, AY8910_control_port_0_w },
1144 	{ 0x4001, 0x4001, AY8910_write_port_0_w },
1145 	{ 0x6000, 0x6000, AY8910_control_port_1_w },
1146 	{ 0x6001, 0x6001, AY8910_write_port_1_w },
1147 
1148 	{ 0x8000, 0x8000, sound_int_clear_w },
1149 	{ 0xa000, 0xa000, sound_nmi_clear_w },
1150 MEMORY_END
1151 
1152 
1153 
1154 
1155 
1156 
1157 INPUT_PORTS_START( mazerbla )
1158 	PORT_START	/* Strobe 0: ZPU Switches */
1159 	PORT_DIPNAME( 0x40, 0x40, "ZPU Switch 1" )
1160 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1161 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1162 	PORT_DIPNAME( 0x80, 0x80, "ZPU Switch 2" )
1163 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1164 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1165 
1166 	PORT_START	/* Strobe 1: Dip Switches 28-35*/
1167 	PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
1168 	PORT_DIPSETTING(	0x03, "6" )
1169 	PORT_DIPSETTING(	0x02, "5" )
1170 	PORT_DIPSETTING(	0x01, "4" )
1171 	PORT_DIPSETTING(	0x00, "3" )
1172 	PORT_DIPNAME( 0x0c, 0x00, "Freeze Time" )
1173 	PORT_DIPSETTING(	0x0c, "1.5 seconds" )
1174 	PORT_DIPSETTING(	0x08, "2.0 seconds" )
1175 	PORT_DIPSETTING(	0x04, "2.5 seconds" )
1176 	PORT_DIPSETTING(	0x00, "3.0 seconds" )
1177 	PORT_DIPNAME( 0x30, 0x00, "Number of points for extra frezze & first life" )
1178 	PORT_DIPSETTING(	0x30, "20000" )
1179 	PORT_DIPSETTING(	0x20, "25000" )
1180 	PORT_DIPSETTING(	0x10, "30000" )
1181 	PORT_DIPSETTING(	0x00, "35000" )
1182 	PORT_DIPNAME( 0xc0, 0x00, "Number of points for extra life other than first" )
1183 	PORT_DIPSETTING(	0xc0, "40000" )
1184 	PORT_DIPSETTING(	0x80, "50000" )
1185 	PORT_DIPSETTING(	0x40, "60000" )
1186 	PORT_DIPSETTING(	0x00, "70000" )
1187 
1188 	PORT_START	/* Strobe 2: Dip Switches 20-27*/
1189 	PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
1190 	PORT_DIPSETTING(    0x06, DEF_STR( 2C_1C ) )
1191 	PORT_DIPSETTING(    0x02, DEF_STR( 4C_3C ) )
1192 	PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
1193 	PORT_DIPSETTING(    0x01, DEF_STR( 4C_5C ) )
1194 	PORT_DIPSETTING(    0x05, DEF_STR( 2C_3C ) )
1195 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_7C ) )
1196 	PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
1197 	PORT_DIPSETTING(    0x04, DEF_STR( 2C_5C ) )
1198 	PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
1199 	PORT_DIPSETTING(    0x03, DEF_STR( 2C_7C ) )
1200 	PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
1201 	PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
1202 	PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
1203 	PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
1204 	PORT_DIPSETTING(    0x08, "1 Coin/10 Credits" )
1205 	PORT_DIPSETTING(    0x07, "1 Coin/14 Credits" )
1206 
1207 	PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
1208 	PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
1209 	PORT_DIPSETTING(    0x20, DEF_STR( 4C_3C ) )
1210 	PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
1211 	PORT_DIPSETTING(    0x10, DEF_STR( 4C_5C ) )
1212 	PORT_DIPSETTING(    0x50, DEF_STR( 2C_3C ) )
1213 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_7C ) )
1214 	PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
1215 	PORT_DIPSETTING(    0x40, DEF_STR( 2C_5C ) )
1216 	PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
1217 	PORT_DIPSETTING(    0x30, DEF_STR( 2C_7C ) )
1218 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
1219 	PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
1220 	PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
1221 	PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
1222 	PORT_DIPSETTING(    0x80, "1 Coin/10 Credits" )
1223 	PORT_DIPSETTING(    0x70, "1 Coin/14 Credits" )
1224 
1225 	PORT_START	/* Strobe 3: Dip Switches 12-19*/
1226 	PORT_DIPNAME( 0x01, 0x01, "Service Index" )
1227 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1228 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1229 	PORT_DIPNAME( 0x02, 0x02, "Switch Test" )
1230 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1231 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1232 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1233 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1234 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1235 	PORT_DIPNAME( 0x08, 0x08, "Player Immortality" )
1236 	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1237 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1238 	PORT_DIPNAME( 0x10, 0x10, "Super Shot" )
1239 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1240 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1241 	PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1242 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1243 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1244 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )	//probably unused
1245 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1246 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1247 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )	//probably unused
1248 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1249 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1250 
1251 	PORT_START	/* Strobe 4: Dip Switches 4-11 */
1252 	PORT_DIPNAME( 0x03, 0x02, "Number of Freezes" )
1253 	PORT_DIPSETTING(	0x03, "4" )
1254 	PORT_DIPSETTING(	0x02, "3" )
1255 	PORT_DIPSETTING(	0x01, "2" )
1256 	PORT_DIPSETTING(	0x00, "1" )
1257 	PORT_DIPNAME( 0x04, 0x04, "Gun Knocker" )
1258 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1259 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1260 	//dips 7-11 - not listed in manual
1261 	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )	//probably unused
1262 	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1263 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1264 	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )	//probably unused
1265 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1266 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1267 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )	//probably unused
1268 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1269 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1270 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )	//probably unused
1271 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1272 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1273 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )	//probably unused
1274 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1275 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1276 
1277 	PORT_START	/* Strobe 5: coin1&2, start1&2, fire */
1278 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN2 )
1279 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
1280 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
1281 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
1282 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
1283 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1284 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1285 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1286 
1287 	PORT_START	/* Strobe 6: horizontal movement of gun */
1288 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_X | IPF_PLAYER1 | IPF_REVERSE, 25, 7, 0, 255)
1289 	PORT_START	/* Strobe 7: vertical movement of gun */
1290 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_Y | IPF_PLAYER1, 25, 7, 0, 255)
1291 
1292 /* Mazer Blazer cabinet has only one gun, really */
1293 	PORT_START	/* Strobe 8: horizontal movement of gun */
1294 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_X | IPF_PLAYER2 | IPF_REVERSE, 25, 7, 0, 255)
1295 	PORT_START	/* Strobe 9: vertical movement of gun */
1296 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_Y | IPF_PLAYER2, 25, 7, 0, 255)
1297 INPUT_PORTS_END
1298 
1299 INPUT_PORTS_START( greatgun )
1300 	PORT_START	/* Strobe 0: ZPU Switches */
1301 	PORT_DIPNAME( 0x40, 0x40, "ZPU Switch 1" )
1302 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1303 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1304 	PORT_DIPNAME( 0x80, 0x80, "ZPU Switch 2" )
1305 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1306 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1307 
1308 	PORT_START	/* Strobe 1: Dip Switches 28-35*/
1309 	PORT_DIPNAME( 0x03, 0x00, "Starting Number of Bullets/Credit" )
1310 	PORT_DIPSETTING(	0x03, "60" )
1311 	PORT_DIPSETTING(	0x02, "70" )
1312 	PORT_DIPSETTING(	0x01, "80" )
1313 	PORT_DIPSETTING(	0x00, "90" )
1314 	PORT_DIPNAME( 0x0c, 0x00, "Target Size" )
1315 	PORT_DIPSETTING(	0x0c, "7 x 7" )
1316 	PORT_DIPSETTING(	0x08, "9 x 9" )
1317 	PORT_DIPSETTING(	0x04, "11x11" )
1318 	PORT_DIPSETTING(	0x00, "7 x 7" )
1319 	PORT_DIPNAME( 0x70, 0x00, "Number of points for extra bullet" )
1320 	PORT_DIPSETTING(	0x70, "1000" )
1321 	PORT_DIPSETTING(	0x60, "2000" )
1322 	PORT_DIPSETTING(	0x50, "3000" )
1323 	PORT_DIPSETTING(	0x40, "4000" )
1324 	PORT_DIPSETTING(	0x30, "5000" )
1325 	PORT_DIPSETTING(	0x20, "6000" )
1326 	PORT_DIPSETTING(	0x10, "7000" )
1327 	PORT_DIPSETTING(	0x00, "8000" )
1328 	/* from manual:
1329 		"This switch is used when an optional coin return or ticket dispenser is used"
1330 	*/
1331 	PORT_DIPNAME( 0x80, 0x00, "Number of coins or tickets returned" )
1332 	PORT_DIPSETTING(	0x80, "1" )
1333 	PORT_DIPSETTING(	0x00, "2" )
1334 
1335 	PORT_START	/* Strobe 2: Dip Switches 20-27*/
1336 	PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
1337 	PORT_DIPSETTING(    0x06, DEF_STR( 2C_1C ) )
1338 	PORT_DIPSETTING(    0x02, DEF_STR( 4C_3C ) )
1339 	PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
1340 	PORT_DIPSETTING(    0x01, DEF_STR( 4C_5C ) )
1341 	PORT_DIPSETTING(    0x05, DEF_STR( 2C_3C ) )
1342 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_7C ) )
1343 	PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
1344 	PORT_DIPSETTING(    0x04, DEF_STR( 2C_5C ) )
1345 	PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
1346 	PORT_DIPSETTING(    0x03, DEF_STR( 2C_7C ) )
1347 	PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
1348 	PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
1349 	PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
1350 	PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
1351 	PORT_DIPSETTING(    0x08, "1 Coin/10 Credits" )
1352 	PORT_DIPSETTING(    0x07, "1 Coin/14 Credits" )
1353 
1354 	PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
1355 	PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
1356 	PORT_DIPSETTING(    0x20, DEF_STR( 4C_3C ) )
1357 	PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
1358 	PORT_DIPSETTING(    0x10, DEF_STR( 4C_5C ) )
1359 	PORT_DIPSETTING(    0x50, DEF_STR( 2C_3C ) )
1360 	PORT_DIPSETTING(    0x00, DEF_STR( 4C_7C ) )
1361 	PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
1362 	PORT_DIPSETTING(    0x40, DEF_STR( 2C_5C ) )
1363 	PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
1364 	PORT_DIPSETTING(    0x30, DEF_STR( 2C_7C ) )
1365 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
1366 	PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
1367 	PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
1368 	PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
1369 	PORT_DIPSETTING(    0x80, "1 Coin/10 Credits" )
1370 	PORT_DIPSETTING(    0x70, "1 Coin/14 Credits" )
1371 
1372 	PORT_START	/* Strobe 3: Dip Switches 12-19*/
1373 	PORT_DIPNAME( 0x01, 0x01, "Service Index" )
1374 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1375 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1376 	PORT_DIPNAME( 0x02, 0x02, "Switch Test" )
1377 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1378 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1379 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1380 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1381 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1382 	PORT_DIPNAME( 0x08, 0x08, "Player Immortality" )
1383 	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1384 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1385 	PORT_DIPNAME( 0x10, 0x10, "Rack Advance" )
1386 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1387 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1388 	PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1389 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1390 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1391 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )	//probably unused
1392 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1393 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1394 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )	//probably unused
1395 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1396 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1397 
1398 	PORT_START	/* Strobe 4: Dip Switches 4-11 */
1399 	PORT_DIPNAME( 0x01, 0x01, "Free game/coin return" )
1400 	PORT_DIPSETTING(	0x01, DEF_STR( Off ) )
1401 	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
1402 	//dips 5-11 - not listed in manual
1403 	PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
1404 	PORT_DIPSETTING(	0x02, DEF_STR( Off ) )
1405 	PORT_DIPSETTING(	0x00, DEF_STR( On ) )
1406 	PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
1407 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1408 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1409 	PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
1410 	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1411 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1412 	PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
1413 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1414 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1415 	PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
1416 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1417 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1418 	PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
1419 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1420 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1421 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
1422 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1423 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1424 
1425 	PORT_START	/* Strobe 5: coin1&2, start1&2, fire */
1426 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN2 )
1427 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
1428 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
1429 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
1430 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
1431 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
1432 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
1433 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 )
1434 
1435 	PORT_START	/* Strobe 6: horizontal movement of gun */
1436 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_X | IPF_PLAYER1, 25, 7, 0, 255)
1437 	PORT_START	/* Strobe 7: vertical movement of gun */
1438 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_Y | IPF_PLAYER1, 25, 7, 0, 255)
1439 
1440 	PORT_START	/* Strobe 8: horizontal movement of gun */
1441 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_X | IPF_PLAYER2, 25, 7, 0, 255)
1442 	PORT_START	/* Strobe 9: vertical movement of gun */
1443 	PORT_ANALOG( 0xff, 0x80, IPT_LIGHTGUN_Y | IPF_PLAYER2, 25, 7, 0, 255)
1444 INPUT_PORTS_END
1445 
1446 
1447 
1448 
1449 static MACHINE_INIT( mazerbla )
1450 {
1451 	game_id = MAZERBLA;
1452 	zpu_int_vector = 0xff;
1453 	cpu_set_irq_callback(0, irq_callback);
1454 }
1455 
1456 
MACHINE_INIT(greatgun)1457 static MACHINE_INIT( greatgun )
1458 {
1459 	game_id = GREATGUN;
1460 	zpu_int_vector = 0xff;
1461 	cpu_set_irq_callback(0, irq_callback);
1462 
1463 
1464 //patch VCU test
1465 //VCU test starts at PC=0x56f
1466 	memory_region(REGION_CPU3)[0x05b6] = 0;
1467 	memory_region(REGION_CPU3)[0x05b7] = 0;
1468 //so we also need to patch ROM checksum test
1469 	memory_region(REGION_CPU3)[0x037f] = 0;
1470 	memory_region(REGION_CPU3)[0x0380] = 0;
1471 }
1472 
1473 
1474 /* only Great Guns */
1475 static struct AY8910interface ay8912_interface =
1476 {
1477 	2,	/* 2 chips */
1478 	14318000 / 8,
1479 	{ 30, 100 },
1480 	{ 0, 0 },	/* port Aread */
1481 	{ soundcommand_r, 0 },	/* port Bread */
1482 	{ /*ay0_output_ctrl_w*/0,/*ay1_output_ctrl_w*/ 0 },	/* port Awrite */
1483 	{ 0, gg_led_ctrl_w }	/* port Bwrite */
1484 };
1485 
1486 
1487 static MACHINE_DRIVER_START( mazerbla )
1488 	/* basic machine hardware */
1489 	MDRV_CPU_ADD(Z80, 4000000)	/* 4 MHz, no NMI, IM2 - vectors at 0xf8, 0xfa, 0xfc */
1490 	MDRV_CPU_MEMORY(readmem,writemem)
1491 	MDRV_CPU_PORTS(readport,writeport)
1492 
1493 	MDRV_CPU_ADD(Z80, 4000000)	/* 4 MHz, NMI, IM1 INT */
1494 	MDRV_CPU_MEMORY(readmem_cpu2,writemem_cpu2)
1495 	MDRV_CPU_PORTS(readport_cpu2,writeport_cpu2)
1496 //MDRV_CPU_PERIODIC_INT(irq0_line_hold, 400 ) /* frequency in Hz */
1497 
1498 	MDRV_CPU_ADD(Z80, 4000000)	/* 4 MHz, no  NMI, IM1 INT */
1499 	MDRV_CPU_MEMORY(readmem_cpu3,writemem_cpu3)
1500 	MDRV_CPU_PORTS(readport_cpu3,writeport_cpu3_mb)
1501 /* (vblank related ??) int generated by a custom video processor
1502 and cleared on ANY port access.
1503 but handled differently for now
1504 */
1505 	MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
1506 
1507 	MDRV_FRAMES_PER_SECOND(60)
1508 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
1509 
1510 	/* synchronization forced on the fly */
1511 
1512 	MDRV_MACHINE_INIT(mazerbla)
1513 
1514 	/* video hardware */
1515 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
1516 	MDRV_SCREEN_SIZE(40*8, 32*8)
1517 	MDRV_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1)
1518 	MDRV_PALETTE_LENGTH(256)
1519 
1520 	MDRV_PALETTE_INIT(mazerbla)
1521 	MDRV_VIDEO_START(mazerbla)
1522 	MDRV_VIDEO_UPDATE(mazerbla)
1523 
1524 	/* sound hardware */
1525 MACHINE_DRIVER_END
1526 
1527 
1528 static MACHINE_DRIVER_START( greatgun )
1529 
1530 	/* basic machine hardware */
1531 	MDRV_CPU_ADD(Z80, 4000000)	/* 4 MHz, no NMI, IM2 - vectors at 0xf8, 0xfa, 0xfc */
1532 	MDRV_CPU_MEMORY(readmem,writemem)
1533 	MDRV_CPU_PORTS(gg_readport,gg_writeport)
1534 
1535 	MDRV_CPU_ADD(Z80, 14318000 / 4)	/* 3.579500 MHz, NMI - caused by sound command write, periodic INT */
1536 	MDRV_CPU_MEMORY(sound_readmem,sound_writemem)
1537 	/* IRQ frequency is: 14318000.0 Hz/16/16/16/16 = 218.475341796875 Hz */
1538 	/*   that is a period of 1000000000.0 / 218.475341796875 = 4577175.5831 ns */
1539 	MDRV_CPU_PERIODIC_INT(sound_interrupt, 4577176 ) /* period in nanoseconds */
1540 
1541 	MDRV_CPU_ADD(Z80, 4000000)	/* 4 MHz, no  NMI, IM1 INT */
1542 	MDRV_CPU_MEMORY(readmem_cpu3,writemem_cpu3)
1543 	MDRV_CPU_PORTS(readport_cpu3,writeport_cpu3_gg)
1544 /* (vblank related ??) int generated by a custom video processor
1545 and cleared on ANY port access.
1546 but handled differently for now
1547 */
1548 	MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
1549 
1550 	MDRV_FRAMES_PER_SECOND(60)
1551 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
1552 
1553 	MDRV_MACHINE_INIT(greatgun)
1554 
1555 	/* video hardware */
1556 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
1557 	MDRV_SCREEN_SIZE(40*8, 32*8)
1558 	MDRV_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1)
1559 	MDRV_PALETTE_LENGTH(256)
1560 
1561 	MDRV_PALETTE_INIT(mazerbla)
1562 	MDRV_VIDEO_START(mazerbla)
1563 	MDRV_VIDEO_UPDATE(greatgun)
1564 
1565 	/* sound hardware */
1566 	MDRV_SOUND_ADD(AY8910, ay8912_interface)
1567 MACHINE_DRIVER_END
1568 
1569 
1570 /***************************************************************************
1571 
1572   Game driver(s)
1573 
1574 ***************************************************************************/
1575 
1576 ROM_START( mazerbla )
1577 	ROM_REGION( 0x10000, REGION_CPU1, 0 )     /* 64k for main CPU (ZPU board) */
1578 	ROM_LOAD( "mblzpu0.bin",0x0000, 0x2000, CRC(82766187) SHA1(cfc425c87cccb84180f1091998eafeaede126d9d) )
1579 	ROM_LOAD( "mblzpu1.bin",0x2000, 0x2000, CRC(8ba2b3f9) SHA1(1d203332e434d1d9821f98c6ac959ae65dcc51ef) )
1580 	ROM_LOAD( "mblzpu2.bin",0x4000, 0x2000, CRC(48e5306c) SHA1(d27cc85d24c7b6c23c5c96be4dad5cae6e8069be) )
1581 	ROM_LOAD( "mblzpu3.bin",0x6000, 0x2000, CRC(eba91546) SHA1(8c1da4e0d9b562dbbf7c7583dbf567c804eb670f) )
1582 
1583 	ROM_REGION( 0x10000, REGION_CPU2, 0 )     /* 64k for sound CPU (VSB board) */
1584 	ROM_LOAD( "mblvsb0.bin",0x0000, 0x1000, CRC(0cf7a1c3) SHA1(af27e3a3b51d03d46c62c2797268744d0577d075) )
1585 	ROM_LOAD( "mblvsb1.bin",0x1000, 0x1000, CRC(0b8d0e43) SHA1(b3ddb7561e715a58ca512fe76e53cda39402a8e4) )
1586 
1587 	ROM_REGION( 0x18000, REGION_CPU3, 0 )     /* 64k for video CPU (CFB board) */
1588 	ROM_LOAD( "mblrom0.bin",0x0000, 0x2000, CRC(948a2c5e) SHA1(d693f1b96caf31649f600c5038bb79b0d1d16133) )
1589 
1590 	ROM_LOAD( "mblrom2.bin",0x10000,0x2000, CRC(36237058) SHA1(9db8fced37a3d40c4ea5b87ea18ac8e75d71e586) )/*banked at 0x4000 (select=0)*/
1591 	ROM_LOAD( "mblrom3.bin",0x12000,0x2000, CRC(18d75d7f) SHA1(51c35ea4a2127439a1299863eb74e57be833e2e4) )/*banked at 0x4000 (select=1)*/
1592 	/* empty socket??? (the *name* of next rom seems good ?) or wrong schematics ?*/
1593 	ROM_LOAD( "mblrom4.bin",0x16000,0x2000, CRC(1805acdc) SHA1(40b8e70e6ba69ac864af0b276e81218e63e48deb) )/*banked at 0x4000 (select=3)*/
1594 ROM_END
1595 
1596 
1597 ROM_START( greatgun )
1598 	ROM_REGION( 0x10000, REGION_CPU1, 0 )     /* 64k for main CPU (ZPU board) */
1599 	ROM_LOAD( "zpu0",0x0000, 0x2000, CRC(80cf2cbf) SHA1(ea24b844ea6d8fc54adb2e28be68e1f3e1184b8b) )
1600 	ROM_LOAD( "zpu1",0x2000, 0x2000, CRC(fc12af94) SHA1(65f5bca2853271c232bd02dfc3467e6a4f7f0a6f) )
1601 	ROM_LOAD( "zpu2",0x4000, 0x2000, CRC(b34cfa26) SHA1(903adc6de0d34e5bc8fb0f8d3e74ff53204d8c68) )
1602 	ROM_LOAD( "zpu3",0x6000, 0x2000, CRC(c142ebdf) SHA1(0b87740d26b19a05f65b811225ee0053ddb27d22) )
1603 
1604 	ROM_REGION( 0x10000, REGION_CPU2, 0 )     /* 64k for sound CPU (PSB board) */
1605 	ROM_LOAD( "psba4",0x0000, 0x2000, CRC(172a793e) SHA1(3618a778af1f4a6267bf7e0786529be731ac9b76) )
1606 
1607 	ROM_REGION( 0x38000, REGION_CPU3, 0 )     /* 64k for video CPU (CFB board) */
1608 	ROM_LOAD( "cfb0",0x0000, 0x2000, CRC(ee372b1f) SHA1(b630fd659d59eb8c2540f18d91ae0d72e859fc4f) )
1609 	ROM_LOAD( "cfb1",0x2000, 0x2000, CRC(b76d9527) SHA1(8f16b850bd67d553aaaf7e176754e36aba581445) )
1610 
1611 	ROM_LOAD( "psb00",0x10000,0x2000, CRC(b4956100) SHA1(98baf5c27c76dc5c4eafc44f42705239504637fe) )/*banked at 0x4000*/
1612 	ROM_LOAD( "psb01",0x12000,0x2000, CRC(acdce2ee) SHA1(96b8961afbd0006b10cfdc825aefe27ec18121ff) )
1613 	ROM_LOAD( "psb02",0x14000,0x2000, CRC(cb840fc6) SHA1(c30c72d355e1957f3715e9fab701f65b9d7d632a) )
1614 	ROM_LOAD( "psb03",0x16000,0x2000, CRC(86ea6f99) SHA1(ce5d42557d0a62eebe3d0cee28587d60707573e4) )
1615 	ROM_LOAD( "psb04",0x18000,0x2000, CRC(65379893) SHA1(84bb755e23d5ce13b1c82e59f24f3890c50697cc) )
1616 	ROM_LOAD( "psb05",0x1a000,0x2000, CRC(f82245cb) SHA1(fa1cab94a03ce7b8e45ea6eec572b21f268f7547) )
1617 	ROM_LOAD( "psb06",0x1c000,0x2000, CRC(6b86794f) SHA1(72cf67ecf5a9198ecb44dd846de968e6cdd6458d) )
1618 	ROM_LOAD( "psb07",0x1e000,0x2000, CRC(60a7abf3) SHA1(44b932d8af29ec706c29d6b71a8bac6318d92315) )
1619 	ROM_LOAD( "psb08",0x20000,0x2000, CRC(854be14e) SHA1(ae9b1fe2443c87bb4334bc776f7bc7e5fa874f38) )
1620 	ROM_LOAD( "psb09",0x22000,0x2000, CRC(b2e8afa3) SHA1(30a3d83bf1ec7885549b47f9569e9ae0d05b948d) )
1621 	ROM_LOAD( "psb10",0x24000,0x2000, CRC(fbfb0aab) SHA1(2eb666a5eff31019b4ffdfc82e242ff47cd59527) )
1622 	ROM_LOAD( "psb11",0x26000,0x2000, CRC(ddcd3cec) SHA1(7d0c3b4160b11ebe9b097664190d8ae605413baa) )
1623 	ROM_LOAD( "psb12",0x28000,0x2000, CRC(c6617377) SHA1(29a6fc52e06c41f06ee333aad707c3a1952dff4d) )
1624 	ROM_LOAD( "psb13",0x2a000,0x2000, CRC(aeab8555) SHA1(c398cac5210022e3c9e25a9f2ef1017b27c21e62) )
1625 	ROM_LOAD( "psb14",0x2c000,0x2000, CRC(ef35e314) SHA1(2e20517ff89b153fd888cf4eb0404a802e16b1b7) )
1626 	ROM_LOAD( "psb15",0x2e000,0x2000, CRC(1fafe83d) SHA1(d1d406275f50d87547aabe1295795099f341433d) )
1627 	ROM_LOAD( "psb16",0x30000,0x2000, CRC(ec49864f) SHA1(7a3b295972b52682406f75c4fe12c29632452491) )
1628 	ROM_LOAD( "psb17",0x32000,0x2000, CRC(d9778e85) SHA1(2998f0a08cdba8a75e687a54cb9a03edeb4b22cd) )
1629 	ROM_LOAD( "psb18",0x34000,0x2000, CRC(ef61b6c0) SHA1(7e8a82beefb9fd8e219fc4d7d25a3a43ab8aadf7) )
1630 	ROM_LOAD( "psb19",0x36000,0x2000, CRC(68752e0d) SHA1(58a4921e4f774af5e1ef7af67f06e9b43643ffab) )
1631 
1632 ROM_END
1633 
1634 
1635 GAMEX( 1983, mazerbla, 0, mazerbla,  mazerbla, 0, ROT0, "Stern", "Mazer Blazer", GAME_IMPERFECT_GRAPHICS |GAME_NO_SOUND | GAME_NOT_WORKING )
1636 GAMEX( 1983, greatgun, 0, greatgun,  greatgun, 0, ROT0, "Stern", "Great Guns", GAME_IMPERFECT_GRAPHICS )
1637