From 08db73db57ec473011b4ccce5a0999a2bced8c3a Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 3 Apr 2018 00:12:08 -0400 Subject: roadriot: Add ADC0809 device (nw) --- src/mame/drivers/atarig42.cpp | 43 ++++++++++++++++++++----------------------- src/mame/includes/atarig42.h | 9 +++++---- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/mame/drivers/atarig42.cpp b/src/mame/drivers/atarig42.cpp index a48173a38a5..9bf4f013193 100644 --- a/src/mame/drivers/atarig42.cpp +++ b/src/mame/drivers/atarig42.cpp @@ -43,7 +43,6 @@ void atarig42_state::machine_start() { atarigen_state::machine_start(); - save_item(NAME(m_analog_data)); save_item(NAME(m_sloop_bank)); save_item(NAME(m_sloop_next_bank)); save_item(NAME(m_sloop_offset)); @@ -65,25 +64,22 @@ void atarig42_state::machine_reset() * *************************************/ -READ16_MEMBER(atarig42_state::special_port2_r) +WRITE8_MEMBER(atarig42_state::a2d_select_w) { - int temp = ioport("IN2")->read(); - temp ^= 0x0008; /* A2D.EOC always high for now */ - return temp; + if (m_adc.found()) + m_adc->address_offset_start_w(space, offset, 0); } -WRITE16_MEMBER(atarig42_state::a2d_select_w) +READ8_MEMBER(atarig42_state::a2d_data_r) { - static const char *const portnames[] = { "A2D0", "A2D1" }; + if (!m_adc.found()) + return 0xff; - m_analog_data = ioport(portnames[offset != 0])->read(); -} - - -READ16_MEMBER(atarig42_state::a2d_data_r) -{ - return m_analog_data << 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; } @@ -325,9 +321,9 @@ void atarig42_state::main_map(address_map &map) map(0x000000, 0x080001).rom(); map(0xe00000, 0xe00001).portr("IN0"); map(0xe00002, 0xe00003).portr("IN1"); - map(0xe00010, 0xe00011).r(this, FUNC(atarig42_state::special_port2_r)); + map(0xe00010, 0xe00011).portr("IN2"); map(0xe00012, 0xe00013).portr("jsa:JSAIII"); - map(0xe00020, 0xe00027).rw(this, FUNC(atarig42_state::a2d_data_r), FUNC(atarig42_state::a2d_select_w)); + map(0xe00020, 0xe0002f).rw(this, FUNC(atarig42_state::a2d_data_r), FUNC(atarig42_state::a2d_select_w)).umask16(0xff00); map(0xe00031, 0xe00031).r(m_jsa, FUNC(atari_jsa_iii_device::main_response_r)); map(0xe00041, 0xe00041).w(m_jsa, FUNC(atari_jsa_iii_device::main_command_w)); map(0xe00050, 0xe00051).w(this, FUNC(atarig42_state::io_latch_w)); @@ -367,7 +363,8 @@ static INPUT_PORTS_START( roadriot ) PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("IN2") /* e00010 */ - PORT_BIT( 0x000f, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_BIT( 0x0007, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("adc", adc0808_device, eoc_r) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_ATARI_JSA_SOUND_TO_MAIN_READY("jsa") PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_ATARI_JSA_MAIN_TO_SOUND_READY("jsa") PORT_SERVICE( 0x0040, IP_ACTIVE_LOW ) @@ -424,12 +421,6 @@ static INPUT_PORTS_START( guardian ) PORT_SERVICE( 0x0040, IP_ACTIVE_LOW ) PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("A2D0") /* analog 0 */ - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("A2D1") /* analog 1 */ - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) INPUT_PORTS_END @@ -529,6 +520,10 @@ MACHINE_CONFIG_START(atarig42_state::atarig42) MCFG_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz) MCFG_CPU_PROGRAM_MAP(main_map) + MCFG_DEVICE_ADD("adc", ADC0809, ATARI_CLOCK_14MHz / 16) + MCFG_ADC0808_IN0_CB(IOPORT("A2D0")) + MCFG_ADC0808_IN1_CB(IOPORT("A2D1")) + MCFG_EEPROM_2816_ADD("eeprom") MCFG_EEPROM_28XX_LOCK_AFTER_WRITE(true) @@ -575,6 +570,8 @@ MACHINE_CONFIG_START(atarig42_0x400_state::atarig42_0x400) /* ASIC65 */ MCFG_ASIC65_ADD("asic65", ASIC65_GUARDIANS) + + MCFG_DEVICE_REMOVE("adc") MACHINE_CONFIG_END diff --git a/src/mame/includes/atarig42.h b/src/mame/includes/atarig42.h index 0e3d0364640..091981ab13c 100644 --- a/src/mame/includes/atarig42.h +++ b/src/mame/includes/atarig42.h @@ -14,6 +14,7 @@ #include "machine/atarigen.h" #include "video/atarirle.h" #include "cpu/m68000/m68000.h" +#include "machine/adc0808.h" #include "machine/asic65.h" class atarig42_state : public atarigen_state @@ -26,6 +27,7 @@ public: m_alpha_tilemap(*this, "alpha"), m_rle(*this, "rle"), m_asic65(*this, "asic65"), + m_adc(*this, "adc"), m_mo_command(*this, "mo_command") { } @@ -34,9 +36,8 @@ protected: virtual void machine_reset() override; virtual void update_interrupts() override; virtual void scanline_update(screen_device &screen, int scanline) override; - DECLARE_READ16_MEMBER(special_port2_r); - DECLARE_WRITE16_MEMBER(a2d_select_w); - DECLARE_READ16_MEMBER(a2d_data_r); + DECLARE_WRITE8_MEMBER(a2d_select_w); + DECLARE_READ8_MEMBER(a2d_data_r); DECLARE_WRITE16_MEMBER(io_latch_w); DECLARE_WRITE16_MEMBER(mo_command_w); TILE_GET_INFO_MEMBER(get_alpha_tile_info); @@ -53,6 +54,7 @@ protected: required_device m_alpha_tilemap; required_device m_rle; required_device m_asic65; + optional_device m_adc; uint16_t m_playfield_base; @@ -62,7 +64,6 @@ protected: uint16_t m_playfield_xscroll; uint16_t m_playfield_yscroll; - uint8_t m_analog_data; required_shared_ptr m_mo_command; int m_sloop_bank; -- cgit v1.2.3