summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/atarisy1.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2018-04-02 19:38:49 -0400
committer AJR <ajrhacker@users.noreply.github.com>2018-04-02 19:38:49 -0400
commit8ed432758a575a17479a35af7c777fcd23967fc4 (patch)
tree92d8b025657ad2323e9482543ecc83d7927d7347 /src/mame/drivers/atarisy1.cpp
parente95e28db8a02d76fcc0dd4fa5a237c86e70dbbb4 (diff)
atarisy1.cpp: Use ADC0809 device for all except marble (nw)
Diffstat (limited to 'src/mame/drivers/atarisy1.cpp')
-rw-r--r--src/mame/drivers/atarisy1.cpp107
1 files changed, 68 insertions, 39 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<int Input>
+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 */
}