From 32aa6d91cf2e5240ea92645a6b32c75bdff19adf Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 2 Apr 2018 23:17:53 -0400 Subject: tmek: Use ADC0809 device (nw) --- src/mame/drivers/atarigt.cpp | 62 +++++++++++++++++++++++--------------------- src/mame/includes/atarigt.h | 7 +++-- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/mame/drivers/atarigt.cpp b/src/mame/drivers/atarigt.cpp index 0b15dc8f647..039589ca0d6 100644 --- a/src/mame/drivers/atarigt.cpp +++ b/src/mame/drivers/atarigt.cpp @@ -109,7 +109,6 @@ READ32_MEMBER(atarigt_state::special_port2_r) { int temp = ioport("SERVICE")->read(); temp ^= 0x0001; /* /A2DRDY always high for now */ - temp ^= 0x0008; /* A2D.EOC always high for now */ return (temp << 16) | temp; } @@ -156,26 +155,32 @@ inline void atarigt_state::compute_fake_pots(int *pots) } -READ32_MEMBER(atarigt_state::analog_port0_r) +READ8_MEMBER(atarigt_state::analog_port_r) { -#if (HACK_TMEK_CONTROLS) - int pots[4]; - compute_fake_pots(pots); - return (pots[0] << 24) | (pots[3] << 8); -#else - return (ioport("AN1")->read() << 24) | (ioport("AN2")->read() << 8); -#endif -} + if (!m_adc.found()) + return 0xff; - -READ32_MEMBER(atarigt_state::analog_port1_r) -{ #if (HACK_TMEK_CONTROLS) int pots[4]; compute_fake_pots(pots); - return (pots[2] << 24) | (pots[1] << 8); + switch (offset) + { + case 2: + return pots[0]; + case 3: + return pots[3]; + case 6: + return pots[2]; + case 7: + return pots[1]; + default: + return 0xff; + } #else - return (ioport("AN3")->read() << 24) | (ioport("AN4")->read() << 8); + uint8_t result = m_adc->data_r(space, 0); + if (!machine().side_effects_disabled()) + m_adc->address_offset_start_w(space, offset, 0); + return result; #endif } @@ -600,8 +605,7 @@ void atarigt_state::main_map(address_map &map) { map(0x000000, 0x1fffff).rom(); map(0xc00000, 0xc00003).rw(this, FUNC(atarigt_state::sound_data_r), FUNC(atarigt_state::sound_data_w)); - map(0xd00014, 0xd00017).r(this, FUNC(atarigt_state::analog_port0_r)); - map(0xd0001c, 0xd0001f).r(this, FUNC(atarigt_state::analog_port1_r)); + map(0xd00010, 0xd0001f).r(this, FUNC(atarigt_state::analog_port_r)).umask32(0xff00ff00); map(0xd20000, 0xd20fff).rw("eeprom", FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)).umask32(0xff00ff00); map(0xd40000, 0xd4ffff).w("eeprom", FUNC(eeprom_parallel_28xx_device::unlock_write32)); map(0xd70000, 0xd7ffff).ram(); @@ -654,7 +658,7 @@ static INPUT_PORTS_START( common ) PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SPECIAL ) /* /A2DRDY */ PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_TILT ) /* TILT */ PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SPECIAL ) /* /XIRQ23 */ - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* A2D.EOC */ + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED ) /* A2D.EOC */ PORT_BIT( 0x0030, IP_ACTIVE_LOW, IPT_UNUSED ) /* NC */ PORT_SERVICE( 0x0040, IP_ACTIVE_LOW ) /* SELFTEST */ PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen") /* VBLANK */ @@ -682,6 +686,8 @@ static INPUT_PORTS_START( tmek ) PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) #else + PORT_MODIFY("SERVICE") + PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("adc", adc0808_device, eoc_r) PORT_START("AN1") PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10) PORT_PLAYER(2) @@ -711,18 +717,6 @@ static INPUT_PORTS_START( primrage ) PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) - - PORT_START("AN1") - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("AN2") - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("AN3") - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("AN4") - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) INPUT_PORTS_END @@ -810,6 +804,12 @@ MACHINE_CONFIG_START(atarigt_state::atarigt) MCFG_MACHINE_RESET_OVERRIDE(atarigt_state,atarigt) + MCFG_DEVICE_ADD("adc", ADC0809, ATARI_CLOCK_14MHz/16) // should be 447 kHz according to schematics, but that fails the self-test + MCFG_ADC0808_IN2_CB(IOPORT("AN4")) + MCFG_ADC0808_IN3_CB(IOPORT("AN1")) + MCFG_ADC0808_IN6_CB(IOPORT("AN2")) + MCFG_ADC0808_IN7_CB(IOPORT("AN3")) + MCFG_EEPROM_2816_ADD("eeprom") MCFG_EEPROM_28XX_LOCK_AFTER_WRITE(true) @@ -848,6 +848,7 @@ MACHINE_CONFIG_START(atarigt_state::primrage) MCFG_DEVICE_ADD("cage", ATARI_CAGE, 0) MCFG_ATARI_CAGE_SPEEDUP(0x42f2) MCFG_ATARI_CAGE_IRQ_CALLBACK(WRITE8(atarigt_state,cage_irq_callback)) + MCFG_DEVICE_REMOVE("adc") MACHINE_CONFIG_END MACHINE_CONFIG_START(atarigt_state::primrage20) @@ -856,6 +857,7 @@ MACHINE_CONFIG_START(atarigt_state::primrage20) MCFG_DEVICE_ADD("cage", ATARI_CAGE, 0) MCFG_ATARI_CAGE_SPEEDUP(0x48a4) MCFG_ATARI_CAGE_IRQ_CALLBACK(WRITE8(atarigt_state,cage_irq_callback)) + MCFG_DEVICE_REMOVE("adc") MACHINE_CONFIG_END /************************************* diff --git a/src/mame/includes/atarigt.h b/src/mame/includes/atarigt.h index 86aad4cea95..656464265c4 100644 --- a/src/mame/includes/atarigt.h +++ b/src/mame/includes/atarigt.h @@ -7,6 +7,7 @@ *************************************************************************/ #include "audio/cage.h" +#include "machine/adc0808.h" #include "machine/atarigen.h" #include "video/atarirle.h" @@ -22,6 +23,7 @@ public: atarigt_state(const machine_config &mconfig, device_type type, const char *tag) : atarigen_state(mconfig, type, tag), m_colorram(*this, "colorram", 32), + m_adc(*this, "adc"), m_playfield_tilemap(*this, "playfield"), m_alpha_tilemap(*this, "alpha"), m_rle(*this, "rle"), @@ -31,6 +33,8 @@ public: uint8_t m_is_primrage; required_shared_ptr m_colorram; + optional_device m_adc; + required_device m_playfield_tilemap; required_device m_alpha_tilemap; required_device m_rle; @@ -63,8 +67,7 @@ public: virtual void scanline_update(screen_device &screen, int scanline) override; DECLARE_READ32_MEMBER(special_port2_r); DECLARE_READ32_MEMBER(special_port3_r); - DECLARE_READ32_MEMBER(analog_port0_r); - DECLARE_READ32_MEMBER(analog_port1_r); + DECLARE_READ8_MEMBER(analog_port_r); DECLARE_WRITE32_MEMBER(latch_w); DECLARE_WRITE32_MEMBER(mo_command_w); DECLARE_WRITE32_MEMBER(led_w); -- cgit v1.2.3