1 // license:CC0
2 // copyright-holders:Couriersud
3 #include "netlist/devices/net_lib.h"
4 
5 //NL_CONTAINS segas16b_audio
6 
7 NETLIST_START(segas16b_audio)
8 	SOLVER(Solver, 48000)
9 	//PARAM(Solver.DYNAMIC_TS, 1)
10 
11 	ANALOG_INPUT(VP5, 5)
12 	ANALOG_INPUT(VP12, 12)
13 
14 	/* UPD7759 has resistor of 47K on reference pin
15 	 * ==> IREF ~30 uA
16 	 * According to datasheet maximum current sink
17 	 * is 34 * IREF.
18 	 *
19 	 * MAME must provide range of 0 to 1020 uA to the current sink.
20 	 *
21 	 */
22 #if 0
23 	CLOCK(T0, 10)
24 	NET_C(GND, T0.GND)
25 	NET_C(VP5, T0.VCC)
26 	RES(T0R, RES_M(10000000))
27 	NET_C(T0, T0R.1)
28 
29 	CS(T1, 0.0)
30 	//PARAM(T1.FUNC, "0.001020 * (0.5 + 0.5 * sin(6280 * T))")
31 	RES(T2, 1000)
32 	NET_C(GND, T2.2, T1.2)
33 	NET_C(T1.1, T2.1, T0R.2)
34 #endif
35 
36 	CS(SPEECH, 0)
37 	//PARAM(SPEECH.FUNC, "0.001020 * (0.5 + 0.5 * sin(6280 * T))")
38 	NET_C(SPEECH.2, GND)
39 
40 	ANALOG_INPUT(CH1, 0)
41 	ANALOG_INPUT(CH2, 0)
42 
43 #if 0
44 	VS(CH1VS, 0)
45 	PARAM(CH1VS.FUNC, "2.5 + 1.25 * sin(6280 * T)")
46 	NET_C(CH1VS.2, GND)
47 	ALIAS(CH2, CH1VS.1)
48 #endif
49 
50 	/* The YM3012 uses only one dac for the two channels.
51 	 * Sample-and-hold is used to two toggle between the two channels.
52 	 * This is not emulated here since the YM2151 signals are provided
53 	 * externally.
54 	 *
55 	 * Therefore two RCOM resistors are used for now directly connected
56 	 * to the channels.
57 	 *
58 	 * The YM3012 datasheet gives a formula for digital to VOUT:
59 	 * VOUT = 0.5 VDD + 0.25 * VDD *(-1 + D9 + d8/2 .. + d0/512 + 1/1024)/pow(2,N)
60 	 * N= S2Q*4+S1Q*2+S0Q
61 	 * 3 bits ignored (I0,I1,I2)
62 	 * Serial data stream: I0,I1,I2,D0,..., D9,S0,S1,S2
63 	 *
64 	 * Basically output is between 0.25 * VDD and 0.75 * VDD.
65 	 * This needs to be done in MAME interface
66 	 */
67 
68 	TL084_DIP(D20)
69 	LM324_DIP(XC20)
70 
71 	RES(RCOM1, 390)
72 	RES(RCOM2, 390)
73 
74 	CAP(C21, CAP_U(2.2))
75 	CAP(C22, CAP_U(2.2)) // Needs verification
76 	CAP(C27, CAP_P(1500))
77 	CAP(C28, CAP_P(1500))
78 
79 	// ------------------------------------
80 	// YM2151/YM3012 inputs
81 	// ------------------------------------
82 
83 	NET_C(CH1, RCOM1.1)
84 	NET_C(RCOM1.2, C27.1, D20.5)
85 	NET_C(D20.7, D20.6, C22.1)
86 
87 	NET_C(CH2, RCOM2.1)
88 	NET_C(RCOM2.2, C28.1, D20.10)
89 	NET_C(D20.8, D20.9, C21.1)
90 
91 	NET_C(GND, C27.2, C28.2)
92 
93 	// OPAMPS, no information on schematics, assume 12V since
94 	// TL084 with 5V would be outside specifications
95 	// No negative voltages found on schematics
96 
97 	NET_C(VP12, XC20.4, D20.4)
98 	NET_C(GND, XC20.11, D20.11)
99 
100 	// ------------------------------------
101 	// Speech inputs
102 	// ------------------------------------
103 
104 	RES(R11, RES_K(1))
105 	RES(R14, RES_K(5.6))
106 	RES(R16, RES_K(6.8))
107 	RES(R15, RES_K(12))
108 	RES(R12, RES_K(1.3))
109 	RES(R13, RES_K(6.2))
110 	CAP(C25, CAP_U(0.0022))
111 	CAP(C26, CAP_U(0.022))
112 	CAP(C23, CAP_U(0.022))
113 	CAP(C29, CAP_U(0.01))
114 	CAP(C62, CAP_U(2.2))
115 
116 	NET_C(VP5, R11.1)
117 	NET_C(SPEECH.1, R11.2, R14.1)
118 	NET_C(R14.2, R16.1, C26.1, R15.1)
119 	NET_C(R15.2, C25.1, XC20.5)
120 	NET_C(XC20.7, XC20.6, C26.2, R12.1)
121 
122 	NET_C(R12.2, C23.1, R13.1)
123 	NET_C(R13.2, C29.1, XC20.3)
124 	NET_C(XC20.1, XC20.2, C23.2, C62.1)
125 
126 	NET_C(GND, R16.2, C25.2, C29.2)
127 
128 	// ------------------------------------
129 	// Mixing and pre amplifier
130 	// ------------------------------------
131 
132 	RES(R6, RES_K(10))
133 	RES(R9, RES_K(47))
134 	RES(R10, RES_K(47))
135 	RES(R4, RES_K(10))
136 	RES(R7, RES_K(47))
137 	RES(R3, RES_K(10))
138 	RES(R5, RES_K(10))
139 	RES(VR1, RES_K(2))    // FIXME: Actually a potentiometer
140 	CAP(C12, CAP_U(10))
141 	CAP(C63, CAP_U(2.2))
142 	CAP(C20, CAP_P(1000))
143 	CAP(C19, CAP_U(47))  // FIXME: Needs verification
144 	RES(AMP_IN, RES_K(100))
145 
146 	NET_C(C62.2, R6.1)
147 	NET_C(C22.2, R9.1)
148 	NET_C(C21.2, R10.1)
149 	NET_C(R6.2, R9.2, R10.2, XC20.9, C20.1, R7.1) // FIXME: Schematics read "9" (XC20.9) - other AMP?
150 	NET_C(R7.2, C20.2, C63.1, XC20.8) // FIXME: Schematics read "7" (XC20.7) - other AMP?
151 
152 	NET_C(VP5, R4.1)
153 	NET_C(R4.2, C19.1, R5.1, XC20.10) // FIXME: Schematics read "8" (XC20.8) - other AMP?
154 
155 	NET_C(C63.2, R3.1)
156 	NET_C(R3.2, VR1.1, C12.1)
157 	NET_C(C12.2, AMP_IN.1)
158 
159 	NET_C(GND, VR1.2, C19.2, R5.2, AMP_IN.2)
160 
161 	// OUTPUT
162 
163 	ALIAS(OUT, AMP_IN.1)
164 
165 	// Not connected
166 
167 	NET_C(GND, XC20.13, XC20.12, D20.13, D20.12, D20.2, D20.3)
168 	NET_C(GND, XC20.14, D20.14, D20.1)
169 NETLIST_END()
170 
171