summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/saa1043.h
blob: 92f2f5a06695f733a78919eb3aa4c27d639fed5c (plain) (blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
/***********************************************************************

    Philips SAA1043 Universal Sync Generator emulation

    TODO:
    - Everything.

************************************************************************
                            _____   _____
                    BC   1 |*    \_/     | 28  Vdd
                   FH2   2 |             | 27  ID
                    SI   3 |             | 26  CS
                   FH3   4 |             | 25  CB
                     X   5 |             | 24  H2
                     Y   6 |             | 23  H1
                    FD   7 |   SAA1043   | 22  DL
                  FH80   8 |             | 21  CLP
                   VCR   9 |             | 20  V2
                  OSCO  10 |             | 19  V1
                  OSCI  11 |             | 18  RR
                    PH  12 |             | 17  WMP
                    NS  13 |             | 16  RI
                   Vss  14 |_____________| 15  ECS

************************************************************************/

#ifndef MAME_MACHINE_SAA1043_H
#define MAME_MACHINE_SAA1043_H

#pragma once



//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

// NB: This is effectively an aggregate of the X and Y inputs.
#define MCFG_SAA1043_TYPE(_type) \
	&downcast<saa1043_device &>(*device).set_type(_type);

#define MCFG_SAA1043_BC_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_bc_callback(DEVCB_##_write);

#define MCFG_SAA1043_FH2_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_fh2_callback(DEVCB_##_write);

#define MCFG_SAA1043_FH3_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_fh3_callback(DEVCB_##_write);

#define MCFG_SAA1043_FH80_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_fh80_callback(DEVCB_##_write);

#define MCFG_SAA1043_PH_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_ph_callback(DEVCB_##_write);

#define MCFG_SAA1043_NS_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_ns_callback(DEVCB_##_write);

#define MCFG_SAA1043_RI_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_ri_callback(DEVCB_##_write);

#define MCFG_SAA1043_WMP_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_wmp_callback(DEVCB_##_write);

#define MCFG_SAA1043_RR_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_rr_callback(DEVCB_##_write);

#define MCFG_SAA1043_V1_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_v1_callback(DEVCB_##_write);

#define MCFG_SAA1043_V2_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_v2_callback(DEVCB_##_write);

#define MCFG_SAA1043_CLP_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_clp_callback(DEVCB_##_write);

#define MCFG_SAA1043_DL_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_dl_callback(DEVCB_##_write);

#define MCFG_SAA1043_H1_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_h1_callback(DEVCB_##_write);

#define MCFG_SAA1043_H2_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_h2_callback(DEVCB_##_write);

#define MCFG_SAA1043_CB_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_cb_callback(DEVCB_##_write);

#define MCFG_SAA1043_CS_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_cs_callback(DEVCB_##_write);

#define MCFG_SAA1043_ID_CALLBACK(_write) \
	downcast<saa1043_device &>(*device).set_id_callback(DEVCB_##_write);

//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> saa1043_device

class saa1043_device : public device_t
{
public:
	// construction/destruction
	saa1043_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	enum outputs : uint32_t
	{
		BC,
		FH2,
		FH3,
		FH80,
		PH,
		NS,
		RI,
		WMP,
		RR,
		V1,
		V2,
		CLP,
		DL,
		H1,
		H2,
		CB,
		CS,
		ID,

		OUT_COUNT
	};

	enum signal_type : uint32_t
	{
		PAL,
		SECAM,
		NTSC,
		PAL_M,
	};

	void set_type(signal_type type) { m_type = type; }

	template <class Object> devcb_base &set_bc_callback(Object &&cb)   { m_outputs_hooked[BC] = true;   return m_outputs[BC].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_fh2_callback(Object &&cb)  { m_outputs_hooked[FH2] = true;  return m_outputs[FH2].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_fh3_callback(Object &&cb)  { m_outputs_hooked[FH3] = true;  return m_outputs[FH3].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_fh80_callback(Object &&cb) { m_outputs_hooked[FH80] = true; return m_outputs[FH80].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_ph_callback(Object &&cb)   { m_outputs_hooked[PH] = true;   return m_outputs[PH].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_ns_callback(Object &&cb)   { m_outputs_hooked[NS] = true;   return m_outputs[NS].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_ri_callback(Object &&cb)   { m_outputs_hooked[RI] = true;   return m_outputs[RI].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_wmp_callback(Object &&cb)  { m_outputs_hooked[WMP] = true;  return m_outputs[WMP].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_rr_callback(Object &&cb)   { m_outputs_hooked[RR] = true;   return m_outputs[RR].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_v1_callback(Object &&cb)   { m_outputs_hooked[V1] = true;   return m_outputs[V1].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_v2_callback(Object &&cb)   { m_outputs_hooked[V2] = true;   return m_outputs[V2].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_clp_callback(Object &&cb)  { m_outputs_hooked[CLP] = true;  return m_outputs[CLP].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_dl_callback(Object &&cb)   { m_outputs_hooked[DL] = true;   return m_outputs[DL].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_h1_callback(Object &&cb)   { m_outputs_hooked[H1] = true;   return m_outputs[H1].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_h2_callback(Object &&cb)   { m_outputs_hooked[H2] = true;   return m_outputs[H2].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_cb_callback(Object &&cb)   { m_outputs_hooked[CB] = true;   return m_outputs[CB].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_cs_callback(Object &&cb)   { m_outputs_hooked[CS] = true;   return m_outputs[CS].set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_id_callback(Object &&cb)   { m_outputs_hooked[ID] = true;   return m_outputs[ID].set_callback(std::forward<Object>(cb)); }

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;

private:
	devcb_write_line m_outputs[OUT_COUNT];
	bool m_outputs_hooked[OUT_COUNT];
	emu_timer *m_timers[OUT_COUNT];
	signal_type m_type;

	attotime m_h;
	uint32_t m_line_count;

	static const uint32_t s_line_counts[4];
};

// device type definition
DECLARE_DEVICE_TYPE(SAA1043, saa1043_device)

#endif // MAME_MACHINE_SAA1043_H