diff options
Diffstat (limited to 'src/devices/machine/saa1043.cpp')
-rw-r--r-- | src/devices/machine/saa1043.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/devices/machine/saa1043.cpp b/src/devices/machine/saa1043.cpp new file mode 100644 index 00000000000..a45b14e0764 --- /dev/null +++ b/src/devices/machine/saa1043.cpp @@ -0,0 +1,78 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/*********************************************************************** + + Philips SAA1043 Universal Sync Generator + + TOOD: + - Everything. + +***********************************************************************/ + +#include "emu.h" +#include "saa1043.h" + +DEFINE_DEVICE_TYPE(SAA1043, saa1043_device, "saa1043", "Philips SAA1043") + +/*static*/ const uint32_t saa1043_device::s_line_counts[4] = { 624, 624, 524, 524 }; + +saa1043_device::saa1043_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, SAA1043, tag, owner, clock) + , m_outputs({ *this, *this, *this, *this, *this, *this, + *this, *this, *this, *this, *this, *this, + *this, *this, *this, *this, *this, *this }) +{ + memset(m_outputs_hooked, 0, sizeof(bool) * OUT_COUNT); +} + +void saa1043_device::device_start() +{ + m_h = attotime::from_ticks(320, clock()); + m_line_count = s_line_counts[m_type]; + + // resolve callbacks + for (uint32_t i = 0; i < OUT_COUNT; i++) + { + m_outputs[i].resolve_safe(); + if (m_outputs_hooked[i]) + { + m_timers[i] = timer_alloc(i); + switch(i) + { + case V2: + m_timers[V2]->adjust(m_h * 6, 1); + break; + default: + // Not yet implemented + break; + } + } + } +} + +void saa1043_device::device_reset() +{ + // Clear any existing clock states + for (uint32_t i = 0; i < OUT_COUNT; i++) + { + m_outputs[i](CLEAR_LINE); + } +} + +void saa1043_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case V2: + m_outputs[id](1 - param); + if (param) + m_timers[V2]->adjust(m_h * (m_line_count - 9), 0); + else + m_timers[V2]->adjust(m_h * 9, 1); + break; + + default: + // Not yet implemented + break; + } +} |