From 4210ce2de00ab1bef328c4fa93ef49508db29e71 Mon Sep 17 00:00:00 2001 From: arbee Date: Sat, 16 Feb 2019 15:27:10 -0500 Subject: apple2: fix missing floating bus reads and improved joystick/paddle calibration [Golden Child] --- src/mame/drivers/apple2.cpp | 22 ++++++++++---------- src/mame/drivers/apple2e.cpp | 48 ++++++++++++++++++++++--------------------- src/mame/drivers/apple2gs.cpp | 21 ++++++++++--------- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/mame/drivers/apple2.cpp b/src/mame/drivers/apple2.cpp index edfba571531..7e0b4bea203 100644 --- a/src/mame/drivers/apple2.cpp +++ b/src/mame/drivers/apple2.cpp @@ -313,8 +313,8 @@ void apple2_state::machine_start() m_inh_bank = 0; // precalculate joystick time constants - m_x_calibration = attotime::from_usec(12).as_double(); - m_y_calibration = attotime::from_usec(13).as_double(); + m_x_calibration = attotime::from_nsec(10800).as_double(); + m_y_calibration = attotime::from_nsec(10800).as_double(); // cache slot devices for (int i = 0; i <= 7; i++) @@ -630,33 +630,33 @@ READ8_MEMBER(apple2_state::flags_r) switch (offset) { case 0: // cassette in - return m_cassette->input() > 0.0 ? 0x80 : 0; + return (m_cassette->input() > 0.0 ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 1: // button 0 - return (m_joybuttons->read() & 0x10) ? 0x80 : 0; + return ((m_joybuttons->read() & 0x10) ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 2: // button 1 - return (m_joybuttons->read() & 0x20) ? 0x80 : 0; + return ((m_joybuttons->read() & 0x20) ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 3: // button 2 // check if SHIFT key mod configured if (m_sysconfig->read() & 0x04) { - return ((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | (read_floatingbus() & 0x3f); } - return (m_joybuttons->read() & 0x40) ? 0x80 : 0; + return ((m_joybuttons->read() & 0x40) ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 4: // joy 1 X axis - return (machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 5: // joy 1 Y axis - return (machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 6: // joy 2 X axis - return (machine().time().as_double() < m_joystick_x2_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_x2_time) ? 0x80 : 0) | (read_floatingbus() & 0x7f); case 7: // joy 2 Y axis - return (machine().time().as_double() < m_joystick_y2_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_y2_time) ? 0x80 : 0) | (read_floatingbus() & 0x7f); } // this is never reached diff --git a/src/mame/drivers/apple2e.cpp b/src/mame/drivers/apple2e.cpp index 6956d51b541..b560a9b8917 100644 --- a/src/mame/drivers/apple2e.cpp +++ b/src/mame/drivers/apple2e.cpp @@ -780,8 +780,8 @@ void apple2e_state::machine_start() } // precalculate joystick time constants - m_x_calibration = attotime::from_usec(12).as_double(); - m_y_calibration = attotime::from_usec(13).as_double(); + m_x_calibration = attotime::from_nsec(10800).as_double(); + m_y_calibration = attotime::from_nsec(10800).as_double(); // cache slot devices for (int i = 0; i <= 7; i++) @@ -1592,6 +1592,7 @@ void apple2e_state::do_io(address_space &space, int offset, bool is_iic) READ8_MEMBER(apple2e_state::c000_r) { if(machine().side_effects_disabled()) return read_floatingbus(); + u8 uFloatingBus7 = read_floatingbus() & 0x7f; if ((offset & 0xf0) == 0x00) // keyboard latch, $C000 is really 00-0F { @@ -1656,43 +1657,43 @@ READ8_MEMBER(apple2e_state::c000_r) case 0x68: if (m_cassette) { - return m_cassette->input() > 0.0 ? 0x80 : 0; + return (m_cassette->input() > 0.0 ? 0x80 : 0) | uFloatingBus7; } - return 0; + return uFloatingBus7; case 0x61: // button 0 or Open Apple case 0x69: - return ((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; case 0x62: // button 1 or Solid Apple case 0x6a: - return ((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; case 0x63: // button 2 or SHIFT key case 0x6b: - return ((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; case 0x64: // joy 1 X axis case 0x6c: - return (machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0) | uFloatingBus7; case 0x65: // joy 1 Y axis case 0x6d: - return (machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0) | uFloatingBus7; case 0x66: // joy 2 X axis case 0x6e: - return (machine().time().as_double() < m_joystick_x2_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_x2_time) ? 0x80 : 0) | uFloatingBus7; case 0x67: // joy 2 Y axis case 0x6f: - return (machine().time().as_double() < m_joystick_y2_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_y2_time) ? 0x80 : 0) | uFloatingBus7; case 0x7e: // read IOUDIS - return m_ioudis ? 0x80 : 0x00; + return (m_ioudis ? 0x80 : 0x00) | uFloatingBus7; case 0x7f: // read DHIRES - return m_video->m_dhires ? 0x00 : 0x80; + return (m_video->m_dhires ? 0x00 : 0x80) | uFloatingBus7; default: do_io(space, offset, false); @@ -1833,6 +1834,7 @@ WRITE8_MEMBER(apple2e_state::c000_w) READ8_MEMBER(apple2e_state::c000_iic_r) { if(machine().side_effects_disabled()) return read_floatingbus(); + u8 uFloatingBus7 = read_floatingbus() & 0x7f; if ((offset & 0xf0) == 0x00) // keyboard latch, $C000 is really 00-0F { @@ -1908,43 +1910,43 @@ READ8_MEMBER(apple2e_state::c000_iic_r) return m_y0edge ? 0x80 : 0x00; case 0x60: // 40/80 column switch (IIc only) - return (m_sysconfig->read() & 0x04) ? 0x80 : 0; + return ((m_sysconfig->read() & 0x04) ? 0x80 : 0) | uFloatingBus7; case 0x61: // button 0 or Open Apple or mouse button 1 case 0x69: - return ((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; case 0x62: // button 1 or Solid Apple case 0x6a: - return ((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; case 0x63: // mouse button 2 (no other function on IIc) case 0x6b: - return m_mouseb->read() ? 0 : 0x80; + return (m_mouseb->read() ? 0 : 0x80) | uFloatingBus7; case 0x64: // joy 1 X axis case 0x6c: - return (machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0) | uFloatingBus7; case 0x65: // joy 1 Y axis case 0x6d: - return (machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0) | uFloatingBus7; case 0x66: // mouse X1 (IIc only) case 0x6e: - return m_x1 ? 0x80 : 0; + return (m_x1 ? 0x80 : 0) | uFloatingBus7; case 0x67: // mouse Y1 (IIc only) case 0x6f: - return m_y1 ? 0x80 : 0; + return (m_y1 ? 0x80 : 0) | uFloatingBus7; case 0x7e: // read IOUDIS m_vbl = false; lower_irq(IRQ_VBL); - return m_ioudis ? 0x80 : 0x00; + return (m_ioudis ? 0x80 : 0x00) | uFloatingBus7; case 0x7f: // read DHIRES - return m_video->m_dhires ? 0x00 : 0x80; + return (m_video->m_dhires ? 0x00 : 0x80) | uFloatingBus7; default: do_io(space, offset, true); diff --git a/src/mame/drivers/apple2gs.cpp b/src/mame/drivers/apple2gs.cpp index db2ab6bbdd5..efa0517557a 100644 --- a/src/mame/drivers/apple2gs.cpp +++ b/src/mame/drivers/apple2gs.cpp @@ -1212,8 +1212,8 @@ void apple2gs_state::machine_start() m_speaker->set_levels(16, lvlTable); // precalculate joystick time constants - m_x_calibration = attotime::from_usec(12).as_double(); - m_y_calibration = attotime::from_usec(13).as_double(); + m_x_calibration = attotime::from_nsec(10800).as_double(); + m_y_calibration = attotime::from_nsec(10800).as_double(); // cache slot devices for (int i = 0; i <= 7; i++) @@ -2029,6 +2029,7 @@ READ8_MEMBER(apple2gs_state::c000_r) } slow_cycle(); + u8 uFloatingBus7 = read_floatingbus(); switch (offset) { @@ -2272,28 +2273,28 @@ READ8_MEMBER(apple2gs_state::c000_r) return (m_an3 ? INTFLAG_AN3 : 0x00) | m_intflag; case 0x60: // button 3 on IIgs - return (m_joybuttons->read() & 0x80); + return (m_joybuttons->read() & 0x80) | uFloatingBus7; case 0x61: // button 0 or Open Apple - return ((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x10) || (m_kbspecial->read() & 0x10)) ? 0x80 : 0) | uFloatingBus7; case 0x62: // button 1 or Solid Apple - return ((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x20) || (m_kbspecial->read() & 0x20)) ? 0x80 : 0) | uFloatingBus7; case 0x63: // button 2 or SHIFT key - return ((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0; + return (((m_joybuttons->read() & 0x40) || (m_kbspecial->read() & 0x06)) ? 0x80 : 0) | uFloatingBus7; case 0x64: // joy 1 X axis - return (machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_x1_time) ? 0x80 : 0) | uFloatingBus7; case 0x65: // joy 1 Y axis - return (machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_y1_time) ? 0x80 : 0) | uFloatingBus7; case 0x66: // joy 2 X axis - return (machine().time().as_double() < m_joystick_x2_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_x2_time) ? 0x80 : 0) | uFloatingBus7; case 0x67: // joy 2 Y axis - return (machine().time().as_double() < m_joystick_y2_time) ? 0x80 : 0; + return ((machine().time().as_double() < m_joystick_y2_time) ? 0x80 : 0) | uFloatingBus7; case 0x68: // STATEREG, synthesizes all the IIe state regs return (m_altzp ? 0x80 : 0x00) | -- cgit v1.2.3