1 // license:CC0
2 // copyright-holders:Aaron Giles
3 
4 //
5 // Netlist for Barrier
6 //
7 // Derived from the schematics in the Barrier manual. This sound
8 // board is quite similar to Space Wars.
9 //
10 // Known problems/issues:
11 //
12 //    * The schematics show a connection between U8.6 and
13 //       R37.2; however, implementing this leads to a direct input
14 //       from the noise source at all times to the summing amp.
15 //       Suspecting this is a typo in the schematics.
16 //
17 //    * Unsure if Barrier should have the noisy background like
18 //       Space Wars. Space Wars has a hard overall mute to suppress
19 //       it when the game isn't running, but Barrier does not.
20 //
21 
22 #include "netlist/devices/net_lib.h"
23 #include "nl_cinemat_common.h"
24 
25 
26 //
27 // Optimizations
28 //
29 
30 #define HLE_NOISE_GEN (1)
31 #define ENABLE_FRONTIERS (1)
32 
33 
34 //
35 // Main netlist
36 //
37 
38 NETLIST_START(barrier)
39 
40 	SOLVER(Solver, 1000)
41 	PARAM(Solver.DYNAMIC_TS, 1)
42 	PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 2e-5)
43 
44 	TTL_INPUT(I_OUT_0, 0)               // active high
45 	TTL_INPUT(I_OUT_1, 0)               // active high
46 	TTL_INPUT(I_OUT_2, 0)               // active high
47 
48 	NET_C(GND, I_OUT_0.GND, I_OUT_1.GND, I_OUT_2.GND)
49 	NET_C(I_V5, I_OUT_0.VCC, I_OUT_1.VCC, I_OUT_2.VCC)
50 
51 	CINEMAT_LOCAL_MODELS
52 
53 	ANALOG_INPUT(I_V5, 5)
54 	ANALOG_INPUT(I_V15, 15)
55 	ANALOG_INPUT(I_VM15, -15)
56 
57 	RES(R1, RES_K(18))
58 	RES(R2, 470)
59 	RES(R3, RES_K(47))
60 	RES(R4, RES_K(220))
61 	RES(R5, 470)
62 	RES(R6, 150)
63 	RES(R7, RES_K(180))
64 	RES(R8, RES_M(10))
65 	RES(R9, RES_K(39))
66 	RES(R10, RES_K(2.2))
67 	RES(R11, 470)
68 	RES(R12, RES_K(30))
69 	RES(R13, RES_K(8.2))
70 	RES(R14, RES_K(33))
71 	RES(R15, RES_K(15))
72 	RES(R16, RES_M(10))
73 	RES(R17, RES_K(10))
74 	RES(R18, RES_K(47))
75 	RES(R19, 820)
76 //  POT(R20, RES_K(10))     -- part of final amp (not emulated)
77 //  RES(R21, 150)           -- part of final amp (not emulated), not present on Space Wars
78 //  RES(R22, 2.7)           -- part of final amp (not emulated), not present on Space Wars
79 //  RES(R23, 2.7)           -- part of final amp (not emulated), not present on Space Wars
80 	RES(R24, RES_K(47))
81 	RES(R25, 150)
82 	RES(R26, RES_K(160))
83 	RES(R27, 750)
84 //  RES(R28, RES_K(150))    -- part of final amp (not emulated), illegible on Space Wars
85 //  POT(R29, RES_K(10))     -- part of final amp (not emulated)
86 //  RES(R30, 470)           -- part of final amp (not emulated)
87 	RES(R31, 470)
88 	RES(R32, RES_K(1))
89 	RES(R33, RES_K(39))
90 	RES(R34, RES_K(6.8))
91 	RES(R35, RES_K(560))
92 	RES(R36, RES_M(1))
93 	RES(R37, RES_K(10))
94 	RES(R38, RES_K(10))
95 
96 	CAP(C1, CAP_U(1))
97 	CAP(C2, CAP_U(1))
98 	CAP(C3, CAP_U(0.01))
99 	CAP(C4, CAP_U(0.01))
100 	CAP(C5, CAP_U(0.1))
101 //  CAP(C6, CAP_U(4.7))     // not needed
102 	CAP(C7, CAP_U(0.01))
103 	CAP(C8, CAP_U(1))
104 	CAP(C9, CAP_U(0.1))
105 	CAP(C10, CAP_P(220))
106 	CAP(C11, CAP_U(0.1))
107 //  CAP(C12, CAP_U(0.01))   -- part of final amp (not emulated)
108 //  CAP(C13, CAP_P(470))    -- part of final amp (not emulated)
109 //  CAP(C14, CAP_P(470))    -- part of final amp (not emulated)
110 //  CAP(C15, CAP_U(50))     -- not needed
111 //  CAP(C16, CAP_U(2.2))    -- not needed
112 	CAP(C17, CAP_U(0.01))
113 	CAP(C18, CAP_U(15))
114 //  CAP(C19, CAP_U(50))     -- not needed
115 //  CAP(C20, CAP_U(2.2))    -- not needed
116 	CAP(C21, CAP_U(0.02))
117 	CAP(C22, CAP_U(0.1))
118 
119 	D_1N914(CR1)
120 	D_1N914(CR2)
121 	D_1N914(CR3)
122 	D_1N914(CR4)
123 	D_1N914(CR5)
124 	D_1N914(CR6)
125 
126 #if !(HLE_NOISE_GEN)
127 	Q_2N3906(Q1)    // PNP
128 	Q_2N3904(Q2)    // NPN
129 #endif
130 	Q_2N6426(Q3)    // NPN Darlington
131 //  Q_2N6292(Q4)    // NPN -- not used
132 //  Q_2N6107(Q5)    // PNP -- not used
133 	Q_2N6426(Q6)    // NPN Darlington
134 	Q_2N3904(Q7)    // NPN
135 
136 	TL081_DIP(U1)           // Op. Amp.
137 	NET_C(U1.4, I_VM15)
138 	NET_C(U1.7, I_V15)
139 
140 	TTL_7406_DIP(U2)        // Hex inverter -- currently using a clone of 7416, no open collector behavior
141 	NET_C(U2.7, GND)
142 	NET_C(U2.14, I_V5)
143 
144 	TL081_DIP(U3)           // Op. Amp.
145 	NET_C(U3.4, I_VM15)
146 	NET_C(U3.7, I_V15)
147 
148 //  TTL_7815_DIP(U4)        // +15V Regulator -- not needed
149 
150 	TL182_DIP(U5)           // Analog switch
151 	NET_C(U5.6, I_V15)
152 	NET_C(U5.7, I_V5)
153 	NET_C(U5.8, GND)
154 	NET_C(U5.9, I_VM15)
155 
156 //  TL081_DIP(U6)           // Op. Amp. -- part of final amp (not emulated)
157 //  NET_C(U6.4, I_VM15)
158 //  NET_C(U6.7, I_V15)
159 
160 //  TTL_7915_DIP(U7)        // -15V Regulator -- not needed
161 
162 	TL081_DIP(U8)           // Op. Amp.
163 	NET_C(U8.4, I_VM15)
164 	NET_C(U8.7, I_V15)
165 
166 	TL081_DIP(U9)           // Op. Amp.
167 	NET_C(U9.4, I_VM15)
168 	NET_C(U9.7, I_V15)
169 
170 	//
171 	// Top-left until output from U1
172 	//
173 
174 #if (HLE_NOISE_GEN)
175 	CLOCK(NOISE_CLOCK, 2000)
176 	NET_C(NOISE_CLOCK.GND, GND)
177 	NET_C(NOISE_CLOCK.VCC, I_V5)
178 
179 	SYS_NOISE_MT_N(NOISE, 0.0001)
180 	NET_C(NOISE.I, NOISE_CLOCK.Q)
181 	NET_C(NOISE.1, GND)
182 	NET_C(NOISE.2, C1.1)
183 
184 	NET_C(GND, R1.1, R1.2, R2.1, R2.2, CR1.A, CR1.K, CR2.A, CR2.K)
185 #else
186 	NET_C(I_V15, CR1.A)
187 	NET_C(CR1.K, CR2.A)
188 	NET_C(CR2.K, R1.2, Q1.B)
189 	NET_C(R1.1, GND)
190 	NET_C(I_V15, R2.2)
191 	NET_C(R2.1, Q1.E)
192 	NET_C(Q2.E, Q1.C, C1.1)
193 	NET_C(Q2.C, GND)
194 #endif
195 
196 	NET_C(C1.2, R3.2, U1.3)
197 	NET_C(R3.1, GND)
198 	NET_C(U1.2, R5.2, R4.1)
199 	NET_C(R5.1, GND)
200 	NET_C(R4.2, U1.6)
201 
202 	//
203 	// Top-middle, from O1 until output from CR3
204 	//
205 
206 	NET_C(I_OUT_1, U2.13)
207 	NET_C(U2.12, R6.1)
208 	NET_C(R6.2, R7.1, C2.1, Q3.B)
209 	NET_C(R7.2, I_V5)
210 	NET_C(C2.2, GND)
211 	NET_C(Q3.E, R11.2)
212 	NET_C(Q3.C, I_V5)
213 	NET_C(R11.1, CR3.A)
214 
215 	//
216 	// Middle chunk, from C3 until output from R13
217 	//
218 
219 	NET_C(U1.6, C3.1)
220 	NET_C(C3.2, R8.1, U3.2)
221 	NET_C(U3.3, GND)
222 	NET_C(R8.2, U3.6, R9.1)
223 	NET_C(R9.2, CR3.K, C4.1, CR4.A, R10.2)
224 	NET_C(R10.1, CR4.K, GND)
225 	NET_C(C4.2, R12.1)
226 	NET_C(R12.2, C5.2, R13.1)
227 	NET_C(C5.1, GND)
228 
229 	//
230 	// Big middle section, from C8 until output from R15/R41/R37
231 	//
232 
233 	NET_C(U1.6, C8.2)
234 	NET_C(C8.1, R24.1)
235 	NET_C(R24.2, U8.2, C10.1, R16.1)
236 	NET_C(U8.3, GND)
237 	NET_C(U8.6, R16.2, C10.2, R31.1, R38.1)
238 //  NET_C(U8.6, R13.2)      // Schems show noise source into summing amp -- wrong??
239 	NET_C(R38.2, U5.14)
240 	NET_C(I_OUT_2, U5.10)
241 	NET_C(U5.13, C7.1)
242 	NET_C(C7.2, R14.1)
243 	NET_C(R37.2, R13.2)
244 	NET_C(R14.2, C9.2, R15.1)
245 	NET_C(C9.1, GND)
246 	NET_C(R15.2, R13.2)
247 	NET_C(I_OUT_0, U2.9)
248 	NET_C(U2.8, R25.1)
249 	NET_C(R25.2, R26.1, C17.1, Q6.B, C18.1)
250 	NET_C(R26.2, C17.2, I_V5)
251 	NET_C(C18.2, GND)
252 	NET_C(Q6.E, R27.2)
253 	NET_C(Q6.C, I_V5)
254 	NET_C(R27.1, CR5.A)
255 	NET_C(CR5.K, R33.2, CR6.A, R34.2, C21.2, C22.1)
256 	NET_C(R31.2, R32.2, R33.1, Q7.E)
257 	NET_C(R32.1, Q7.B)
258 	NET_C(Q7.C, CR6.K, R34.1, C21.1, GND)
259 	NET_C(C22.2, R35.1)
260 	NET_C(R35.2, U9.2, R36.1)
261 	NET_C(U9.3, GND)
262 	NET_C(U9.6, R36.2, R37.1)
263 
264 	//
265 	// Final stage
266 	//
267 
268 	NET_C(R17.2, C11.1, R13.2)
269 	NET_C(R17.1, R18.1, GND)
270 	NET_C(C11.2, R18.2, R19.1)
271 	NET_C(R19.2, GND)
272 	ALIAS(OUTPUT, R18.2)
273 
274 	//
275 	// Unconnected inputs
276 	//
277 
278 	NET_C(GND, U2.3, U2.5, U2.11)
279 	NET_C(GND, U5.1, U5.2, U5.5, U2.1)
280 
281 	//
282 	// Frontier optimizations
283 	//
284 
285 #if (ENABLE_FRONTIERS)
286 	// Separate each input into the summing network
287 	OPTIMIZE_FRONTIER(R13.1, RES_M(1), 50)
288 	OPTIMIZE_FRONTIER(R15.1, RES_M(1), 50)
289 	OPTIMIZE_FRONTIER(R37.1, RES_M(1), 50)
290 
291 	// Decouple the Darlington BJTs from the sounds they enable
292 	OPTIMIZE_FRONTIER(R27.2, RES_M(1), 50)
293 	OPTIMIZE_FRONTIER(R11.2, RES_M(1), 50)
294 
295 	// Decouple the noise source from the downstream filters
296 	OPTIMIZE_FRONTIER(C3.1, RES_M(1), 50)
297 	OPTIMIZE_FRONTIER(R24.1, RES_M(1), 50)
298 	OPTIMIZE_FRONTIER(R38.1, RES_M(1), 50)
299 #endif
300 
301 NETLIST_END()
302