trunk/src/mame/drivers/atari_s2.c
| r31803 | r31804 | |
| 8 | 8 | |
| 9 | 9 | The only difference seems to be an extra bank of inputs (or something) at 2008-200B. |
| 10 | 10 | |
| 11 | ToDo: |
| 12 | - 4x4 not emulated yet, appears to be a different cpu and hardware. |
| 13 | - sounds to be verified against a real machine |
| 14 | - noise generator not done yet |
| 15 | - inputs, outputs, dips vary per machine |
| 16 | - High score isn't saved or remembered |
| 11 | 17 | |
| 18 | |
| 12 | 19 | *****************************************************************************************/ |
| 13 | 20 | |
| 14 | 21 | #include "machine/genpin.h" |
| 15 | 22 | #include "cpu/m6800/m6800.h" |
| 23 | #include "sound/dac.h" |
| 16 | 24 | #include "atari_s2.lh" |
| 17 | 25 | |
| 18 | 26 | |
| r31803 | r31804 | |
| 20 | 28 | { |
| 21 | 29 | public: |
| 22 | 30 | atari_s2_state(const machine_config &mconfig, device_type type, const char *tag) |
| 23 | | : genpin_class(mconfig, type, tag), |
| 24 | | m_maincpu(*this, "maincpu") |
| 31 | : genpin_class(mconfig, type, tag) |
| 32 | , m_maincpu(*this, "maincpu") |
| 33 | , m_dac(*this, "dac") |
| 25 | 34 | { } |
| 26 | 35 | |
| 27 | | DECLARE_WRITE8_MEMBER(sound0_w) { }; |
| 28 | | DECLARE_WRITE8_MEMBER(sound1_w) { }; |
| 36 | DECLARE_WRITE8_MEMBER(sound0_w); |
| 37 | DECLARE_WRITE8_MEMBER(sound1_w); |
| 29 | 38 | DECLARE_WRITE8_MEMBER(lamp_w) { }; |
| 30 | 39 | DECLARE_WRITE8_MEMBER(sol0_w); |
| 31 | 40 | DECLARE_WRITE8_MEMBER(sol1_w) { }; |
| 32 | 41 | DECLARE_WRITE8_MEMBER(intack_w); |
| 33 | 42 | DECLARE_WRITE8_MEMBER(display_w); |
| 34 | 43 | DECLARE_READ8_MEMBER(switch_r); |
| 35 | | |
| 36 | 44 | TIMER_DEVICE_CALLBACK_MEMBER(irq); |
| 37 | | protected: |
| 38 | | |
| 39 | | // devices |
| 40 | | required_device<cpu_device> m_maincpu; |
| 41 | | |
| 42 | | // driver_device overrides |
| 43 | | virtual void machine_reset(); |
| 45 | TIMER_DEVICE_CALLBACK_MEMBER(timer_s); |
| 44 | 46 | private: |
| 47 | bool m_timer_sb; |
| 48 | UINT8 m_timer_s[3]; |
| 49 | UINT8 m_sound0; |
| 50 | UINT8 m_sound1; |
| 51 | UINT8 m_vol; |
| 45 | 52 | UINT8 m_t_c; |
| 46 | 53 | UINT8 m_segment[7]; |
| 54 | UINT8 *m_p_prom; |
| 55 | virtual void machine_reset(); |
| 56 | required_device<cpu_device> m_maincpu; |
| 57 | required_device<dac_device> m_dac; |
| 47 | 58 | }; |
| 48 | 59 | |
| 49 | 60 | |
| r31803 | r31804 | |
| 337 | 348 | return ioport(kbdrow)->read(); |
| 338 | 349 | } |
| 339 | 350 | |
| 351 | // Sound |
| 352 | // 4 frequencies (500k,250k,125k,62.5k) come from main clock circuits |
| 353 | // We choose one of these with SEL A,B |
| 354 | // Then presettable 74LS161 binary divider controlled by m_sound0:d4-7 |
| 355 | // Then a 74LS393 to generate 5 address lines |
| 356 | // The address lines are merged with m_sound0:d0-3 to form a lookup on the prom |
| 357 | // Output of prom goes to a 4-bit DAC |
| 358 | // Volume is controlled by m_sound1:d0-3 |
| 359 | // Variables: |
| 360 | // m_timer_s[0] inc each timer cycle, bit 0 = 500k, bit 1 = 250k, bit 2 = 125k, bit 3 = 62.5k |
| 361 | // m_timer_s[1] count in 74LS161 |
| 362 | // m_timer_s[2] count in 74LS393 |
| 363 | // m_timer_sb wanted output of m_timer_s[0] |
| 364 | TIMER_DEVICE_CALLBACK_MEMBER( atari_s2_state::timer_s ) |
| 365 | { |
| 366 | m_timer_s[0]++; |
| 367 | bool cs = BIT(m_timer_s[0], (m_sound0 & 0x30) >> 4); // select which frequency to work with by using SEL A,B |
| 368 | if (cs != m_timer_sb) |
| 369 | { |
| 370 | m_timer_sb = cs; |
| 371 | m_timer_s[1]++; |
| 372 | if (m_timer_s[1] > 15) |
| 373 | { |
| 374 | m_timer_s[1] = m_sound1; // set to preset value |
| 375 | m_timer_s[2]++; |
| 376 | offs_t offs = (m_timer_s[2] & 31) | ((m_sound0 & 15) << 5); |
| 377 | if BIT(m_sound0, 6) |
| 378 | m_dac->write_unsigned8(m_p_prom[offs]<< 4); |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | // d0-3 = sound data to prom |
| 384 | // d4-5 = select initial clock frequency |
| 385 | // d6 h = enable wave |
| 386 | // d7 h = enable noise |
| 387 | WRITE8_MEMBER( atari_s2_state::sound0_w ) |
| 388 | { |
| 389 | m_sound0 = data; |
| 390 | offs_t offs = (m_timer_s[2] & 31) | ((m_sound0 & 15) << 5); |
| 391 | if BIT(m_sound0, 6) |
| 392 | m_dac->write_unsigned8(m_p_prom[offs]<< 4); |
| 393 | } |
| 394 | |
| 395 | // d0-3 = volume |
| 396 | // d4-7 = preset on 74LS161 |
| 397 | WRITE8_MEMBER( atari_s2_state::sound1_w ) |
| 398 | { |
| 399 | m_sound1 = data >> 4; |
| 400 | |
| 401 | data &= 15; |
| 402 | |
| 403 | if (data != m_vol) |
| 404 | { |
| 405 | m_vol = data; |
| 406 | float vol = m_vol/16.666+0.1; |
| 407 | m_dac->set_output_gain(0, vol); |
| 408 | } |
| 409 | } |
| 410 | |
| 340 | 411 | TIMER_DEVICE_CALLBACK_MEMBER( atari_s2_state::irq ) |
| 341 | 412 | { |
| 342 | 413 | if (m_t_c > 0x40) |
| r31803 | r31804 | |
| 347 | 418 | |
| 348 | 419 | void atari_s2_state::machine_reset() |
| 349 | 420 | { |
| 421 | m_p_prom = memregion("proms")->base(); |
| 422 | m_vol = 0; |
| 423 | m_sound0 = 0; |
| 424 | m_sound1 = 0; |
| 350 | 425 | } |
| 351 | 426 | |
| 427 | |
| 352 | 428 | static MACHINE_CONFIG_START( atari_s2, atari_s2_state ) |
| 353 | 429 | /* basic machine hardware */ |
| 354 | 430 | MCFG_CPU_ADD("maincpu", M6800, XTAL_4MHz / 4) |
| 355 | 431 | MCFG_CPU_PROGRAM_MAP(atari_s2_map) |
| 356 | 432 | MCFG_NVRAM_ADD_0FILL("nvram") |
| 357 | | MCFG_TIMER_DRIVER_ADD_PERIODIC("irq", atari_s2_state, irq, attotime::from_hz(XTAL_4MHz / 8192)) |
| 358 | 433 | |
| 359 | 434 | /* Sound */ |
| 360 | 435 | MCFG_FRAGMENT_ADD( genpin_audio ) |
| 436 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 437 | MCFG_SOUND_ADD("dac", DAC, 0) |
| 438 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 361 | 439 | |
| 362 | 440 | /* Video */ |
| 363 | 441 | MCFG_DEFAULT_LAYOUT(layout_atari_s2) |
| 442 | |
| 443 | MCFG_TIMER_DRIVER_ADD_PERIODIC("irq", atari_s2_state, irq, attotime::from_hz(XTAL_4MHz / 8192)) |
| 444 | MCFG_TIMER_DRIVER_ADD_PERIODIC("timer_s", atari_s2_state, timer_s, attotime::from_hz(150000)) |
| 364 | 445 | MACHINE_CONFIG_END |
| 365 | 446 | |
| 366 | 447 | static MACHINE_CONFIG_DERIVED( atari_s3, atari_s2 ) |
| r31803 | r31804 | |
| 378 | 459 | ROM_LOAD("atari_m.rom", 0x3000, 0x0800, CRC(1bb6b72c) SHA1(dd24ed54de275aadf8dc0810a6af3ac97aea4026)) |
| 379 | 460 | ROM_LOAD("atari_j.rom", 0x3800, 0x0800, CRC(26521779) SHA1(2cf1c66441aee99b9d01859d495c12025b5ef094)) |
| 380 | 461 | |
| 381 | | ROM_REGION(0x1000, "sound1", 0) |
| 462 | ROM_REGION(0x0200, "proms", 0) |
| 382 | 463 | ROM_LOAD("82s130.bin", 0x0000, 0x0200, CRC(da1f77b4) SHA1(b21fdc1c6f196c320ec5404013d672c35f95890b)) |
| 383 | 464 | ROM_END |
| 384 | 465 | |
| r31803 | r31804 | |
| 391 | 472 | ROM_LOAD("atari_m.rom", 0x3000, 0x0800, CRC(1bb6b72c) SHA1(dd24ed54de275aadf8dc0810a6af3ac97aea4026)) |
| 392 | 473 | ROM_LOAD("atari_j.rom", 0x3800, 0x0800, CRC(26521779) SHA1(2cf1c66441aee99b9d01859d495c12025b5ef094)) |
| 393 | 474 | |
| 394 | | ROM_REGION(0x1000, "sound1", 0) |
| 475 | ROM_REGION(0x0200, "proms", 0) |
| 395 | 476 | ROM_LOAD("82s130.bin", 0x0000, 0x0200, CRC(da1f77b4) SHA1(b21fdc1c6f196c320ec5404013d672c35f95890b)) |
| 396 | 477 | ROM_END |
| 397 | 478 | |
| r31803 | r31804 | |
| 404 | 485 | ROM_LOAD("3000.716", 0x3000, 0x0800, CRC(2fc01359) SHA1(d3df20c764bb68a5316367bb18d34a03293e7fa6)) |
| 405 | 486 | ROM_LOAD("3800.716", 0x3800, 0x0800, CRC(77262408) SHA1(3045a732c39c96002f495f64ed752279f7d43ee7)) |
| 406 | 487 | |
| 407 | | ROM_REGION(0x1000, "sound1", 0) |
| 488 | ROM_REGION(0x0200, "proms", 0) |
| 408 | 489 | ROM_LOAD("82s130.bin", 0x0000, 0x0200, CRC(da1f77b4) SHA1(b21fdc1c6f196c320ec5404013d672c35f95890b)) |
| 409 | 490 | ROM_END |
| 410 | 491 | |
| r31803 | r31804 | |
| 418 | 499 | ROM_LOAD("c000a70c.bin", 0xc000, 0x2000, CRC(c31ca8d3) SHA1(53f20eff0084771dc61d19db7ddae52e4423e75e)) \ |
| 419 | 500 | ROM_RELOAD(0xe000, 0x2000) |
| 420 | 501 | |
| 421 | | ROM_REGION(0x1000, "sound1", 0) |
| 502 | ROM_REGION(0x0200, "proms", 0) |
| 422 | 503 | ROM_LOAD("82s130.bin", 0x0000, 0x0200, CRC(da1f77b4) SHA1(b21fdc1c6f196c320ec5404013d672c35f95890b)) |
| 423 | 504 | ROM_END |
| 424 | 505 | |
| 425 | | GAME( 1979, supermap, 0, atari_s2, atari_s2, driver_device, 0, ROT0, "Atari", "Superman (Pinball)", GAME_MECHANICAL | GAME_NO_SOUND) |
| 426 | | GAME( 1979, hercules, 0, atari_s2, atari_s2, driver_device, 0, ROT0, "Atari", "Hercules", GAME_MECHANICAL | GAME_NO_SOUND) |
| 427 | | GAME( 1979, roadrunr, 0, atari_s3, atari_s2, driver_device, 0, ROT0, "Atari", "Road Runner", GAME_MECHANICAL | GAME_NO_SOUND) |
| 428 | | GAME( 1982, fourx4, 0, atari_s2, atari_s2, driver_device, 0, ROT0, "Atari", "4x4", GAME_IS_SKELETON_MECHANICAL) |
| 506 | GAME( 1979, supermap, 0, atari_s2, atari_s2, driver_device, 0, ROT0, "Atari", "Superman (Pinball)", GAME_MECHANICAL | GAME_IMPERFECT_SOUND) |
| 507 | GAME( 1979, hercules, 0, atari_s2, atari_s2, driver_device, 0, ROT0, "Atari", "Hercules", GAME_MECHANICAL | GAME_IMPERFECT_SOUND) |
| 508 | GAME( 1979, roadrunr, 0, atari_s3, atari_s2, driver_device, 0, ROT0, "Atari", "Road Runner", GAME_MECHANICAL | GAME_IMPERFECT_SOUND) |
| 509 | GAME( 1982, fourx4, 0, atari_s3, atari_s2, driver_device, 0, ROT0, "Atari", "4x4", GAME_IS_SKELETON_MECHANICAL) |