1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /***************************************************************************
4
5 Atari Bad Lands hardware
6
7 driver by Aaron Giles
8
9 Games supported:
10 * Bad Lands (1989)
11
12 Known bugs:
13 * none at this time
14
15 ****************************************************************************
16
17 Memory map
18
19 ****************************************************************************
20
21 ========================================================================
22 MAIN CPU
23 ========================================================================
24 000000-03FFFF R xxxxxxxx xxxxxxxx Program ROM
25 FC0000 R -------x -------- Sound command buffer full
26 FC0000 W -------- -------- Sound CPU reset
27 FD0000-FD1FFF R/W -------- xxxxxxxx EEPROM
28 FE0000 W -------- -------- Watchdog reset
29 FE2000 W -------- -------- VBLANK IRQ acknowledge
30 FE4000 R -------- xxxx---- Switch inputs
31 R -------- x------- (Self test)
32 R -------- -x------ (VBLANK)
33 R -------- --x----- (Player 2 button)
34 R -------- ---x---- (Player 1 button)
35 FE6000 R -------- xxxxxxxx Player 1 steering
36 FE6002 R -------- xxxxxxxx Player 2 steering
37 FE6004 R -------- xxxxxxxx Player 1 pedal
38 FE6006 R -------- xxxxxxxx Player 2 pedal
39 FE8000 W xxxxxxxx -------- Sound command write
40 FEA000 R xxxxxxxx -------- Sound response read
41 FEC000 W -------- -------x Playfield tile bank select
42 FEE000 W -------- -------- EEPROM enable
43 FFC000-FFC0FF R/W xxxxxxxx xxxxxxxx Playfield palette RAM (128 entries)
44 R/W x------- -------- (RGB 1 LSB)
45 R/W -xxxxx-- -------- (Red 5 MSB)
46 R/W ------xx xxx----- (Green 5 MSB)
47 R/W -------- ---xxxxx (Blue 5 MSB)
48 FFC100-FFC1FF R/W xxxxxxxx xxxxxxxx Motion object palette RAM (128 entries)
49 FFC200-FFC3FF R/W xxxxxxxx xxxxxxxx Extra palette RAM (256 entries)
50 FFE000-FFEFFF R/W xxxxxxxx xxxxxxxx Playfield RAM (64x32 tiles)
51 R/W xxx----- -------- (Palette select)
52 R/W ---x---- -------- (Tile bank select)
53 R/W ----xxxx xxxxxxxx (Tile index)
54 FFF000-FFFFFF R/W xxxxxxxx xxxxxxxx Motion object RAM (32 entries x 4 words)
55 R/W ----xxxx xxxxxxxx (0: Tile index)
56 R/W xxxxxxxx x------- (1: Y position)
57 R/W -------- ----xxxx (1: Number of Y tiles - 1)
58 R/W xxxxxxxx x------- (3: X position)
59 R/W -------- ----x--- (3: Priority)
60 R/W -------- -----xxx (3: Palette select)
61 ========================================================================
62 Interrupts:
63 IRQ1 = VBLANK
64 IRQ2 = sound CPU communications
65 ========================================================================
66
67
68 ========================================================================
69 SOUND CPU (based on JSA II, but implemented onboard)
70 ========================================================================
71 0000-1FFF R/W xxxxxxxx Program RAM
72 2000-2001 R/W xxxxxxxx YM2151 communications
73 2802 R xxxxxxxx Sound command read
74 2804 R xxxx--xx Status input
75 R x------- (Self test)
76 R -x------ (Sound command buffer full)
77 R --x----- (Sound response buffer full)
78 R ---x---- (Self test)
79 R ------xx (Coin inputs)
80 2806 R/W -------- IRQ acknowledge
81 2A02 W xxxxxxxx Sound response write
82 2A04 W xxxx---x Sound control
83 W xx------ (ROM bank select)
84 W --xx---- (Coin counters)
85 W -------x (YM2151 reset)
86 3000-3FFF R xxxxxxxx Banked ROM
87 4000-FFFF R xxxxxxxx Program ROM
88 ========================================================================
89 Interrupts:
90 IRQ = timed interrupt (clocked by VBLANK ORed with 32V; YM2151 IRQ
91 is tested by service routine but not connected on hardware)
92 NMI = latch on sound command
93 ========================================================================
94
95
96 Badlands
97 Atari Games, 1989
98
99 PCB Layout
100 ----------
101
102 A047193-01 BADLANDS
103 |-------------------------------------------------|
104 |TDA2030 LM324 ROM.2N ROM.2S ROM.2U|
105 |VOL LM324 ROM.4N ROM.4S ROM.4U|
106 |6264 YM3012 |
107 | YM2151 6116 PAL3 |
108 | ROM.9C PAL2 ROM.10R 10T |
109 |J 6502 ROM.14R ROM.14T|
110 |A MB87316 |
111 |M 14.31818MHz PAL4 VMA |
112 |M |
113 |A VGC7205 ROM.17F PAL5 |
114 | TEST_SW 68000 ROM.20F SOS |
115 | NE556 PAL1 ROM.24F PAL6 6264 |
116 |LED DIP20 ROM.27F 2816 |
117 |-------------------------------------------------|
118 Notes:
119 68000 - clock 7.15909MHz [14.31818/2]
120 6502 - clock 1.7897725 [14.31818/8]
121 YM2151 - clock 3.579545MHz [14.31818/4]
122 VGC7205- VLSI VGC7205A0672 ATARI 137304-2002
123 2816 - 2k x8 EEPROM
124 DIP20 - socket not populated
125 SOS - Motorola (rebadged) SOS-137550-001 ZKZKAA8946
126 VMA - Motorola (rebadged) VMA-137552-001 ZKZKAB8948
127 MB87316- Fujitsu MB87316 137536-001 with clock input 7.15909MHz
128 Listed in Jed Margolin's Atari Approved Vendor List
129 (http://www.jmargolin.com/schem/atariavl.htm) as.....
130 137536-001 IC,Line_Buffer(LB),CMOS,672B_RAM,500_Gate,40pin FUJITSU MB87316
131
132 ROMs -
133 location label
134 ------------------------
135 9C 136074-1018 E1FF
136 17F 136074-1009 86DF
137 20F 136074-1008 87FF
138 24F 136074-1007 F2DE
139 27F 136074-1006 98FE
140 2N 136074-1013 A5A0
141 2S 136074-1014 567B
142 2U 136074-1017 BB88
143 4N 136074-1012 6B70
144 4S 136074-1014 4475
145 4U 136074-1016 42A5
146 10R 136074-1011 041C
147 10T not populated
148 14R 136074-1010 5E67
149 14T 136074-1019 D4C4
150
151 PALs -
152 PAL1 - Lattice GAL16V8A-25LP labelled '136074-1001'
153 PAL2 - Lattice GAL16V8A-25LP labelled '136074-1005'
154 PAL3 - Lattice GAL16V8A-25LP labelled '136074-1004'
155 PAL4 - Lattice GAL16V8A-25LP labelled '136074-1003'
156 PAL5 - Lattice GAL16V8A-25LP labelled '136074-1002'
157 PAL6 - Lattice GAL16V8A-25LP labelled '136074-2000'
158
159 Measurements -
160 X1 - 14.31995MHz
161 VSync - 59.9310Hz
162 HSync - 15.4611kHz
163
164 ****************************************************************************/
165
166
167 #include "emu.h"
168 #include "includes/badlands.h"
169 #include "emupal.h"
170
171
172 /*************************************
173 *
174 * Initialization
175 *
176 *************************************/
177
TIMER_DEVICE_CALLBACK_MEMBER(badlands_state::sound_scanline)178 TIMER_DEVICE_CALLBACK_MEMBER(badlands_state::sound_scanline)
179 {
180 int scanline = param;
181 //address_space &space = m_audiocpu->space(AS_PROGRAM);
182
183 // 32V
184 if ((scanline % 64) == 0 && scanline < 240)
185 m_audiocpu->set_input_line(m6502_device::IRQ_LINE, ASSERT_LINE);
186 }
187
188
MACHINE_START_MEMBER(badlands_state,badlands)189 MACHINE_START_MEMBER(badlands_state,badlands)
190 {
191 save_item(NAME(m_pedal_value));
192 }
193
194
MACHINE_RESET_MEMBER(badlands_state,badlands)195 MACHINE_RESET_MEMBER(badlands_state,badlands)
196 {
197 m_pedal_value[0] = m_pedal_value[1] = 0x80;
198
199 //scanline_timer_reset(*m_screen, 32);
200
201 membank("soundbank")->set_entry(0);
202 }
203
204
205
206 /*************************************
207 *
208 * Interrupt handling
209 *
210 *************************************/
211
INTERRUPT_GEN_MEMBER(badlands_state::vblank_int)212 INTERRUPT_GEN_MEMBER(badlands_state::vblank_int)
213 {
214 // TODO: remove this hack
215 int pedal_state = ioport("PEDALS")->read();
216 int i;
217
218 /* update the pedals once per frame */
219 for (i = 0; i < 2; i++)
220 {
221 m_pedal_value[i]--;
222 if (pedal_state & (1 << i))
223 m_pedal_value[i]++;
224 }
225
226 m_maincpu->set_input_line(M68K_IRQ_1, ASSERT_LINE);
227 }
228
video_int_ack_w(uint16_t data)229 void badlands_state::video_int_ack_w(uint16_t data)
230 {
231 m_maincpu->set_input_line(M68K_IRQ_1, CLEAR_LINE);
232 }
233
234
235
236 /*************************************
237 *
238 * I/O read dispatch
239 *
240 *************************************/
241
sound_busy_r()242 uint16_t badlands_state::sound_busy_r()
243 {
244 uint16_t temp = 0xfeff;
245 if (m_soundlatch->pending_r()) temp ^= 0x0100;
246 return temp;
247 }
248
249
sound_reset_w(uint16_t data)250 void badlands_state::sound_reset_w(uint16_t data)
251 {
252 m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);
253 audio_io_w(0);
254 }
255
256
pedal_0_r()257 uint16_t badlands_state::pedal_0_r()
258 {
259 return m_pedal_value[0];
260 }
261
262
pedal_1_r()263 uint16_t badlands_state::pedal_1_r()
264 {
265 return m_pedal_value[1];
266 }
267
268
269 /*************************************
270 *
271 * Audio I/O handlers
272 *
273 *************************************/
274
audio_io_r()275 uint8_t badlands_state::audio_io_r()
276 {
277 /*
278 /RDIO
279 0x80 = self test
280 0x40 = NMI line state (active low)
281 0x20 = sound output full
282 0x10 = self test
283 0x08 = +5V
284 0x04 = +5V
285 0x02 = coin 2
286 0x01 = coin 1
287 */
288 uint8_t result = ioport("AUDIO")->read();
289 if (!(ioport("FE4000")->read() & 0x0080)) result ^= 0x90;
290 result ^= 0x10;
291
292 return result;
293 }
294
295
audio_io_w(uint8_t data)296 void badlands_state::audio_io_w(uint8_t data)
297 {
298 /*
299 /WRIO
300 0xc0 = bank address
301 0x20 = coin counter 1
302 0x10 = coin counter 2
303 0x08 = n/c
304 0x04 = n/c
305 0x02 = n/c
306 0x01 = YM2151 reset (active low)
307 */
308
309 // update the bank
310 membank("soundbank")->set_entry((data >> 6) & 3);
311 machine().bookkeeping().coin_counter_w(0, BIT(data, 5));
312 machine().bookkeeping().coin_counter_w(1, BIT(data, 4));
313 m_ymsnd->reset_w(BIT(data, 0));
314 }
315
316
audio_irqack_r()317 uint8_t badlands_state::audio_irqack_r()
318 {
319 if (!machine().side_effects_disabled())
320 m_audiocpu->set_input_line(m6502_device::IRQ_LINE, CLEAR_LINE);
321
322 return 0xff;
323 }
324
325
audio_irqack_w(uint8_t data)326 void badlands_state::audio_irqack_w(uint8_t data)
327 {
328 m_audiocpu->set_input_line(m6502_device::IRQ_LINE, CLEAR_LINE);
329 }
330
331
332
333 /*************************************
334 *
335 * Main CPU memory handlers
336 *
337 *************************************/
338
main_map(address_map & map)339 void badlands_state::main_map(address_map &map)
340 {
341 map(0x000000, 0x03ffff).rom();
342 map(0xfc0000, 0xfc1fff).rw(FUNC(badlands_state::sound_busy_r), FUNC(badlands_state::sound_reset_w));
343 map(0xfd0000, 0xfd1fff).rw("eeprom", FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)).umask16(0x00ff);
344 map(0xfe0000, 0xfe1fff).w("watchdog", FUNC(watchdog_timer_device::reset16_w));
345 map(0xfe2000, 0xfe3fff).w(FUNC(badlands_state::video_int_ack_w));
346 map(0xfe4000, 0xfe5fff).portr("FE4000");
347 map(0xfe6000, 0xfe6001).portr("FE6000");
348 map(0xfe6002, 0xfe6003).portr("FE6002");
349 map(0xfe6004, 0xfe6005).r(FUNC(badlands_state::pedal_0_r));
350 map(0xfe6006, 0xfe6007).r(FUNC(badlands_state::pedal_1_r));
351 map(0xfe8000, 0xfe9fff).w(m_soundlatch, FUNC(generic_latch_8_device::write)).umask16(0xff00);
352 map(0xfea000, 0xfebfff).r(m_mainlatch, FUNC(generic_latch_8_device::read)).umask16(0xff00);
353 map(0xfec000, 0xfedfff).w(FUNC(badlands_state::badlands_pf_bank_w));
354 map(0xfee000, 0xfeffff).w("eeprom", FUNC(eeprom_parallel_28xx_device::unlock_write16));
355 map(0xffc000, 0xffc3ff).rw("palette", FUNC(palette_device::read8), FUNC(palette_device::write8)).umask16(0xff00).share("palette");
356 map(0xffe000, 0xffefff).ram().w(m_playfield_tilemap, FUNC(tilemap_device::write16)).share("playfield");
357 map(0xfff000, 0xfff1ff).ram().share("mob");
358 map(0xfff200, 0xffffff).ram();
359 }
360
361
362
363 /*************************************
364 *
365 * Sound CPU memory handlers
366 *
367 *************************************/
368
audio_map(address_map & map)369 void badlands_state::audio_map(address_map &map)
370 {
371 map(0x0000, 0x1fff).ram();
372 map(0x2000, 0x2001).mirror(0x5fe).rw(m_ymsnd, FUNC(ym2151_device::read), FUNC(ym2151_device::write));
373 map(0x2802, 0x2802).mirror(0x5f9).r(m_soundlatch, FUNC(generic_latch_8_device::read));
374 map(0x2804, 0x2804).mirror(0x5f9).r(FUNC(badlands_state::audio_io_r));
375 map(0x2806, 0x2806).mirror(0x5f9).rw(FUNC(badlands_state::audio_irqack_r), FUNC(badlands_state::audio_irqack_w));
376 map(0x2a02, 0x2a02).mirror(0x5f9).w(m_mainlatch, FUNC(generic_latch_8_device::write));
377 map(0x2a04, 0x2a04).mirror(0x5f9).w(FUNC(badlands_state::audio_io_w));
378 map(0x3000, 0x3fff).bankr("soundbank");
379 map(0x4000, 0xffff).rom();
380 }
381
382
383 /*************************************
384 *
385 * Graphics definitions
386 *
387 *************************************/
388
389 static const gfx_layout pflayout =
390 {
391 8,8,
392 RGN_FRAC(1,1),
393 4,
394 { 0, 1, 2, 3 },
395 { 0, 4, 8, 12, 16, 20, 24, 28 },
396 { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
397 32*8
398 };
399
400 static const gfx_layout badlands_molayout =
401 {
402 16,8,
403 RGN_FRAC(1,1),
404 4,
405 { 0, 1, 2, 3 },
406 { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60 },
407 { 0*8, 8*8, 16*8, 24*8, 32*8, 40*8, 48*8, 56*8 },
408 64*8
409 };
410
411 static GFXDECODE_START( gfx_badlands )
412 GFXDECODE_ENTRY( "gfx1", 0, pflayout, 0, 8 )
413 GFXDECODE_ENTRY( "gfx2", 0, badlands_molayout, 128, 8 )
414 GFXDECODE_END
415
416
417
418 /*************************************
419 *
420 * Machine driver
421 *
422 *************************************/
423
badlands(machine_config & config)424 void badlands_state::badlands(machine_config &config)
425 {
426 /* basic machine hardware */
427 M68000(config, m_maincpu, 14.318181_MHz_XTAL/2);
428 m_maincpu->set_addrmap(AS_PROGRAM, &badlands_state::main_map);
429 m_maincpu->set_vblank_int("screen", FUNC(badlands_state::vblank_int));
430
431 M6502(config, m_audiocpu, 14.318181_MHz_XTAL/8);
432 m_audiocpu->set_addrmap(AS_PROGRAM, &badlands_state::audio_map);
433 TIMER(config, "scantimer").configure_scanline(FUNC(badlands_state::sound_scanline), "screen", 0, 1);
434
435 MCFG_MACHINE_START_OVERRIDE(badlands_state,badlands)
436 MCFG_MACHINE_RESET_OVERRIDE(badlands_state,badlands)
437
438 EEPROM_2816(config, "eeprom").lock_after_write(true);
439
440 WATCHDOG_TIMER(config, "watchdog");
441
442 /* video hardware */
443 GFXDECODE(config, m_gfxdecode, "palette", gfx_badlands);
444 palette_device &palette(PALETTE(config, "palette"));
445 palette.set_format(palette_device::IRGB_1555, 256);
446 palette.set_membits(8);
447
448 TILEMAP(config, m_playfield_tilemap, m_gfxdecode, 2, 8,8, TILEMAP_SCAN_ROWS, 64,32).set_info_callback(FUNC(badlands_state::get_playfield_tile_info));
449
450 ATARI_MOTION_OBJECTS(config, m_mob, 0, m_screen, badlands_state::s_mob_config);
451 m_mob->set_gfxdecode(m_gfxdecode);
452
453 SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
454 m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
455 /* note: these parameters are from published specs, not derived */
456 /* the board uses an SOS-2 chip to generate video signals */
457 m_screen->set_raw(14.318181_MHz_XTAL/2, 456, 0, 336, 262, 0, 240);
458 m_screen->set_screen_update(FUNC(badlands_state::screen_update_badlands));
459 m_screen->set_palette("palette");
460
461 MCFG_VIDEO_START_OVERRIDE(badlands_state,badlands)
462
463 /* sound hardware */
464 GENERIC_LATCH_8(config, m_soundlatch);
465 m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, m6502_device::NMI_LINE);
466
467 GENERIC_LATCH_8(config, m_mainlatch);
468 m_mainlatch->data_pending_callback().set_inputline(m_maincpu, M68K_IRQ_2);
469
470 SPEAKER(config, "mono").front_center();
471
472 YM2151(config, m_ymsnd, 14.318181_MHz_XTAL/4);
473 m_ymsnd->add_route(0, "mono", 0.30).add_route(1, "mono", 0.30);
474 }
475
476
477
478 /*************************************
479 *
480 * ROM definition(s)
481 *
482 *************************************/
483
484 ROM_START( badlands )
485 ROM_REGION( 0x40000, "maincpu", 0 ) /* 4*64k for 68000 code */
CRC(a3da5774)486 ROM_LOAD16_BYTE( "136074-1008.20f", 0x00000, 0x10000, CRC(a3da5774) SHA1(5ab1eb61d25594b2d7c40400cb57e7f47a717598) )
487 ROM_LOAD16_BYTE( "136074-1006.27f", 0x00001, 0x10000, CRC(aa03b4f3) SHA1(5eda60c715ffcefd4ad34bdb90579e8671dc384a) )
488 ROM_LOAD16_BYTE( "136074-1009.17f", 0x20000, 0x10000, CRC(0e2e807f) SHA1(5b61de066dca12c44335aa68a13c821845657866) )
489 ROM_LOAD16_BYTE( "136074-1007.24f", 0x20001, 0x10000, CRC(99a20c2c) SHA1(9b0a5a5dafb8816e72330d302c60339b600b49a8) )
490
491 ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for 6502 code */
492 ROM_LOAD( "136074-1018.9c", 0x00000, 0x10000, CRC(a05fd146) SHA1(d97abbcf7897ca720cc18ff3a323f41cd3b23c34) )
493
494 ROM_REGION( 0x60000, "gfx1", ROMREGION_INVERT )
495 ROM_LOAD( "136074-1012.4n", 0x000000, 0x10000, CRC(5d124c6c) SHA1(afebaaf90b3751f5e873fc4c45f1d5385ef86a6e) ) /* playfield */
496 ROM_LOAD( "136074-1013.2n", 0x010000, 0x10000, CRC(b1ec90d6) SHA1(8d4c7db8e1bf9c050f5869eb38fa573867fdc12b) )
497 ROM_LOAD( "136074-1014.4s", 0x020000, 0x10000, CRC(248a6845) SHA1(086ef0840b889e790ce3fcd09f98589aae932456) )
498 ROM_LOAD( "136074-1015.2s", 0x030000, 0x10000, CRC(792296d8) SHA1(833cdb968064151ca77bb3dbe416ff7127a12de4) )
499 ROM_LOAD( "136074-1016.4u", 0x040000, 0x10000, CRC(878f7c66) SHA1(31159bea5d6aac8100fca8f3860220b97d63e72e) )
500 ROM_LOAD( "136074-1017.2u", 0x050000, 0x10000, CRC(ad0071a3) SHA1(472b197e5d320b3424d8a8d8c051b1023a07ae08) )
501
502 ROM_REGION( 0x30000, "gfx2", ROMREGION_INVERT )
503 ROM_LOAD( "136074-1010.14r", 0x000000, 0x10000, CRC(c15f629e) SHA1(944e3479dce6e420cf9a3f4c1438c5ca66e5cb97) ) /* mo */
504 ROM_LOAD( "136074-1011.10r", 0x010000, 0x10000, CRC(fb0b6717) SHA1(694ab0f04d673682831a24027757d4b3c40a4e0e) )
505 ROM_LOAD( "136074-1019.14t", 0x020000, 0x10000, CRC(0e26bff6) SHA1(ee018dd37a27c7e7c16a57ea0d32aeb9cdf26bb4) )
506
507 ROM_REGION( 0x0C00, "plds", 0 ) /* GAL16V8A-25LP */
508 ROM_LOAD( "136074-1001.26c", 0x0000, 0x0117, CRC(04c3be6a) SHA1(f027834e652f3ff778b09c3754294b303f9ed826) )
509 ROM_LOAD( "136074-1002.21r", 0x0200, 0x0117, CRC(f68bf41d) SHA1(72edd6d0f5d55d39c0020f384149de7ac964f273) )
510 ROM_LOAD( "136074-1003.16s", 0x0400, 0x0117, CRC(a288bbd0) SHA1(62f5900ac88ffb335257f58d892492f370805498) )
511 ROM_LOAD( "136074-1004.9n", 0x0600, 0x0117, CRC(5ffbdaad) SHA1(f7f802dfb7c9b404305a36b8354f91151e61c502) )
512 ROM_LOAD( "136074-1005.12e", 0x0800, 0x0117, CRC(9df77c79) SHA1(52c1c190b80db9b9bc43ce6eefd5f37ac16e590c) )
513 ROM_LOAD( "136074-2000.26r", 0x0A00, 0x0117, CRC(fb8fb3d0) SHA1(361b8f7984695ff26156afe79eaa2d85a150a978) )
514 ROM_END
515
516
517
518 /*************************************
519 *
520 * Driver initialization
521 *
522 *************************************/
523
524 void badlands_state::init_badlands()
525 {
526 /* initialize the audio system */
527 membank("soundbank")->configure_entries(0, 4, memregion("audiocpu")->base(), 0x01000);
528 }
529
530
531
532 /*************************************
533 *
534 * Game driver(s)
535 *
536 *************************************/
537
538 GAME( 1989, badlands, 0, badlands, badlands, badlands_state, init_badlands, ROT0, "Atari Games", "Bad Lands", MACHINE_SUPPORTS_SAVE )
539