From 8ed432758a575a17479a35af7c777fcd23967fc4 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 2 Apr 2018 19:38:49 -0400 Subject: atarisy1.cpp: Use ADC0809 device for all except marble (nw) --- src/mame/drivers/atarisy1.cpp | 107 +++++++++++++++++++++++++++--------------- src/mame/includes/atarisy1.h | 17 ++++--- 2 files changed, 78 insertions(+), 46 deletions(-) diff --git a/src/mame/drivers/atarisy1.cpp b/src/mame/drivers/atarisy1.cpp index cfa9d97a90d..f39bd664a8c 100644 --- a/src/mame/drivers/atarisy1.cpp +++ b/src/mame/drivers/atarisy1.cpp @@ -212,7 +212,7 @@ RoadBlasters (aka Future Vette):005* void atarisy1_state::update_interrupts() { - m_maincpu->set_input_line(2, m_joystick_int && m_joystick_int_enable ? ASSERT_LINE : CLEAR_LINE); + m_maincpu->set_input_line(2, m_joystick_int ? ASSERT_LINE : CLEAR_LINE); m_maincpu->set_input_line(3, m_scanline_int_state ? ASSERT_LINE : CLEAR_LINE); m_maincpu->set_input_line(4, m_video_int_state ? ASSERT_LINE : CLEAR_LINE); m_maincpu->set_input_line(6, m_sound_int_state ? ASSERT_LINE : CLEAR_LINE); @@ -223,9 +223,8 @@ MACHINE_START_MEMBER(atarisy1_state,atarisy1) { atarigen_state::machine_start(); + m_joystick_int = 0; save_item(NAME(m_joystick_int)); - save_item(NAME(m_joystick_int_enable)); - save_item(NAME(m_joystick_value)); } @@ -233,10 +232,8 @@ MACHINE_RESET_MEMBER(atarisy1_state,atarisy1) { atarigen_state::machine_reset(); - /* reset the joystick parameters */ - m_joystick_value = 0; - m_joystick_int = 0; - m_joystick_int_enable = 0; + if (m_adc.found()) + m_ajsint->in_w<0>(0); } @@ -246,47 +243,40 @@ MACHINE_RESET_MEMBER(atarisy1_state,atarisy1) * *************************************/ -TIMER_DEVICE_CALLBACK_MEMBER(atarisy1_state::delayed_joystick_int) +WRITE_LINE_MEMBER(atarisy1_state::joystick_int) { - m_joystick_value = param; - m_joystick_int = 1; + m_joystick_int = state; update_interrupts(); } -READ16_MEMBER(atarisy1_state::joystick_r) +template +READ8_MEMBER(atarisy1_state::digital_joystick_r) { - int newval = 0xff; - static const char *const portnames[] = { "IN0", "IN1" }; + return BIT(ioport("IN0")->read(), 7 - Input) ? 0xf0 : 0x00; +} - /* digital joystick type */ - if (m_joystick_type == 1) - newval = (ioport("IN0")->read() & (0x80 >> offset)) ? 0xf0 : 0x00; - /* Hall-effect analog joystick */ - else if (m_joystick_type == 2) - newval = ioport(portnames[offset & 1])->read(); +READ8_MEMBER(atarisy1_state::adc_r) +{ + if (!m_adc.found()) + return 0xff; - /* Road Blasters gas pedal */ - else if (m_joystick_type == 3) - newval = ioport("IN1")->read(); + int value = m_adc->data_r(space, 0); - /* the A4 bit enables/disables joystick IRQs */ - m_joystick_int_enable = ((offset >> 3) & 1) ^ 1; + if (!machine().side_effects_disabled()) + adc_w(space, offset, 0); - /* clear any existing interrupt and set a timer for a new one */ - m_joystick_int = 0; - m_joystick_timer->adjust(attotime::from_usec(50), newval); - update_interrupts(); - - return m_joystick_value; + return value; } -WRITE16_MEMBER(atarisy1_state::joystick_w) +WRITE8_MEMBER(atarisy1_state::adc_w) { + m_adc->address_offset_start_w(space, offset & 7, 0); + /* the A4 bit enables/disables joystick IRQs */ - m_joystick_int_enable = ((offset >> 3) & 1) ^ 1; + m_ajsint->in_w<0>(!BIT(offset, 3)); } @@ -465,7 +455,7 @@ void atarisy1_state::main_map(address_map &map) map(0xb00000, 0xb007ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); map(0xf00000, 0xf00fff).rw("eeprom", FUNC(eeprom_parallel_28xx_device::read), FUNC(eeprom_parallel_28xx_device::write)).umask16(0x00ff); map(0xf20000, 0xf20007).r(this, FUNC(atarisy1_state::trakball_r)); - map(0xf40000, 0xf4001f).rw(this, FUNC(atarisy1_state::joystick_r), FUNC(atarisy1_state::joystick_w)); + map(0xf40000, 0xf4001f).rw(this, FUNC(atarisy1_state::adc_r), FUNC(atarisy1_state::adc_w)).umask16(0x00ff); map(0xf60000, 0xf60003).portr("F60000"); map(0xf80001, 0xf80001).w(m_soundcomm, FUNC(atari_sound_comm_device::main_command_w)); /* used by roadbls2 */ map(0xfc0001, 0xfc0001).r(m_soundcomm, FUNC(atari_sound_comm_device::main_response_r)); @@ -739,6 +729,20 @@ MACHINE_CONFIG_START(atarisy1_state::atarisy1) MCFG_MACHINE_START_OVERRIDE(atarisy1_state,atarisy1) MCFG_MACHINE_RESET_OVERRIDE(atarisy1_state,atarisy1) + MCFG_DEVICE_ADD("adc", ADC0809, ATARI_CLOCK_14MHz/16) + MCFG_ADC0808_EOC_CB(DEVWRITELINE("ajsint", input_merger_device, in_w<1>)) + // IN7 = J102 pin 2 + // IN6 = J102 pin 3 + // IN5 = J102 pin 4 + // IN4 = J102 pin 6 + // IN3 = J102 pin 8 + // IN2 = J102 pin 9 + // IN1 = J102 pin 7 + // IN0 = J102 pin 5 + + MCFG_INPUT_MERGER_ALL_HIGH("ajsint") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(WRITELINE(atarisy1_state, joystick_int)) + MCFG_EEPROM_2804_ADD("eeprom") MCFG_EEPROM_28XX_LOCK_AFTER_WRITE(true) @@ -751,7 +755,6 @@ MACHINE_CONFIG_START(atarisy1_state::atarisy1) MCFG_WATCHDOG_ADD("watchdog") - MCFG_TIMER_DRIVER_ADD("joystick_timer", atarisy1_state, delayed_joystick_int) MCFG_TIMER_DRIVER_ADD("scan_timer", atarisy1_state, atarisy1_int3_callback) MCFG_TIMER_DRIVER_ADD("int3off_timer", atarisy1_state, atarisy1_int3off_callback) MCFG_TIMER_DRIVER_ADD("yreset_timer", atarisy1_state, atarisy1_reset_yscroll_callback) @@ -807,31 +810,62 @@ MACHINE_CONFIG_END MACHINE_CONFIG_START(atarisy1_state::marble) atarisy1(config); MCFG_SLAPSTIC_ADD("slapstic", 103) + + // No joystick + MCFG_DEVICE_REMOVE("adc") + MCFG_DEVICE_REMOVE("ajsint") MACHINE_CONFIG_END MACHINE_CONFIG_START(atarisy1_state::peterpak) atarisy1(config); MCFG_SLAPSTIC_ADD("slapstic", 107) + + // Digital joystick read through ADC + MCFG_DEVICE_MODIFY("adc") + MCFG_ADC0808_IN0_CB(READ8(atarisy1_state, digital_joystick_r<0>)) + MCFG_ADC0808_IN1_CB(READ8(atarisy1_state, digital_joystick_r<1>)) + MCFG_ADC0808_IN2_CB(READ8(atarisy1_state, digital_joystick_r<2>)) + MCFG_ADC0808_IN3_CB(READ8(atarisy1_state, digital_joystick_r<3>)) MACHINE_CONFIG_END MACHINE_CONFIG_START(atarisy1_state::indytemp) atarisy1(config); MCFG_SLAPSTIC_ADD("slapstic", 105) + + // Digital joystick read through ADC + MCFG_DEVICE_MODIFY("adc") + MCFG_ADC0808_IN0_CB(READ8(atarisy1_state, digital_joystick_r<0>)) + MCFG_ADC0808_IN1_CB(READ8(atarisy1_state, digital_joystick_r<1>)) + MCFG_ADC0808_IN2_CB(READ8(atarisy1_state, digital_joystick_r<2>)) + MCFG_ADC0808_IN3_CB(READ8(atarisy1_state, digital_joystick_r<3>)) MACHINE_CONFIG_END MACHINE_CONFIG_START(atarisy1_state::roadrunn) atarisy1(config); MCFG_SLAPSTIC_ADD("slapstic", 108) + + // Hall-effect analog joystick + MCFG_DEVICE_MODIFY("adc") + MCFG_ADC0808_IN6_CB(IOPORT("IN0")) + MCFG_ADC0808_IN7_CB(IOPORT("IN1")) MACHINE_CONFIG_END MACHINE_CONFIG_START(atarisy1_state::roadb109) atarisy1(config); MCFG_SLAPSTIC_ADD("slapstic", 109) + + // Road Blasters gas pedal + MCFG_DEVICE_MODIFY("adc") + MCFG_ADC0808_IN2_CB(IOPORT("IN1")) MACHINE_CONFIG_END MACHINE_CONFIG_START(atarisy1_state::roadb110) atarisy1(config); MCFG_SLAPSTIC_ADD("slapstic", 110) + + // Road Blasters gas pedal + MCFG_DEVICE_MODIFY("adc") + MCFG_ADC0808_IN2_CB(IOPORT("IN1")) MACHINE_CONFIG_END @@ -2466,7 +2500,6 @@ DRIVER_INIT_MEMBER(atarisy1_state,marble) { slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000); - m_joystick_type = 0; /* none */ m_trackball_type = 1; /* rotated */ } @@ -2475,7 +2508,6 @@ DRIVER_INIT_MEMBER(atarisy1_state,peterpak) { slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000); - m_joystick_type = 1; /* digital */ m_trackball_type = 0; /* none */ } @@ -2484,7 +2516,6 @@ DRIVER_INIT_MEMBER(atarisy1_state,indytemp) { slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000); - m_joystick_type = 1; /* digital */ m_trackball_type = 0; /* none */ } @@ -2493,7 +2524,6 @@ DRIVER_INIT_MEMBER(atarisy1_state,roadrunn) { slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000); - m_joystick_type = 2; /* analog */ m_trackball_type = 0; /* none */ } @@ -2502,7 +2532,6 @@ DRIVER_INIT_MEMBER(atarisy1_state,roadblst) { slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000); - m_joystick_type = 3; /* pedal */ m_trackball_type = 2; /* steering wheel */ } diff --git a/src/mame/includes/atarisy1.h b/src/mame/includes/atarisy1.h index 2e49fc4ac58..adeabc0e323 100644 --- a/src/mame/includes/atarisy1.h +++ b/src/mame/includes/atarisy1.h @@ -7,7 +7,9 @@ *************************************************************************/ #include "machine/74259.h" +#include "machine/adc0808.h" #include "machine/atarigen.h" +#include "machine/input_merger.h" #include "machine/timer.h" #include "sound/tms5220.h" #include "sound/ym2151.h" @@ -22,7 +24,8 @@ public: m_soundcomm(*this, "soundcomm"), m_bankselect(*this, "bankselect"), m_mob(*this, "mob"), - m_joystick_timer(*this, "joystick_timer"), + m_adc(*this, "adc"), + m_ajsint(*this, "ajsint"), m_playfield_tilemap(*this, "playfield"), m_alpha_tilemap(*this, "alpha"), m_yscroll_reset_timer(*this, "yreset_timer"), @@ -40,10 +43,9 @@ public: uint8_t m_joystick_type; uint8_t m_trackball_type; - required_device m_joystick_timer; + optional_device m_adc; + optional_device m_ajsint; uint8_t m_joystick_int; - uint8_t m_joystick_int_enable; - uint8_t m_joystick_value; /* playfield parameters */ required_device m_playfield_tilemap; @@ -69,8 +71,9 @@ public: uint8_t m_cur[2][2]; virtual void update_interrupts() override; - DECLARE_READ16_MEMBER(joystick_r); - DECLARE_WRITE16_MEMBER(joystick_w); + template DECLARE_READ8_MEMBER(digital_joystick_r); + DECLARE_READ8_MEMBER(adc_r); + DECLARE_WRITE8_MEMBER(adc_w); DECLARE_READ16_MEMBER(trakball_r); DECLARE_READ8_MEMBER(switch_6502_r); DECLARE_WRITE_LINE_MEMBER(led_1_w); @@ -92,7 +95,7 @@ public: DECLARE_MACHINE_RESET(atarisy1); DECLARE_VIDEO_START(atarisy1); uint32_t screen_update_atarisy1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - TIMER_DEVICE_CALLBACK_MEMBER(delayed_joystick_int); + DECLARE_WRITE_LINE_MEMBER(joystick_int); TIMER_DEVICE_CALLBACK_MEMBER(atarisy1_reset_yscroll_callback); TIMER_DEVICE_CALLBACK_MEMBER(atarisy1_int3off_callback); TIMER_DEVICE_CALLBACK_MEMBER(atarisy1_int3_callback); -- cgit v1.2.3