1 /***************************************************************************
2
3 Atari Sprint 4 driver
4
5 set 1 => large car sprites [12x12 pixels]
6 set 2 => small car sprites [11x11 pixels]
7
8 ***************************************************************************/
9
10 #include "driver.h"
11
12 extern VIDEO_EOF( sprint4 );
13 extern VIDEO_START( sprint4 );
14 extern VIDEO_UPDATE( sprint4 );
15
16 extern WRITE_HANDLER( sprint4_video_ram_w );
17
18 extern UINT8* sprint4_video_ram;
19
20 extern int sprint4_collision[4];
21
22 static int analog;
23 static int steer_dir[4];
24 static int steer_flag[4];
25 static int gear[4];
26
27
PALETTE_INIT(sprint4)28 static PALETTE_INIT( sprint4 )
29 {
30 palette_set_color(0, 0x00, 0x00, 0x00); /* black */
31 palette_set_color(1, 0xfc, 0xdf, 0x80); /* peach */
32 palette_set_color(2, 0xf0, 0x00, 0xf0); /* violet */
33 palette_set_color(3, 0x00, 0xf0, 0x0f); /* green */
34 palette_set_color(4, 0x30, 0x4f, 0xff); /* blue */
35 palette_set_color(5, 0xff, 0xff, 0xff); /* white */
36
37 memset(colortable, 0, 10 * sizeof (colortable[0]));
38
39 colortable[1] = 1;
40 colortable[3] = 2;
41 colortable[5] = 3;
42 colortable[7] = 4;
43 colortable[9] = 5;
44 }
45
46
input_callback(int dummy)47 static void input_callback(int dummy)
48 {
49 static UINT8 dial[4];
50
51 /* handle steering wheels and gear shift levers */
52
53 int i;
54
55 for (i = 0; i < 4; i++)
56 {
57 signed char delta = readinputport(5 + i) - dial[i];
58
59 if (delta < 0)
60 {
61 steer_dir[i] = 0;
62 }
63 if (delta > 0)
64 {
65 steer_dir[i] = 1;
66 }
67
68 steer_flag[i] = dial[i] & 1;
69
70 switch (readinputport(9 + i))
71 {
72 case 1: gear[i] = 1; break;
73 case 2: gear[i] = 2; break;
74 case 4: gear[i] = 3; break;
75 case 8: gear[i] = 4; break;
76 }
77
78 dial[i] += delta;
79 }
80 }
81
82
nmi_callback(int scanline)83 static void nmi_callback(int scanline)
84 {
85 scanline += 64;
86
87 if (scanline >= 262)
88 {
89 scanline = 32;
90 }
91
92 /* NMI is disabled during service mode */
93
94 if (readinputport(2) & 0x40)
95 {
96 cpu_set_nmi_line(0, PULSE_LINE);
97 }
98
99 timer_set(cpu_getscanlinetime(scanline), scanline, nmi_callback);
100 }
101
102
MACHINE_INIT(sprint4)103 static MACHINE_INIT( sprint4 )
104 {
105 timer_set(cpu_getscanlinetime(32), 32, nmi_callback);
106
107 timer_pulse(TIME_IN_HZ(60), 0, input_callback);
108 }
109
110
READ_HANDLER(sprint4_wram_r)111 static READ_HANDLER( sprint4_wram_r )
112 {
113 return sprint4_video_ram[0x380 + offset % 0x80];
114 }
115
116
READ_HANDLER(sprint4_analog_r)117 static READ_HANDLER( sprint4_analog_r )
118 {
119 int n = (offset >> 1) & 3;
120
121 UINT8 val;
122
123 if (offset & 1)
124 {
125 val = 4 * gear[n];
126 }
127 else
128 {
129 val = 8 * steer_flag[n] + 8 * steer_dir[n];
130 }
131
132 return val > analog ? 0x80 : 0x00;
133 }
134
135
READ_HANDLER(sprint4_coin_r)136 static READ_HANDLER( sprint4_coin_r )
137 {
138 return (readinputport(1) << ((offset & 7) ^ 7)) & 0x80;
139 }
140
141
READ_HANDLER(sprint4_gas_r)142 static READ_HANDLER( sprint4_gas_r )
143 {
144 UINT8 val = readinputport(0);
145
146 if (sprint4_collision[0]) val |= 0x02;
147 if (sprint4_collision[1]) val |= 0x08;
148 if (sprint4_collision[2]) val |= 0x20;
149 if (sprint4_collision[3]) val |= 0x80;
150
151 return (val << ((offset & 7) ^ 7)) & 0x80;
152 }
153
154
READ_HANDLER(sprint4_dip_r)155 static READ_HANDLER( sprint4_dip_r )
156 {
157 return (readinputport(4) >> (2 * (offset & 3))) & 3;
158 }
159
160
WRITE_HANDLER(sprint4_wram_w)161 static WRITE_HANDLER( sprint4_wram_w )
162 {
163 sprint4_video_ram[0x380 + offset % 0x80] = data;
164 }
165
166
WRITE_HANDLER(sprint4_collision_reset_w)167 static WRITE_HANDLER( sprint4_collision_reset_w )
168 {
169 sprint4_collision[(offset >> 1) & 3] = 0;
170 }
171
172
WRITE_HANDLER(sprint4_analog_w)173 static WRITE_HANDLER( sprint4_analog_w )
174 {
175 analog = data & 15;
176 }
177
178
WRITE_HANDLER(sprint4_lamp_w)179 static WRITE_HANDLER( sprint4_lamp_w )
180 {
181 set_led_status((offset >> 1) & 3, offset & 1);
182 }
183
184
WRITE_HANDLER(sprint4_attract_w)185 static WRITE_HANDLER( sprint4_attract_w )
186 {
187 /* sound */
188 }
WRITE_HANDLER(sprint4_crash_w)189 static WRITE_HANDLER( sprint4_crash_w )
190 {
191 /* sound */
192 }
WRITE_HANDLER(sprint4_skid_w)193 static WRITE_HANDLER( sprint4_skid_w )
194 {
195 /* sound */
196 }
197
198
MEMORY_READ_START(readmem)199 static MEMORY_READ_START( readmem )
200 { 0x0000, 0x001f, sprint4_analog_r },
201 { 0x0020, 0x003f, sprint4_coin_r },
202 { 0x0040, 0x005f, sprint4_gas_r },
203 { 0x0060, 0x007f, sprint4_dip_r },
204 { 0x0080, 0x00ff, sprint4_wram_r },
205 { 0x0180, 0x01ff, sprint4_wram_r },
206 { 0x0800, 0x0bff, MRA_RAM },
207 { 0x1000, 0x17ff, input_port_2_r },
208 { 0x1800, 0x1fff, input_port_3_r },
209 { 0x2000, 0x3fff, MRA_ROM },
210 { 0xe800, 0xffff, MRA_ROM },
211 MEMORY_END
212
213
214 static MEMORY_WRITE_START( writemem )
215 { 0x0000, 0x001f, sprint4_attract_w },
216 { 0x0020, 0x003f, sprint4_collision_reset_w },
217 { 0x0040, 0x0041, sprint4_analog_w },
218 { 0x0042, 0x0043, sprint4_crash_w },
219 { 0x0044, 0x0045, MWA_NOP }, /* watchdog, disabled during service mode */
220 { 0x0046, 0x0047, MWA_NOP }, /* SPARE */
221 { 0x0060, 0x0067, sprint4_lamp_w },
222 { 0x0068, 0x006f, sprint4_skid_w },
223 { 0x0080, 0x00ff, sprint4_wram_w },
224 { 0x0180, 0x01ff, sprint4_wram_w },
225 { 0x0800, 0x0bff, sprint4_video_ram_w, &sprint4_video_ram },
226 { 0x2000, 0x3fff, MWA_ROM },
227 { 0x4000, 0x4000, MWA_NOP }, /* diagnostic ROM location */
228 { 0xe800, 0xffff, MWA_ROM },
229 MEMORY_END
230
231
232 INPUT_PORTS_START( sprint4 )
233
234 PORT_START
235 PORT_BITX( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1, "Player 1 Gas", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
236 PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* P1 collision */
237 PORT_BITX( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2, "Player 2 Gas", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
238 PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* P2 collision */
239 PORT_BITX( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3, "Player 3 Gas", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
240 PORT_BIT ( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* P3 collision */
241 PORT_BITX( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER4, "Player 4 Gas", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
242 PORT_BIT ( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* P4 collision */
243
244 PORT_START
245 PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
246 PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_START1 )
247 PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
248 PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_START2 )
249 PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_COIN3 )
250 PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_START3 )
251 PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_COIN4 )
252 PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_START4 )
253
254 PORT_START
255 PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
256 PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
257
258 PORT_START
259 PORT_BITX( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2, "Track Select", KEYCODE_SPACE, IP_JOY_DEFAULT )
260
261 PORT_START
262 PORT_DIPNAME( 0x03, 0x03, "Language" )
263 PORT_DIPSETTING( 0x00, "German" )
264 PORT_DIPSETTING( 0x01, "French" )
265 PORT_DIPSETTING( 0x02, "Spanish" )
266 PORT_DIPSETTING( 0x03, "English" )
267 PORT_DIPNAME( 0x04, 0x04, DEF_STR( Coinage ))
268 PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ))
269 PORT_DIPSETTING( 0x04, DEF_STR( 1C_1C ))
270 PORT_DIPNAME( 0x08, 0x08, "Allow Late Entry" )
271 PORT_DIPSETTING( 0x08, DEF_STR( No ))
272 PORT_DIPSETTING( 0x00, DEF_STR( Yes ))
273 PORT_DIPNAME( 0xf0, 0xb0, "Play Time" )
274 PORT_DIPSETTING( 0x70, "60 seconds" )
275 PORT_DIPSETTING( 0xb0, "90 seconds" )
276 PORT_DIPSETTING( 0xd0, "120 seconds" )
277 PORT_DIPSETTING( 0xe0, "150 seconds" )
278
279 PORT_START
280 PORT_ANALOG( 0xff, 0x00, IPT_DIAL | IPF_PLAYER1, 100, 1, 0, 0 )
281
282 PORT_START
283 PORT_ANALOG( 0xff, 0x00, IPT_DIAL | IPF_PLAYER2, 100, 1, 0, 0 )
284
285 PORT_START
286 PORT_ANALOG( 0xff, 0x00, IPT_DIAL | IPF_PLAYER3, 100, 1, 0, 0 )
287
288 PORT_START
289 PORT_ANALOG( 0xff, 0x00, IPT_DIAL | IPF_PLAYER4, 100, 1, 0, 0 )
290
291 PORT_START
292 PORT_BITX(0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER1, "Player 1 Gear 1", KEYCODE_Z, IP_JOY_DEFAULT )
293 PORT_BITX(0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_PLAYER1, "Player 1 Gear 2", KEYCODE_X, IP_JOY_DEFAULT )
294 PORT_BITX(0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 | IPF_PLAYER1, "Player 1 Gear 3", KEYCODE_C, IP_JOY_DEFAULT )
295 PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 | IPF_PLAYER1, "Player 1 Gear 4", KEYCODE_V, IP_JOY_DEFAULT )
296
297 PORT_START
298 PORT_BITX(0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER2, "Player 2 Gear 1", KEYCODE_Q, IP_JOY_DEFAULT )
299 PORT_BITX(0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_PLAYER2, "Player 2 Gear 2", KEYCODE_W, IP_JOY_DEFAULT )
300 PORT_BITX(0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 | IPF_PLAYER2, "Player 2 Gear 3", KEYCODE_E, IP_JOY_DEFAULT )
301 PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 | IPF_PLAYER2, "Player 2 Gear 4", KEYCODE_R, IP_JOY_DEFAULT )
302
303 PORT_START
304 PORT_BITX(0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER3, "Player 3 Gear 1", KEYCODE_Y, IP_JOY_DEFAULT )
305 PORT_BITX(0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_PLAYER3, "Player 3 Gear 2", KEYCODE_U, IP_JOY_DEFAULT )
306 PORT_BITX(0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 | IPF_PLAYER3, "Player 3 Gear 3", KEYCODE_I, IP_JOY_DEFAULT )
307 PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 | IPF_PLAYER3, "Player 3 Gear 4", KEYCODE_O, IP_JOY_DEFAULT )
308
309 PORT_START
310 PORT_BITX(0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_PLAYER3, "Player 4 Gear 1", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
311 PORT_BITX(0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 | IPF_PLAYER3, "Player 4 Gear 2", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
312 PORT_BITX(0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 | IPF_PLAYER3, "Player 4 Gear 3", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
313 PORT_BITX(0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 | IPF_PLAYER3, "Player 4 Gear 4", IP_KEY_DEFAULT, IP_JOY_DEFAULT )
314
315 INPUT_PORTS_END
316
317
318 static struct GfxLayout tile_layout =
319 {
320 8, 8,
321 256,
322 1,
323 { 0 },
324 {
325 0, 1, 2, 3, 4, 5, 6, 7
326 },
327 {
328 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38
329 },
330 0x40
331 };
332
333
334 static struct GfxLayout car_layout =
335 {
336 12, 16,
337 64,
338 1,
339 { 0 },
340 {
341 0x0007, 0x0006, 0x0005, 0x0004,
342 0x2007, 0x2006, 0x2005, 0x2004,
343 0x4007, 0x4006, 0x4005, 0x4004
344 },
345 {
346 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38,
347 0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x78
348 },
349 0x80
350 };
351
352
353 static struct GfxDecodeInfo gfxdecodeinfo[] =
354 {
355 { REGION_GFX1, 0, &tile_layout, 0, 5 },
356 { REGION_GFX2, 0, &car_layout, 0, 5 },
357 { -1 }
358 };
359
360
361 static MACHINE_DRIVER_START( sprint4 )
362
363 /* basic machine hardware */
364 MDRV_CPU_ADD(M6502, 12096000 / 16)
365 MDRV_CPU_MEMORY(readmem, writemem)
366
367 MDRV_FRAMES_PER_SECOND(60)
368 MDRV_VBLANK_DURATION(38 * 1000000 / 15750)
369 MDRV_MACHINE_INIT(sprint4)
370
371 /* video hardware */
372 MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
373 MDRV_SCREEN_SIZE(256, 262)
374 MDRV_VISIBLE_AREA(0, 255, 0, 223)
375 MDRV_GFXDECODE(gfxdecodeinfo)
376 MDRV_PALETTE_LENGTH(6)
377 MDRV_COLORTABLE_LENGTH(10)
378
379 MDRV_PALETTE_INIT(sprint4)
380 MDRV_VIDEO_START(sprint4)
381 MDRV_VIDEO_UPDATE(sprint4)
382 MDRV_VIDEO_EOF(sprint4)
383
384 /* sound hardware */
385 MACHINE_DRIVER_END
386
387
388 ROM_START( sprint4 )
389 ROM_REGION( 0x10000, REGION_CPU1, 0 )
390 ROM_LOAD ( "30031.c1", 0x2800, 0x0800, CRC(017ee7c4) SHA1(9386cacc619669c18af31f66691a45af6dafef64) )
391 ROM_RELOAD ( 0xe800, 0x0800 )
392 ROM_LOAD_NIB_LOW ( "30036-02.n1", 0x3000, 0x0800, CRC(883b9d7c) SHA1(af52ffdd9cd8dfed54013c9b0d3c6e48c7419d17) )
393 ROM_RELOAD ( 0xf000, 0x0800 )
394 ROM_LOAD_NIB_HIGH( "30037-02.k1", 0x3000, 0x0800, CRC(c297fbd8) SHA1(8cc0f486429e12bee21a5dd1135e799196480044) )
395 ROM_RELOAD ( 0xf000, 0x0800 )
396 ROM_LOAD ( "30033.e1", 0x3800, 0x0800, CRC(b8b717b7) SHA1(2f6b1a0e9803901d9ba79d1f19a025f6a6134756) )
397 ROM_RELOAD ( 0xf800, 0x0800 )
398
399 ROM_REGION( 0x0800, REGION_GFX1, ROMREGION_DISPOSE ) /* tiles */
400 ROM_LOAD( "30027.h5", 0x0000, 0x0800, CRC(3a752e07) SHA1(d990f94b296409d47e8bada98ddbed5f76567e1b) )
401
402 ROM_REGION( 0x0c00, REGION_GFX2, ROMREGION_DISPOSE ) /* cars */
403 ROM_LOAD( "30028-01.n6", 0x0000, 0x0400, CRC(3ebcb13f) SHA1(e0b87239081f12f6613d3db6a8cb5b80937df7d7) )
404 ROM_LOAD( "30029-01.m6", 0x0400, 0x0400, CRC(963a8424) SHA1(d52a0e73c54154531e825153012687bdb85e479a) )
405 ROM_LOAD( "30030-01.l6", 0x0800, 0x0400, CRC(e94dfc2d) SHA1(9c5b1401c4aadda0a3aee76e4f92e73ae1d35cb7) )
406
407 ROM_REGION( 0x0200, REGION_PROMS, 0 )
408 ROM_LOAD( "30024-01.p8", 0x0000, 0x0200, CRC(e71d2e22) SHA1(434c3a8237468604cce7feb40e6061d2670013b3) ) /* SYNC */
409 ROM_END
410
411
412 ROM_START( sprint4a )
413 ROM_REGION( 0x10000, REGION_CPU1, 0 )
414 ROM_LOAD ( "30031.c1", 0x2800, 0x0800, CRC(017ee7c4) SHA1(9386cacc619669c18af31f66691a45af6dafef64) )
415 ROM_RELOAD ( 0xe800, 0x0800 )
416 ROM_LOAD_NIB_LOW ( "30036-02.n1", 0x3000, 0x0800, CRC(883b9d7c) SHA1(af52ffdd9cd8dfed54013c9b0d3c6e48c7419d17) )
417 ROM_RELOAD ( 0xf000, 0x0800 )
418 ROM_LOAD_NIB_HIGH( "30037-02.k1", 0x3000, 0x0800, CRC(c297fbd8) SHA1(8cc0f486429e12bee21a5dd1135e799196480044) )
419 ROM_RELOAD ( 0xf000, 0x0800 )
420 ROM_LOAD ( "30033.e1", 0x3800, 0x0800, CRC(b8b717b7) SHA1(2f6b1a0e9803901d9ba79d1f19a025f6a6134756) )
421 ROM_RELOAD ( 0xf800, 0x0800 )
422
423 ROM_REGION( 0x0800, REGION_GFX1, ROMREGION_DISPOSE ) /* tiles */
424 ROM_LOAD( "30027.h5", 0x0000, 0x0800, CRC(3a752e07) SHA1(d990f94b296409d47e8bada98ddbed5f76567e1b) )
425
426 ROM_REGION( 0x0c00, REGION_GFX2, ROMREGION_DISPOSE ) /* cars */
427 ROM_LOAD( "30028-03.n6", 0x0000, 0x0400, CRC(d3337030) SHA1(3e73fc45bdcaa52dc1aa01489b46240284562ab7) )
428 ROM_LOAD( "30029-03.m6", 0x0400, 0x0400, NO_DUMP )
429 ROM_LOAD( "30030-03.l6", 0x0800, 0x0400, CRC(aa1b45ab) SHA1(1ddb64d4ec92a1383866daaefa556499837decd1) )
430
431 ROM_REGION( 0x0200, REGION_PROMS, 0 )
432 ROM_LOAD( "30024-01.p8", 0x0000, 0x0200, CRC(e71d2e22) SHA1(434c3a8237468604cce7feb40e6061d2670013b3) ) /* SYNC */
433 ROM_END
434
435
436 GAMEX( 1977, sprint4, 0, sprint4, sprint4, 0, ROT0, "Atari", "Sprint 4 (set 1)", GAME_NO_SOUND )
437 GAMEX( 1977, sprint4a, sprint4, sprint4, sprint4, 0, ROT0, "Atari", "Sprint 4 (set 2)", GAME_NO_SOUND )
438