1 /***************************************************************************
2 
3 Atari Boxer (prototype) driver
4 
5   AKA Boxing, both game titles appear in the schematics
6 
7   This game had some weird controls that don't work well in MAME.
8 
9 ***************************************************************************/
10 
11 #include "driver.h"
12 
13 extern UINT8* boxer_tile_ram;
14 extern UINT8* boxer_sprite_ram;
15 
16 extern VIDEO_UPDATE( boxer );
17 
18 static UINT8 pot_state;
19 static UINT8 pot_latch;
20 
21 
pot_interrupt(int mask)22 static void pot_interrupt(int mask)
23 {
24 	if (pot_latch & mask)
25 	{
26 		cpu_set_nmi_line(0, ASSERT_LINE);
27 	}
28 
29 	pot_state |= mask;
30 }
31 
32 
periodic_callback(int scanline)33 static void periodic_callback(int scanline)
34 {
35 	cpu_set_irq_line(0, 0, ASSERT_LINE);
36 
37 	if (scanline == 0)
38 	{
39 		UINT8 mask[256];
40 
41 		int i;
42 
43 		memset(mask, 0, sizeof mask);
44 
45 		mask[readinputport(3)] |= 0x01;
46 		mask[readinputport(4)] |= 0x02;
47 		mask[readinputport(5)] |= 0x04;
48 		mask[readinputport(6)] |= 0x08;
49 		mask[readinputport(7)] |= 0x10;
50 		mask[readinputport(8)] |= 0x20;
51 
52 		for (i = 1; i < 256; i++)
53 		{
54 			if (mask[i] != 0)
55 			{
56 				timer_set(cpu_getscanlinetime(i), mask[i], pot_interrupt);
57 			}
58 		}
59 
60 		pot_state = 0;
61 	}
62 
63 	scanline += 64;
64 
65 	if (scanline >= 262)
66 	{
67 		scanline = 0;
68 	}
69 
70 	timer_set(cpu_getscanlinetime(scanline), scanline, periodic_callback);
71 }
72 
73 
PALETTE_INIT(boxer)74 static PALETTE_INIT( boxer )
75 {
76 	palette_set_color(0, 0x00, 0x00, 0x00);
77 	palette_set_color(1, 0xff, 0xff, 0xff);
78 
79 	colortable[0] = 0;
80 	colortable[1] = 1;
81 	colortable[2] = 1;
82 	colortable[3] = 0;
83 }
84 
85 
MACHINE_INIT(boxer)86 static MACHINE_INIT( boxer )
87 {
88 	timer_set(cpu_getscanlinetime(0), 0, periodic_callback);
89 
90 	pot_latch = 0;
91 }
92 
93 
READ_HANDLER(boxer_input_r)94 static READ_HANDLER( boxer_input_r )
95 {
96 	UINT8 val = readinputport(0);
97 
98 	if (readinputport(9) < cpu_getscanline())
99 	{
100 		val |= 0x02;
101 	}
102 
103 	return (val << ((offset & 7) ^ 7)) & 0x80;
104 }
105 
106 
READ_HANDLER(boxer_misc_r)107 static READ_HANDLER( boxer_misc_r )
108 {
109 	UINT8 val = 0;
110 
111 	switch (offset & 3)
112 	{
113 	case 0:
114 		val = pot_state & pot_latch;
115 		break;
116 
117 	case 1:
118 		val = cpu_getscanline();
119 		break;
120 
121 	case 2:
122 		val = readinputport(1);
123 		break;
124 
125 	case 3:
126 		val = readinputport(2);
127 		break;
128 	}
129 
130 	return val ^ 0x3f;
131 }
132 
133 
READ_HANDLER(boxer_bad_address_r)134 static READ_HANDLER( boxer_bad_address_r )
135 {
136 	cpu_set_reset_line(0, PULSE_LINE);
137 
138 	return 0;
139 }
140 
141 
WRITE_HANDLER(boxer_bell_w)142 static WRITE_HANDLER( boxer_bell_w )
143 {
144 }
145 
146 
WRITE_HANDLER(boxer_sound_w)147 static WRITE_HANDLER( boxer_sound_w )
148 {
149 }
150 
151 
WRITE_HANDLER(boxer_pot_w)152 static WRITE_HANDLER( boxer_pot_w )
153 {
154 	/* BIT0 => HPOT1 */
155 	/* BIT1 => VPOT1 */
156 	/* BIT2 => RPOT1 */
157 	/* BIT3 => HPOT2 */
158 	/* BIT4 => VPOT2 */
159 	/* BIT5 => RPOT2 */
160 
161 	pot_latch = data & 0x3f;
162 
163 	cpu_set_nmi_line(0, CLEAR_LINE);
164 }
165 
166 
WRITE_HANDLER(boxer_irq_reset_w)167 static WRITE_HANDLER( boxer_irq_reset_w )
168 {
169 	cpu_set_irq_line(0, 0, CLEAR_LINE);
170 }
171 
172 
WRITE_HANDLER(boxer_crowd_w)173 static WRITE_HANDLER( boxer_crowd_w )
174 {
175 	/* BIT0 => ATTRACT */
176 	/* BIT1 => CROWD-1 */
177 	/* BIT2 => CROWD-2 */
178 	/* BIT3 => CROWD-3 */
179 
180 	coin_lockout_global_w(data & 1);
181 }
182 
183 
WRITE_HANDLER(boxer_led_w)184 static WRITE_HANDLER( boxer_led_w )
185 {
186 	set_led_status(1, !(data & 1));
187 	set_led_status(0, !(data & 2));
188 }
189 
190 
WRITE_HANDLER(boxer_bad_address_w)191 static WRITE_HANDLER( boxer_bad_address_w )
192 {
193 	cpu_set_reset_line(0, PULSE_LINE);
194 }
195 
196 
MEMORY_READ_START(boxer_readmem)197 static MEMORY_READ_START( boxer_readmem )
198 	{ 0x0000, 0x01ff, MRA_RAM },
199 	{ 0x0200, 0x03ff, MRA_RAM },
200 	{ 0x0800, 0x08ff, boxer_input_r },
201 	{ 0x1000, 0x17ff, boxer_misc_r },
202 	{ 0x3000, 0x3fff, MRA_ROM },
203 	{ 0x4000, 0xbfff, boxer_bad_address_r },
204 	{ 0xf000, 0xffff, MRA_ROM },
205 MEMORY_END
206 
207 
208 static MEMORY_WRITE_START( boxer_writemem )
209 	{ 0x0000, 0x01ff, MWA_RAM },
210 	{ 0x0200, 0x03ff, MWA_RAM, &boxer_tile_ram },
211 	{ 0x1800, 0x1800, boxer_pot_w },
212 	{ 0x1900, 0x19ff, boxer_led_w },
213 	{ 0x1a00, 0x1aff, boxer_sound_w },
214 	{ 0x1b00, 0x1bff, boxer_crowd_w },
215 	{ 0x1c00, 0x1cff, boxer_irq_reset_w },
216 	{ 0x1d00, 0x1dff, boxer_bell_w },
217 	{ 0x1e00, 0x1eff, MWA_RAM, &boxer_sprite_ram },
218 	{ 0x1f00, 0x1fff, watchdog_reset_w },
219 	{ 0x3000, 0x3fff, MWA_ROM },
220 	{ 0x4000, 0xbfff, boxer_bad_address_w },
221 	{ 0xf000, 0xffff, MWA_ROM },
222 MEMORY_END
223 
224 
225 INPUT_PORTS_START( boxer )
226 
227 	PORT_START
228 	PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
229 	PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) /* TIMER */
230 	PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_TILT )
231 	PORT_SERVICE( 0x08, IP_ACTIVE_HIGH )
232 	PORT_BIT ( 0x10, IP_ACTIVE_HIGH, IPT_START1 )
233 	PORT_BIT ( 0x20, IP_ACTIVE_HIGH, IPT_START2 )
234 	PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
235 	PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
236 
237 	PORT_START
238 	PORT_DIPNAME( 0x03, 0x01, "Number of Rounds" )
239 	PORT_DIPSETTING(    0x03, "1" )
240 	PORT_DIPSETTING(    0x02, "2" )
241 	PORT_DIPSETTING(    0x01, "3" )
242 	PORT_DIPSETTING(    0x00, "4" )
243 
244 	PORT_START
245 	PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) )
246 	PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
247 	PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
248 	PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
249 	PORT_DIPSETTING(    0x03, DEF_STR( Free_Play ) )
250 
251 	PORT_START
252 	PORT_ANALOG ( 0xff, 0x80, IPT_AD_STICK_X | IPF_REVERSE | IPF_PLAYER1, 30, 16, 0x20, 0xe0)
253 
254 	PORT_START
255 	PORT_ANALOG ( 0xff, 0x80, IPT_AD_STICK_Y | IPF_REVERSE | IPF_PLAYER1, 30, 16, 0x20, 0xe0)
256 
257 	PORT_START
258 	PORT_ANALOGX( 0xff, 0x80, IPT_PADDLE | IPF_PLAYER1, 30, 16, 0x20, 0xe0, KEYCODE_Z, KEYCODE_X, IP_JOY_NONE, IP_JOY_NONE )
259 
260 	PORT_START
261 	PORT_ANALOG ( 0xff, 0x80, IPT_AD_STICK_X | IPF_REVERSE | IPF_PLAYER2, 30, 16, 0x20, 0xe0)
262 
263 	PORT_START
264 	PORT_ANALOG ( 0xff, 0x80, IPT_AD_STICK_Y | IPF_REVERSE | IPF_PLAYER2, 30, 16, 0x20, 0xe0)
265 
266 	PORT_START
267 	PORT_ANALOGX( 0xff, 0x80, IPT_PADDLE | IPF_PLAYER2, 30, 16, 0x20, 0xe0, KEYCODE_Q, KEYCODE_W, IP_JOY_NONE, IP_JOY_NONE )
268 
269 	PORT_START
270 	PORT_DIPNAME( 0xff, 0x5C, "Round Time" ) /* actually a potentiometer */
271 	PORT_DIPSETTING(    0x3C, "15 seconds" )
272 	PORT_DIPSETTING(    0x5C, "30 seconds" )
273 	PORT_DIPSETTING(    0x7C, "45 seconds" )
274 
275 INPUT_PORTS_END
276 
277 
278 static struct GfxLayout tile_layout =
279 {
280 	8, 8,
281 	64,
282 	1,
283 	{ 0 },
284 	{
285 		0x7, 0x6, 0x5, 0x4, 0xf, 0xe, 0xd, 0xc
286 	},
287 	{
288 		0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70
289 	},
290 	0x80
291 };
292 
293 
294 static struct GfxLayout sprite_layout =
295 {
296 	8, 8,
297 	64,
298 	1,
299 	{ 0 },
300 	{
301 		0x4, 0x5, 0x6, 0x7, 0xc, 0xd, 0xe, 0xf
302 	},
303 	{
304 		0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70
305 	},
306 	0x80
307 };
308 
309 
310 static struct GfxDecodeInfo gfxdecodeinfo[] =
311 {
312 	{ REGION_GFX1, 0, &sprite_layout, 0, 1 },
313 	{ REGION_GFX2, 0, &sprite_layout, 0, 1 },
314 	{ REGION_GFX3, 0, &tile_layout, 2, 1 },
315 	{ -1 } /* end of array */
316 };
317 
318 
319 static MACHINE_DRIVER_START(boxer)
320 
321 	/* basic machine hardware */
322 	MDRV_CPU_ADD(M6502, 12096000 / 16)
323 	MDRV_CPU_MEMORY(boxer_readmem, boxer_writemem)
324 
325 	MDRV_FRAMES_PER_SECOND(60)
326 
327 	/* video hardware */
328 	MDRV_MACHINE_INIT(boxer)
329 
330 	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
331 	MDRV_SCREEN_SIZE(256, 262)
332 	MDRV_VISIBLE_AREA(8, 247, 0, 239)
333 	MDRV_GFXDECODE(gfxdecodeinfo)
334 	MDRV_PALETTE_LENGTH(2)
335 	MDRV_COLORTABLE_LENGTH(4)
336 	MDRV_PALETTE_INIT(boxer)
337 	MDRV_VIDEO_UPDATE(boxer)
338 
339 	/* sound hardware */
340 MACHINE_DRIVER_END
341 
342 
343 ROM_START( boxer )
344 
345 	ROM_REGION( 0x10000, REGION_CPU1, 0 )
346 	ROM_LOAD_NIB_LOW ( "3400l.e1", 0x3400, 0x0400, CRC(df85afa4) SHA1(5a74a08f1e0b0bbec02999d5e46513d8afd333ac) )
347 	ROM_RELOAD       (             0xF400, 0x0400 )
348 	ROM_LOAD_NIB_HIGH( "3400m.a1", 0x3400, 0x0400, CRC(23fe06aa) SHA1(03a4eedbf60f07d1dd8d7af576828df5f032146e) )
349 	ROM_RELOAD       (             0xF400, 0x0400 )
350 	ROM_LOAD_NIB_LOW ( "3800l.j1", 0x3800, 0x0400, CRC(087263fb) SHA1(cc3715a68bd05f23b4abf9f18ca14a8fe55163f7) )
351 	ROM_RELOAD       (             0xF800, 0x0400 )
352 	ROM_LOAD_NIB_HIGH( "3800m.d1", 0x3800, 0x0400, CRC(3bbf605e) SHA1(be4ff1702eb837710421a7dafcdc60fe2d3259e8) )
353 	ROM_RELOAD       (             0xF800, 0x0400 )
354 	ROM_LOAD_NIB_LOW ( "3c00l.h1", 0x3C00, 0x0400, CRC(09e204f2) SHA1(565d4c8865da7d96a45e909973d570101de61f63) )
355 	ROM_RELOAD       (             0xFC00, 0x0400 )
356 	ROM_LOAD_NIB_HIGH( "3c00m.c1", 0x3C00, 0x0400, CRC(2f8ebc85) SHA1(05a4e29ec7e49173200d5fe5344274fd6afd16d7) )
357 	ROM_RELOAD       (             0xFC00, 0x0400 )
358 
359 	ROM_REGION( 0x0400, REGION_GFX1, ROMREGION_DISPOSE ) /* lower boxer */
360 	ROM_LOAD( "bx137l.c8", 0x0000, 0x0400, CRC(e91f2048) SHA1(64039d07557e210aa4f6663cd7e72814cb881310) )
361 
362 	ROM_REGION( 0x0400, REGION_GFX2, ROMREGION_DISPOSE ) /* upper boxer */
363 	ROM_LOAD( "bx137u.m8", 0x0000, 0x0400, CRC(e4fee386) SHA1(79b70aca4a92c56363689a363b643d46294d3e88) )
364 
365 	ROM_REGION( 0x0400, REGION_GFX3, ROMREGION_DISPOSE ) /* tiles */
366 	ROM_LOAD( "9417.k2", 0x0000, 0x0400, CRC(7e3d22cf) SHA1(92e6bbe049dc8fcd674f2ff96cde3786f714508d) )
367 
368 	ROM_REGION( 0x0200, REGION_USER1, 0 ) /* lower boxer map */
369 	ROM_LOAD( "bx115l.b7", 0x0000, 0x0200, CRC(31f2234f) SHA1(d53f3a1d0db3cf3024de61ef64f76c6dfdf6861c) )
370 
371 	ROM_REGION( 0x0200, REGION_USER2, 0 ) /* upper boxer map */
372 	ROM_LOAD( "bx115u.l7", 0x0000, 0x0200, CRC(124d3f24) SHA1(09fab2ae218b8584c0e3c8e02f5680ce083a33d6) )
373 
374 	ROM_REGION( 0x0100, REGION_PROMS, 0 ) /* sync prom */
375 	ROM_LOAD( "9402.m3", 0x0000, 0x0100, CRC(00e224a0) SHA1(1a384ef488791c62566c91b18d6a1fb4a5def2ba) )
376 ROM_END
377 
378 
379 GAMEX( 1978, boxer, 0, boxer, boxer, 0, 0, "Atari", "Boxer (prototype)", GAME_NO_SOUND )
380