mirror of
https://github.com/holub/mame
synced 2025-05-17 11:15:06 +03:00
Changed all "output[0] = ..." into "set_output(0, ..)" calls.
Rewrote modules using "output[0]" as a latch as well. The purpose is to decouple nodes from the discrete infrastructure implementation. [Couriersud]
This commit is contained in:
parent
9f6f3d4d39
commit
ef874a6f74
@ -68,6 +68,7 @@ DISCRETE_STEP(dsd_555_astbl)
|
||||
double v_charge, exponent = 0;
|
||||
UINT8 flip_flop = m_flip_flop;
|
||||
UINT8 update_exponent = 0;
|
||||
double v_out = 0.0;
|
||||
|
||||
/* put commonly used stuff in local variables for speed */
|
||||
double threshold = m_threshold;
|
||||
@ -76,7 +77,7 @@ DISCRETE_STEP(dsd_555_astbl)
|
||||
if(DSD_555_ASTBL__RESET)
|
||||
{
|
||||
/* We are in RESET */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
m_flip_flop = 1;
|
||||
m_cap_voltage = 0;
|
||||
return;
|
||||
@ -245,38 +246,39 @@ DISCRETE_STEP(dsd_555_astbl)
|
||||
case DISC_555_OUT_SQW:
|
||||
if (count_f + count_r >= 2)
|
||||
/* force at least 1 toggle */
|
||||
this->output[0] = m_flip_flop ? 0 : m_v_out_high;
|
||||
v_out = m_flip_flop ? 0 : m_v_out_high;
|
||||
else
|
||||
this->output[0] = flip_flop * m_v_out_high;
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out = flip_flop * m_v_out_high;
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_555_OUT_CAP:
|
||||
this->output[0] = v_cap;
|
||||
v_out = v_cap;
|
||||
/* Fake it to AC if needed */
|
||||
if (m_output_is_ac)
|
||||
this->output[0] -= threshold * 3.0 /4.0;
|
||||
v_out -= threshold * 3.0 /4.0;
|
||||
break;
|
||||
case DISC_555_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = m_v_out_high * (flip_flop ? x_time : (1.0 - x_time));
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out = m_v_out_high * (flip_flop ? x_time : (1.0 - x_time));
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_555_OUT_LOGIC_X:
|
||||
this->output[0] = flip_flop + x_time;
|
||||
v_out = flip_flop + x_time;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_F_X:
|
||||
this->output[0] = count_f ? count_f + x_time : count_f;
|
||||
v_out = count_f ? count_f + x_time : count_f;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_R_X:
|
||||
this->output[0] = count_r ? count_r + x_time : count_r;
|
||||
v_out = count_r ? count_r + x_time : count_r;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_F:
|
||||
this->output[0] = count_f;
|
||||
v_out = count_f;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_R:
|
||||
this->output[0] = count_r;
|
||||
v_out = count_r;
|
||||
break;
|
||||
}
|
||||
set_output(0, v_out);
|
||||
m_flip_flop = flip_flop;
|
||||
}
|
||||
|
||||
@ -375,7 +377,7 @@ DISCRETE_STEP(dsd_555_mstbl)
|
||||
if(UNEXPECTED(DSD_555_MSTBL__RESET))
|
||||
{
|
||||
/* We are in RESET */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
m_flip_flop = 0;
|
||||
m_cap_voltage = 0;
|
||||
return;
|
||||
@ -489,7 +491,7 @@ DISCRETE_STEP(dsd_555_mstbl)
|
||||
out -= m_ac_shift;
|
||||
break;
|
||||
}
|
||||
this->output[0] = out;
|
||||
set_output(0, out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dsd_555_mstbl)
|
||||
@ -535,7 +537,7 @@ DISCRETE_RESET(dsd_555_mstbl)
|
||||
else
|
||||
m_exp_charge = RC_CHARGE_EXP(DSD_555_MSTBL__R * DSD_555_MSTBL__C);
|
||||
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -597,11 +599,13 @@ DISCRETE_STEP(dsd_555_cc)
|
||||
UINT8 update_exponent, update_t_rc;
|
||||
UINT8 flip_flop = m_flip_flop;
|
||||
|
||||
double v_out = 0;
|
||||
|
||||
|
||||
if (UNEXPECTED(DSD_555_CC__RESET))
|
||||
{
|
||||
/* We are in RESET */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
m_flip_flop = 1;
|
||||
m_cap_voltage = 0;
|
||||
return;
|
||||
@ -861,36 +865,37 @@ DISCRETE_STEP(dsd_555_cc)
|
||||
case DISC_555_OUT_SQW:
|
||||
if (count_f + count_r >= 2)
|
||||
/* force at least 1 toggle */
|
||||
this->output[0] = m_flip_flop ? 0 : m_v_out_high;
|
||||
v_out = m_flip_flop ? 0 : m_v_out_high;
|
||||
else
|
||||
this->output[0] = flip_flop * m_v_out_high;
|
||||
v_out = flip_flop * m_v_out_high;
|
||||
/* Fake it to AC if needed */
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_555_OUT_CAP:
|
||||
this->output[0] = v_cap + m_ac_shift;
|
||||
v_out = v_cap + m_ac_shift;
|
||||
break;
|
||||
case DISC_555_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = m_v_out_high * (flip_flop ? x_time : (1.0 - x_time));
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out = m_v_out_high * (flip_flop ? x_time : (1.0 - x_time));
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_555_OUT_LOGIC_X:
|
||||
this->output[0] = flip_flop + x_time;
|
||||
v_out = flip_flop + x_time;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_F_X:
|
||||
this->output[0] = count_f ? count_f + x_time : count_f;
|
||||
v_out = count_f ? count_f + x_time : count_f;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_R_X:
|
||||
this->output[0] = count_r ? count_r + x_time : count_r;
|
||||
v_out = count_r ? count_r + x_time : count_r;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_F:
|
||||
this->output[0] = count_f;
|
||||
v_out = count_f;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_R:
|
||||
this->output[0] = count_r;
|
||||
v_out = count_r;
|
||||
break;
|
||||
}
|
||||
set_output(0, v_out);
|
||||
m_flip_flop = flip_flop;
|
||||
}
|
||||
|
||||
@ -1134,6 +1139,8 @@ DISCRETE_STEP(dsd_555_vco1)
|
||||
double v_cap; /* Current voltage on capacitor, before dt */
|
||||
double v_cap_next = 0; /* Voltage on capacitor, after dt */
|
||||
|
||||
double v_out = 0;
|
||||
|
||||
dt = this->sample_time(); /* Change in time */
|
||||
v_cap = m_cap_voltage;
|
||||
|
||||
@ -1244,35 +1251,36 @@ DISCRETE_STEP(dsd_555_vco1)
|
||||
switch (m_output_type)
|
||||
{
|
||||
case DISC_555_OUT_SQW:
|
||||
this->output[0] = m_flip_flop * m_v_out_high + m_ac_shift;
|
||||
v_out = m_flip_flop * m_v_out_high + m_ac_shift;
|
||||
break;
|
||||
case DISC_555_OUT_CAP:
|
||||
this->output[0] = v_cap_next;
|
||||
v_out = v_cap_next;
|
||||
/* Fake it to AC if needed */
|
||||
if (m_output_is_ac)
|
||||
this->output[0] -= m_threshold * 3.0 /4.0;
|
||||
v_out -= m_threshold * 3.0 /4.0;
|
||||
break;
|
||||
case DISC_555_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = m_v_out_high * (m_flip_flop ? x_time : (1.0 - x_time));
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out = m_v_out_high * (m_flip_flop ? x_time : (1.0 - x_time));
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_555_OUT_LOGIC_X:
|
||||
this->output[0] = m_flip_flop + x_time;
|
||||
v_out = m_flip_flop + x_time;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_F_X:
|
||||
this->output[0] = count_f ? count_f + x_time : count_f;
|
||||
v_out = count_f ? count_f + x_time : count_f;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_R_X:
|
||||
this->output[0] = count_r ? count_r + x_time : count_r;
|
||||
v_out = count_r ? count_r + x_time : count_r;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_F:
|
||||
this->output[0] = count_f;
|
||||
v_out = count_f;
|
||||
break;
|
||||
case DISC_555_OUT_COUNT_R:
|
||||
this->output[0] = count_r;
|
||||
v_out = count_r;
|
||||
break;
|
||||
}
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dsd_555_vco1)
|
||||
@ -1421,6 +1429,8 @@ DISCRETE_STEP(dsd_566)
|
||||
double v_cap; /* Current voltage on capacitor, before dt */
|
||||
int count_f = 0, count_r = 0;
|
||||
|
||||
double v_out = 0.0;
|
||||
|
||||
dt = this->sample_time(); /* Change in time */
|
||||
v_cap = m_cap_voltage; /* Set to voltage before change */
|
||||
|
||||
@ -1499,37 +1509,38 @@ DISCRETE_STEP(dsd_566)
|
||||
switch (m_out_type)
|
||||
{
|
||||
case DISC_566_OUT_SQUARE:
|
||||
this->output[0] = m_flip_flop ? m_v_sqr_high : m_v_sqr_low;
|
||||
v_out = m_flip_flop ? m_v_sqr_high : m_v_sqr_low;
|
||||
if (m_fake_ac)
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_566_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = m_v_sqr_low + m_v_sqr_diff * (m_flip_flop ? x_time : (1.0 - x_time));
|
||||
v_out = m_v_sqr_low + m_v_sqr_diff * (m_flip_flop ? x_time : (1.0 - x_time));
|
||||
if (m_fake_ac)
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_566_OUT_LOGIC:
|
||||
this->output[0] = m_flip_flop;
|
||||
v_out = m_flip_flop;
|
||||
break;
|
||||
case DISC_566_OUT_TRIANGLE:
|
||||
this->output[0] = v_cap;
|
||||
v_out = v_cap;
|
||||
if (m_fake_ac)
|
||||
this->output[0] += m_ac_shift;
|
||||
v_out += m_ac_shift;
|
||||
break;
|
||||
case DISC_566_OUT_COUNT_F_X:
|
||||
this->output[0] = count_f ? count_f + x_time : count_f;
|
||||
v_out = count_f ? count_f + x_time : count_f;
|
||||
break;
|
||||
case DISC_566_OUT_COUNT_R_X:
|
||||
this->output[0] = count_r ? count_r + x_time : count_r;
|
||||
v_out = count_r ? count_r + x_time : count_r;
|
||||
break;
|
||||
case DISC_566_OUT_COUNT_F:
|
||||
this->output[0] = count_f;
|
||||
v_out = count_f;
|
||||
break;
|
||||
case DISC_566_OUT_COUNT_R:
|
||||
this->output[0] = count_r;
|
||||
v_out = count_r;
|
||||
break;
|
||||
}
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dsd_566)
|
||||
@ -1715,29 +1726,29 @@ DISCRETE_STEP(dsd_ls624)
|
||||
switch (m_out_type)
|
||||
{
|
||||
case DISC_LS624_OUT_LOGIC_X:
|
||||
this->output[0] = m_flip_flop + x_time;
|
||||
set_output(0, m_flip_flop + x_time);
|
||||
break;
|
||||
case DISC_LS624_OUT_COUNT_F_X:
|
||||
this->output[0] = count_f ? count_f + x_time : count_f;
|
||||
set_output(0, count_f ? count_f + x_time : count_f);
|
||||
break;
|
||||
case DISC_LS624_OUT_COUNT_R_X:
|
||||
this->output[0] = count_r ? count_r + x_time : count_r;
|
||||
set_output(0, count_r ? count_r + x_time : count_r);
|
||||
break;
|
||||
case DISC_LS624_OUT_COUNT_F:
|
||||
this->output[0] = count_f;
|
||||
set_output(0, count_f);
|
||||
break;
|
||||
case DISC_LS624_OUT_COUNT_R:
|
||||
this->output[0] = count_r;
|
||||
set_output(0, count_r);
|
||||
break;
|
||||
case DISC_LS624_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = LS624_OUT_HIGH * (m_flip_flop ? x_time : (1.0 - x_time));
|
||||
set_output(0, LS624_OUT_HIGH * (m_flip_flop ? x_time : (1.0 - x_time)));
|
||||
break;
|
||||
case DISC_LS624_OUT_LOGIC:
|
||||
this->output[0] = m_flip_flop;
|
||||
set_output(0, m_flip_flop);
|
||||
break;
|
||||
case DISC_LS624_OUT_SQUARE:
|
||||
this->output[0] = m_flip_flop ? LS624_OUT_HIGH : 0;
|
||||
set_output(0, m_flip_flop ? LS624_OUT_HIGH : 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1759,5 +1770,5 @@ DISCRETE_RESET(dsd_ls624)
|
||||
else
|
||||
m_has_freq_in_cap = 0;
|
||||
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ DISCRETE_STEP(dst_crfilter)
|
||||
|
||||
double v_out = DST_CRFILTER__IN - m_vCap;
|
||||
double v_diff = v_out - DST_CRFILTER__VREF;
|
||||
this->output[0] = v_out;
|
||||
set_output(0, v_out);
|
||||
m_vCap += v_diff * m_exponent;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ DISCRETE_RESET(dst_crfilter)
|
||||
m_rc = DST_CRFILTER__R * DST_CRFILTER__C;
|
||||
m_exponent = RC_CHARGE_EXP(m_rc);
|
||||
m_vCap = 0;
|
||||
this->output[0] = DST_CRFILTER__IN;
|
||||
set_output(0, DST_CRFILTER__IN);
|
||||
}
|
||||
|
||||
|
||||
@ -118,22 +118,24 @@ static void calculate_filter1_coefficients(discrete_base_node *node, double fc,
|
||||
DISCRETE_STEP(dst_filter1)
|
||||
{
|
||||
double gain = 1.0;
|
||||
double v_out;
|
||||
|
||||
if (DST_FILTER1__ENABLE == 0.0)
|
||||
{
|
||||
gain = 0.0;
|
||||
}
|
||||
|
||||
this->output[0] = -m_fc.a1*m_fc.y1 + m_fc.b0*gain*DST_FILTER1__IN + m_fc.b1*m_fc.x1;
|
||||
v_out = -m_fc.a1*m_fc.y1 + m_fc.b0*gain*DST_FILTER1__IN + m_fc.b1*m_fc.x1;
|
||||
|
||||
m_fc.x1 = gain*DST_FILTER1__IN;
|
||||
m_fc.y1 = this->output[0];
|
||||
m_fc.y1 = v_out;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_filter1)
|
||||
{
|
||||
calculate_filter1_coefficients(this, DST_FILTER1__FREQ, DST_FILTER1__TYPE, m_fc);
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -200,26 +202,28 @@ static void calculate_filter2_coefficients(discrete_base_node *node,
|
||||
DISCRETE_STEP(dst_filter2)
|
||||
{
|
||||
double gain = 1.0;
|
||||
double v_out;
|
||||
|
||||
if (DST_FILTER2__ENABLE == 0.0)
|
||||
{
|
||||
gain = 0.0;
|
||||
}
|
||||
|
||||
this->output[0] = -m_fc.a1 * m_fc.y1 - m_fc.a2 * m_fc.y2 +
|
||||
v_out = -m_fc.a1 * m_fc.y1 - m_fc.a2 * m_fc.y2 +
|
||||
m_fc.b0 * gain * DST_FILTER2__IN + m_fc.b1 * m_fc.x1 + m_fc.b2 * m_fc.x2;
|
||||
|
||||
m_fc.x2 = m_fc.x1;
|
||||
m_fc.x1 = gain * DST_FILTER2__IN;
|
||||
m_fc.y2 = m_fc.y1;
|
||||
m_fc.y1 = this->output[0];
|
||||
m_fc.y1 = v_out;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_filter2)
|
||||
{
|
||||
calculate_filter2_coefficients(this, DST_FILTER2__FREQ, DST_FILTER2__DAMP, DST_FILTER2__TYPE,
|
||||
m_fc);
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -244,6 +248,7 @@ DISCRETE_RESET(dst_filter2)
|
||||
DISCRETE_STEP(dst_op_amp_filt)
|
||||
{
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_filt_info)
|
||||
double v_out = 0;
|
||||
|
||||
double i, v = 0;
|
||||
|
||||
@ -280,46 +285,46 @@ DISCRETE_STEP(dst_op_amp_filt)
|
||||
{
|
||||
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1:
|
||||
m_vC1 += (v - m_vC1) * m_exponentC1;
|
||||
this->output[0] = m_vC1 * m_gain + info->vRef;
|
||||
v_out = m_vC1 * m_gain + info->vRef;
|
||||
break;
|
||||
|
||||
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1_A:
|
||||
m_vC1 += (v - m_vC1) * m_exponentC1;
|
||||
this->output[0] = m_vC1 * m_gain + DST_OP_AMP_FILT__INP2;
|
||||
v_out = m_vC1 * m_gain + DST_OP_AMP_FILT__INP2;
|
||||
break;
|
||||
|
||||
case DISC_OP_AMP_FILTER_IS_HIGH_PASS_1:
|
||||
this->output[0] = (v - m_vC1) * m_gain + info->vRef;
|
||||
v_out = (v - m_vC1) * m_gain + info->vRef;
|
||||
m_vC1 += (v - m_vC1) * m_exponentC1;
|
||||
break;
|
||||
|
||||
case DISC_OP_AMP_FILTER_IS_BAND_PASS_1:
|
||||
this->output[0] = (v - m_vC2);
|
||||
v_out = (v - m_vC2);
|
||||
m_vC2 += (v - m_vC2) * m_exponentC2;
|
||||
m_vC1 += (this->output[0] - m_vC1) * m_exponentC1;
|
||||
this->output[0] = m_vC1 * m_gain + info->vRef;
|
||||
m_vC1 += (v_out - m_vC1) * m_exponentC1;
|
||||
v_out = m_vC1 * m_gain + info->vRef;
|
||||
break;
|
||||
|
||||
case DISC_OP_AMP_FILTER_IS_BAND_PASS_0 | DISC_OP_AMP_IS_NORTON:
|
||||
m_vC1 += (v - m_vC1) * m_exponentC1;
|
||||
m_vC2 += (m_vC1 - m_vC2) * m_exponentC2;
|
||||
v = m_vC2;
|
||||
this->output[0] = v - m_vC3;
|
||||
v_out = v - m_vC3;
|
||||
m_vC3 += (v - m_vC3) * m_exponentC3;
|
||||
i = this->output[0] / m_rTotal;
|
||||
this->output[0] = (m_iFixed - i) * info->rF;
|
||||
i = v_out / m_rTotal;
|
||||
v_out = (m_iFixed - i) * info->rF;
|
||||
break;
|
||||
|
||||
case DISC_OP_AMP_FILTER_IS_HIGH_PASS_0 | DISC_OP_AMP_IS_NORTON:
|
||||
this->output[0] = v - m_vC1;
|
||||
v_out = v - m_vC1;
|
||||
m_vC1 += (v - m_vC1) * m_exponentC1;
|
||||
i = this->output[0] / m_rTotal;
|
||||
this->output[0] = (m_iFixed - i) * info->rF;
|
||||
i = v_out / m_rTotal;
|
||||
v_out = (m_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:
|
||||
this->output[0] = -m_fc.a1 * m_fc.y1 - m_fc.a2 * m_fc.y2 +
|
||||
v_out = -m_fc.a1 * m_fc.y1 - m_fc.a2 * m_fc.y2 +
|
||||
m_fc.b0 * v + m_fc.b1 * m_fc.x1 + m_fc.b2 * m_fc.x2 +
|
||||
m_vRef;
|
||||
m_fc.x2 = m_fc.x1;
|
||||
@ -331,12 +336,13 @@ DISCRETE_STEP(dst_op_amp_filt)
|
||||
/* Clip the output to the voltage rails.
|
||||
* This way we get the original distortion in all it's glory.
|
||||
*/
|
||||
if (this->output[0] > m_vP) this->output[0] = m_vP;
|
||||
if (this->output[0] < m_vN) this->output[0] = m_vN;
|
||||
m_fc.y1 = this->output[0] - m_vRef;
|
||||
if (v_out > m_vP) v_out = m_vP;
|
||||
if (v_out < m_vN) v_out = m_vN;
|
||||
m_fc.y1 = v_out - m_vRef;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
else
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
|
||||
}
|
||||
|
||||
@ -435,7 +441,7 @@ DISCRETE_RESET(dst_op_amp_filt)
|
||||
m_vC2 = 0;
|
||||
m_vC3 = 0;
|
||||
|
||||
this->output[0] = info->vRef;
|
||||
set_output(0, info->vRef);
|
||||
}
|
||||
|
||||
|
||||
@ -457,12 +463,12 @@ DISCRETE_STEP( dst_rc_circuit_1 )
|
||||
if (DST_RC_CIRCUIT_1__IN1 == 0)
|
||||
/* cap is floating and does not change charge */
|
||||
/* output is pulled to ground */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
else
|
||||
{
|
||||
/* cap is discharged */
|
||||
m_v_cap -= m_v_cap * m_exp_2;
|
||||
this->output[0] = m_v_cap * m_v_drop;
|
||||
set_output(0, m_v_cap * m_v_drop);
|
||||
}
|
||||
else
|
||||
if (DST_RC_CIRCUIT_1__IN1 == 0)
|
||||
@ -470,13 +476,13 @@ DISCRETE_STEP( dst_rc_circuit_1 )
|
||||
/* cap is charged */
|
||||
m_v_cap += (5.0 - m_v_cap) * m_exp_1;
|
||||
/* output is pulled to ground */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* cap is charged slightly less */
|
||||
m_v_cap += (m_v_charge_1_2 - m_v_cap) * m_exp_1_2;
|
||||
this->output[0] = m_v_cap * m_v_drop;
|
||||
set_output(0, m_v_cap * m_v_drop);
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,7 +502,7 @@ DISCRETE_RESET( dst_rc_circuit_1 )
|
||||
m_exp_1_2 = RC_CHARGE_EXP(RES_2_PARALLEL(CD4066_R_ON, CD4066_R_ON + DST_RC_CIRCUIT_1__R) * DST_RC_CIRCUIT_1__C);
|
||||
|
||||
/* starts at 0 until cap starts charging */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -525,13 +531,13 @@ DISCRETE_STEP(dst_rcdisc)
|
||||
m_state = 1;
|
||||
m_t = 0;
|
||||
}
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (DST_RCDISC__ENABLE)
|
||||
{
|
||||
this->output[0] = DST_RCDISC__IN * exp(m_t / m_exponent0);
|
||||
set_output(0, DST_RCDISC__IN * exp(m_t / m_exponent0));
|
||||
m_t += this->sample_time();
|
||||
} else
|
||||
{
|
||||
@ -542,7 +548,7 @@ DISCRETE_STEP(dst_rcdisc)
|
||||
|
||||
DISCRETE_RESET(dst_rcdisc)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
|
||||
m_state = 0;
|
||||
m_t = 0;
|
||||
@ -577,14 +583,15 @@ DISCRETE_STEP(dst_rcdisc2)
|
||||
/* 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) - this->output[0];
|
||||
diff = ((DST_RCDISC2__ENABLE == 0) ? DST_RCDISC2__IN0 : DST_RCDISC2__IN1) - m_v_out;
|
||||
diff = diff - (diff * ((DST_RCDISC2__ENABLE == 0) ? m_exponent0 : m_exponent1));
|
||||
this->output[0] += diff;
|
||||
m_v_out += diff;
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_rcdisc2)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
|
||||
m_state = 0;
|
||||
m_t = 0;
|
||||
@ -620,7 +627,7 @@ DISCRETE_STEP(dst_rcdisc3)
|
||||
|
||||
if(DST_RCDISC3__ENABLE)
|
||||
{
|
||||
diff = DST_RCDISC3__IN - this->output[0];
|
||||
diff = DST_RCDISC3__IN - m_v_out;
|
||||
if (m_v_diode > 0)
|
||||
{
|
||||
if (diff > 0)
|
||||
@ -651,17 +658,18 @@ DISCRETE_STEP(dst_rcdisc3)
|
||||
diff = diff * m_exponent0;
|
||||
}
|
||||
}
|
||||
this->output[0] += diff;
|
||||
m_v_out += diff;
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_rcdisc3)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
|
||||
m_state = 0;
|
||||
m_t = 0;
|
||||
@ -696,10 +704,11 @@ DISCRETE_RESET(dst_rcdisc3)
|
||||
DISCRETE_STEP(dst_rcdisc4)
|
||||
{
|
||||
int inp1 = (DST_RCDISC4__IN == 0) ? 0 : 1;
|
||||
double v_out = 0;
|
||||
|
||||
if (DST_RCDISC4__ENABLE == 0)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -708,13 +717,14 @@ DISCRETE_STEP(dst_rcdisc4)
|
||||
case 1:
|
||||
case 3:
|
||||
m_vC1 += ((m_v[inp1] - m_vC1) * m_exp[inp1]);
|
||||
this->output[0] = m_vC1;
|
||||
v_out = m_vC1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* clip output */
|
||||
if (this->output[0] > m_max_out) this->output[0] = m_max_out;
|
||||
if (this->output[0] < 0) this->output[0] = 0;
|
||||
if (v_out > m_max_out) v_out = m_max_out;
|
||||
if (v_out < 0) v_out = 0;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET( dst_rcdisc4)
|
||||
@ -819,20 +829,20 @@ DISCRETE_STEP( dst_rcdisc5)
|
||||
diff = diff * m_exponent0;
|
||||
|
||||
m_v_cap += diff;
|
||||
this->output[0] = m_v_cap;
|
||||
set_output(0, m_v_cap);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(diff > 0)
|
||||
m_v_cap = u;
|
||||
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DISCRETE_RESET( dst_rcdisc5)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
|
||||
m_state = 0;
|
||||
m_t = 0;
|
||||
@ -886,14 +896,14 @@ DISCRETE_STEP(dst_rcdisc_mod)
|
||||
diff = u + 0.6 - v_cap;
|
||||
diff -= diff * m_exp_low[mod1_state];
|
||||
v_cap += diff;
|
||||
this->output[0] = mod2_state ? 0 : -0.6;
|
||||
set_output(0, mod2_state ? 0 : -0.6);
|
||||
}
|
||||
else
|
||||
{
|
||||
diff -= diff * m_exp_high[mod_state];
|
||||
v_cap += diff;
|
||||
/* neglecting current through R3 drawn by next8 node */
|
||||
this->output[0] = mod2_state ? 0: (u - v_cap) * m_gain[mod1_state];
|
||||
set_output(0, mod2_state ? 0: (u - v_cap) * m_gain[mod1_state]);
|
||||
}
|
||||
m_v_cap = v_cap;
|
||||
}
|
||||
@ -931,7 +941,7 @@ DISCRETE_RESET(dst_rcdisc_mod)
|
||||
m_vd_gain[3] = RES_VOLTAGE_DIVIDER(rc[1], rc2[1]);
|
||||
|
||||
m_v_cap = 0;
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -953,7 +963,7 @@ DISCRETE_RESET(dst_rcdisc_mod)
|
||||
DISCRETE_STEP(dst_rcfilter)
|
||||
{
|
||||
if (EXPECTED(m_is_fast))
|
||||
this->output[0] += ((DST_RCFILTER__VIN - this->output[0]) * m_exponent);
|
||||
m_v_out += ((DST_RCFILTER__VIN - m_v_out) * m_exponent);
|
||||
else
|
||||
{
|
||||
if (UNEXPECTED(m_has_rc_nodes))
|
||||
@ -970,8 +980,9 @@ DISCRETE_STEP(dst_rcfilter)
|
||||
/* Next Value = PREV + (INPUT_VALUE - PREV)*(1-(EXP(-TIMEDELTA/RC))) */
|
||||
/************************************************************************/
|
||||
|
||||
m_vCap += ((DST_RCFILTER__VIN - this->output[0]) * m_exponent);
|
||||
this->output[0] = m_vCap + DST_RCFILTER__VREF;
|
||||
m_vCap += ((DST_RCFILTER__VIN - m_v_out) * m_exponent);
|
||||
m_v_out = m_vCap + DST_RCFILTER__VREF;
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
}
|
||||
|
||||
@ -982,7 +993,7 @@ DISCRETE_RESET(dst_rcfilter)
|
||||
m_rc = DST_RCFILTER__R * DST_RCFILTER__C;
|
||||
m_exponent = RC_CHARGE_EXP(m_rc);
|
||||
m_vCap = 0;
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
/* FIXME --> we really need another class here */
|
||||
if (!m_has_rc_nodes && DST_RCFILTER__VREF == 0)
|
||||
m_is_fast = 1;
|
||||
@ -1024,21 +1035,22 @@ DISCRETE_STEP(dst_rcfilter_sw)
|
||||
int bits = (int)DST_RCFILTER_SW__SWITCH;
|
||||
double us = 0;
|
||||
double vIn = DST_RCFILTER_SW__VIN;
|
||||
double v_out;
|
||||
|
||||
if (EXPECTED(DST_RCFILTER_SW__ENABLE))
|
||||
{
|
||||
switch (bits)
|
||||
{
|
||||
case 0:
|
||||
this->output[0] = vIn;
|
||||
v_out = vIn;
|
||||
break;
|
||||
case 1:
|
||||
m_vCap[0] += (vIn - m_vCap[0]) * m_exp0;
|
||||
this->output[0] = m_vCap[0] + (vIn - m_vCap[0]) * m_factor;
|
||||
v_out = m_vCap[0] + (vIn - m_vCap[0]) * m_factor;
|
||||
break;
|
||||
case 2:
|
||||
m_vCap[1] += (vIn - m_vCap[1]) * m_exp1;
|
||||
this->output[0] = m_vCap[1] + (vIn - m_vCap[1]) * m_factor;
|
||||
v_out = m_vCap[1] + (vIn - m_vCap[1]) * m_factor;
|
||||
break;
|
||||
default:
|
||||
for (i = 0; i < 4; i++)
|
||||
@ -1046,17 +1058,18 @@ DISCRETE_STEP(dst_rcfilter_sw)
|
||||
if (( bits & (1 << i)) != 0)
|
||||
us += m_vCap[i];
|
||||
}
|
||||
this->output[0] = m_f1[bits] * vIn + m_f2[bits] * us;
|
||||
v_out = m_f1[bits] * vIn + m_f2[bits] * us;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (( bits & (1 << i)) != 0)
|
||||
m_vCap[i] += (this->output[0] - m_vCap[i]) * m_exp[i];
|
||||
m_vCap[i] += (v_out - m_vCap[i]) * m_exp[i];
|
||||
}
|
||||
}
|
||||
set_output(0, v_out);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1089,7 +1102,7 @@ DISCRETE_RESET(dst_rcfilter_sw)
|
||||
m_exp1 = RC_CHARGE_EXP((CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(1));
|
||||
m_factor = RES_VOLTAGE_DIVIDER(DST_RCFILTER_SW__R, CD4066_ON_RES);
|
||||
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1185,13 +1198,13 @@ DISCRETE_STEP( dst_rcintegrate)
|
||||
switch (m_type)
|
||||
{
|
||||
case DISC_RC_INTEGRATE_TYPE1:
|
||||
this->output[0] = m_vCap;
|
||||
set_output(0, m_vCap);
|
||||
break;
|
||||
case DISC_RC_INTEGRATE_TYPE2:
|
||||
this->output[0] = vE;
|
||||
set_output(0, vE);
|
||||
break;
|
||||
case DISC_RC_INTEGRATE_TYPE3:
|
||||
this->output[0] = MAX(0, vP - iQ * DST_RCINTEGRATE__R3);
|
||||
set_output(0, MAX(0, vP - iQ * DST_RCINTEGRATE__R3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1221,7 +1234,7 @@ DISCRETE_RESET(dst_rcintegrate)
|
||||
|
||||
m_EM_IC_0_7 = EM_IC(0.7);
|
||||
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -1243,19 +1256,21 @@ DISCRETE_RESET(dst_rcintegrate)
|
||||
DISCRETE_STEP(dst_sallen_key)
|
||||
{
|
||||
double gain = 1.0;
|
||||
double v_out;
|
||||
|
||||
if (DST_SALLEN_KEY__ENABLE == 0.0)
|
||||
{
|
||||
gain = 0.0;
|
||||
}
|
||||
|
||||
this->output[0] = -m_fc.a1 * m_fc.y1 - m_fc.a2 * m_fc.y2 +
|
||||
v_out = -m_fc.a1 * m_fc.y1 - m_fc.a2 * m_fc.y2 +
|
||||
m_fc.b0 * gain * DST_SALLEN_KEY__INP0 + m_fc.b1 * m_fc.x1 + m_fc.b2 * m_fc.x2;
|
||||
|
||||
m_fc.x2 = m_fc.x1;
|
||||
m_fc.x1 = gain * DST_SALLEN_KEY__INP0;
|
||||
m_fc.y2 = m_fc.y1;
|
||||
m_fc.y1 = this->output[0];
|
||||
m_fc.y1 = v_out;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_sallen_key)
|
||||
@ -1275,7 +1290,7 @@ DISCRETE_RESET(dst_sallen_key)
|
||||
}
|
||||
|
||||
calculate_filter2_coefficients(this, freq, 1.0 / q, DISC_FILTER_LOWPASS, m_fc);
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1350,6 +1365,7 @@ DISCRETE_RESET(dst_rcdiscN)
|
||||
DISCRETE_STEP(dst_rcdiscN)
|
||||
{
|
||||
double gain = 1.0;
|
||||
double v_out;
|
||||
|
||||
if (DST_RCDISCN__ENABLE == 0.0)
|
||||
{
|
||||
@ -1359,12 +1375,13 @@ DISCRETE_STEP(dst_rcdiscN)
|
||||
/* A rise in the input signal results in an instant charge, */
|
||||
/* else discharge through the RC to zero */
|
||||
if (gain* DST_RCDISCN__IN > m_x1)
|
||||
this->output[0] = gain* DST_RCDISCN__IN;
|
||||
v_out = gain* DST_RCDISCN__IN;
|
||||
else
|
||||
this->output[0] = -m_a1*m_y1;
|
||||
v_out = -m_a1*m_y1;
|
||||
|
||||
m_x1 = gain* DST_RCDISCN__IN;
|
||||
m_y1 = this->output[0];
|
||||
m_y1 = v_out;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
|
||||
@ -1392,14 +1409,16 @@ DISCRETE_STEP(dst_rcdiscN)
|
||||
DISCRETE_STEP(dst_rcdisc2N)
|
||||
{
|
||||
double inp = ((DST_RCDISC2N__ENABLE == 0) ? DST_RCDISC2N__IN0 : DST_RCDISC2N__IN1);
|
||||
double v_out;
|
||||
|
||||
if (DST_RCDISC2N__ENABLE == 0)
|
||||
this->output[0] = -m_fc0.a1*m_y1 + m_fc0.b0*inp + m_fc0.b1 * m_x1;
|
||||
v_out = -m_fc0.a1*m_y1 + m_fc0.b0*inp + m_fc0.b1 * m_x1;
|
||||
else
|
||||
this->output[0] = -m_fc1.a1*m_y1 + m_fc1.b0*inp + m_fc1.b1*m_x1;
|
||||
v_out = -m_fc1.a1*m_y1 + m_fc1.b0*inp + m_fc1.b1*m_x1;
|
||||
|
||||
m_x1 = inp;
|
||||
m_y1 = this->output[0];
|
||||
m_y1 = v_out;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_rcdisc2N)
|
||||
@ -1413,5 +1432,5 @@ DISCRETE_RESET(dst_rcdisc2N)
|
||||
calculate_filter1_coefficients(this, f2, DISC_FILTER_LOWPASS, m_fc1);
|
||||
|
||||
/* Initialize the object */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ DISCRETE_CLASS_STEP_RESET(dst_rcdisc, 1,
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_rcdisc2, 1,
|
||||
int m_state;
|
||||
double m_v_out;
|
||||
double m_t; /* time */
|
||||
double m_exponent0;
|
||||
double m_exponent1;
|
||||
@ -95,6 +96,7 @@ DISCRETE_CLASS_STEP_RESET(dst_rcdisc2, 1,
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_rcdisc3, 1,
|
||||
int m_state;
|
||||
double m_v_out;
|
||||
double m_t; /* time */
|
||||
double m_exponent0;
|
||||
double m_exponent1;
|
||||
@ -140,6 +142,7 @@ DISCRETE_CLASS_STEP_RESET(dst_rcdisc_mod, 1,
|
||||
);
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_rcfilter, 1,
|
||||
double m_v_out;
|
||||
double m_vCap;
|
||||
double m_rc;
|
||||
double m_exponent;
|
||||
|
@ -65,9 +65,9 @@ DISCRETE_STEP(dss_adjustment)
|
||||
|
||||
m_lastpval = rawportval;
|
||||
if (DSS_ADJUSTMENT__LOG == 0)
|
||||
this->output[0] = scaledval;
|
||||
set_output(0, scaledval);
|
||||
else
|
||||
this->output[0] = pow(10, scaledval);
|
||||
set_output(0, pow(10, scaledval));
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ DISCRETE_RESET(dss_adjustment)
|
||||
|
||||
DISCRETE_RESET(dss_constant)
|
||||
{
|
||||
this->output[0]= DSS_CONSTANT__INIT;
|
||||
set_output(0, DSS_CONSTANT__INIT);
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ DISCRETE_RESET(dss_input_data)
|
||||
m_offset = DSS_INPUT__OFFSET;
|
||||
|
||||
m_data = DSS_INPUT__INIT;
|
||||
this->output[0] = m_data * m_gain + m_offset;
|
||||
set_output(0, m_data * m_gain + m_offset);
|
||||
}
|
||||
|
||||
void DISCRETE_CLASS_FUNC(dss_input_data, input_write)(int sub_node, UINT8 data )
|
||||
@ -153,7 +153,7 @@ void DISCRETE_CLASS_FUNC(dss_input_data, input_write)(int sub_node, UINT8 data )
|
||||
m_data = new_data;
|
||||
|
||||
/* Update the node output here so we don't have to do it each step */
|
||||
this->output[0] = m_data * m_gain + m_offset;
|
||||
set_output(0, m_data * m_gain + m_offset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ DISCRETE_RESET(dss_input_logic)
|
||||
m_offset = DSS_INPUT__OFFSET;
|
||||
|
||||
m_data = (DSS_INPUT__INIT == 0) ? 0 : 1;
|
||||
this->output[0] = m_data * m_gain + m_offset;
|
||||
set_output(0, m_data * m_gain + m_offset);
|
||||
}
|
||||
|
||||
void DISCRETE_CLASS_FUNC(dss_input_logic, input_write)(int sub_node, UINT8 data )
|
||||
@ -180,7 +180,7 @@ void DISCRETE_CLASS_FUNC(dss_input_logic, input_write)(int sub_node, UINT8 data
|
||||
m_data = new_data;
|
||||
|
||||
/* Update the node output here so we don't have to do it each step */
|
||||
this->output[0] = m_data * m_gain + m_offset;
|
||||
set_output(0, m_data * m_gain + m_offset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ DISCRETE_RESET(dss_input_not)
|
||||
m_offset = DSS_INPUT__OFFSET;
|
||||
|
||||
m_data = (DSS_INPUT__INIT == 0) ? 1 : 0;
|
||||
this->output[0] = m_data * m_gain + m_offset;
|
||||
set_output(0, m_data * m_gain + m_offset);
|
||||
}
|
||||
|
||||
void DISCRETE_CLASS_FUNC(dss_input_not, input_write)(int sub_node, UINT8 data )
|
||||
@ -207,14 +207,14 @@ void DISCRETE_CLASS_FUNC(dss_input_not, input_write)(int sub_node, UINT8 data )
|
||||
m_data = new_data;
|
||||
|
||||
/* Update the node output here so we don't have to do it each step */
|
||||
this->output[0] = m_data * m_gain + m_offset;
|
||||
set_output(0, m_data * m_gain + m_offset);
|
||||
}
|
||||
}
|
||||
|
||||
DISCRETE_STEP(dss_input_pulse)
|
||||
{
|
||||
/* Set a valid output */
|
||||
this->output[0] = m_data;
|
||||
set_output(0, m_data);
|
||||
/* Reset the input to default for the next cycle */
|
||||
/* node order is now important */
|
||||
m_data = DSS_INPUT__INIT;
|
||||
@ -223,7 +223,7 @@ DISCRETE_STEP(dss_input_pulse)
|
||||
DISCRETE_RESET(dss_input_pulse)
|
||||
{
|
||||
m_data = (DSS_INPUT__INIT == 0) ? 0 : 1;
|
||||
this->output[0] = m_data;
|
||||
set_output(0, m_data);
|
||||
}
|
||||
|
||||
void DISCRETE_CLASS_FUNC(dss_input_pulse, input_write)(int sub_node, UINT8 data )
|
||||
@ -271,11 +271,11 @@ DISCRETE_STEP(dss_input_stream)
|
||||
/* the context pointer is set to point to the current input stream data in discrete_stream_update */
|
||||
if (EXPECTED(m_ptr))
|
||||
{
|
||||
this->output[0] = (*m_ptr) * m_gain + m_offset;
|
||||
set_output(0, (*m_ptr) * m_gain + m_offset);
|
||||
m_ptr++;
|
||||
}
|
||||
else
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dss_input_stream)
|
||||
@ -307,7 +307,7 @@ void DISCRETE_CLASS_FUNC(dss_input_stream, input_write)(int sub_node, UINT8 data
|
||||
m_data = new_data;
|
||||
|
||||
/* Update the node output here so we don't have to do it each step */
|
||||
this->output[0] = new_data * m_gain + m_offset;
|
||||
set_output(0, new_data * m_gain + m_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,11 +72,11 @@ DISCRETE_STEP(dst_adder)
|
||||
{
|
||||
if(DST_ADDER__ENABLE)
|
||||
{
|
||||
this->output[0] = DST_ADDER__IN0 + DST_ADDER__IN1 + DST_ADDER__IN2 + DST_ADDER__IN3;
|
||||
set_output(0, DST_ADDER__IN0 + DST_ADDER__IN1 + DST_ADDER__IN2 + DST_ADDER__IN3);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0]=0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ DISCRETE_STEP(dst_comp_adder)
|
||||
|
||||
select = (int)DST_COMP_ADDER__SELECT;
|
||||
assert(select < 256);
|
||||
this->output[0] = m_total[select];
|
||||
set_output(0, m_total[select]);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_comp_adder)
|
||||
@ -137,7 +137,7 @@ DISCRETE_RESET(dst_comp_adder)
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->output[0] = m_total[0];
|
||||
set_output(0, m_total[0]);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -155,9 +155,12 @@ DISCRETE_RESET(dst_comp_adder)
|
||||
|
||||
DISCRETE_STEP(dst_clamp)
|
||||
{
|
||||
if (DST_CLAMP__IN < DST_CLAMP__MIN) this->output[0] = DST_CLAMP__MIN;
|
||||
else if (DST_CLAMP__IN > DST_CLAMP__MAX) this->output[0] = DST_CLAMP__MAX;
|
||||
else this->output[0]= DST_CLAMP__IN;
|
||||
if (DST_CLAMP__IN < DST_CLAMP__MIN)
|
||||
set_output(0, DST_CLAMP__MIN);
|
||||
else if (DST_CLAMP__IN > DST_CLAMP__MAX)
|
||||
set_output(0, DST_CLAMP__MAX);
|
||||
else
|
||||
set_output(0, DST_CLAMP__IN);
|
||||
}
|
||||
|
||||
|
||||
@ -191,19 +194,19 @@ DISCRETE_STEP(dst_dac_r1)
|
||||
/* Filter if needed, else just output voltage */
|
||||
if (m_has_c_filter)
|
||||
{
|
||||
double out = this->output[0];
|
||||
double v_diff = v - out;
|
||||
double v_diff = v - m_v_out;
|
||||
/* optimization - if charged close enough to voltage */
|
||||
if (fabs(v_diff) < 0.000001)
|
||||
this->output[0] = v;
|
||||
m_v_out = v;
|
||||
else
|
||||
{
|
||||
out += v_diff * m_exponent;
|
||||
this->output[0] = out;
|
||||
m_v_out += v_diff * m_exponent;
|
||||
}
|
||||
}
|
||||
else
|
||||
this->output[0] = v;
|
||||
m_v_out = v;
|
||||
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_dac_r1)
|
||||
@ -254,7 +257,7 @@ DISCRETE_RESET(dst_dac_r1)
|
||||
if (info->rGnd > 0) r_total += 1.0 / info->rGnd;
|
||||
r_total = 1.0 / r_total;
|
||||
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
|
||||
if (info->cFilter > 0)
|
||||
{
|
||||
@ -314,7 +317,7 @@ DISCRETE_STEP(dst_diode_mix)
|
||||
if (val > max) max = val;
|
||||
}
|
||||
if (max < 0) max = 0;
|
||||
this->output[0] = max;
|
||||
set_output(0, max);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_diode_mix)
|
||||
@ -362,17 +365,17 @@ DISCRETE_STEP(dst_divide)
|
||||
{
|
||||
if(DST_DIVIDE__DIV == 0)
|
||||
{
|
||||
this->output[0 ]= DBL_MAX; /* Max out but don't break */
|
||||
set_output(0, DBL_MAX); /* Max out but don't break */
|
||||
m_device->discrete_log("dst_divider_step() - Divide by Zero attempted in NODE_%02d.\n",this->index());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0]= DST_DIVIDE__IN / DST_DIVIDE__DIV;
|
||||
set_output(0, DST_DIVIDE__IN / DST_DIVIDE__DIV);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0]=0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,7 +395,7 @@ DISCRETE_STEP(dst_divide)
|
||||
|
||||
DISCRETE_STEP(dst_gain)
|
||||
{
|
||||
this->output[0] = DST_GAIN__IN * DST_GAIN__GAIN + DST_GAIN__OFFSET;
|
||||
set_output(0, DST_GAIN__IN * DST_GAIN__GAIN + DST_GAIN__OFFSET);
|
||||
}
|
||||
|
||||
|
||||
@ -460,17 +463,18 @@ DISCRETE_STEP(dst_integrate)
|
||||
/* This forces the cap to completely charge,
|
||||
* and the output to go to it's max value.
|
||||
*/
|
||||
this->output[0] = m_v_max_out;
|
||||
m_v_out = m_v_max_out;
|
||||
set_output(0, m_v_out);
|
||||
return;
|
||||
}
|
||||
this->output[0] -= m_change;
|
||||
m_v_out -= m_change;
|
||||
break;
|
||||
|
||||
case DISC_INTEGRATE_OP_AMP_1 | DISC_OP_AMP_IS_NORTON:
|
||||
i_neg = m_v_max_in / info->r1;
|
||||
i_pos = (DST_INTEGRATE__TRG0 - OP_AMP_NORTON_VBE) / info->r2;
|
||||
if (i_pos < 0) i_pos = 0;
|
||||
this->output[0] += (i_pos - i_neg) / this->sample_rate() / info->c;
|
||||
m_v_out += (i_pos - i_neg) / this->sample_rate() / info->c;
|
||||
break;
|
||||
|
||||
case DISC_INTEGRATE_OP_AMP_2 | DISC_OP_AMP_IS_NORTON:
|
||||
@ -479,13 +483,15 @@ DISCRETE_STEP(dst_integrate)
|
||||
i_neg = dst_trigger_function(trig0, trig1, 0, info->f0) ? m_v_max_in_d / info->r1 : 0;
|
||||
i_pos = dst_trigger_function(trig0, trig1, 0, info->f1) ? m_v_max_in / info->r2 : 0;
|
||||
i_pos += dst_trigger_function(trig0, trig1, 0, info->f2) ? m_v_max_in_d / info->r3 : 0;
|
||||
this->output[0] += (i_pos - i_neg) / this->sample_rate() / info->c;
|
||||
m_v_out += (i_pos - i_neg) / this->sample_rate() / info->c;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Clip the output. */
|
||||
if (this->output[0] < 0) this->output[0] = 0;
|
||||
if (this->output[0] > m_v_max_out) this->output[0] = m_v_max_out;
|
||||
if (m_v_out < 0) m_v_out = 0;
|
||||
if (m_v_out > m_v_max_out) m_v_out = m_v_max_out;
|
||||
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_integrate)
|
||||
@ -509,7 +515,8 @@ DISCRETE_RESET(dst_integrate)
|
||||
i = v / info->r1;
|
||||
m_change = i / this->sample_rate() / info->c;
|
||||
}
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
|
||||
@ -525,7 +532,7 @@ DISCRETE_RESET(dst_integrate)
|
||||
|
||||
DISCRETE_STEP(dst_logic_inv)
|
||||
{
|
||||
this->output[0] = DST_LOGIC_INV__IN ? 0.0 : 1.0;
|
||||
set_output(0, DST_LOGIC_INV__IN ? 0.0 : 1.0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -584,7 +591,7 @@ DISCRETE_STEP(dst_bits_decode)
|
||||
else
|
||||
out *= new_bit;
|
||||
}
|
||||
this->output[i] = out;
|
||||
set_output(i, out);
|
||||
if (has_x_time && bit_changed)
|
||||
/* set */
|
||||
m_last_had_x_time |= 1 << (i + from);
|
||||
@ -627,7 +634,7 @@ DISCRETE_RESET(dst_bits_decode)
|
||||
|
||||
DISCRETE_STEP(dst_logic_and)
|
||||
{
|
||||
this->output[0] = (DST_LOGIC_AND__IN0 && DST_LOGIC_AND__IN1 && DST_LOGIC_AND__IN2 && DST_LOGIC_AND__IN3)? 1.0 : 0.0;
|
||||
set_output(0, (DST_LOGIC_AND__IN0 && DST_LOGIC_AND__IN1 && DST_LOGIC_AND__IN2 && DST_LOGIC_AND__IN3)? 1.0 : 0.0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -647,7 +654,7 @@ DISCRETE_STEP(dst_logic_and)
|
||||
|
||||
DISCRETE_STEP(dst_logic_nand)
|
||||
{
|
||||
this->output[0]= (DST_LOGIC_NAND__IN0 && DST_LOGIC_NAND__IN1 && DST_LOGIC_NAND__IN2 && DST_LOGIC_NAND__IN3)? 0.0 : 1.0;
|
||||
set_output(0, (DST_LOGIC_NAND__IN0 && DST_LOGIC_NAND__IN1 && DST_LOGIC_NAND__IN2 && DST_LOGIC_NAND__IN3)? 0.0 : 1.0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -667,7 +674,7 @@ DISCRETE_STEP(dst_logic_nand)
|
||||
|
||||
DISCRETE_STEP(dst_logic_or)
|
||||
{
|
||||
this->output[0] = (DST_LOGIC_OR__IN0 || DST_LOGIC_OR__IN1 || DST_LOGIC_OR__IN2 || DST_LOGIC_OR__IN3) ? 1.0 : 0.0;
|
||||
set_output(0, (DST_LOGIC_OR__IN0 || DST_LOGIC_OR__IN1 || DST_LOGIC_OR__IN2 || DST_LOGIC_OR__IN3) ? 1.0 : 0.0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -687,7 +694,7 @@ DISCRETE_STEP(dst_logic_or)
|
||||
|
||||
DISCRETE_STEP(dst_logic_nor)
|
||||
{
|
||||
this->output[0] = (DST_LOGIC_NOR__IN0 || DST_LOGIC_NOR__IN1 || DST_LOGIC_NOR__IN2 || DST_LOGIC_NOR__IN3) ? 0.0 : 1.0;
|
||||
set_output(0, (DST_LOGIC_NOR__IN0 || DST_LOGIC_NOR__IN1 || DST_LOGIC_NOR__IN2 || DST_LOGIC_NOR__IN3) ? 0.0 : 1.0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -703,7 +710,7 @@ DISCRETE_STEP(dst_logic_nor)
|
||||
|
||||
DISCRETE_STEP(dst_logic_xor)
|
||||
{
|
||||
this->output[0] = ((DST_LOGIC_XOR__IN0 && !DST_LOGIC_XOR__IN1) || (!DST_LOGIC_XOR__IN0 && DST_LOGIC_XOR__IN1)) ? 1.0 : 0.0;
|
||||
set_output(0, ((DST_LOGIC_XOR__IN0 && !DST_LOGIC_XOR__IN1) || (!DST_LOGIC_XOR__IN0 && DST_LOGIC_XOR__IN1)) ? 1.0 : 0.0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -719,7 +726,7 @@ DISCRETE_STEP(dst_logic_xor)
|
||||
|
||||
DISCRETE_STEP(dst_logic_nxor)
|
||||
{
|
||||
this->output[0] = ((DST_LOGIC_XNOR__IN0 && !DST_LOGIC_XNOR__IN1) || (!DST_LOGIC_XNOR__IN0 && DST_LOGIC_XNOR__IN1)) ? 0.0 : 1.0;
|
||||
set_output(0, ((DST_LOGIC_XNOR__IN0 && !DST_LOGIC_XNOR__IN1) || (!DST_LOGIC_XNOR__IN0 && DST_LOGIC_XNOR__IN1)) ? 0.0 : 1.0);
|
||||
}
|
||||
|
||||
|
||||
@ -743,18 +750,18 @@ DISCRETE_STEP(dst_logic_dff)
|
||||
int clk = (int)DST_LOGIC_DFF__CLOCK;
|
||||
|
||||
if (DST_LOGIC_DFF__RESET)
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
else if (DST_LOGIC_DFF__SET)
|
||||
this->output[0] = 1;
|
||||
set_output(0, 1);
|
||||
else if (!m_last_clk && clk) /* low to high */
|
||||
this->output[0] = DST_LOGIC_DFF__DATA;
|
||||
set_output(0, DST_LOGIC_DFF__DATA);
|
||||
m_last_clk = clk;
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_logic_dff)
|
||||
{
|
||||
m_last_clk = 0;
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -782,9 +789,9 @@ DISCRETE_STEP(dst_logic_jkff)
|
||||
int k = (int)DST_LOGIC_JKFF__K;
|
||||
|
||||
if (DST_LOGIC_JKFF__RESET)
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
else if (DST_LOGIC_JKFF__SET)
|
||||
this->output[0] = 1;
|
||||
m_v_out = 1;
|
||||
else if (m_last_clk && !clk) /* high to low */
|
||||
{
|
||||
if (!j)
|
||||
@ -792,25 +799,27 @@ DISCRETE_STEP(dst_logic_jkff)
|
||||
/* J=0, K=0 - Hold */
|
||||
if (k)
|
||||
/* J=0, K=1 - Reset */
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!k)
|
||||
/* J=1, K=0 - Set */
|
||||
this->output[0] = 1;
|
||||
m_v_out = 1;
|
||||
else
|
||||
/* J=1, K=1 - Toggle */
|
||||
this->output[0] = !(int)this->output[0];
|
||||
m_v_out = !(int)m_v_out;
|
||||
}
|
||||
}
|
||||
m_last_clk = clk;
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_logic_jkff)
|
||||
{
|
||||
m_last_clk = 0;
|
||||
this->output[0] = 0;
|
||||
m_v_out = 0;
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -848,7 +857,7 @@ DISCRETE_STEP(dst_logic_shift)
|
||||
if(((DST_LOGIC_SHIFT__RESET == 0) ? 0 : 1) == m_reset_on_high)
|
||||
{
|
||||
m_shift_data = 0;
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -895,7 +904,7 @@ DISCRETE_STEP(dst_logic_shift)
|
||||
m_shift_data &= m_bit_mask;
|
||||
}
|
||||
|
||||
this->output[0] = m_shift_data;
|
||||
set_output(0, m_shift_data);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_logic_shift)
|
||||
@ -908,7 +917,7 @@ DISCRETE_RESET(dst_logic_shift)
|
||||
m_t_left = 0;
|
||||
m_last = 0;
|
||||
m_shift_data = 0;
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -932,9 +941,9 @@ DISCRETE_STEP(dst_lookup_table)
|
||||
int addr = DST_LOOKUP_TABLE__IN;
|
||||
|
||||
if (addr < 0 || addr >= DST_LOOKUP_TABLE__SIZE)
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
else
|
||||
this->output[0] = info[addr];
|
||||
set_output(0, info[addr]);
|
||||
}
|
||||
|
||||
|
||||
@ -1139,11 +1148,11 @@ DISCRETE_STEP(dst_mixer)
|
||||
m_v_cap_amp += (v - m_v_cap_amp) * m_exponent_c_amp;
|
||||
v -= m_v_cap_amp;
|
||||
}
|
||||
this->output[0] = v * info->gain;
|
||||
set_output(0, v * info->gain);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1247,7 +1256,7 @@ DISCRETE_RESET(dst_mixer)
|
||||
|
||||
if (m_type == DISC_MIXER_IS_OP_AMP_WITH_RI) m_gain = info->rF / info->rI;
|
||||
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1272,7 +1281,7 @@ DISCRETE_STEP(dst_multiplex)
|
||||
addr = DST_MULTIPLEX__ADDR; /* FP to INT */
|
||||
if ((addr >= 0) && (addr < m_size))
|
||||
{
|
||||
this->output[0] = DST_MULTIPLEX__INP(addr);
|
||||
set_output(0, DST_MULTIPLEX__INP(addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1317,7 +1326,7 @@ DISCRETE_STEP(dst_oneshot)
|
||||
if (UNEXPECTED(DST_ONESHOT__RESET))
|
||||
{
|
||||
/* Hold in Reset */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
m_state = 0;
|
||||
}
|
||||
else
|
||||
@ -1335,7 +1344,7 @@ DISCRETE_STEP(dst_oneshot)
|
||||
{
|
||||
/* We have first trigger */
|
||||
m_state = 1;
|
||||
this->output[0] = (m_type & DISC_OUT_ACTIVE_LOW) ? 0 : DST_ONESHOT__AMP;
|
||||
set_output(0, (m_type & DISC_OUT_ACTIVE_LOW) ? 0 : DST_ONESHOT__AMP);
|
||||
m_countdown = DST_ONESHOT__WIDTH;
|
||||
}
|
||||
else
|
||||
@ -1356,7 +1365,7 @@ DISCRETE_STEP(dst_oneshot)
|
||||
m_countdown -= this->sample_time();
|
||||
if(m_countdown <= 0.0)
|
||||
{
|
||||
this->output[0] = (m_type & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0;
|
||||
set_output(0, (m_type & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0);
|
||||
m_countdown = 0;
|
||||
m_state = 0;
|
||||
}
|
||||
@ -1373,7 +1382,7 @@ DISCRETE_RESET(dst_oneshot)
|
||||
m_last_trig = 0;
|
||||
m_type = DST_ONESHOT__TYPE;
|
||||
|
||||
this->output[0] = (m_type & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0;
|
||||
set_output(0, (m_type & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1403,27 +1412,29 @@ DISCRETE_STEP(dst_ramp)
|
||||
if (!m_last_en)
|
||||
{
|
||||
m_last_en = 1;
|
||||
this->output[0] = DST_RAMP__START;
|
||||
m_v_out = DST_RAMP__START;
|
||||
}
|
||||
if(m_dir ? DST_RAMP__DIR : !DST_RAMP__DIR) this->output[0]+=m_step;
|
||||
else this->output[0] -= m_step;
|
||||
if(m_dir ? DST_RAMP__DIR : !DST_RAMP__DIR) m_v_out += m_step;
|
||||
else m_v_out -= m_step;
|
||||
/* Clamp to min/max */
|
||||
if(m_dir ? (this->output[0] < DST_RAMP__START)
|
||||
: (this->output[0] > DST_RAMP__START)) this->output[0] = DST_RAMP__START;
|
||||
if(m_dir ? (this->output[0] > DST_RAMP__END)
|
||||
: (this->output[0] < DST_RAMP__END)) this->output[0] = DST_RAMP__END;
|
||||
if(m_dir ? (m_v_out < DST_RAMP__START)
|
||||
: (m_v_out > DST_RAMP__START)) m_v_out = DST_RAMP__START;
|
||||
if(m_dir ? (m_v_out > DST_RAMP__END)
|
||||
: (m_v_out < DST_RAMP__END)) m_v_out = DST_RAMP__END;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_last_en = 0;
|
||||
/* Disabled so clamp to output */
|
||||
this->output[0] = DST_RAMP__CLAMP;
|
||||
m_v_out = DST_RAMP__CLAMP;
|
||||
}
|
||||
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_ramp)
|
||||
{
|
||||
this->output[0] = DST_RAMP__CLAMP;
|
||||
m_v_out = DST_RAMP__CLAMP;
|
||||
m_step = DST_RAMP__GRAD / this->sample_rate();
|
||||
m_dir = ((DST_RAMP__END - DST_RAMP__START) == abs(DST_RAMP__END - DST_RAMP__START));
|
||||
m_last_en = 0;
|
||||
@ -1449,19 +1460,19 @@ DISCRETE_STEP(dst_samphold)
|
||||
{
|
||||
case DISC_SAMPHOLD_REDGE:
|
||||
/* Clock the whole time the input is rising */
|
||||
if (DST_SAMPHOLD__CLOCK > m_last_input) this->output[0] = DST_SAMPHOLD__IN0;
|
||||
if (DST_SAMPHOLD__CLOCK > m_last_input) set_output(0, DST_SAMPHOLD__IN0);
|
||||
break;
|
||||
case DISC_SAMPHOLD_FEDGE:
|
||||
/* Clock the whole time the input is falling */
|
||||
if(DST_SAMPHOLD__CLOCK < m_last_input) this->output[0] = DST_SAMPHOLD__IN0;
|
||||
if(DST_SAMPHOLD__CLOCK < m_last_input) set_output(0, DST_SAMPHOLD__IN0);
|
||||
break;
|
||||
case DISC_SAMPHOLD_HLATCH:
|
||||
/* Output follows input if clock != 0 */
|
||||
if( DST_SAMPHOLD__CLOCK) this->output[0] = DST_SAMPHOLD__IN0;
|
||||
if( DST_SAMPHOLD__CLOCK) set_output(0, DST_SAMPHOLD__IN0);
|
||||
break;
|
||||
case DISC_SAMPHOLD_LLATCH:
|
||||
/* Output follows input if clock == 0 */
|
||||
if (DST_SAMPHOLD__CLOCK == 0) this->output[0] = DST_SAMPHOLD__IN0;
|
||||
if (DST_SAMPHOLD__CLOCK == 0) set_output(0, DST_SAMPHOLD__IN0);
|
||||
break;
|
||||
default:
|
||||
m_device->discrete_log("dst_samphold_step - Invalid clocktype passed");
|
||||
@ -1473,7 +1484,7 @@ DISCRETE_STEP(dst_samphold)
|
||||
|
||||
DISCRETE_RESET(dst_samphold)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
m_last_input = -1;
|
||||
/* Only stored in here to speed up and save casting in the step function */
|
||||
m_clocktype = (int)DST_SAMPHOLD__TYPE;
|
||||
@ -1500,11 +1511,11 @@ DISCRETE_STEP(dst_switch)
|
||||
{
|
||||
if(DST_SWITCH__ENABLE)
|
||||
{
|
||||
this->output[0] = DST_SWITCH__SWITCH ? DST_SWITCH__IN1 : DST_SWITCH__IN0;
|
||||
set_output(0, DST_SWITCH__SWITCH ? DST_SWITCH__IN1 : DST_SWITCH__IN0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1524,7 +1535,7 @@ DISCRETE_STEP(dst_switch)
|
||||
|
||||
DISCRETE_STEP(dst_aswitch)
|
||||
{
|
||||
this->output[0] = DST_ASWITCH__CTRL > DST_ASWITCH__THRESHOLD ? DST_ASWITCH__IN : 0;
|
||||
set_output(0, DST_ASWITCH__CTRL > DST_ASWITCH__THRESHOLD ? DST_ASWITCH__IN : 0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -1596,7 +1607,7 @@ DISCRETE_STEP(dst_transform)
|
||||
case TOK_END: break; /* please compiler */
|
||||
}
|
||||
}
|
||||
this->output[0] = top;
|
||||
set_output(0, top);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_transform)
|
||||
@ -1661,6 +1672,7 @@ DISCRETE_STEP(dst_op_amp)
|
||||
double i_pos = 0;
|
||||
double i_neg = 0;
|
||||
double i = 0;
|
||||
double v_out;
|
||||
|
||||
if (DST_OP_AMP__ENABLE)
|
||||
{
|
||||
@ -1694,30 +1706,32 @@ DISCRETE_STEP(dst_op_amp)
|
||||
else
|
||||
/* linear charge */
|
||||
m_v_cap += i / m_exponent;
|
||||
this->output[0] = m_v_cap;
|
||||
v_out = m_v_cap;
|
||||
}
|
||||
else
|
||||
if (m_has_r4)
|
||||
this->output[0] = i * info->r4;
|
||||
v_out = i * info->r4;
|
||||
else
|
||||
/* output just swings to rail when there is no r4 */
|
||||
if (i > 0)
|
||||
this->output[0] = m_v_max;
|
||||
v_out = m_v_max;
|
||||
else
|
||||
this->output[0] = 0;
|
||||
v_out = 0;
|
||||
|
||||
/* clamp output */
|
||||
if (this->output[0] > m_v_max) this->output[0] = m_v_max;
|
||||
else if (this->output[0] < info->vN) this->output[0] = info->vN;
|
||||
m_v_cap = this->output[0];
|
||||
if (v_out > m_v_max) v_out = m_v_max;
|
||||
else if (v_out < info->vN) v_out = info->vN;
|
||||
m_v_cap = v_out;
|
||||
|
||||
set_output(0, v_out);
|
||||
break;
|
||||
|
||||
default:
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_op_amp)
|
||||
@ -1773,7 +1787,7 @@ DISCRETE_STEP(dst_op_amp_1sht)
|
||||
|
||||
/* update trigger circuit */
|
||||
i_pos = (DST_OP_AMP_1SHT__TRIGGER - m_v_cap2) / info->r2;
|
||||
i_pos += this->output[0] / info->r5;
|
||||
i_pos += m_v_out / info->r5;
|
||||
m_v_cap2 += (DST_OP_AMP_1SHT__TRIGGER - m_v_cap2) * m_exponent2;
|
||||
|
||||
/* calculate currents and output */
|
||||
@ -1781,13 +1795,13 @@ DISCRETE_STEP(dst_op_amp_1sht)
|
||||
if (i_neg < 0) i_neg = 0;
|
||||
i_neg += m_i_fixed;
|
||||
|
||||
if (i_pos > i_neg) this->output[0] = m_v_max;
|
||||
else this->output[0] = info->vN;
|
||||
if (i_pos > i_neg) m_v_out = m_v_max;
|
||||
else m_v_out = info->vN;
|
||||
|
||||
/* update c1 */
|
||||
/* rough value of voltage at anode of diode if discharging */
|
||||
v = this->output[0] + 0.6;
|
||||
if (m_v_cap1 > this->output[0])
|
||||
v = m_v_out + 0.6;
|
||||
if (m_v_cap1 > m_v_out)
|
||||
{
|
||||
/* discharge */
|
||||
if (m_v_cap1 > v)
|
||||
@ -1795,11 +1809,13 @@ DISCRETE_STEP(dst_op_amp_1sht)
|
||||
m_v_cap1 = v;
|
||||
else
|
||||
/* discharge through r4 */
|
||||
m_v_cap1 += (this->output[0] - m_v_cap1) * m_exponent1d;
|
||||
m_v_cap1 += (m_v_out - m_v_cap1) * m_exponent1d;
|
||||
}
|
||||
else
|
||||
/* charge */
|
||||
m_v_cap1 += ((this->output[0] - OP_AMP_NORTON_VBE) * m_r34ratio + OP_AMP_NORTON_VBE - m_v_cap1) * m_exponent1c;
|
||||
m_v_cap1 += ((m_v_out - OP_AMP_NORTON_VBE) * m_r34ratio + OP_AMP_NORTON_VBE - m_v_cap1) * m_exponent1c;
|
||||
|
||||
set_output(0, m_v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_op_amp_1sht)
|
||||
@ -1847,6 +1863,8 @@ DISCRETE_STEP(dst_tvca_op_amp)
|
||||
double i_pos = 0; /* current into + input */
|
||||
double i_out = 0; /* current at output */
|
||||
|
||||
double v_out;
|
||||
|
||||
trig0 = (int)DST_TVCA_OP_AMP__TRG0;
|
||||
trig1 = (int)DST_TVCA_OP_AMP__TRG1;
|
||||
trig2 = (int)DST_TVCA_OP_AMP__TRG2;
|
||||
@ -1924,15 +1942,17 @@ DISCRETE_STEP(dst_tvca_op_amp)
|
||||
m_v_cap4 += i_out / m_exponent4;
|
||||
if (m_v_cap4 < 0)
|
||||
m_v_cap4 = 0;
|
||||
this->output[0] = m_v_cap4;
|
||||
v_out = m_v_cap4;
|
||||
}
|
||||
else
|
||||
this->output[0] = i_out * info->r4;
|
||||
v_out = i_out * info->r4;
|
||||
|
||||
|
||||
|
||||
/* Clip the output if needed. */
|
||||
if (this->output[0] > m_v_out_max) this->output[0] = m_v_out_max;
|
||||
if (v_out > m_v_out_max) v_out = m_v_out_max;
|
||||
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dst_tvca_op_amp)
|
||||
@ -2036,13 +2056,13 @@ DISCRETE_STEP(dst_xtime_buffer)
|
||||
{
|
||||
double diff = out_high - out_low;
|
||||
diff = out ? diff * x_time : diff * (1.0 - x_time);
|
||||
this->output[0] = out_low + diff;
|
||||
set_output(0, out_low + diff);
|
||||
}
|
||||
else
|
||||
this->output[0] = out ? out_high : out_low;
|
||||
set_output(0, out ? out_high : out_low);
|
||||
}
|
||||
else
|
||||
this->output[0] = out + x_time;
|
||||
set_output(0, out + x_time);
|
||||
}
|
||||
|
||||
|
||||
@ -2256,13 +2276,13 @@ DISCRETE_STEP(dst_xtime_and)
|
||||
{
|
||||
double diff = out_high - out_low;
|
||||
diff = out ? diff * x_time : diff * (1.0 - x_time);
|
||||
this->output[0] = out_low + diff;
|
||||
set_output(0, out_low + diff);
|
||||
}
|
||||
else
|
||||
this->output[0] = out ? out_high : out_low;
|
||||
set_output(0, out ? out_high : out_low);
|
||||
}
|
||||
else
|
||||
this->output[0] = out + x_time;
|
||||
set_output(0, out + x_time);
|
||||
}
|
||||
|
||||
|
||||
@ -2481,13 +2501,13 @@ DISCRETE_STEP(dst_xtime_or)
|
||||
{
|
||||
double diff = out_high - out_low;
|
||||
diff = out ? diff * x_time : diff * (1.0 - x_time);
|
||||
this->output[0] = out_low + diff;
|
||||
set_output(0, out_low + diff);
|
||||
}
|
||||
else
|
||||
this->output[0] = out ? out_high : out_low;
|
||||
set_output(0, out ? out_high : out_low);
|
||||
}
|
||||
else
|
||||
this->output[0] = out + x_time;
|
||||
set_output(0, out + x_time);
|
||||
}
|
||||
|
||||
|
||||
@ -2742,11 +2762,11 @@ DISCRETE_STEP(dst_xtime_xor)
|
||||
{
|
||||
double diff = out_high - out_low;
|
||||
diff = out ? diff * x_time : diff * (1.0 - x_time);
|
||||
this->output[0] = out_low + diff;
|
||||
set_output(0, out_low + diff);
|
||||
}
|
||||
else
|
||||
this->output[0] = out ? out_high : out_low;
|
||||
set_output(0, out ? out_high : out_low);
|
||||
}
|
||||
else
|
||||
this->output[0] = out + x_time;
|
||||
set_output(0, out + x_time);
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ DISCRETE_CLASS_STEP_RESET(dst_logic_dff, 1,
|
||||
);
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_logic_jkff, 1,
|
||||
double m_v_out;
|
||||
int m_last_clk;
|
||||
);
|
||||
|
||||
@ -83,6 +84,7 @@ DISCRETE_CLASS_STEP_RESET(dst_oneshot, 1,
|
||||
);
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_ramp, 1,
|
||||
double m_v_out;
|
||||
double m_step;
|
||||
int m_dir; /* 1 if End is higher then Start */
|
||||
int m_last_en; /* Keep track of the last enable value */
|
||||
@ -144,6 +146,7 @@ DISCRETE_CLASS_STEP_RESET(dst_comp_adder, 1,
|
||||
);
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_dac_r1, 1,
|
||||
double m_v_out;
|
||||
double m_exponent;
|
||||
double m_last_v;
|
||||
double m_v_step[256];
|
||||
@ -156,6 +159,7 @@ DISCRETE_CLASS_STEP_RESET(dst_diode_mix, 1,
|
||||
);
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_integrate, 1,
|
||||
double m_v_out;
|
||||
double m_change;
|
||||
double m_v_max_in; /* v1 - norton VBE */
|
||||
double m_v_max_in_d; /* v1 - norton VBE - diode drop */
|
||||
@ -191,6 +195,7 @@ DISCRETE_CLASS_STEP_RESET(dst_op_amp, 1,
|
||||
);
|
||||
|
||||
DISCRETE_CLASS_STEP_RESET(dst_op_amp_1sht, 1,
|
||||
double m_v_out;
|
||||
double m_i_fixed;
|
||||
double m_v_max;
|
||||
double m_r34ratio;
|
||||
|
@ -84,7 +84,7 @@ DISCRETE_STEP(dss_counter)
|
||||
if (UNEXPECTED(DSS_COUNTER__RESET))
|
||||
{
|
||||
m_last_count = (int)DSS_COUNTER__INIT;
|
||||
this->output[0] = (int)DSS_COUNTER__INIT;
|
||||
set_output(0, (int)DSS_COUNTER__INIT);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -94,6 +94,8 @@ DISCRETE_STEP(dss_counter)
|
||||
*/
|
||||
if (EXPECTED(DSS_COUNTER__ENABLE))
|
||||
{
|
||||
double v_out;
|
||||
|
||||
switch (m_clock_type)
|
||||
{
|
||||
case DISC_CLK_ON_F_EDGE:
|
||||
@ -136,7 +138,7 @@ DISCRETE_STEP(dss_counter)
|
||||
}
|
||||
|
||||
m_last_count = count;
|
||||
this->output[0] = m_is_7492 ? disc_7492_count[count] : count;
|
||||
v_out = m_is_7492 ? disc_7492_count[count] : count;
|
||||
|
||||
if (UNEXPECTED(count != last_count))
|
||||
{
|
||||
@ -144,18 +146,19 @@ DISCRETE_STEP(dss_counter)
|
||||
switch (m_out_type)
|
||||
{
|
||||
case DISC_OUT_HAS_XTIME:
|
||||
this->output[0] += x_time;
|
||||
v_out += x_time;
|
||||
break;
|
||||
case DISC_OUT_IS_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = last_count;
|
||||
v_out = last_count;
|
||||
if (count > last_count)
|
||||
this->output[0] += (count - last_count) * x_time;
|
||||
v_out += (count - last_count) * x_time;
|
||||
else
|
||||
this->output[0] -= (last_count - count) * x_time;
|
||||
v_out -= (last_count - count) * x_time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
set_output(0, v_out);
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +192,7 @@ DISCRETE_RESET(dss_counter)
|
||||
m_t_left = 0;
|
||||
m_last_count = 0;
|
||||
m_last_clock = 0;
|
||||
this->output[0] = DSS_COUNTER__INIT; /* count starts at reset value */
|
||||
set_output(0, DSS_COUNTER__INIT); /* count starts at reset value */
|
||||
}
|
||||
|
||||
|
||||
@ -325,6 +328,8 @@ DISCRETE_STEP(dss_lfsr_noise)
|
||||
|
||||
if (inc > 0)
|
||||
{
|
||||
double v_out;
|
||||
|
||||
noise_feed = (DSS_LFSR_NOISE__FEED ? 0x01 : 0x00);
|
||||
for (clock = 0; clock < inc; clock++)
|
||||
{
|
||||
@ -352,26 +357,28 @@ DISCRETE_STEP(dss_lfsr_noise)
|
||||
}
|
||||
/* Now select the output bit */
|
||||
if (m_out_is_f0)
|
||||
this->output[0] = fbresult & 0x01;
|
||||
v_out = fbresult & 0x01;
|
||||
else
|
||||
this->output[0] = (m_lfsr_reg >> info->output_bit) & 0x01;
|
||||
v_out = (m_lfsr_reg >> info->output_bit) & 0x01;
|
||||
|
||||
/* Final inversion if required */
|
||||
if (m_invert_output) this->output[0] = this->output[0] ? 0 : 1;
|
||||
if (m_invert_output) v_out = v_out ? 0 : 1;
|
||||
|
||||
/* Gain stage */
|
||||
this->output[0] = this->output[0] ? DSS_LFSR_NOISE__AMP / 2 : -DSS_LFSR_NOISE__AMP / 2;
|
||||
v_out = v_out ? DSS_LFSR_NOISE__AMP / 2 : -DSS_LFSR_NOISE__AMP / 2;
|
||||
/* Bias input as required */
|
||||
this->output[0] = this->output[0] + DSS_LFSR_NOISE__BIAS;
|
||||
v_out = v_out + DSS_LFSR_NOISE__BIAS;
|
||||
|
||||
set_output(0, v_out);
|
||||
|
||||
/* output the lfsr reg ?*/
|
||||
if (m_out_lfsr_reg)
|
||||
this->output[1] = (double) m_lfsr_reg;
|
||||
set_output(1, (double) m_lfsr_reg);
|
||||
|
||||
}
|
||||
if(!DSS_LFSR_NOISE__ENABLE)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,6 +387,7 @@ DISCRETE_RESET(dss_lfsr_noise)
|
||||
DISCRETE_DECLARE_INFO(discrete_lfsr_desc)
|
||||
|
||||
int fb0 , fb1, fbresult;
|
||||
double v_out;
|
||||
|
||||
m_reset_on_high = (info->flags & DISC_LFSR_FLAG_RESET_TYPE_H) ? 1 : 0;
|
||||
m_invert_output = info->flags & DISC_LFSR_FLAG_OUT_INVERT;
|
||||
@ -404,15 +412,18 @@ DISCRETE_RESET(dss_lfsr_noise)
|
||||
m_lfsr_reg=dss_lfsr_function(m_device, DISC_LFSR_REPLACE, m_lfsr_reg, fbresult << info->bitlength, (2<< info->bitlength ) - 1);
|
||||
|
||||
/* Now select and setup the output bit */
|
||||
this->output[0] = (m_lfsr_reg >> info->output_bit) & 0x01;
|
||||
v_out = (m_lfsr_reg >> info->output_bit) & 0x01;
|
||||
|
||||
/* Final inversion if required */
|
||||
if(info->flags & DISC_LFSR_FLAG_OUT_INVERT) this->output[0] = this->output[0] ? 0 : 1;
|
||||
if(info->flags & DISC_LFSR_FLAG_OUT_INVERT) v_out = v_out ? 0 : 1;
|
||||
|
||||
/* Gain stage */
|
||||
this->output[0] = this->output[0] ? DSS_LFSR_NOISE__AMP / 2 : -DSS_LFSR_NOISE__AMP / 2;
|
||||
v_out = v_out ? DSS_LFSR_NOISE__AMP / 2 : -DSS_LFSR_NOISE__AMP / 2;
|
||||
/* Bias input as required */
|
||||
this->output[0] = this->output[0] + DSS_LFSR_NOISE__BIAS;
|
||||
v_out += DSS_LFSR_NOISE__BIAS;
|
||||
|
||||
set_output(0, v_out);
|
||||
set_output(1, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -433,6 +444,8 @@ DISCRETE_RESET(dss_lfsr_noise)
|
||||
|
||||
DISCRETE_STEP(dss_noise)
|
||||
{
|
||||
double v_out;
|
||||
|
||||
if(DSS_NOISE__ENABLE)
|
||||
{
|
||||
/* Only sample noise on rollover to next cycle */
|
||||
@ -442,19 +455,20 @@ DISCRETE_STEP(dss_noise)
|
||||
int newval = (m_device->machine->rand() & 0x7fff) - 16384;
|
||||
|
||||
/* make sure the peak to peak values are the amplitude */
|
||||
this->output[0] = DSS_NOISE__AMP / 2;
|
||||
v_out = DSS_NOISE__AMP / 2;
|
||||
if (newval > 0)
|
||||
this->output[0] *= ((double)newval / 16383);
|
||||
v_out *= ((double)newval / 16383);
|
||||
else
|
||||
this->output[0] *= ((double)newval / 16384);
|
||||
v_out *= ((double)newval / 16384);
|
||||
|
||||
/* Add DC Bias component */
|
||||
this->output[0] += DSS_NOISE__BIAS;
|
||||
v_out += DSS_NOISE__BIAS;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/* Keep the new phasor in the 2Pi range.*/
|
||||
@ -498,6 +512,7 @@ DISCRETE_STEP(dss_note)
|
||||
double cycles;
|
||||
int clock = 0, last_count2, inc = 0;
|
||||
double x_time = 0;
|
||||
double v_out;
|
||||
|
||||
if (m_clock_type == DISC_CLK_IS_FREQ)
|
||||
{
|
||||
@ -557,7 +572,7 @@ DISCRETE_STEP(dss_note)
|
||||
}
|
||||
}
|
||||
|
||||
this->output[0] = m_count2;
|
||||
v_out = m_count2;
|
||||
if (m_count2 != last_count2)
|
||||
{
|
||||
/* the x_time is only output if the output changed. */
|
||||
@ -565,20 +580,21 @@ DISCRETE_STEP(dss_note)
|
||||
{
|
||||
case DISC_OUT_IS_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = last_count2;
|
||||
v_out = last_count2;
|
||||
if (m_count2 > last_count2)
|
||||
this->output[0] += (m_count2 - last_count2) * x_time;
|
||||
v_out += (m_count2 - last_count2) * x_time;
|
||||
else
|
||||
this->output[0] -= (last_count2 - m_count2) * x_time;
|
||||
v_out -= (last_count2 - m_count2) * x_time;
|
||||
break;
|
||||
case DISC_OUT_HAS_XTIME:
|
||||
this->output[0] += x_time;
|
||||
v_out += x_time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
set_output(0, v_out);
|
||||
}
|
||||
else
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dss_note)
|
||||
@ -594,7 +610,7 @@ DISCRETE_RESET(dss_note)
|
||||
m_count2 = 0;
|
||||
m_max1 = (int)DSS_NOTE__MAX1;
|
||||
m_max2 = (int)DSS_NOTE__MAX2;
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
@ -637,6 +653,8 @@ DISCRETE_STEP(dss_op_amp_osc)
|
||||
int count_f = 0;
|
||||
int count_r = 0;
|
||||
|
||||
double v_out = 0;
|
||||
|
||||
dt = this->sample_time(); /* Change in time */
|
||||
v_cap = m_v_cap; /* Set to voltage before change */
|
||||
|
||||
@ -741,7 +759,7 @@ DISCRETE_STEP(dss_op_amp_osc)
|
||||
if (!enable)
|
||||
{
|
||||
/* we will just output 0 for oscillators that have no real enable. */
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -851,29 +869,30 @@ DISCRETE_STEP(dss_op_amp_osc)
|
||||
switch (m_output_type)
|
||||
{
|
||||
case DISC_OP_AMP_OSCILLATOR_OUT_CAP:
|
||||
this->output[0] = v_cap;
|
||||
v_out = v_cap;
|
||||
break;
|
||||
case DISC_OP_AMP_OSCILLATOR_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
this->output[0] = m_v_out_high * (flip_flop ? x_time : (1.0 - x_time));
|
||||
v_out = m_v_out_high * (flip_flop ? x_time : (1.0 - x_time));
|
||||
break;
|
||||
case DISC_OP_AMP_OSCILLATOR_OUT_SQW:
|
||||
if (count_f + count_r >= 2)
|
||||
/* force at least 1 toggle */
|
||||
this->output[0] = m_flip_flop ? 0 : m_v_out_high;
|
||||
v_out = m_flip_flop ? 0 : m_v_out_high;
|
||||
else
|
||||
this->output[0] = flip_flop * m_v_out_high;
|
||||
v_out = flip_flop * m_v_out_high;
|
||||
break;
|
||||
case DISC_OP_AMP_OSCILLATOR_OUT_COUNT_F_X:
|
||||
this->output[0] = count_f ? count_f + x_time : count_f;
|
||||
v_out = count_f ? count_f + x_time : count_f;
|
||||
break;
|
||||
case DISC_OP_AMP_OSCILLATOR_OUT_COUNT_R_X:
|
||||
this->output[0] = count_r ? count_r + x_time : count_r;
|
||||
v_out = count_r ? count_r + x_time : count_r;
|
||||
break;
|
||||
case DISC_OP_AMP_OSCILLATOR_OUT_LOGIC_X:
|
||||
this->output[0] = m_flip_flop + x_time;
|
||||
v_out = m_flip_flop + x_time;
|
||||
break;
|
||||
}
|
||||
set_output(0, v_out);
|
||||
m_flip_flop = flip_flop;
|
||||
}
|
||||
|
||||
@ -1078,17 +1097,20 @@ DISCRETE_RESET(dss_op_amp_osc)
|
||||
|
||||
DISCRETE_STEP(dss_sawtoothwave)
|
||||
{
|
||||
double v_out;
|
||||
|
||||
if(DSS_SAWTOOTHWAVE__ENABLE)
|
||||
{
|
||||
this->output[0] = (m_type == 0) ? m_phase * (DSS_SAWTOOTHWAVE__AMP / (2.0 * M_PI)) : DSS_SAWTOOTHWAVE__AMP - (m_phase * (DSS_SAWTOOTHWAVE__AMP / (2.0 * M_PI)));
|
||||
this->output[0] -= DSS_SAWTOOTHWAVE__AMP / 2.0;
|
||||
v_out = (m_type == 0) ? m_phase * (DSS_SAWTOOTHWAVE__AMP / (2.0 * M_PI)) : DSS_SAWTOOTHWAVE__AMP - (m_phase * (DSS_SAWTOOTHWAVE__AMP / (2.0 * M_PI)));
|
||||
v_out -= DSS_SAWTOOTHWAVE__AMP / 2.0;
|
||||
/* Add DC Bias component */
|
||||
this->output[0] = this->output[0] + DSS_SAWTOOTHWAVE__BIAS;
|
||||
v_out = v_out + DSS_SAWTOOTHWAVE__BIAS;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
v_out = 0;
|
||||
}
|
||||
set_output(0, v_out);
|
||||
|
||||
/* Work out the phase step based on phase/freq & sample rate */
|
||||
/* The enable input only curtails output, phase rotation */
|
||||
@ -1138,6 +1160,7 @@ DISCRETE_STEP(dss_schmitt_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_schmitt_osc_desc)
|
||||
|
||||
double supply, v_cap, new_vCap, t, exponent;
|
||||
double v_out = 0;
|
||||
|
||||
/* We will always oscillate. The enable just affects the output. */
|
||||
v_cap = m_v_cap;
|
||||
@ -1191,19 +1214,20 @@ DISCRETE_STEP(dss_schmitt_osc)
|
||||
switch (m_enable_type)
|
||||
{
|
||||
case DISC_SCHMITT_OSC_ENAB_IS_AND:
|
||||
this->output[0] = DSS_SCHMITT_OSC__ENABLE && m_state;
|
||||
v_out = DSS_SCHMITT_OSC__ENABLE && m_state;
|
||||
break;
|
||||
case DISC_SCHMITT_OSC_ENAB_IS_NAND:
|
||||
this->output[0] = !(DSS_SCHMITT_OSC__ENABLE && m_state);
|
||||
v_out = !(DSS_SCHMITT_OSC__ENABLE && m_state);
|
||||
break;
|
||||
case DISC_SCHMITT_OSC_ENAB_IS_OR:
|
||||
this->output[0] = DSS_SCHMITT_OSC__ENABLE || m_state;
|
||||
v_out = DSS_SCHMITT_OSC__ENABLE || m_state;
|
||||
break;
|
||||
case DISC_SCHMITT_OSC_ENAB_IS_NOR:
|
||||
this->output[0] = !(DSS_SCHMITT_OSC__ENABLE || m_state);
|
||||
v_out = !(DSS_SCHMITT_OSC__ENABLE || m_state);
|
||||
break;
|
||||
}
|
||||
this->output[0] *= DSS_SCHMITT_OSC__AMP;
|
||||
v_out *= DSS_SCHMITT_OSC__AMP;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dss_schmitt_osc)
|
||||
@ -1230,7 +1254,7 @@ DISCRETE_RESET(dss_schmitt_osc)
|
||||
m_v_cap = 0;
|
||||
m_state = 1;
|
||||
|
||||
this->output[0] = info->options ? 0 : DSS_SCHMITT_OSC__AMP;
|
||||
set_output(0, info->options ? 0 : DSS_SCHMITT_OSC__AMP);
|
||||
}
|
||||
|
||||
|
||||
@ -1256,13 +1280,12 @@ DISCRETE_STEP(dss_sinewave)
|
||||
/* Set the output */
|
||||
if(DSS_SINEWAVE__ENABLE)
|
||||
{
|
||||
this->output[0] = (DSS_SINEWAVE__AMPL / 2.0) * sin(m_phase);
|
||||
set_output(0, (DSS_SINEWAVE__AMPL / 2.0) * sin(m_phase) + DSS_SINEWAVE__BIAS);
|
||||
/* Add DC Bias component */
|
||||
this->output[0] = this->output[0] + DSS_SINEWAVE__BIAS;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/* Work out the phase step based on phase/freq & sample rate */
|
||||
@ -1316,16 +1339,14 @@ DISCRETE_STEP(dss_squarewave)
|
||||
if(DSS_SQUAREWAVE__ENABLE)
|
||||
{
|
||||
if(m_phase>m_trigger)
|
||||
this->output[0] = DSS_SQUAREWAVE__AMP /2.0;
|
||||
set_output(0, DSS_SQUAREWAVE__AMP / 2.0 + DSS_SQUAREWAVE__BIAS);
|
||||
else
|
||||
this->output[0] =- DSS_SQUAREWAVE__AMP / 2.0;
|
||||
|
||||
set_output(0, - DSS_SQUAREWAVE__AMP / 2.0 + DSS_SQUAREWAVE__BIAS);
|
||||
/* Add DC Bias component */
|
||||
this->output[0] = this->output[0] + DSS_SQUAREWAVE__BIAS;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/* Work out the phase step based on phase/freq & sample rate */
|
||||
@ -1389,11 +1410,11 @@ DISCRETE_STEP(dss_squarewfix)
|
||||
m_t_on = m_t_off * (DSS_SQUAREWFIX__DUTY / 100.0);
|
||||
m_t_off -= m_t_on;
|
||||
|
||||
this->output[0] = (m_flip_flop ? DSS_SQUAREWFIX__AMP / 2.0 : -(DSS_SQUAREWFIX__AMP / 2.0)) + DSS_SQUAREWFIX__BIAS;
|
||||
set_output(0, (m_flip_flop ? DSS_SQUAREWFIX__AMP / 2.0 : -(DSS_SQUAREWFIX__AMP / 2.0)) + DSS_SQUAREWFIX__BIAS);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0]=0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1464,17 +1485,15 @@ DISCRETE_STEP(dss_squarewave2)
|
||||
/* Keep the new phasor in the 2Pi range.*/
|
||||
m_phase = fmod(newphase, 2.0 * M_PI);
|
||||
|
||||
if(m_phase>m_trigger)
|
||||
this->output[0] = DSS_SQUAREWAVE2__AMP / 2.0;
|
||||
else
|
||||
this->output[0] = -DSS_SQUAREWAVE2__AMP / 2.0;
|
||||
|
||||
/* Add DC Bias component */
|
||||
this->output[0] = this->output[0] + DSS_SQUAREWAVE2__BIAS;
|
||||
if(m_phase>m_trigger)
|
||||
set_output(0, DSS_SQUAREWAVE2__AMP / 2.0 + DSS_SQUAREWAVE2__BIAS);
|
||||
else
|
||||
set_output(0, -DSS_SQUAREWAVE2__AMP / 2.0 + DSS_SQUAREWAVE2__BIAS);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1541,6 +1560,7 @@ DISCRETE_STEP(dss_inverter_osc)
|
||||
double diff, vG1, vG2, vG3, vI;
|
||||
double vMix, rMix;
|
||||
int clamped;
|
||||
double v_out;
|
||||
|
||||
/* Get new state */
|
||||
vI = mc_v_cap + mc_v_g2_old;
|
||||
@ -1638,14 +1658,19 @@ DISCRETE_STEP(dss_inverter_osc)
|
||||
default:
|
||||
fatalerror("DISCRETE_INVERTER_OSC - Wrong type on NODE_%02d", this->index());
|
||||
}
|
||||
|
||||
mc_v_cap += diff;
|
||||
mc_v_g2_old = vG2;
|
||||
|
||||
if ((info->options & TYPE_MASK) == IS_TYPE3)
|
||||
this->output[0] = vG1;
|
||||
v_out = vG1;
|
||||
else
|
||||
this->output[0] = vG3;
|
||||
v_out = vG3;
|
||||
|
||||
if (info->options & OUT_IS_LOGIC)
|
||||
this->output[0] = (this->output[0] > info->vInFall);
|
||||
v_out = (v_out > info->vInFall);
|
||||
|
||||
set_output(0, v_out);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(dss_inverter_osc)
|
||||
@ -1657,7 +1682,7 @@ DISCRETE_RESET(dss_inverter_osc)
|
||||
/* exponent */
|
||||
mc_w = exp(-this->sample_time() / (I_RC() * I_C()));
|
||||
mc_wc = exp(-this->sample_time() / ((I_RC() * I_RP()) / (I_RP() + I_RC()) * I_C()));
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
mc_v_cap = 0;
|
||||
mc_v_g2_old = 0;
|
||||
mc_rp = I_RP();
|
||||
@ -1695,15 +1720,16 @@ DISCRETE_STEP(dss_trianglewave)
|
||||
{
|
||||
if(DSS_TRIANGLEWAVE__ENABLE)
|
||||
{
|
||||
this->output[0] = m_phase < M_PI ? (DSS_TRIANGLEWAVE__AMP * (m_phase / (M_PI / 2.0) - 1.0)) / 2.0 :
|
||||
double v_out = m_phase < M_PI ? (DSS_TRIANGLEWAVE__AMP * (m_phase / (M_PI / 2.0) - 1.0)) / 2.0 :
|
||||
(DSS_TRIANGLEWAVE__AMP * (3.0 - m_phase / (M_PI / 2.0))) / 2.0 ;
|
||||
|
||||
/* Add DC Bias component */
|
||||
this->output[0] = this->output[0] + DSS_TRIANGLEWAVE__BIAS;
|
||||
v_out += DSS_TRIANGLEWAVE__BIAS;
|
||||
set_output(0, v_out);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
|
||||
/* Work out the phase step based on phase/freq & sample rate */
|
||||
@ -1745,11 +1771,11 @@ DISCRETE_STEP(dss_adsrenv)
|
||||
{
|
||||
if(DSS_ADSR__ENABLE)
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ discrete_base_node::discrete_base_node() :
|
||||
m_step_intf(NULL),
|
||||
m_input_intf(NULL)
|
||||
{
|
||||
output[0] = 0.0;
|
||||
m_output[0] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
@ -387,7 +387,7 @@ void discrete_base_node::init(discrete_device *pdev, const discrete_sound_block
|
||||
void discrete_base_node::save_state(void)
|
||||
{
|
||||
if (m_block->node != NODE_SPECIAL)
|
||||
state_save_register_device_item_array(m_device, m_block->node, output);
|
||||
state_save_register_device_item_array(m_device, m_block->node, m_output);
|
||||
}
|
||||
|
||||
const discrete_base_node *discrete_device::discrete_find_node(int node)
|
||||
@ -415,7 +415,7 @@ void discrete_base_node::resolve_input_nodes(void)
|
||||
if ((NODE_CHILD_NODE_NUM(inputnode) >= node_ref->max_output()) /*&& (node_ref->module_type() != DST_CUSTOM)*/)
|
||||
fatalerror("discrete_start - NODE_%02d referenced non existent output %d on node NODE_%02d", index(), NODE_CHILD_NODE_NUM(inputnode), NODE_INDEX(inputnode));
|
||||
|
||||
m_input[inputnum] = &(node_ref->output[NODE_CHILD_NODE_NUM(inputnode)]); /* Link referenced node out to input */
|
||||
m_input[inputnum] = &(node_ref->m_output[NODE_CHILD_NODE_NUM(inputnode)]); /* Link referenced node out to input */
|
||||
m_input_is_node |= 1 << inputnum; /* Bit flag if input is node */
|
||||
}
|
||||
else
|
||||
@ -447,7 +447,7 @@ const double *discrete_device::node_output_ptr(int onode)
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
return &(node->output[NODE_CHILD_NODE_NUM(onode)]);
|
||||
return &(node->m_output[NODE_CHILD_NODE_NUM(onode)]);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
@ -1001,7 +1001,7 @@ void discrete_device::device_reset()
|
||||
for_each (discrete_base_node **, node, &m_node_list)
|
||||
{
|
||||
/* Fimxe : node_level */
|
||||
(*node)->output[0] = 0;
|
||||
(*node)->m_output[0] = 0;
|
||||
|
||||
(*node)->reset();
|
||||
}
|
||||
@ -1077,7 +1077,7 @@ READ8_MEMBER( discrete_device::read )
|
||||
/* Bring the system up to now */
|
||||
stream_update(m_stream);
|
||||
|
||||
data = (UINT8) node->output[NODE_CHILD_NODE_NUM(offset)];
|
||||
data = (UINT8) node->m_output[NODE_CHILD_NODE_NUM(offset)];
|
||||
}
|
||||
else
|
||||
fatalerror("discrete_sound_r read from non-existent NODE_%02d\n", offset-NODE_00);
|
||||
|
@ -4290,7 +4290,6 @@ READ8_DEVICE_HANDLER( discrete_sound_r );
|
||||
#define MCFG_DISCRETE_INTF(_intf) \
|
||||
discrete_device_config::static_set_intf(device, (const discrete_sound_block *)&(_intf##_discrete_interface)); \
|
||||
|
||||
|
||||
#define MCFG_SOUND_CONFIG_DISCRETE(name) MCFG_SOUND_CONFIG(name##_discrete_interface)
|
||||
|
||||
//**************************************************************************
|
||||
@ -4441,9 +4440,12 @@ public:
|
||||
inline bool interface(discrete_input_interface *&intf) const { intf = m_input_intf; return (intf != NULL); }
|
||||
inline bool interface(discrete_output_interface *&intf) const { intf = m_output_intf; return (intf != NULL); }
|
||||
|
||||
/* get the input from node #n */
|
||||
/* get the input value from node #n */
|
||||
inline double input(int n) { return *(m_input[n]); }
|
||||
|
||||
/* set an output */
|
||||
inline void set_output(int n, double val) { m_output[n] = val; }
|
||||
|
||||
/* Return the node index, i.e. X from NODE(X) */
|
||||
inline int index(void) { return NODE_INDEX(m_block->node); }
|
||||
|
||||
@ -4476,7 +4478,7 @@ protected:
|
||||
|
||||
void resolve_input_nodes(void);
|
||||
|
||||
double output[DISCRETE_MAX_OUTPUTS]; /* The node's last output value */
|
||||
double m_output[DISCRETE_MAX_OUTPUTS]; /* The node's last output value */
|
||||
const double * m_input[DISCRETE_MAX_INPUTS]; /* Addresses of Input values */
|
||||
discrete_device * m_device; /* Points to the parent */
|
||||
|
||||
|
@ -234,6 +234,7 @@ DISCRETE_CLASS_STEP_RESET(bzone_custom_filter, 1,
|
||||
double m_v_p;
|
||||
double m_exponent;
|
||||
double m_gain[2];
|
||||
double m_out_v;
|
||||
);
|
||||
|
||||
DISCRETE_STEP(bzone_custom_filter)
|
||||
@ -248,7 +249,8 @@ DISCRETE_STEP(bzone_custom_filter)
|
||||
if (v > m_v_p) v = m_v_p;
|
||||
if (v < 0) v = 0;
|
||||
|
||||
this->output[0] += (v - this->output[0]) * m_exponent;
|
||||
m_out_v += (v - m_out_v) * m_exponent;
|
||||
set_output(0, m_out_v);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(bzone_custom_filter)
|
||||
@ -260,7 +262,7 @@ DISCRETE_RESET(bzone_custom_filter)
|
||||
m_v_in1_gain = RES_VOLTAGE_DIVIDER(BZONE_CUSTOM_FILTER__R3, BZONE_CUSTOM_FILTER__R4);
|
||||
m_v_p = BZONE_CUSTOM_FILTER__VP - OP_AMP_VP_RAIL_OFFSET;
|
||||
m_exponent = RC_CHARGE_EXP(BZONE_CUSTOM_FILTER__R5 * BZONE_CUSTOM_FILTER__C);;
|
||||
this->output[0] = 0;
|
||||
m_out_v = 0.0;
|
||||
}
|
||||
|
||||
/*************************************
|
||||
|
@ -318,13 +318,13 @@ DISCRETE_STEP(copsnrob_custom_noise)
|
||||
new_noise_bit = (low_byte >> 4) & 0x01;
|
||||
if (last_noise1_bit != new_noise_bit)
|
||||
{
|
||||
this->output[0] = COPSNROB_CUSTOM_NOISE_HIGH * (new_noise_bit ? x_time : (1.0 - x_time));
|
||||
set_output(0, COPSNROB_CUSTOM_NOISE_HIGH * (new_noise_bit ? x_time : (1.0 - x_time)));
|
||||
m_noise1_had_xtime = 1;
|
||||
}
|
||||
new_noise_bit = (low_byte >> 5) & 0x01;
|
||||
if (last_noise2_bit != new_noise_bit)
|
||||
{
|
||||
this->output[1] = COPSNROB_CUSTOM_NOISE_HIGH * (new_noise_bit ? x_time : (1.0 - x_time));
|
||||
set_output(1, COPSNROB_CUSTOM_NOISE_HIGH * (new_noise_bit ? x_time : (1.0 - x_time)));
|
||||
m_noise2_had_xtime = 1;
|
||||
}
|
||||
}
|
||||
@ -334,12 +334,12 @@ DISCRETE_STEP(copsnrob_custom_noise)
|
||||
/* see if we need to move from x_time state to full state */
|
||||
if (m_noise1_had_xtime)
|
||||
{
|
||||
this->output[0] = COPSNROB_CUSTOM_NOISE_HIGH * last_noise1_bit;
|
||||
set_output(0, COPSNROB_CUSTOM_NOISE_HIGH * last_noise1_bit);
|
||||
m_noise1_had_xtime = 0;
|
||||
}
|
||||
if (m_noise2_had_xtime)
|
||||
{
|
||||
this->output[1] = COPSNROB_CUSTOM_NOISE_HIGH * last_noise2_bit;
|
||||
set_output(1, COPSNROB_CUSTOM_NOISE_HIGH * last_noise2_bit);
|
||||
m_noise2_had_xtime = 0;
|
||||
}
|
||||
}
|
||||
@ -435,11 +435,11 @@ DISCRETE_STEP(copsnrob_zings_555_monostable)
|
||||
m_v_cap = v_cap;
|
||||
|
||||
if (x_time > 0)
|
||||
this->output[0] = v_out_high * x_time;
|
||||
set_output(0, v_out_high * x_time);
|
||||
else if (flip_flop)
|
||||
this->output[0] = v_out_high;
|
||||
set_output(0, v_out_high);
|
||||
else
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0.0);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(copsnrob_zings_555_monostable)
|
||||
@ -448,7 +448,7 @@ DISCRETE_RESET(copsnrob_zings_555_monostable)
|
||||
m_exponent = RC_CHARGE_EXP(m_rc);
|
||||
m_v_cap = 0;
|
||||
m_flip_flop = 0;
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0.0);
|
||||
}
|
||||
|
||||
/************************************************
|
||||
@ -483,7 +483,7 @@ DISCRETE_STEP(copsnrob_zings_555_astable)
|
||||
double v_trigger, v_threshold;
|
||||
double v1 = COPSNROB_CUSTOM_ZINGS_555_ASTABLE__RESET;
|
||||
double v_cap1 = m_v_cap1;
|
||||
double v_cap2 = this->output[0];
|
||||
double v_cap2 = m_v_cap2;
|
||||
double dt = 0;
|
||||
int reset_active = (v1 < 0.7) ? 1 : 0;
|
||||
int flip_flop = m_flip_flop;
|
||||
@ -516,9 +516,9 @@ DISCRETE_STEP(copsnrob_zings_555_astable)
|
||||
v_cap2 -= v_cap2 * m_exponent2;
|
||||
/* Optimization - close enough to 0 to be 0 */
|
||||
if (v_cap2 < 0.000001)
|
||||
this->output[0] = 0;
|
||||
set_output(0, 0.0);
|
||||
else
|
||||
this->output[0] = v_cap2;
|
||||
set_output(0, v_cap2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -565,9 +565,10 @@ DISCRETE_STEP(copsnrob_zings_555_astable)
|
||||
}
|
||||
}
|
||||
if (v_cap2 > 0)
|
||||
this->output[0] = v_cap2;
|
||||
m_v_cap2 = v_cap2;
|
||||
else
|
||||
this->output[0] = 0;
|
||||
m_v_cap2 = 0.0;
|
||||
set_output(0, m_v_cap2);
|
||||
}
|
||||
|
||||
DISCRETE_RESET(copsnrob_zings_555_astable)
|
||||
@ -578,7 +579,7 @@ DISCRETE_RESET(copsnrob_zings_555_astable)
|
||||
m_exponent2 = RC_CHARGE_EXP(m_r2c2);
|
||||
m_v_cap1 = 0;
|
||||
m_flip_flop = 0;
|
||||
this->output[0] = 0; /* charge on C2 */
|
||||
m_v_cap2 = 0.0; /* charge on C2 */
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,6 +299,7 @@ DISCRETE_CLASS_STEP_RESET(dkong_custom_mixer, 1,
|
||||
double m_r_in[2];
|
||||
double m_r_total[2];
|
||||
double m_exp[2];
|
||||
double m_out_v;
|
||||
);
|
||||
|
||||
DISCRETE_STEP( dkong_custom_mixer )
|
||||
@ -313,7 +314,8 @@ DISCRETE_STEP( dkong_custom_mixer )
|
||||
i_total += DKONG_CUSTOM_IN2 / DKONG_CUSTOM_R3;
|
||||
/* charge cap */
|
||||
/* node->output is cap voltage, (i_total * m_r_total[in_1]) is current charge voltage */
|
||||
this->output[0] += (i_total * m_r_total[in_1] - this->output[0]) * m_exp[in_1];
|
||||
m_out_v += (i_total * m_r_total[in_1] - m_out_v) * m_exp[in_1];
|
||||
set_output(0, m_out_v);
|
||||
}
|
||||
|
||||
#define NE555_CV_R RES_2_PARALLEL(RES_K(5), RES_K(10))
|
||||
@ -334,7 +336,7 @@ DISCRETE_RESET( dkong_custom_mixer )
|
||||
m_exp[0] = RC_CHARGE_EXP(m_r_total[0] * DKONG_CUSTOM_C);
|
||||
m_exp[1] = RC_CHARGE_EXP(m_r_total[1] * DKONG_CUSTOM_C);
|
||||
|
||||
this->output[0] = 0;
|
||||
m_out_v = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -157,7 +157,7 @@ DISCRETE_STEP( skyraid_missle_custom_charge )
|
||||
/* charge/discharge cap */
|
||||
m_v_cap += (m_v_charge[in_1] - m_v_cap) * m_exp[in_1];
|
||||
|
||||
this->output[0] = SKYRAID_MISSLE_CHARGE_PLUS - m_v_cap;
|
||||
set_output(0, SKYRAID_MISSLE_CHARGE_PLUS - m_v_cap);
|
||||
}
|
||||
|
||||
DISCRETE_RESET( skyraid_missle_custom_charge )
|
||||
@ -177,7 +177,7 @@ DISCRETE_RESET( skyraid_missle_custom_charge )
|
||||
m_exp[1] = RC_CHARGE_EXP(RES_2_PARALLEL(SKYRAID_MISSLE_CUSTOM_R1 + SKYRAID_MISSLE_CUSTOM_R2, SKYRAID_MISSLE_CUSTOM_R3) * SKYRAID_MISSLE_CUSTOM_C);
|
||||
|
||||
/* starts at full voltage until cap starts charging */
|
||||
this->output[0] = SKYRAID_MISSLE_CHARGE_PLUS;
|
||||
set_output(0, SKYRAID_MISSLE_CHARGE_PLUS);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user