From ca9069617e741d8db2516e1bb55a7887fc8087d6 Mon Sep 17 00:00:00 2001 From: arbee Date: Mon, 10 Jun 2024 21:32:10 -0400 Subject: [PATCH] apple/adbmodem.cpp: Fixed clock to the SCC 3.68 MHz from the schematics, brings ADB timings exactly to spec. [R. Belmont] apple/macii.cpp, apple/maciici.cpp: With the adjusted timings, adbmodem now works with the Mac II/IIx/IIcx/IIci, and SE/30. This corrects the jerky mouse movements caused by macadb HLE mode (GitHub issue #12189). [R. Belmont] apple/maciifx.cpp: Corrected ADB hookup, PIC now transmits valid ADB but doesn't appear to receive it. [R. Belmont] --- src/mame/apple/adbmodem.cpp | 2 +- src/mame/apple/apple2gs.cpp | 2 -- src/mame/apple/macii.cpp | 32 ----------------------------- src/mame/apple/maciici.cpp | 40 ++++++++++++++++++++++++------------- src/mame/apple/maciifx.cpp | 2 +- 5 files changed, 28 insertions(+), 50 deletions(-) diff --git a/src/mame/apple/adbmodem.cpp b/src/mame/apple/adbmodem.cpp index 0f3424c8b43..1e310864a34 100644 --- a/src/mame/apple/adbmodem.cpp +++ b/src/mame/apple/adbmodem.cpp @@ -47,7 +47,7 @@ void adbmodem_device::adbmodem_map(address_map &map) void adbmodem_device::device_add_mconfig(machine_config &config) { - PIC1654S(config, m_maincpu, 15.6672_MHz_XTAL/4); + PIC1654S(config, m_maincpu, 3.6864_MHz_XTAL); m_maincpu->set_addrmap(AS_PROGRAM, &adbmodem_device::adbmodem_map); m_maincpu->read_a().set(FUNC(adbmodem_device::porta_r)); m_maincpu->write_a().set(FUNC(adbmodem_device::porta_w)); diff --git a/src/mame/apple/apple2gs.cpp b/src/mame/apple/apple2gs.cpp index 9895d9dd301..a2bad0d7f25 100644 --- a/src/mame/apple/apple2gs.cpp +++ b/src/mame/apple/apple2gs.cpp @@ -1047,7 +1047,6 @@ TIMER_DEVICE_CALLBACK_MEMBER(apple2gs_state::apple2_interrupt) if (scanline == (192+BORDER_TOP)) { - m_macadb->adb_vblank(); m_vbl = true; // VBL interrupt @@ -3794,7 +3793,6 @@ void apple2gs_state::apple2gs(machine_config &config) m_adbmicro->write_p<3>().set(FUNC(apple2gs_state::adbmicro_p3_out)); MACADB(config, m_macadb, A2GS_MASTER_CLOCK/8); - m_macadb->set_mcu_mode(true); m_macadb->adb_data_callback().set(FUNC(apple2gs_state::set_adb_line)); RTC3430042(config, m_rtc, XTAL(32'768)); diff --git a/src/mame/apple/macii.cpp b/src/mame/apple/macii.cpp index 78a79e5ab2a..e8b8071129f 100644 --- a/src/mame/apple/macii.cpp +++ b/src/mame/apple/macii.cpp @@ -60,8 +60,6 @@ namespace { #define MAC_H_TOTAL (704) // (512+192) #define MAC_V_TOTAL (370) // (342+28) -#define MACII_USE_ADBMODEM (0) - // Mac driver data class mac_state:public driver_device @@ -212,7 +210,6 @@ class mac_state:public driver_device TIMER_CALLBACK_MEMBER(mac_adbrefresh_tick); TIMER_CALLBACK_MEMBER(mac_scanline_tick); - void mac_adb_via_out_cb2(int state); uint8_t mac_via_in_a(); uint8_t mac_via_in_b(); void mac_via_out_a(uint8_t data); @@ -537,17 +534,6 @@ void mac_state::mac_iwm_w(offs_t offset, uint16_t data, uint16_t mem_mask) m_maincpu->adjust_icount(-5); } -void mac_state::mac_adb_via_out_cb2(int state) -{ - // printf("VIA OUT CB2 = %x\n", state); -#if !MACII_USE_ADBMODEM - if (m_macadb) - { - m_macadb->adb_data_w(state); - } -#endif -} - /* ************************************************************************* * VIA * ************************************************************************* @@ -610,10 +596,6 @@ uint8_t mac_state::mac_via_in_b() { int val = 0; -#if !MACII_USE_ADBMODEM - val |= m_macadb->get_adb_state() << 4; -#endif - if (!m_adb_irq_pending) { val |= 0x08; @@ -651,11 +633,7 @@ void mac_state::mac_via_out_b(uint8_t data) } } -#if MACII_USE_ADBMODEM m_adbmodem->set_via_state((data & 0x30) >> 4); -#else - m_macadb->mac_adb_newaction((data & 0x30) >> 4); -#endif m_rtc->ce_w((data & 0x04) >> 2); m_rtc->data_w(data & 0x01); @@ -1113,7 +1091,6 @@ void mac_state::macii(machine_config &config) m_via1->readpb_handler().set(FUNC(mac_state::mac_via_in_b)); m_via1->writepa_handler().set(FUNC(mac_state::mac_via_out_a)); m_via1->writepb_handler().set(FUNC(mac_state::mac_via_out_b)); - m_via1->cb2_handler().set(FUNC(mac_state::mac_adb_via_out_cb2)); m_via1->irq_handler().set(FUNC(mac_state::mac_via_irq)); R65NC22(config, m_via2, C7M/10); @@ -1123,7 +1100,6 @@ void mac_state::macii(machine_config &config) m_via2->writepb_handler().set(FUNC(mac_state::mac_via2_out_b)); m_via2->irq_handler().set(FUNC(mac_state::mac_via2_irq)); -#if MACII_USE_ADBMODEM ADBMODEM(config, m_adbmodem, C7M); m_adbmodem->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); m_adbmodem->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); @@ -1131,17 +1107,9 @@ void mac_state::macii(machine_config &config) m_adbmodem->irq_callback().set(FUNC(mac_state::adb_irq_w)); m_via1->cb2_handler().set(m_adbmodem, FUNC(adbmodem_device::set_via_data)); config.set_perfect_quantum(m_maincpu); -#endif MACADB(config, m_macadb, C15M); -#if !MACII_USE_ADBMODEM - m_macadb->set_mcu_mode(false); - m_macadb->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); - m_macadb->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); - m_macadb->adb_irq_callback().set(FUNC(mac_state::adb_irq_w)); -#else m_macadb->adb_data_callback().set(m_adbmodem, FUNC(adbmodem_device::set_adb_line)); -#endif RAM(config, m_ram); m_ram->set_default_size("2M"); diff --git a/src/mame/apple/maciici.cpp b/src/mame/apple/maciici.cpp index 68b1fb832b5..97ed6946bff 100644 --- a/src/mame/apple/maciici.cpp +++ b/src/mame/apple/maciici.cpp @@ -17,6 +17,7 @@ #include "emu.h" +#include "adbmodem.h" #include "egret.h" #include "macadb.h" #include "macrtc.h" @@ -58,6 +59,7 @@ class maciici_state : public driver_device m_rbv(*this, "rbv"), m_macadb(*this, "macadb"), m_ram(*this, RAM_TAG), + m_adbmodem(*this, "adbmodem"), m_asc(*this, "asc"), m_scsibus1(*this, "scsi"), m_ncr5380(*this, "scsi:7:ncr5380"), @@ -70,6 +72,7 @@ class maciici_state : public driver_device { } + void maciixi_base(machine_config &config); void maciici(machine_config &config); void maciisi(machine_config &config); @@ -83,6 +86,7 @@ class maciici_state : public driver_device required_device m_rbv; required_device m_macadb; required_device m_ram; + optional_device m_adbmodem; required_device m_asc; required_device m_scsibus1; required_device m_ncr5380; @@ -340,15 +344,13 @@ uint8_t maciici_state::via_in_a_iisi() uint8_t maciici_state::via_in_b() { - u8 val = m_macadb->get_adb_state() << 4; + u8 val = m_rtc->data_r(); if (!m_adb_irq_pending) { val |= 0x08; } - val |= m_rtc->data_r(); - return val; } @@ -373,9 +375,9 @@ void maciici_state::via_out_a(uint8_t data) void maciici_state::via_out_b(uint8_t data) { // printf("%s VIA1 OUT B: %02x\n", machine().describe_context().c_str(), data); - m_macadb->mac_adb_newaction((data & 0x30) >> 4); + m_adbmodem->set_via_state((data & 0x30) >> 4); - m_rtc->ce_w(BIT(data, 2)); +m_rtc->ce_w(BIT(data, 2)); m_rtc->data_w(BIT(data, 0)); m_rtc->clk_w(BIT(data, 1)); } @@ -388,7 +390,7 @@ void maciici_state::via_out_b_iisi(uint8_t data) void maciici_state::via_out_cb2(int state) { - m_macadb->adb_data_w(state); +// m_macadb->adb_data_w(state); } void maciici_state::via_out_cb2_iisi(int state) @@ -503,7 +505,7 @@ INPUT_PORTS_END /*************************************************************************** MACHINE DRIVERS ***************************************************************************/ -void maciici_state::maciici(machine_config &config) +void maciici_state::maciixi_base(machine_config &config) { M68030(config, m_maincpu, 25000000); m_maincpu->set_addrmap(AS_PROGRAM, &maciici_state::maciici_map); @@ -610,29 +612,39 @@ void maciici_state::maciici(machine_config &config) NUBUS_SLOT(config, "nbc", "nubus", mac_nubus_cards, nullptr); NUBUS_SLOT(config, "nbd", "nubus", mac_nubus_cards, nullptr); NUBUS_SLOT(config, "nbe", "nubus", mac_nubus_cards, nullptr); +} + +void maciici_state::maciici(machine_config &config) +{ + maciixi_base(config); + + ADBMODEM(config, m_adbmodem, C7M); + m_adbmodem->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); + m_adbmodem->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); + m_adbmodem->linechange_callback().set(m_macadb, FUNC(macadb_device::adb_linechange_w)); + m_adbmodem->irq_callback().set(FUNC(maciici_state::adb_irq_w)); + m_via1->cb2_handler().set(m_adbmodem, FUNC(adbmodem_device::set_via_data)); + config.set_perfect_quantum(m_maincpu); MACADB(config, m_macadb, C15M); - m_macadb->set_mcu_mode(false); - m_macadb->via_clock_callback().set(m_via1, FUNC(via6522_device::write_cb1)); - m_macadb->via_data_callback().set(m_via1, FUNC(via6522_device::write_cb2)); - m_macadb->adb_irq_callback().set(FUNC(maciici_state::adb_irq_w)); + m_macadb->adb_data_callback().set(m_adbmodem, FUNC(adbmodem_device::set_adb_line)); } void maciici_state::maciisi(machine_config &config) { - maciici(config); + maciixi_base(config); M68030(config.replace(), m_maincpu, 20000000); m_maincpu->set_addrmap(AS_PROGRAM, &maciici_state::maciici_map); m_maincpu->set_dasm_override(std::function(&mac68k_dasm_override), "mac68k_dasm_override"); - MACADB(config.replace(), m_macadb, C15M); - m_via1->readpa_handler().set(FUNC(maciici_state::via_in_a_iisi)); m_via1->readpb_handler().set(FUNC(maciici_state::via_in_b_iisi)); m_via1->writepb_handler().set(FUNC(maciici_state::via_out_b_iisi)); m_via1->cb2_handler().set(FUNC(maciici_state::via_out_cb2_iisi)); + MACADB(config, m_macadb, C15M); + EGRET(config, m_egret, XTAL(32'768)); m_egret->set_default_bios_tag("344s0100"); m_egret->reset_callback().set(FUNC(maciici_state::egret_reset_w)); diff --git a/src/mame/apple/maciifx.cpp b/src/mame/apple/maciifx.cpp index efe38cece47..ac1aa7fe4df 100644 --- a/src/mame/apple/maciifx.cpp +++ b/src/mame/apple/maciifx.cpp @@ -580,7 +580,7 @@ void maciifx_state::maciifx(machine_config &config) swimpic.prd_callback().set(m_fdc, FUNC(applefdintf_device::read)); swimpic.pwr_callback().set(m_fdc, FUNC(applefdintf_device::write)); swimpic.hint_callback().set(FUNC(maciifx_state::oss_interrupt<6>)); - swimpic.gpout0_callback().set(m_macadb, FUNC(macadb_device::adb_data_w)); + swimpic.gpout0_callback().set(m_macadb, FUNC(macadb_device::adb_linechange_w)).invert(); swimpic.gpin_callback().set(FUNC(maciifx_state::adbin_r)); m_fdc->dat1byte_cb().set("swimpic", FUNC(applepic_device::reqa_w));