From 54797825ba86c00add667a66a81b03a2140f4091 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Mon, 3 Feb 2014 22:15:14 +0000 Subject: [PATCH] (MESS) 64h156: Return of the weak bits. (nw) --- src/emu/machine/64h156.c | 18 +++++++++++++++++- src/emu/machine/64h156.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/emu/machine/64h156.c b/src/emu/machine/64h156.c index 4d600176a66..b4f1354b515 100644 --- a/src/emu/machine/64h156.c +++ b/src/emu/machine/64h156.c @@ -87,7 +87,19 @@ inline void c64h156_device::receive_bit() m_bit_sync = (m_edge.is_never() || m_edge >= next) ? 0 : 1; if (m_bit_sync) { + m_zero_count = 0; + m_cycles_until_random_flux = (rand() % 31) + 289; + get_next_edge(when); + } else { + m_zero_count++; + } + + if (m_zero_count >= m_cycles_until_random_flux) { + m_bit_sync = 1; + + m_zero_count = 0; + m_cycles_until_random_flux = (rand() % 367) + 33; } } @@ -311,7 +323,9 @@ c64h156_device::c64h156_device(const machine_config &mconfig, const char *tag, d m_u4a(0), m_u4b(0), m_ue3(0), - m_uc1b(0) + m_uc1b(0), + m_zero_count(0), + m_cycles_until_random_flux(0) { } @@ -357,6 +371,8 @@ void c64h156_device::device_start() save_item(NAME(m_uc1b)); save_item(NAME(m_via_pa)); save_item(NAME(m_ud3)); + save_item(NAME(m_zero_count)); + save_item(NAME(m_cycles_until_random_flux)); } diff --git a/src/emu/machine/64h156.h b/src/emu/machine/64h156.h index 78a5dd0e65e..3d586eed828 100644 --- a/src/emu/machine/64h156.h +++ b/src/emu/machine/64h156.h @@ -177,6 +177,8 @@ private: int m_u4b; int m_ue3; int m_uc1b; + int m_zero_count; + int m_cycles_until_random_flux; // write logic UINT8 m_via_pa;