diff options
author | Couriersud <couriersud@users.noreply.github.com> | 2008-04-01 21:17:17 +0000 |
---|---|---|
committer | Couriersud <couriersud@users.noreply.github.com> | 2008-04-01 21:17:17 +0000 |
commit | f4b7ad20e2db44f48010aee83d5759773bb0cc83 (patch) | |
tree | 43f00c47ae3ca958b7ea6e2cd17966e7a48e6201 | |
parent | 4a83ea709fcd94b5a44dcca43db53695965e30eb (diff) |
discrete sound system:
* Fix timing of stream_update in discrete_sound_w
All sound cores update before processing changed data
* Add streeam_update to discrete_sound_r
* Now supports multiple output nodes per module.
There is the possibility to support multiple outputs per module.
In this case, NODE_XXX is the default output. Alternative outputs may
be accessed by using NODE_XXX_YY where 00<Y<08.
You may also access nodes with macros:
NODE_XXX = NODE_SUB(XXX, 0)
NODE_XXX = NODE(XXX)
NODE_XXX_YY = NODE_SUB(XXX, YY) with YY != 00
This should e.g. make discrete sound emulation easier
when dealing with e.g. flip flops (Q & QQ) and binary counters
* added sanity checks to check consistency issues introduced by this change
* modules specify number of outputs ==> Certain special modules (WAVELOG)
may no longer be used as input nodes
* removed explicit (NODE_XX + expr) from a couple of drivers
-rw-r--r-- | src/emu/sound/disc_dev.c | 106 | ||||
-rw-r--r-- | src/emu/sound/disc_flt.c | 136 | ||||
-rw-r--r-- | src/emu/sound/disc_inp.c | 33 | ||||
-rw-r--r-- | src/emu/sound/disc_mth.c | 214 | ||||
-rw-r--r-- | src/emu/sound/disc_wav.c | 130 | ||||
-rw-r--r-- | src/emu/sound/discrete.c | 191 | ||||
-rw-r--r-- | src/emu/sound/discrete.h | 124 | ||||
-rw-r--r-- | src/mame/audio/mw8080bw.c | 2 | ||||
-rw-r--r-- | src/mame/audio/sprint4.c | 2 |
9 files changed, 492 insertions, 446 deletions
diff --git a/src/emu/sound/disc_dev.c b/src/emu/sound/disc_dev.c index feb3ee7bcc1..54d32c2cc3a 100644 --- a/src/emu/sound/disc_dev.c +++ b/src/emu/sound/disc_dev.c @@ -175,7 +175,7 @@ static void dsd_555_astbl_step(node_description *node) { /* We are in RESET */ /* If there was a fatal INIT error then we will also stay in RESET */ - node->output = 0; + node->output[0] = 0; context->flip_flop = 1; context->cap_voltage = 0; return; @@ -308,32 +308,32 @@ static void dsd_555_astbl_step(node_description *node) switch (context->output_type) { case DISC_555_OUT_SQW: - node->output = context->flip_flop * context->output_high_voltage + context->ac_shift; + node->output[0] = context->flip_flop * context->output_high_voltage + context->ac_shift; break; case DISC_555_OUT_CAP: - node->output = vCnext; + node->output[0] = vCnext; /* Fake it to AC if needed */ if (context->output_is_ac) - node->output -= context->threshold * 3.0 /4.0; + node->output[0] -= context->threshold * 3.0 /4.0; break; case DISC_555_OUT_ENERGY: - node->output = context->output_high_voltage * (context->flip_flop ? xTime : (1 - xTime)); - node->output += context->ac_shift; + node->output[0] = context->output_high_voltage * (context->flip_flop ? xTime : (1 - xTime)); + node->output[0] += context->ac_shift; break; case DISC_555_OUT_LOGIC_X: - node->output = context->flip_flop + xTime; + node->output[0] = context->flip_flop + xTime; break; case DISC_555_OUT_COUNT_F_X: - node->output = count_f ? count_f + xTime : count_f; + node->output[0] = count_f ? count_f + xTime : count_f; break; case DISC_555_OUT_COUNT_R_X: - node->output = count_r ? count_r + xTime : count_r; + node->output[0] = count_r ? count_r + xTime : count_r; break; case DISC_555_OUT_COUNT_F: - node->output = count_f; + node->output[0] = count_f; break; case DISC_555_OUT_COUNT_R: - node->output = count_r; + node->output[0] = count_r; break; } } @@ -411,7 +411,7 @@ static void dsd_555_mstbl_step(node_description *node) { /* We are in RESET */ /* If there was a fatal INIT error then we will also stay in RESET */ - node->output = 0; + node->output[0] = 0; context->flip_flop = 0; context->cap_voltage = 0; } @@ -469,16 +469,16 @@ static void dsd_555_mstbl_step(node_description *node) switch (info->options & DISC_555_OUT_MASK) { case DISC_555_OUT_SQW: - node->output = context->flip_flop * context->output_high_voltage; + node->output[0] = context->flip_flop * context->output_high_voltage; /* Fake it to AC if needed */ if (context->output_is_ac) - node->output -= context->output_high_voltage / 2.0; + node->output[0] -= context->output_high_voltage / 2.0; break; case DISC_555_OUT_CAP: - node->output = vCnext; + node->output[0] = vCnext; /* Fake it to AC if needed */ if (context->output_is_ac) - node->output -= context->threshold * 3.0 /4.0; + node->output[0] -= context->threshold * 3.0 /4.0; break; } } @@ -514,7 +514,7 @@ static void dsd_555_mstbl_reset(node_description *node) context->flip_flop = 0; context->cap_voltage = 0; - node->output = 0; + node->output[0] = 0; } @@ -568,7 +568,7 @@ static void dsd_555_cc_step(node_description *node) { /* We are in RESET */ /* If there was a fatal INIT error then we will also stay in RESET */ - node->output = 0; + node->output[0] = 0; context->flip_flop = 1; context->cap_voltage = 0; return; @@ -782,34 +782,34 @@ static void dsd_555_cc_step(node_description *node) if (count_r && (~context->type & 0x01)) { /* There has been an immediate discharge, so keep low for 1 sample. */ - node->output = 0; + node->output[0] = 0; } else - node->output = context->flip_flop * context->output_high_voltage; + node->output[0] = context->flip_flop * context->output_high_voltage; /* Fake it to AC if needed */ - node->output += context->ac_shift; + node->output[0] += context->ac_shift; break; case DISC_555_OUT_CAP: - node->output = vCnext + context->ac_shift; + node->output[0] = vCnext + context->ac_shift; break; case DISC_555_OUT_ENERGY: - node->output = context->output_high_voltage * (context->flip_flop ? xTime : (1 - xTime)); - node->output += context->ac_shift; + node->output[0] = context->output_high_voltage * (context->flip_flop ? xTime : (1 - xTime)); + node->output[0] += context->ac_shift; break; case DISC_555_OUT_LOGIC_X: - node->output = context->flip_flop + xTime; + node->output[0] = context->flip_flop + xTime; break; case DISC_555_OUT_COUNT_F_X: - node->output = count_f + xTime; + node->output[0] = count_f + xTime; break; case DISC_555_OUT_COUNT_R_X: - node->output = count_r + xTime; + node->output[0] = count_r + xTime; break; case DISC_555_OUT_COUNT_F: - node->output = count_f; + node->output[0] = count_f; break; case DISC_555_OUT_COUNT_R: - node->output = count_r; + node->output[0] = count_r; break; } } @@ -1120,32 +1120,32 @@ static void dsd_555_vco1_step(node_description *node) switch (context->output_type) { case DISC_555_OUT_SQW: - node->output = context->flip_flop * context->output_high_voltage + context->ac_shift; + node->output[0] = context->flip_flop * context->output_high_voltage + context->ac_shift; break; case DISC_555_OUT_CAP: - node->output = vCnext; + node->output[0] = vCnext; /* Fake it to AC if needed */ if (context->output_is_ac) - node->output -= context->threshold * 3.0 /4.0; + node->output[0] -= context->threshold * 3.0 /4.0; break; case DISC_555_OUT_ENERGY: - node->output = context->output_high_voltage * (context->flip_flop ? xTime : (1 - xTime)); - node->output += context->ac_shift; + node->output[0] = context->output_high_voltage * (context->flip_flop ? xTime : (1 - xTime)); + node->output[0] += context->ac_shift; break; case DISC_555_OUT_LOGIC_X: - node->output = context->flip_flop + xTime; + node->output[0] = context->flip_flop + xTime; break; case DISC_555_OUT_COUNT_F_X: - node->output = count_f ? count_f + xTime : count_f; + node->output[0] = count_f ? count_f + xTime : count_f; break; case DISC_555_OUT_COUNT_R_X: - node->output = count_r ? count_r + xTime : count_r; + node->output[0] = count_r ? count_r + xTime : count_r; break; case DISC_555_OUT_COUNT_F: - node->output = count_f; + node->output[0] = count_f; break; case DISC_555_OUT_COUNT_R: - node->output = count_r; + node->output[0] = count_r; break; } } @@ -1308,34 +1308,34 @@ static void dsd_566_step(node_description *node) case DISC_566_OUT_SQUARE: case DISC_566_OUT_LOGIC: /* use up any output states */ - if (node->output && context->state[0]) + if (node->output[0] && context->state[0]) { - node->output = 0; + node->output[0] = 0; context->state[0]--; } - else if (!node->output && context->state[1]) + else if (!node->output[0] && context->state[1]) { - node->output = 1; + node->output[0] = 1; context->state[1]--; } else { - node->output = context->flip_flop; + node->output[0] = context->flip_flop; } if ((info->options & DISC_566_OUT_MASK) != DISC_566_OUT_LOGIC) - node->output = context->flip_flop ? context->vSqrHigh : context->vSqrLow; + node->output[0] = context->flip_flop ? context->vSqrHigh : context->vSqrLow; break; case DISC_566_OUT_TRIANGLE: /* we can ignore any unused states when * outputting the cap voltage */ - node->output = vCnext; + node->output[0] = vCnext; if (info->options & DISC_566_OUT_AC) - node->output -= context->triOffset; + node->output[0] -= context->triOffset; break; } } else - node->output = 0; + node->output[0] = 0; } static void dsd_566_reset(node_description *node) @@ -1434,22 +1434,22 @@ static void dsd_ls624_step(node_description *node) switch (context->outtype) { case DISC_LS624_OUT_ENERGY: - node->output = ((double) lst) * (1.0+context->remain/sample_t) - ((double) context->state) * context->remain/sample_t; + node->output[0] = ((double) lst) * (1.0+context->remain/sample_t) - ((double) context->state) * context->remain/sample_t; break; case DISC_LS624_OUT_LOGIC: - node->output = context->state; + node->output[0] = context->state; break; case DISC_LS624_OUT_COUNT_F: - node->output = cntf; + node->output[0] = cntf; break; case DISC_LS624_OUT_COUNT_R: - node->output = cntr; + node->output[0] = cntr; break; } } else - node->output = 0; + node->output[0] = 0; } static void dsd_ls624_reset(node_description *node) diff --git a/src/emu/sound/disc_flt.c b/src/emu/sound/disc_flt.c index d68120980be..b8a2cc6b47a 100644 --- a/src/emu/sound/disc_flt.c +++ b/src/emu/sound/disc_flt.c @@ -119,12 +119,12 @@ static void dst_crfilter_step(node_description *node) if(DST_CRFILTER__ENABLE) { - node->output = DST_CRFILTER__IN - context->vCap; + node->output[0] = DST_CRFILTER__IN - context->vCap; context->vCap += ((DST_CRFILTER__IN - DST_CRFILTER__VREF) - context->vCap) * context->exponent; } else { - node->output = 0; + node->output[0] = 0; } } @@ -135,7 +135,7 @@ static void dst_crfilter_reset(node_description *node) context->exponent = -1.0 / (DST_CRFILTER__R * DST_CRFILTER__C * discrete_current_context->sample_rate); context->exponent = 1.0 - exp(context->exponent); context->vCap = 0; - node->output = DST_CRFILTER__IN; + node->output[0] = DST_CRFILTER__IN; } @@ -191,10 +191,10 @@ static void dst_filter1_step(node_description *node) gain = 0.0; } - node->output = -context->a1*context->y1 + context->b0*gain*DST_FILTER1__IN + context->b1*context->x1; + node->output[0] = -context->a1*context->y1 + context->b0*gain*DST_FILTER1__IN + context->b1*context->x1; context->x1 = gain*DST_FILTER1__IN; - context->y1 = node->output; + context->y1 = node->output[0]; } static void dst_filter1_reset(node_description *node) @@ -202,7 +202,7 @@ static void dst_filter1_reset(node_description *node) struct dss_filter1_context *context = node->context; calculate_filter1_coefficients(DST_FILTER1__FREQ, DST_FILTER1__TYPE, &context->a1, &context->b0, &context->b1); - node->output=0; + node->output[0]=0; } @@ -275,13 +275,13 @@ static void dst_filter2_step(node_description *node) gain = 0.0; } - node->output = -context->a1*context->y1 - context->a2*context->y2 + + node->output[0] = -context->a1*context->y1 - context->a2*context->y2 + context->b0*gain*DST_FILTER2__IN + context->b1*context->x1 + context->b2*context->x2; context->x2 = context->x1; context->x1 = gain * DST_FILTER2__IN; context->y2 = context->y1; - context->y1 = node->output; + context->y1 = node->output[0]; } static void dst_filter2_reset(node_description *node) @@ -291,7 +291,7 @@ static void dst_filter2_reset(node_description *node) calculate_filter2_coefficients(DST_FILTER2__FREQ, DST_FILTER2__DAMP, DST_FILTER2__TYPE, &context->a1, &context->a2, &context->b0, &context->b1, &context->b2); - node->output=0; + node->output[0]=0; } @@ -341,41 +341,41 @@ static void dst_op_amp_filt_step(node_description *node) { case DISC_OP_AMP_FILTER_IS_LOW_PASS_1: context->vC1 += (v - context->vC1) * context->exponentC1; - node->output = context->vC1 * context->gain + info->vRef; + node->output[0] = context->vC1 * context->gain + info->vRef; break; case DISC_OP_AMP_FILTER_IS_HIGH_PASS_1: - node->output = (v - context->vC1) * context->gain + info->vRef; + node->output[0] = (v - context->vC1) * context->gain + info->vRef; context->vC1 += (v - context->vC1) * context->exponentC1; break; case DISC_OP_AMP_FILTER_IS_BAND_PASS_1: - node->output = (v - context->vC2); + node->output[0] = (v - context->vC2); context->vC2 += (v - context->vC2) * context->exponentC2; - context->vC1 += (node->output - context->vC1) * context->exponentC1; - node->output = context->vC1 * context->gain + info->vRef; + context->vC1 += (node->output[0] - context->vC1) * context->exponentC1; + node->output[0] = context->vC1 * context->gain + info->vRef; break; case DISC_OP_AMP_FILTER_IS_BAND_PASS_0 | DISC_OP_AMP_IS_NORTON: context->vC1 += (v - context->vC1) * context->exponentC1; context->vC2 += (context->vC1 - context->vC2) * context->exponentC2; v = context->vC2; - node->output = v - context->vC3; + node->output[0] = v - context->vC3; context->vC3 += (v - context->vC3) * context->exponentC3; - i = node->output / context->rTotal; - node->output = (context->iFixed - i) * info->rF; + i = node->output[0] / context->rTotal; + node->output[0] = (context->iFixed - i) * info->rF; break; case DISC_OP_AMP_FILTER_IS_HIGH_PASS_0 | DISC_OP_AMP_IS_NORTON: - node->output = v - context->vC1; + node->output[0] = v - context->vC1; context->vC1 += (v - context->vC1) * context->exponentC1; - i = node->output / context->rTotal; - node->output = (context->iFixed - i) * info->rF; + i = node->output[0] / context->rTotal; + node->output[0] = (context->iFixed - i) * info->rF; break; case DISC_OP_AMP_FILTER_IS_BAND_PASS_1M: case DISC_OP_AMP_FILTER_IS_BAND_PASS_1M | DISC_OP_AMP_IS_NORTON: - node->output = -context->a1*context->y1 - context->a2*context->y2 + + node->output[0] = -context->a1*context->y1 - context->a2*context->y2 + context->b0*v + context->b1*context->x1 + context->b2*context->x2 + context->vRef; context->x2 = context->x1; @@ -387,12 +387,12 @@ static void dst_op_amp_filt_step(node_description *node) /* Clip the output to the voltage rails. * This way we get the original distortion in all it's glory. */ - if (node->output > context->vP) node->output = context->vP; - if (node->output < context->vN) node->output = context->vN; - context->y1 = node->output - context->vRef; + if (node->output[0] > context->vP) node->output[0] = context->vP; + if (node->output[0] < context->vN) node->output[0] = context->vN; + context->y1 = node->output[0] - context->vRef; } else - node->output = 0; + node->output[0] = 0; } @@ -498,7 +498,7 @@ static void dst_op_amp_filt_reset(node_description *node) context->vC2 = 0; context->vC3 = 0; - node->output = info->vRef; + node->output[0] = info->vRef; } @@ -528,12 +528,12 @@ static void dst_rcdisc_step(node_description *node) context->state = 1; context->t = 0; } - node->output=0; + node->output[0]=0; break; case 1: if (DST_RCDISC__ENABLE) { - node->output = DST_RCDISC__IN * exp(context->t / context->exponent0); + node->output[0] = DST_RCDISC__IN * exp(context->t / context->exponent0); context->t += discrete_current_context->sample_time; } else { context->state = 0; @@ -545,7 +545,7 @@ static void dst_rcdisc_reset(node_description *node) { struct dst_rcdisc_context *context = node->context; - node->output=0; + node->output[0]=0; context->state = 0; context->t = 0; @@ -581,16 +581,16 @@ static void dst_rcdisc2_step(node_description *node) /* Works differently to other as we are always on, no enable */ /* exponential based in difference between input/output */ - diff = ((DST_RCDISC2__ENABLE == 0) ? DST_RCDISC2__IN0 : DST_RCDISC2__IN1) - node->output; + diff = ((DST_RCDISC2__ENABLE == 0) ? DST_RCDISC2__IN0 : DST_RCDISC2__IN1) - node->output[0]; diff = diff - (diff * exp(discrete_current_context->sample_time / ((DST_RCDISC2__ENABLE == 0) ? context->exponent0 : context->exponent1))); - node->output += diff; + node->output[0] += diff; } static void dst_rcdisc2_reset(node_description *node) { struct dst_rcdisc_context *context = node->context; - node->output=0; + node->output[0]=0; context->state = 0; context->t = 0; @@ -625,7 +625,7 @@ static void dst_rcdisc3_step(node_description *node) if(DST_RCDISC3__ENABLE) { - diff = DST_RCDISC3__IN - node->output; + diff = DST_RCDISC3__IN - node->output[0]; if( diff > 0 ) { diff = diff - (diff * exp(discrete_current_context->sample_time / context->exponent0)); @@ -636,11 +636,11 @@ static void dst_rcdisc3_step(node_description *node) else diff = diff - (diff * exp(discrete_current_context->sample_time / context->exponent0)); } - node->output += diff; + node->output[0] += diff; } else { - node->output=0; + node->output[0]=0; } } @@ -648,7 +648,7 @@ static void dst_rcdisc3_reset(node_description *node) { struct dst_rcdisc_context *context = node->context; - node->output=0; + node->output[0]=0; context->state = 0; context->t = 0; @@ -686,7 +686,7 @@ static void dst_rcdisc4_step(node_description *node) if (DST_RCDISC4__ENABLE == 0) { - node->output = 0; + node->output[0] = 0; return; } @@ -695,13 +695,13 @@ static void dst_rcdisc4_step(node_description *node) case 1: case 3: context->vC1 += ((context->v[inp1] - context->vC1) * context->exp[inp1]); - node->output = context->vC1; + node->output[0] = context->vC1; break; } /* clip output */ - if (node->output > context->max_out) node->output = context->max_out; - if (node->output < 0) node->output = 0; + if (node->output[0] > context->max_out) node->output[0] = context->max_out; + if (node->output[0] < 0) node->output[0] = 0; } static void dst_rcdisc4_reset(node_description *node) @@ -806,16 +806,16 @@ static void dst_rcdisc5_step(node_description *node) if( u < 0) u = 0; - diff = u - node->output; + diff = u - node->output[0]; if(diff < 0) //diff = diff - (diff * exp(discrete_current_context->sample_time / context->exponent0)); - diff = -node->output + (node->output * exp(discrete_current_context->sample_time / context->exponent0)); - node->output += diff; + diff = -node->output[0] + (node->output[0] * exp(discrete_current_context->sample_time / context->exponent0)); + node->output[0] += diff; } else { - node->output=0; + node->output[0]=0; } } @@ -823,7 +823,7 @@ static void dst_rcdisc5_reset(node_description *node) { struct dst_rcdisc_context *context = node->context; - node->output=0; + node->output[0]=0; context->state = 0; context->t = 0; @@ -920,19 +920,19 @@ static void dst_rcintegrate_step(node_description *node) switch (context->state) { case DISC_RC_INTEGRATE_TYPE1: - node->output = context->vCap; + node->output[0] = context->vCap; break; case DISC_RC_INTEGRATE_TYPE2: - node->output = vE; + node->output[0] = vE; break; case DISC_RC_INTEGRATE_TYPE3: - node->output = MAX(0,vP - iQ * context->R3); + node->output[0] = MAX(0,vP - iQ * context->R3); break; } } else { - node->output=0; + node->output[0]=0; } } @@ -941,7 +941,7 @@ static void dst_rcintegrate_reset(node_description *node) struct dst_rcdisc_context *context = node->context; double r; - node->output=0; + node->output[0]=0; context->state = DST_RCINTEGRATE__TYPE; context->R1 = DST_RCINTEGRATE__R1; @@ -1009,20 +1009,20 @@ static void dst_rcdisc_mod_step(node_description *node) diff = u + 0.6 - vCap; diff = diff - (diff * exp(0.0-discrete_current_context->sample_time / (DST_RCDISC_MOD__C*Rc))); vCap += diff; - node->output = (DST_RCDISC_MOD__IN2 <= 0.6) ? -0.6 : 0; + node->output[0] = (DST_RCDISC_MOD__IN2 <= 0.6) ? -0.6 : 0; } else { diff = diff - (diff * exp(0.0-discrete_current_context->sample_time / (DST_RCDISC_MOD__C*(Rc+Rc2)))); vCap += diff; /* neglecting current through R3 drawn by next node */ - node->output = (DST_RCDISC_MOD__IN2 <= 0.6) ? (u-vCap)*DST_RCDISC_MOD__R4/(DST_RCDISC_MOD__R4+Rc) : 0; + node->output[0] = (DST_RCDISC_MOD__IN2 <= 0.6) ? (u-vCap)*DST_RCDISC_MOD__R4/(DST_RCDISC_MOD__R4+Rc) : 0; } context->vCap = vCap; } else { - node->output=0; + node->output[0]=0; } } @@ -1030,7 +1030,7 @@ static void dst_rcdisc_mod_reset(node_description *node) { struct dst_rcdisc_context *context = node->context; - node->output=0; + node->output[0]=0; context->vCap = 0; } @@ -1062,11 +1062,11 @@ static void dst_rcfilter_step(node_description *node) if(DST_RCFILTER__ENABLE) { context->vCap += ((DST_RCFILTER__VIN - DST_RCFILTER__VREF - context->vCap) * context->exponent); - node->output = context->vCap + DST_RCFILTER__VREF; + node->output[0] = context->vCap + DST_RCFILTER__VREF; } else { - node->output=0; + node->output[0]=0; } } @@ -1077,7 +1077,7 @@ static void dst_rcfilter_reset(node_description *node) context->exponent = -1.0 / (DST_RCFILTER__R * DST_RCFILTER__C * discrete_current_context->sample_rate); context->exponent = 1.0 - exp(context->exponent); context->vCap = 0; - node->output = 0; + node->output[0] = 0; } /************************************************************************ @@ -1116,19 +1116,19 @@ static void dst_rcfilter_sw_step(node_description *node) rs += DST_RCFILTER_SW__R; } } - node->output = CD4066_ON_RES / ( CD4066_ON_RES + rs) * DST_RCFILTER_SW__VIN + DST_RCFILTER_SW__R / (CD4066_ON_RES + rs) * us; + node->output[0] = CD4066_ON_RES / ( CD4066_ON_RES + rs) * DST_RCFILTER_SW__VIN + DST_RCFILTER_SW__R / (CD4066_ON_RES + rs) * us; for (i=0;i<4;i++) { if ( ( (int)DST_RCFILTER_SW__SWITCH & (1<<i)) == 1) { rcexp = 1.0 - exp(-1.0 / ( CD4066_ON_RES * DST_RCFILTER_SW__C(i)) * discrete_current_context->sample_rate); - context->vCap[i] += ((node->output - context->vCap[i]) * rcexp); + context->vCap[i] += ((node->output[0] - context->vCap[i]) * rcexp); } } } else { - node->output=0; + node->output[0]=0; } } @@ -1139,7 +1139,7 @@ static void dst_rcfilter_sw_reset(node_description *node) for (i=0;i<4;i++) context->vCap[i] = 0; - node->output = 0; + node->output[0] = 0; } /* !!!!!!!!!!! NEW FILTERS for testing !!!!!!!!!!!!!!!!!!!!! */ @@ -1218,12 +1218,12 @@ static void dst_rcdiscN_step(node_description *node) /* A rise in the input signal results in an instant charge, */ /* else discharge through the RC to zero */ if (gain* DST_RCDISCN__IN > context->x1) - node->output = gain* DST_RCDISCN__IN; + node->output[0] = gain* DST_RCDISCN__IN; else - node->output = -context->a1*context->y1; + node->output[0] = -context->a1*context->y1; context->x1 = gain* DST_RCDISCN__IN; - context->y1 = node->output; + context->y1 = node->output[0]; } @@ -1261,12 +1261,12 @@ static void dst_rcdisc2N_step(node_description *node) double input = ((DST_RCDISC2N__ENABLE == 0) ? DST_RCDISC2N__IN0 : DST_RCDISC2N__IN1); if (DST_RCDISC2N__ENABLE == 0) - node->output = -context->a1_0*context->y1 + context->b0_0*input + context->b1_0*context->x1; + node->output[0] = -context->a1_0*context->y1 + context->b0_0*input + context->b1_0*context->x1; else - node->output = -context->a1_1*context->y1 + context->b0_1*input + context->b1_1*context->x1; + node->output[0] = -context->a1_1*context->y1 + context->b0_1*input + context->b1_1*context->x1; context->x1 = input; - context->y1 = node->output; + context->y1 = node->output[0]; } static void dst_rcdisc2N_reset(node_description *node) @@ -1281,5 +1281,5 @@ static void dst_rcdisc2N_reset(node_description *node) calculate_filter1_coefficients(f2, DISC_FILTER_LOWPASS, &context->a1_1, &context->b0_1, &context->b1_1); /* Initialize the object */ - node->output=0; + node->output[0]=0; } diff --git a/src/emu/sound/disc_inp.c b/src/emu/sound/disc_inp.c index c1ca45881f6..58f3573aac9 100644 --- a/src/emu/sound/disc_inp.c +++ b/src/emu/sound/disc_inp.c @@ -42,6 +42,9 @@ READ8_HANDLER(discrete_sound_r) { UINT8 *node_data = node->context; + /* Bring the system up to now */ + stream_update(info->discrete_stream); + if ((node->module.type >= DSS_INPUT_DATA) && (node->module.type <= DSS_INPUT_PULSE)) { data = *node_data; @@ -63,24 +66,28 @@ WRITE8_HANDLER(discrete_sound_w) { UINT8 *node_data = node->context; UINT8 last_data = *node_data; + UINT8 new_data = 0; switch (node->module.type) { case DSS_INPUT_DATA: - *node_data = data; + new_data = data; break; case DSS_INPUT_LOGIC: case DSS_INPUT_PULSE: - *node_data = data ? 1 : 0; + new_data = data ? 1 : 0; break; case DSS_INPUT_NOT: - *node_data = data ? 0 : 1; + new_data = data ? 0 : 1; break; } - - /* Bring the system up to now */ - if (last_data != *node_data) + if (last_data != new_data) + { + /* Bring the system up to now */ stream_update(info->discrete_stream); + + *node_data = new_data; + } } else { @@ -125,14 +132,14 @@ static void dss_adjustment_step(node_description *node) context->lastpval = rawportval; if (DSS_ADJUSTMENT__LOG == 0) - node->output = scaledval; + node->output[0] = scaledval; else - node->output = pow(10, scaledval); + node->output[0] = pow(10, scaledval); } } else { - node->output = 0; + node->output[0] = 0; } } @@ -186,7 +193,7 @@ static void dss_adjustment_reset(node_description *node) static void dss_constant_step(node_description *node) { - node->output= DSS_CONSTANT__INIT; + node->output[0]= DSS_CONSTANT__INIT; } @@ -204,7 +211,7 @@ static void dss_input_step(node_description *node) { UINT8 *node_data = node->context; - node->output = *node_data * DSS_INPUT__GAIN + DSS_INPUT__OFFSET; + node->output[0] = *node_data * DSS_INPUT__GAIN + DSS_INPUT__OFFSET; } static void dss_input_reset(node_description *node) @@ -232,7 +239,7 @@ static void dss_input_pulse_step(node_description *node) UINT8 *node_data = node->context; /* Set a valid output */ - node->output = *node_data; + node->output[0] = *node_data; /* Reset the input to default for the next cycle */ /* node order is now important */ *node_data = DSS_INPUT__INIT; @@ -258,7 +265,7 @@ static void dss_input_stream_step(node_description *node) stream_sample_t **ptr = node->context; stream_sample_t *data = *ptr; - node->output = data ? (*data) * DSS_INPUT_STREAM__GAIN + DSS_INPUT_STREAM__OFFSET : 0; + node->output[0] = data ? (*data) * DSS_INPUT_STREAM__GAIN + DSS_INPUT_STREAM__OFFSET : 0; } static void dss_input_stream_reset(node_description *node) diff --git a/src/emu/sound/disc_mth.c b/src/emu/sound/disc_mth.c index 800c2671deb..e8e573b9c67 100644 --- a/src/emu/sound/disc_mth.c +++ b/src/emu/sound/disc_mth.c @@ -167,11 +167,11 @@ static void dst_adder_step(node_description *node) { if(DST_ADDER__ENABLE) { - node->output = DST_ADDER__IN0 + DST_ADDER__IN1 + DST_ADDER__IN2 + DST_ADDER__IN3; + node->output[0] = DST_ADDER__IN0 + DST_ADDER__IN1 + DST_ADDER__IN2 + DST_ADDER__IN3; } else { - node->output=0; + node->output[0]=0; } } @@ -200,25 +200,25 @@ static void dst_comp_adder_step(node_description *node) switch (info->type) { case DISC_COMP_P_CAPACITOR: - node->output = info->cDefault; + node->output[0] = info->cDefault; for(bit=0; bit < info->length; bit++) { - if (DST_COMP_ADDER__SELECT & (1 << bit)) node->output += info->c[bit]; + if (DST_COMP_ADDER__SELECT & (1 << bit)) node->output[0] += info->c[bit]; } break; case DISC_COMP_P_RESISTOR: - node->output = info->cDefault ? 1.0 / info->cDefault : 0; + node->output[0] = info->cDefault ? 1.0 / info->cDefault : 0; for(bit=0; bit < info->length; bit++) { - if (DST_COMP_ADDER__SELECT & (1 << bit)) node->output += 1.0 / info->c[bit]; + if (DST_COMP_ADDER__SELECT & (1 << bit)) node->output[0] += 1.0 / info->c[bit]; } - if (node->output != 0) node->output = 1.0 / node->output; + if (node->output[0] != 0) node->output[0] = 1.0 / node->output[0]; break; } } else { - node->output = 0; + node->output[0] = 0; } } @@ -244,13 +244,13 @@ static void dst_clamp_step(node_description *node) { if(DST_CLAMP__ENABLE) { - if(DST_CLAMP__IN < DST_CLAMP__MIN) node->output = DST_CLAMP__MIN; - else if(DST_CLAMP__IN > DST_CLAMP__MAX) node->output = DST_CLAMP__MAX; - else node->output= DST_CLAMP__IN; + if(DST_CLAMP__IN < DST_CLAMP__MIN) node->output[0] = DST_CLAMP__MIN; + else if(DST_CLAMP__IN > DST_CLAMP__MAX) node->output[0] = DST_CLAMP__MAX; + else node->output[0]= DST_CLAMP__IN; } else { - node->output = DST_CLAMP__CLAMP; + node->output[0] = DST_CLAMP__CLAMP; } } @@ -295,7 +295,7 @@ static void dst_dac_r1_step(node_description *node) v = i * context->rTotal; /* Filter if needed, else just output voltage */ - node->output = info->cFilter ? node->output + ((v - node->output) * context->exponent) : v; + node->output[0] = info->cFilter ? node->output[0] + ((v - node->output[0]) * context->exponent) : v; } else { @@ -350,7 +350,7 @@ static void dst_dac_r1_reset(node_description *node) if (info->rGnd) context->rTotal += 1.0 / info->rGnd; context->rTotal = 1.0 / context->rTotal; - node->output = 0; + node->output[0] = 0; if (info->cFilter) { @@ -388,12 +388,12 @@ static void dst_diode_mix_step(node_description *node) { if (DST_DIODE_MIX__INP(addr) > max) max = DST_DIODE_MIX__INP(addr); } - node->output = max - DST_DIODE_MIX__VJUNC; - if (node->output < 0) node->output = 0; + node->output[0] = max - DST_DIODE_MIX__VJUNC; + if (node->output[0] < 0) node->output[0] = 0; } else { - node->output = 0; + node->output[0] = 0; } } @@ -426,17 +426,17 @@ static void dst_divide_step(node_description *node) { if(DST_DIVIDE__DIV == 0) { - node->output=DBL_MAX; /* Max out but don't break */ - discrete_log("dst_divider_step() - Divide by Zero attempted in NODE_%02d.\n",node->node-NODE_START); + node->output[0]=DBL_MAX; /* Max out but don't break */ + discrete_log("dst_divider_step() - Divide by Zero attempted in NODE_%02d.\n",NODE_INDEX(node->node)); } else { - node->output= DST_DIVIDE__IN / DST_DIVIDE__DIV; + node->output[0]= DST_DIVIDE__IN / DST_DIVIDE__DIV; } } else { - node->output=0; + node->output[0]=0; } } @@ -460,12 +460,12 @@ static void dst_gain_step(node_description *node) { if(DST_GAIN__ENABLE) { - node->output = DST_GAIN__IN * DST_GAIN__GAIN; - node->output += DST_GAIN__OFFSET; + node->output[0] = DST_GAIN__IN * DST_GAIN__GAIN; + node->output[0] += DST_GAIN__OFFSET; } else { - node->output=0; + node->output[0]=0; } } @@ -535,17 +535,17 @@ static void dst_integrate_step(node_description *node) /* This forces the cap to completely charge, * and the output to go to it's max value. */ - node->output = context->vMaxOut; + node->output[0] = context->vMaxOut; return; } - node->output -= context->change; + node->output[0] -= context->change; break; case DISC_INTEGRATE_OP_AMP_1 | DISC_OP_AMP_IS_NORTON: iNeg = context->vMaxIn / info->r1; iPos = (DST_INTEGRATE__TRG0 - OP_AMP_NORTON_VBE) / info->r2; if (iPos < 0) iPos = 0; - node->output += (iPos - iNeg) / discrete_current_context->sample_rate / info->c; + node->output[0] += (iPos - iNeg) / discrete_current_context->sample_rate / info->c; break; case DISC_INTEGRATE_OP_AMP_2 | DISC_OP_AMP_IS_NORTON: @@ -554,13 +554,13 @@ static void dst_integrate_step(node_description *node) iNeg = dst_trigger_function(trig0, trig1, 0, info->f0) ? context->vMaxInD / info->r1 : 0; iPos = dst_trigger_function(trig0, trig1, 0, info->f1) ? context->vMaxIn / info->r2 : 0; iPos += dst_trigger_function(trig0, trig1, 0, info->f2) ? context->vMaxInD / info->r3 : 0; - node->output += (iPos - iNeg) / discrete_current_context->sample_rate / info->c; + node->output[0] += (iPos - iNeg) / discrete_current_context->sample_rate / info->c; break; } /* Clip the output. */ - if (node->output < 0) node->output = 0; - if (node->output > context->vMaxOut) node->output = context->vMaxOut; + if (node->output[0] < 0) node->output[0] = 0; + if (node->output[0] > context->vMaxOut) node->output[0] = context->vMaxOut; } static void dst_integrate_reset(node_description *node) @@ -584,7 +584,7 @@ static void dst_integrate_reset(node_description *node) i = v / info->r1; context->change = i / discrete_current_context->sample_rate / info->c; } - node->output = 0; + node->output[0] = 0; } @@ -603,11 +603,11 @@ static void dst_logic_inv_step(node_description *node) { if(DST_LOGIC_INV__ENABLE) { - node->output = DST_LOGIC_INV__IN ? 0.0 : 1.0; + node->output[0] = DST_LOGIC_INV__IN ? 0.0 : 1.0; } else { - node->output=0.0; + node->output[0]=0.0; } } @@ -632,11 +632,11 @@ static void dst_logic_and_step(node_description *node) { if(DST_LOGIC_AND__ENABLE) { - node->output= (DST_LOGIC_AND__IN0 && DST_LOGIC_AND__IN1 && DST_LOGIC_AND__IN2 && DST_LOGIC_AND__IN3)? 1.0 : 0.0; + node->output[0]= (DST_LOGIC_AND__IN0 && DST_LOGIC_AND__IN1 && DST_LOGIC_AND__IN2 && DST_LOGIC_AND__IN3)? 1.0 : 0.0; } else { - node->output=0.0; + node->output[0]=0.0; } } @@ -661,11 +661,11 @@ static void dst_logic_nand_step(node_description *node) { if(DST_LOGIC_NAND__ENABLE) { - node->output= (DST_LOGIC_NAND__IN0 && DST_LOGIC_NAND__IN1 && DST_LOGIC_NAND__IN2 && DST_LOGIC_NAND__IN3)? 0.0 : 1.0; + node->output[0]= (DST_LOGIC_NAND__IN0 && DST_LOGIC_NAND__IN1 && DST_LOGIC_NAND__IN2 && DST_LOGIC_NAND__IN3)? 0.0 : 1.0; } else { - node->output=0.0; + node->output[0]=0.0; } } @@ -690,11 +690,11 @@ static void dst_logic_or_step(node_description *node) { if(DST_LOGIC_OR__ENABLE) { - node->output = (DST_LOGIC_OR__IN0 || DST_LOGIC_OR__IN1 || DST_LOGIC_OR__IN2 || DST_LOGIC_OR__IN3) ? 1.0 : 0.0; + node->output[0] = (DST_LOGIC_OR__IN0 || DST_LOGIC_OR__IN1 || DST_LOGIC_OR__IN2 || DST_LOGIC_OR__IN3) ? 1.0 : 0.0; } else { - node->output=0.0; + node->output[0]=0.0; } } @@ -719,11 +719,11 @@ static void dst_logic_nor_step(node_description *node) { if(DST_LOGIC_NOR__ENABLE) { - node->output = (DST_LOGIC_NOR__IN0 || DST_LOGIC_NOR__IN1 || DST_LOGIC_NOR__IN2 || DST_LOGIC_NOR__IN3) ? 0.0 : 1.0; + node->output[0] = (DST_LOGIC_NOR__IN0 || DST_LOGIC_NOR__IN1 || DST_LOGIC_NOR__IN2 || DST_LOGIC_NOR__IN3) ? 0.0 : 1.0; } else { - node->output=0.0; + node->output[0]=0.0; } } @@ -744,11 +744,11 @@ static void dst_logic_xor_step(node_description *node) { if(DST_LOGIC_XOR__ENABLE) { - node->output=((DST_LOGIC_XOR__IN0 && !DST_LOGIC_XOR__IN1) || (!DST_LOGIC_XOR__IN0 && DST_LOGIC_XOR__IN1)) ? 1.0 : 0.0; + node->output[0]=((DST_LOGIC_XOR__IN0 && !DST_LOGIC_XOR__IN1) || (!DST_LOGIC_XOR__IN0 && DST_LOGIC_XOR__IN1)) ? 1.0 : 0.0; } else { - node->output=0.0; + node->output[0]=0.0; } } @@ -769,11 +769,11 @@ static void dst_logic_nxor_step(node_description *node) { if(DST_LOGIC_XNOR__ENABLE) { - node->output=((DST_LOGIC_XNOR__IN0 && !DST_LOGIC_XNOR__IN1) || (!DST_LOGIC_XNOR__IN0 && DST_LOGIC_XNOR__IN1)) ? 0.0 : 1.0; + node->output[0]=((DST_LOGIC_XNOR__IN0 && !DST_LOGIC_XNOR__IN1) || (!DST_LOGIC_XNOR__IN0 && DST_LOGIC_XNOR__IN1)) ? 0.0 : 1.0; } else { - node->output=0.0; + node->output[0]=0.0; } } @@ -803,17 +803,17 @@ static void dst_logic_dff_step(node_description *node) if (DST_LOGIC_DFF__ENABLE) { if (DST_LOGIC_DFF__RESET) - node->output = 0; + node->output[0] = 0; else if (DST_LOGIC_DFF__SET) - node->output = 1; + node->output[0] = 1; else if (!context->last_clk && clk) /* low to high */ { - node->output = DST_LOGIC_DFF__DATA; + node->output[0] = DST_LOGIC_DFF__DATA; } } else { - node->output = 0; + node->output[0] = 0; } context->last_clk = clk; } @@ -822,7 +822,7 @@ static void dst_logic_ff_reset(node_description *node) { struct dst_flipflop_context *context = node->context; context->last_clk = 0; - node->output = 0; + node->output[0] = 0; } @@ -855,9 +855,9 @@ static void dst_logic_jkff_step(node_description *node) if (DST_LOGIC_JKFF__ENABLE) { if (DST_LOGIC_JKFF__RESET) - node->output = 0; + node->output[0] = 0; else if (DST_LOGIC_JKFF__SET) - node->output = 1; + node->output[0] = 1; else if (context->last_clk && !clk) /* high to low */ { if (!j) @@ -865,22 +865,22 @@ static void dst_logic_jkff_step(node_description *node) /* J=0, K=0 - Hold */ if (k) /* J=0, K=1 - Reset */ - node->output = 0; + node->output[0] = 0; } else { if (!k) /* J=1, K=0 - Set */ - node->output = 1; + node->output[0] = 1; else /* J=1, K=1 - Toggle */ - node->output = !(int)node->output; + node->output[0] = !(int)node->output[0]; } } } else { - node->output=0; + node->output[0]=0; } context->last_clk = clk; } @@ -908,9 +908,9 @@ static void dst_lookup_table_step(node_description *node) int addr = DST_LOOKUP_TABLE__IN; if (!DST_LOOKUP_TABLE__ENABLE || addr < 0 || addr >= DST_LOOKUP_TABLE__SIZE) - node->output = 0; + node->output[0] = 0; else - node->output = table[addr]; + node->output[0] = table[addr]; } /************************************************************************ @@ -1061,11 +1061,11 @@ static void dst_mixer_step(node_description *node) context->vCapAmp += (v - context->vCapAmp) * context->exponent_cAmp; v -= context->vCapAmp; } - node->output = v * info->gain; + node->output[0] = v * info->gain; } else { - node->output = 0; + node->output[0] = 0; } } @@ -1083,7 +1083,7 @@ static void dst_mixer_reset(node_description *node) { r_node = discrete_find_node(NULL, info->rNode[bit]); if (r_node) - context->rNode[bit] = &(r_node->output); + context->rNode[bit] = &(r_node->output[NODE_CHILD_NODE_NUM(info->rNode[bit])]); else context->rNode[bit] = NULL; } @@ -1169,7 +1169,7 @@ static void dst_mixer_reset(node_description *node) if ((context->type & DISC_MIXER_TYPE_MASK) == DISC_MIXER_IS_OP_AMP_WITH_RI) context->gain = info->rF / info->rI; - node->output = 0; + node->output[0] = 0; } @@ -1199,7 +1199,7 @@ static void dst_multiplex_step(node_description *node) addr = DST_MULTIPLEX__ADDR; // FP to INT if ((addr >= 0) && (addr < context->size)) { - node->output = DST_MULTIPLEX__INP(addr); + node->output[0] = DST_MULTIPLEX__INP(addr); } else { @@ -1209,7 +1209,7 @@ static void dst_multiplex_step(node_description *node) } else { - node->output=0; + node->output[0]=0; } } @@ -1252,7 +1252,7 @@ static void dst_oneshot_step(node_description *node) if (DST_ONESHOT__RESET) { /* Hold in Reset */ - node->output = 0; + node->output[0] = 0; context->state = 0; } else @@ -1270,7 +1270,7 @@ static void dst_oneshot_step(node_description *node) { /* We have first trigger */ context->state = 1; - node->output = (DST_ONESHOT__TYPE & DISC_OUT_ACTIVE_LOW) ? 0 : DST_ONESHOT__AMP; + node->output[0] = (DST_ONESHOT__TYPE & DISC_OUT_ACTIVE_LOW) ? 0 : DST_ONESHOT__AMP; context->countdown = DST_ONESHOT__WIDTH; } else @@ -1291,7 +1291,7 @@ static void dst_oneshot_step(node_description *node) context->countdown -= discrete_current_context->sample_time; if(context->countdown <= 0.0) { - node->output = (DST_ONESHOT__TYPE & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0; + node->output[0] = (DST_ONESHOT__TYPE & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0; context->countdown = 0; context->state = 0; } @@ -1307,7 +1307,7 @@ static void dst_oneshot_reset(node_description *node) context->state = 0; context->lastTrig = 0; - node->output = (DST_ONESHOT__TYPE & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0; + node->output[0] = (DST_ONESHOT__TYPE & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0; } @@ -1339,21 +1339,21 @@ static void dst_ramp_step(node_description *node) if (!context->last_en) { context->last_en = 1; - node->output = DST_RAMP__START; + node->output[0] = DST_RAMP__START; } - if(context->dir ? DST_RAMP__DIR : !DST_RAMP__DIR) node->output+=context->step; - else node->output-=context->step; + if(context->dir ? DST_RAMP__DIR : !DST_RAMP__DIR) node->output[0]+=context->step; + else node->output[0]-=context->step; /* Clamp to min/max */ - if(context->dir ? (node->output < DST_RAMP__START) - : (node->output > DST_RAMP__START)) node->output=DST_RAMP__START; - if(context->dir ? (node->output > DST_RAMP__END) - : (node->output < DST_RAMP__END)) node->output=DST_RAMP__END; + if(context->dir ? (node->output[0] < DST_RAMP__START) + : (node->output[0] > DST_RAMP__START)) node->output[0]=DST_RAMP__START; + if(context->dir ? (node->output[0] > DST_RAMP__END) + : (node->output[0] < DST_RAMP__END)) node->output[0]=DST_RAMP__END; } else { context->last_en = 0; // Disabled so clamp to output - node->output=DST_RAMP__CLAMP; + node->output[0]=DST_RAMP__CLAMP; } } @@ -1361,7 +1361,7 @@ static void dst_ramp_reset(node_description *node) { struct dss_ramp_context *context = node->context; - node->output=DST_RAMP__CLAMP; + node->output[0]=DST_RAMP__CLAMP; context->step = DST_RAMP__GRAD / discrete_current_context->sample_rate; context->dir = ((DST_RAMP__END - DST_RAMP__START) == abs(DST_RAMP__END - DST_RAMP__START)); context->last_en = 0; @@ -1393,19 +1393,19 @@ static void dst_samphold_step(node_description *node) { case DISC_SAMPHOLD_REDGE: /* Clock the whole time the input is rising */ - if(DST_SAMPHOLD__CLOCK > context->lastinput) node->output=DST_SAMPHOLD__IN0; + if(DST_SAMPHOLD__CLOCK > context->lastinput) node->output[0]=DST_SAMPHOLD__IN0; break; case DISC_SAMPHOLD_FEDGE: /* Clock the whole time the input is falling */ - if(DST_SAMPHOLD__CLOCK < context->lastinput) node->output=DST_SAMPHOLD__IN0; + if(DST_SAMPHOLD__CLOCK < context->lastinput) node->output[0]=DST_SAMPHOLD__IN0; break; case DISC_SAMPHOLD_HLATCH: /* Output follows input if clock != 0 */ - if(DST_SAMPHOLD__CLOCK) node->output=DST_SAMPHOLD__IN0; + if(DST_SAMPHOLD__CLOCK) node->output[0]=DST_SAMPHOLD__IN0; break; case DISC_SAMPHOLD_LLATCH: /* Output follows input if clock == 0 */ - if(DST_SAMPHOLD__CLOCK==0) node->output=DST_SAMPHOLD__IN0; + if(DST_SAMPHOLD__CLOCK==0) node->output[0]=DST_SAMPHOLD__IN0; break; default: discrete_log("dst_samphold_step - Invalid clocktype passed"); @@ -1414,7 +1414,7 @@ static void dst_samphold_step(node_description *node) } else { - node->output=0; + node->output[0]=0; } /* Save the last value */ context->lastinput=DST_SAMPHOLD__CLOCK; @@ -1424,7 +1424,7 @@ static void dst_samphold_reset(node_description *node) { struct dst_samphold_context *context = node->context; - node->output=0; + node->output[0]=0; context->lastinput=-1; /* Only stored in here to speed up and save casting in the step function */ context->clocktype=(int)DST_SAMPHOLD__TYPE; @@ -1451,11 +1451,11 @@ static void dst_switch_step(node_description *node) { if(DSS_SWITCH__ENABLE) { - node->output=DSS_SWITCH__SWITCH ? DSS_SWITCH__IN1 : DSS_SWITCH__IN0; + node->output[0]=DSS_SWITCH__SWITCH ? DSS_SWITCH__IN1 : DSS_SWITCH__IN0; } else { - node->output=0; + node->output[0]=0; } } @@ -1479,11 +1479,11 @@ static void dst_aswitch_step(node_description *node) { if(DSS_SWITCH__ENABLE) { - node->output=DSS_ASWITCH__CTRL > DSS_ASWITCH__THRESHOLD ? DSS_ASWITCH__IN : 0; + node->output[0]=DSS_ASWITCH__CTRL > DSS_ASWITCH__THRESHOLD ? DSS_ASWITCH__IN : 0; } else { - node->output=0; + node->output[0]=0; } } @@ -1533,7 +1533,7 @@ static void dst_transform_step(node_description *node) int trans_stack_ptr=0; const char *fPTR = node->custom; - node->output=0; + node->output[0]=0; while(*fPTR!=0) { @@ -1631,15 +1631,15 @@ static void dst_transform_step(node_description *node) break; default: discrete_log("dst_transform_step - Invalid function type/variable passed"); - node->output = 0; + node->output[0] = 0; break; } } - node->output=dst_transform_pop(trans_stack,&trans_stack_ptr); + node->output[0]=dst_transform_pop(trans_stack,&trans_stack_ptr); } else { - node->output=0; + node->output[0]=0; } } @@ -1701,23 +1701,23 @@ static void dst_op_amp_step(node_description *node) else /* linear charge */ context->vCap += i / context->exponent; - node->output = context->vCap; + node->output[0] = context->vCap; } else - node->output = i * info->r4; + node->output[0] = i * info->r4; /* clamp output */ - if (node->output > context->vMax) node->output = context->vMax; - else if (node->output < info->vN) node->output = info->vN; - context->vCap = node->output; + if (node->output[0] > context->vMax) node->output[0] = context->vMax; + else if (node->output[0] < info->vN) node->output[0] = info->vN; + context->vCap = node->output[0]; break; default: - node->output = 0; + node->output[0] = 0; } } else - node->output = 0; + node->output[0] = 0; } static void dst_op_amp_reset(node_description *node) @@ -1774,7 +1774,7 @@ static void dst_op_amp_1sht_step(node_description *node) /* update trigger circuit */ iPos = (DST_OP_AMP_1SHT__TRIGGER - context->vCap2) / info->r2; - iPos += node->output / info->r5; + iPos += node->output[0] / info->r5; context->vCap2 += (DST_OP_AMP_1SHT__TRIGGER - context->vCap2) * context->exponent2; /* calculate currents and output */ @@ -1782,13 +1782,13 @@ static void dst_op_amp_1sht_step(node_description *node) if (iNeg < 0) iNeg = 0; iNeg += context->iFixed; - if (iPos > iNeg) node->output = context->vMax; - else node->output = info->vN; + if (iPos > iNeg) node->output[0] = context->vMax; + else node->output[0] = info->vN; /* update c1 */ /* rough value of voltage at anode of diode if discharging */ - v = node->output + 0.6; - if (context->vCap1 > node->output) + v = node->output[0] + 0.6; + if (context->vCap1 > node->output[0]) { /* discharge */ if (context->vCap1 > v) @@ -1796,11 +1796,11 @@ static void dst_op_amp_1sht_step(node_description *node) context->vCap1 = v; else /* discharge through r4 */ - context->vCap1 += (node->output - context->vCap1) * context->exponent1d; + context->vCap1 += (node->output[0] - context->vCap1) * context->exponent1d; } else /* charge */ - context->vCap1 += ((node->output - OP_AMP_NORTON_VBE) * context->r34ratio + OP_AMP_NORTON_VBE - context->vCap1) * context->exponent1c; + context->vCap1 += ((node->output[0] - OP_AMP_NORTON_VBE) * context->r34ratio + OP_AMP_NORTON_VBE - context->vCap1) * context->exponent1c; } static void dst_op_amp_1sht_reset(node_description *node) @@ -1916,9 +1916,9 @@ static void dst_tvca_op_amp_step(node_description *node) iOut = iPos - iNeg; if (iOut < 0) iOut = 0; /* Convert to voltage for final output. */ - node->output = iOut * info->r4; + node->output[0] = iOut * info->r4; /* Clip the output if needed. */ - if (node->output > context->vOutMax) node->output = context->vOutMax; + if (node->output[0] > context->vOutMax) node->output[0] = context->vOutMax; } static void dst_tvca_op_amp_reset(node_description *node) diff --git a/src/emu/sound/disc_wav.c b/src/emu/sound/disc_wav.c index 9721cdb041b..dd683f64aad 100644 --- a/src/emu/sound/disc_wav.c +++ b/src/emu/sound/disc_wav.c @@ -204,7 +204,7 @@ static void dss_counter_step(node_description *node) if (DSS_COUNTER__RESET) { context->count = DSS_COUNTER__INIT; - node->output = context->is_7492 ? 0 : context->count; + node->output[0] = context->is_7492 ? 0 : context->count; return; } @@ -246,7 +246,7 @@ static void dss_counter_step(node_description *node) if (context->count > max) context->count = 0; } - node->output = context->is_7492 ? disc_7492_count[context->count] : context->count; + node->output[0] = context->is_7492 ? disc_7492_count[context->count] : context->count; if (context->count != last_count) { @@ -255,16 +255,16 @@ static void dss_counter_step(node_description *node) { case DISC_OUT_IS_ENERGY: if (xTime != 0) - node->output = (context->count > last_count) ? (last_count + xTime) : (last_count - xTime); + node->output[0] = (context->count > last_count) ? (last_count + xTime) : (last_count - xTime); break; case DISC_OUT_HAS_XTIME: - node->output += xTime; + node->output[0] += xTime; break; } } } else - node->output = context->count; + node->output[0] = context->count; } static void dss_counter_reset(node_description *node) @@ -280,12 +280,12 @@ static void dss_counter_reset(node_description *node) else context->is_7492 = 0; if ((context->clock_type < DISC_CLK_ON_F_EDGE) || (context->clock_type > DISC_CLK_IS_FREQ)) - discrete_log("Invalid clock type passed in NODE_%d\n", node->node - NODE_START); + discrete_log("Invalid clock type passed in NODE_%d\n", NODE_INDEX(node->node)); context->last = 0; if (context->clock_type == DISC_CLK_IS_FREQ) context->t_clock = 1.0 / DSS_COUNTER__CLOCK; context->t_left = 0; context->count = DSS_COUNTER__INIT; /* count starts at reset value */ - node->output = DSS_COUNTER__INIT; + node->output[0] = DSS_COUNTER__INIT; } @@ -446,22 +446,22 @@ static void dss_lfsr_step(node_description *node) /* Now select the output bit */ if (context->out_is_f0) - node->output = fbresult & 0x01; + node->output[0] = fbresult & 0x01; else - node->output=((context->lfsr_reg)>>(lfsr_desc->output_bit))&0x01; + node->output[0]=((context->lfsr_reg)>>(lfsr_desc->output_bit))&0x01; /* Final inversion if required */ - if(context->invert_output) node->output=(node->output)?0.0:1.0; + if(context->invert_output) node->output[0]=(node->output[0])?0.0:1.0; /* Gain stage */ - node->output=(node->output)?(DSS_LFSR_NOISE__AMP)/2:-(DSS_LFSR_NOISE__AMP)/2; + node->output[0]=(node->output[0])?(DSS_LFSR_NOISE__AMP)/2:-(DSS_LFSR_NOISE__AMP)/2; /* Bias input as required */ - node->output=node->output+DSS_LFSR_NOISE__BIAS; + node->output[0]=node->output[0]+DSS_LFSR_NOISE__BIAS; } if(!DSS_LFSR_NOISE__ENABLE) { - node->output=0; + node->output[0]=0; } } @@ -476,7 +476,7 @@ static void dss_lfsr_reset(node_description *node) context->out_is_f0 = (lfsr_desc->flags & DISC_LFSR_FLAG_OUTPUT_F0) ? 1 : 0; if ((lfsr_desc->clock_type < DISC_CLK_ON_F_EDGE) || (lfsr_desc->clock_type > DISC_CLK_IS_FREQ)) - discrete_log("Invalid clock type passed in NODE_%d\n", node->node - NODE_START); + discrete_log("Invalid clock type passed in NODE_%d\n", NODE_INDEX(node->node)); context->last = (DSS_COUNTER__CLOCK != 0); if (lfsr_desc->clock_type == DISC_CLK_IS_FREQ) context->t_clock = 1.0 / DSS_LFSR_NOISE__CLOCK; context->t_left = 0; @@ -492,15 +492,15 @@ static void dss_lfsr_reset(node_description *node) context->lfsr_reg=dss_lfsr_function(DISC_LFSR_REPLACE,(context->lfsr_reg), fbresult<<(lfsr_desc->bitlength), ((2<<(lfsr_desc->bitlength))-1)); /* Now select and setup the output bit */ - node->output=((context->lfsr_reg)>>(lfsr_desc->output_bit))&0x01; + node->output[0]=((context->lfsr_reg)>>(lfsr_desc->output_bit))&0x01; /* Final inversion if required */ - if(lfsr_desc->flags&DISC_LFSR_FLAG_OUT_INVERT) node->output=(node->output)?0.0:1.0; + if(lfsr_desc->flags&DISC_LFSR_FLAG_OUT_INVERT) node->output[0]=(node->output[0])?0.0:1.0; /* Gain stage */ - node->output=(node->output)?(DSS_LFSR_NOISE__AMP)/2:-(DSS_LFSR_NOISE__AMP)/2; + node->output[0]=(node->output[0])?(DSS_LFSR_NOISE__AMP)/2:-(DSS_LFSR_NOISE__AMP)/2; /* Bias input as required */ - node->output=node->output+DSS_LFSR_NOISE__BIAS; + node->output[0]=node->output[0]+DSS_LFSR_NOISE__BIAS; } @@ -532,19 +532,19 @@ static void dss_noise_step(node_description *node) int newval = (mame_rand(Machine) & 0x7fff) - 16384; /* make sure the peak to peak values are the amplitude */ - node->output = DSS_NOISE__AMP / 2; + node->output[0] = DSS_NOISE__AMP / 2; if (newval > 0) - node->output *= ((double)newval / 16383); + node->output[0] *= ((double)newval / 16383); else - node->output *= ((double)newval / 16384); + node->output[0] *= ((double)newval / 16384); /* Add DC Bias component */ - node->output += DSS_NOISE__BIAS; + node->output[0] += DSS_NOISE__BIAS; } } else { - node->output = 0; + node->output[0] = 0; } /* Keep the new phasor in the 2Pi range.*/ @@ -651,7 +651,7 @@ static void dss_note_step(node_description *node) } } - node->output = context->count2; + node->output[0] = context->count2; if (context->count2 != last_count2) { /* the xTime is only output if the output changed. */ @@ -659,16 +659,16 @@ static void dss_note_step(node_description *node) { case DISC_OUT_IS_ENERGY: if (xTime != 0) - node->output = (context->count2 > last_count2) ? (last_count2 + xTime) : (last_count2 - xTime); + node->output[0] = (context->count2 > last_count2) ? (last_count2 + xTime) : (last_count2 - xTime); break; case DISC_OUT_HAS_XTIME: - node->output += xTime; + node->output[0] += xTime; break; } } } else - node->output = 0; + node->output[0] = 0; } static void dss_note_reset(node_description *node) @@ -685,7 +685,7 @@ static void dss_note_reset(node_description *node) context->count2 = 0; context->max1 = (int)DSS_NOTE__MAX1; context->max2 = (int)DSS_NOTE__MAX2; - node->output = 0; + node->output[0] = 0; } /************************************************************************ @@ -867,17 +867,17 @@ static void dss_op_amp_osc_step(node_description *node) /* squarewave to happen in the sample time causing it to be missed. */ /* If we toggle 2 states we force the missed output for 1 sample. */ /* If more then 2 states happen, there is no hope, the sample rate is just too low. */ - node->output = context->high_out_V * (context->flip_flop ? 0 : 1); + node->output[0] = context->high_out_V * (context->flip_flop ? 0 : 1); else - node->output = context->high_out_V * context->flip_flop; + node->output[0] = context->high_out_V * context->flip_flop; } else - node->output = context->vCap; + node->output[0] = context->vCap; } else { /* we will just output 0 for oscillators that have no real enable. */ - node->output = 0; + node->output[0] = 0; } } @@ -901,7 +901,7 @@ static void dss_op_amp_osc_reset(node_description *node) if IS_VALUE_A_NODE(*r_info_ptr) { r_node = discrete_find_node(NULL, *r_info_ptr); - *r_context_ptr = &(r_node->output); + *r_context_ptr = &(r_node->output[NODE_CHILD_NODE_NUM((int)*r_info_ptr)]); } else *r_context_ptr = r_info_ptr; @@ -1030,14 +1030,14 @@ static void dss_sawtoothwave_step(node_description *node) if(DSS_SAWTOOTHWAVE__ENABLE) { - node->output=(context->type==0)?context->phase*(DSS_SAWTOOTHWAVE__AMP/(2.0*M_PI)):DSS_SAWTOOTHWAVE__AMP-(context->phase*(DSS_SAWTOOTHWAVE__AMP/(2.0*M_PI))); - node->output-=DSS_SAWTOOTHWAVE__AMP/2.0; + node->output[0]=(context->type==0)?context->phase*(DSS_SAWTOOTHWAVE__AMP/(2.0*M_PI)):DSS_SAWTOOTHWAVE__AMP-(context->phase*(DSS_SAWTOOTHWAVE__AMP/(2.0*M_PI))); + node->output[0]-=DSS_SAWTOOTHWAVE__AMP/2.0; /* Add DC Bias component */ - node->output=node->output+DSS_SAWTOOTHWAVE__BIAS; + node->output[0]=node->output[0]+DSS_SAWTOOTHWAVE__BIAS; } else { - node->output=0; + node->output[0]=0; } /* Work out the phase step based on phase/freq & sample rate */ @@ -1143,19 +1143,19 @@ static void dss_schmitt_osc_step(node_description *node) switch (context->enable_type) { case DISC_SCHMITT_OSC_ENAB_IS_AND: - node->output = DSS_SCHMITT_OSC__ENABLE && context->state; + node->output[0] = DSS_SCHMITT_OSC__ENABLE && context->state; break; case DISC_SCHMITT_OSC_ENAB_IS_NAND: - node->output = !(DSS_SCHMITT_OSC__ENABLE && context->state); + node->output[0] = !(DSS_SCHMITT_OSC__ENABLE && context->state); break; case DISC_SCHMITT_OSC_ENAB_IS_OR: - node->output = DSS_SCHMITT_OSC__ENABLE || context->state; + node->output[0] = DSS_SCHMITT_OSC__ENABLE || context->state; break; case DISC_SCHMITT_OSC_ENAB_IS_NOR: - node->output = !(DSS_SCHMITT_OSC__ENABLE || context->state); + node->output[0] = !(DSS_SCHMITT_OSC__ENABLE || context->state); break; } - node->output *= DSS_SCHMITT_OSC__AMP; + node->output[0] *= DSS_SCHMITT_OSC__AMP; } static void dss_schmitt_osc_reset(node_description *node) @@ -1183,7 +1183,7 @@ static void dss_schmitt_osc_reset(node_description *node) context->vCap = 0; context->state = 1; - node->output = info->options ? 0 : DSS_SCHMITT_OSC__AMP; + node->output[0] = info->options ? 0 : DSS_SCHMITT_OSC__AMP; } @@ -1211,13 +1211,13 @@ static void dss_sinewave_step(node_description *node) /* Set the output */ if(DSS_SINEWAVE__ENABLE) { - node->output=(DSS_SINEWAVE__AMPL/2.0) * sin(context->phase); + node->output[0]=(DSS_SINEWAVE__AMPL/2.0) * sin(context->phase); /* Add DC Bias component */ - node->output=node->output+DSS_SINEWAVE__BIAS; + node->output[0]=node->output[0]+DSS_SINEWAVE__BIAS; } else { - node->output=0; + node->output[0]=0; } /* Work out the phase step based on phase/freq & sample rate */ @@ -1274,16 +1274,16 @@ static void dss_squarewave_step(node_description *node) if(DSS_SQUAREWAVE__ENABLE) { if(context->phase>context->trigger) - node->output=(DSS_SQUAREWAVE__AMP/2.0); + node->output[0]=(DSS_SQUAREWAVE__AMP/2.0); else - node->output=-(DSS_SQUAREWAVE__AMP/2.0); + node->output[0]=-(DSS_SQUAREWAVE__AMP/2.0); /* Add DC Bias component */ - node->output=node->output+DSS_SQUAREWAVE__BIAS; + node->output[0]=node->output[0]+DSS_SQUAREWAVE__BIAS; } else { - node->output=0; + node->output[0]=0; } /* Work out the phase step based on phase/freq & sample rate */ @@ -1350,11 +1350,11 @@ static void dss_squarewfix_step(node_description *node) context->tOn = context->tOff * (DSS_SQUAREWFIX__DUTY / 100.0); context->tOff -= context->tOn; - node->output = (context->flip_flop ? DSS_SQUAREWFIX__AMP / 2.0 : -(DSS_SQUAREWFIX__AMP / 2.0)) + DSS_SQUAREWFIX__BIAS; + node->output[0] = (context->flip_flop ? DSS_SQUAREWFIX__AMP / 2.0 : -(DSS_SQUAREWFIX__AMP / 2.0)) + DSS_SQUAREWFIX__BIAS; } else { - node->output=0; + node->output[0]=0; } } @@ -1429,16 +1429,16 @@ static void dss_squarewave2_step(node_description *node) context->phase = fmod(newphase, 2.0 * M_PI); if(context->phase>context->trigger) - node->output=(DSS_SQUAREWAVE2__AMP/2.0); + node->output[0]=(DSS_SQUAREWAVE2__AMP/2.0); else - node->output=-(DSS_SQUAREWAVE2__AMP/2.0); + node->output[0]=-(DSS_SQUAREWAVE2__AMP/2.0); /* Add DC Bias component */ - node->output = node->output + DSS_SQUAREWAVE2__BIAS; + node->output[0] = node->output[0] + DSS_SQUAREWAVE2__BIAS; } else { - node->output=0; + node->output[0]=0; } } @@ -1589,11 +1589,11 @@ static void dss_inverter_osc_step(node_description *node) context->vCap += diff; context->vG2_old = vG2; if ((info->options & DISC_OSC_INVERTER_TYPE_MASK)==DISC_OSC_INVERTER_IS_TYPE3) - node->output = vG1; + node->output[0] = vG1; else - node->output = vG3; + node->output[0] = vG3; if (info->options & DISC_OSC_INVERTER_OUT_IS_LOGIC) - node->output = (node->output > info->vInFall); + node->output[0] = (node->output[0] > info->vInFall); } static void dss_inverter_osc_reset(node_description *node) @@ -1604,7 +1604,7 @@ static void dss_inverter_osc_reset(node_description *node) /* exponent */ context->w = -1.0 / (DSS_INVERTER_OSC__RC * DSS_INVERTER_OSC__C); context->wc = -1.0 / ((DSS_INVERTER_OSC__RC * DSS_INVERTER_OSC__RP) / (DSS_INVERTER_OSC__RP + DSS_INVERTER_OSC__RC) * DSS_INVERTER_OSC__C); - node->output = 0; + node->output[0] = 0; context->vCap = 0; context->vG2_old = 0; context->Rp = DSS_INVERTER_OSC__RP; @@ -1639,15 +1639,15 @@ static void dss_trianglewave_step(node_description *node) if(DSS_TRIANGLEWAVE__ENABLE) { - node->output=context->phase < M_PI ? (DSS_TRIANGLEWAVE__AMP * (context->phase / (M_PI/2.0) - 1.0))/2.0 : + node->output[0]=context->phase < M_PI ? (DSS_TRIANGLEWAVE__AMP * (context->phase / (M_PI/2.0) - 1.0))/2.0 : (DSS_TRIANGLEWAVE__AMP * (3.0 - context->phase / (M_PI/2.0)))/2.0 ; /* Add DC Bias component */ - node->output=node->output+DSS_TRIANGLEWAVE__BIAS; + node->output[0]=node->output[0]+DSS_TRIANGLEWAVE__BIAS; } else { - node->output=0; + node->output[0]=0; } /* Work out the phase step based on phase/freq & sample rate */ @@ -1692,11 +1692,11 @@ static void dss_adsrenv_step(node_description *node) if(DSS_ADSR__ENABLE) { - node->output=0; + node->output[0]=0; } else { - node->output=0; + node->output[0]=0; } } diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index a5dbbf600e6..6cd59e96eea 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -163,105 +163,105 @@ static void CLIB_DECL ATTR_PRINTF(1,2) discrete_log(const char *text, ...) static const discrete_module module_list[] = { - { DSO_OUTPUT ,"DSO_OUTPUT" ,0 ,NULL ,NULL }, - { DSO_CSVLOG ,"DSO_CSVLOG" ,0 ,NULL ,NULL }, - { DSO_WAVELOG ,"DSO_WAVELOG" ,0 ,NULL ,NULL }, + { DSO_OUTPUT ,"DSO_OUTPUT" , 0 ,0 ,NULL ,NULL }, + { DSO_CSVLOG ,"DSO_CSVLOG" , 0 ,0 ,NULL ,NULL }, + { DSO_WAVELOG ,"DSO_WAVELOG" , 0 ,0 ,NULL ,NULL }, /* from disc_inp.c */ - { DSS_ADJUSTMENT ,"DSS_ADJUSTMENT" ,sizeof(struct dss_adjustment_context) ,dss_adjustment_reset ,dss_adjustment_step }, - { DSS_CONSTANT ,"DSS_CONSTANT" ,0 ,NULL ,dss_constant_step }, - { DSS_INPUT_DATA ,"DSS_INPUT_DATA" ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, - { DSS_INPUT_LOGIC ,"DSS_INPUT_LOGIC" ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, - { DSS_INPUT_NOT ,"DSS_INPUT_NOT" ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, - { DSS_INPUT_PULSE ,"DSS_INPUT_PULSE" ,sizeof(UINT8) ,dss_input_reset ,dss_input_pulse_step }, - { DSS_INPUT_STREAM,"DSS_INPUT_STREAM",0 ,dss_input_stream_reset,dss_input_stream_step}, + { DSS_ADJUSTMENT ,"DSS_ADJUSTMENT" , 1 ,sizeof(struct dss_adjustment_context) ,dss_adjustment_reset ,dss_adjustment_step }, + { DSS_CONSTANT ,"DSS_CONSTANT" , 1 ,0 ,NULL ,dss_constant_step }, + { DSS_INPUT_DATA ,"DSS_INPUT_DATA" , 1 ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, + { DSS_INPUT_LOGIC ,"DSS_INPUT_LOGIC" , 1 ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, + { DSS_INPUT_NOT ,"DSS_INPUT_NOT" , 1 ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, + { DSS_INPUT_PULSE ,"DSS_INPUT_PULSE" , 1 ,sizeof(UINT8) ,dss_input_reset ,dss_input_pulse_step }, + { DSS_INPUT_STREAM,"DSS_INPUT_STREAM", 1 ,0 ,dss_input_stream_reset,dss_input_stream_step}, /* from disc_wav.c */ /* Generic modules */ - { DSS_COUNTER ,"DSS_COUNTER" ,sizeof(struct dss_counter_context) ,dss_counter_reset ,dss_counter_step }, - { DSS_LFSR_NOISE ,"DSS_LFSR_NOISE" ,sizeof(struct dss_lfsr_context) ,dss_lfsr_reset ,dss_lfsr_step }, - { DSS_NOISE ,"DSS_NOISE" ,sizeof(struct dss_noise_context) ,dss_noise_reset ,dss_noise_step }, - { DSS_NOTE ,"DSS_NOTE" ,sizeof(struct dss_note_context) ,dss_note_reset ,dss_note_step }, - { DSS_SAWTOOTHWAVE,"DSS_SAWTOOTHWAVE",sizeof(struct dss_sawtoothwave_context),dss_sawtoothwave_reset,dss_sawtoothwave_step}, - { DSS_SINEWAVE ,"DSS_SINEWAVE" ,sizeof(struct dss_sinewave_context) ,dss_sinewave_reset ,dss_sinewave_step }, - { DSS_SQUAREWAVE ,"DSS_SQUAREWAVE" ,sizeof(struct dss_squarewave_context) ,dss_squarewave_reset ,dss_squarewave_step }, - { DSS_SQUAREWFIX ,"DSS_SQUAREWFIX" ,sizeof(struct dss_squarewfix_context) ,dss_squarewfix_reset ,dss_squarewfix_step }, - { DSS_SQUAREWAVE2 ,"DSS_SQUAREWAVE2" ,sizeof(struct dss_squarewave_context) ,dss_squarewave2_reset ,dss_squarewave2_step }, - { DSS_TRIANGLEWAVE,"DSS_TRIANGLEWAVE",sizeof(struct dss_trianglewave_context),dss_trianglewave_reset,dss_trianglewave_step}, + { DSS_COUNTER ,"DSS_COUNTER" , 1 ,sizeof(struct dss_counter_context) ,dss_counter_reset ,dss_counter_step }, + { DSS_LFSR_NOISE ,"DSS_LFSR_NOISE" , 1 ,sizeof(struct dss_lfsr_context) ,dss_lfsr_reset ,dss_lfsr_step }, + { DSS_NOISE ,"DSS_NOISE" , 1 ,sizeof(struct dss_noise_context) ,dss_noise_reset ,dss_noise_step }, + { DSS_NOTE ,"DSS_NOTE" , 1 ,sizeof(struct dss_note_context) ,dss_note_reset ,dss_note_step }, + { DSS_SAWTOOTHWAVE,"DSS_SAWTOOTHWAVE", 1 ,sizeof(struct dss_sawtoothwave_context),dss_sawtoothwave_reset,dss_sawtoothwave_step}, + { DSS_SINEWAVE ,"DSS_SINEWAVE" , 1 ,sizeof(struct dss_sinewave_context) ,dss_sinewave_reset ,dss_sinewave_step }, + { DSS_SQUAREWAVE ,"DSS_SQUAREWAVE" , 1 ,sizeof(struct dss_squarewave_context) ,dss_squarewave_reset ,dss_squarewave_step }, + { DSS_SQUAREWFIX ,"DSS_SQUAREWFIX" , 1 ,sizeof(struct dss_squarewfix_context) ,dss_squarewfix_reset ,dss_squarewfix_step }, + { DSS_SQUAREWAVE2 ,"DSS_SQUAREWAVE2" , 1 ,sizeof(struct dss_squarewave_context) ,dss_squarewave2_reset ,dss_squarewave2_step }, + { DSS_TRIANGLEWAVE,"DSS_TRIANGLEWAVE", 1 ,sizeof(struct dss_trianglewave_context),dss_trianglewave_reset,dss_trianglewave_step}, /* Component specific modules */ - { DSS_INVERTER_OSC ,"DSS_INVERTER_OSC" ,sizeof(struct dss_inverter_osc_context) ,dss_inverter_osc_reset ,dss_inverter_osc_step }, - { DSS_OP_AMP_OSC ,"DSS_OP_AMP_OSC" ,sizeof(struct dss_op_amp_osc_context) ,dss_op_amp_osc_reset ,dss_op_amp_osc_step }, - { DSS_SCHMITT_OSC ,"DSS_SCHMITT_OSC" ,sizeof(struct dss_schmitt_osc_context) ,dss_schmitt_osc_reset ,dss_schmitt_osc_step }, + { DSS_INVERTER_OSC ,"DSS_INVERTER_OSC" , 1 ,sizeof(struct dss_inverter_osc_context) ,dss_inverter_osc_reset ,dss_inverter_osc_step }, + { DSS_OP_AMP_OSC ,"DSS_OP_AMP_OSC" , 1 ,sizeof(struct dss_op_amp_osc_context) ,dss_op_amp_osc_reset ,dss_op_amp_osc_step }, + { DSS_SCHMITT_OSC ,"DSS_SCHMITT_OSC" , 1 ,sizeof(struct dss_schmitt_osc_context) ,dss_schmitt_osc_reset ,dss_schmitt_osc_step }, /* Not yet implemented */ - { DSS_ADSR ,"DSS_ADSR" ,sizeof(struct dss_adsr_context) ,dss_adsrenv_reset ,dss_adsrenv_step }, + { DSS_ADSR ,"DSS_ADSR" , 1 ,sizeof(struct dss_adsr_context) ,dss_adsrenv_reset ,dss_adsrenv_step }, /* from disc_mth.c */ /* Generic modules */ - { DST_ADDER ,"DST_ADDER" ,0 ,NULL ,dst_adder_step }, - { DST_CLAMP ,"DST_CLAMP" ,0 ,NULL ,dst_clamp_step }, - { DST_DIVIDE ,"DST_DIVIDE" ,0 ,NULL ,dst_divide_step }, - { DST_GAIN ,"DST_GAIN" ,0 ,NULL ,dst_gain_step }, - { DST_LOGIC_INV ,"DST_LOGIC_INV" ,0 ,NULL ,dst_logic_inv_step }, - { DST_LOGIC_AND ,"DST_LOGIC_AND" ,0 ,NULL ,dst_logic_and_step }, - { DST_LOGIC_NAND ,"DST_LOGIC_NAND" ,0 ,NULL ,dst_logic_nand_step }, - { DST_LOGIC_OR ,"DST_LOGIC_OR" ,0 ,NULL ,dst_logic_or_step }, - { DST_LOGIC_NOR ,"DST_LOGIC_NOR" ,0 ,NULL ,dst_logic_nor_step }, - { DST_LOGIC_XOR ,"DST_LOGIC_XOR" ,0 ,NULL ,dst_logic_xor_step }, - { DST_LOGIC_NXOR ,"DST_LOGIC_NXOR" ,0 ,NULL ,dst_logic_nxor_step }, - { DST_LOGIC_DFF ,"DST_LOGIC_DFF" ,sizeof(struct dst_flipflop_context) ,dst_logic_ff_reset ,dst_logic_dff_step }, - { DST_LOGIC_JKFF ,"DST_LOGIC_JKFF" ,sizeof(struct dst_flipflop_context) ,dst_logic_ff_reset ,dst_logic_jkff_step }, - { DST_LOOKUP_TABLE,"DST_LOOKUP_TABLE",0 ,NULL ,dst_lookup_table_step}, - { DST_MULTIPLEX ,"DST_MULTIPLEX" ,sizeof(struct dst_size_context) ,dst_multiplex_reset ,dst_multiplex_step }, - { DST_ONESHOT ,"DST_ONESHOT" ,sizeof(struct dst_oneshot_context) ,dst_oneshot_reset ,dst_oneshot_step }, - { DST_RAMP ,"DST_RAMP" ,sizeof(struct dss_ramp_context) ,dst_ramp_reset ,dst_ramp_step }, - { DST_SAMPHOLD ,"DST_SAMPHOLD" ,sizeof(struct dst_samphold_context) ,dst_samphold_reset ,dst_samphold_step }, - { DST_SWITCH ,"DST_SWITCH" ,0 ,NULL ,dst_switch_step }, - { DST_ASWITCH ,"DST_ASWITCH" ,0 ,NULL ,dst_aswitch_step }, - { DST_TRANSFORM ,"DST_TRANSFORM" ,0 ,NULL ,dst_transform_step }, + { DST_ADDER ,"DST_ADDER" , 1 ,0 ,NULL ,dst_adder_step }, + { DST_CLAMP ,"DST_CLAMP" , 1 ,0 ,NULL ,dst_clamp_step }, + { DST_DIVIDE ,"DST_DIVIDE" , 1 ,0 ,NULL ,dst_divide_step }, + { DST_GAIN ,"DST_GAIN" , 1 ,0 ,NULL ,dst_gain_step }, + { DST_LOGIC_INV ,"DST_LOGIC_INV" , 1 ,0 ,NULL ,dst_logic_inv_step }, + { DST_LOGIC_AND ,"DST_LOGIC_AND" , 1 ,0 ,NULL ,dst_logic_and_step }, + { DST_LOGIC_NAND ,"DST_LOGIC_NAND" , 1 ,0 ,NULL ,dst_logic_nand_step }, + { DST_LOGIC_OR ,"DST_LOGIC_OR" , 1 ,0 ,NULL ,dst_logic_or_step }, + { DST_LOGIC_NOR ,"DST_LOGIC_NOR" , 1 ,0 ,NULL ,dst_logic_nor_step }, + { DST_LOGIC_XOR ,"DST_LOGIC_XOR" , 1 ,0 ,NULL ,dst_logic_xor_step }, + { DST_LOGIC_NXOR ,"DST_LOGIC_NXOR" , 1 ,0 ,NULL ,dst_logic_nxor_step }, + { DST_LOGIC_DFF ,"DST_LOGIC_DFF" , 1 ,sizeof(struct dst_flipflop_context) ,dst_logic_ff_reset ,dst_logic_dff_step }, + { DST_LOGIC_JKFF ,"DST_LOGIC_JKFF" , 1 ,sizeof(struct dst_flipflop_context) ,dst_logic_ff_reset ,dst_logic_jkff_step }, + { DST_LOOKUP_TABLE,"DST_LOOKUP_TABLE", 1 ,0 ,NULL ,dst_lookup_table_step}, + { DST_MULTIPLEX ,"DST_MULTIPLEX" , 1 ,sizeof(struct dst_size_context) ,dst_multiplex_reset ,dst_multiplex_step }, + { DST_ONESHOT ,"DST_ONESHOT" , 1 ,sizeof(struct dst_oneshot_context) ,dst_oneshot_reset ,dst_oneshot_step }, + { DST_RAMP ,"DST_RAMP" , 1 ,sizeof(struct dss_ramp_context) ,dst_ramp_reset ,dst_ramp_step }, + { DST_SAMPHOLD ,"DST_SAMPHOLD" , 1 ,sizeof(struct dst_samphold_context) ,dst_samphold_reset ,dst_samphold_step }, + { DST_SWITCH ,"DST_SWITCH" , 1 ,0 ,NULL ,dst_switch_step }, + { DST_ASWITCH ,"DST_ASWITCH" , 1 ,0 ,NULL ,dst_aswitch_step }, + { DST_TRANSFORM ,"DST_TRANSFORM" , 1 ,0 ,NULL ,dst_transform_step }, /* Component specific */ - { DST_COMP_ADDER ,"DST_COMP_ADDER" ,0 ,NULL ,dst_comp_adder_step }, - { DST_DAC_R1 ,"DST_DAC_R1" ,sizeof(struct dst_dac_r1_context) ,dst_dac_r1_reset ,dst_dac_r1_step }, - { DST_DIODE_MIX ,"DST_DIODE_MIX" ,sizeof(struct dst_size_context) ,dst_diode_mix_reset ,dst_diode_mix_step }, - { DST_INTEGRATE ,"DST_INTEGRATE" ,sizeof(struct dst_integrate_context) ,dst_integrate_reset ,dst_integrate_step }, - { DST_MIXER ,"DST_MIXER" ,sizeof(struct dst_mixer_context) ,dst_mixer_reset ,dst_mixer_step }, - { DST_OP_AMP ,"DST_OP_AMP" ,sizeof(struct dst_op_amp_context) ,dst_op_amp_reset ,dst_op_amp_step }, - { DST_OP_AMP_1SHT ,"DST_OP_AMP_1SHT" ,sizeof(struct dst_op_amp_1sht_context) ,dst_op_amp_1sht_reset ,dst_op_amp_1sht_step }, - { DST_TVCA_OP_AMP ,"DST_TVCA_OP_AMP" ,sizeof(struct dst_tvca_op_amp_context) ,dst_tvca_op_amp_reset ,dst_tvca_op_amp_step }, - { DST_VCA ,"DST_VCA" ,0 ,NULL ,NULL }, + { DST_COMP_ADDER ,"DST_COMP_ADDER" , 1 ,0 ,NULL ,dst_comp_adder_step }, + { DST_DAC_R1 ,"DST_DAC_R1" , 1 ,sizeof(struct dst_dac_r1_context) ,dst_dac_r1_reset ,dst_dac_r1_step }, + { DST_DIODE_MIX ,"DST_DIODE_MIX" , 1 ,sizeof(struct dst_size_context) ,dst_diode_mix_reset ,dst_diode_mix_step }, + { DST_INTEGRATE ,"DST_INTEGRATE" , 1 ,sizeof(struct dst_integrate_context) ,dst_integrate_reset ,dst_integrate_step }, + { DST_MIXER ,"DST_MIXER" , 1 ,sizeof(struct dst_mixer_context) ,dst_mixer_reset ,dst_mixer_step }, + { DST_OP_AMP ,"DST_OP_AMP" , 1 ,sizeof(struct dst_op_amp_context) ,dst_op_amp_reset ,dst_op_amp_step }, + { DST_OP_AMP_1SHT ,"DST_OP_AMP_1SHT" , 1 ,sizeof(struct dst_op_amp_1sht_context) ,dst_op_amp_1sht_reset ,dst_op_amp_1sht_step }, + { DST_TVCA_OP_AMP ,"DST_TVCA_OP_AMP" , 1 ,sizeof(struct dst_tvca_op_amp_context) ,dst_tvca_op_amp_reset ,dst_tvca_op_amp_step }, + { DST_VCA ,"DST_VCA" , 1 ,0 ,NULL ,NULL }, /* from disc_flt.c */ /* Generic modules */ - { DST_FILTER1 ,"DST_FILTER1" ,sizeof(struct dss_filter1_context) ,dst_filter1_reset ,dst_filter1_step }, - { DST_FILTER2 ,"DST_FILTER2" ,sizeof(struct dss_filter2_context) ,dst_filter2_reset ,dst_filter2_step }, + { DST_FILTER1 ,"DST_FILTER1" , 1 ,sizeof(struct dss_filter1_context) ,dst_filter1_reset ,dst_filter1_step }, + { DST_FILTER2 ,"DST_FILTER2" , 1 ,sizeof(struct dss_filter2_context) ,dst_filter2_reset ,dst_filter2_step }, /* Component specific modules */ - { DST_CRFILTER ,"DST_CRFILTER" ,sizeof(struct dst_rcfilter_context) ,dst_crfilter_reset ,dst_crfilter_step }, - { DST_OP_AMP_FILT ,"DST_OP_AMP_FILT" ,sizeof(struct dst_op_amp_filt_context) ,dst_op_amp_filt_reset ,dst_op_amp_filt_step }, - { DST_RCDISC ,"DST_RCDISC" ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc_reset ,dst_rcdisc_step }, - { DST_RCDISC2 ,"DST_RCDISC2" ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc2_reset ,dst_rcdisc2_step }, - { DST_RCDISC3 ,"DST_RCDISC3" ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc3_reset ,dst_rcdisc3_step }, - { DST_RCDISC4 ,"DST_RCDISC4" ,sizeof(struct dst_rcdisc4_context) ,dst_rcdisc4_reset ,dst_rcdisc4_step }, - { DST_RCDISC5 ,"DST_RCDISC5" ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc5_reset ,dst_rcdisc5_step }, - { DST_RCINTEGRATE ,"DST_RCINTEGRATE" ,sizeof(struct dst_rcdisc_context) ,dst_rcintegrate_reset ,dst_rcintegrate_step }, - { DST_RCDISC_MOD ,"DST_RCDISC_MOD" ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc_mod_reset ,dst_rcdisc_mod_step }, - { DST_RCFILTER ,"DST_RCFILTER" ,sizeof(struct dst_rcfilter_context) ,dst_rcfilter_reset ,dst_rcfilter_step }, - { DST_RCFILTER_SW ,"DST_RCFILTER_SW" ,sizeof(struct dst_rcfilter_sw_context) ,dst_rcfilter_sw_reset ,dst_rcfilter_sw_step }, + { DST_CRFILTER ,"DST_CRFILTER" , 1 ,sizeof(struct dst_rcfilter_context) ,dst_crfilter_reset ,dst_crfilter_step }, + { DST_OP_AMP_FILT ,"DST_OP_AMP_FILT" , 1 ,sizeof(struct dst_op_amp_filt_context) ,dst_op_amp_filt_reset ,dst_op_amp_filt_step }, + { DST_RCDISC ,"DST_RCDISC" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc_reset ,dst_rcdisc_step }, + { DST_RCDISC2 ,"DST_RCDISC2" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc2_reset ,dst_rcdisc2_step }, + { DST_RCDISC3 ,"DST_RCDISC3" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc3_reset ,dst_rcdisc3_step }, + { DST_RCDISC4 ,"DST_RCDISC4" , 1 ,sizeof(struct dst_rcdisc4_context) ,dst_rcdisc4_reset ,dst_rcdisc4_step }, + { DST_RCDISC5 ,"DST_RCDISC5" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc5_reset ,dst_rcdisc5_step }, + { DST_RCINTEGRATE ,"DST_RCINTEGRATE" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcintegrate_reset ,dst_rcintegrate_step }, + { DST_RCDISC_MOD ,"DST_RCDISC_MOD" , 1 ,sizeof(struct dst_rcdisc_context) ,dst_rcdisc_mod_reset ,dst_rcdisc_mod_step }, + { DST_RCFILTER ,"DST_RCFILTER" , 1 ,sizeof(struct dst_rcfilter_context) ,dst_rcfilter_reset ,dst_rcfilter_step }, + { DST_RCFILTER_SW ,"DST_RCFILTER_SW" , 1 ,sizeof(struct dst_rcfilter_sw_context) ,dst_rcfilter_sw_reset ,dst_rcfilter_sw_step }, /* For testing - seem to be buggered. Use versions not ending in N. */ - { DST_RCFILTERN ,"DST_RCFILTERN" ,sizeof(struct dss_filter1_context) ,dst_rcfilterN_reset ,dst_filter1_step }, - { DST_RCDISCN ,"DST_RCDISCN" ,sizeof(struct dss_filter1_context) ,dst_rcdiscN_reset ,dst_rcdiscN_step }, - { DST_RCDISC2N ,"DST_RCDISC2N" ,sizeof(struct dss_rcdisc2_context) ,dst_rcdisc2N_reset ,dst_rcdisc2N_step }, + { DST_RCFILTERN ,"DST_RCFILTERN" , 1 ,sizeof(struct dss_filter1_context) ,dst_rcfilterN_reset ,dst_filter1_step }, + { DST_RCDISCN ,"DST_RCDISCN" , 1 ,sizeof(struct dss_filter1_context) ,dst_rcdiscN_reset ,dst_rcdiscN_step }, + { DST_RCDISC2N ,"DST_RCDISC2N" , 1 ,sizeof(struct dss_rcdisc2_context) ,dst_rcdisc2N_reset ,dst_rcdisc2N_step }, /* from disc_dev.c */ /* generic modules */ - { DST_CUSTOM ,"DST_CUSTOM" ,0 ,NULL ,NULL }, + { DST_CUSTOM ,"DST_CUSTOM" , 1 ,0 ,NULL ,NULL }, /* Component specific modules */ - { DSD_555_ASTBL ,"DSD_555_ASTBL" ,sizeof(struct dsd_555_astbl_context) ,dsd_555_astbl_reset ,dsd_555_astbl_step }, - { DSD_555_MSTBL ,"DSD_555_MSTBL" ,sizeof(struct dsd_555_mstbl_context) ,dsd_555_mstbl_reset ,dsd_555_mstbl_step }, - { DSD_555_CC ,"DSD_555_CC" ,sizeof(struct dsd_555_cc_context) ,dsd_555_cc_reset ,dsd_555_cc_step }, - { DSD_555_VCO1 ,"DSD_555_VCO1" ,sizeof(struct dsd_555_vco1_context) ,dsd_555_vco1_reset ,dsd_555_vco1_step }, - { DSD_566 ,"DSD_566" ,sizeof(struct dsd_566_context) ,dsd_566_reset ,dsd_566_step }, - { DSD_LS624 ,"DSD_LS624" ,sizeof(struct dsd_ls624_context) ,dsd_ls624_reset ,dsd_ls624_step }, + { DSD_555_ASTBL ,"DSD_555_ASTBL" , 1 ,sizeof(struct dsd_555_astbl_context) ,dsd_555_astbl_reset ,dsd_555_astbl_step }, + { DSD_555_MSTBL ,"DSD_555_MSTBL" , 1 ,sizeof(struct dsd_555_mstbl_context) ,dsd_555_mstbl_reset ,dsd_555_mstbl_step }, + { DSD_555_CC ,"DSD_555_CC" , 1 ,sizeof(struct dsd_555_cc_context) ,dsd_555_cc_reset ,dsd_555_cc_step }, + { DSD_555_VCO1 ,"DSD_555_VCO1" , 1 ,sizeof(struct dsd_555_vco1_context) ,dsd_555_vco1_reset ,dsd_555_vco1_step }, + { DSD_566 ,"DSD_566" , 1 ,sizeof(struct dsd_566_context) ,dsd_566_reset ,dsd_566_step }, + { DSD_LS624 ,"DSD_LS624" , 1 ,sizeof(struct dsd_ls624_context) ,dsd_ls624_reset ,dsd_ls624_step }, /* must be the last one */ - { DSS_NULL ,"DSS_NULL" ,0 ,NULL ,NULL } + { DSS_NULL ,"DSS_NULL" , 0 ,0 ,NULL ,NULL } }; @@ -276,7 +276,7 @@ node_description *discrete_find_node(void *chip, int node) { discrete_info *info = chip ? chip : discrete_current_context; if (node < NODE_START || node > NODE_END) return NULL; - return info->indexed_node[node - NODE_START]; + return info->indexed_node[NODE_INDEX(node)]; } @@ -324,7 +324,13 @@ static void *discrete_start(int sndindex, int clock, const void *config) /* make sure the node type is valid */ if (intf[info->node_count].type > DSO_OUTPUT) - fatalerror("discrete_start() - Invalid function type on NODE_%02d", intf[info->node_count].node - NODE_START); + fatalerror("discrete_start() - Invalid function type on NODE_%02d", NODE_INDEX(intf[info->node_count].node) ); + + /* make sure this is a main node */ + if (NODE_CHILD_NODE_NUM(intf[info->node_count].node) > 0) + fatalerror("discrete_start() - Child node number on NODE_%02d", NODE_INDEX(intf[info->node_count].node) ); + + } info->node_count++; discrete_log("discrete_start() - Sanity check counted %d nodes", info->node_count); @@ -409,7 +415,7 @@ static void discrete_reset(void *chip) { node_description *node = info->running_order[nodenum]; - node->output = 0; + node->output[0] = 0; /* if the node has a reset function, call it */ if (node->module.reset) @@ -571,9 +577,9 @@ static void init_nodes(discrete_info *info, discrete_sound_block *block_list) /* otherwise, make sure we are not a duplicate, and put ourselves into the indexed list */ else { - if (info->indexed_node[block->node - NODE_START]) - fatalerror("init_nodes() - Duplicate entries for NODE_%02d", block->node - NODE_START); - info->indexed_node[block->node - NODE_START] = node; + if (info->indexed_node[NODE_INDEX(block->node)]) + fatalerror("init_nodes() - Duplicate entries for NODE_%02d", NODE_INDEX(block->node)); + info->indexed_node[NODE_INDEX(block->node)] = node; } /* find the requested module */ @@ -581,12 +587,12 @@ static void init_nodes(discrete_info *info, discrete_sound_block *block_list) if (module_list[modulenum].type == block->type) break; if (module_list[modulenum].type != block->type) - fatalerror("init_nodes() - Unable to find discrete module type %d for NODE_%02d", block->type, block->node - NODE_START); + fatalerror("init_nodes() - Unable to find discrete module type %d for NODE_%02d", block->type, NODE_INDEX(block->node)); /* static inits */ node->node = block->node; node->module = module_list[modulenum]; - node->output = 0.0; + node->output[0] = 0.0; node->block = block; node->active_inputs = block->active_inputs; @@ -659,11 +665,14 @@ static void find_input_nodes(discrete_info *info, discrete_sound_block *block_li /* if this input is node-based, find the node in the indexed list */ if IS_VALUE_A_NODE(inputnode) { - node_description *node_ref = info->indexed_node[inputnode - NODE_START]; + node_description *node_ref = info->indexed_node[NODE_INDEX(inputnode)]; if (!node_ref) - fatalerror("discrete_start - Node NODE_%02d referenced a non existent node NODE_%02d", node->node - NODE_START, inputnode - NODE_START); + fatalerror("discrete_start - Node NODE_%02d referenced a non existent node NODE_%02d", NODE_INDEX(node->node), NODE_INDEX(inputnode)); - node->input[inputnum] = &(node_ref->output); // Link referenced node out to input + if (NODE_CHILD_NODE_NUM(inputnode) >= node_ref->module.num_output) + fatalerror("discrete_start - Node NODE_%02d referenced non existent output %d on node NODE_%02d", NODE_INDEX(node->node), NODE_CHILD_NODE_NUM(inputnode), NODE_INDEX(inputnode)); + + node->input[inputnum] = &(node_ref->output[NODE_CHILD_NODE_NUM(inputnode)]); // Link referenced node out to input node->input_is_node |= 1 << inputnum; // Bit flag if input is node } } @@ -709,7 +718,7 @@ static void setup_disc_logs(discrete_info *info) fprintf(info->disc_csv_file[log_num], "\"Sample\""); for (node_num = 0; node_num < info->csvlog_node[log_num]->active_inputs; node_num++) { - fprintf(info->disc_csv_file[log_num], ", \"NODE_%2d\"", info->csvlog_node[log_num]->block->input_node[node_num] - NODE_START); + fprintf(info->disc_csv_file[log_num], ", \"NODE_%2d\"", NODE_INDEX(info->csvlog_node[log_num]->block->input_node[node_num])); } fprintf(info->disc_csv_file[log_num], "\n"); } @@ -751,7 +760,7 @@ void discrete_get_info(void *token, UINT32 state, sndinfo *info) /* --- the following bits of info are returned as NULL-terminated strings --- */ case SNDINFO_STR_NAME: info->s = "Discrete"; break; case SNDINFO_STR_CORE_FAMILY: info->s = "Analog"; break; - case SNDINFO_STR_CORE_VERSION: info->s = "1.0"; break; + case SNDINFO_STR_CORE_VERSION: info->s = "1.1"; break; case SNDINFO_STR_CORE_FILE: info->s = __FILE__; break; case SNDINFO_STR_CORE_CREDITS: info->s = "Copyright Nicola Salmoria and the MAME Team"; break; } diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index d65fc982047..bfb04d37cb2 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -41,6 +41,16 @@ * does not do individual device emulation, but instead does a function * emulation. So you will need to convert the schematic design into * a logic block representation. + * + * There is the possibility to support multiple outputs per module. + * In this case, NODE_XXX is the default ouput. Alternative outputs may + * be accessed by using NODE_XXX_YY where 00<=Y<08. + * + * You may also access nodes with a macros: + * + * NODE_XXX = NODE_SUB(XXX, 0) + * NODE_XXX = NODE(XXX) + * NODE_XXX_YY = NODE_SUB(XXX, YY) with YY != 00 * * One node point may feed a number of inputs, for example you could * connect the output of a DISCRETE_SINEWAVE to the AMPLITUDE input @@ -3113,7 +3123,7 @@ #define DISCRETE_MAX_OUTPUTS 16 #define DISCRETE_MAX_WAVELOGS 10 #define DISCRETE_MAX_CSVLOGS 10 - +#define DISCRETE_MAX_NODE_OUTPUTS 8 /************************************* @@ -3340,6 +3350,7 @@ struct _discrete_module { int type; const char * name; + int num_output; /* Total number of output nodes, i.e. Master node + 1 */ size_t contextsize; void (*reset)(node_description *node); /* Called to reset a node after creation or system reset */ void (*step)(node_description *node); /* Called to execute one time delta of output update */ @@ -3355,18 +3366,18 @@ typedef struct _discrete_module discrete_module; struct _node_description { - int node; /* The node's index number in the node list */ - double output; /* The node's last output value */ - - int active_inputs; /* Number of active inputs on this node type */ - int input_is_node; /* Bit Flags. 1 in bit location means input_is_node */ - const double * input[DISCRETE_MAX_INPUTS]; /* Addresses of Input values */ - - discrete_module module; /* Copy of the node's module info */ - const discrete_sound_block *block; /* Points to the node's setup block. */ - void * context; /* Contextual information specific to this node type */ - const char * name; /* Text name string for identification/debug */ - const void * custom; /* Custom function specific initialisation data */ + int node; /* The node's index number in the node list */ + double output[DISCRETE_MAX_NODE_OUTPUTS]; /* The node's last output value */ + + int active_inputs; /* Number of active inputs on this node type */ + int input_is_node; /* Bit Flags. 1 in bit location means input_is_node */ + const double * input[DISCRETE_MAX_INPUTS]; /* Addresses of Input values */ + + discrete_module module; /* Copy of the node's module info */ + const discrete_sound_block *block; /* Points to the node's setup block. */ + void * context; /* Contextual information specific to this node type */ + const char * name; /* Text name string for identification/debug */ + const void * custom; /* Custom function specific initialisation data */ }; @@ -3672,46 +3683,65 @@ typedef struct _discrete_inverter_osc_desc discrete_inverter_osc_desc; * *************************************/ -enum { NODE_00=0x40000000 - , NODE_01, NODE_02, NODE_03, NODE_04, NODE_05, NODE_06, NODE_07, NODE_08, NODE_09, - NODE_10, NODE_11, NODE_12, NODE_13, NODE_14, NODE_15, NODE_16, NODE_17, NODE_18, NODE_19, - NODE_20, NODE_21, NODE_22, NODE_23, NODE_24, NODE_25, NODE_26, NODE_27, NODE_28, NODE_29, - NODE_30, NODE_31, NODE_32, NODE_33, NODE_34, NODE_35, NODE_36, NODE_37, NODE_38, NODE_39, - NODE_40, NODE_41, NODE_42, NODE_43, NODE_44, NODE_45, NODE_46, NODE_47, NODE_48, NODE_49, - NODE_50, NODE_51, NODE_52, NODE_53, NODE_54, NODE_55, NODE_56, NODE_57, NODE_58, NODE_59, - NODE_60, NODE_61, NODE_62, NODE_63, NODE_64, NODE_65, NODE_66, NODE_67, NODE_68, NODE_69, - NODE_70, NODE_71, NODE_72, NODE_73, NODE_74, NODE_75, NODE_76, NODE_77, NODE_78, NODE_79, - NODE_80, NODE_81, NODE_82, NODE_83, NODE_84, NODE_85, NODE_86, NODE_87, NODE_88, NODE_89, - NODE_90, NODE_91, NODE_92, NODE_93, NODE_94, NODE_95, NODE_96, NODE_97, NODE_98, NODE_99, - NODE_100,NODE_101,NODE_102,NODE_103,NODE_104,NODE_105,NODE_106,NODE_107,NODE_108,NODE_109, - NODE_110,NODE_111,NODE_112,NODE_113,NODE_114,NODE_115,NODE_116,NODE_117,NODE_118,NODE_119, - NODE_120,NODE_121,NODE_122,NODE_123,NODE_124,NODE_125,NODE_126,NODE_127,NODE_128,NODE_129, - NODE_130,NODE_131,NODE_132,NODE_133,NODE_134,NODE_135,NODE_136,NODE_137,NODE_138,NODE_139, - NODE_140,NODE_141,NODE_142,NODE_143,NODE_144,NODE_145,NODE_146,NODE_147,NODE_148,NODE_149, - NODE_150,NODE_151,NODE_152,NODE_153,NODE_154,NODE_155,NODE_156,NODE_157,NODE_158,NODE_159, - NODE_160,NODE_161,NODE_162,NODE_163,NODE_164,NODE_165,NODE_166,NODE_167,NODE_168,NODE_169, - NODE_170,NODE_171,NODE_172,NODE_173,NODE_174,NODE_175,NODE_176,NODE_177,NODE_178,NODE_179, - NODE_180,NODE_181,NODE_182,NODE_183,NODE_184,NODE_185,NODE_186,NODE_187,NODE_188,NODE_189, - NODE_190,NODE_191,NODE_192,NODE_193,NODE_194,NODE_195,NODE_196,NODE_197,NODE_198,NODE_199, - NODE_200,NODE_201,NODE_202,NODE_203,NODE_204,NODE_205,NODE_206,NODE_207,NODE_208,NODE_209, - NODE_210,NODE_211,NODE_212,NODE_213,NODE_214,NODE_215,NODE_216,NODE_217,NODE_218,NODE_219, - NODE_220,NODE_221,NODE_222,NODE_223,NODE_224,NODE_225,NODE_226,NODE_227,NODE_228,NODE_229, - NODE_230,NODE_231,NODE_232,NODE_233,NODE_234,NODE_235,NODE_236,NODE_237,NODE_238,NODE_239, - NODE_240,NODE_241,NODE_242,NODE_243,NODE_244,NODE_245,NODE_246,NODE_247,NODE_248,NODE_249, - NODE_250,NODE_251,NODE_252,NODE_253,NODE_254,NODE_255,NODE_256,NODE_257,NODE_258,NODE_259, - NODE_260,NODE_261,NODE_262,NODE_263,NODE_264,NODE_265,NODE_266,NODE_267,NODE_268,NODE_269, - NODE_270,NODE_271,NODE_272,NODE_273,NODE_274,NODE_275,NODE_276,NODE_277,NODE_278,NODE_279, - NODE_280,NODE_281,NODE_282,NODE_283,NODE_284,NODE_285,NODE_286,NODE_287,NODE_288,NODE_289, - NODE_290,NODE_291,NODE_292,NODE_293,NODE_294,NODE_295,NODE_296,NODE_297,NODE_298,NODE_299 }; +#define NODE0_DEF(_x) NODE_ ## 0 ## _x = (0x40000000 + (_x) * DISCRETE_MAX_NODE_OUTPUTS), \ + NODE_ ## 0 ## _x ## _01, NODE_ ## 0 ## _x ## _02, NODE_ ## 0 ## _x ## _03, NODE_ ## 0 ## _x ## _04, \ + NODE_ ## 0 ## _x ## _05, NODE_ ## 0 ## _x ## _06, NODE_ ## 0 ## _x ## _07 +#define NODE_DEF(_x) NODE_ ## _x = (0x40000000 + (_x) * DISCRETE_MAX_NODE_OUTPUTS), \ + NODE_ ## _x ## _01, NODE_ ## _x ## _02, NODE_ ## _x ## _03, NODE_ ## _x ## _04, \ + NODE_ ## _x ## _05, NODE_ ## _x ## _06, NODE_ ## _x ## _07 + +enum { + NODE0_DEF(0), NODE0_DEF(1), NODE0_DEF(2), NODE0_DEF(3), NODE0_DEF(4), NODE0_DEF(5), NODE0_DEF(6), NODE0_DEF(7), NODE0_DEF(8), NODE0_DEF(9), + NODE_DEF(10), NODE_DEF(11), NODE_DEF(12), NODE_DEF(13), NODE_DEF(14), NODE_DEF(15), NODE_DEF(16), NODE_DEF(17), NODE_DEF(18), NODE_DEF(19), + NODE_DEF(20), NODE_DEF(21), NODE_DEF(22), NODE_DEF(23), NODE_DEF(24), NODE_DEF(25), NODE_DEF(26), NODE_DEF(27), NODE_DEF(28), NODE_DEF(29), + NODE_DEF(30), NODE_DEF(31), NODE_DEF(32), NODE_DEF(33), NODE_DEF(34), NODE_DEF(35), NODE_DEF(36), NODE_DEF(37), NODE_DEF(38), NODE_DEF(39), + NODE_DEF(40), NODE_DEF(41), NODE_DEF(42), NODE_DEF(43), NODE_DEF(44), NODE_DEF(45), NODE_DEF(46), NODE_DEF(47), NODE_DEF(48), NODE_DEF(49), + NODE_DEF(50), NODE_DEF(51), NODE_DEF(52), NODE_DEF(53), NODE_DEF(54), NODE_DEF(55), NODE_DEF(56), NODE_DEF(57), NODE_DEF(58), NODE_DEF(59), + NODE_DEF(60), NODE_DEF(61), NODE_DEF(62), NODE_DEF(63), NODE_DEF(64), NODE_DEF(65), NODE_DEF(66), NODE_DEF(67), NODE_DEF(68), NODE_DEF(69), + NODE_DEF(70), NODE_DEF(71), NODE_DEF(72), NODE_DEF(73), NODE_DEF(74), NODE_DEF(75), NODE_DEF(76), NODE_DEF(77), NODE_DEF(78), NODE_DEF(79), + NODE_DEF(80), NODE_DEF(81), NODE_DEF(82), NODE_DEF(83), NODE_DEF(84), NODE_DEF(85), NODE_DEF(86), NODE_DEF(87), NODE_DEF(88), NODE_DEF(89), + NODE_DEF(90), NODE_DEF(91), NODE_DEF(92), NODE_DEF(93), NODE_DEF(94), NODE_DEF(95), NODE_DEF(96), NODE_DEF(97), NODE_DEF(98), NODE_DEF(99), + NODE_DEF(100),NODE_DEF(101),NODE_DEF(102),NODE_DEF(103),NODE_DEF(104),NODE_DEF(105),NODE_DEF(106),NODE_DEF(107),NODE_DEF(108),NODE_DEF(109), + NODE_DEF(110),NODE_DEF(111),NODE_DEF(112),NODE_DEF(113),NODE_DEF(114),NODE_DEF(115),NODE_DEF(116),NODE_DEF(117),NODE_DEF(118),NODE_DEF(119), + NODE_DEF(120),NODE_DEF(121),NODE_DEF(122),NODE_DEF(123),NODE_DEF(124),NODE_DEF(125),NODE_DEF(126),NODE_DEF(127),NODE_DEF(128),NODE_DEF(129), + NODE_DEF(130),NODE_DEF(131),NODE_DEF(132),NODE_DEF(133),NODE_DEF(134),NODE_DEF(135),NODE_DEF(136),NODE_DEF(137),NODE_DEF(138),NODE_DEF(139), + NODE_DEF(140),NODE_DEF(141),NODE_DEF(142),NODE_DEF(143),NODE_DEF(144),NODE_DEF(145),NODE_DEF(146),NODE_DEF(147),NODE_DEF(148),NODE_DEF(149), + NODE_DEF(150),NODE_DEF(151),NODE_DEF(152),NODE_DEF(153),NODE_DEF(154),NODE_DEF(155),NODE_DEF(156),NODE_DEF(157),NODE_DEF(158),NODE_DEF(159), + NODE_DEF(160),NODE_DEF(161),NODE_DEF(162),NODE_DEF(163),NODE_DEF(164),NODE_DEF(165),NODE_DEF(166),NODE_DEF(167),NODE_DEF(168),NODE_DEF(169), + NODE_DEF(170),NODE_DEF(171),NODE_DEF(172),NODE_DEF(173),NODE_DEF(174),NODE_DEF(175),NODE_DEF(176),NODE_DEF(177),NODE_DEF(178),NODE_DEF(179), + NODE_DEF(180),NODE_DEF(181),NODE_DEF(182),NODE_DEF(183),NODE_DEF(184),NODE_DEF(185),NODE_DEF(186),NODE_DEF(187),NODE_DEF(188),NODE_DEF(189), + NODE_DEF(190),NODE_DEF(191),NODE_DEF(192),NODE_DEF(193),NODE_DEF(194),NODE_DEF(195),NODE_DEF(196),NODE_DEF(197),NODE_DEF(198),NODE_DEF(199), + NODE_DEF(200),NODE_DEF(201),NODE_DEF(202),NODE_DEF(203),NODE_DEF(204),NODE_DEF(205),NODE_DEF(206),NODE_DEF(207),NODE_DEF(208),NODE_DEF(209), + NODE_DEF(210),NODE_DEF(211),NODE_DEF(212),NODE_DEF(213),NODE_DEF(214),NODE_DEF(215),NODE_DEF(216),NODE_DEF(217),NODE_DEF(218),NODE_DEF(219), + NODE_DEF(220),NODE_DEF(221),NODE_DEF(222),NODE_DEF(223),NODE_DEF(224),NODE_DEF(225),NODE_DEF(226),NODE_DEF(227),NODE_DEF(228),NODE_DEF(229), + NODE_DEF(230),NODE_DEF(231),NODE_DEF(232),NODE_DEF(233),NODE_DEF(234),NODE_DEF(235),NODE_DEF(236),NODE_DEF(237),NODE_DEF(238),NODE_DEF(239), + NODE_DEF(240),NODE_DEF(241),NODE_DEF(242),NODE_DEF(243),NODE_DEF(244),NODE_DEF(245),NODE_DEF(246),NODE_DEF(247),NODE_DEF(248),NODE_DEF(249), + NODE_DEF(250),NODE_DEF(251),NODE_DEF(252),NODE_DEF(253),NODE_DEF(254),NODE_DEF(255),NODE_DEF(256),NODE_DEF(257),NODE_DEF(258),NODE_DEF(259), + NODE_DEF(260),NODE_DEF(261),NODE_DEF(262),NODE_DEF(263),NODE_DEF(264),NODE_DEF(265),NODE_DEF(266),NODE_DEF(267),NODE_DEF(268),NODE_DEF(269), + NODE_DEF(270),NODE_DEF(271),NODE_DEF(272),NODE_DEF(273),NODE_DEF(274),NODE_DEF(275),NODE_DEF(276),NODE_DEF(277),NODE_DEF(278),NODE_DEF(279), + NODE_DEF(280),NODE_DEF(281),NODE_DEF(282),NODE_DEF(283),NODE_DEF(284),NODE_DEF(285),NODE_DEF(286),NODE_DEF(287),NODE_DEF(288),NODE_DEF(289), + NODE_DEF(290),NODE_DEF(291),NODE_DEF(292),NODE_DEF(293),NODE_DEF(294),NODE_DEF(295),NODE_DEF(296),NODE_DEF(297),NODE_DEF(298),NODE_DEF(299) +}; /* Some Pre-defined nodes for convenience */ + +#define NODE(_x) (NODE_00 + (_x) * DISCRETE_MAX_NODE_OUTPUTS) +#define NODE_SUB(_x, _y) (NODE(_x) + (_y)) + +#if DISCRETE_MAX_NODE_OUTPUTS == 8 +#define NODE_CHILD_NODE_NUM(_x) ((_x) & 7) +#define NODE_DEFAULT_NODE(_x) ((_x) & ~7) +#define NODE_INDEX(_x) (((_x) - NODE_START)>>3) +#else +#error "DISCRETE_MAX_NODE_OUTPUTS != 8" +#endif + #define NODE_NC NODE_00 -#define NODE_SPECIAL (NODE_00+(DISCRETE_MAX_NODES)) +#define NODE_SPECIAL NODE(DISCRETE_MAX_NODES) #define NODE_START NODE_00 #define NODE_END NODE_SPECIAL - -#define NODE(_x) (NODE_00+(_x)) + /************************************* diff --git a/src/mame/audio/mw8080bw.c b/src/mame/audio/mw8080bw.c index 3fe750e045b..a8567fad329 100644 --- a/src/mame/audio/mw8080bw.c +++ b/src/mame/audio/mw8080bw.c @@ -3395,7 +3395,7 @@ static const discrete_mixer_desc invaders_mixer = /* sound board 1 or 2, for multi-board games */ -#define INVADERS_NODE(_node, _board) (NODE_START + _node + ((_board - 1) * 100)) +#define INVADERS_NODE(_node, _board) (NODE(_node + ((_board - 1) * 100))) /************************************************ * Noise Generator diff --git a/src/mame/audio/sprint4.c b/src/mame/audio/sprint4.c index bdcd0483c57..f5e9426a4ae 100644 --- a/src/mame/audio/sprint4.c +++ b/src/mame/audio/sprint4.c @@ -157,7 +157,7 @@ static const discrete_mixer_desc sprint4_mixer = /* used to offset the motor nodes based on the player so the nodes do not overlap */ /* _plr must be 1, 2, 3, or 4 */ /* so it uses NODES_30 to NODE_69 */ -#define SPRINT4_PLAYER_MOTOR_NODE(_node, _plr) NODE_20 + 10 * _plr + _node +#define SPRINT4_PLAYER_MOTOR_NODE(_node, _plr) NODE(20 + 10 * _plr + _node) /************************************************ |