1 /***************************************************************************
2 
3 	Atari G42 hardware
4 
5 	driver by Aaron Giles
6 
7 	Games supported:
8 		* Road Riot 4WD (1991)
9 		* Guardians of the 'Hood (1992)
10 
11 	Known bugs:
12 		* ASIC65 for Road Riot not quite perfect
13 
14 ****************************************************************************
15 
16 	Memory map (TBA)
17 
18 ***************************************************************************/
19 
20 
21 #include "driver.h"
22 #include "machine/atarigen.h"
23 #include "machine/asic65.h"
24 #include "sndhrdw/atarijsa.h"
25 #include "vidhrdw/atarirle.h"
26 #include "atarig42.h"
27 
28 
29 /*************************************
30  *
31  *	Statics
32  *
33  *************************************/
34 
35 static UINT8 analog_data;
36 static data16_t *mo_command;
37 
38 static int sloop_bank;
39 static int sloop_next_bank;
40 static int sloop_offset;
41 static int sloop_state;
42 static data16_t *sloop_base;
43 
44 
45 
46 /*************************************
47  *
48  *	Initialization & interrupts
49  *
50  *************************************/
51 
update_interrupts(void)52 static void update_interrupts(void)
53 {
54 	int newstate = 0;
55 
56 	if (atarigen_video_int_state)
57 		newstate = 4;
58 	if (atarigen_sound_int_state)
59 		newstate = 5;
60 
61 	if (newstate)
62 		cpu_set_irq_line(0, newstate, ASSERT_LINE);
63 	else
64 		cpu_set_irq_line(0, 7, CLEAR_LINE);
65 }
66 
67 
MACHINE_INIT(atarig42)68 static MACHINE_INIT( atarig42 )
69 {
70 	atarigen_eeprom_reset();
71 	atarigen_interrupt_reset(update_interrupts);
72 	atarigen_scanline_timer_reset(atarig42_scanline_update, 8);
73 	atarijsa_reset();
74 }
75 
76 
77 
78 /*************************************
79  *
80  *	I/O read dispatch.
81  *
82  *************************************/
83 
READ16_HANDLER(special_port2_r)84 static READ16_HANDLER( special_port2_r )
85 {
86 	int temp = readinputport(2);
87 	if (atarigen_cpu_to_sound_ready) temp ^= 0x0020;
88 	if (atarigen_sound_to_cpu_ready) temp ^= 0x0010;
89 	temp ^= 0x0008;		/* A2D.EOC always high for now */
90 	return temp;
91 }
92 
93 
WRITE16_HANDLER(a2d_select_w)94 static WRITE16_HANDLER( a2d_select_w )
95 {
96 	analog_data = readinputport(4 + (offset != 0));
97 }
98 
99 
READ16_HANDLER(a2d_data_r)100 static READ16_HANDLER( a2d_data_r )
101 {
102 	return analog_data << 8;
103 }
104 
105 
WRITE16_HANDLER(io_latch_w)106 static WRITE16_HANDLER( io_latch_w )
107 {
108 	/* upper byte */
109 	if (ACCESSING_MSB)
110 	{
111 		/* bit 14 controls the ASIC65 reset line */
112 		asic65_reset((~data >> 14) & 1);
113 
114 		/* bits 13-11 are the MO control bits */
115 		atarirle_control_w(0, (data >> 11) & 7);
116 	}
117 
118 	/* lower byte */
119 	if (ACCESSING_LSB)
120 	{
121 		/* bit 4 resets the sound CPU */
122 		cpu_set_reset_line(1, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
123 		if (!(data & 0x10)) atarijsa_reset();
124 
125 		/* bit 5 is /XRESET, probably related to the ASIC */
126 
127 		/* bits 3 and 0 are coin counters */
128 	}
129 }
130 
131 
WRITE16_HANDLER(mo_command_w)132 static WRITE16_HANDLER( mo_command_w )
133 {
134 	COMBINE_DATA(mo_command);
135 	atarirle_command_w(0, (data == 0) ? ATARIRLE_COMMAND_CHECKSUM : ATARIRLE_COMMAND_DRAW);
136 }
137 
138 
139 
140 /*************************************
141  *
142  *	SLOOP banking -- Road Riot
143  *
144  *************************************/
145 
roadriot_sloop_tweak(int offset)146 static void roadriot_sloop_tweak(int offset)
147 {
148 /*
149 	sequence 1:
150 
151 		touch $68000
152 		touch $68eee and $124/$678/$abc/$1024(bank) in the same instruction
153 		touch $69158/$6a690/$6e708/$71166
154 
155 	sequence 2:
156 
157 		touch $5edb4 to add 2 to the bank
158 		touch $5db0a to add 1 to the bank
159 		touch $5f042
160 		touch $69158/$6a690/$6e708/$71166
161 		touch $68000
162 		touch $5d532/$5d534
163 */
164 
165 	switch (offset)
166 	{
167 		/* standard 68000 -> 68eee -> (bank) addressing */
168 		case 0x68000/2:
169 			sloop_state = 1;
170 			break;
171 		case 0x68eee/2:
172 			if (sloop_state == 1)
173 				sloop_state = 2;
174 			break;
175 		case 0x00124/2:
176 			if (sloop_state == 2)
177 			{
178 				sloop_next_bank = 0;
179 				sloop_state = 3;
180 			}
181 			break;
182 		case 0x00678/2:
183 			if (sloop_state == 2)
184 			{
185 				sloop_next_bank = 1;
186 				sloop_state = 3;
187 			}
188 			break;
189 		case 0x00abc/2:
190 			if (sloop_state == 2)
191 			{
192 				sloop_next_bank = 2;
193 				sloop_state = 3;
194 			}
195 			break;
196 		case 0x01024/2:
197 			if (sloop_state == 2)
198 			{
199 				sloop_next_bank = 3;
200 				sloop_state = 3;
201 			}
202 			break;
203 
204 		/* lock in the change? */
205 		case 0x69158/2:
206 			/* written if $ff8007 == 0 */
207 		case 0x6a690/2:
208 			/* written if $ff8007 == 1 */
209 		case 0x6e708/2:
210 			/* written if $ff8007 == 2 */
211 		case 0x71166/2:
212 			/* written if $ff8007 == 3 */
213 			if (sloop_state == 3)
214 				sloop_bank = sloop_next_bank;
215 			sloop_state = 0;
216 			break;
217 
218 		/* bank offsets */
219 		case 0x5edb4/2:
220 			if (sloop_state == 0)
221 			{
222 				sloop_state = 10;
223 				sloop_offset = 0;
224 			}
225 			sloop_offset += 2;
226 			break;
227 		case 0x5db0a/2:
228 			if (sloop_state == 0)
229 			{
230 				sloop_state = 10;
231 				sloop_offset = 0;
232 			}
233 			sloop_offset += 1;
234 			break;
235 
236 		/* apply the offset */
237 		case 0x5f042/2:
238 			if (sloop_state == 10)
239 			{
240 				sloop_bank = (sloop_bank + sloop_offset) & 3;
241 				sloop_offset = 0;
242 				sloop_state = 0;
243 			}
244 			break;
245 
246 		/* unknown */
247 		case 0x5d532/2:
248 			break;
249 		case 0x5d534/2:
250 			break;
251 
252 		default:
253 			break;
254 	}
255 }
256 
257 
READ16_HANDLER(roadriot_sloop_data_r)258 static READ16_HANDLER( roadriot_sloop_data_r )
259 {
260 	roadriot_sloop_tweak(offset);
261 	if (offset < 0x78000/2)
262 		return sloop_base[offset];
263 	else
264 		return sloop_base[0x78000/2 + sloop_bank * 0x1000 + (offset & 0xfff)];
265 }
266 
267 
WRITE16_HANDLER(roadriot_sloop_data_w)268 static WRITE16_HANDLER( roadriot_sloop_data_w )
269 {
270 	roadriot_sloop_tweak(offset);
271 }
272 
273 
274 
275 /*************************************
276  *
277  *	SLOOP banking -- Guardians
278  *
279  *************************************/
280 
guardians_sloop_tweak(int offset)281 static void guardians_sloop_tweak(int offset)
282 {
283 	static UINT32 last_accesses[8];
284 
285 	if (offset >= 0x7f7c0/2)
286 	{
287 		last_accesses[0] = last_accesses[1];
288 		last_accesses[1] = last_accesses[2];
289 		last_accesses[2] = last_accesses[3];
290 		last_accesses[3] = last_accesses[4];
291 		last_accesses[4] = last_accesses[5];
292 		last_accesses[5] = last_accesses[6];
293 		last_accesses[6] = last_accesses[7];
294 		last_accesses[7] = offset;
295 
296 		if (last_accesses[0] == 0x7f7c0/2 && last_accesses[1] == 0x7f7ce/2 && last_accesses[2] == 0x7f7c2/2 && last_accesses[3] == 0x7f7cc/2 &&
297 			last_accesses[4] == 0x7f7c4/2 && last_accesses[5] == 0x7f7ca/2 && last_accesses[6] == 0x7f7c6/2 && last_accesses[7] == 0x7f7c8/2)
298 			sloop_bank = 0;
299 
300 		if (last_accesses[0] == 0x7f7d0/2 && last_accesses[1] == 0x7f7de/2 && last_accesses[2] == 0x7f7d2/2 && last_accesses[3] == 0x7f7dc/2 &&
301 			last_accesses[4] == 0x7f7d4/2 && last_accesses[5] == 0x7f7da/2 && last_accesses[6] == 0x7f7d6/2 && last_accesses[7] == 0x7f7d8/2)
302 			sloop_bank = 1;
303 
304 		if (last_accesses[0] == 0x7f7e0/2 && last_accesses[1] == 0x7f7ee/2 && last_accesses[2] == 0x7f7e2/2 && last_accesses[3] == 0x7f7ec/2 &&
305 			last_accesses[4] == 0x7f7e4/2 && last_accesses[5] == 0x7f7ea/2 && last_accesses[6] == 0x7f7e6/2 && last_accesses[7] == 0x7f7e8/2)
306 			sloop_bank = 2;
307 
308 		if (last_accesses[0] == 0x7f7f0/2 && last_accesses[1] == 0x7f7fe/2 && last_accesses[2] == 0x7f7f2/2 && last_accesses[3] == 0x7f7fc/2 &&
309 			last_accesses[4] == 0x7f7f4/2 && last_accesses[5] == 0x7f7fa/2 && last_accesses[6] == 0x7f7f6/2 && last_accesses[7] == 0x7f7f8/2)
310 			sloop_bank = 3;
311 	}
312 }
313 
314 
READ16_HANDLER(guardians_sloop_data_r)315 static READ16_HANDLER( guardians_sloop_data_r )
316 {
317 	guardians_sloop_tweak(offset);
318 	if (offset < 0x78000/2)
319 		return sloop_base[offset];
320 	else
321 		return sloop_base[0x78000/2 + sloop_bank * 0x1000 + (offset & 0xfff)];
322 }
323 
324 
WRITE16_HANDLER(guardians_sloop_data_w)325 static WRITE16_HANDLER( guardians_sloop_data_w )
326 {
327 	guardians_sloop_tweak(offset);
328 }
329 
330 
331 
332 /*************************************
333  *
334  *	Main CPU memory handlers
335  *
336  *************************************/
337 
MEMORY_READ16_START(main_readmem)338 static MEMORY_READ16_START( main_readmem )
339 	{ 0x000000, 0x080001, MRA16_ROM },
340 	{ 0xe00000, 0xe00001, input_port_0_word_r },
341 	{ 0xe00002, 0xe00003, input_port_1_word_r },
342 	{ 0xe00010, 0xe00011, special_port2_r },
343 	{ 0xe00012, 0xe00013, input_port_3_word_r },
344 	{ 0xe00020, 0xe00027, a2d_data_r },
345 	{ 0xe00030, 0xe00031, atarigen_sound_r },
346 	{ 0xe80000, 0xe80fff, MRA16_RAM },
347 	{ 0xf40000, 0xf40001, asic65_io_r },
348 	{ 0xf60000, 0xf60001, asic65_r },
349 	{ 0xfa0000, 0xfa0fff, atarigen_eeprom_r },
350 	{ 0xfc0000, 0xfc0fff, MRA16_RAM },
351 	{ 0xff0000, 0xffffff, MRA16_RAM },
352 MEMORY_END
353 
354 
355 static MEMORY_WRITE16_START( main_writemem )
356 	{ 0x000000, 0x080001, MWA16_ROM },
357 	{ 0xe00020, 0xe00027, a2d_select_w },
358 	{ 0xe00040, 0xe00041, atarigen_sound_w },
359 	{ 0xe00050, 0xe00051, io_latch_w },
360 	{ 0xe00060, 0xe00061, atarigen_eeprom_enable_w },
361 	{ 0xe03000, 0xe03001, atarigen_video_int_ack_w },
362 	{ 0xe03800, 0xe03801, watchdog_reset16_w },
363 	{ 0xe80000, 0xe80fff, MWA16_RAM },
364 	{ 0xf80000, 0xf80003, asic65_data_w },
365 	{ 0xfa0000, 0xfa0fff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
366 	{ 0xfc0000, 0xfc0fff, atarigen_666_paletteram_w, &paletteram16 },
367 	{ 0xff0000, 0xff0fff, atarirle_0_spriteram_w, &atarirle_0_spriteram },
368 	{ 0xff1000, 0xff1fff, MWA16_RAM },
369 	{ 0xff2000, 0xff5fff, atarigen_playfield_w, &atarigen_playfield },
370 	{ 0xff6000, 0xff6fff, atarigen_alpha_w, &atarigen_alpha },
371 	{ 0xff7000, 0xff7001, mo_command_w, &mo_command },
372 	{ 0xff7002, 0xffffff, MWA16_RAM },
373 MEMORY_END
374 
375 
376 
377 /*************************************
378  *
379  *	Port definitions
380  *
381  *************************************/
382 
383 INPUT_PORTS_START( roadriot )
384 	PORT_START		/* e00000 */
385 	PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
386 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
387 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
388 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
389 	PORT_BIT( 0xf800, IP_ACTIVE_LOW, IPT_UNUSED )
390 
391 	PORT_START      /* e00002 */
392 	PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )
393 
394 	PORT_START		/* e00010 */
395 	PORT_BIT( 0x003f, IP_ACTIVE_LOW, IPT_UNUSED )
396 	PORT_SERVICE( 0x0040, IP_ACTIVE_LOW )
397 	PORT_BIT(  0x0080, IP_ACTIVE_LOW, IPT_VBLANK )
398 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
399 
400 	JSA_III_PORT	/* audio board port */
401 
402 	PORT_START		/* analog 0 */
403 	PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_X, 50, 10, 0, 255 )
404 
405 	PORT_START      /* analog 1 */
406 	PORT_ANALOG( 0xff, 0x00, IPT_PEDAL, 100, 16, 0x00, 0xff )
407 INPUT_PORTS_END
408 
409 
410 INPUT_PORTS_START( guardian )
411 	PORT_START		/* e00000 */
412 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED )
413 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON5 | IPF_PLAYER3 )
414 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
415 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER3 )
416 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER3 )
417 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER3 )
418 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER3 )
419 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER3 )
420 	PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
421 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON5 | IPF_PLAYER1 )
422 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
423 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )
424 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
425 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER1 )
426 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER1 )
427 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER1 )
428 
429 	PORT_START      /* e00002 */
430 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
431 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
432 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
433 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
434 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER3 )
435 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
436 	PORT_BIT( 0x01c0, IP_ACTIVE_LOW, IPT_UNUSED )
437 	PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON5 | IPF_PLAYER2 )
438 	PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
439 	PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
440 	PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
441 	PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_PLAYER2 )
442 	PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_PLAYER2 )
443 	PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_PLAYER2 )
444 
445 	PORT_START		/* e00010 */
446 	PORT_BIT( 0x003f, IP_ACTIVE_LOW, IPT_UNUSED )
447 	PORT_SERVICE( 0x0040, IP_ACTIVE_LOW )
448 	PORT_BIT(  0x0080, IP_ACTIVE_LOW, IPT_VBLANK )
449 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
450 
451 	JSA_III_PORT	/* audio board port */
452 
453 	PORT_START		/* analog 0 */
454 	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
455 
456 	PORT_START      /* analog 1 */
457 	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
458 INPUT_PORTS_END
459 
460 
461 
462 /*************************************
463  *
464  *	Graphics definitions
465  *
466  *************************************/
467 
468 static struct GfxLayout pflayout =
469 {
470 	8,8,
471 	RGN_FRAC(1,3),
472 	5,
473 	{ 0, 0, 1, 2, 3 },
474 	{ RGN_FRAC(1,3)+0, RGN_FRAC(1,3)+4, 0, 4, RGN_FRAC(1,3)+8, RGN_FRAC(1,3)+12, 8, 12 },
475 	{ 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
476 	16*8
477 };
478 
479 static struct GfxLayout pftoplayout =
480 {
481 	8,8,
482 	RGN_FRAC(1,3),
483 	6,
484 	{ RGN_FRAC(2,3)+0, RGN_FRAC(2,3)+4, 0, 0, 0, 0 },
485 	{ 3, 2, 1, 0, 11, 10, 9, 8 },
486 	{ 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
487 	16*8
488 };
489 
490 static struct GfxLayout anlayout =
491 {
492 	8,8,
493 	RGN_FRAC(1,1),
494 	4,
495 	{ 0, 1, 2, 3 },
496 	{ 0, 4, 8, 12, 16, 20, 24, 28 },
497 	{ 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
498 	32*8
499 };
500 
501 static struct GfxDecodeInfo gfxdecodeinfo[] =
502 {
503 	{ REGION_GFX1, 0, &pflayout, 0x000, 64 },
504 	{ REGION_GFX2, 0, &anlayout, 0x000, 16 },
505 	{ REGION_GFX1, 0, &pftoplayout, 0x000, 64 },
506 	{ -1 } /* end of array */
507 };
508 
509 
510 
511 /*************************************
512  *
513  *	Machine driver
514  *
515  *************************************/
516 
517 static MACHINE_DRIVER_START( atarig42 )
518 
519 	/* basic machine hardware */
MDRV_CPU_ADD(M68000,ATARI_CLOCK_14MHz)520 	MDRV_CPU_ADD(M68000, ATARI_CLOCK_14MHz)
521 	MDRV_CPU_MEMORY(main_readmem,main_writemem)
522 	MDRV_CPU_VBLANK_INT(atarigen_video_int_gen,1)
523 
524 	MDRV_FRAMES_PER_SECOND(60)
525 	MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
526 
527 	MDRV_MACHINE_INIT(atarig42)
528 	MDRV_NVRAM_HANDLER(atarigen)
529 
530 	/* video hardware */
531 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_NEEDS_6BITS_PER_GUN | VIDEO_UPDATE_BEFORE_VBLANK)
532 	MDRV_SCREEN_SIZE(42*8, 30*8)
533 	MDRV_VISIBLE_AREA(0*8, 42*8-1, 0*8, 30*8-1)
534 	MDRV_GFXDECODE(gfxdecodeinfo)
535 	MDRV_PALETTE_LENGTH(2048)
536 
537 	MDRV_VIDEO_START(atarig42)
538 	MDRV_VIDEO_EOF(atarirle)
539 	MDRV_VIDEO_UPDATE(atarig42)
540 
541 	/* sound hardware */
542 	MDRV_IMPORT_FROM(jsa_iii_mono)
543 MACHINE_DRIVER_END
544 
545 
546 
547 /*************************************
548  *
549  *	ROM definition(s)
550  *
551  *************************************/
552 
553 ROM_START( roadriot )
554 	ROM_REGION( 0x80004, REGION_CPU1, 0 )	/* 8*64k for 68000 code */
555 	ROM_LOAD16_BYTE( "rriot.8d", 0x00000, 0x20000, CRC(bf8aaafc) SHA1(1594d91b56609d49921c866d8f5796619e79217b) )
556 	ROM_LOAD16_BYTE( "rriot.8c", 0x00001, 0x20000, CRC(5dd2dd70) SHA1(8f6a0e809ec1f6feea8a18197a789086a7b9dd6a) )
557 	ROM_LOAD16_BYTE( "rriot.9d", 0x40000, 0x20000, CRC(6191653c) SHA1(97d1a84a585149e8f2c49cab7af22dc755dff350) )
558 	ROM_LOAD16_BYTE( "rriot.9c", 0x40001, 0x20000, CRC(0d34419a) SHA1(f16e9fb4cd537d727611cb7dd5537c030671fe1e) )
559 
560 	ROM_REGION( 0x14000, REGION_CPU2, 0 )	/* 64k for 6502 code */
561 	ROM_LOAD( "rriots.12c", 0x10000, 0x4000, CRC(849dd26c) SHA1(05a0b2a5f7ee4437448b5f076d3066d96dec2320) )
562 	ROM_CONTINUE(           0x04000, 0xc000 )
563 
564 	ROM_REGION( 0xc0000, REGION_GFX1, ROMREGION_DISPOSE )
565 	ROM_LOAD( "rriot.22d",    0x000000, 0x20000, CRC(b7451f92) SHA1(9fd17913630e457e406e596f2d86afff98787750) ) /* playfield, planes 0-1 */
566 	ROM_LOAD( "rriot.22c",    0x020000, 0x20000, CRC(90f3c6ee) SHA1(7607509e2d3b2080a918cfaf2879dbed6b79d029) )
567 	ROM_LOAD( "rriot20.21d",  0x040000, 0x20000, CRC(d40de62b) SHA1(fa6dfd20bdad7874ae33a1027a9bb0ea200f86ca) ) /* playfield, planes 2-3 */
568 	ROM_LOAD( "rriot20.21c",  0x060000, 0x20000, CRC(a7e836b1) SHA1(d41f1e4166ca757176c6976be2a953db5db05e48) )
569 	ROM_LOAD( "rriot.20d",    0x080000, 0x20000, CRC(a81ae93f) SHA1(b694ba5fab35f8fa505a02039ae62f7af3c7ae1d) ) /* playfield, planes 4-5 */
570 	ROM_LOAD( "rriot.20c",    0x0a0000, 0x20000, CRC(b8a6d15a) SHA1(43d2be9d40a84b2c01d80bbcac737eda04d55999) )
571 
572 	ROM_REGION( 0x020000, REGION_GFX2, ROMREGION_DISPOSE )
573 	ROM_LOAD( "rriot.22j",    0x000000, 0x20000, CRC(0005bab0) SHA1(257e1b23eea117fe6701a67134b96d9d9fe10caf) ) /* alphanumerics */
574 
575 	ROM_REGION16_BE( 0x200000, REGION_GFX3, 0 )
576 	ROM_LOAD16_BYTE( "rriot.2s", 0x000000, 0x20000, CRC(19590a94) SHA1(e375b7e01a8b1f366bb4e7750e33f0b6d9ae2042) )
577 	ROM_LOAD16_BYTE( "rriot.2p", 0x000001, 0x20000, CRC(c2bf3f69) SHA1(f822359070b1907973ee7ee35469f4a59f720830) )
578 	ROM_LOAD16_BYTE( "rriot.3s", 0x040000, 0x20000, CRC(bab110e4) SHA1(0c4e3521474249517e7832df1bc63aca6d6a6c91) )
579 	ROM_LOAD16_BYTE( "rriot.3p", 0x040001, 0x20000, CRC(791ad2c5) SHA1(4ef218fbf38a9c6b58c86f203843988df1c935f6) )
580 	ROM_LOAD16_BYTE( "rriot.4s", 0x080000, 0x20000, CRC(79cba484) SHA1(ce361a432f1fe627086bab3c1131118fd15056f1) )
581 	ROM_LOAD16_BYTE( "rriot.4p", 0x080001, 0x20000, CRC(86a2e257) SHA1(98d95d2e67fecc332f6c66358a1f8d58b168c74b) )
582 	ROM_LOAD16_BYTE( "rriot.5s", 0x0c0000, 0x20000, CRC(67d28478) SHA1(cfc9da6d20c65d11c2a59a38660a8da4d1cc219d) )
583 	ROM_LOAD16_BYTE( "rriot.5p", 0x0c0001, 0x20000, CRC(74638838) SHA1(bea0fb21ccb946e023c88791ce5a8dd92b44baec) )
584 	ROM_LOAD16_BYTE( "rriot.6s", 0x100000, 0x20000, CRC(24933c37) SHA1(516393aae51fc9634a5c6d5134be058d6067e114) )
585 	ROM_LOAD16_BYTE( "rriot.6p", 0x100001, 0x20000, CRC(054a163b) SHA1(1b0b129c093398bc5c14b3fdd87dfe149f555fac) )
586 	ROM_LOAD16_BYTE( "rriot.7s", 0x140000, 0x20000, CRC(31ff090a) SHA1(7b43ed37901c3f94cae90c84b3c8c689d7b64dd6) )
587 	ROM_LOAD16_BYTE( "rriot.7p", 0x140001, 0x20000, CRC(bbe5b69b) SHA1(9eaa551fba763824d36fc41bfe0e6d735a9e68c5) )
588 	ROM_LOAD16_BYTE( "rriot.8s", 0x180000, 0x20000, CRC(6c89d2c5) SHA1(0bf2990ce1cd5ec5b84f7e3171725540e6238408) )
589 	ROM_LOAD16_BYTE( "rriot.8p", 0x180001, 0x20000, CRC(40d9bde5) SHA1(aca6e07ea96e4618412d32fe4d4cd293ae82d940) )
590 	ROM_LOAD16_BYTE( "rriot.9s", 0x1c0000, 0x20000, CRC(eca3c595) SHA1(5d067b7c02675b1e6dd3c4046697a16f873f80af) )
591 	ROM_LOAD16_BYTE( "rriot.9p", 0x1c0001, 0x20000, CRC(88acdb53) SHA1(5bf2424ee75a25248a8ce38c8605b6780da4e323) )
592 
593 	ROM_REGION( 0x100000, REGION_SOUND1, 0 )	/* 1MB for ADPCM samples */
594 	ROM_LOAD( "rriots.19e",  0x80000, 0x20000, CRC(2db638a7) SHA1(45da8088f7439beacc3056952a4d631d9633efa7) )
595 	ROM_LOAD( "rriots.17e",  0xa0000, 0x20000, CRC(e1dd7f9e) SHA1(6b9a240aa84d210d3052daab6ea26f9cd0e62dc1) )
596 	ROM_LOAD( "rriots.15e",  0xc0000, 0x20000, CRC(64d410bb) SHA1(877bccca7ff37a9dd8294bc1453487a2f516ca7d) )
597 	ROM_LOAD( "rriots.12e",  0xe0000, 0x20000, CRC(bffd01c8) SHA1(f6de000f61ea0c1ddb31ee5301506e5e966638c2) )
598 
599 	ROM_REGION( 0x0600, REGION_PROMS, ROMREGION_DISPOSE )	/* microcode for growth renderer */
600 	ROM_LOAD( "089-1001.bin",  0x0000, 0x0200, CRC(5836cb5a) SHA1(2c797f6a1227d6e1fd7a12f99f0254072c8c266e) )
601 	ROM_LOAD( "089-1002.bin",  0x0200, 0x0200, CRC(44288753) SHA1(811582015264f85a32643196cdb331a41430318f) )
602 	ROM_LOAD( "089-1003.bin",  0x0400, 0x0200, CRC(1f571706) SHA1(26d5ea59163b3482ab1f8a26178d0849c5fd9692) )
603 ROM_END
604 
605 
606 ROM_START( guardian )
607 	ROM_REGION( 0x80004, REGION_CPU1, 0 )	/* 8*64k for 68000 code */
608 	ROM_LOAD16_BYTE( "2021.8e",  0x00000, 0x20000, CRC(efea1e02) SHA1(f0f1ef300f36953aff73b68ffe6d9950ac575f7d) )
609 	ROM_LOAD16_BYTE( "2020.8cd", 0x00001, 0x20000, CRC(a8f655ba) SHA1(2defe4d138613e248718a617d103794e051746f7) )
610 	ROM_LOAD16_BYTE( "2023.9e",  0x40000, 0x20000, CRC(cfa29316) SHA1(4e0e76304e29ee59bc2ce9a704e3f651dc9d473c) )
611 	ROM_LOAD16_BYTE( "2022.9cd", 0x40001, 0x20000, CRC(ed2abc91) SHA1(81531040d5663f6ab82e924210056e3737e17a8d) )
612 
613 	ROM_REGION( 0x14000, REGION_CPU2, 0 )	/* 64k for 6502 code */
614 	ROM_LOAD( "0080-snd.12c", 0x10000, 0x4000, CRC(0388f805) SHA1(49c11313bc4192dbe294cf68b652cb19047889fd) )
615 	ROM_CONTINUE(             0x04000, 0xc000 )
616 
617 	ROM_REGION( 0x180000, REGION_GFX1, ROMREGION_DISPOSE )
618 	ROM_LOAD( "0037a.23e",  0x000000, 0x80000, CRC(ca10b63e) SHA1(243a2a440e1bc9135d3dbe6553d39c54b9bdcd13) ) /* playfield, planes 0-1 */
619 	ROM_LOAD( "0038a.22e",  0x080000, 0x80000, CRC(cb1431a1) SHA1(d7b8f49a1e794ca2083e4bf0fa3870ce08caa53a) ) /* playfield, planes 2-3 */
620 	ROM_LOAD( "0039a.20e",  0x100000, 0x80000, CRC(2eee7188) SHA1(d3adbd7b20bc898fee35b6ba781e7775f82acd19) ) /* playfield, planes 4-5 */
621 
622 	ROM_REGION( 0x020000, REGION_GFX2, ROMREGION_DISPOSE )
623 	ROM_LOAD( "0030.23k",   0x000000, 0x20000, CRC(0fd7baa1) SHA1(7802d732e5173291628ed498ad0fab71aeef4688) ) /* alphanumerics */
624 
625 	ROM_REGION16_BE( 0x600000, REGION_GFX3, 0 )
626 	ROM_LOAD16_BYTE( "0041.2s",  0x000000, 0x80000, CRC(a2a5ae08) SHA1(d99f925bbc9a72432e13328ee8422fde615db90f) )
627 	ROM_LOAD16_BYTE( "0040.2p",  0x000001, 0x80000, CRC(ef95132e) SHA1(288de1d15956a612b7d19ceb2cf853490bf42b05) )
628 	ROM_LOAD16_BYTE( "0043.3s",  0x100000, 0x80000, CRC(6438b8e4) SHA1(ee1446209fbcab8b17c88c53b65e754a85f279d1) )
629 	ROM_LOAD16_BYTE( "0042.3p",  0x100001, 0x80000, CRC(46bf7c0d) SHA1(12414de2698178b158ec4ca0fbb176943c944cec) )
630 	ROM_LOAD16_BYTE( "0045.4s",  0x200000, 0x80000, CRC(4f4f2bee) SHA1(8276cdcd252d2d8fa41ab28e76a6bd72613c14ec) )
631 	ROM_LOAD16_BYTE( "0044.4p",  0x200001, 0x80000, CRC(20a4250b) SHA1(6a2e2596a9eef2792f7cdab648dd455b8e420a74) )
632 	ROM_LOAD16_BYTE( "0063a.6s", 0x300000, 0x80000, CRC(93933bcf) SHA1(a67d4839ffdb0eafbc2d68a60fb3bf1507c793cf) )
633 	ROM_LOAD16_BYTE( "0062a.6p", 0x300001, 0x80000, CRC(613e6f1d) SHA1(fd2ea18d245d0895e0bac6c5caa6d35fdd6a199f) )
634 	ROM_LOAD16_BYTE( "0065a.7s", 0x400000, 0x80000, CRC(6bcd1205) SHA1(c883c55f88d274ba8aa48c962406b253e1f8001e) )
635 	ROM_LOAD16_BYTE( "0064a.7p", 0x400001, 0x80000, CRC(7b4dce05) SHA1(36545917388e704f73a9b4d85189ec978d655b63) )
636 	ROM_LOAD16_BYTE( "0067a.9s", 0x500000, 0x80000, CRC(15845fba) SHA1(f7b670a8d48a5e9c261150914a06ef9a938a84e7) )
637 	ROM_LOAD16_BYTE( "0066a.9p", 0x500001, 0x80000, CRC(7130c575) SHA1(b3ea109981a1e5c631705b23dfad4a3a3daf7734) )
638 
639 	ROM_REGION( 0x100000, REGION_SOUND1, 0 )	/* 1MB for ADPCM samples */
640 	ROM_LOAD( "0010-snd",  0x80000, 0x80000, CRC(bca27f40) SHA1(91a41eac116eb7d9a790abc590eb06328726d1c2) )
641 
642 	ROM_REGION( 0x0600, REGION_PROMS, ROMREGION_DISPOSE )	/* microcode for growth renderer */
643 	ROM_LOAD( "092-1001.bin",  0x0000, 0x0200, CRC(b3251eeb) SHA1(5e83baa70aaa28f07f32657bf974fd87719972d3) )
644 	ROM_LOAD( "092-1002.bin",  0x0200, 0x0200, CRC(0c5314da) SHA1(a9c7ee3ab015c7f3ada4200acd2854eb9a5c74b0) )
645 	ROM_LOAD( "092-1003.bin",  0x0400, 0x0200, CRC(344b406a) SHA1(f4422f8c0d7004d0277a4fc77718d555f80fcf69) )
646 ROM_END
647 
648 
649 
650 /*************************************
651  *
652  *	Driver initialization
653  *
654  *************************************/
655 
656 static DRIVER_INIT( roadriot )
657 {
658 	static const UINT16 default_eeprom[] =
659 	{
660 		0x0001,0x01B7,0x01AF,0x01E4,0x0100,0x0130,0x0300,0x01CC,
661 		0x0700,0x01FE,0x0500,0x0102,0x0200,0x0108,0x011B,0x01C8,
662 		0x0100,0x0107,0x0120,0x0100,0x0125,0x0500,0x0177,0x0162,
663 		0x013A,0x010A,0x01B7,0x01AF,0x01E4,0x0100,0x0130,0x0300,
664 		0x01CC,0x0700,0x01FE,0x0500,0x0102,0x0200,0x0108,0x011B,
665 		0x01C8,0x0100,0x0107,0x0120,0x0100,0x0125,0x0500,0x0177,
666 		0x0162,0x013A,0x010A,0xE700,0x0164,0x0106,0x0100,0x0104,
667 		0x01B0,0x0146,0x012E,0x1A00,0x01C8,0x01D0,0x0118,0x0D00,
668 		0x0118,0x0100,0x01C8,0x01D0,0x0000
669 	};
670 	atarigen_eeprom_default = default_eeprom;
671 	atarijsa_init(1, 3, 2, 0x0040);
672 	atarijsa3_init_adpcm(REGION_SOUND1);
673 
674 	atarig42_playfield_base = 0x400;
675 	atarig42_motion_object_base = 0x200;
676 	atarig42_motion_object_mask = 0x1ff;
677 
678 	sloop_base = install_mem_read16_handler(0, 0x000000, 0x07ffff, roadriot_sloop_data_r);
679 	sloop_base = install_mem_write16_handler(0, 0x000000, 0x07ffff, roadriot_sloop_data_w);
680 
681 	asic65_config(ASIC65_STANDARD);
682 /*
683 	Road Riot color MUX
684 
685 	CRA10=!MGEP*!AN.VID7*AN.0				-- if (mopri < pfpri) && (!alpha)
686 	   +!AN.VID7*AN.0*MO.0					or if (mopix == 0) && (!alpha)
687 
688 	CRA9=MGEP*!AN.VID7*AN.0*!MO.0			-- if (mopri >= pfpri) && (mopix != 0) && (!alpha)
689 	   +!AN.VID7*AN.0*PF.VID9				or if (pfpix & 0x200) && (!alpha)
690 
691 	CRA8=MGEP*!AN.VID7*AN.0*!MO.0*MVID8		-- if (mopri >= pfpri) && (mopix != 0) && (mopix & 0x100) && (!alpha)
692 	   +!MGEP*!AN.VID7*AN.0*PF.VID8			or if (mopri < pfpri) && (pfpix & 0x100) && (!alpha)
693 	   +!AN.VID7*AN.0*MO.0*PF.VID8			or if (pfpix & 0x100) && (!alpha)
694 
695 	CRMUXB=!AN.VID7*AN.0					-- if (!alpha)
696 
697 	CRMUXA=!MGEP							-- if (mopri < pfpri)
698 	   +MO.0								or (mopix == 0)
699 	   +AN.VID7								or (alpha)
700 	   +!AN.0
701 */
702 }
703 
704 
DRIVER_INIT(guardian)705 static DRIVER_INIT( guardian )
706 {
707 	static const UINT16 default_eeprom[] =
708 	{
709 		0x0001,0x01FD,0x01FF,0x01EF,0x0100,0x01CD,0x0300,0x0104,
710 		0x0700,0x0117,0x0F00,0x0133,0x1F00,0x0133,0x2400,0x0120,
711 		0x0600,0x0104,0x0300,0x010C,0x01A0,0x0100,0x0152,0x0179,
712 		0x012D,0x01BD,0x01FD,0x01FF,0x01EF,0x0100,0x01CD,0x0300,
713 		0x0104,0x0700,0x0117,0x0F00,0x0133,0x1F00,0x0133,0x2400,
714 		0x0120,0x0600,0x0104,0x0300,0x010C,0x01A0,0x0100,0x0152,
715 		0x0179,0x012D,0x01BD,0x8C00,0x0118,0x01AB,0x015A,0x0100,
716 		0x01D0,0x010B,0x01B8,0x01C7,0x01E2,0x0134,0x0100,0x010A,
717 		0x01BE,0x016D,0x0142,0x0100,0x0120,0x0109,0x0110,0x0141,
718 		0x0109,0x0100,0x0108,0x0134,0x0105,0x0148,0x1400,0x0000
719 	};
720 	atarigen_eeprom_default = default_eeprom;
721 	atarijsa_init(1, 3, 2, 0x0040);
722 	atarijsa3_init_adpcm(REGION_SOUND1);
723 
724 	atarig42_playfield_base = 0x000;
725 	atarig42_motion_object_base = 0x400;
726 	atarig42_motion_object_mask = 0x3ff;
727 
728 	/* it looks like they jsr to $80000 as some kind of protection */
729 	/* put an RTS there so we don't die */
730 	*(data16_t *)&memory_region(REGION_CPU1)[0x80000] = 0x4E75;
731 
732 	sloop_base = install_mem_read16_handler(0, 0x000000, 0x07ffff, guardians_sloop_data_r);
733 	sloop_base = install_mem_write16_handler(0, 0x000000, 0x07ffff, guardians_sloop_data_w);
734 
735 	asic65_config(ASIC65_GUARDIANS);
736 /*
737 	Guardians color MUX
738 
739 	CRA10=MGEP*!AN.VID7*AN.0*!MO.0			-- if (mopri >= pfpri) && (!alpha) && (mopix != 0)
740 
741 	CRA9=MGEP*!AN.VID7*AN.0*!MO.0*MVID9		-- if (mopri >= pfpri) && (!alpha) && (mopix != 0) && (mopix & 0x200)
742 	   +!MGEP*!AN.VID7*AN.0*PF.VID9			or if (mopri < pfpri) && (!alpha) && (pfpix & 0x200)
743 	   +!AN.VID7*AN.0*MO.0*PF.VID9			or if (mopix == 0) && (!alpha) && (pfpix & 0x200)
744 
745 	CRA8=MGEP*!AN.VID7*AN.0*!MO.0*MVID8		-- if (mopri >= pfpri) && (!alpha) && (mopix != 0) && (mopix & 0x100)
746 	   +!MGEP*!AN.VID7*AN.0*PF.VID8			or if (mopri < pfpri) && (!alpha) && (pfpix & 0x100)
747 	   +!AN.VID7*AN.0*MO.0*PF.VID8			or if (mopix == 0) && (!alpha) && (pfpix & 0x100)
748 
749 	CRMUXB=!AN.VID7*AN.0					-- if (!alpha)
750 
751 	CRMUXA=!MGEP							-- if (mopri < pfpri)
752 	   +MO.0								or (mopix == 0)
753 	   +AN.VID7								or (alpha)
754 	   +!AN.0
755 */
756 }
757 
758 
759 
760 /*************************************
761  *
762  *	Game driver(s)
763  *
764  *************************************/
765 
766 GAMEX( 1991, roadriot, 0,        atarig42, roadriot, roadriot, ROT0, "Atari Games", "Road Riot 4WD", GAME_UNEMULATED_PROTECTION )
767 GAME ( 1992, guardian, 0,        atarig42, guardian, guardian, ROT0, "Atari Games", "Guardians of the Hood" )
768