~ubuntu-branches/ubuntu/lucid/sdlmame/lucid

« back to all changes in this revision

Viewing changes to src/mame/audio/mario.c

  • Committer: Bazaar Package Importer
  • Author(s): Cesare Falco
  • Date: 2009-11-03 17:10:15 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091103171015-6hop4ory5lxnumpn
Tags: 0.135-0ubuntu1
* New upstream release - Closes (LP: #403212)
* debian/watch: unstable releases are no longer detected
* mame.ini: added the cheat subdirectories to cheatpath so zipped
  cheatfiles will be searched too
* renamed crsshair subdirectory to crosshair to reflect upstream change
* mame.ini: renamed references to crosshair subdirectory (see above)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "driver.h"
2
2
#include "cpu/z80/z80.h"
3
3
#include "cpu/mcs48/mcs48.h"
4
 
#include "sound/dac.h"
5
4
#include "sound/ay8910.h"
6
5
#include "sound/discrete.h"
7
6
 
16
15
/* FIXME: Capacitor aging - only in for calibration now        */
17
16
/* Adjustments are needed to bring this close to recordings    */
18
17
 
19
 
#define CAP_AGE(c, f)   ((c) * (f))
20
 
 
21
18
/* FIXME: Awaiting verification. VCO range inputs are shown    */
22
19
/* as connected to +5V on schematics. This does not match      */
23
20
/* recordings                                                  */
24
21
 
 
22
#define USE_LS629       (0)             /* set to use new LS624 code */
 
23
 
25
24
#define RUN_VCO_VOLTAGE         (0.0)   /* 5 in schematics */
26
25
 
27
26
#define USE_8039        (0)                     /* set to 1 to try 8039 hack */
83
82
 *
84
83
 * Mario Discrete Sound Interface
85
84
 *
86
 
 * verified against picture of a TMA1-04-CPU Board. Some
87
 
 * of the values were hard to read, though.
88
 
 *
 
85
 * Parts verified against a real TMA1-04-CPU Board.
89
86
 ****************************************************************/
90
87
 
91
88
#define MR_R6           RES_K(4.7)              /* verified                             */
97
94
#define MR_R19          RES_K(22)               /* verified                             */
98
95
#define MR_R20          RES_K(22)               /* verified                             */
99
96
#define MR_R40          RES_K(22)               /* verified                             */
100
 
#define MR_R41          RES_K(100)              /* verified, hard to read               */
101
 
#define MR_R42          RES_K(43)
102
 
#define MR_R43          RES_K(100)
103
 
#define MR_R61          RES_K(47)               /* verified, hard to read               */
 
97
#define MR_R41          RES_K(100)              /* verified                             */
 
98
#define MR_R42          RES_K(43)               /* verified                             */
 
99
#define MR_R43          RES_K(100)              /* verified                             */
 
100
#define MR_R61          RES_K(47)               /* verified                             */
104
101
#define MR_R64          RES_K(20)               /* verified                             */
105
102
#define MR_R65          RES_K(10)               /* verified                             */
106
103
 
107
104
#define MR_C3           CAP_U(10)               /* verified                             */
108
 
#define MR_C4           CAP_U(4.7)              /* illegible, 4.7 or 47 pcb/schematics  */
109
 
                                                                        /* 4.7 in parts list                    */
110
 
#define MR_C5           CAP_N(39)               /* illegible on pcb                     */
111
 
#define MR_C6           CAP_N(3.9)              /* illegible on pcb                     */
 
105
#define MR_C4           CAP_U(4.7)              /* verified                             */
 
106
#define MR_C5           CAP_N(39)               /* verified                             */
 
107
#define MR_C6           CAP_N(3.9)              /* verified                             */
112
108
#define MR_C14          CAP_U(4.7)              /* verified                             */
113
109
#define MR_C15          CAP_U(4.7)              /* verified                             */
114
110
#define MR_C16          CAP_N(6.8)              /* verified                             */
115
 
#define MR_C17          CAP_N(22)               /* illegible on pcb                     */
116
 
#define MR_C31          CAP_U(0.022)    /* not found                            */
117
 
#define MR_C32          CAP_U(1)                /* illegible on pcb                     */
118
 
#define MR_C39          CAP_N(4.7)              /* not found                            */
 
111
#define MR_C17          CAP_N(22)               /* verified                             */
 
112
#define MR_C30          CAP_P(100)              /* verified                             */
 
113
#define MR_C31          CAP_U(0.022)    /* verified                             */
 
114
#define MR_C32          CAP_U(1)                /* verified                             */
 
115
#define MR_C39          CAP_N(4.7)              /* verified                             */
119
116
#define MR_C40          CAP_N(22)               /* verified                             */
120
 
//#define MR_C41        CAP_U(4.7)      /* verified, hard to read           */
121
 
#define MR_C41          CAP_U(4.7)
 
117
#define MR_C41          CAP_U(4.7)              /* verified                             */
122
118
#define MR_C43          CAP_U(3.3)              /* verified                             */
123
119
#define MR_C44          CAP_U(3.3)              /* verified                             */
124
120
 
132
128
#define DISCRETE_LS123_INV(_N, _T, _R, _C) \
133
129
        DISCRETE_ONESHOTR(_N, 0, _T, TTL_HIGH, (0.25 * (_R) * (_C) * (1.0+700./(_R))), DISC_ONESHOT_RETRIG | DISC_ONESHOT_REDGE | DISC_OUT_ACTIVE_LOW)
134
130
 
135
 
#define DISCRETE_BITSET(_N, _N1, _B) DISCRETE_TRANSFORM3(_N, _N1, (1 << ((_B)-1)), 0, "01&2>")
 
131
/* speed optimization */
 
132
/* pow(10, x) = exp(ln(10)*x) */
 
133
#define pow10(x) exp(2.30258509299404568401*(x))
136
134
 
137
135
/* The following formula was derived from figures 2 and 3 in LS624 datasheet. Coefficients
138
136
 * where calculated using least square approximation.
139
137
 * This approach gives a bit better results compared to the first approach.
140
138
 */
141
 
#define LS624_F(_C, _VI, _VR)   pow(10, -0.912029404 * log10(_C) + 0.243264328 * (_VI) \
142
 
                          - 0.091695877 * (_VR) -0.014110946 * (_VI) * (_VR) - 3.207072925)
 
139
//#define LS624_F(_C, _VI, _VR) pow10( -0.912029404 * log10(_C) + 0.243264328 * (_VI)
 
140
//                - 0.091695877 * (_VR) -0.014110946 * (_VI) * (_VR) - 3.207072925)
 
141
#define LS624_F(_in, _num)      pow10(context->k1_##_num + 0.243264328 * (_in) + context->k2_##_num * (_in))
143
142
 
144
143
/************************************************************************
145
144
 *
171
170
 *            -||-
172
171
 *             C2
173
172
 ************************************************************************/
174
 
#define MARIO_CUSTOM_VOUT               (*(node->input[0]))
175
 
#define MARIO_CUSTOM_IN1                (*(node->input[1]))
176
 
#define MARIO_CUSTOM_IN2                (*(node->input[2]))
177
 
#define MARIO_CUSTOM_C1                 (*(node->input[3]))
178
 
#define MARIO_CUSTOM_C2                 (*(node->input[4]))
179
 
#define MARIO_CUSTOM_R1                 (*(node->input[5]))
180
 
#define MARIO_CUSTOM_C3                 (*(node->input[6]))
 
173
#define MARIO_CUSTOM_VOUT               DISCRETE_INPUT(0)
 
174
#define MARIO_CUSTOM_IN1                DISCRETE_INPUT(1)
 
175
#define MARIO_CUSTOM_IN2                DISCRETE_INPUT(2)
 
176
#define MARIO_CUSTOM_C1                 DISCRETE_INPUT(3)
 
177
#define MARIO_CUSTOM_C2                 DISCRETE_INPUT(4)
 
178
#define MARIO_CUSTOM_R1                 DISCRETE_INPUT(5)
 
179
#define MARIO_CUSTOM_C3                 DISCRETE_INPUT(6)
181
180
 
182
181
struct mario_custom_run_context
183
182
{
186
185
        double  remain1;
187
186
        double  remain2;
188
187
        double  vc3;
 
188
        double  r1_c3;
 
189
        double  k1_1;
 
190
        double  k2_1;
 
191
        double  k1_2;
 
192
        double  k2_2;
 
193
        double  exponent_c3;
 
194
        double  dt_in1_at_0;
 
195
        double  dt_in2_at_0;
189
196
};
190
197
 
191
198
static DISCRETE_STEP( mario_custom_run )
192
199
{
193
200
        struct mario_custom_run_context *context = (struct mario_custom_run_context *)node->context;
194
201
 
195
 
        double  t1      = 0.5 / LS624_F(MARIO_CUSTOM_C1, MARIO_CUSTOM_IN1, RUN_VCO_VOLTAGE);
196
 
        double  t2      = 0.5 / LS624_F(MARIO_CUSTOM_C2, MARIO_CUSTOM_IN2, RUN_VCO_VOLTAGE);
197
 
        double  sample_t = discrete_current_context->sample_time;
198
 
        double  vn, t;
199
 
 
200
 
        //if (MARIO_CUSTOM_VOUT)
201
 
        //  printf("%f %f %f %f\n", MARIO_CUSTOM_IN1, MARIO_CUSTOM_IN2, 0.5 / t1, 0.5 / t2);
 
202
        double  sample_t = node->info->sample_time;
 
203
        double  vn, exponent, t = 0;
 
204
        int             update_exponent;
 
205
        double  t1, t2;
 
206
 
 
207
        if (EXPECTED(MARIO_CUSTOM_IN1 > 0.001))
 
208
                t1      = 0.5 / LS624_F(MARIO_CUSTOM_IN1, 1);
 
209
        else
 
210
                /* close enough to 0, so we can speed things up by no longer call pow() */
 
211
                t1 = context->dt_in1_at_0;
 
212
 
 
213
        if (EXPECTED(MARIO_CUSTOM_IN2 > 0.001))
 
214
                t2      = 0.5 / LS624_F(MARIO_CUSTOM_IN2, 2);
 
215
        else
 
216
                t2 = context->dt_in2_at_0;
 
217
 
202
218
        while (sample_t > 0.0f)
203
219
        {
204
220
                /* state before time advance */
205
221
                vn = (double) (context->state1 ^ context->state2);
206
222
                vn *= MARIO_CUSTOM_VOUT;
 
223
                update_exponent = 0;
207
224
                if (context->remain1 < context->remain2)
208
225
                {
209
 
                        if (context->remain1 < sample_t)
 
226
                        if (EXPECTED(context->remain1 < sample_t))
210
227
                        {
211
228
                                t = context->remain1;
 
229
                                update_exponent = 1;
212
230
                                context->state1 ^= 1;
213
231
                                sample_t -= context->remain1;
214
232
                                context->remain2 -= context->remain1;
216
234
                        }
217
235
                        else
218
236
                        {
219
 
                                t = sample_t;
220
237
                                context->remain1 -= sample_t;
221
238
                                context->remain2 -= sample_t;
222
239
                                sample_t = 0.0f;
224
241
                }
225
242
                else
226
243
                {
227
 
                        if (context->remain2 < sample_t)
 
244
                        if (EXPECTED(context->remain2 < sample_t))
228
245
                        {
229
246
                                t = context->remain2;
 
247
                                update_exponent = 1;
230
248
                                context->state2 ^= 1;
231
249
                                sample_t -= context->remain2;
232
250
                                context->remain1 -= context->remain2;
234
252
                        }
235
253
                        else
236
254
                        {
237
 
                                t = sample_t;
238
255
                                context->remain1 -= sample_t;
239
256
                                context->remain2 -= sample_t;
240
257
                                sample_t = 0.0f;
241
258
                        }
242
259
                }
243
260
 
244
 
                context->vc3 += (vn - context->vc3) * (1.0 - exp(- t / (MARIO_CUSTOM_R1 * MARIO_CUSTOM_C3)));
 
261
                if (EXPECTED(update_exponent))
 
262
                        exponent = RC_CHARGE_EXP_DT(context->r1_c3, t);
 
263
                else
 
264
                        exponent = context->exponent_c3;
 
265
                context->vc3 += (vn - context->vc3) * exponent;
245
266
        }
246
267
        node->output[0] = context->vc3;
247
268
}
255
276
        context->state1 = 0;
256
277
        context->state2 = 0;
257
278
        context->vc3 = 0;
 
279
        context->r1_c3 = MARIO_CUSTOM_R1 * MARIO_CUSTOM_C3;
258
280
        node->output[0] = 0;
 
281
 
 
282
        /* precalculate some parts of the formulas for speed */
 
283
        context->k1_1 = -0.912029404 * log10(MARIO_CUSTOM_C1) -0.091695877 * (RUN_VCO_VOLTAGE) - 3.207072925;
 
284
        context->k2_1 = -0.014110946 * (RUN_VCO_VOLTAGE);
 
285
        context->k1_2 = -0.912029404 * log10(MARIO_CUSTOM_C2) -0.091695877 * (RUN_VCO_VOLTAGE) - 3.207072925;
 
286
        context->k2_2 = -0.014110946 * (RUN_VCO_VOLTAGE);
 
287
        context->exponent_c3 = RC_CHARGE_EXP(context->r1_c3);
 
288
 
 
289
        context->dt_in1_at_0 = 0.5 / LS624_F(0, 1);
 
290
        context->dt_in2_at_0 = 0.5 / LS624_F(0, 2);
259
291
}
260
292
 
261
293
static const discrete_custom_info mario_custom_run_info =
262
294
{
263
 
        DISCRETE_RESET_NAME( mario_custom_run ),
264
 
        DISCRETE_STEP_NAME( mario_custom_run ),
265
 
        sizeof(struct mario_custom_run_context),
 
295
        DISCRETE_CUSTOM_MODULE( mario_custom_run, struct mario_custom_run_context),
266
296
        NULL
267
297
};
268
298
 
 
299
static const discrete_mixer_desc mario_mixer =
 
300
{
 
301
        DISC_MIXER_IS_RESISTOR,
 
302
        {MR_R20, MR_R19, MR_R41, MR_R40},
 
303
        {0}, {0}, 0, 0, MR_C31, MR_C32, 0, 1    /* r_node{}, c{}, rI, rF, cF, cAmp, vRef, gain*/
 
304
};
 
305
 
 
306
#define LS629_FREQ_R_IN         RES_K(95)
 
307
 
269
308
static DISCRETE_SOUND_START(mario)
270
309
 
271
310
        /************************************************/
273
312
        /************************************************/
274
313
 
275
314
        /* DISCRETE_INPUT_DATA */
276
 
    DISCRETE_INPUT_PULSE(DS_SOUND0_INV, 1)
277
 
    DISCRETE_INPUT_PULSE(DS_SOUND1_INV, 1)
278
315
    DISCRETE_INPUT_NOT(DS_SOUND7_INV)
279
 
    DISCRETE_INPUT_DATA(DS_DAC)
280
316
 
281
317
        /************************************************/
282
318
        /* SOUND0                                       */
283
319
        /************************************************/
284
320
 
285
 
        DISCRETE_LS123(NODE_10, DS_SOUND0_INV, MR_R17, CAP_AGE(MR_C14, 0.7))
286
 
        DISCRETE_RCFILTER(NODE_11, 1, NODE_10, MR_R6, CAP_AGE(MR_C3, 0.5) )
287
 
        DISCRETE_CUSTOM7(NODE_12, NODE_10, NODE_11, NODE_11, MR_C6, MR_C17,
 
321
    DISCRETE_TASK_START(1)
 
322
    DISCRETE_INPUT_PULSE(DS_SOUND0_INV, 1)
 
323
        DISCRETE_LS123(NODE_10, DS_SOUND0_INV, MR_R17, MR_C14)
 
324
        DISCRETE_RCFILTER(NODE_11, NODE_10, MR_R6, MR_C3 )
 
325
#if (USE_LS629)
 
326
        DISCRETE_74LS629(NODE_12,                                               /* IC 1J, pin 10 */
 
327
                1,                                                                                      /* ENAB */
 
328
                NODE_11, 5,                                                                     /* VMOD, VRNG */
 
329
                MR_C6, RES_2_PARALLEL(MR_R6, LS629_FREQ_R_IN),          /* C, R_FREQ_IN */
 
330
                DISC_LS624_OUT_SQUARE)
 
331
        DISCRETE_74LS629(NODE_13,                                               /* IC 2J, pin 10 */
 
332
                1,                                                                                      /* ENAB */
 
333
                NODE_11, 5,                                                                     /* VMOD, VRNG */
 
334
                MR_C17, RES_2_PARALLEL(MR_R6, LS629_FREQ_R_IN),         /* C, R_FREQ_IN */
 
335
                DISC_LS624_OUT_SQUARE)
 
336
        DISCRETE_LOGIC_XOR(NODE_14,                                             /* IC 1K, pin 6 */
 
337
                NODE_12, NODE_13)
 
338
        DISCRETE_SWITCH(DS_OUT_SOUND0,                                  /* IC 2K, pin 3 */
 
339
                NODE_10, NODE_14,                                                       /* ENAB, SWITCH */
 
340
                0, TTL_HIGH)                                                            /* INP0,INP1 */
 
341
#else
 
342
        DISCRETE_CUSTOM7(DS_OUT_SOUND0, NODE_10, NODE_11, NODE_11, MR_C6, MR_C17,
288
343
                        MR_MIXER_RPAR, MR_C31, &mario_custom_run_info)
289
 
        DISCRETE_MULTIPLY(DS_OUT_SOUND0, 1, NODE_12, MR_MIXER_RPAR / MR_R20)
 
344
#endif
 
345
        DISCRETE_TASK_END()
290
346
 
291
347
        /************************************************/
292
348
        /* SOUND1                                       */
293
349
        /************************************************/
294
350
 
295
 
        DISCRETE_LS123(NODE_20, DS_SOUND1_INV, MR_R18, CAP_AGE(MR_C15, 0.7))
296
 
        DISCRETE_RCFILTER(NODE_21, 1, NODE_20, MR_R7, CAP_AGE(MR_C4, 0.5) )
297
 
        DISCRETE_CUSTOM7(NODE_22, NODE_20, NODE_21, NODE_21, MR_C5, MR_C16,
 
351
        DISCRETE_TASK_START(1)
 
352
        DISCRETE_INPUT_PULSE(DS_SOUND1_INV, 1)
 
353
        DISCRETE_LS123(NODE_20, DS_SOUND1_INV, MR_R18, MR_C15)
 
354
        DISCRETE_RCFILTER(NODE_21, NODE_20, MR_R7, MR_C4 )
 
355
#if (USE_LS629)
 
356
        DISCRETE_74LS629(NODE_22,                                               /* IC 1J, pin 7 */
 
357
                1,                                                                                      /* ENAB */
 
358
                NODE_21, 5,                                                                     /* VMOD, VRNG */
 
359
                MR_C5, RES_2_PARALLEL(MR_R7, LS629_FREQ_R_IN),          /* C, R_FREQ_IN */
 
360
                DISC_LS624_OUT_SQUARE)
 
361
        DISCRETE_74LS629(NODE_23,                                               /* IC 2J, pin 7 */
 
362
                1,                                                                                      /* ENAB */
 
363
                NODE_21, 5,                                                                     /* VMOD, VRNG */
 
364
                MR_C16, RES_2_PARALLEL(MR_R7, LS629_FREQ_R_IN),         /* C, R_FREQ_IN */
 
365
                DISC_LS624_OUT_SQUARE)
 
366
        DISCRETE_LOGIC_XOR(NODE_24,                                             /* IC 1K, pin 3 */
 
367
                NODE_22, NODE_23)
 
368
        DISCRETE_SWITCH(DS_OUT_SOUND1,                                  /* IC 2K, pin 3 */
 
369
                NODE_20, NODE_24,                                                       /* ENAB, SWITCH */
 
370
                0, TTL_HIGH)                                                            /* INP0,INP1 */
 
371
#else
 
372
        DISCRETE_CUSTOM7(DS_OUT_SOUND1, NODE_20, NODE_21, NODE_21, MR_C5, MR_C16,
298
373
                MR_MIXER_RPAR, MR_C31, &mario_custom_run_info)
299
 
        DISCRETE_MULTIPLY(DS_OUT_SOUND1, 1, NODE_22, MR_MIXER_RPAR / MR_R19)
 
374
#endif
 
375
        DISCRETE_TASK_END()
300
376
 
301
377
        /************************************************/
302
378
        /* SOUND7                                       */
303
379
        /************************************************/
304
380
 
305
 
        DISCRETE_COUNTER(NODE_100,1,0,NODE_118,0xFFFF,DISC_COUNT_UP,0,DISC_CLK_BY_COUNT)
306
 
 
307
 
        DISCRETE_BITSET(NODE_102, NODE_100, 4)  //LS157 2B
308
 
        DISCRETE_BITSET(NODE_104, NODE_100, 12) //LS157 3B
309
 
 
310
 
        DISCRETE_LS123(NODE_110, DS_SOUND7_INV, MR_R61, CAP_AGE(MR_C41, 0.6))
 
381
        DISCRETE_TASK_START(1)
 
382
        DISCRETE_COUNTER(NODE_100,1,0,NODE_118,0,0xFFFF,DISC_COUNT_UP,0,DISC_CLK_BY_COUNT)
 
383
 
 
384
        DISCRETE_BIT_DECODE(NODE_102, NODE_100, 3, 1)   //LS157 2B
 
385
        DISCRETE_BIT_DECODE(NODE_104, NODE_100, 11, TTL_HIGH) //LS157 3B
 
386
 
 
387
        DISCRETE_LS123(NODE_110, DS_SOUND7_INV, MR_R61, MR_C41)
311
388
        DISCRETE_TRANSFORM2(NODE_111, NODE_110, TTL_HIGH, "0!1*")
312
 
        DISCRETE_RCFILTER(NODE_112, 1, NODE_111, MR_R65, MR_C44)
313
 
        DISCRETE_74LS624(NODE_113, 1, NODE_112, VSS, MR_C40, DISC_LS624_OUT_LOGIC)
314
 
 
315
 
        DISCRETE_LOGIC_XOR(NODE_115, 1, NODE_102, NODE_113)
316
 
 
317
 
        DISCRETE_TRANSFORM2(NODE_116, NODE_104, TTL_HIGH, "0!1*")
318
 
        DISCRETE_RCFILTER(NODE_117, 1, NODE_116, MR_R64, MR_C43)
319
 
        DISCRETE_74LS624(NODE_118, 1, NODE_117, VSS, MR_C39, DISC_LS624_OUT_COUNT_F)
320
 
 
321
 
        DISCRETE_LOGIC_AND(NODE_120, 1, NODE_115, NODE_110)
322
 
        DISCRETE_MULTIPLY(NODE_121, 1, NODE_120, TTL_HIGH * MR_MIXER_RPAR / MR_R41)
323
 
        DISCRETE_RCFILTER(DS_OUT_SOUND7, 1, NODE_121, MR_MIXER_RPAR, MR_C31)
 
389
        DISCRETE_RCFILTER(NODE_112, NODE_111, MR_R65, MR_C44)
 
390
#if (USE_LS629)
 
391
        DISCRETE_74LS629(NODE_113,                                              /* IC 4K, pin 10 */
 
392
                1,                                                                                      /* ENAB */
 
393
                NODE_112, 5,                                                            /* VMOD, VRNG */
 
394
                MR_C40, MR_R65,                                                         /* C, R_FREQ_IN */
 
395
                DISC_LS624_OUT_LOGIC)
 
396
#else
 
397
        DISCRETE_74LS624(NODE_113, NODE_112, RUN_VCO_VOLTAGE /*VSS*/, MR_C40, DISC_LS624_OUT_LOGIC)
 
398
#endif
 
399
 
 
400
        DISCRETE_LOGIC_XOR(NODE_115, NODE_102, NODE_113)
 
401
 
 
402
        DISCRETE_RCFILTER(NODE_117, NODE_104, MR_R64, MR_C43)
 
403
#if (USE_LS629)
 
404
        DISCRETE_74LS629(NODE_118,                                              /* IC 4K, pin 7 */
 
405
                1,                                                                                      /* ENAB */
 
406
                NODE_117, 5,                                                            /* VMOD, VRNG */
 
407
                MR_C39, MR_R64,                                                         /* C, R_FREQ_IN */
 
408
                DISC_LS624_OUT_LOGIC)
 
409
#else
 
410
        DISCRETE_74LS624(NODE_118, NODE_117, RUN_VCO_VOLTAGE /*VSS*/, MR_C39, DISC_LS624_OUT_COUNT_F)
 
411
#endif
 
412
        DISCRETE_LOGIC_AND(NODE_120, NODE_115, NODE_110)
 
413
        DISCRETE_MULTIPLY(DS_OUT_SOUND7, NODE_120, TTL_HIGH)
 
414
        DISCRETE_TASK_END()
324
415
 
325
416
        /************************************************/
326
417
        /* DAC                                          */
330
421
     * is a filter circuit. Simulation in LTSPICE shows, that the following is equivalent:
331
422
     */
332
423
 
333
 
        DISCRETE_MULTIPLY(NODE_170, 1, DS_DAC, TTL_HIGH/256.0)
334
 
        DISCRETE_RCFILTER(NODE_171, 1, NODE_170, RES_K(750), CAP_P(200))
335
 
 
336
 
        DISCRETE_MULTIPLY(NODE_172, 1, NODE_171, MR_MIXER_RPAR / MR_R40)
337
 
        DISCRETE_RCFILTER(DS_OUT_DAC, 1, NODE_172, MR_MIXER_RPAR, MR_C31)
 
424
        DISCRETE_TASK_START(1)
 
425
        DISCRETE_INPUT_BUFFER(DS_DAC, 0)
 
426
        DISCRETE_MULTIPLY(NODE_170, DS_DAC, TTL_HIGH/256.0)
 
427
        DISCRETE_RCFILTER(DS_OUT_DAC, NODE_170, RES_K(750), CAP_P(200))
 
428
        DISCRETE_TASK_END()
338
429
 
339
430
 
340
431
        /************************************************/
341
432
        /* MIXER                                        */
342
433
        /************************************************/
343
434
 
344
 
        DISCRETE_ADDER4(NODE_295, 1, DS_OUT_SOUND0, DS_OUT_SOUND1, DS_OUT_SOUND7, DS_OUT_DAC)
345
 
 
346
 
        /* Amplifier: internal amplifier
347
 
     * Just a 1:n amplifier without filters and no output capacitor
348
 
     */
349
 
        DISCRETE_CRFILTER(NODE_296, 1, NODE_295, RES_2_PARALLEL(MR_R42, MR_R43), MR_C32)
350
 
        /* EZV20 (Monitor) ouput capacitor / Speaker */
351
 
        DISCRETE_CRFILTER(NODE_297, 1, NODE_296, 6, CAP_U(22))
352
 
        DISCRETE_OUTPUT(NODE_297, 32767.0/5.0 * 10)
353
 
        //DISCRETE_WAVELOG1(DS_OUT_SOUND0, 32767/5.0)
354
 
        //DISCRETE_WAVELOG2(NODE_296, 32767/5.0 * 2, DS_SOUND7_INV, 10000)
 
435
        DISCRETE_TASK_START(2)
 
436
        DISCRETE_MIXER4(NODE_297,
 
437
                1,                                                                                                                      /* ENAB */
 
438
                DS_OUT_SOUND0, DS_OUT_SOUND1, DS_OUT_SOUND7, DS_OUT_DAC,
 
439
                &mario_mixer)
 
440
        DISCRETE_OUTPUT(NODE_297, 32767.0/1.7)
 
441
        DISCRETE_TASK_END()
355
442
 
356
443
DISCRETE_SOUND_END
357
444