diff options
Diffstat (limited to 'src/emu/sound/disc_mth.c')
-rw-r--r-- | src/emu/sound/disc_mth.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/emu/sound/disc_mth.c b/src/emu/sound/disc_mth.c index eb117875c20..eb9a8b58a48 100644 --- a/src/emu/sound/disc_mth.c +++ b/src/emu/sound/disc_mth.c @@ -175,10 +175,14 @@ struct dst_tvca_op_amp_context double exponent_d[2]; /* Discharge exponents based on function F3 */ double exponent2[2]; /* Discharge/charge exponents based on function F4 */ double exponent3[2]; /* Discharge/charge exponents based on function F5 */ + double exponent4; /* Discharge/charge exponents for c4 */ double v_cap1; /* charge on cap c1 */ double v_cap2; /* charge on cap c2 */ double v_cap3; /* charge on cap c3 */ + double v_cap4; /* charge on cap c4 */ double r67; /* = r6 + r7 (for easy use later) */ + UINT8 has_c4; + UINT8 has_r4; }; @@ -2023,12 +2027,32 @@ static DISCRETE_STEP(dst_tvca_op_amp) i_pos += context->v_cap3 / info->r11; } - /* Calculate output current. */ i_out = i_pos - i_neg; if (i_out < 0) i_out = 0; + /* Convert to voltage for final output. */ - node->output[0] = i_out * info->r4; + if (context->has_c4) + { + if (context->has_r4) + { + /* voltage across r4 charging cap */ + i_out *= info->r4; + /* exponential charge */ + context->v_cap4 += (i_out - context->v_cap4) * context->exponent4; + } + else + /* linear charge */ + context->v_cap4 += i_out / context->exponent4; + if (context->v_cap4 < 0) + context->v_cap4 = 0; + node->output[0] = context->v_cap4; + } + else + node->output[0] = i_out * info->r4; + + + /* Clip the output if needed. */ if (node->output[0] > context->v_out_max) node->output[0] = context->v_out_max; } @@ -2063,10 +2087,15 @@ static DISCRETE_RESET(dst_tvca_op_amp) context->v_trig2 = (info->v2 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r8, info->r9); context->exponent2[0] = RC_CHARGE_EXP(info->r9 * info->c2); context->exponent2[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r8, info->r9) * info->c2); - context->v_cap3 = 0; - context->v_trig3 = (info->v3 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r10, info->r11); + context->v_cap3 = 0; + context->v_trig3 = (info->v3 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r10, info->r11); context->exponent3[0] = RC_CHARGE_EXP(info->r11 * info->c3); context->exponent3[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r10, info->r11) * info->c3); + context->v_cap4 = 0; + if (info->r4 != 0) context->has_r4 = 1; + if (info->c4 != 0) context->has_c4 = 1; + if (context->has_r4 && context->has_c4) + context->exponent4 = RC_CHARGE_EXP(info->r4 * info->c4); DISCRETE_STEP_CALL(dst_tvca_op_amp); } |