1 /***************************************************************************
2 
3 							Speed Buggy / Buggy Boy
4 
5 							  (C) 1986 Data East
6 							  Developed by Tatsumi
7 
8 				    driver by Luca Elia (eliavit@unina.it)
9 
10 CPU   : AMD 8086 x 2	Z80
11 SOUND : 8253?	2 x 2149?
12 OSC.  : ?
13 
14 Hardware-wise, it uses some funky stuff too. The sound system is pretty
15 standard... Z80, 8253 and two YM2149's, but I don't see anything I'm
16 familiar with CPU-wise. It's got two 40 pin NEC 70116 chips and a 40 pin
17 Hitachi 46505.
18 
19 Test
20 1000-1003
21 write 1004-1005
22 6 words before 300
23 3 words before 00a
24 read word 3f00 & 300e
25 clear 1800-1eff
26 
27 chcksum 0-3fff even:	5ac4 -> [670]
28 chcksum 0-3fff odd :	2c77 -> [672]
29 
30 added together (=873b), subtracted [f840] (=87d9)
31 
32 1000
33 1400	error text written ($34 words)
34 
35 ***************************************************************************/
36 #include "driver.h"
37 
38 #if 0
39 static data8_t *sharedram;
40 #endif
41 
42 /* Variables defined in vidhrdw */
43 unsigned char *spdbuggy_bgram, *spdbuggy_fgram;
44 unsigned char *spdbuggy_ram, *spdbuggy_ram2;
45 
46 /* Functions defined in vidhrdw */
47 WRITE_HANDLER( spdbuggy_bgram_w );
48 WRITE_HANDLER( spdbuggy_fgram_w );
49 
50 WRITE_HANDLER( spdbuggy_scrollregs_w );
51 
52 VIDEO_START( spdbuggy );
53 VIDEO_UPDATE( spdbuggy );
54 
55 
56 
57 /***************************************************************************
58 
59 
60 								Main CPU
61 
62 
63 ***************************************************************************/
64 #if 0
65 static READ_HANDLER ( sharedram_r )	{ return sharedram[offset]; }
66 static WRITE_HANDLER( sharedram_w )	{ sharedram[offset] = data; }
67 #endif
68 
69 /*
70 	a9e.b	accel (00-70?)
71 	aa0.b	brake
72 	52a.b	steering
73 
74 	aa6.b
75 		0	coin 1	(1276.b)
76 		1	coin 2	(1277.b)
77 		2	coin 3	(1278.b)
78 
79 		6	start?
80 		7	?
81 
82 	aa8.b
83 		0	shift
84 		7	service / coin3
85 
86 
87 [Main]
88 	8000-8fff	text ram (words)
89 	a400		shared with sub 1800
90 
91 */
READ_HANDLER(spdbuggy_ram_r)92 READ_HANDLER( spdbuggy_ram_r )
93 {
94 	switch (offset)
95 	{
96 		case 0x0aa6:
97 		case 0x0aa7:
98 		case 0x0aa8:
99 		case 0x0aa9:	return 0xff;
100 
101 		default:		return spdbuggy_ram[offset];
102 	}
103 }
104 
105 // f002 read : watchdog reset
MEMORY_READ_START(spdbuggy_readmem)106 static MEMORY_READ_START ( spdbuggy_readmem )
107 	{ 0x00000, 0x023ff, MRA_RAM },
108 
109 	{ 0x08000, 0x08fff, MRA_RAM },
110 	{ 0x0a000, 0x0afff, MRA_RAM },	// shared?
111 	{ 0x18000, 0x18fff, MRA_RAM },
112 
113 	{ 0x10000, 0x17fff, MRA_ROM },
114 	{ 0x20000, 0x2ffff, MRA_ROM },
115 	{ 0xf0000, 0xfffff, MRA_ROM },
116 MEMORY_END
117 
118 static MEMORY_WRITE_START ( spdbuggy_writemem )
119 	{ 0x00000, 0x023ff, MWA_RAM },
120 
121 	{ 0x08000, 0x08fff, spdbuggy_fgram_w, &spdbuggy_fgram	},	// fg
122 	{ 0x18000, 0x18fff, spdbuggy_bgram_w, &spdbuggy_bgram	},	// bg
123 	{ 0x0a000, 0x0afff, MWA_RAM },	// shared?
124 
125 	{ 0x10000, 0x17fff, MWA_ROM },
126 	{ 0x20000, 0x2ffff, MWA_ROM },
127 	{ 0xf0000, 0xfffff, MWA_ROM },
128 MEMORY_END
129 
130 
131 
132 
133 
134 
135 /***************************************************************************
136 
137 
138 									Sub CPU
139 
140 
141 ***************************************************************************/
142 
143 
144 READ_HANDLER( spdbuggy_ram2_r )
145 {
146 	switch (offset)
147 	{
148 		case 0x3e00:
149 		case 0x3e01:
150 		{
151 			unsigned char *fn_rom = memory_region( REGION_USER1 );
152 			int bank = spdbuggy_ram2[0x3680] & 7;
153 			int fn_offs = (spdbuggy_ram2[0x3601]*256 + spdbuggy_ram2[0x3600])&0x7ff;
154 
155 			return fn_rom[bank * 0x800 + fn_offs + 0x4000 * (offset&1)];
156 		}
157 		default:	return spdbuggy_ram2[offset];
158 	}
159 }
160 
161 
MEMORY_READ_START(spdbuggy_readmem2)162 static MEMORY_READ_START ( spdbuggy_readmem2 )
163 	{ 0x0000, 0x7fff, spdbuggy_ram2_r },
164 	{ 0x8000, 0xffff, MRA_ROM },
165 MEMORY_END
166 
167 static MEMORY_WRITE_START ( spdbuggy_writemem2 )
168 	{ 0x0000, 0x7fff, MWA_RAM, &spdbuggy_ram2 },
169 	{ 0x8000, 0xffff, MWA_ROM },
170 MEMORY_END
171 
172 
173 
174 
175 
176 
177 /***************************************************************************
178 
179 
180 								Input Ports
181 
182 
183 ***************************************************************************/
184 
185 INPUT_PORTS_START( spdbuggy )
186 
187 	PORT_START	// IN0 - Player 1
188 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
189 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
190 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
191 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
192 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
193 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
194 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
195 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
196 
197 	PORT_START	// IN1 - Player 2
198 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
199 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
200 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
201 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
202 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
203 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
204 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
205 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
206 
207 	PORT_START	// IN2 - Service
208 	PORT_BIT(  0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
209 	PORT_BIT(  0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
210 	PORT_BIT(  0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
211 	PORT_BIT(  0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
212 	PORT_BIT(  0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
213 	PORT_BIT(  0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
214 	PORT_BIT(  0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
215 	PORT_BIT(  0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
216 
217 	PORT_START	// IN3 - $aa6 - DSW 1
218 	PORT_DIPNAME( 0x01, 0x01, "Unknown 1-0" )
219 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
220 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
221 	PORT_DIPNAME( 0x02, 0x02, "Unknown 1-1" )
222 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
223 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
224 	PORT_DIPNAME( 0x04, 0x04, "Unknown 1-2" )
225 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
226 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
227 	PORT_DIPNAME( 0x08, 0x08, "Unknown 1-3" )
228 	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
229 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
230 	PORT_DIPNAME( 0x10, 0x10, "Unknown 1-4" )
231 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
232 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
233 	PORT_DIPNAME( 0x20, 0x20, "Unknown 1-5" )
234 	PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
235 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
236 	PORT_DIPNAME( 0x40, 0x40, "Unknown 1-6" )
237 	PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
238 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
239 	PORT_DIPNAME( 0x80, 0x80, "Unknown 1-7" )
240 	PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
241 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
242 
243 	PORT_START	// IN4 - $aa8 - DSW 2
244 	PORT_DIPNAME( 0x01, 0x01, "Unknown 2-0" )
245 	PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
246 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
247 	PORT_DIPNAME( 0x02, 0x02, "Unknown 2-1" )
248 	PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
249 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
250 	PORT_DIPNAME( 0x04, 0x04, "Unknown 2-2" )
251 	PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
252 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
253 	PORT_DIPNAME( 0x08, 0x08, "Unknown 2-3" )
254 	PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
255 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
256 	PORT_DIPNAME( 0x10, 0x10, "Unknown 2-4" )
257 	PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
258 	PORT_DIPSETTING(    0x00, DEF_STR( On ) )
259 	PORT_DIPNAME( 0x60, 0x60, "Copyright" )
260 	PORT_DIPSETTING(    0x60, "Tatsumi" )
261 	PORT_DIPSETTING(    0x40, "Taito" )
262 	PORT_DIPSETTING(    0x20, "Data East" )	// BUGGY BOY
263 	PORT_DIPSETTING(    0x00, "Tatsumi" )
264 	PORT_DIPNAME( 0x80, 0x80, "Coin Slots" )
265 	PORT_DIPSETTING(    0x80, "2" )
266 	PORT_DIPSETTING(    0x00, "3" )
267 
268 INPUT_PORTS_END
269 
270 
271 
272 /***************************************************************************
273 
274 
275 								Gfx Layouts
276 
277 
278 ***************************************************************************/
279 
280 #define LAYOUT_PLANAR_8x8x2(_name_,_romsize_) \
281 static struct GfxLayout _name_ =\
282 {\
283 	8,8,\
284 	(_romsize_)*8/(8*8*2),\
285 	2,\
286 	{ 0, ((_romsize_) / 2) * 8},\
287 	{0,1,2,3,4,5,6,7},\
288 	{0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8},\
289 	8*8\
290 };
291 
292 #if 0
293 #define LAYOUT_CHUNKY_16x16x8(_name_,_romsize_) \
294 static struct GfxLayout _name_ =\
295 {\
296 	32,16,\
297 	(_romsize_)*8/(32*16*4),\
298 	4,\
299 	{0, 1, 2, 3},\
300 	{0*4,1*4,2*4,3*4,4*4,5*4,6*4,7*4, \
301 	 8*4,9*4,10*4,11*4,12*4,13*4,14*4,15*4, \
302 	 16*4,17*4,18*4,19*4,20*4,21*4,22*4,23*4, \
303 	 24*4,25*4,26*4,27*4,28*4,29*4,30*4,31*4}, \
304 	{0*128,1*128,2*128,3*128,4*128,5*128,6*128,7*128,\
305 	 8*128,9*128,10*128,11*128,12*128,13*128,14*128,15*128}, \
306 	32*16*4\
307 };
308 #else
309 #define LAYOUT_CHUNKY_16x16x8(_name_,_romsize_) \
310 static struct GfxLayout _name_ =\
311 {\
312 	64,64,\
313 	(_romsize_)*8/(64*16*4),\
314 	4,\
315 	{0, 1, ((_romsize_)/2)*8,((_romsize_)/2)*8+1 }, \
316 	{0*2,1*2,2*2,3*2,4*2,5*2,6*2,7*2, \
317 	 8*2,9*2,10*2,11*2,12*2,13*2,14*2,15*2, \
318 	 16*2,17*2,18*2,19*2,20*2,21*2,22*2,23*2, \
319 	 24*2,25*2,26*2,27*2,28*2,29*2,30*2,31*2, \
320 \
321 	 32*2,33*2,34*2,35*2,36*2,37*2,38*2,39*2, \
322 	 40*2,41*2,42*2,43*2,44*2,45*2,46*2,47*2, \
323 	 48*2,49*2,50*2,51*2,52*2,53*2,54*2,55*2, \
324 	 56*2,57*2,58*2,59*2,60*2,61*2,62*2,63*2}, \
325 \
326 	{0*128,0*128,0*128,0*128,1*128,1*128,1*128,1*128,\
327 	 2*128,2*128,2*128,2*128,3*128,3*128,3*128,3*128, \
328 	 4*128,4*128,4*128,4*128,5*128,5*128,5*128,5*128, \
329 	 6*128,6*128,6*128,6*128,7*128,7*128,7*128,7*128, \
330 \
331 	 8*128,8*128,8*128,8*128,9*128,9*128,9*128,9*128,\
332 	 10*128,10*128,10*128,10*128,11*128,11*128,11*128,11*128, \
333 	 12*128,12*128,12*128,12*128,13*128,13*128,13*128,13*128, \
334 	 14*128,14*128,14*128,14*128,15*128,15*128,15*128,15*128}, \
335 	64*16*2\
336 };
337 
338 #endif
339 
340 #if 0
341 
342 static struct GfxLayout _name_ =\
343 {\
344 	16,16,\
345 	(_romsize_)*8/(16*16*8),\
346 	8,\
347 	{0, 1, 2, 3, 4, 5, 6, 7},\
348 	{0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8, \
349 	 8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8}, \
350 	{0*128,1*128,2*128,3*128,4*128,5*128,6*128,7*128,\
351 	 8*128,9*128,10*128,11*128,12*128,13*128,14*128,15*128}, \
352 	16*16*8\
353 };
354 
355 #endif
356 
357 LAYOUT_PLANAR_8x8x2( tilelayout, 0x30000 )
358 LAYOUT_PLANAR_8x8x2( charlayout, 0x08000 )
359 
360 LAYOUT_CHUNKY_16x16x8( spritelayout,			 0x10000 )
361 
362 
363 static struct GfxDecodeInfo gfxdecodeinfo[] =
364 {
365 	{ REGION_GFX1, 0x000000, &tilelayout,   256*0, 16 }, // [0] bg
366 	{ REGION_GFX1, 0x030000, &charlayout,   256*1, 16 }, // [1] txt
367 	{ REGION_GFX1, 0x038000, &spritelayout, 256*2, 16 }, // [2] sprites
368 	{ -1 }
369 };
370 
371 
372 static MACHINE_DRIVER_START( spdbuggy )
373 
374 	/* basic machine hardware */
375 	MDRV_CPU_ADD(V20, 4000000)	/* ?? */
376 	MDRV_CPU_MEMORY(spdbuggy_readmem,spdbuggy_writemem)
377 
378 	MDRV_CPU_ADD(V20, 4000000)	/* ?? */
379 	MDRV_CPU_MEMORY(spdbuggy_readmem2,spdbuggy_writemem2)
380 
381 	MDRV_FRAMES_PER_SECOND(60)
382 	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)
383 
384 	/* video hardware */
385 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
386 	MDRV_SCREEN_SIZE(256, 256)
387 	MDRV_VISIBLE_AREA(0, 256-1, 0, 256-1)
388 	MDRV_GFXDECODE(gfxdecodeinfo)
389 	MDRV_PALETTE_LENGTH(256 * 3)
390 	MDRV_COLORTABLE_LENGTH(256 * 3)
391 
392 	MDRV_VIDEO_START(spdbuggy)
393 	MDRV_VIDEO_UPDATE(spdbuggy)
394 
395 	/* sound hardware */
396 MACHINE_DRIVER_END
397 
398 
399 
400 /***************************************************************************
401 
402   Game driver(s)
403 
404 CPU AMD 8086 X2
405 SOUND ? MISSING SOUND ROM
406 
407 Luca:
408 ic25.2                                          FIRST AND SECOND HALF IDENTICAL
409 ic26.3                                          FIRST AND SECOND HALF IDENTICAL
410 ic32.11                                                    1xxxxxxxxxxxx = 0xFF
411 ic95.4                                          BAD ADDRESS LINES (mask=000010)
412 ic162-30.bin                                    FIXED BITS (0000xxxx)
413 ic190-31.bin                                    FIXED BITS (0000xxxx)
414 ic189-15.bin                                    FIXED BITS (0000xxxx)
415 ic31-23.bin                                     FIXED BITS (0000xxxx)
416 ic39-24.bin                                     FIXED BITS (0000xxxx)
417 ic40-25.bin                                     FIXED BITS (0000xxxx)
418 ic41-26.bin                                     FIXED BITS (0000xxxx)
419 ic42-27.bin                                     FIXED BITS (00001xxx)
420 ic19-22.bin                                     FIXED BITS (0000xxxx)
421 ic162-30.bin            ic190-31.bin            IDENTICAL
422 
423 (4 bits)
424 IC189-15 BIN           256
425 IC31-23  BIN           256
426 IC39-24  BIN           256
427 IC40-25  BIN           256
428 IC41-26  BIN           256
429 IC42-27  BIN           256
430 IC19-22  BIN           256
431 IC162-30 BIN         2.048\	Identical
432 IC190-31 BIN         2.048/
433 
434 IC32     11          8.192
435 
436 IC95     4          16.384	bad fn_data odd?
437 IC138    5          16.384	fn_data even
438 
439 IC46     12         16.384	planar 8x8	(charset)
440 IC47     13         16.384	planar 8x8
441 
442 IC139    14         32.768	chunky 16x16x8?
443 IC140    15         32.768	""
444 IC141    17         16.384	""
445 
446 IC142    16         32.768	planar 8x8
447 IC145    20         32.768	planar 8x8
448 
449 IC43     18         32.768	planar 8x8
450 IC146    21         32.768	planar 8x8
451 
452 IC144    19         32.768	planar 8x8
453 IC147    22         32.768	planar 8x8
454 
455 IC26     3          16.384	sub even
456 IC25     2          16.384	sub odd
457 
458 IC213    8          32.768	main even
459 IC174    6          32.768	main odd
460 IC214    9          32.768	main even
461 IC175    7          32.768	main odd
462 
463 IC225    10         16.384	main even???
464 
465 
466 ***************************************************************************/
467 
468 ROM_START( spdbuggy )
469 	ROM_REGION( 0x100000, REGION_CPU1, 0 )		/* Main CPU Code */
470 	ROM_LOAD16_BYTE( "ic174.6",  0xf0001, 0x08000, CRC(5e352d8d) SHA1(350c206b5241d5628e673ce1108f728c8c4f980c) )
471 	ROM_LOAD16_BYTE( "ic213.8",  0xf0000, 0x08000, CRC(abcc8ad2) SHA1(aeb695c3675d40a951fe8272cbf0f6673435dab8) )
472 
473 	ROM_LOAD16_BYTE( "ic175.7",  0x20001, 0x08000, CRC(40ce3930) SHA1(4bf62ebeea1549a13a21a32cb860717f064b186a) )
474 	ROM_LOAD16_BYTE( "ic214.9",  0x20000, 0x08000, CRC(92797c25) SHA1(8f7434abbd7f557d3202abb01b1e4899c82c67a5) )
475 
476 	ROM_LOAD16_BYTE( "ic225.10", 0x10000, 0x04000, CRC(771af4e1) SHA1(a42b164dd0567c78c0d308ee48d63e5a284897bb) )
477 
478 	ROM_REGION( 0x100000, REGION_CPU2, 0 )		/* Sub CPU Code */
479 	ROM_LOAD16_BYTE( "ic25.2", 0x08001, 0x04000, CRC(197beee2) SHA1(5f6ccdb8a8a732f8767690e166a5b648e5cace39) )
480 	ROM_LOAD16_BYTE( "ic26.3", 0x08000, 0x04000, CRC(e91d4eef) SHA1(0da4bf5e1443b57df188316be4094a9ae0c69c81) )
481 
482 	ROM_REGION( 0x010000, REGION_CPU3, 0 )		/* Sound CPU Code */
483 
484 	ROM_REGION( 0x100000, REGION_GFX1, ROMREGION_DISPOSE )	/* */
485 	ROM_LOAD( "ic142.16", 0x00000, 0x08000, CRC(015db5d8) SHA1(39ef8b44f2eb9399fb1555cffa6763e06d59c181) )	// 8x8 plane 1
486 	ROM_LOAD( "ic43.18",  0x08000, 0x08000, CRC(876a5666) SHA1(db485cdf35f63c080c919ee86374f63e577092c3) )
487 	ROM_LOAD( "ic144.19", 0x10000, 0x08000, CRC(838e0697) SHA1(0e9aff2c4065d79350ddb55edff57a899c33ef1c) )
488 	ROM_LOAD( "ic145.20", 0x18000, 0x08000, CRC(11d8e2a8) SHA1(9bf198229a12d331e8e7352b7ee3f39f6891f517) )	// 8x8 plane 2
489 	ROM_LOAD( "ic146.21", 0x20000, 0x08000, CRC(8b47d227) SHA1(a3e57594ad0085e8b1bd327c580eb36237f3e3d2) )
490 	ROM_LOAD( "ic147.22", 0x28000, 0x08000, CRC(14033710) SHA1(e05afeb557ce14055fa8b4f6d8805307feaa1660) )
491 
492 	/* halves swapped */
493 	ROM_LOAD( "ic46.12",  0x32000, 0x02000, CRC(8ea8fec4) SHA1(75e67c9a59a86fcdedf2a70fafd303baa552aa18) )	// 8x8 plane 1 (charset)
494 	ROM_CONTINUE(         0x30000, 0x02000             )
495 	ROM_LOAD( "ic47.13",  0x36000, 0x02000, CRC(459c2b03) SHA1(ff62a86195042a349fbe799c638cf590fe9572bb) )	// 8x8 plane 2
496 	ROM_CONTINUE(         0x34000, 0x02000             )
497 
498 	// 16x16x8? chunky
499 	ROM_LOAD( "ic140.15", 0x38000, 0x08000, CRC(82cabdd4) SHA1(94324fcf83c373621fc40553473ae3cb552ab704) )	//
500 	ROM_LOAD( "ic139.14", 0x40000, 0x08000, CRC(1903a9ad) SHA1(526c404c15e3f04b4afb27dee66e9deb0a6b9704) )	// every bit
501 	ROM_LOAD( "ic141.17", 0x48000, 0x04000, CRC(67786327) SHA1(32cc1f5bc654497c968ddcd4af29720c6d659482) )
502 
503 	ROM_REGION( 0x8000, REGION_USER1, 0 )	/* ? zoom table or something ? */
504 	ROM_LOAD( "ic138.5", 0x00000, 0x04000, CRC(7d84135b) SHA1(3c669c4e796e83672aceeb6de1aeea28f9f2fef0) )	// fn_data even
505 	ROM_LOAD( "ic95.4",  0x04000, 0x04000, CRC(493ea590) SHA1(bde4e09bba2e53a0650f26976d81cd1e0bc88cb4) )	// odd
506 
507 ROM_END
508 
509 GAMEX( 1986, spdbuggy, 0, spdbuggy, spdbuggy, 0, ROT0, "Tatsumi", "Speed Buggy", GAME_NO_SOUND | GAME_NOT_WORKING )
510 
511 
512 
513 
514 
515 
516 /***************************************************************************
517 
518 
519 							Speed Buggy / Buggy Boy
520 
521 							  (C) 1986 Data East
522 							  Developed by Tatsumi
523 
524 				    driver by Luca Elia (eliavit@unina.it)
525 
526 **************************************************************************/
527 #include "vidhrdw/generic.h"
528 
529 /* Variables only used here: */
530 static struct tilemap *bg_tilemap, *fg_tilemap;
531 
532 
533 /* Variables that driver has acces to: */
534 
535 
536 
537 /* Variables defined in driver: */
538 
539 
540 /***************************************************************************
541 							Common routines
542 ***************************************************************************/
543 
544 /* Useful defines - for debug */
545 #define KEY(_k_,_action_) \
546 	if (keyboard_pressed(KEYCODE_##_k_))	{ while (keyboard_pressed(KEYCODE_##_k_)); _action_ }
547 #define KEY_SHIFT(_k_,_action_) \
548 	if ( (keyboard_pressed(KEYCODE_LSHIFT)||keyboard_pressed(KEYCODE_RSHIFT)) && \
549 	      keyboard_pressed(KEYCODE_##_k_) )	{ while (keyboard_pressed(KEYCODE_##_k_)); _action_ }
550 #define KEY_FAST(_k_,_action_) \
551 	if (keyboard_pressed(KEYCODE_##_k_))	{ _action_ }
552 
553 
554 
555 /***************************************************************************
556 
557 					  Callbacks for the TileMap code
558 
559 ***************************************************************************/
560 
561 /*------------------------------------------------------------------------
562 							[ Background ]
563 ------------------------------------------------------------------------*/
564 
565 #define BG_NX  (0x40)
566 #define BG_NY  (0x40)
567 #define BG_GFX (0)
568 
spdbuggy_get_bg_tile_info(int tile_index)569 static void spdbuggy_get_bg_tile_info( int tile_index )
570 {
571 	int code 		=	spdbuggy_bgram[tile_index*2] + spdbuggy_bgram[tile_index*2+1]*256;
572 	SET_TILE_INFO(BG_GFX, code & 0x0fff, code >> 12, 0 );	// $3000 tiles!
573 }
574 
WRITE_HANDLER(spdbuggy_bgram_w)575 WRITE_HANDLER( spdbuggy_bgram_w )
576 {
577 	if (data != spdbuggy_bgram[offset])
578 	{
579 		spdbuggy_bgram[offset] = data;
580 		tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
581 	}
582 }
583 
584 
585 
586 /*------------------------------------------------------------------------
587 							[ Foreground ]
588 ------------------------------------------------------------------------*/
589 
590 #define FG_NX  (0x40)
591 #define FG_NY  (0x40)
592 #define FG_GFX (1)
593 
spdbuggy_get_fg_tile_info(int tile_index)594 static void spdbuggy_get_fg_tile_info( int tile_index )
595 {
596 	int code 		=	spdbuggy_fgram[tile_index*2] + spdbuggy_fgram[tile_index*2+1]*256;
597 	SET_TILE_INFO(FG_GFX, code & 0x07ff, code >> 12, 0 );
598 }
599 
WRITE_HANDLER(spdbuggy_fgram_w)600 WRITE_HANDLER( spdbuggy_fgram_w )
601 {
602 	if (data != spdbuggy_fgram[offset])
603 	{
604 		spdbuggy_fgram[offset] = data;
605 		tilemap_mark_tile_dirty(fg_tilemap, offset / 2);
606 	}
607 }
608 
609 
610 
611 
612 
613 /*------------------------------------------------------------------------
614 						[ Video Hardware Start ]
615 ------------------------------------------------------------------------*/
616 
VIDEO_START(spdbuggy)617 VIDEO_START( spdbuggy )
618 {
619 	bg_tilemap = tilemap_create(spdbuggy_get_bg_tile_info,
620 								tilemap_scan_rows,
621 								TILEMAP_OPAQUE,
622 								8,8,
623 								BG_NX,BG_NY );
624 
625 	fg_tilemap = tilemap_create(spdbuggy_get_fg_tile_info,
626 								tilemap_scan_rows,
627 								TILEMAP_TRANSPARENT,
628 								8,8,
629 								FG_NX,FG_NY );
630 
631 	if ( bg_tilemap && fg_tilemap )
632 	{
633 		tilemap_set_scroll_rows(bg_tilemap,1);
634 		tilemap_set_scroll_cols(bg_tilemap,1);
635 
636 		tilemap_set_scroll_rows(fg_tilemap,1);
637 		tilemap_set_scroll_cols(fg_tilemap,1);
638 
639 		tilemap_set_transparent_pen(fg_tilemap,0);
640 
641 		return 0;
642 	}
643 	else return 1;
644 }
645 
646 
647 /***************************************************************************
648 
649 							Sprites Drawing
650 
651 ***************************************************************************/
652 
draw_sprites(struct mame_bitmap * bitmap,const struct rectangle * cliprect)653 static void draw_sprites(struct mame_bitmap *bitmap, const struct rectangle *cliprect)
654 {
655 }
656 
657 /***************************************************************************
658 
659 							Screen Drawing
660 
661 ***************************************************************************/
662 
663 
664 
665 
VIDEO_UPDATE(spdbuggy)666 VIDEO_UPDATE( spdbuggy )
667 {
668 	int layers_ctrl = 0xFFFF;
669 
670 #if 0
671 	unsigned char *RAM = memory_region( REGION_CPU1 );
672 
673 	fillbitmap(bitmap,Machine->pens[0],&Machine->visible_area);
674 	for (i = 0; i < 0x1000; i+=2)
675 	{
676 		drawgfx(bitmap,Machine->gfx[1],
677 				RAM[0x8000+i],
678 				0,
679 				0, 0,
680 				((i/2)%FG_NX)*8,((i/2)/FG_NX)*8,
681 				&Machine->drv->visible_area,TRANSPARENCY_PEN,0);
682 	}
683 
684 
685 	return;
686 #endif
687 
688 #ifdef MAME_DEBUG
689 {
690 	if (keyboard_pressed(KEYCODE_Z))
691 	{
692 		int msk = 0;
693 		if (keyboard_pressed(KEYCODE_Q))	{ msk |= 1;}
694 		if (keyboard_pressed(KEYCODE_W))	{ msk |= 2;}
695 		if (keyboard_pressed(KEYCODE_E))	{ msk |= 4;}
696 		if (keyboard_pressed(KEYCODE_A))	{ msk |= 8;}
697 		if (keyboard_pressed(KEYCODE_R))	{ msk |= 16;}
698 		if (msk != 0) layers_ctrl &= msk;
699 	}
700 }
701 #endif
702 
703 
704 	/* Draw the background */
705 	if (layers_ctrl & 1)	tilemap_draw(bitmap, cliprect, bg_tilemap,  0, 0);
706 	else					fillbitmap(bitmap,Machine->pens[0],cliprect);
707 
708 	/* Draw the sprites */
709 	if (layers_ctrl & 8)	draw_sprites(bitmap, cliprect);
710 
711 	/* Draw the foreground (text) */
712 	if (layers_ctrl & 4)	tilemap_draw(bitmap, cliprect, fg_tilemap,  0, 0);
713 }
714