1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
/***********************************************************************
Philips SAA1043 Universal Sync Generator
TOOD:
- Everything.
***********************************************************************/
#include "emu.h"
#include "saa1043.h"
#include <algorithm>
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)
{
std::fill(std::begin(m_outputs_hooked), std::end(m_outputs_hooked), false);
}
void saa1043_device::device_start()
{
m_h = attotime::from_ticks(320, clock() * 2);
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);
}
m_outputs[V2](ASSERT_LINE);
}
void saa1043_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
switch (id)
{
case V2:
m_outputs[V2](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;
}
}
|