From d96b74baaffad8d21bd3536260abf500309e93c0 Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Fri, 8 May 2020 10:21:31 +0200 Subject: [PATCH] 6522via: Don't lose sync on edge count when the serial clock is external [O. Galibert] mac: Don't go out-of-bounds on palette writes [O. Galibert] --- src/devices/machine/6522via.cpp | 22 +++++++++++++--------- src/mame/drivers/mac.cpp | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/devices/machine/6522via.cpp b/src/devices/machine/6522via.cpp index fef19fab4b8..a0b66c138d8 100644 --- a/src/devices/machine/6522via.cpp +++ b/src/devices/machine/6522via.cpp @@ -459,7 +459,7 @@ void via6522_device::device_timer(emu_timer &timer, device_timer_id id, int para } // If in continous mode or the shifter is still shifting we re-arm the timer - if (SO_T2_RATE(m_acr) || (m_shift_counter != 0x0f)) + if (SO_T2_RATE(m_acr) || (m_shift_counter < 0x0f)) { if (SI_O2_CONTROL(m_acr) || SO_O2_CONTROL(m_acr)) { @@ -703,9 +703,14 @@ u8 via6522_device::read(offs_t offset) val = m_sr; if (!machine().side_effects_disabled()) { - m_out_cb1 = 1; - m_cb1_handler(m_out_cb1); - m_shift_counter = 0x0f; + if (!(SI_EXT_CONTROL(m_acr) || SO_EXT_CONTROL(m_acr))) { + m_out_cb1 = 1; + m_cb1_handler(m_out_cb1); + m_shift_counter = 0x0f; + } + else + m_shift_counter = m_in_cb1 ? 0x0f : 0x10; + LOGINT("SR INT "); clear_int(INT_SR); LOGSHIFT(" - ACR: %02x ", m_acr); @@ -889,15 +894,14 @@ void via6522_device::write(offs_t offset, u8 data) m_sr = data; LOGSHIFT("Write SR: %02x\n", m_sr); - // make sure CB1 is high - this should not be needed though - if (m_out_cb1 != 1) - { - logerror("VIA: CB1 is low starting shifter\n"); + if (!(SI_EXT_CONTROL(m_acr) || SO_EXT_CONTROL(m_acr))) { m_out_cb1 = 1; m_cb1_handler(m_out_cb1); + m_shift_counter = 0x0f; } + else + m_shift_counter = m_in_cb1 ? 0x0f : 0x10; - m_shift_counter = 0x0f; LOGINT("SR INT "); clear_int(INT_SR); LOGSHIFT(" - ACR is: %02x ", m_acr); diff --git a/src/mame/drivers/mac.cpp b/src/mame/drivers/mac.cpp index 3c7d19ef6a7..a3944ba5d82 100644 --- a/src/mame/drivers/mac.cpp +++ b/src/mame/drivers/mac.cpp @@ -179,14 +179,14 @@ WRITE32_MEMBER( mac_state::ariel_ramdac_w ) // this is for the "Ariel" style RAM { m_palette->set_pen_color(m_rbv_clutoffs, rgb_t(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2])); m_rbv_palette[m_rbv_clutoffs] = rgb_t(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]); - m_rbv_clutoffs++; + m_rbv_clutoffs = (m_rbv_clutoffs + 1) & 0xff; m_rbv_count = 0; } else { m_palette->set_pen_color(m_rbv_clutoffs, rgb_t(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2])); m_rbv_palette[m_rbv_clutoffs] = rgb_t(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2]); - m_rbv_clutoffs++; + m_rbv_clutoffs = (m_rbv_clutoffs + 1) & 0xff; m_rbv_count = 0; } }