mirror of
https://github.com/holub/mame
synced 2025-05-28 16:43:04 +03:00
Discrete Updates [Derrick Renaud]
Removed old DISCRETE_74LS624 code and replaced it with new 74LS629 based code. Updated Mario to use new DISCRETE_74LS624 and DISCRETE_XTIME_logic modules. ---- Some not whats.new stuff: I also fixed the regression to Galaxian. I made a DISCRETE_DECLARE_CONTEXT() macro to clean up the discrete module code and make it easier for any future possible C++ conversion.
This commit is contained in:
parent
411f90023d
commit
13c39be494
@ -14,8 +14,7 @@
|
||||
* DSD_555_CC - NE555 Constant Current VCO
|
||||
* DSD_555_VCO1 - Op-Amp linear ramp based 555 VCO
|
||||
* DSD_566 - NE566 Simulation
|
||||
* DSD_LS624
|
||||
* DSD_LS629
|
||||
* DSD_LS624 - 74LS624/629 Simulation
|
||||
*
|
||||
************************************************************************
|
||||
*
|
||||
@ -126,21 +125,12 @@ struct dsd_566_context
|
||||
};
|
||||
|
||||
struct dsd_ls624_context
|
||||
{
|
||||
int state;
|
||||
double remain; /* remaining time from last step */
|
||||
int out_type;
|
||||
double k1; /* precalculated cap part of formula */
|
||||
double k2; /* precalculated ring part of formula */
|
||||
double dt_vmod_at_0;
|
||||
};
|
||||
|
||||
struct dsd_ls629_context
|
||||
{
|
||||
double exponent;
|
||||
double t_used;
|
||||
double vmod_scale;
|
||||
double v_cap_freq_in;
|
||||
double v_freq_scale;
|
||||
double v_rng_scale;
|
||||
int flip_flop;
|
||||
int has_freq_in_cap;
|
||||
int out_type;
|
||||
@ -176,10 +166,10 @@ struct dsd_ls629_context
|
||||
#define DSD_555_ASTBL_T_RC_CHARGE ((DSD_555_ASTBL__R1 + ((info->options & DISC_555_ASTABLE_HAS_FAST_CHARGE_DIODE) ? 0 : DSD_555_ASTBL__R2)) * DSD_555_ASTBL__C)
|
||||
#define DSD_555_ASTBL_T_RC_DISCHARGE (DSD_555_ASTBL__R2 * DSD_555_ASTBL__C)
|
||||
|
||||
static DISCRETE_STEP(dsd_555_astbl)
|
||||
DISCRETE_STEP(dsd_555_astbl)
|
||||
{
|
||||
const discrete_555_desc *info = (const discrete_555_desc *)node->custom;
|
||||
struct dsd_555_astbl_context *context = (struct dsd_555_astbl_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_astbl)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_desc)
|
||||
|
||||
int count_f = 0;
|
||||
int count_r = 0;
|
||||
@ -402,10 +392,11 @@ static DISCRETE_STEP(dsd_555_astbl)
|
||||
context->flip_flop = flip_flop;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dsd_555_astbl)
|
||||
DISCRETE_RESET(dsd_555_astbl)
|
||||
{
|
||||
const discrete_555_desc *info = (const discrete_555_desc *)node->custom;
|
||||
struct dsd_555_astbl_context *context = (struct dsd_555_astbl_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_astbl)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_desc)
|
||||
|
||||
node_description *v_charge_node;
|
||||
|
||||
context->use_ctrlv = (node->input_is_node >> 4) & 1;
|
||||
@ -486,10 +477,10 @@ static DISCRETE_RESET(dsd_555_astbl)
|
||||
/* bit mask of the above RC inputs */
|
||||
#define DSD_555_MSTBL_RC_MASK 0x0c
|
||||
|
||||
static DISCRETE_STEP(dsd_555_mstbl)
|
||||
DISCRETE_STEP(dsd_555_mstbl)
|
||||
{
|
||||
const discrete_555_desc *info = (const discrete_555_desc *)node->custom;
|
||||
struct dsd_555_mstbl_context *context = (struct dsd_555_mstbl_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_mstbl)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_desc)
|
||||
|
||||
double v_cap; /* Current voltage on capacitor, before dt */
|
||||
double v_cap_next = 0; /* Voltage on capacitor, after dt */
|
||||
@ -606,10 +597,10 @@ static DISCRETE_STEP(dsd_555_mstbl)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dsd_555_mstbl)
|
||||
DISCRETE_RESET(dsd_555_mstbl)
|
||||
{
|
||||
const discrete_555_desc *info = (const discrete_555_desc *)node->custom;
|
||||
struct dsd_555_mstbl_context *context = (struct dsd_555_mstbl_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_mstbl)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_desc)
|
||||
|
||||
context->output_type = info->options & DISC_555_OUT_MASK;
|
||||
if ((context->output_type == DISC_555_OUT_COUNT_F) || (context->output_type == DISC_555_OUT_COUNT_R))
|
||||
@ -682,10 +673,10 @@ static DISCRETE_RESET(dsd_555_mstbl)
|
||||
#define DSD_555_CC_T_RC_DISCHARGE (r_discharge * DSD_555_CC__C)
|
||||
|
||||
|
||||
static DISCRETE_STEP(dsd_555_cc)
|
||||
DISCRETE_STEP(dsd_555_cc)
|
||||
{
|
||||
const discrete_555_cc_desc *info = (const discrete_555_cc_desc *)node->custom;
|
||||
struct dsd_555_cc_context *context = (struct dsd_555_cc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_cc)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_cc_desc)
|
||||
|
||||
int count_f = 0;
|
||||
int count_r = 0;
|
||||
@ -1003,10 +994,10 @@ static DISCRETE_STEP(dsd_555_cc)
|
||||
context->flip_flop = flip_flop;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dsd_555_cc)
|
||||
DISCRETE_RESET(dsd_555_cc)
|
||||
{
|
||||
const discrete_555_cc_desc *info = (const discrete_555_cc_desc *)node->custom;
|
||||
struct dsd_555_cc_context *context = (struct dsd_555_cc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_cc)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_cc_desc)
|
||||
|
||||
double r_temp, r_discharge = 0, r_charge = 0;
|
||||
|
||||
@ -1233,10 +1224,10 @@ static DISCRETE_RESET(dsd_555_cc)
|
||||
#define DSD_555_VCO1__VIN1 DISCRETE_INPUT(1)
|
||||
#define DSD_555_VCO1__VIN2 DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dsd_555_vco1)
|
||||
DISCRETE_STEP(dsd_555_vco1)
|
||||
{
|
||||
const discrete_555_vco1_desc *info = (const discrete_555_vco1_desc *)node->custom;
|
||||
struct dsd_555_vco1_context *context = (struct dsd_555_vco1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_vco1)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_vco1_desc)
|
||||
|
||||
int count_f = 0;
|
||||
int count_r = 0;
|
||||
@ -1386,10 +1377,10 @@ static DISCRETE_STEP(dsd_555_vco1)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dsd_555_vco1)
|
||||
DISCRETE_RESET(dsd_555_vco1)
|
||||
{
|
||||
const discrete_555_vco1_desc *info = (const discrete_555_vco1_desc *)node->custom;
|
||||
struct dsd_555_vco1_context *context = (struct dsd_555_vco1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_555_vco1)
|
||||
DISCRETE_DECLARE_INFO(discrete_555_vco1_desc)
|
||||
|
||||
double v_ratio_r3, v_ratio_r4_1, r_in_1;
|
||||
|
||||
@ -1524,9 +1515,9 @@ static const struct
|
||||
{4.495, /*4.895,*/ 5.343, /*5.703,*/ 5.997, 6.507, 7.016, 7.518} /* osc_stop */
|
||||
};
|
||||
|
||||
static DISCRETE_STEP(dsd_566)
|
||||
DISCRETE_STEP(dsd_566)
|
||||
{
|
||||
struct dsd_566_context *context = (struct dsd_566_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_566)
|
||||
|
||||
double i = 0; /* Charging current created by vIn */
|
||||
double i_rise; /* non-linear rise charge current */
|
||||
@ -1646,9 +1637,9 @@ static DISCRETE_STEP(dsd_566)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dsd_566)
|
||||
DISCRETE_RESET(dsd_566)
|
||||
{
|
||||
struct dsd_566_context *context = (struct dsd_566_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_566)
|
||||
|
||||
int v_int;
|
||||
double v_float;
|
||||
@ -1697,130 +1688,21 @@ static DISCRETE_RESET(dsd_566)
|
||||
*
|
||||
* DSD_LS624 - Usage of node_description values
|
||||
*
|
||||
* input[0] - Modulation Voltage
|
||||
* input[1] - Range Voltage
|
||||
* input[2] - C value
|
||||
* input[3] - Output type
|
||||
*
|
||||
* Dec 2007, Couriersud
|
||||
************************************************************************/
|
||||
#define DSD_LS624__VMOD DISCRETE_INPUT(0)
|
||||
#define DSD_LS624__VRNG DISCRETE_INPUT(1)
|
||||
#define DSD_LS624__C DISCRETE_INPUT(2)
|
||||
#define DSD_LS624__OUTTYPE DISCRETE_INPUT(3)
|
||||
|
||||
/*
|
||||
* The datasheet mentions a 600 ohm discharge. It also gives
|
||||
* equivalent circuits for VI and VR.
|
||||
*/
|
||||
|
||||
#define LS624_F1(x) (0.19 + 20.0/90.0*(x))
|
||||
#define LS624_T(_C, _R, _F) ((-600.0 * (_C) * log(1.0-LS624_F1(_R)*0.12/LS624_F1(_F))) * 16.0 )
|
||||
|
||||
/* The following formula was derived from figures 2 and 3 in LS624 datasheet. Coefficients
|
||||
* where calculated using least square approximation.
|
||||
* This approach gives a bit better results compared to the first approach.
|
||||
*/
|
||||
/* Original formula before optimization of static values
|
||||
#define LS624_F(_C, _VI, _VR) pow(10, -0.912029404 * log10(_C) + 0.243264328 * (_VI) \
|
||||
- 0.091695877 * (_VR) -0.014110946 * (_VI) * (_VR) - 3.207072925)
|
||||
*/
|
||||
|
||||
/* pow(10, x) = exp(ln(10)*x) */
|
||||
#define pow10(x) exp(2.30258509299404568401*(x))
|
||||
|
||||
#define LS624_F(_VI) pow10(context->k1 + 0.243264328 * (_VI) + context->k2 * (_VI))
|
||||
|
||||
static DISCRETE_STEP(dsd_ls624)
|
||||
{
|
||||
struct dsd_ls624_context *context = (struct dsd_ls624_context *)node->context;
|
||||
|
||||
double dt; /* change in time */
|
||||
double sample_t;
|
||||
double t;
|
||||
double en = 0.0f;
|
||||
int cntf = 0, cntr = 0;
|
||||
|
||||
sample_t = node->info->sample_time; /* Change in time */
|
||||
//dt = LS624_T(DSD_LS624__C, DSD_LS624__VRNG, DSD_LS624__VMOD) / 2.0;
|
||||
if (EXPECTED(DSD_LS624__VMOD > 0.001))
|
||||
dt = 0.5 / LS624_F(DSD_LS624__VMOD);
|
||||
else
|
||||
/* close enough to 0, so we can speed things up by no longer call pow() */
|
||||
dt = context->dt_vmod_at_0;
|
||||
t = context->remain;
|
||||
en += (double) context->state * t;
|
||||
while (EXPECTED(t + dt <= sample_t))
|
||||
{
|
||||
en += (double) context->state * dt;
|
||||
context->state = (1 - context->state);
|
||||
if (context->state)
|
||||
cntr++;
|
||||
else
|
||||
cntf++;
|
||||
t += dt;
|
||||
}
|
||||
en += (sample_t - t) * (double) context->state;
|
||||
context->remain = t - sample_t;
|
||||
|
||||
switch (context->out_type)
|
||||
{
|
||||
case DISC_LS624_OUT_ENERGY:
|
||||
node->output[0] = en / sample_t;
|
||||
break;
|
||||
case DISC_LS624_OUT_LOGIC:
|
||||
/* filter out randomness */
|
||||
if (UNEXPECTED(cntf + cntr > 1))
|
||||
node->output[0] = 1;
|
||||
else
|
||||
node->output[0] = context->state;
|
||||
break;
|
||||
case DISC_LS624_OUT_COUNT_F:
|
||||
node->output[0] = cntf;
|
||||
break;
|
||||
case DISC_LS624_OUT_COUNT_R:
|
||||
node->output[0] = cntr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dsd_ls624)
|
||||
{
|
||||
struct dsd_ls624_context *context = (struct dsd_ls624_context *)node->context;
|
||||
|
||||
context->remain = 0;
|
||||
context->state = 0;
|
||||
context->out_type = DSD_LS624__OUTTYPE;
|
||||
|
||||
/* precalculate some parts of the formula for speed */
|
||||
context->k1 = -0.912029404 * log10(DSD_LS624__C) -0.091695877 * (DSD_LS624__VRNG) - 3.207072925;
|
||||
context->k2 = -0.014110946 * (DSD_LS624__VRNG);
|
||||
|
||||
context->dt_vmod_at_0 = 0.5 / LS624_F(0);
|
||||
|
||||
/* Step the output */
|
||||
DISCRETE_STEP_CALL(dsd_ls624);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* DSD_LS629 - Usage of node_description values
|
||||
*
|
||||
* Dec 2007, Couriersud based on data sheet
|
||||
* Oct 2009, complete re-write based on IC testing
|
||||
************************************************************************/
|
||||
#define DSD_LS629__ENABLE DISCRETE_INPUT(0)
|
||||
#define DSD_LS629__VMOD DISCRETE_INPUT(1)
|
||||
#define DSD_LS629__VRNG DISCRETE_INPUT(2)
|
||||
#define DSD_LS629__C DISCRETE_INPUT(3)
|
||||
#define DSD_LS629__R_FREQ_IN DISCRETE_INPUT(4)
|
||||
#define DSD_LS629__C_FREQ_IN DISCRETE_INPUT(5)
|
||||
#define DSD_LS629__OUTTYPE DISCRETE_INPUT(6)
|
||||
#define DSD_LS624__ENABLE DISCRETE_INPUT(0)
|
||||
#define DSD_LS624__VMOD DISCRETE_INPUT(1)
|
||||
#define DSD_LS624__VRNG DISCRETE_INPUT(2)
|
||||
#define DSD_LS624__C DISCRETE_INPUT(3)
|
||||
#define DSD_LS624__R_FREQ_IN DISCRETE_INPUT(4)
|
||||
#define DSD_LS624__C_FREQ_IN DISCRETE_INPUT(5)
|
||||
#define DSD_LS624__R_RNG_IN DISCRETE_INPUT(6)
|
||||
#define DSD_LS624__OUTTYPE DISCRETE_INPUT(7)
|
||||
|
||||
#define LS624_R_EXT 600.0 /* as specified in data sheet */
|
||||
#define LS624_OUT_HIGH 4.5 /* measured */
|
||||
#define LS624_FREQ_R_IN RES_K(90) /* measured & 70K + 20k per data sheet */
|
||||
#define LS624_IN_R RES_K(90) /* measured & 70K + 20k per data sheet */
|
||||
|
||||
/*
|
||||
* The 74LS624 series are constant current based VCOs. The Freq Control voltage
|
||||
@ -1856,17 +1738,17 @@ static DISCRETE_RESET(dsd_ls624)
|
||||
*/
|
||||
|
||||
|
||||
static DISCRETE_STEP(dsd_ls629)
|
||||
DISCRETE_STEP(dsd_ls624)
|
||||
{
|
||||
struct dsd_ls629_context *context = (struct dsd_ls629_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dsd_ls624)
|
||||
|
||||
double x_time = 0;
|
||||
double freq, t1;
|
||||
double v_freq_2, v_freq_3, v_freq_4;
|
||||
double t_used = context->t_used;
|
||||
double dt = node->info->sample_time;;
|
||||
double vmod = DSD_LS629__VMOD;
|
||||
double vmod_2, vmod_3, vmod_4;
|
||||
double range = DSD_LS629__VRNG;
|
||||
double v_freq = DSD_LS624__VMOD;
|
||||
double v_rng = DSD_LS624__VRNG;
|
||||
int count_f = 0, count_r = 0;
|
||||
|
||||
/* coefficients */
|
||||
@ -1881,36 +1763,36 @@ static DISCRETE_STEP(dsd_ls629)
|
||||
const double k9 = 2.9914575453819188E+00;
|
||||
const double k10 = 1.6855569086173170E+00;
|
||||
|
||||
if (UNEXPECTED(DSD_LS629__ENABLE == 0))
|
||||
if (UNEXPECTED(DSD_LS624__ENABLE == 0))
|
||||
return;
|
||||
|
||||
/* scale due to input resistance */
|
||||
if ((EXPECTED(DSD_LS629__R_FREQ_IN > 0)))
|
||||
vmod *= context->vmod_scale;
|
||||
v_freq *= context->v_freq_scale;
|
||||
v_rng *= context->v_rng_scale;
|
||||
|
||||
/* apply cap if needed */
|
||||
if (context->has_freq_in_cap)
|
||||
{
|
||||
context->v_cap_freq_in += (vmod - context->v_cap_freq_in) * context->exponent;
|
||||
vmod = context->v_cap_freq_in;
|
||||
context->v_cap_freq_in += (v_freq - context->v_cap_freq_in) * context->exponent;
|
||||
v_freq = context->v_cap_freq_in;
|
||||
}
|
||||
|
||||
/* Polyfunctional3D_model created by zunzun.com using sum of squared absolute error */
|
||||
vmod_2 = vmod * vmod;
|
||||
vmod_3 = vmod_2 * vmod;
|
||||
vmod_4 = vmod_3 * vmod;
|
||||
v_freq_2 = v_freq * v_freq;
|
||||
v_freq_3 = v_freq_2 * v_freq;
|
||||
v_freq_4 = v_freq_3 * v_freq;
|
||||
freq = k1;
|
||||
freq += k2 * vmod;
|
||||
freq += k3 * vmod_2;
|
||||
freq += k4 * vmod_3;
|
||||
freq += k5 * vmod_4;
|
||||
freq += k6 * range;
|
||||
freq += k7 * range * vmod;
|
||||
freq += k8 * range * vmod_2;
|
||||
freq += k9 * range * vmod_3;
|
||||
freq += k10 * range * vmod_4;
|
||||
freq += k2 * v_freq;
|
||||
freq += k3 * v_freq_2;
|
||||
freq += k4 * v_freq_3;
|
||||
freq += k5 * v_freq_4;
|
||||
freq += k6 * v_rng;
|
||||
freq += k7 * v_rng * v_freq;
|
||||
freq += k8 * v_rng * v_freq_2;
|
||||
freq += k9 * v_rng * v_freq_3;
|
||||
freq += k10 * v_rng * v_freq_4;
|
||||
|
||||
freq *= CAP_U(0.1) / DSD_LS629__C;
|
||||
freq *= CAP_U(0.1) / DSD_LS624__C;
|
||||
|
||||
t1 = 0.5 / freq ;
|
||||
t_used += node->info->sample_time;
|
||||
@ -1941,16 +1823,6 @@ static DISCRETE_STEP(dsd_ls629)
|
||||
|
||||
switch (context->out_type)
|
||||
{
|
||||
case DISC_LS624_OUT_SQUARE:
|
||||
node->output[0] = context->flip_flop ? LS624_OUT_HIGH : 0;
|
||||
break;
|
||||
case DISC_LS624_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
node->output[0] = LS624_OUT_HIGH * (context->flip_flop ? x_time : (1.0 - x_time));
|
||||
break;
|
||||
case DISC_LS624_OUT_LOGIC:
|
||||
node->output[0] = context->flip_flop;
|
||||
break;
|
||||
case DISC_LS624_OUT_LOGIC_X:
|
||||
node->output[0] = context->flip_flop + x_time;
|
||||
break;
|
||||
@ -1966,22 +1838,33 @@ static DISCRETE_STEP(dsd_ls629)
|
||||
case DISC_LS624_OUT_COUNT_R:
|
||||
node->output[0] = count_r;
|
||||
break;
|
||||
case DISC_LS624_OUT_ENERGY:
|
||||
if (x_time == 0) x_time = 1.0;
|
||||
node->output[0] = LS624_OUT_HIGH * (context->flip_flop ? x_time : (1.0 - x_time));
|
||||
break;
|
||||
case DISC_LS624_OUT_LOGIC:
|
||||
node->output[0] = context->flip_flop;
|
||||
break;
|
||||
case DISC_LS624_OUT_SQUARE:
|
||||
node->output[0] = context->flip_flop ? LS624_OUT_HIGH : 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dsd_ls629)
|
||||
DISCRETE_RESET(dsd_ls624)
|
||||
{
|
||||
struct dsd_ls629_context *context = (struct dsd_ls629_context *)node->context;
|
||||
struct dsd_ls624_context *context = (struct dsd_ls624_context *)node->context;
|
||||
|
||||
context->out_type = (int)DSD_LS629__OUTTYPE;
|
||||
context->out_type = (int)DSD_LS624__OUTTYPE;
|
||||
|
||||
context->flip_flop = 0;
|
||||
context->t_used = 0;
|
||||
context->vmod_scale = RES_K(90) / (DSD_LS629__R_FREQ_IN + RES_K(90));
|
||||
if (DSD_LS629__C_FREQ_IN > 0)
|
||||
context->v_freq_scale = LS624_IN_R / (DSD_LS624__R_FREQ_IN + LS624_IN_R);
|
||||
context->v_rng_scale = LS624_IN_R / (DSD_LS624__R_RNG_IN + LS624_IN_R);
|
||||
if (DSD_LS624__C_FREQ_IN > 0)
|
||||
{
|
||||
context->has_freq_in_cap = 1;
|
||||
context->exponent = RC_CHARGE_EXP(RES_2_PARALLEL(DSD_LS629__R_FREQ_IN, RES_K(90)) * DSD_LS629__C_FREQ_IN);
|
||||
context->exponent = RC_CHARGE_EXP(RES_2_PARALLEL(DSD_LS624__R_FREQ_IN, LS624_IN_R) * DSD_LS624__C_FREQ_IN);
|
||||
context->v_cap_freq_in = 0;
|
||||
}
|
||||
else
|
||||
|
@ -27,7 +27,7 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
struct dss_filter1_context
|
||||
struct dst_filter1_context
|
||||
{
|
||||
double x1; /* x[k-1], previous input value */
|
||||
double y1; /* y[k-1], previous output value */
|
||||
@ -35,7 +35,7 @@ struct dss_filter1_context
|
||||
double b0, b1; /* digital filter coefficients, numerator */
|
||||
};
|
||||
|
||||
struct dss_filter2_context
|
||||
struct dst_filter2_context
|
||||
{
|
||||
double x1, x2; /* x[k-1], x[k-2], previous 2 input values */
|
||||
double y1, y2; /* y[k-1], y[k-2], previous 2 output values */
|
||||
@ -155,9 +155,9 @@ struct dst_rcintegrate_context
|
||||
#define DST_CRFILTER__C DISCRETE_INPUT(2)
|
||||
#define DST_CRFILTER__VREF DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_crfilter)
|
||||
DISCRETE_STEP(dst_crfilter)
|
||||
{
|
||||
struct dst_rcfilter_context *context = (struct dst_rcfilter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcfilter)
|
||||
|
||||
if (UNEXPECTED(context->has_rc_nodes))
|
||||
{
|
||||
@ -174,9 +174,9 @@ static DISCRETE_STEP(dst_crfilter)
|
||||
context->vCap += (node->output[0] - DST_CRFILTER__VREF) * context->exponent;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_crfilter)
|
||||
DISCRETE_RESET(dst_crfilter)
|
||||
{
|
||||
struct dst_rcfilter_context *context = (struct dst_rcfilter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcfilter)
|
||||
|
||||
context->has_rc_nodes = node->input_is_node & 0x6;
|
||||
context->rc = DST_CRFILTER__R * DST_CRFILTER__C;
|
||||
@ -228,9 +228,9 @@ static void calculate_filter1_coefficients(const discrete_info *disc_info, doubl
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dst_filter1)
|
||||
DISCRETE_STEP(dst_filter1)
|
||||
{
|
||||
struct dss_filter1_context *context = (struct dss_filter1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_filter1)
|
||||
|
||||
double gain = 1.0;
|
||||
|
||||
@ -245,9 +245,9 @@ static DISCRETE_STEP(dst_filter1)
|
||||
context->y1 = node->output[0];
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_filter1)
|
||||
DISCRETE_RESET(dst_filter1)
|
||||
{
|
||||
struct dss_filter1_context *context = (struct dss_filter1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_filter1)
|
||||
|
||||
calculate_filter1_coefficients(node->info, DST_FILTER1__FREQ, DST_FILTER1__TYPE, &context->a1, &context->b0, &context->b1);
|
||||
node->output[0] = 0;
|
||||
@ -314,9 +314,9 @@ static void calculate_filter2_coefficients(const discrete_info *disc_info,
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dst_filter2)
|
||||
DISCRETE_STEP(dst_filter2)
|
||||
{
|
||||
struct dss_filter2_context *context = (struct dss_filter2_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_filter2)
|
||||
|
||||
double gain = 1.0;
|
||||
|
||||
@ -334,9 +334,9 @@ static DISCRETE_STEP(dst_filter2)
|
||||
context->y1 = node->output[0];
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_filter2)
|
||||
DISCRETE_RESET(dst_filter2)
|
||||
{
|
||||
struct dss_filter2_context *context = (struct dss_filter2_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_filter2)
|
||||
|
||||
calculate_filter2_coefficients(node->info, DST_FILTER2__FREQ, DST_FILTER2__DAMP, DST_FILTER2__TYPE,
|
||||
&context->a1, &context->a2,
|
||||
@ -363,10 +363,10 @@ static DISCRETE_RESET(dst_filter2)
|
||||
#define DST_OP_AMP_FILT__INP2 DISCRETE_INPUT(2)
|
||||
#define DST_OP_AMP_FILT__TYPE DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_op_amp_filt)
|
||||
DISCRETE_STEP(dst_op_amp_filt)
|
||||
{
|
||||
const discrete_op_amp_filt_info *info = (const discrete_op_amp_filt_info *)node->custom;
|
||||
struct dst_op_amp_filt_context *context = (struct dst_op_amp_filt_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_op_amp_filt)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_filt_info)
|
||||
|
||||
double i, v = 0;
|
||||
|
||||
@ -463,10 +463,10 @@ static DISCRETE_STEP(dst_op_amp_filt)
|
||||
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_op_amp_filt)
|
||||
DISCRETE_RESET(dst_op_amp_filt)
|
||||
{
|
||||
const discrete_op_amp_filt_info *info = (const discrete_op_amp_filt_info *)node->custom;
|
||||
struct dst_op_amp_filt_context *context = (struct dst_op_amp_filt_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_op_amp_filt)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_filt_info)
|
||||
|
||||
/* Convert the passed filter type into an int for easy use. */
|
||||
context->type = (int)DST_OP_AMP_FILT__TYPE & DISC_OP_AMP_FILTER_TYPE_MASK;
|
||||
@ -577,9 +577,9 @@ static DISCRETE_RESET(dst_op_amp_filt)
|
||||
|
||||
#define CD4066_R_ON 270
|
||||
|
||||
static DISCRETE_STEP( dst_rc_circuit_1 )
|
||||
DISCRETE_STEP( dst_rc_circuit_1 )
|
||||
{
|
||||
struct dst_rc_circuit_1_context *context = (struct dst_rc_circuit_1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rc_circuit_1)
|
||||
|
||||
if (DST_RC_CIRCUIT_1__IN0 == 0)
|
||||
if (DST_RC_CIRCUIT_1__IN1 == 0)
|
||||
@ -608,9 +608,9 @@ static DISCRETE_STEP( dst_rc_circuit_1 )
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET( dst_rc_circuit_1 )
|
||||
DISCRETE_RESET( dst_rc_circuit_1 )
|
||||
{
|
||||
struct dst_rc_circuit_1_context *context = (struct dst_rc_circuit_1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rc_circuit_1)
|
||||
|
||||
/* the charging voltage across the cap based on in2*/
|
||||
context->v_drop = RES_VOLTAGE_DIVIDER(CD4066_R_ON, CD4066_R_ON + DST_RC_CIRCUIT_1__R);
|
||||
@ -645,9 +645,9 @@ static DISCRETE_RESET( dst_rc_circuit_1 )
|
||||
#define DST_RCDISC__R DISCRETE_INPUT(2)
|
||||
#define DST_RCDISC__C DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_rcdisc)
|
||||
DISCRETE_STEP(dst_rcdisc)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
switch (context->state)
|
||||
{
|
||||
@ -672,9 +672,9 @@ static DISCRETE_STEP(dst_rcdisc)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_rcdisc)
|
||||
DISCRETE_RESET(dst_rcdisc)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
node->output[0] = 0;
|
||||
|
||||
@ -704,9 +704,9 @@ static DISCRETE_RESET(dst_rcdisc)
|
||||
#define DST_RCDISC2__R1 DISCRETE_INPUT(4)
|
||||
#define DST_RCDISC2__C DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dst_rcdisc2)
|
||||
DISCRETE_STEP(dst_rcdisc2)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
double diff;
|
||||
|
||||
@ -718,9 +718,9 @@ static DISCRETE_STEP(dst_rcdisc2)
|
||||
node->output[0] += diff;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_rcdisc2)
|
||||
DISCRETE_RESET(dst_rcdisc2)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
node->output[0] = 0;
|
||||
|
||||
@ -750,9 +750,9 @@ static DISCRETE_RESET(dst_rcdisc2)
|
||||
#define DST_RCDISC3__C DISCRETE_INPUT(4)
|
||||
#define DST_RCDISC3__DJV DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dst_rcdisc3)
|
||||
DISCRETE_STEP(dst_rcdisc3)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
double diff;
|
||||
|
||||
@ -799,9 +799,9 @@ static DISCRETE_STEP(dst_rcdisc3)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_rcdisc3)
|
||||
DISCRETE_RESET(dst_rcdisc3)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
node->output[0] = 0;
|
||||
|
||||
@ -835,9 +835,9 @@ static DISCRETE_RESET(dst_rcdisc3)
|
||||
#define DST_RCDISC4__VP DISCRETE_INPUT(6)
|
||||
#define DST_RCDISC4__TYPE DISCRETE_INPUT(7)
|
||||
|
||||
static DISCRETE_STEP(dst_rcdisc4)
|
||||
DISCRETE_STEP(dst_rcdisc4)
|
||||
{
|
||||
struct dst_rcdisc4_context *context = (struct dst_rcdisc4_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc4)
|
||||
|
||||
int inp1 = (DST_RCDISC4__IN == 0) ? 0 : 1;
|
||||
|
||||
@ -861,9 +861,9 @@ static DISCRETE_STEP(dst_rcdisc4)
|
||||
if (node->output[0] < 0) node->output[0] = 0;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET( dst_rcdisc4)
|
||||
DISCRETE_RESET( dst_rcdisc4)
|
||||
{
|
||||
struct dst_rcdisc4_context *context = (struct dst_rcdisc4_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc4)
|
||||
|
||||
double v, i, r, rT;
|
||||
|
||||
@ -947,9 +947,9 @@ static DISCRETE_RESET( dst_rcdisc4)
|
||||
#define DST_RCDISC5__R DISCRETE_INPUT(2)
|
||||
#define DST_RCDISC5__C DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP( dst_rcdisc5)
|
||||
DISCRETE_STEP( dst_rcdisc5)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
double diff,u;
|
||||
|
||||
@ -978,9 +978,9 @@ static DISCRETE_STEP( dst_rcdisc5)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET( dst_rcdisc5)
|
||||
DISCRETE_RESET( dst_rcdisc5)
|
||||
{
|
||||
struct dst_rcdisc_context *context = (struct dst_rcdisc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc)
|
||||
|
||||
node->output[0] = 0;
|
||||
|
||||
@ -1015,9 +1015,9 @@ static DISCRETE_RESET( dst_rcdisc5)
|
||||
#define DST_RCDISC_MOD__C DISCRETE_INPUT(6)
|
||||
#define DST_RCDISC_MOD__VP DISCRETE_INPUT(7)
|
||||
|
||||
static DISCRETE_STEP(dst_rcdisc_mod)
|
||||
DISCRETE_STEP(dst_rcdisc_mod)
|
||||
{
|
||||
struct dst_rcdisc_mod_context *context = (struct dst_rcdisc_mod_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc_mod)
|
||||
|
||||
double diff, v_cap, u, vD;
|
||||
int mod_state, mod1_state, mod2_state;
|
||||
@ -1050,9 +1050,9 @@ static DISCRETE_STEP(dst_rcdisc_mod)
|
||||
context->v_cap = v_cap;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_rcdisc_mod)
|
||||
DISCRETE_RESET(dst_rcdisc_mod)
|
||||
{
|
||||
struct dst_rcdisc_mod_context *context = (struct dst_rcdisc_mod_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc_mod)
|
||||
|
||||
double rc[2], rc2[2];
|
||||
|
||||
@ -1104,9 +1104,9 @@ static DISCRETE_RESET(dst_rcdisc_mod)
|
||||
#define DST_RCFILTER__C DISCRETE_INPUT(2)
|
||||
#define DST_RCFILTER__VREF DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_rcfilter)
|
||||
DISCRETE_STEP(dst_rcfilter)
|
||||
{
|
||||
struct dst_rcfilter_context *context = (struct dst_rcfilter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcfilter)
|
||||
|
||||
if (UNEXPECTED(context->has_rc_nodes))
|
||||
{
|
||||
@ -1126,15 +1126,16 @@ static DISCRETE_STEP(dst_rcfilter)
|
||||
node->output[0] = context->vCap + DST_RCFILTER__VREF;
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dst_rcfilter_fast)
|
||||
DISCRETE_STEP(dst_rcfilter_fast)
|
||||
{
|
||||
struct dst_rcfilter_context *context = (struct dst_rcfilter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcfilter)
|
||||
|
||||
node->output[0] += ((DST_RCFILTER__VIN - node->output[0]) * context->exponent);
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_rcfilter)
|
||||
DISCRETE_RESET(dst_rcfilter)
|
||||
{
|
||||
struct dst_rcfilter_context *context = (struct dst_rcfilter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcfilter)
|
||||
|
||||
context->has_rc_nodes = node->input_is_node & 0x6;
|
||||
context->rc = DST_RCFILTER__R * DST_RCFILTER__C;
|
||||
@ -1173,9 +1174,9 @@ static DISCRETE_RESET(dst_rcfilter)
|
||||
#define CD4066_ON_RES (40)
|
||||
|
||||
// FIXME: This needs optimization !
|
||||
static DISCRETE_STEP(dst_rcfilter_sw)
|
||||
DISCRETE_STEP(dst_rcfilter_sw)
|
||||
{
|
||||
struct dst_rcfilter_sw_context *context = (struct dst_rcfilter_sw_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcfilter_sw)
|
||||
|
||||
int i;
|
||||
int bits = (int)DST_RCFILTER_SW__SWITCH;
|
||||
@ -1217,9 +1218,9 @@ static DISCRETE_STEP(dst_rcfilter_sw)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_rcfilter_sw)
|
||||
DISCRETE_RESET(dst_rcfilter_sw)
|
||||
{
|
||||
struct dst_rcfilter_sw_context *context = (struct dst_rcfilter_sw_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcfilter_sw)
|
||||
|
||||
int i, bits;
|
||||
|
||||
@ -1289,9 +1290,9 @@ static DISCRETE_RESET(dst_rcfilter_sw)
|
||||
#define KT 0.026
|
||||
#define EM_IC(x) (ALPHAT * IES * exp( (x) / KT - 1.0 ))
|
||||
|
||||
static DISCRETE_STEP( dst_rcintegrate)
|
||||
DISCRETE_STEP( dst_rcintegrate)
|
||||
{
|
||||
struct dst_rcintegrate_context *context = (struct dst_rcintegrate_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcintegrate)
|
||||
|
||||
double diff, u, iQ, iQc, iC, RG, vE;
|
||||
double vP;
|
||||
@ -1350,9 +1351,9 @@ static DISCRETE_STEP( dst_rcintegrate)
|
||||
break;
|
||||
}
|
||||
}
|
||||
static DISCRETE_RESET(dst_rcintegrate)
|
||||
DISCRETE_RESET(dst_rcintegrate)
|
||||
{
|
||||
struct dst_rcintegrate_context *context = (struct dst_rcintegrate_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcintegrate)
|
||||
|
||||
double r;
|
||||
double dt = node->info->sample_time;
|
||||
@ -1394,9 +1395,9 @@ static DISCRETE_RESET(dst_rcintegrate)
|
||||
#define DST_SALLEN_KEY__INP0 DISCRETE_INPUT(1)
|
||||
#define DST_SALLEN_KEY__TYPE DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dst_sallen_key)
|
||||
DISCRETE_STEP(dst_sallen_key)
|
||||
{
|
||||
struct dss_filter2_context *context = (struct dss_filter2_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_filter2)
|
||||
|
||||
double gain = 1.0;
|
||||
|
||||
@ -1414,10 +1415,10 @@ static DISCRETE_STEP(dst_sallen_key)
|
||||
context->y1 = node->output[0];
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_sallen_key)
|
||||
DISCRETE_RESET(dst_sallen_key)
|
||||
{
|
||||
struct dss_filter2_context *context = (struct dss_filter2_context *)node->context;
|
||||
const discrete_op_amp_filt_info *info = (const discrete_op_amp_filt_info *)node->custom;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_filter2)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_filt_info)
|
||||
|
||||
double freq, q;
|
||||
|
||||
@ -1456,7 +1457,7 @@ static DISCRETE_RESET(dst_sallen_key)
|
||||
#define DST_RCFILTERN__R DISCRETE_INPUT(2)
|
||||
#define DST_RCFILTERN__C DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_RESET(dst_rcfilterN)
|
||||
DISCRETE_RESET(dst_rcfilterN)
|
||||
{
|
||||
#if 0
|
||||
double f=1.0/(2*M_PI* DST_RCFILTERN__R * DST_RCFILTERN__C);
|
||||
@ -1489,7 +1490,7 @@ static DISCRETE_RESET(dst_rcfilterN)
|
||||
#define DST_RCDISCN__R DISCRETE_INPUT(2)
|
||||
#define DST_RCDISCN__C DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_RESET(dst_rcdiscN)
|
||||
DISCRETE_RESET(dst_rcdiscN)
|
||||
{
|
||||
#if 0
|
||||
double f = 1.0 / (2 * M_PI * DST_RCDISCN__R * DST_RCDISCN__C);
|
||||
@ -1505,9 +1506,9 @@ static DISCRETE_RESET(dst_rcdiscN)
|
||||
#endif
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dst_rcdiscN)
|
||||
DISCRETE_STEP(dst_rcdiscN)
|
||||
{
|
||||
struct dss_filter1_context *context = (struct dss_filter1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_filter1)
|
||||
|
||||
double gain = 1.0;
|
||||
|
||||
@ -1548,7 +1549,7 @@ static DISCRETE_STEP(dst_rcdiscN)
|
||||
#define DST_RCDISC2N__R1 DISCRETE_INPUT(4)
|
||||
#define DST_RCDISC2N__C DISCRETE_INPUT(5)
|
||||
|
||||
struct dss_rcdisc2_context
|
||||
struct dst_rcdisc2_context
|
||||
{
|
||||
double x1; /* x[k-1], last input value */
|
||||
double y1; /* y[k-1], last output value */
|
||||
@ -1556,9 +1557,9 @@ struct dss_rcdisc2_context
|
||||
double a1_1, b0_1, b1_1; /* digital filter coefficients, filter #2 */
|
||||
};
|
||||
|
||||
static DISCRETE_STEP(dst_rcdisc2N)
|
||||
DISCRETE_STEP(dst_rcdisc2N)
|
||||
{
|
||||
struct dss_rcdisc2_context *context = (struct dss_rcdisc2_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc2)
|
||||
|
||||
double input = ((DST_RCDISC2N__ENABLE == 0) ? DST_RCDISC2N__IN0 : DST_RCDISC2N__IN1);
|
||||
|
||||
@ -1571,9 +1572,9 @@ static DISCRETE_STEP(dst_rcdisc2N)
|
||||
context->y1 = node->output[0];
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_rcdisc2N)
|
||||
DISCRETE_RESET(dst_rcdisc2N)
|
||||
{
|
||||
struct dss_rcdisc2_context *context = (struct dss_rcdisc2_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_rcdisc2)
|
||||
double f1,f2;
|
||||
|
||||
f1 = 1.0 / (2 * M_PI * DST_RCDISC2N__R0 * DST_RCDISC2N__C);
|
||||
|
@ -146,9 +146,9 @@ WRITE8_DEVICE_HANDLER(discrete_sound_w)
|
||||
#define DSS_ADJUSTMENT__PMIN DISCRETE_INPUT(4)
|
||||
#define DSS_ADJUSTMENT__PMAX DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dss_adjustment)
|
||||
DISCRETE_STEP(dss_adjustment)
|
||||
{
|
||||
struct dss_adjustment_context *context = (struct dss_adjustment_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_adjustment)
|
||||
|
||||
INT32 rawportval = input_port_read_direct(context->port);
|
||||
|
||||
@ -166,9 +166,9 @@ static DISCRETE_STEP(dss_adjustment)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_adjustment)
|
||||
DISCRETE_RESET(dss_adjustment)
|
||||
{
|
||||
struct dss_adjustment_context *context = (struct dss_adjustment_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_adjustment)
|
||||
|
||||
double min, max;
|
||||
|
||||
@ -210,7 +210,7 @@ static DISCRETE_RESET(dss_adjustment)
|
||||
************************************************************************/
|
||||
#define DSS_CONSTANT__INIT DISCRETE_INPUT(0)
|
||||
|
||||
static DISCRETE_RESET(dss_constant)
|
||||
DISCRETE_RESET(dss_constant)
|
||||
{
|
||||
node->output[0]= DSS_CONSTANT__INIT;
|
||||
}
|
||||
@ -226,9 +226,9 @@ static DISCRETE_RESET(dss_constant)
|
||||
* input[3] - Current data value
|
||||
*
|
||||
************************************************************************/
|
||||
static DISCRETE_RESET(dss_input)
|
||||
DISCRETE_RESET(dss_input)
|
||||
{
|
||||
struct dss_input_context *context = (struct dss_input_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_input)
|
||||
|
||||
context->is_buffered = FALSE;
|
||||
context->is_stream = FALSE;
|
||||
@ -251,9 +251,9 @@ static DISCRETE_RESET(dss_input)
|
||||
node->output[0] = context->data * context->gain + context->offset;
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dss_input_pulse)
|
||||
DISCRETE_STEP(dss_input_pulse)
|
||||
{
|
||||
struct dss_input_context *context = (struct dss_input_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_input)
|
||||
|
||||
/* Set a valid output */
|
||||
node->output[0] = context->data;
|
||||
@ -276,10 +276,10 @@ static DISCRETE_STEP(dss_input_pulse)
|
||||
#define DSS_INPUT_STREAM__GAIN DISCRETE_INPUT(1)
|
||||
#define DSS_INPUT_STREAM__OFFSET DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dss_input_stream)
|
||||
DISCRETE_STEP(dss_input_stream)
|
||||
{
|
||||
/* the context pointer is set to point to the current input stream data in discrete_stream_update */
|
||||
struct dss_input_context *context = (struct dss_input_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_input)
|
||||
|
||||
if (EXPECTED(context->ptr))
|
||||
{
|
||||
@ -290,17 +290,17 @@ static DISCRETE_STEP(dss_input_stream)
|
||||
node->output[0] = 0;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_input_stream)
|
||||
DISCRETE_RESET(dss_input_stream)
|
||||
{
|
||||
struct dss_input_context *context = (struct dss_input_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_input)
|
||||
|
||||
context->ptr = NULL;
|
||||
context->data = 0;
|
||||
}
|
||||
|
||||
static DISCRETE_START(dss_input_stream)
|
||||
DISCRETE_START(dss_input_stream)
|
||||
{
|
||||
struct dss_input_context *context = (struct dss_input_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_input)
|
||||
|
||||
assert(DSS_INPUT_STREAM__STREAM < linked_list_count(node->info->input_list));
|
||||
|
||||
|
@ -71,7 +71,7 @@ struct dst_dac_r1_context
|
||||
int last_data;
|
||||
};
|
||||
|
||||
struct dst_diode_mix__context
|
||||
struct dst_diode_mix_context
|
||||
{
|
||||
int size;
|
||||
double v_junction[8];
|
||||
@ -118,7 +118,7 @@ struct dst_oneshot_context
|
||||
int type;
|
||||
};
|
||||
|
||||
struct dss_ramp_context
|
||||
struct dst_ramp_context
|
||||
{
|
||||
double step;
|
||||
int dir; /* 1 if End is higher then Start */
|
||||
@ -209,7 +209,7 @@ struct dst_tvca_op_amp_context
|
||||
#define DST_ADDER__IN2 DISCRETE_INPUT(3)
|
||||
#define DST_ADDER__IN3 DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_adder)
|
||||
DISCRETE_STEP(dst_adder)
|
||||
{
|
||||
if(DST_ADDER__ENABLE)
|
||||
{
|
||||
@ -234,9 +234,9 @@ static DISCRETE_STEP(dst_adder)
|
||||
************************************************************************/
|
||||
#define DST_COMP_ADDER__SELECT DISCRETE_INPUT(0)
|
||||
|
||||
static DISCRETE_STEP(dst_comp_adder)
|
||||
DISCRETE_STEP(dst_comp_adder)
|
||||
{
|
||||
struct dst_comp_adder_context *context = (struct dst_comp_adder_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_comp_adder)
|
||||
int select;
|
||||
|
||||
select = (int)DST_COMP_ADDER__SELECT;
|
||||
@ -244,10 +244,10 @@ static DISCRETE_STEP(dst_comp_adder)
|
||||
node->output[0] = context->total[select];
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_comp_adder)
|
||||
DISCRETE_RESET(dst_comp_adder)
|
||||
{
|
||||
const discrete_comp_adder_table *info = (const discrete_comp_adder_table *)node->custom;
|
||||
struct dst_comp_adder_context *context = (struct dst_comp_adder_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_comp_adder)
|
||||
DISCRETE_DECLARE_INFO(discrete_comp_adder_table)
|
||||
|
||||
int i, bit;
|
||||
int length = 1 << info->length;
|
||||
@ -292,7 +292,7 @@ static DISCRETE_RESET(dst_comp_adder)
|
||||
#define DST_CLAMP__MIN DISCRETE_INPUT(1)
|
||||
#define DST_CLAMP__MAX DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dst_clamp)
|
||||
DISCRETE_STEP(dst_clamp)
|
||||
{
|
||||
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;
|
||||
@ -314,10 +314,10 @@ static DISCRETE_STEP(dst_clamp)
|
||||
#define DST_DAC_R1__DATA DISCRETE_INPUT(0)
|
||||
#define DST_DAC_R1__VON DISCRETE_INPUT(1)
|
||||
|
||||
static DISCRETE_STEP(dst_dac_r1)
|
||||
DISCRETE_STEP(dst_dac_r1)
|
||||
{
|
||||
const discrete_dac_r1_ladder *info = (const discrete_dac_r1_ladder *)node->custom;
|
||||
struct dst_dac_r1_context *context = (struct dst_dac_r1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_dac_r1)
|
||||
DISCRETE_DECLARE_INFO(discrete_dac_r1_ladder)
|
||||
|
||||
int bit, bit_val, data;
|
||||
double v, i_bit, i_total, x_time, von;
|
||||
@ -362,10 +362,10 @@ static DISCRETE_STEP(dst_dac_r1)
|
||||
node->output[0] = info->cFilter ? node->output[0] + ((v - node->output[0]) * context->exponent) : v;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_dac_r1)
|
||||
DISCRETE_RESET(dst_dac_r1)
|
||||
{
|
||||
const discrete_dac_r1_ladder *info = (const discrete_dac_r1_ladder *)node->custom;
|
||||
struct dst_dac_r1_context *context = (struct dst_dac_r1_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_dac_r1)
|
||||
DISCRETE_DECLARE_INFO(discrete_dac_r1_ladder)
|
||||
|
||||
int bit;
|
||||
|
||||
@ -427,9 +427,9 @@ static DISCRETE_RESET(dst_dac_r1)
|
||||
#define DST_DIODE_MIX_INP_OFFSET 0
|
||||
#define DST_DIODE_MIX__INP(addr) DISCRETE_INPUT(DST_DIODE_MIX_INP_OFFSET + addr)
|
||||
|
||||
static DISCRETE_STEP(dst_diode_mix)
|
||||
DISCRETE_STEP(dst_diode_mix)
|
||||
{
|
||||
struct dst_diode_mix__context *context = (struct dst_diode_mix__context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_diode_mix)
|
||||
|
||||
double val, max = 0;
|
||||
int addr;
|
||||
@ -443,10 +443,10 @@ static DISCRETE_STEP(dst_diode_mix)
|
||||
node->output[0] = max;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_diode_mix)
|
||||
DISCRETE_RESET(dst_diode_mix)
|
||||
{
|
||||
const double *info = (const double *)node->custom;
|
||||
struct dst_diode_mix__context *context = (struct dst_diode_mix__context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_diode_mix)
|
||||
DISCRETE_DECLARE_INFO(double)
|
||||
|
||||
int addr;
|
||||
|
||||
@ -483,7 +483,7 @@ static DISCRETE_RESET(dst_diode_mix)
|
||||
#define DST_DIVIDE__IN DISCRETE_INPUT(1)
|
||||
#define DST_DIVIDE__DIV DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dst_divide)
|
||||
DISCRETE_STEP(dst_divide)
|
||||
{
|
||||
if(DST_DIVIDE__ENABLE)
|
||||
{
|
||||
@ -517,7 +517,7 @@ static DISCRETE_STEP(dst_divide)
|
||||
#define DST_GAIN__GAIN DISCRETE_INPUT(1)
|
||||
#define DST_GAIN__OFFSET DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dst_gain)
|
||||
DISCRETE_STEP(dst_gain)
|
||||
{
|
||||
node->output[0] = DST_GAIN__IN * DST_GAIN__GAIN + DST_GAIN__OFFSET;
|
||||
}
|
||||
@ -571,10 +571,10 @@ static int dst_trigger_function(int trig0, int trig1, int trig2, int function)
|
||||
return (result);
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dst_integrate)
|
||||
DISCRETE_STEP(dst_integrate)
|
||||
{
|
||||
const discrete_integrate_info *info = (const discrete_integrate_info *)node->custom;
|
||||
struct dst_integrate_context *context = (struct dst_integrate_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_integrate)
|
||||
DISCRETE_DECLARE_INFO(discrete_integrate_info)
|
||||
|
||||
int trig0, trig1;
|
||||
double i_neg = 0; /* current into - input */
|
||||
@ -616,10 +616,11 @@ static DISCRETE_STEP(dst_integrate)
|
||||
if (node->output[0] > context->v_max_out) node->output[0] = context->v_max_out;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_integrate)
|
||||
DISCRETE_RESET(dst_integrate)
|
||||
{
|
||||
const discrete_integrate_info *info = (const discrete_integrate_info *)node->custom;
|
||||
struct dst_integrate_context *context = (struct dst_integrate_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_integrate)
|
||||
DISCRETE_DECLARE_INFO(discrete_integrate_info)
|
||||
|
||||
double i, v;
|
||||
|
||||
if (info->type & DISC_OP_AMP_IS_NORTON)
|
||||
@ -651,7 +652,7 @@ static DISCRETE_RESET(dst_integrate)
|
||||
************************************************************************/
|
||||
#define DST_LOGIC_INV__IN DISCRETE_INPUT(0)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_inv)
|
||||
DISCRETE_STEP(dst_logic_inv)
|
||||
{
|
||||
node->output[0] = DST_LOGIC_INV__IN ? 0.0 : 1.0;
|
||||
}
|
||||
@ -666,9 +667,10 @@ static DISCRETE_STEP(dst_logic_inv)
|
||||
#define DST_BITS_DECODE__TO DISCRETE_INPUT(2)
|
||||
#define DST_BITS_DECODE__VOUT DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_bits_decode)
|
||||
DISCRETE_STEP(dst_bits_decode)
|
||||
{
|
||||
struct dst_bits_decode_context *context = (struct dst_bits_decode_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_bits_decode)
|
||||
|
||||
int new_val = DST_BITS_DECODE__IN;
|
||||
int last_val = context->last_val;
|
||||
int last_had_x_time = context->last_had_x_time;
|
||||
@ -681,6 +683,7 @@ static DISCRETE_STEP(dst_bits_decode)
|
||||
int count = context->count;
|
||||
int decode_x_time = context->decode_x_time;
|
||||
int has_x_time = x_time > 0 ? 1 : 0;
|
||||
double out = 0;
|
||||
double v_out = DST_BITS_DECODE__VOUT;
|
||||
|
||||
for (i = 0; i < count; i++ )
|
||||
@ -695,23 +698,24 @@ static DISCRETE_STEP(dst_bits_decode)
|
||||
|
||||
if (decode_x_time)
|
||||
{
|
||||
v_out = new_bit;
|
||||
out = new_bit;
|
||||
if (bit_changed)
|
||||
v_out += x_time;
|
||||
out += x_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
out = v_out;
|
||||
if (has_x_time && bit_changed)
|
||||
{
|
||||
if (new_bit)
|
||||
v_out *= x_time;
|
||||
out *= x_time;
|
||||
else
|
||||
v_out *= (1.0 - x_time);
|
||||
out *= (1.0 - x_time);
|
||||
}
|
||||
else
|
||||
v_out *= new_bit;
|
||||
out *= new_bit;
|
||||
}
|
||||
node->output[i] = v_out;
|
||||
node->output[i] = out;
|
||||
if (has_x_time && bit_changed)
|
||||
/* set */
|
||||
context->last_had_x_time |= 1 << (i + from);
|
||||
@ -723,9 +727,9 @@ static DISCRETE_STEP(dst_bits_decode)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_bits_decode)
|
||||
DISCRETE_RESET(dst_bits_decode)
|
||||
{
|
||||
struct dst_bits_decode_context *context = (struct dst_bits_decode_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_bits_decode)
|
||||
|
||||
context->from = DST_BITS_DECODE__FROM;
|
||||
context->count = DST_BITS_DECODE__TO - context->from + 1;
|
||||
@ -754,7 +758,7 @@ static DISCRETE_RESET(dst_bits_decode)
|
||||
#define DST_LOGIC_AND__IN2 DISCRETE_INPUT(2)
|
||||
#define DST_LOGIC_AND__IN3 DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_and)
|
||||
DISCRETE_STEP(dst_logic_and)
|
||||
{
|
||||
node->output[0] = (DST_LOGIC_AND__IN0 && DST_LOGIC_AND__IN1 && DST_LOGIC_AND__IN2 && DST_LOGIC_AND__IN3)? 1.0 : 0.0;
|
||||
}
|
||||
@ -774,7 +778,7 @@ static DISCRETE_STEP(dst_logic_and)
|
||||
#define DST_LOGIC_NAND__IN2 DISCRETE_INPUT(2)
|
||||
#define DST_LOGIC_NAND__IN3 DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_nand)
|
||||
DISCRETE_STEP(dst_logic_nand)
|
||||
{
|
||||
node->output[0]= (DST_LOGIC_NAND__IN0 && DST_LOGIC_NAND__IN1 && DST_LOGIC_NAND__IN2 && DST_LOGIC_NAND__IN3)? 0.0 : 1.0;
|
||||
}
|
||||
@ -794,7 +798,7 @@ static DISCRETE_STEP(dst_logic_nand)
|
||||
#define DST_LOGIC_OR__IN2 DISCRETE_INPUT(2)
|
||||
#define DST_LOGIC_OR__IN3 DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_or)
|
||||
DISCRETE_STEP(dst_logic_or)
|
||||
{
|
||||
node->output[0] = (DST_LOGIC_OR__IN0 || DST_LOGIC_OR__IN1 || DST_LOGIC_OR__IN2 || DST_LOGIC_OR__IN3) ? 1.0 : 0.0;
|
||||
}
|
||||
@ -814,7 +818,7 @@ static DISCRETE_STEP(dst_logic_or)
|
||||
#define DST_LOGIC_NOR__IN2 DISCRETE_INPUT(2)
|
||||
#define DST_LOGIC_NOR__IN3 DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_nor)
|
||||
DISCRETE_STEP(dst_logic_nor)
|
||||
{
|
||||
node->output[0] = (DST_LOGIC_NOR__IN0 || DST_LOGIC_NOR__IN1 || DST_LOGIC_NOR__IN2 || DST_LOGIC_NOR__IN3) ? 0.0 : 1.0;
|
||||
}
|
||||
@ -830,7 +834,7 @@ static DISCRETE_STEP(dst_logic_nor)
|
||||
#define DST_LOGIC_XOR__IN0 DISCRETE_INPUT(0)
|
||||
#define DST_LOGIC_XOR__IN1 DISCRETE_INPUT(1)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_xor)
|
||||
DISCRETE_STEP(dst_logic_xor)
|
||||
{
|
||||
node->output[0] = ((DST_LOGIC_XOR__IN0 && !DST_LOGIC_XOR__IN1) || (!DST_LOGIC_XOR__IN0 && DST_LOGIC_XOR__IN1)) ? 1.0 : 0.0;
|
||||
}
|
||||
@ -846,7 +850,7 @@ static DISCRETE_STEP(dst_logic_xor)
|
||||
#define DST_LOGIC_XNOR__IN0 DISCRETE_INPUT(0)
|
||||
#define DST_LOGIC_XNOR__IN1 DISCRETE_INPUT(1)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_nxor)
|
||||
DISCRETE_STEP(dst_logic_nxor)
|
||||
{
|
||||
node->output[0] = ((DST_LOGIC_XNOR__IN0 && !DST_LOGIC_XNOR__IN1) || (!DST_LOGIC_XNOR__IN0 && DST_LOGIC_XNOR__IN1)) ? 0.0 : 1.0;
|
||||
}
|
||||
@ -867,9 +871,9 @@ static DISCRETE_STEP(dst_logic_nxor)
|
||||
#define DST_LOGIC_DFF__CLOCK DISCRETE_INPUT(2)
|
||||
#define DST_LOGIC_DFF__DATA DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_dff)
|
||||
DISCRETE_STEP(dst_logic_dff)
|
||||
{
|
||||
struct dst_flipflop_context *context = (struct dst_flipflop_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_flipflop)
|
||||
|
||||
int clk = (int)DST_LOGIC_DFF__CLOCK;
|
||||
|
||||
@ -882,9 +886,10 @@ static DISCRETE_STEP(dst_logic_dff)
|
||||
context->last_clk = clk;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_logic_ff)
|
||||
DISCRETE_RESET(dst_logic_ff)
|
||||
{
|
||||
struct dst_flipflop_context *context = (struct dst_flipflop_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_flipflop)
|
||||
|
||||
|
||||
context->last_clk = 0;
|
||||
node->output[0] = 0;
|
||||
@ -908,9 +913,9 @@ static DISCRETE_RESET(dst_logic_ff)
|
||||
#define DST_LOGIC_JKFF__J DISCRETE_INPUT(3)
|
||||
#define DST_LOGIC_JKFF__K DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_jkff)
|
||||
DISCRETE_STEP(dst_logic_jkff)
|
||||
{
|
||||
struct dst_flipflop_context *context = (struct dst_flipflop_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_flipflop)
|
||||
|
||||
int clk = (int)DST_LOGIC_JKFF__CLOCK;
|
||||
int j = (int)DST_LOGIC_JKFF__J;
|
||||
@ -954,9 +959,9 @@ static DISCRETE_STEP(dst_logic_jkff)
|
||||
#define DST_LOGIC_SHIFT__SIZE DISCRETE_INPUT(3)
|
||||
#define DST_LOGIC_SHIFT__OPTIONS DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_logic_shift)
|
||||
DISCRETE_STEP(dst_logic_shift)
|
||||
{
|
||||
struct dst_shift_context *context = (struct dst_shift_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_shift)
|
||||
|
||||
double cycles;
|
||||
double ds_clock;
|
||||
@ -1030,9 +1035,9 @@ static DISCRETE_STEP(dst_logic_shift)
|
||||
node->output[0] = context->shift_data;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_logic_shift)
|
||||
DISCRETE_RESET(dst_logic_shift)
|
||||
{
|
||||
struct dst_shift_context *context = (struct dst_shift_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_shift)
|
||||
|
||||
context->bit_mask = (1 << (int)DST_LOGIC_SHIFT__SIZE) - 1;
|
||||
context->clock_type = (int)DST_LOGIC_SHIFT__OPTIONS & DISC_CLK_MASK;
|
||||
@ -1059,16 +1064,16 @@ static DISCRETE_RESET(dst_logic_shift)
|
||||
#define DST_LOOKUP_TABLE__IN DISCRETE_INPUT(0)
|
||||
#define DST_LOOKUP_TABLE__SIZE DISCRETE_INPUT(1)
|
||||
|
||||
static DISCRETE_STEP(dst_lookup_table)
|
||||
DISCRETE_STEP(dst_lookup_table)
|
||||
{
|
||||
const double *table = (const double *)node->custom;
|
||||
DISCRETE_DECLARE_INFO(double)
|
||||
|
||||
int addr = DST_LOOKUP_TABLE__IN;
|
||||
|
||||
if (addr < 0 || addr >= DST_LOOKUP_TABLE__SIZE)
|
||||
node->output[0] = 0;
|
||||
else
|
||||
node->output[0] = table[addr];
|
||||
node->output[0] = info[addr];
|
||||
}
|
||||
|
||||
|
||||
@ -1125,10 +1130,10 @@ static DISCRETE_STEP(dst_lookup_table)
|
||||
#define DST_MIXER__ENABLE DISCRETE_INPUT(0)
|
||||
#define DST_MIXER__IN(bit) DISCRETE_INPUT(bit + 1)
|
||||
|
||||
static DISCRETE_STEP(dst_mixer)
|
||||
DISCRETE_STEP(dst_mixer)
|
||||
{
|
||||
const discrete_mixer_desc *info = (const discrete_mixer_desc *)node->custom;
|
||||
struct dst_mixer_context *context = (struct dst_mixer_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_mixer)
|
||||
DISCRETE_DECLARE_INFO(discrete_mixer_desc)
|
||||
|
||||
double v, vTemp, r_total, rTemp, rTemp2 = 0;
|
||||
double i = 0; /* total current of inputs */
|
||||
@ -1283,10 +1288,11 @@ static DISCRETE_STEP(dst_mixer)
|
||||
}
|
||||
|
||||
|
||||
static DISCRETE_RESET(dst_mixer)
|
||||
DISCRETE_RESET(dst_mixer)
|
||||
{
|
||||
const discrete_mixer_desc *info = (const discrete_mixer_desc *)node->custom;
|
||||
struct dst_mixer_context *context = (struct dst_mixer_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_mixer)
|
||||
DISCRETE_DECLARE_INFO(discrete_mixer_desc)
|
||||
|
||||
node_description *r_node;
|
||||
|
||||
int bit;
|
||||
@ -1405,9 +1411,9 @@ static DISCRETE_RESET(dst_mixer)
|
||||
#define DST_MULTIPLEX__ADDR DISCRETE_INPUT(0)
|
||||
#define DST_MULTIPLEX__INP(addr) DISCRETE_INPUT(1 + addr)
|
||||
|
||||
static DISCRETE_STEP(dst_multiplex)
|
||||
DISCRETE_STEP(dst_multiplex)
|
||||
{
|
||||
struct dst_size_context *context = (struct dst_size_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_size)
|
||||
|
||||
int addr;
|
||||
|
||||
@ -1423,9 +1429,9 @@ static DISCRETE_STEP(dst_multiplex)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_multiplex)
|
||||
DISCRETE_RESET(dst_multiplex)
|
||||
{
|
||||
struct dst_size_context *context = (struct dst_size_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_size)
|
||||
|
||||
context->size = node->active_inputs - 1;
|
||||
|
||||
@ -1451,9 +1457,9 @@ static DISCRETE_RESET(dst_multiplex)
|
||||
#define DST_ONESHOT__WIDTH DISCRETE_INPUT(3)
|
||||
#define DST_ONESHOT__TYPE (int)DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_oneshot)
|
||||
DISCRETE_STEP(dst_oneshot)
|
||||
{
|
||||
struct dst_oneshot_context *context = (struct dst_oneshot_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_oneshot)
|
||||
|
||||
int trigger = (DST_ONESHOT__TRIG != 0);
|
||||
|
||||
@ -1511,9 +1517,9 @@ static DISCRETE_STEP(dst_oneshot)
|
||||
}
|
||||
|
||||
|
||||
static DISCRETE_RESET(dst_oneshot)
|
||||
DISCRETE_RESET(dst_oneshot)
|
||||
{
|
||||
struct dst_oneshot_context *context = (struct dst_oneshot_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_oneshot)
|
||||
|
||||
context->countdown = 0;
|
||||
context->state = 0;
|
||||
@ -1544,9 +1550,9 @@ static DISCRETE_RESET(dst_oneshot)
|
||||
#define DST_RAMP__END DISCRETE_INPUT(4)
|
||||
#define DST_RAMP__CLAMP DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dst_ramp)
|
||||
DISCRETE_STEP(dst_ramp)
|
||||
{
|
||||
struct dss_ramp_context *context = (struct dss_ramp_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_ramp)
|
||||
|
||||
if(DST_RAMP__ENABLE)
|
||||
{
|
||||
@ -1571,9 +1577,9 @@ static DISCRETE_STEP(dst_ramp)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_ramp)
|
||||
DISCRETE_RESET(dst_ramp)
|
||||
{
|
||||
struct dss_ramp_context *context = (struct dss_ramp_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_ramp)
|
||||
|
||||
node->output[0] = DST_RAMP__CLAMP;
|
||||
context->step = DST_RAMP__GRAD / node->info->sample_rate;
|
||||
@ -1595,9 +1601,9 @@ static DISCRETE_RESET(dst_ramp)
|
||||
#define DST_SAMPHOLD__CLOCK DISCRETE_INPUT(1)
|
||||
#define DST_SAMPHOLD__TYPE DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dst_samphold)
|
||||
DISCRETE_STEP(dst_samphold)
|
||||
{
|
||||
struct dst_samphold_context *context = (struct dst_samphold_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_samphold)
|
||||
|
||||
switch(context->clocktype)
|
||||
{
|
||||
@ -1625,9 +1631,9 @@ static DISCRETE_STEP(dst_samphold)
|
||||
context->last_input = DST_SAMPHOLD__CLOCK;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_samphold)
|
||||
DISCRETE_RESET(dst_samphold)
|
||||
{
|
||||
struct dst_samphold_context *context = (struct dst_samphold_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_samphold)
|
||||
|
||||
node->output[0] = 0;
|
||||
context->last_input = -1;
|
||||
@ -1652,7 +1658,7 @@ static DISCRETE_RESET(dst_samphold)
|
||||
#define DST_SWITCH__IN0 DISCRETE_INPUT(2)
|
||||
#define DST_SWITCH__IN1 DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_switch)
|
||||
DISCRETE_STEP(dst_switch)
|
||||
{
|
||||
if(DST_SWITCH__ENABLE)
|
||||
{
|
||||
@ -1678,7 +1684,7 @@ static DISCRETE_STEP(dst_switch)
|
||||
#define DST_ASWITCH__THRESHOLD DISCRETE_INPUT(2)
|
||||
|
||||
|
||||
static DISCRETE_STEP(dst_aswitch)
|
||||
DISCRETE_STEP(dst_aswitch)
|
||||
{
|
||||
node->output[0] = DST_ASWITCH__CTRL > DST_ASWITCH__THRESHOLD ? DST_ASWITCH__IN : 0;
|
||||
}
|
||||
@ -1717,7 +1723,7 @@ INLINE void dst_transform_push(double *stack, int *pointer, double value)
|
||||
stack[(*pointer)++] = value;
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dst_transform)
|
||||
DISCRETE_STEP(dst_transform)
|
||||
{
|
||||
double trans_stack[MAX_TRANS_STACK];
|
||||
double number1,top;
|
||||
@ -1830,10 +1836,10 @@ static DISCRETE_STEP(dst_transform)
|
||||
#define DST_OP_AMP__INP0 DISCRETE_INPUT(1)
|
||||
#define DST_OP_AMP__INP1 DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dst_op_amp)
|
||||
DISCRETE_STEP(dst_op_amp)
|
||||
{
|
||||
const discrete_op_amp_info *info = (const discrete_op_amp_info *)node->custom;
|
||||
struct dst_op_amp_context *context = (struct dst_op_amp_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_op_amp)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_info)
|
||||
|
||||
double i_pos = 0;
|
||||
double i_neg = 0;
|
||||
@ -1897,10 +1903,10 @@ static DISCRETE_STEP(dst_op_amp)
|
||||
node->output[0] = 0;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_op_amp)
|
||||
DISCRETE_RESET(dst_op_amp)
|
||||
{
|
||||
const discrete_op_amp_info *info = (const discrete_op_amp_info *)node->custom;
|
||||
struct dst_op_amp_context *context = (struct dst_op_amp_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_op_amp)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_info)
|
||||
|
||||
context->has_r1 = info->r1 > 0;
|
||||
context->has_r4 = info->r4 > 0;
|
||||
@ -1941,10 +1947,10 @@ static DISCRETE_RESET(dst_op_amp)
|
||||
************************************************************************/
|
||||
#define DST_OP_AMP_1SHT__TRIGGER DISCRETE_INPUT(0)
|
||||
|
||||
static DISCRETE_STEP(dst_op_amp_1sht)
|
||||
DISCRETE_STEP(dst_op_amp_1sht)
|
||||
{
|
||||
const discrete_op_amp_1sht_info *info = (const discrete_op_amp_1sht_info *)node->custom;
|
||||
struct dst_op_amp_1sht_context *context = (struct dst_op_amp_1sht_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_op_amp_1sht)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_1sht_info)
|
||||
|
||||
double i_pos;
|
||||
double i_neg;
|
||||
@ -1981,10 +1987,10 @@ static DISCRETE_STEP(dst_op_amp_1sht)
|
||||
context->v_cap1 += ((node->output[0] - OP_AMP_NORTON_VBE) * context->r34ratio + OP_AMP_NORTON_VBE - context->v_cap1) * context->exponent1c;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_op_amp_1sht)
|
||||
DISCRETE_RESET(dst_op_amp_1sht)
|
||||
{
|
||||
const discrete_op_amp_1sht_info *info = (const discrete_op_amp_1sht_info *)node->custom;
|
||||
struct dst_op_amp_1sht_context *context = (struct dst_op_amp_1sht_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_op_amp_1sht)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_1sht_info)
|
||||
|
||||
context->exponent1c = RC_CHARGE_EXP(RES_2_PARALLEL(info->r3, info->r4) * info->c1);
|
||||
context->exponent1d = RC_CHARGE_EXP(info->r4 * info->c1);
|
||||
@ -2016,10 +2022,10 @@ static DISCRETE_RESET(dst_op_amp_1sht)
|
||||
#define DST_TVCA_OP_AMP__INP0 DISCRETE_INPUT(3)
|
||||
#define DST_TVCA_OP_AMP__INP1 DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_tvca_op_amp)
|
||||
DISCRETE_STEP(dst_tvca_op_amp)
|
||||
{
|
||||
const discrete_op_amp_tvca_info *info = (const discrete_op_amp_tvca_info *)node->custom;
|
||||
struct dst_tvca_op_amp_context *context = (struct dst_tvca_op_amp_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_tvca_op_amp)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_tvca_info)
|
||||
|
||||
int trig0, trig1, trig2, f3;
|
||||
double i2 = 0; /* current through r2 */
|
||||
@ -2116,10 +2122,10 @@ static DISCRETE_STEP(dst_tvca_op_amp)
|
||||
if (node->output[0] > context->v_out_max) node->output[0] = context->v_out_max;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dst_tvca_op_amp)
|
||||
DISCRETE_RESET(dst_tvca_op_amp)
|
||||
{
|
||||
const discrete_op_amp_tvca_info *info = (const discrete_op_amp_tvca_info *)node->custom;
|
||||
struct dst_tvca_op_amp_context *context = (struct dst_tvca_op_amp_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dst_tvca_op_amp)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_tvca_info)
|
||||
|
||||
context->r67 = info->r6 + info->r7;
|
||||
|
||||
@ -2195,7 +2201,7 @@ enum
|
||||
#define DST_XTIME_BUFFER_OUT_HIGH DISCRETE_INPUT(2)
|
||||
#define DST_XTIME_BUFFER_INVERT DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dst_xtime_buffer)
|
||||
DISCRETE_STEP(dst_xtime_buffer)
|
||||
{
|
||||
int in0 = (int)DST_XTIME_BUFFER__IN;
|
||||
int out = in0;
|
||||
@ -2242,7 +2248,7 @@ static DISCRETE_STEP(dst_xtime_buffer)
|
||||
#define DST_XTIME_AND_OUT_HIGH DISCRETE_INPUT(3)
|
||||
#define DST_XTIME_AND_INVERT DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_xtime_and)
|
||||
DISCRETE_STEP(dst_xtime_and)
|
||||
{
|
||||
int in0 = (int)DST_XTIME_AND__IN0;
|
||||
int in1 = (int)DST_XTIME_AND__IN1;
|
||||
@ -2462,7 +2468,7 @@ static DISCRETE_STEP(dst_xtime_and)
|
||||
#define DST_XTIME_OR_OUT_HIGH DISCRETE_INPUT(3)
|
||||
#define DST_XTIME_OR_INVERT DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_xtime_or)
|
||||
DISCRETE_STEP(dst_xtime_or)
|
||||
{
|
||||
int in0 = (int)DST_XTIME_OR__IN0;
|
||||
int in1 = (int)DST_XTIME_OR__IN1;
|
||||
@ -2687,7 +2693,7 @@ static DISCRETE_STEP(dst_xtime_or)
|
||||
#define DST_XTIME_XOR_OUT_HIGH DISCRETE_INPUT(3)
|
||||
#define DST_XTIME_XOR_INVERT DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dst_xtime_xor)
|
||||
DISCRETE_STEP(dst_xtime_xor)
|
||||
{
|
||||
int in0 = (int)DST_XTIME_XOR__IN0;
|
||||
int in1 = (int)DST_XTIME_XOR__IN1;
|
||||
|
@ -23,7 +23,7 @@ struct dso_csvlog_context
|
||||
char name[32];
|
||||
};
|
||||
|
||||
struct dso_wavelog_context
|
||||
struct dso_wavlog_context
|
||||
{
|
||||
wav_file *wavfile;
|
||||
char name[32];
|
||||
@ -103,9 +103,12 @@ static void task_check(discrete_task *task, discrete_task *dest_task)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_START( dso_task_start )
|
||||
#define DISCRETE_DECLARE_TASK discrete_task *task = (discrete_task *) node->context;
|
||||
|
||||
DISCRETE_START( dso_task_start )
|
||||
{
|
||||
discrete_task *task = (discrete_task *) node->context;
|
||||
DISCRETE_DECLARE_TASK
|
||||
|
||||
const linked_list_entry *task_entry;
|
||||
|
||||
task->task_group = (int) DISCRETE_INPUT(0);
|
||||
@ -123,18 +126,20 @@ static DISCRETE_START( dso_task_start )
|
||||
|
||||
}
|
||||
|
||||
static DISCRETE_STEP( dso_task_end )
|
||||
DISCRETE_STEP( dso_task_end )
|
||||
{
|
||||
discrete_task *task = (discrete_task *) node->context;
|
||||
DISCRETE_DECLARE_TASK
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < task->numbuffered; i++)
|
||||
*(task->ptr[i]++) = *task->source[i];
|
||||
}
|
||||
|
||||
static DISCRETE_STEP( dso_task_start )
|
||||
DISCRETE_STEP( dso_task_start )
|
||||
{
|
||||
const discrete_task *task = (discrete_task *) node->context;
|
||||
DISCRETE_DECLARE_TASK
|
||||
|
||||
const linked_list_entry *entry;
|
||||
|
||||
/* update source node buffer */
|
||||
@ -146,12 +151,12 @@ static DISCRETE_STEP( dso_task_start )
|
||||
}
|
||||
|
||||
|
||||
static DISCRETE_RESET( dso_task )
|
||||
DISCRETE_RESET( dso_task )
|
||||
{
|
||||
/* nothing to do - just avoid being stepped */
|
||||
}
|
||||
|
||||
static DISCRETE_STEP( dso_output )
|
||||
DISCRETE_STEP( dso_output )
|
||||
{
|
||||
stream_sample_t **output = (stream_sample_t **) &node->context;
|
||||
double val;
|
||||
@ -163,14 +168,15 @@ static DISCRETE_STEP( dso_output )
|
||||
(*output)++;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET( dso_output )
|
||||
DISCRETE_RESET( dso_output )
|
||||
{
|
||||
/* nothing to do - just avoid being stepped */
|
||||
}
|
||||
|
||||
static DISCRETE_START( dso_csvlog )
|
||||
DISCRETE_START( dso_csvlog )
|
||||
{
|
||||
struct dso_csvlog_context *context = (struct dso_csvlog_context *) node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dso_csvlog)
|
||||
|
||||
int log_num, node_num;
|
||||
|
||||
log_num = node_module_index(node);
|
||||
@ -191,18 +197,19 @@ static DISCRETE_START( dso_csvlog )
|
||||
fprintf(context->csv_file, "\n");
|
||||
}
|
||||
|
||||
static DISCRETE_STOP( dso_csvlog )
|
||||
DISCRETE_STOP( dso_csvlog )
|
||||
{
|
||||
struct dso_csvlog_context *context = (struct dso_csvlog_context *) node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dso_csvlog)
|
||||
|
||||
/* close any csv files */
|
||||
if (context->csv_file)
|
||||
fclose(context->csv_file);
|
||||
}
|
||||
|
||||
static DISCRETE_STEP( dso_csvlog )
|
||||
DISCRETE_STEP( dso_csvlog )
|
||||
{
|
||||
struct dso_csvlog_context *context = (struct dso_csvlog_context *) node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dso_csvlog)
|
||||
|
||||
int nodenum;
|
||||
|
||||
/* Dump any csv logs */
|
||||
@ -214,9 +221,10 @@ static DISCRETE_STEP( dso_csvlog )
|
||||
fprintf(context->csv_file, "\n");
|
||||
}
|
||||
|
||||
static DISCRETE_START( dso_wavelog )
|
||||
DISCRETE_START( dso_wavlog )
|
||||
{
|
||||
struct dso_wavelog_context *context = (struct dso_wavelog_context *) node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dso_wavlog)
|
||||
|
||||
int log_num;
|
||||
|
||||
log_num = node_module_index(node);
|
||||
@ -224,18 +232,19 @@ static DISCRETE_START( dso_wavelog )
|
||||
context->wavfile = wav_open(context->name, node->info->sample_rate, node->active_inputs/2);
|
||||
}
|
||||
|
||||
static DISCRETE_STOP( dso_wavelog )
|
||||
DISCRETE_STOP( dso_wavlog )
|
||||
{
|
||||
struct dso_wavelog_context *context = (struct dso_wavelog_context *) node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dso_wavlog)
|
||||
|
||||
/* close any wave files */
|
||||
if (context->wavfile)
|
||||
wav_close(context->wavfile);
|
||||
}
|
||||
|
||||
static DISCRETE_STEP( dso_wavelog )
|
||||
DISCRETE_STEP( dso_wavlog )
|
||||
{
|
||||
struct dso_wavelog_context *context = (struct dso_wavelog_context *) node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dso_wavlog)
|
||||
|
||||
double val;
|
||||
INT16 wave_data_l, wave_data_r;
|
||||
|
||||
@ -246,12 +255,12 @@ static DISCRETE_STEP( dso_wavelog )
|
||||
wave_data_l = (INT16)val;
|
||||
if (node->active_inputs == 2)
|
||||
{
|
||||
/* DISCRETE_WAVELOG1 */
|
||||
/* DISCRETE_WAVLOG1 */
|
||||
wav_add_data_16(context->wavfile, &wave_data_l, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* DISCRETE_WAVELOG2 */
|
||||
/* DISCRETE_WAVLOG2 */
|
||||
val = DISCRETE_INPUT(2) * DISCRETE_INPUT(3);
|
||||
val = (val < -32768) ? -32768 : (val > 32767) ? 32767 : val;
|
||||
wave_data_r = (INT16)val;
|
||||
|
@ -190,9 +190,10 @@ struct dss_trianglewave_context
|
||||
|
||||
static const int disc_7492_count[6] = {0x00, 0x01, 0x02, 0x04, 0x05, 0x06};
|
||||
|
||||
static DISCRETE_STEP(dss_counter)
|
||||
DISCRETE_STEP(dss_counter)
|
||||
{
|
||||
struct dss_counter_context *context = (struct dss_counter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_counter)
|
||||
|
||||
double cycles;
|
||||
double ds_clock;
|
||||
int clock = 0, last_count, inc = 0;
|
||||
@ -295,9 +296,9 @@ static DISCRETE_STEP(dss_counter)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_counter)
|
||||
DISCRETE_RESET(dss_counter)
|
||||
{
|
||||
struct dss_counter_context *context = (struct dss_counter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_counter)
|
||||
|
||||
if (DSS_COUNTER__MAX < DSS_COUNTER__MIN)
|
||||
fatalerror("MAX < MIN in NODE_%02d", NODE_INDEX(node->block->node));
|
||||
@ -411,17 +412,18 @@ INLINE int dss_lfsr_function(const discrete_info *disc_info, int myfunc, int in0
|
||||
}
|
||||
|
||||
/* reset prototype so that it can be used in init function */
|
||||
static DISCRETE_RESET(dss_lfsr);
|
||||
DISCRETE_RESET(dss_lfsr);
|
||||
|
||||
static DISCRETE_STEP(dss_lfsr)
|
||||
DISCRETE_STEP(dss_lfsr)
|
||||
{
|
||||
const discrete_lfsr_desc *lfsr_desc = (const discrete_lfsr_desc *)node->custom;
|
||||
struct dss_lfsr_context *context = (struct dss_lfsr_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_lfsr)
|
||||
DISCRETE_DECLARE_INFO(discrete_lfsr_desc)
|
||||
|
||||
double cycles;
|
||||
int clock, inc = 0;
|
||||
int fb0, fb1, fbresult = 0, noise_feed;
|
||||
|
||||
if (lfsr_desc->clock_type == DISC_CLK_IS_FREQ)
|
||||
if (info->clock_type == DISC_CLK_IS_FREQ)
|
||||
{
|
||||
/* We need to keep clocking the internal clock even if disabled. */
|
||||
cycles = (context->t_left + node->info->sample_time) / context->t_clock;
|
||||
@ -436,7 +438,7 @@ static DISCRETE_STEP(dss_lfsr)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (lfsr_desc->clock_type)
|
||||
switch (info->clock_type)
|
||||
{
|
||||
case DISC_CLK_ON_F_EDGE:
|
||||
case DISC_CLK_ON_R_EDGE:
|
||||
@ -445,7 +447,7 @@ static DISCRETE_STEP(dss_lfsr)
|
||||
if (context->last != clock)
|
||||
{
|
||||
context->last = clock;
|
||||
if (lfsr_desc->clock_type == clock)
|
||||
if (info->clock_type == clock)
|
||||
{
|
||||
/* Toggled */
|
||||
inc = 1;
|
||||
@ -465,32 +467,32 @@ static DISCRETE_STEP(dss_lfsr)
|
||||
for (clock = 0; clock < inc; clock++)
|
||||
{
|
||||
/* Fetch the last feedback result */
|
||||
fbresult = (context->lfsr_reg >> lfsr_desc->bitlength) & 0x01;
|
||||
fbresult = (context->lfsr_reg >> info->bitlength) & 0x01;
|
||||
|
||||
/* Stage 2 feedback combine fbresultNew with infeed bit */
|
||||
fbresult = dss_lfsr_function(node->info, lfsr_desc->feedback_function1, fbresult, noise_feed, 0x01);
|
||||
fbresult = dss_lfsr_function(node->info, info->feedback_function1, fbresult, noise_feed, 0x01);
|
||||
|
||||
/* Stage 3 first we setup where the bit is going to be shifted into */
|
||||
fbresult = fbresult * lfsr_desc->feedback_function2_mask;
|
||||
fbresult = fbresult * info->feedback_function2_mask;
|
||||
/* Then we left shift the register, */
|
||||
context->lfsr_reg = context->lfsr_reg << 1;
|
||||
/* Now move the fbresult into the shift register and mask it to the bitlength */
|
||||
context->lfsr_reg = dss_lfsr_function(node->info, lfsr_desc->feedback_function2, fbresult, context->lfsr_reg, (1 << lfsr_desc->bitlength) - 1 );
|
||||
context->lfsr_reg = dss_lfsr_function(node->info, info->feedback_function2, fbresult, context->lfsr_reg, (1 << info->bitlength) - 1 );
|
||||
|
||||
/* Now get and store the new feedback result */
|
||||
/* Fetch the feedback bits */
|
||||
fb0 = (context->lfsr_reg >> lfsr_desc->feedback_bitsel0) & 0x01;
|
||||
fb1 = (context->lfsr_reg >> lfsr_desc->feedback_bitsel1) & 0x01;
|
||||
fb0 = (context->lfsr_reg >> info->feedback_bitsel0) & 0x01;
|
||||
fb1 = (context->lfsr_reg >> info->feedback_bitsel1) & 0x01;
|
||||
/* Now do the combo on them */
|
||||
fbresult = dss_lfsr_function(node->info, lfsr_desc->feedback_function0, fb0, fb1, 0x01);
|
||||
context->lfsr_reg = dss_lfsr_function(node->info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << lfsr_desc->bitlength, (2 << lfsr_desc->bitlength) - 1);
|
||||
fbresult = dss_lfsr_function(node->info, info->feedback_function0, fb0, fb1, 0x01);
|
||||
context->lfsr_reg = dss_lfsr_function(node->info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << info->bitlength, (2 << info->bitlength) - 1);
|
||||
|
||||
}
|
||||
/* Now select the output bit */
|
||||
if (context->out_is_f0)
|
||||
node->output[0] = fbresult & 0x01;
|
||||
else
|
||||
node->output[0] = (context->lfsr_reg >> lfsr_desc->output_bit) & 0x01;
|
||||
node->output[0] = (context->lfsr_reg >> info->output_bit) & 0x01;
|
||||
|
||||
/* Final inversion if required */
|
||||
if (context->invert_output) node->output[0] = node->output[0] ? 0 : 1;
|
||||
@ -511,39 +513,40 @@ static DISCRETE_STEP(dss_lfsr)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_lfsr)
|
||||
DISCRETE_RESET(dss_lfsr)
|
||||
{
|
||||
const discrete_lfsr_desc *lfsr_desc = (const discrete_lfsr_desc *)node->custom;
|
||||
struct dss_lfsr_context *context = (struct dss_lfsr_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_lfsr)
|
||||
DISCRETE_DECLARE_INFO(discrete_lfsr_desc)
|
||||
|
||||
int fb0 , fb1, fbresult;
|
||||
|
||||
context->reset_on_high = (lfsr_desc->flags & DISC_LFSR_FLAG_RESET_TYPE_H) ? 1 : 0;
|
||||
context->invert_output = lfsr_desc->flags & DISC_LFSR_FLAG_OUT_INVERT;
|
||||
context->out_is_f0 = (lfsr_desc->flags & DISC_LFSR_FLAG_OUTPUT_F0) ? 1 : 0;
|
||||
context->out_lfsr_reg = (lfsr_desc->flags & DISC_LFSR_FLAG_OUTPUT_SR_SN1) ? 1 : 0;
|
||||
context->reset_on_high = (info->flags & DISC_LFSR_FLAG_RESET_TYPE_H) ? 1 : 0;
|
||||
context->invert_output = info->flags & DISC_LFSR_FLAG_OUT_INVERT;
|
||||
context->out_is_f0 = (info->flags & DISC_LFSR_FLAG_OUTPUT_F0) ? 1 : 0;
|
||||
context->out_lfsr_reg = (info->flags & DISC_LFSR_FLAG_OUTPUT_SR_SN1) ? 1 : 0;
|
||||
|
||||
if ((lfsr_desc->clock_type < DISC_CLK_ON_F_EDGE) || (lfsr_desc->clock_type > DISC_CLK_IS_FREQ))
|
||||
if ((info->clock_type < DISC_CLK_ON_F_EDGE) || (info->clock_type > DISC_CLK_IS_FREQ))
|
||||
discrete_log(node->info, "Invalid clock type passed in NODE_%d\n", NODE_BLOCKINDEX(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;
|
||||
if (info->clock_type == DISC_CLK_IS_FREQ) context->t_clock = 1.0 / DSS_LFSR_NOISE__CLOCK;
|
||||
context->t_left = 0;
|
||||
|
||||
context->lfsr_reg = lfsr_desc->reset_value;
|
||||
context->lfsr_reg = info->reset_value;
|
||||
|
||||
/* Now get and store the new feedback result */
|
||||
/* Fetch the feedback bits */
|
||||
fb0 = (context->lfsr_reg >> lfsr_desc->feedback_bitsel0) & 0x01;
|
||||
fb1=(context->lfsr_reg >> lfsr_desc->feedback_bitsel1) & 0x01;
|
||||
fb0 = (context->lfsr_reg >> info->feedback_bitsel0) & 0x01;
|
||||
fb1=(context->lfsr_reg >> info->feedback_bitsel1) & 0x01;
|
||||
/* Now do the combo on them */
|
||||
fbresult = dss_lfsr_function(node->info, lfsr_desc->feedback_function0, fb0, fb1, 0x01);
|
||||
context->lfsr_reg=dss_lfsr_function(node->info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << lfsr_desc->bitlength, (2<< lfsr_desc->bitlength ) - 1);
|
||||
fbresult = dss_lfsr_function(node->info, info->feedback_function0, fb0, fb1, 0x01);
|
||||
context->lfsr_reg=dss_lfsr_function(node->info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << info->bitlength, (2<< info->bitlength ) - 1);
|
||||
|
||||
/* Now select and setup the output bit */
|
||||
node->output[0] = (context->lfsr_reg >> lfsr_desc->output_bit) & 0x01;
|
||||
node->output[0] = (context->lfsr_reg >> info->output_bit) & 0x01;
|
||||
|
||||
/* Final inversion if required */
|
||||
if(lfsr_desc->flags & DISC_LFSR_FLAG_OUT_INVERT) node->output[0] = node->output[0] ? 0 : 1;
|
||||
if(info->flags & DISC_LFSR_FLAG_OUT_INVERT) node->output[0] = node->output[0] ? 0 : 1;
|
||||
|
||||
/* Gain stage */
|
||||
node->output[0] = node->output[0] ? DSS_LFSR_NOISE__AMP / 2 : -DSS_LFSR_NOISE__AMP / 2;
|
||||
@ -567,9 +570,9 @@ static DISCRETE_RESET(dss_lfsr)
|
||||
#define DSS_NOISE__AMP DISCRETE_INPUT(2)
|
||||
#define DSS_NOISE__BIAS DISCRETE_INPUT(3)
|
||||
|
||||
static DISCRETE_STEP(dss_noise)
|
||||
DISCRETE_STEP(dss_noise)
|
||||
{
|
||||
struct dss_noise_context *context = (struct dss_noise_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_noise)
|
||||
|
||||
if(DSS_NOISE__ENABLE)
|
||||
{
|
||||
@ -604,9 +607,9 @@ static DISCRETE_STEP(dss_noise)
|
||||
}
|
||||
|
||||
|
||||
static DISCRETE_RESET(dss_noise)
|
||||
DISCRETE_RESET(dss_noise)
|
||||
{
|
||||
struct dss_noise_context *context = (struct dss_noise_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_noise)
|
||||
|
||||
context->phase=0;
|
||||
DISCRETE_STEP_CALL( dss_noise );
|
||||
@ -633,9 +636,9 @@ static DISCRETE_RESET(dss_noise)
|
||||
#define DSS_NOTE__MAX2 DISCRETE_INPUT(4)
|
||||
#define DSS_NOTE__CLOCK_TYPE DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dss_note)
|
||||
DISCRETE_STEP(dss_note)
|
||||
{
|
||||
struct dss_note_context *context = (struct dss_note_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_note)
|
||||
|
||||
double cycles;
|
||||
int clock = 0, last_count2, inc = 0;
|
||||
@ -723,9 +726,9 @@ static DISCRETE_STEP(dss_note)
|
||||
node->output[0] = 0;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_note)
|
||||
DISCRETE_RESET(dss_note)
|
||||
{
|
||||
struct dss_note_context *context = (struct dss_note_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_note)
|
||||
|
||||
context->clock_type = (int)DSS_NOTE__CLOCK_TYPE & DISC_CLK_MASK;
|
||||
context->out_type = (int)DSS_NOTE__CLOCK_TYPE & DISC_OUT_MASK;
|
||||
@ -762,11 +765,10 @@ static DISCRETE_RESET(dss_note)
|
||||
/* the same to save a calculation step */
|
||||
#define DSS_OP_AMP_OSC_NORTON_VP_IN context->v_out_high
|
||||
|
||||
static DISCRETE_STEP(dss_op_amp_osc)
|
||||
DISCRETE_STEP(dss_op_amp_osc)
|
||||
{
|
||||
const discrete_op_amp_osc_info *info = (const discrete_op_amp_osc_info *)node->custom;
|
||||
struct dss_op_amp_osc_context *context = (struct dss_op_amp_osc_context *)node->context;
|
||||
|
||||
DISCRETE_DECLARE_CONTEXT(dss_op_amp_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_osc_info)
|
||||
|
||||
double i = 0; /* Charging current created by vIn */
|
||||
double v = 0; /* all input voltages mixed */
|
||||
@ -1025,10 +1027,11 @@ static DISCRETE_STEP(dss_op_amp_osc)
|
||||
|
||||
#define DIODE_DROP 0.7
|
||||
|
||||
static DISCRETE_RESET(dss_op_amp_osc)
|
||||
DISCRETE_RESET(dss_op_amp_osc)
|
||||
{
|
||||
const discrete_op_amp_osc_info *info = (const discrete_op_amp_osc_info *)node->custom;
|
||||
struct dss_op_amp_osc_context *context = (struct dss_op_amp_osc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_op_amp_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_op_amp_osc_info)
|
||||
|
||||
const double *r_info_ptr;
|
||||
const double **r_context_ptr;
|
||||
int loop;
|
||||
@ -1230,9 +1233,9 @@ static DISCRETE_RESET(dss_op_amp_osc)
|
||||
#define DSS_SAWTOOTHWAVE__GRAD DISCRETE_INPUT(4)
|
||||
#define DSS_SAWTOOTHWAVE__PHASE DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dss_sawtoothwave)
|
||||
DISCRETE_STEP(dss_sawtoothwave)
|
||||
{
|
||||
struct dss_sawtoothwave_context *context = (struct dss_sawtoothwave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_sawtoothwave)
|
||||
|
||||
if(DSS_SAWTOOTHWAVE__ENABLE)
|
||||
{
|
||||
@ -1256,9 +1259,10 @@ static DISCRETE_STEP(dss_sawtoothwave)
|
||||
context->phase = fmod((context->phase + ((2.0 * M_PI * DSS_SAWTOOTHWAVE__FREQ) / node->info->sample_rate)), 2.0 * M_PI);
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_sawtoothwave)
|
||||
DISCRETE_RESET(dss_sawtoothwave)
|
||||
{
|
||||
struct dss_sawtoothwave_context *context = (struct dss_sawtoothwave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_sawtoothwave)
|
||||
|
||||
double start;
|
||||
|
||||
/* Establish starting phase, convert from degrees to radians */
|
||||
@ -1290,10 +1294,10 @@ static DISCRETE_RESET(dss_sawtoothwave)
|
||||
#define DSS_SCHMITT_OSC__VIN DISCRETE_INPUT(1)
|
||||
#define DSS_SCHMITT_OSC__AMP DISCRETE_INPUT(2)
|
||||
|
||||
static DISCRETE_STEP(dss_schmitt_osc)
|
||||
DISCRETE_STEP(dss_schmitt_osc)
|
||||
{
|
||||
const discrete_schmitt_osc_desc *info = (const discrete_schmitt_osc_desc *)node->custom;
|
||||
struct dss_schmitt_osc_context *context = (struct dss_schmitt_osc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_schmitt_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_schmitt_osc_desc)
|
||||
|
||||
double supply, v_cap, new_vCap, t, exponent;
|
||||
|
||||
@ -1364,10 +1368,11 @@ static DISCRETE_STEP(dss_schmitt_osc)
|
||||
node->output[0] *= DSS_SCHMITT_OSC__AMP;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_schmitt_osc)
|
||||
DISCRETE_RESET(dss_schmitt_osc)
|
||||
{
|
||||
const discrete_schmitt_osc_desc *info = (const discrete_schmitt_osc_desc *)node->custom;
|
||||
struct dss_schmitt_osc_context *context = (struct dss_schmitt_osc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_schmitt_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_schmitt_osc_desc)
|
||||
|
||||
double rSource;
|
||||
|
||||
context->enable_type = info->options & DISC_SCHMITT_OSC_ENAB_MASK;
|
||||
@ -1409,9 +1414,9 @@ static DISCRETE_RESET(dss_schmitt_osc)
|
||||
#define DSS_SINEWAVE__BIAS DISCRETE_INPUT(3)
|
||||
#define DSS_SINEWAVE__PHASE DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dss_sinewave)
|
||||
DISCRETE_STEP(dss_sinewave)
|
||||
{
|
||||
struct dss_sinewave_context *context = (struct dss_sinewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_sinewave)
|
||||
|
||||
/* Set the output */
|
||||
if(DSS_SINEWAVE__ENABLE)
|
||||
@ -1435,9 +1440,10 @@ static DISCRETE_STEP(dss_sinewave)
|
||||
context->phase=fmod((context->phase + ((2.0 * M_PI * DSS_SINEWAVE__FREQ) / node->info->sample_rate)), 2.0 * M_PI);
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_sinewave)
|
||||
DISCRETE_RESET(dss_sinewave)
|
||||
{
|
||||
struct dss_sinewave_context *context = (struct dss_sinewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_sinewave)
|
||||
|
||||
double start;
|
||||
|
||||
/* Establish starting phase, convert from degrees to radians */
|
||||
@ -1468,9 +1474,9 @@ static DISCRETE_RESET(dss_sinewave)
|
||||
#define DSS_SQUAREWAVE__BIAS DISCRETE_INPUT(4)
|
||||
#define DSS_SQUAREWAVE__PHASE DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dss_squarewave)
|
||||
DISCRETE_STEP(dss_squarewave)
|
||||
{
|
||||
struct dss_squarewave_context *context = (struct dss_squarewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_squarewave)
|
||||
|
||||
/* Establish trigger phase from duty */
|
||||
context->trigger=((100-DSS_SQUAREWAVE__DUTY)/100)*(2.0*M_PI);
|
||||
@ -1501,9 +1507,10 @@ static DISCRETE_STEP(dss_squarewave)
|
||||
context->phase=fmod(context->phase + ((2.0 * M_PI * DSS_SQUAREWAVE__FREQ) / node->info->sample_rate), 2.0 * M_PI);
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_squarewave)
|
||||
DISCRETE_RESET(dss_squarewave)
|
||||
{
|
||||
struct dss_squarewave_context *context = (struct dss_squarewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_squarewave)
|
||||
|
||||
double start;
|
||||
|
||||
/* Establish starting phase, convert from degrees to radians */
|
||||
@ -1534,9 +1541,9 @@ static DISCRETE_RESET(dss_squarewave)
|
||||
#define DSS_SQUAREWFIX__BIAS DISCRETE_INPUT(4)
|
||||
#define DSS_SQUAREWFIX__PHASE DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dss_squarewfix)
|
||||
DISCRETE_STEP(dss_squarewfix)
|
||||
{
|
||||
struct dss_squarewfix_context *context = (struct dss_squarewfix_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_squarewfix)
|
||||
|
||||
context->t_left -= context->sample_step;
|
||||
|
||||
@ -1563,9 +1570,9 @@ static DISCRETE_STEP(dss_squarewfix)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_squarewfix)
|
||||
DISCRETE_RESET(dss_squarewfix)
|
||||
{
|
||||
struct dss_squarewfix_context *context = (struct dss_squarewfix_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_squarewfix)
|
||||
|
||||
context->sample_step = 1.0 / node->info->sample_rate;
|
||||
context->flip_flop = 1;
|
||||
@ -1612,9 +1619,10 @@ static DISCRETE_RESET(dss_squarewfix)
|
||||
#define DSS_SQUAREWAVE2__BIAS DISCRETE_INPUT(4)
|
||||
#define DSS_SQUAREWAVE2__SHIFT DISCRETE_INPUT(5)
|
||||
|
||||
static DISCRETE_STEP(dss_squarewave2)
|
||||
DISCRETE_STEP(dss_squarewave2)
|
||||
{
|
||||
struct dss_squarewave_context *context = (struct dss_squarewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_squarewave)
|
||||
|
||||
double newphase;
|
||||
|
||||
if(DSS_SQUAREWAVE2__ENABLE)
|
||||
@ -1647,9 +1655,10 @@ static DISCRETE_STEP(dss_squarewave2)
|
||||
}
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_squarewave2)
|
||||
DISCRETE_RESET(dss_squarewave2)
|
||||
{
|
||||
struct dss_squarewave_context *context = (struct dss_squarewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_squarewave)
|
||||
|
||||
double start;
|
||||
|
||||
/* Establish starting phase, convert from degrees to radians */
|
||||
@ -1685,8 +1694,8 @@ static DISCRETE_RESET(dss_squarewave2)
|
||||
|
||||
INLINE double dss_inverter_tftab(const node_description *node, double x)
|
||||
{
|
||||
const discrete_inverter_osc_desc *info = (const discrete_inverter_osc_desc *)node->custom;
|
||||
struct dss_inverter_osc_context *context = (struct dss_inverter_osc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_inverter_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_inverter_osc_desc)
|
||||
|
||||
x = x / info->vB;
|
||||
if (x > 0)
|
||||
@ -1697,8 +1706,8 @@ INLINE double dss_inverter_tftab(const node_description *node, double x)
|
||||
|
||||
INLINE double dss_inverter_tf(const node_description *node, double x)
|
||||
{
|
||||
const discrete_inverter_osc_desc *info = (const discrete_inverter_osc_desc *)node->custom;
|
||||
struct dss_inverter_osc_context *context = (struct dss_inverter_osc_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_inverter_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_inverter_osc_desc)
|
||||
|
||||
if (x < 0.0)
|
||||
return info->vB;
|
||||
@ -1708,10 +1717,10 @@ INLINE double dss_inverter_tf(const node_description *node, double x)
|
||||
return context->tf_tab[DSS_INV_TAB_SIZE - 1];
|
||||
}
|
||||
|
||||
static DISCRETE_STEP(dss_inverter_osc)
|
||||
DISCRETE_STEP(dss_inverter_osc)
|
||||
{
|
||||
struct dss_inverter_osc_context *context = (struct dss_inverter_osc_context *)node->context;
|
||||
const discrete_inverter_osc_desc *info = (const discrete_inverter_osc_desc *)node->custom;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_inverter_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_inverter_osc_desc)
|
||||
|
||||
double diff, vG1, vG2, vG3, vI;
|
||||
double vMix, rMix;
|
||||
@ -1823,10 +1832,10 @@ static DISCRETE_STEP(dss_inverter_osc)
|
||||
node->output[0] = (node->output[0] > info->vInFall);
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_inverter_osc)
|
||||
DISCRETE_RESET(dss_inverter_osc)
|
||||
{
|
||||
struct dss_inverter_osc_context *context = (struct dss_inverter_osc_context *)node->context;
|
||||
const discrete_inverter_osc_desc *info = (const discrete_inverter_osc_desc *)node->custom;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_inverter_osc)
|
||||
DISCRETE_DECLARE_INFO(discrete_inverter_osc_desc)
|
||||
|
||||
int i;
|
||||
|
||||
@ -1867,9 +1876,9 @@ static DISCRETE_RESET(dss_inverter_osc)
|
||||
#define DSS_TRIANGLEWAVE__BIAS DISCRETE_INPUT(3)
|
||||
#define DSS_TRIANGLEWAVE__PHASE DISCRETE_INPUT(4)
|
||||
|
||||
static DISCRETE_STEP(dss_trianglewave)
|
||||
DISCRETE_STEP(dss_trianglewave)
|
||||
{
|
||||
struct dss_trianglewave_context *context = (struct dss_trianglewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_trianglewave)
|
||||
|
||||
if(DSS_TRIANGLEWAVE__ENABLE)
|
||||
{
|
||||
@ -1894,9 +1903,10 @@ static DISCRETE_STEP(dss_trianglewave)
|
||||
context->phase=fmod((context->phase + ((2.0 * M_PI * DSS_TRIANGLEWAVE__FREQ) / node->info->sample_rate)), 2.0 * M_PI);
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(dss_trianglewave)
|
||||
DISCRETE_RESET(dss_trianglewave)
|
||||
{
|
||||
struct dss_trianglewave_context *context = (struct dss_trianglewave_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dss_trianglewave)
|
||||
|
||||
double start;
|
||||
|
||||
/* Establish starting phase, convert from degrees to radians */
|
||||
@ -1920,10 +1930,8 @@ static DISCRETE_RESET(dss_trianglewave)
|
||||
************************************************************************/
|
||||
#define DSS_ADSR__ENABLE DISCRETE_INPUT(0)
|
||||
|
||||
static DISCRETE_STEP(dss_adsrenv)
|
||||
DISCRETE_STEP(dss_adsrenv)
|
||||
{
|
||||
/* struct dss_adsr_context *context = node->context; */
|
||||
|
||||
if(DSS_ADSR__ENABLE)
|
||||
{
|
||||
node->output[0] = 0;
|
||||
@ -1935,7 +1943,7 @@ static DISCRETE_STEP(dss_adsrenv)
|
||||
}
|
||||
|
||||
|
||||
static DISCRETE_RESET(dss_adsrenv)
|
||||
DISCRETE_RESET(dss_adsrenv)
|
||||
{
|
||||
DISCRETE_STEP_CALL(dss_adsrenv);
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ static const discrete_module module_list[] =
|
||||
{
|
||||
{ DSO_OUTPUT ,"DSO_OUTPUT" , 0 ,0 ,dso_output_reset ,dso_output_step ,NULL ,NULL },
|
||||
{ DSO_CSVLOG ,"DSO_CSVLOG" , 0 ,sizeof(struct dso_csvlog_context) ,NULL ,dso_csvlog_step ,dso_csvlog_start ,dso_csvlog_stop },
|
||||
{ DSO_WAVELOG ,"DSO_WAVELOG" , 0 ,sizeof(struct dso_wavelog_context) ,NULL ,dso_wavelog_step ,dso_wavelog_start ,dso_wavelog_stop },
|
||||
{ DSO_WAVELOG ,"DSO_WAVELOG" , 0 ,sizeof(struct dso_wavlog_context) ,NULL ,dso_wavlog_step ,dso_wavlog_start ,dso_wavlog_stop },
|
||||
{ DSO_IMPORT ,"DSO_IMPORT" , 0 ,0 ,NULL ,NULL ,NULL ,NULL },
|
||||
|
||||
/* parallel modules */
|
||||
@ -261,7 +261,7 @@ static const discrete_module module_list[] =
|
||||
{ DST_LOOKUP_TABLE,"DST_LOOKUP_TABLE", 1 ,0 ,NULL ,dst_lookup_table_step,NULL ,NULL },
|
||||
{ DST_MULTIPLEX ,"DST_MULTIPLEX" , 1 ,sizeof(struct dst_size_context) ,dst_multiplex_reset ,dst_multiplex_step ,NULL ,NULL },
|
||||
{ DST_ONESHOT ,"DST_ONESHOT" , 1 ,sizeof(struct dst_oneshot_context) ,dst_oneshot_reset ,dst_oneshot_step ,NULL ,NULL },
|
||||
{ DST_RAMP ,"DST_RAMP" , 1 ,sizeof(struct dss_ramp_context) ,dst_ramp_reset ,dst_ramp_step ,NULL ,NULL },
|
||||
{ DST_RAMP ,"DST_RAMP" , 1 ,sizeof(struct dst_ramp_context) ,dst_ramp_reset ,dst_ramp_step ,NULL ,NULL },
|
||||
{ DST_SAMPHOLD ,"DST_SAMPHOLD" , 1 ,sizeof(struct dst_samphold_context) ,dst_samphold_reset ,dst_samphold_step ,NULL ,NULL },
|
||||
{ DST_SWITCH ,"DST_SWITCH" , 1 ,0 ,NULL ,dst_switch_step ,NULL ,NULL },
|
||||
{ DST_ASWITCH ,"DST_ASWITCH" , 1 ,0 ,NULL ,dst_aswitch_step ,NULL ,NULL },
|
||||
@ -269,7 +269,7 @@ static const discrete_module module_list[] =
|
||||
/* Component specific */
|
||||
{ DST_COMP_ADDER ,"DST_COMP_ADDER" , 1 ,sizeof(struct dst_comp_adder_context) ,dst_comp_adder_reset ,dst_comp_adder_step ,NULL ,NULL },
|
||||
{ DST_DAC_R1 ,"DST_DAC_R1" , 1 ,sizeof(struct dst_dac_r1_context) ,dst_dac_r1_reset ,dst_dac_r1_step ,NULL ,NULL },
|
||||
{ DST_DIODE_MIX ,"DST_DIODE_MIX" , 1 ,sizeof(struct dst_diode_mix__context) ,dst_diode_mix_reset ,dst_diode_mix_step ,NULL ,NULL },
|
||||
{ DST_DIODE_MIX ,"DST_DIODE_MIX" , 1 ,sizeof(struct dst_diode_mix_context) ,dst_diode_mix_reset ,dst_diode_mix_step ,NULL ,NULL },
|
||||
{ DST_INTEGRATE ,"DST_INTEGRATE" , 1 ,sizeof(struct dst_integrate_context) ,dst_integrate_reset ,dst_integrate_step ,NULL ,NULL },
|
||||
{ DST_MIXER ,"DST_MIXER" , 1 ,sizeof(struct dst_mixer_context) ,dst_mixer_reset ,dst_mixer_step ,NULL ,NULL },
|
||||
{ DST_OP_AMP ,"DST_OP_AMP" , 1 ,sizeof(struct dst_op_amp_context) ,dst_op_amp_reset ,dst_op_amp_step ,NULL ,NULL },
|
||||
@ -283,10 +283,10 @@ static const discrete_module module_list[] =
|
||||
|
||||
/* from disc_flt.c */
|
||||
/* Generic modules */
|
||||
{ DST_FILTER1 ,"DST_FILTER1" , 1 ,sizeof(struct dss_filter1_context) ,dst_filter1_reset ,dst_filter1_step ,NULL ,NULL },
|
||||
{ DST_FILTER2 ,"DST_FILTER2" , 1 ,sizeof(struct dss_filter2_context) ,dst_filter2_reset ,dst_filter2_step ,NULL ,NULL },
|
||||
{ DST_FILTER1 ,"DST_FILTER1" , 1 ,sizeof(struct dst_filter1_context) ,dst_filter1_reset ,dst_filter1_step ,NULL ,NULL },
|
||||
{ DST_FILTER2 ,"DST_FILTER2" , 1 ,sizeof(struct dst_filter2_context) ,dst_filter2_reset ,dst_filter2_step ,NULL ,NULL },
|
||||
/* Component specific modules */
|
||||
{ DST_SALLEN_KEY ,"DST_SALLEN_KEY" , 1 ,sizeof(struct dss_filter2_context) ,dst_sallen_key_reset ,dst_sallen_key_step ,NULL ,NULL },
|
||||
{ DST_SALLEN_KEY ,"DST_SALLEN_KEY" , 1 ,sizeof(struct dst_filter2_context) ,dst_sallen_key_reset ,dst_sallen_key_step ,NULL ,NULL },
|
||||
{ DST_CRFILTER ,"DST_CRFILTER" , 1 ,sizeof(struct dst_rcfilter_context) ,dst_crfilter_reset ,dst_crfilter_step ,NULL ,NULL },
|
||||
{ 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 ,NULL ,NULL },
|
||||
{ DST_RC_CIRCUIT_1,"DST_RC_CIRCUIT_1", 1 ,sizeof(struct dst_rc_circuit_1_context),dst_rc_circuit_1_reset,dst_rc_circuit_1_step,NULL ,NULL },
|
||||
@ -300,9 +300,9 @@ static const discrete_module module_list[] =
|
||||
{ DST_RCFILTER ,"DST_RCFILTER" , 1 ,sizeof(struct dst_rcfilter_context) ,dst_rcfilter_reset ,dst_rcfilter_step ,NULL ,NULL },
|
||||
{ DST_RCFILTER_SW ,"DST_RCFILTER_SW" , 1 ,sizeof(struct dst_rcfilter_sw_context) ,dst_rcfilter_sw_reset ,dst_rcfilter_sw_step ,NULL ,NULL },
|
||||
/* For testing - seem to be buggered. Use versions not ending in N. */
|
||||
{ DST_RCFILTERN ,"DST_RCFILTERN" , 1 ,sizeof(struct dss_filter1_context) ,dst_rcfilterN_reset ,dst_filter1_step ,NULL ,NULL },
|
||||
{ DST_RCDISCN ,"DST_RCDISCN" , 1 ,sizeof(struct dss_filter1_context) ,dst_rcdiscN_reset ,dst_rcdiscN_step ,NULL ,NULL },
|
||||
{ DST_RCDISC2N ,"DST_RCDISC2N" , 1 ,sizeof(struct dss_rcdisc2_context) ,dst_rcdisc2N_reset ,dst_rcdisc2N_step ,NULL ,NULL },
|
||||
{ DST_RCFILTERN ,"DST_RCFILTERN" , 1 ,sizeof(struct dst_filter1_context) ,dst_rcfilterN_reset ,dst_filter1_step ,NULL ,NULL },
|
||||
{ DST_RCDISCN ,"DST_RCDISCN" , 1 ,sizeof(struct dst_filter1_context) ,dst_rcdiscN_reset ,dst_rcdiscN_step ,NULL ,NULL },
|
||||
{ DST_RCDISC2N ,"DST_RCDISC2N" , 1 ,sizeof(struct dst_rcdisc2_context) ,dst_rcdisc2N_reset ,dst_rcdisc2N_step ,NULL ,NULL },
|
||||
|
||||
/* from disc_dev.c */
|
||||
/* generic modules */
|
||||
@ -314,7 +314,6 @@ static const discrete_module module_list[] =
|
||||
{ DSD_555_VCO1 ,"DSD_555_VCO1" , 1 ,sizeof(struct dsd_555_vco1_context) ,dsd_555_vco1_reset ,dsd_555_vco1_step ,NULL ,NULL },
|
||||
{ DSD_566 ,"DSD_566" , 1 ,sizeof(struct dsd_566_context) ,dsd_566_reset ,dsd_566_step ,NULL ,NULL },
|
||||
{ DSD_LS624 ,"DSD_LS624" , 1 ,sizeof(struct dsd_ls624_context) ,dsd_ls624_reset ,dsd_ls624_step ,NULL ,NULL },
|
||||
{ DSD_LS629 ,"DSD_LS629" , 1 ,sizeof(struct dsd_ls629_context) ,dsd_ls629_reset ,dsd_ls629_step ,NULL ,NULL },
|
||||
/* must be the last one */
|
||||
{ DSS_NULL ,"DSS_NULL" , 0 ,0 ,NULL ,NULL ,NULL ,NULL }
|
||||
};
|
||||
|
@ -25,7 +25,7 @@
|
||||
* http://www.ibiblio.org/obp/electricCircuits/
|
||||
* For a free circuit simulator:
|
||||
* http://qucs.sourceforge.net/index.html
|
||||
* For a free waveform editor to view DISCRETE_WAVELOG dumps:
|
||||
* For a free waveform editor to view DISCRETE_WAVLOG dumps:
|
||||
* http://audacity.sourceforge.net/
|
||||
* http://www.sonicvisualiser.org/
|
||||
*
|
||||
@ -315,8 +315,7 @@
|
||||
* DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS)
|
||||
* DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS)
|
||||
* DISCRETE_566(NODE,VMOD,R,C,VPOS,VNEG,VCHARGE,OPTIONS)
|
||||
* DISCRETE_74LS624(NODE,VMOD,VRNG,C,OUTTYPE)
|
||||
* DISCRETE_74LS629(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,OUTTYPE)
|
||||
* DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE)
|
||||
*
|
||||
* DISCRETE_CUSTOM1(NODE,IN0,INFO)
|
||||
* DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO)
|
||||
@ -333,8 +332,8 @@
|
||||
* DISCRETE_CSVLOG3(NODE1,NODE2,NODE3)
|
||||
* DISCRETE_CSVLOG4(NODE1,NODE2,NODE3,NODE4)
|
||||
* DISCRETE_CSVLOG5(NODE1,NODE2,NODE3,NODE4,NODE5)
|
||||
* DISCRETE_WAVELOG1(NODE1,GAIN1)
|
||||
* DISCRETE_WAVELOG2(NODE1,GAIN1,NODE2,GAIN2)
|
||||
* DISCRETE_WAVLOG1(NODE1,GAIN1)
|
||||
* DISCRETE_WAVLOG2(NODE1,GAIN1,NODE2,GAIN2)
|
||||
* DISCRETE_OUTPUT(OPNODE,GAIN)
|
||||
*
|
||||
***********************************************************************
|
||||
@ -1401,7 +1400,7 @@
|
||||
* will be output. Otherwise the Low/High voltages will be used
|
||||
* to convert the x_time to energy.
|
||||
*
|
||||
* EXAMPLES: see Mario, Donkey Kong Jr
|
||||
* EXAMPLES: see Mario Bros.; Donkey Kong Jr
|
||||
*
|
||||
***********************************************************************
|
||||
*
|
||||
@ -3315,49 +3314,54 @@
|
||||
*
|
||||
***********************************************************************
|
||||
*
|
||||
* DISCRETE_74LS624 - VCO.
|
||||
* DISCRETE_74LS624 - VCO. 1/2 of 74LS629.
|
||||
*
|
||||
* Simplified 74LS624 - calculated frequencies should match datasheet
|
||||
* for C > 1nF. Output is Logic (1/0)
|
||||
*
|
||||
* The datasheet gives no formulae. The implementation therefore is
|
||||
* a rough model of the diagrams given.
|
||||
* The datasheet gives no formulae. The implementation is based on
|
||||
* testing a 74LS629.
|
||||
*
|
||||
* For a LS628, use VRng = 3.2
|
||||
*
|
||||
* V+
|
||||
* |
|
||||
* .---------.
|
||||
* vRng >------------|Rng V+ |
|
||||
* | |
|
||||
* vMod >------------|Freq Z |---------> Netlist Node
|
||||
* | |
|
||||
* .---|CX1 |
|
||||
* | | |
|
||||
* --- | |
|
||||
* C --- | |
|
||||
* | | |
|
||||
* '---|CX2 |
|
||||
* '---------'
|
||||
* |
|
||||
* GND
|
||||
* V+
|
||||
* |
|
||||
* R_rng_in .---------.
|
||||
* vRng >-----------ZZZZ-------|Rng V+ |
|
||||
* R_freq_in | |
|
||||
* vMod >---ZZZZ-+-------------|Freq Z |---------> Netlist Node
|
||||
* | | |
|
||||
* C_freq_in --- .---|CX1 |
|
||||
* --- | | |
|
||||
* | --- | |
|
||||
* | C --- | |
|
||||
* Gnd | | |
|
||||
* '---|CX2 |
|
||||
* '---------'
|
||||
* |
|
||||
* GND
|
||||
*
|
||||
* Declaration syntax
|
||||
*
|
||||
* DISCRETE_74LS624(name of node,
|
||||
* DISCRETE_74LS624(name of node,(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,OUTTYPE)
|
||||
* enable node or static value,
|
||||
* vMod node or static value,
|
||||
* vRng static value,
|
||||
* C static value in Farads,
|
||||
* Type of output static value)
|
||||
* R_freq_in static value in Ohms,
|
||||
* C_freq_in static value in Farads,
|
||||
* R_rng_in static value in Ohms,
|
||||
* Type of output static value)
|
||||
*
|
||||
* Type of Output
|
||||
* DISC_LS624_OUT_ENERGY Energy - use for audio output
|
||||
* DISC_LS624_OUT_LOGIC Logic ( 0 or 1)
|
||||
* DISC_LS624_OUT_COUNT_F Number of Falling edges
|
||||
* DISC_LS624_OUT_COUNT_R Number of Rising edges
|
||||
* DISC_LS624_OUT_SQUARE - 4.4V square wave
|
||||
* DISC_LS624_OUT_ENERGY - 4.4V anti-aliased square wave
|
||||
* DISC_LS624_OUT_LOGIC - Logic ( 0 or 1)
|
||||
* DISC_LS624_OUT_LOGIC_X - Logic ( 0 or 1) with xime
|
||||
* DISC_LS624_OUT_COUNT_F - Number of Falling edges
|
||||
* DISC_LS624_OUT_COUNT_F_X - Number of Falling edges with xime
|
||||
* DISC_LS624_OUT_COUNT_R - Number of Rising edges
|
||||
* DISC_LS624_OUT_COUNT_R_X - Number of Rising edges with xime
|
||||
*
|
||||
*
|
||||
* EXAMPLES: see Donkey Kong Jr.
|
||||
* EXAMPLES: see Donkey Kong Jr.; Mario Bros.
|
||||
*
|
||||
***********************************************************************
|
||||
*
|
||||
@ -3380,7 +3384,7 @@
|
||||
* if you have used DISCRETE_STEP(basename) and DISCRETE_RESET(basename) to define
|
||||
* the step/reset procedures.
|
||||
*
|
||||
* EXAMPLES: see Donkey Kong, Mario Bros., Sky Raider
|
||||
* EXAMPLES: see Sky Raider, Donkey Kong
|
||||
*
|
||||
***********************************************************************
|
||||
=======================================================================
|
||||
@ -3409,21 +3413,21 @@
|
||||
*
|
||||
************************************************************************
|
||||
*
|
||||
* DISCRETE_WAVELOG - Dump nodes into a wav file
|
||||
* DISCRETE_WAVLOG - Dump nodes into a wav file
|
||||
*
|
||||
* Declaration syntax
|
||||
*
|
||||
* DISCRETE_WAVELOG1(node,
|
||||
* DISCRETE_WAVLOG1(node,
|
||||
* static gain for node)
|
||||
*
|
||||
* DISCRETE_WAVELOG2(left node,
|
||||
* DISCRETE_WAVLOG2(left node,
|
||||
* static gain for left node,
|
||||
* right node,
|
||||
* static gain for right node)
|
||||
*
|
||||
* Use this to monitor nodes while debugging the driver. You should
|
||||
* remove these nodes from the final driver. You can use up to a maximum
|
||||
* of DISCRETE_MAX_WAVELOGS. Each file will be called discreteX_Y.wav,
|
||||
* of DISCRETE_MAX_WAVLOGS. Each file will be called discreteX_Y.wav,
|
||||
* where X is the sound tag. Y is 0-9, in the order the file is
|
||||
* created in the driver.
|
||||
*
|
||||
@ -3501,16 +3505,19 @@
|
||||
|
||||
#define DISCRETE_FUNC(_func) void _func (node_description *node)
|
||||
|
||||
#define DISCRETE_STEP(_func) DISCRETE_FUNC(DISCRETE_STEP_NAME(_func))
|
||||
#define DISCRETE_RESET(_func) DISCRETE_FUNC(DISCRETE_RESET_NAME(_func))
|
||||
#define DISCRETE_START(_func) DISCRETE_FUNC(DISCRETE_START_NAME(_func))
|
||||
#define DISCRETE_STOP(_func) DISCRETE_FUNC(DISCRETE_STOP_NAME(_func))
|
||||
#define DISCRETE_STEP(_func) static DISCRETE_FUNC(DISCRETE_STEP_NAME(_func))
|
||||
#define DISCRETE_RESET(_func) static DISCRETE_FUNC(DISCRETE_RESET_NAME(_func))
|
||||
#define DISCRETE_START(_func) static DISCRETE_FUNC(DISCRETE_START_NAME(_func))
|
||||
#define DISCRETE_STOP(_func) static DISCRETE_FUNC(DISCRETE_STOP_NAME(_func))
|
||||
|
||||
#define DISCRETE_STEP_CALL(_func) DISCRETE_STEP_NAME(_func) (node)
|
||||
#define DISCRETE_RESET_CALL(_func) DISCRETE_RESET_NAME(_func) (node)
|
||||
#define DISCRETE_START_CALL(_func) DISCRETE_START_NAME(_func) (node)
|
||||
#define DISCRETE_STOP_CALL(_func) DISCRETE_STOP_NAME(_func) (node)
|
||||
|
||||
#define DISCRETE_DECLARE_CONTEXT(_name) struct _name##_context *context = (struct _name##_context *)node->context;
|
||||
#define DISCRETE_DECLARE_INFO(_name) const _name *info = (const _name *)node->custom;
|
||||
|
||||
#define DISCRETE_CUSTOM_MODULE(_basename, _context_type) \
|
||||
{ DST_CUSTOM, "CUSTOM", 1, sizeof(_context_type), DISCRETE_RESET_NAME(_basename), DISCRETE_STEP_NAME(_basename) }
|
||||
|
||||
@ -3725,11 +3732,11 @@ enum
|
||||
#define DISC_LS624_OUT_SQUARE 0x01
|
||||
#define DISC_LS624_OUT_ENERGY 0x02
|
||||
#define DISC_LS624_OUT_LOGIC 0x03
|
||||
#define DISC_LS624_OUT_LOGIC_X 0x08
|
||||
#define DISC_LS624_OUT_COUNT_F 0x04
|
||||
#define DISC_LS624_OUT_COUNT_R 0x05
|
||||
#define DISC_LS624_OUT_COUNT_F_X 0x06
|
||||
#define DISC_LS624_OUT_COUNT_R_X 0x07
|
||||
#define DISC_LS624_OUT_LOGIC_X 0x04
|
||||
#define DISC_LS624_OUT_COUNT_F 0x05
|
||||
#define DISC_LS624_OUT_COUNT_R 0x06
|
||||
#define DISC_LS624_OUT_COUNT_F_X 0x07
|
||||
#define DISC_LS624_OUT_COUNT_R_X 0x08
|
||||
|
||||
/* Oneshot types */
|
||||
#define DISC_ONESHOT_FEDGE 0x00
|
||||
@ -4379,7 +4386,6 @@ enum
|
||||
DSD_555_VCO1, /* Op-Amp linear ramp based 555 VCO */
|
||||
DSD_566, /* NE566 Emulation */
|
||||
DSD_LS624, /* 74LS624 Emulation */
|
||||
DSD_LS629, /* 74LS624 Emulation - new */
|
||||
|
||||
/* Custom */
|
||||
DST_CUSTOM, /* whatever you want */
|
||||
@ -4580,8 +4586,7 @@ enum
|
||||
#define DISCRETE_555_VCO1(NODE,RESET,VIN,OPTIONS) { NODE, DSD_555_VCO1 , 3, { RESET,VIN,NODE_NC }, { RESET,VIN,-1 }, OPTIONS, "DISCRETE_555_VCO1" },
|
||||
#define DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS) { NODE, DSD_555_VCO1 , 3, { RESET,VIN,CTRLV }, { RESET,VIN,CTRLV }, OPTIONS, "DISCRETE_555_VCO1_CV" },
|
||||
#define DISCRETE_566(NODE,VMOD,R,C,VPOS,VNEG,VCHARGE,OPTIONS) { NODE, DSD_566 , 7, { VMOD,R,C,NODE_NC,NODE_NC,VCHARGE,NODE_NC }, { VMOD,R,C,VPOS,VNEG,VCHARGE,OPTIONS }, NULL, "DISCRETE_566" },
|
||||
#define DISCRETE_74LS624(NODE,VMOD,VRNG,C,OUTTYPE) { NODE, DSD_LS624 , 4, { VMOD,NODE_NC,NODE_NC,NODE_NC }, { VMOD,VRNG,C,OUTTYPE }, NULL, "DISCRETE_74LS624" },
|
||||
#define DISCRETE_74LS629(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,OUTTYPE) { NODE, DSD_LS629 , 7, { ENAB,VMOD,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,OUTTYPE }, NULL, "DISCRETE_74LS629" },
|
||||
#define DISCRETE_74LS624(NODE,ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE) { NODE, DSD_LS624 , 8, { ENAB,VMOD,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,VMOD,VRNG,C,R_FREQ_IN,C_FREQ_IN,R_RNG_IN,OUTTYPE }, NULL, "DISCRETE_74LS624" },
|
||||
|
||||
/* NOP */
|
||||
#define DISCRETE_NOP(NODE) { NODE, DSS_NOP , 0, { 0 }, { 0 }, NULL, "DISCRETE_NOP" },
|
||||
@ -4592,8 +4597,8 @@ enum
|
||||
#define DISCRETE_CSVLOG3(NODE1,NODE2,NODE3) { NODE_SPECIAL, DSO_CSVLOG , 3, { NODE1,NODE2,NODE3 }, { NODE1,NODE2,NODE3 }, NULL, "DISCRETE_CSVLOG3" },
|
||||
#define DISCRETE_CSVLOG4(NODE1,NODE2,NODE3,NODE4) { NODE_SPECIAL, DSO_CSVLOG , 4, { NODE1,NODE2,NODE3,NODE4 }, { NODE1,NODE2,NODE3,NODE4 }, NULL, "DISCRETE_CSVLOG4" },
|
||||
#define DISCRETE_CSVLOG5(NODE1,NODE2,NODE3,NODE4,NODE5) { NODE_SPECIAL, DSO_CSVLOG , 5, { NODE1,NODE2,NODE3,NODE4,NODE5 }, { NODE1,NODE2,NODE3,NODE4,NODE5 }, NULL, "DISCRETE_CSVLOG5" },
|
||||
#define DISCRETE_WAVELOG1(NODE1,GAIN1) { NODE_SPECIAL, DSO_WAVELOG , 2, { NODE1,NODE_NC }, { NODE1,GAIN1 }, NULL, "DISCRETE_WAVELOG1" },
|
||||
#define DISCRETE_WAVELOG2(NODE1,GAIN1,NODE2,GAIN2) { NODE_SPECIAL, DSO_WAVELOG , 4, { NODE1,NODE_NC,NODE2,NODE_NC }, { NODE1,GAIN1,NODE2,GAIN2 }, NULL, "DISCRETE_WAVELOG2" },
|
||||
#define DISCRETE_WAVLOG1(NODE1,GAIN1) { NODE_SPECIAL, DSO_WAVELOG , 2, { NODE1,NODE_NC }, { NODE1,GAIN1 }, NULL, "DISCRETE_WAVLOG1" },
|
||||
#define DISCRETE_WAVLOG2(NODE1,GAIN1,NODE2,GAIN2) { NODE_SPECIAL, DSO_WAVELOG , 4, { NODE1,NODE_NC,NODE2,NODE_NC }, { NODE1,GAIN1,NODE2,GAIN2 }, NULL, "DISCRETE_WAVLOG2" },
|
||||
|
||||
/* import */
|
||||
#define DISCRETE_IMPORT(INFO) { NODE_SPECIAL, DSO_IMPORT , 0, { 0 }, { 0 }, &(INFO##_discrete_interface), "DISCRETE_IMPORT" },
|
||||
|
@ -237,9 +237,9 @@ struct bzone_custom_filter_context
|
||||
|
||||
#define CD4066_R_ON 270
|
||||
|
||||
static DISCRETE_STEP(bzone_custom_filter)
|
||||
DISCRETE_STEP(bzone_custom_filter)
|
||||
{
|
||||
struct bzone_custom_filter_context *context = (struct bzone_custom_filter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(bzone_custom_filter)
|
||||
|
||||
int in0 = (BZONE_CUSTOM_FILTER__IN0 == 0) ? 0 : 1;
|
||||
double v;
|
||||
@ -254,9 +254,9 @@ static DISCRETE_STEP(bzone_custom_filter)
|
||||
node->output[0] += (v - node->output[0]) * context->exponent;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET(bzone_custom_filter)
|
||||
DISCRETE_RESET(bzone_custom_filter)
|
||||
{
|
||||
struct bzone_custom_filter_context *context = (struct bzone_custom_filter_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(bzone_custom_filter)
|
||||
|
||||
context->gain[0] = BZONE_CUSTOM_FILTER__R1 + BZONE_CUSTOM_FILTER__R2;
|
||||
context->gain[0] = BZONE_CUSTOM_FILTER__R5 / context->gain[0] + 1;
|
||||
|
@ -302,9 +302,9 @@ struct dkong_custom_mixer_context
|
||||
double exp[2];
|
||||
};
|
||||
|
||||
static DISCRETE_STEP( dkong_custom_mixer )
|
||||
DISCRETE_STEP( dkong_custom_mixer )
|
||||
{
|
||||
struct dkong_custom_mixer_context *context = (struct dkong_custom_mixer_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dkong_custom_mixer)
|
||||
|
||||
int in_1 = (int)DKONG_CUSTOM_IN1;
|
||||
|
||||
@ -321,9 +321,9 @@ static DISCRETE_STEP( dkong_custom_mixer )
|
||||
|
||||
#define NE555_CV_R RES_2_PARALLEL(RES_K(5), RES_K(10))
|
||||
|
||||
static DISCRETE_RESET( dkong_custom_mixer )
|
||||
DISCRETE_RESET( dkong_custom_mixer )
|
||||
{
|
||||
struct dkong_custom_mixer_context *context = (struct dkong_custom_mixer_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(dkong_custom_mixer)
|
||||
|
||||
/* everything is based on the input to the O.C. inverter */
|
||||
/* precalculate current from In1 */
|
||||
@ -786,6 +786,9 @@ DISCRETE_SOUND_END
|
||||
#define JR_R25 RES_K(47)
|
||||
#define JR_R27 RES_K(10)
|
||||
#define JR_R28 RES_K(100)
|
||||
#define JR_R33 RES_K(1)
|
||||
#define JR_R34 RES_K(1)
|
||||
#define JR_R35 RES_K(1)
|
||||
|
||||
|
||||
#define JR_C13 CAP_U(4.7)
|
||||
@ -883,13 +886,13 @@ DISCRETE_TASK_START(1)
|
||||
0, 0x3FFF, DISC_COUNT_UP, 0, DISC_CLK_BY_COUNT | DISC_OUT_HAS_XTIME)
|
||||
|
||||
DISCRETE_BIT_DECODE(NODE_101, /* IC 6L, pin 6 */
|
||||
NODE_100, 6, 0)
|
||||
NODE_100, 6, 0) /* output x_time logic */
|
||||
DISCRETE_BIT_DECODE(NODE_102, /* IC 6L, pin 7 */
|
||||
NODE_100, 3, 0)
|
||||
NODE_100, 3, 0) /* output x_time logic */
|
||||
DISCRETE_BIT_DECODE(NODE_103, /* IC 6L, pin 2 */
|
||||
NODE_100, 12, 0)
|
||||
NODE_100, 12, 0) /* output x_time logic */
|
||||
DISCRETE_BIT_DECODE(NODE_104, /* IC 6L, pin 1 */
|
||||
NODE_100, 11, 0)
|
||||
NODE_100, 11, 0) /* output x_time logic */
|
||||
|
||||
/* LS157 Switches - IC 6K */
|
||||
DISCRETE_SWITCH(NODE_106, /* IC 6K, pin 7 */
|
||||
@ -906,24 +909,24 @@ DISCRETE_TASK_START(1)
|
||||
1, NODE_110, /* ENAB; IC 4F, pin 11 */
|
||||
4.14, 0.151) /* INP0; INP1 (measured) */
|
||||
|
||||
/* Breadboarded measurements IC 5K, pin 7
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.151 3139
|
||||
0.25 2883
|
||||
0.5 2820
|
||||
0.75 3336
|
||||
1 3805
|
||||
2 6498
|
||||
3 9796
|
||||
4 13440
|
||||
4.14 13980
|
||||
*/
|
||||
/* Breadboarded measurements IC 5K, pin 7
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.151 3139
|
||||
0.25 2883
|
||||
0.5 2820
|
||||
0.75 3336
|
||||
1 3805
|
||||
2 6498
|
||||
3 9796
|
||||
4 13440
|
||||
4.14 13980
|
||||
*/
|
||||
|
||||
DISCRETE_74LS629(NODE_113, /* IC 5K, pin 7 */
|
||||
DISCRETE_74LS624(NODE_113, /* IC 5K, pin 7 */
|
||||
1, /* ENAB */
|
||||
NODE_111, DK_SUP_V, /* VMOD - IC 5K, pin 2; VRNG */
|
||||
JR_C18, JR_R10, JR_C17, /* C; R_FREQ_IN; C_FREQ_IN */
|
||||
JR_C18, JR_R10, JR_C17, JR_R33, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
DISCRETE_SWITCH(NODE_105, /* IC 6K, pin 4 */
|
||||
1, /* ENAB */
|
||||
@ -938,24 +941,24 @@ DISCRETE_TASK_START(1)
|
||||
NODE_107, /* IC 5J, pin 9 */
|
||||
0.135, 4.15) /* measured Low/High */
|
||||
|
||||
/* Breadboarded measurements IC 5K, pin 10
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.135 14450 - measured 74LS04 low
|
||||
0.25 13320
|
||||
0.5 12980
|
||||
0.75 15150
|
||||
1 17270
|
||||
2 28230
|
||||
3 41910
|
||||
4 56950
|
||||
4.15 59400 - measured 74LS04 high
|
||||
*/
|
||||
/* Breadboarded measurements IC 5K, pin 10
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.135 14450 - measured 74LS04 low
|
||||
0.25 13320
|
||||
0.5 12980
|
||||
0.75 15150
|
||||
1 17270
|
||||
2 28230
|
||||
3 41910
|
||||
4 56950
|
||||
4.15 59400 - measured 74LS04 high
|
||||
*/
|
||||
|
||||
DISCRETE_74LS629(NODE_118, /* IC 5K, pin 10 */
|
||||
DISCRETE_74LS624(NODE_118, /* IC 5K, pin 10 */
|
||||
1, /* ENAB */
|
||||
NODE_116, DK_SUP_V, /* VMOD - IC 5K, pin 1; VRNG */
|
||||
JR_C19, JR_R11, JR_C16, /* C; R_FREQ_IN; C_FREQ_IN */
|
||||
JR_C19, JR_R11, JR_C16, JR_R33, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_COUNT_F_X)
|
||||
DISCRETE_SWITCH(NODE_119, 1, NODE_110, 0, 1) /* convert from voltage to x_time logic */
|
||||
DISCRETE_XTIME_NAND(DS_OUT_SOUND0, /* IC 5N, pin 11 */
|
||||
@ -980,25 +983,25 @@ DISCRETE_TASK_START(2)
|
||||
0.151, 4.14) /* measured Low/High */
|
||||
DISCRETE_MIXER2(NODE_13, 1, NODE_11, NODE_12, &dkongjr_s1_mixer_desc)
|
||||
|
||||
/* Breadboarded measurements IC 8L, pin 10
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.151 313
|
||||
0.25 288
|
||||
0.5 275
|
||||
0.75 324
|
||||
1 370
|
||||
2 635
|
||||
3 965
|
||||
4 1325
|
||||
4.14 1378
|
||||
*/
|
||||
/* Breadboarded measurements IC 8L, pin 10
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.151 313
|
||||
0.25 288
|
||||
0.5 275
|
||||
0.75 324
|
||||
1 370
|
||||
2 635
|
||||
3 965
|
||||
4 1325
|
||||
4.14 1378
|
||||
*/
|
||||
|
||||
DISCRETE_74LS629(NODE_14, /* IC 8L, pin 10 */
|
||||
DISCRETE_74LS624(NODE_14, /* IC 8L, pin 10 */
|
||||
1, /* ENAB */
|
||||
NODE_13, DK_SUP_V, /* VMOD - IC 8L, pin 1, VRNG */
|
||||
/* C_FREQ_IN is taken care of by the NODE_13 mixer */
|
||||
JR_C22, RES_2_PARALLEL(JR_R13, JR_R12), 0, /* C, R_FREQ_IN, C_FREQ_IN */
|
||||
JR_C22, RES_2_PARALLEL(JR_R13, JR_R12), 0, JR_R35, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_ENERGY)
|
||||
|
||||
DISCRETE_LOGIC_INVERT(NODE_15, NODE_10) /* fake invert for NODE_16 */
|
||||
@ -1044,23 +1047,23 @@ DISCRETE_TASK_START(1)
|
||||
DS_SOUND9_EN, /* IC 7N, pin 9 */
|
||||
0.134, 4.16) /* measured Low/High */
|
||||
|
||||
/* Breadboarded measurements IC 7P, pin 7
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.134 570
|
||||
0.25 538
|
||||
0.5 489
|
||||
0.75 560
|
||||
1 636
|
||||
2 1003
|
||||
3 1484
|
||||
4 2016
|
||||
4.16 2111
|
||||
*/
|
||||
DISCRETE_74LS629(NODE_91, /* IC 7P, pin 7 */
|
||||
/* Breadboarded measurements IC 7P, pin 7
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.134 570
|
||||
0.25 538
|
||||
0.5 489
|
||||
0.75 560
|
||||
1 636
|
||||
2 1003
|
||||
3 1484
|
||||
4 2016
|
||||
4.16 2111
|
||||
*/
|
||||
DISCRETE_74LS624(NODE_91, /* IC 7P, pin 7 */
|
||||
1, /* ENAB */
|
||||
NODE_90, DK_SUP_V, /* VMOD - IC 7P, pin 2, VRNG */
|
||||
JR_C37, JR_R14, JR_C26, /* C, R_FREQ_IN, C_FREQ_IN */
|
||||
JR_C37, JR_R14, JR_C26, JR_R34, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
DISCRETE_XTIME_NAND(DS_OUT_SOUND9, /* IC 5N, pin 8 */
|
||||
DS_SOUND9_EN, /* IC 5N, pin 9 */
|
||||
@ -1101,7 +1104,12 @@ DISCRETE_TASK_START(3)
|
||||
* Just a 1:n amplifier without filters - just the output filter
|
||||
*/
|
||||
DISCRETE_CRFILTER(NODE_295, NODE_288, 1000, JR_C13)
|
||||
DISCRETE_OUTPUT(NODE_295, 32767.0/5.0 * 5)
|
||||
/* approx -1.805V to 2.0V when playing, but turn on sound peaks at 2.36V */
|
||||
/* we will set the full wav range to 1.18V which will cause clipping on the turn on
|
||||
* sound and explosions. The real game would do this when the volume is turned up too.
|
||||
* Reducing MAME's master volume to 50% will provide full unclipped volume.
|
||||
*/
|
||||
DISCRETE_OUTPUT(NODE_295, 32767.0/1.18)
|
||||
DISCRETE_TASK_END()
|
||||
|
||||
DISCRETE_SOUND_END
|
||||
@ -1245,16 +1253,16 @@ static READ8_DEVICE_HANDLER( dkong_voice_status_r )
|
||||
static READ8_DEVICE_HANDLER( dkong_tune_r )
|
||||
{
|
||||
dkong_state *state = device->machine->driver_data<dkong_state>();
|
||||
UINT8 page = latch8_r(state->dev_vp2,0) & 0x47;
|
||||
UINT8 page = latch8_r(state->dev_vp2, 0) & 0x47;
|
||||
|
||||
if ( page & 0x40 )
|
||||
{
|
||||
return (latch8_r(device, 0) & 0x0F) | (dkong_voice_status_r(device,0)<<4);
|
||||
return (latch8_r(device, 0) & 0x0F) | (dkong_voice_status_r(device, 0) << 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* printf("%s:rom access\n",cpuexec_describe_context(device->machine)); */
|
||||
return (state->snd_rom[0x1000+(page & 7)*256+offset]);
|
||||
return (state->snd_rom[0x1000 + (page & 7) * 256 + offset]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,12 +15,6 @@
|
||||
/* FIXME: Capacitor aging - only in for calibration now */
|
||||
/* Adjustments are needed to bring this close to recordings */
|
||||
|
||||
/* FIXME: Awaiting verification. VCO range inputs are shown */
|
||||
/* as connected to +5V on schematics. This does not match */
|
||||
/* recordings */
|
||||
|
||||
#define USE_LS629 (0) /* set to use new LS624 code */
|
||||
|
||||
#define RUN_VCO_VOLTAGE (0.0) /* 5 in schematics */
|
||||
|
||||
#define USE_8039 (0) /* set to 1 to try 8039 hack */
|
||||
@ -93,6 +87,9 @@
|
||||
/* 27 verified, 30K in schematics */
|
||||
#define MR_R19 RES_K(22) /* verified */
|
||||
#define MR_R20 RES_K(22) /* verified */
|
||||
#define MR_R34 RES_M(2) /* */
|
||||
#define MR_R35 RES_M(1) /* */
|
||||
#define MR_R36 RES_M(1.8) /* */
|
||||
#define MR_R40 RES_K(22) /* verified */
|
||||
#define MR_R41 RES_K(100) /* verified */
|
||||
#define MR_R42 RES_K(43) /* verified */
|
||||
@ -124,298 +121,236 @@
|
||||
/* KT = 0.25 for diode circuit, 0.33 else */
|
||||
|
||||
#define DISCRETE_LS123(_N, _T, _R, _C) \
|
||||
DISCRETE_ONESHOTR(_N, 0, _T, TTL_HIGH, (0.25 * (_R) * (_C) * (1.0+700./(_R))), DISC_ONESHOT_RETRIG | DISC_ONESHOT_REDGE)
|
||||
DISCRETE_ONESHOTR(_N, 0, _T, 1, (0.25 * (_R) * (_C) * (1.0+700./(_R))), DISC_ONESHOT_RETRIG | DISC_ONESHOT_REDGE)
|
||||
#define DISCRETE_LS123_INV(_N, _T, _R, _C) \
|
||||
DISCRETE_ONESHOTR(_N, 0, _T, TTL_HIGH, (0.25 * (_R) * (_C) * (1.0+700./(_R))), DISC_ONESHOT_RETRIG | DISC_ONESHOT_REDGE | DISC_OUT_ACTIVE_LOW)
|
||||
DISCRETE_ONESHOTR(_N, 0, _T, 1, (0.25 * (_R) * (_C) * (1.0+700./(_R))), DISC_ONESHOT_RETRIG | DISC_ONESHOT_REDGE | DISC_OUT_ACTIVE_LOW)
|
||||
|
||||
/* speed optimization */
|
||||
/* pow(10, x) = exp(ln(10)*x) */
|
||||
#define pow10(x) exp(2.30258509299404568401*(x))
|
||||
|
||||
/* The following formula was derived from figures 2 and 3 in LS624 datasheet. Coefficients
|
||||
* where calculated using least square approximation.
|
||||
* This approach gives a bit better results compared to the first approach.
|
||||
*/
|
||||
//#define LS624_F(_C, _VI, _VR) pow10( -0.912029404 * log10(_C) + 0.243264328 * (_VI)
|
||||
// - 0.091695877 * (_VR) -0.014110946 * (_VI) * (_VR) - 3.207072925)
|
||||
#define LS624_F(_in, _num) pow10(context->k1_##_num + 0.243264328 * (_in) + context->k2_##_num * (_in))
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* Custom mario run
|
||||
*
|
||||
* Two VCO with XOR'd signal
|
||||
*
|
||||
* input[0] - Enable / Amplitude
|
||||
* input[1] - In1 VCO Control 1
|
||||
* input[2] - In2 VCO Control 2
|
||||
* input[3] - C1 VCO 1 Cap
|
||||
* input[4] - C2 VCO 2 CAP
|
||||
* input[5] - R1
|
||||
* input[6] - C3
|
||||
*
|
||||
* Vout >--------------------------
|
||||
* |
|
||||
* C1 |
|
||||
* -||- |
|
||||
* | | -- +---
|
||||
* ------ --- |AND| R1
|
||||
* In1 >---+ Y1 +--------+ | |(*)+---ZZZ--+------> Out
|
||||
* | | |XOR+------+--- |
|
||||
* | | ---+ | |
|
||||
* | | | --- ---
|
||||
* In2 >---+ Y2 +---- --- C3
|
||||
* ------ |
|
||||
* | | Gnd
|
||||
* -||-
|
||||
* C2
|
||||
************************************************************************/
|
||||
#define MARIO_CUSTOM_VOUT DISCRETE_INPUT(0)
|
||||
#define MARIO_CUSTOM_IN1 DISCRETE_INPUT(1)
|
||||
#define MARIO_CUSTOM_IN2 DISCRETE_INPUT(2)
|
||||
#define MARIO_CUSTOM_C1 DISCRETE_INPUT(3)
|
||||
#define MARIO_CUSTOM_C2 DISCRETE_INPUT(4)
|
||||
#define MARIO_CUSTOM_R1 DISCRETE_INPUT(5)
|
||||
#define MARIO_CUSTOM_C3 DISCRETE_INPUT(6)
|
||||
|
||||
struct mario_custom_run_context
|
||||
static const discrete_op_amp_info mario_dac_amp =
|
||||
{
|
||||
int state1;
|
||||
int state2;
|
||||
double remain1;
|
||||
double remain2;
|
||||
double vc3;
|
||||
double r1_c3;
|
||||
double k1_1;
|
||||
double k2_1;
|
||||
double k1_2;
|
||||
double k2_2;
|
||||
double exponent_c3;
|
||||
double dt_in1_at_0;
|
||||
double dt_in2_at_0;
|
||||
DISC_OP_AMP_IS_NORTON,
|
||||
MR_R34, MR_R36, 0, MR_R35, 0, /* r1, r2, r3, r4, c */
|
||||
0, 5 /* vN, vP */
|
||||
};
|
||||
|
||||
static DISCRETE_STEP( mario_custom_run )
|
||||
{
|
||||
struct mario_custom_run_context *context = (struct mario_custom_run_context *)node->context;
|
||||
|
||||
double sample_t = node->info->sample_time;
|
||||
double vn, exponent, t = 0;
|
||||
int update_exponent;
|
||||
double t1, t2;
|
||||
|
||||
if (EXPECTED(MARIO_CUSTOM_IN1 > 0.001))
|
||||
t1 = 0.5 / LS624_F(MARIO_CUSTOM_IN1, 1);
|
||||
else
|
||||
/* close enough to 0, so we can speed things up by no longer call pow() */
|
||||
t1 = context->dt_in1_at_0;
|
||||
|
||||
if (EXPECTED(MARIO_CUSTOM_IN2 > 0.001))
|
||||
t2 = 0.5 / LS624_F(MARIO_CUSTOM_IN2, 2);
|
||||
else
|
||||
t2 = context->dt_in2_at_0;
|
||||
|
||||
while (sample_t > 0.0f)
|
||||
{
|
||||
/* state before time advance */
|
||||
vn = (double) (context->state1 ^ context->state2);
|
||||
vn *= MARIO_CUSTOM_VOUT;
|
||||
update_exponent = 0;
|
||||
if (context->remain1 < context->remain2)
|
||||
{
|
||||
if (EXPECTED(context->remain1 < sample_t))
|
||||
{
|
||||
t = context->remain1;
|
||||
update_exponent = 1;
|
||||
context->state1 ^= 1;
|
||||
sample_t -= context->remain1;
|
||||
context->remain2 -= context->remain1;
|
||||
context->remain1 = t1;
|
||||
}
|
||||
else
|
||||
{
|
||||
context->remain1 -= sample_t;
|
||||
context->remain2 -= sample_t;
|
||||
sample_t = 0.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EXPECTED(context->remain2 < sample_t))
|
||||
{
|
||||
t = context->remain2;
|
||||
update_exponent = 1;
|
||||
context->state2 ^= 1;
|
||||
sample_t -= context->remain2;
|
||||
context->remain1 -= context->remain2;
|
||||
context->remain2 = t2;
|
||||
}
|
||||
else
|
||||
{
|
||||
context->remain1 -= sample_t;
|
||||
context->remain2 -= sample_t;
|
||||
sample_t = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (EXPECTED(update_exponent))
|
||||
exponent = RC_CHARGE_EXP_DT(context->r1_c3, t);
|
||||
else
|
||||
exponent = context->exponent_c3;
|
||||
context->vc3 += (vn - context->vc3) * exponent;
|
||||
}
|
||||
node->output[0] = context->vc3;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET( mario_custom_run )
|
||||
{
|
||||
struct mario_custom_run_context *context = (struct mario_custom_run_context *)node->context;
|
||||
|
||||
context->remain1 = 0.0;
|
||||
context->remain2 = 0.0;
|
||||
context->state1 = 0;
|
||||
context->state2 = 0;
|
||||
context->vc3 = 0;
|
||||
context->r1_c3 = MARIO_CUSTOM_R1 * MARIO_CUSTOM_C3;
|
||||
node->output[0] = 0;
|
||||
|
||||
/* precalculate some parts of the formulas for speed */
|
||||
context->k1_1 = -0.912029404 * log10(MARIO_CUSTOM_C1) -0.091695877 * (RUN_VCO_VOLTAGE) - 3.207072925;
|
||||
context->k2_1 = -0.014110946 * (RUN_VCO_VOLTAGE);
|
||||
context->k1_2 = -0.912029404 * log10(MARIO_CUSTOM_C2) -0.091695877 * (RUN_VCO_VOLTAGE) - 3.207072925;
|
||||
context->k2_2 = -0.014110946 * (RUN_VCO_VOLTAGE);
|
||||
context->exponent_c3 = RC_CHARGE_EXP(context->r1_c3);
|
||||
|
||||
context->dt_in1_at_0 = 0.5 / LS624_F(0, 1);
|
||||
context->dt_in2_at_0 = 0.5 / LS624_F(0, 2);
|
||||
}
|
||||
|
||||
static const discrete_custom_info mario_custom_run_info =
|
||||
{
|
||||
DISCRETE_CUSTOM_MODULE( mario_custom_run, struct mario_custom_run_context),
|
||||
NULL
|
||||
};
|
||||
|
||||
static const discrete_mixer_desc mario_mixer =
|
||||
static const discrete_mixer_desc mario_mixer =
|
||||
{
|
||||
DISC_MIXER_IS_RESISTOR,
|
||||
{MR_R20, MR_R19, MR_R41, MR_R40},
|
||||
{0}, {0}, 0, 0, MR_C31, MR_C32, 0, 1 /* r_node{}, c{}, rI, rF, cF, cAmp, vRef, gain*/
|
||||
};
|
||||
|
||||
#define LS629_FREQ_R_IN RES_K(95)
|
||||
#define LS629_FREQ_R_IN RES_K(90)
|
||||
|
||||
static DISCRETE_SOUND_START(mario)
|
||||
|
||||
/************************************************/
|
||||
/* Input register mapping for mario */
|
||||
/************************************************/
|
||||
/************************************************
|
||||
* Input register mapping for mario
|
||||
************************************************/
|
||||
|
||||
/* DISCRETE_INPUT_DATA */
|
||||
DISCRETE_INPUT_NOT(DS_SOUND7_INV)
|
||||
DISCRETE_INPUT_NOT(DS_SOUND7_INV) /* IC 7L, pin 8 */
|
||||
|
||||
/************************************************/
|
||||
/* SOUND0 */
|
||||
/************************************************/
|
||||
/************************************************
|
||||
* SOUND0
|
||||
************************************************/
|
||||
|
||||
DISCRETE_TASK_START(1)
|
||||
DISCRETE_INPUT_PULSE(DS_SOUND0_INV, 1)
|
||||
DISCRETE_LS123(NODE_10, DS_SOUND0_INV, MR_R17, MR_C14)
|
||||
DISCRETE_RCFILTER(NODE_11, NODE_10, MR_R6, MR_C3 )
|
||||
#if (USE_LS629)
|
||||
DISCRETE_74LS629(NODE_12, /* IC 1J, pin 10 */
|
||||
DISCRETE_INPUT_PULSE(DS_SOUND0_INV, 1) /* IC 4C, pin 15 */
|
||||
DISCRETE_LS123(NODE_10, /* IC 2H, pin 13 */
|
||||
DS_SOUND0_INV, /* IC 2H, pin 2 */
|
||||
MR_R17, MR_C14)
|
||||
|
||||
/* Breadboarded measurements IC 1J, pin 10
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.115 14470
|
||||
0.250 15190
|
||||
0.500 14980
|
||||
0.750 18150
|
||||
1.000 21690
|
||||
2.000 38790
|
||||
3.000 58580
|
||||
4.000 79890
|
||||
*/
|
||||
|
||||
/* Breadboarded measurements IC 2J, pin 10
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.116 2458
|
||||
0.250 2593
|
||||
0.500 2540
|
||||
0.750 3081
|
||||
1.000 3676
|
||||
2.000 6590
|
||||
3.000 9974
|
||||
4.000 13620
|
||||
*/
|
||||
|
||||
/* covert logic to measured voltage */
|
||||
DISCRETE_XTIME_BUFFER(NODE_11, /* IC 1H, pin 10 */
|
||||
NODE_10, /* IC 1H, pin 11 */
|
||||
0.115, 4.0) /* measured Low/High */
|
||||
/* work out cap charge of RC in parallel with 2 74LS629s */
|
||||
DISCRETE_RCFILTER(NODE_12, NODE_11, RES_3_PARALLEL(MR_R6, LS629_FREQ_R_IN, LS629_FREQ_R_IN), MR_C3 )
|
||||
/* work out voltage drop of RC in parallel with 2 74LS629s */
|
||||
DISCRETE_GAIN(NODE_13, NODE_12, RES_VOLTAGE_DIVIDER(MR_R6, RES_2_PARALLEL(LS629_FREQ_R_IN, LS629_FREQ_R_IN)))
|
||||
DISCRETE_74LS624(NODE_14, /* IC 1J, pin 10 */
|
||||
1, /* ENAB */
|
||||
NODE_11, 5, /* VMOD, VRNG */
|
||||
MR_C6, RES_2_PARALLEL(MR_R6, LS629_FREQ_R_IN), /* C, R_FREQ_IN */
|
||||
DISC_LS624_OUT_SQUARE)
|
||||
DISCRETE_74LS629(NODE_13, /* IC 2J, pin 10 */
|
||||
NODE_13, 5, /* VMOD - IC 1J, pin 1; VRNG */
|
||||
MR_C6, 0, 0, 0, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
DISCRETE_74LS624(NODE_15, /* IC 2J, pin 10 */
|
||||
1, /* ENAB */
|
||||
NODE_11, 5, /* VMOD, VRNG */
|
||||
MR_C17, RES_2_PARALLEL(MR_R6, LS629_FREQ_R_IN), /* C, R_FREQ_IN */
|
||||
DISC_LS624_OUT_SQUARE)
|
||||
DISCRETE_LOGIC_XOR(NODE_14, /* IC 1K, pin 6 */
|
||||
NODE_12, NODE_13)
|
||||
DISCRETE_SWITCH(DS_OUT_SOUND0, /* IC 2K, pin 3 */
|
||||
NODE_10, NODE_14, /* ENAB, SWITCH */
|
||||
0, TTL_HIGH) /* INP0,INP1 */
|
||||
#else
|
||||
DISCRETE_CUSTOM7(DS_OUT_SOUND0, NODE_10, NODE_11, NODE_11, MR_C6, MR_C17,
|
||||
MR_MIXER_RPAR, MR_C31, &mario_custom_run_info)
|
||||
#endif
|
||||
NODE_13, 5, /* VMOD - IC 2J, pin 1; VRNG */
|
||||
MR_C17, 0, 0, 0, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
DISCRETE_XTIME_XOR(NODE_16, /* IC IC 1K, pin 6 */
|
||||
NODE_14, NODE_15, /* IC 1K, pin 5; pin 4 */
|
||||
0, 0) /* use x_time logic */
|
||||
DISCRETE_XTIME_AND(DS_OUT_SOUND0, /* IC 2K, pin 6 */
|
||||
NODE_10, NODE_16, /* IC 2K, pin 5; pin 4 */
|
||||
0.066, 3.8) /* LOW; HIGH (varies due to load 3.7 - 4.4) */
|
||||
DISCRETE_TASK_END()
|
||||
|
||||
/************************************************/
|
||||
/* SOUND1 */
|
||||
/************************************************/
|
||||
/************************************************
|
||||
* SOUND1
|
||||
************************************************/
|
||||
|
||||
DISCRETE_TASK_START(1)
|
||||
DISCRETE_INPUT_PULSE(DS_SOUND1_INV, 1)
|
||||
DISCRETE_LS123(NODE_20, DS_SOUND1_INV, MR_R18, MR_C15)
|
||||
DISCRETE_RCFILTER(NODE_21, NODE_20, MR_R7, MR_C4 )
|
||||
#if (USE_LS629)
|
||||
DISCRETE_74LS629(NODE_22, /* IC 1J, pin 7 */
|
||||
DISCRETE_INPUT_PULSE(DS_SOUND1_INV, 1) /* IC 4C, pin 14 */
|
||||
DISCRETE_LS123(NODE_20, /* IC 2H, pin 5 */
|
||||
DS_SOUND1_INV, /* IC 2H, pin 10 */
|
||||
MR_R18, MR_C15)
|
||||
|
||||
/* Breadboarded measurements IC 1J, pin 7
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.116 1380
|
||||
0.250 1448
|
||||
0.500 1419
|
||||
0.750 1717
|
||||
1.000 2053
|
||||
2.000 3677
|
||||
3.000 5561
|
||||
4.000 7610
|
||||
*/
|
||||
|
||||
/* Breadboarded measurements IC 2J, pin 7
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.112 8030
|
||||
0.250 8490
|
||||
0.500 8326
|
||||
0.750 10030
|
||||
1.000 12000
|
||||
2.000 21460
|
||||
3.000 32540
|
||||
4.000 44300
|
||||
*/
|
||||
|
||||
/* covert logic to measured voltage */
|
||||
DISCRETE_XTIME_BUFFER(NODE_21, /* IC 1H, pin 8 */
|
||||
NODE_20, /* IC 1H, pin 9 */
|
||||
0.115, 4.0) /* measured Low/High */
|
||||
/* work out cap charge of RC in parallel with 2 74LS629s */
|
||||
DISCRETE_RCFILTER(NODE_22, NODE_21, RES_3_PARALLEL(MR_R7, LS629_FREQ_R_IN, LS629_FREQ_R_IN), MR_C4 )
|
||||
/* work out voltage drop of RC in parallel with 2 74LS629s */
|
||||
DISCRETE_GAIN(NODE_23, NODE_22, RES_VOLTAGE_DIVIDER(MR_R7, RES_2_PARALLEL(LS629_FREQ_R_IN, LS629_FREQ_R_IN)))
|
||||
DISCRETE_74LS624(NODE_24, /* IC 1J, pin 7 */
|
||||
1, /* ENAB */
|
||||
NODE_21, 5, /* VMOD, VRNG */
|
||||
MR_C5, RES_2_PARALLEL(MR_R7, LS629_FREQ_R_IN), /* C, R_FREQ_IN */
|
||||
DISC_LS624_OUT_SQUARE)
|
||||
DISCRETE_74LS629(NODE_23, /* IC 2J, pin 7 */
|
||||
NODE_23, 5, /* VMOD, VRNG */
|
||||
MR_C5, 0, 0, 0, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
DISCRETE_74LS624(NODE_25, /* IC 2J, pin 7 */
|
||||
1, /* ENAB */
|
||||
NODE_21, 5, /* VMOD, VRNG */
|
||||
MR_C16, RES_2_PARALLEL(MR_R7, LS629_FREQ_R_IN), /* C, R_FREQ_IN */
|
||||
DISC_LS624_OUT_SQUARE)
|
||||
DISCRETE_LOGIC_XOR(NODE_24, /* IC 1K, pin 3 */
|
||||
NODE_22, NODE_23)
|
||||
DISCRETE_SWITCH(DS_OUT_SOUND1, /* IC 2K, pin 3 */
|
||||
NODE_20, NODE_24, /* ENAB, SWITCH */
|
||||
0, TTL_HIGH) /* INP0,INP1 */
|
||||
#else
|
||||
DISCRETE_CUSTOM7(DS_OUT_SOUND1, NODE_20, NODE_21, NODE_21, MR_C5, MR_C16,
|
||||
MR_MIXER_RPAR, MR_C31, &mario_custom_run_info)
|
||||
#endif
|
||||
NODE_23, 5, /* VMOD, VRNG */
|
||||
MR_C16, 0, 0, 0, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
DISCRETE_XTIME_XOR(NODE_26, /* IC IC 1K, pin 3 */
|
||||
NODE_24, NODE_25, /* IC 1K, pin 1; pin 2 */
|
||||
0, 0) /* use x_time logic */
|
||||
DISCRETE_XTIME_AND(DS_OUT_SOUND1, /* IC 2K, pin 3 */
|
||||
NODE_20, NODE_26, /* IC 2K, pin 2; pin 1 */
|
||||
0.066, 3.8) /* LOW; HIGH (varies due to load 3.7 - 4.4) */
|
||||
DISCRETE_TASK_END()
|
||||
|
||||
/************************************************/
|
||||
/* SOUND7 */
|
||||
/************************************************/
|
||||
/************************************************
|
||||
* SOUND7
|
||||
************************************************/
|
||||
|
||||
DISCRETE_TASK_START(1)
|
||||
DISCRETE_COUNTER(NODE_100,1,0,NODE_118,0,0xFFFF,DISC_COUNT_UP,0,DISC_CLK_BY_COUNT)
|
||||
DISCRETE_COUNTER(NODE_100, /* IC 3H */
|
||||
1, 0, /* ENAB; RESET */
|
||||
NODE_118, /* CLK - IC 3H, pin 10 */
|
||||
0, 0x3FFF, DISC_COUNT_UP, 0, DISC_CLK_BY_COUNT | DISC_OUT_HAS_XTIME)
|
||||
DISCRETE_BIT_DECODE(NODE_102, /* IC 3H, pin 7 */
|
||||
NODE_100, 3, 0) /* output x_time logic */
|
||||
DISCRETE_BIT_DECODE(NODE_104, /* IC 3H, pin 1 */
|
||||
NODE_100, 11, 0) /* output x_time logic */
|
||||
|
||||
DISCRETE_BIT_DECODE(NODE_102, NODE_100, 3, 1) //LS157 2B
|
||||
DISCRETE_BIT_DECODE(NODE_104, NODE_100, 11, TTL_HIGH) //LS157 3B
|
||||
DISCRETE_LS123(NODE_110, /* IC 4L, pin 13 */
|
||||
DS_SOUND7_INV, /* IC 4L, pin 2 */
|
||||
MR_R61, MR_C41)
|
||||
DISCRETE_XTIME_INVERTER(NODE_111, /* IC 4J, pin 8 */
|
||||
NODE_110, /* IC 4J, pin 9 */
|
||||
0.151, 4.14) /* measured Low/High */
|
||||
|
||||
DISCRETE_LS123(NODE_110, DS_SOUND7_INV, MR_R61, MR_C41)
|
||||
DISCRETE_TRANSFORM2(NODE_111, NODE_110, TTL_HIGH, "0!1*")
|
||||
DISCRETE_RCFILTER(NODE_112, NODE_111, MR_R65, MR_C44)
|
||||
#if (USE_LS629)
|
||||
DISCRETE_74LS629(NODE_113, /* IC 4K, pin 10 */
|
||||
/* Breadboarded measurements IC 4K, pin 10
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.151 3139
|
||||
0.25 2883
|
||||
0.5 2820
|
||||
0.75 3336
|
||||
1 3805
|
||||
2 6498
|
||||
3 9796
|
||||
4 13440
|
||||
4.14 13980
|
||||
*/
|
||||
|
||||
DISCRETE_74LS624(NODE_113, /* IC 4K, pin 10 */
|
||||
1, /* ENAB */
|
||||
NODE_112, 5, /* VMOD, VRNG */
|
||||
MR_C40, MR_R65, /* C, R_FREQ_IN */
|
||||
DISC_LS624_OUT_LOGIC)
|
||||
#else
|
||||
DISCRETE_74LS624(NODE_113, NODE_112, RUN_VCO_VOLTAGE /*VSS*/, MR_C40, DISC_LS624_OUT_LOGIC)
|
||||
#endif
|
||||
NODE_111, 5, /* VMOD - IC 4K, pin 1; VRNG */
|
||||
MR_C40, MR_R65, MR_C44, 0, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
|
||||
DISCRETE_LOGIC_XOR(NODE_115, NODE_102, NODE_113)
|
||||
DISCRETE_XTIME_XOR(NODE_115, /* IC 6N, pin 3 */
|
||||
NODE_113, NODE_102, /* IC 6N, pin 1; pin 2 */
|
||||
0, 0) /* use x_time logic */
|
||||
|
||||
DISCRETE_RCFILTER(NODE_117, NODE_104, MR_R64, MR_C43)
|
||||
#if (USE_LS629)
|
||||
DISCRETE_74LS629(NODE_118, /* IC 4K, pin 7 */
|
||||
/* Breadboarded measurements IC 4K, pin 7
|
||||
D.R. Oct 2010
|
||||
V Hz
|
||||
0.135 14450
|
||||
0.25 13320
|
||||
0.5 12980
|
||||
0.75 15150
|
||||
1 17270
|
||||
2 28230
|
||||
3 41910
|
||||
4 56950
|
||||
4.15 59400
|
||||
*/
|
||||
|
||||
DISCRETE_XTIME_INVERTER(NODE_117, /* IC 4J, pin 4 */
|
||||
NODE_104, /* IC 4J, pin 3 */
|
||||
0.135, 4.15) /* measured Low/High */
|
||||
DISCRETE_74LS624(NODE_118, /* IC 4K, pin 7 */
|
||||
1, /* ENAB */
|
||||
NODE_117, 5, /* VMOD, VRNG */
|
||||
MR_C39, MR_R64, /* C, R_FREQ_IN */
|
||||
DISC_LS624_OUT_LOGIC)
|
||||
#else
|
||||
DISCRETE_74LS624(NODE_118, NODE_117, RUN_VCO_VOLTAGE /*VSS*/, MR_C39, DISC_LS624_OUT_COUNT_F)
|
||||
#endif
|
||||
DISCRETE_LOGIC_AND(NODE_120, NODE_115, NODE_110)
|
||||
DISCRETE_MULTIPLY(DS_OUT_SOUND7, NODE_120, TTL_HIGH)
|
||||
NODE_117, 5, /* VMOD - IC 4K, pin 2; VRNG */
|
||||
MR_C39, MR_R64, MR_C43, 0, /* C; R_FREQ_IN; C_FREQ_IN; R_RNG_IN */
|
||||
DISC_LS624_OUT_LOGIC_X)
|
||||
|
||||
DISCRETE_XTIME_AND(DS_OUT_SOUND7, /* IC 2K, pin 11 */
|
||||
NODE_110, NODE_115, /* IC 2K, pin 12; pin 13 */
|
||||
0.066, 4.07) /* LOW; HIGH (varies due to load 4.07 is lowest) */
|
||||
DISCRETE_TASK_END()
|
||||
|
||||
/************************************************/
|
||||
/* DAC */
|
||||
/************************************************/
|
||||
/************************************************
|
||||
* DAC
|
||||
************************************************/
|
||||
|
||||
/* following the resistor DAC are two opamps. The first is a 1:1 amplifier, the second
|
||||
* is a filter circuit. Simulation in LTSPICE shows, that the following is equivalent:
|
||||
@ -423,21 +358,34 @@ static DISCRETE_SOUND_START(mario)
|
||||
|
||||
DISCRETE_TASK_START(1)
|
||||
DISCRETE_INPUT_BUFFER(DS_DAC, 0)
|
||||
DISCRETE_MULTIPLY(NODE_170, DS_DAC, TTL_HIGH/256.0)
|
||||
DISCRETE_RCFILTER(DS_OUT_DAC, NODE_170, RES_K(750), CAP_P(200))
|
||||
DISCRETE_MULTIPLY(NODE_170, DS_DAC, TTL_HIGH / 256.0) /* MXR1 */
|
||||
/* this stage reduces the gain of the DAC by 50%, so yes the volume is much lower then the walk sound */
|
||||
DISCRETE_OP_AMP(NODE_171, /* IC 3M, pin 5 */
|
||||
1, /* ENAB */
|
||||
NODE_170, 5, /* IN0 - IC 3M, pin 6; IN1 - IC 3M, pin 1 */
|
||||
&mario_dac_amp)
|
||||
/* This provides a close simulation of the IC 3M, pin 10 filter circuit */
|
||||
/* The Measured and SPICEd low freq gain is 1, it then has a high frequency
|
||||
* drop close to the following RC filter. */
|
||||
DISCRETE_RCFILTER_VREF(DS_OUT_DAC, NODE_171, RES_K(750), CAP_P(180), 2.5)
|
||||
DISCRETE_TASK_END()
|
||||
|
||||
|
||||
/************************************************/
|
||||
/* MIXER */
|
||||
/************************************************/
|
||||
/************************************************
|
||||
* MIXER
|
||||
************************************************/
|
||||
|
||||
DISCRETE_TASK_START(2)
|
||||
DISCRETE_MIXER4(NODE_297,
|
||||
1, /* ENAB */
|
||||
DS_OUT_SOUND0, DS_OUT_SOUND1, DS_OUT_SOUND7, DS_OUT_DAC,
|
||||
&mario_mixer)
|
||||
DISCRETE_OUTPUT(NODE_297, 32767.0/1.7)
|
||||
/* approx -0.625V to 0.980V when playing, but turn on sound peaks at 2.38V */
|
||||
/* we will set the full wav range to 1.19V which will cause clipping on the turn on
|
||||
* sound. The real game would do this when the volume is turned up too.
|
||||
* Reducing MAME's master volume to 50% will provide full unclipped volume.
|
||||
*/
|
||||
DISCRETE_OUTPUT(NODE_297, 32767.0/1.19)
|
||||
DISCRETE_TASK_END()
|
||||
|
||||
DISCRETE_SOUND_END
|
||||
@ -496,12 +444,12 @@ static SOUND_RESET( mario )
|
||||
#endif
|
||||
|
||||
/* FIXME: convert to latch8 */
|
||||
soundlatch_clear_w(space,0,0);
|
||||
soundlatch2_clear_w(space,0,0);
|
||||
soundlatch3_clear_w(space,0,0);
|
||||
soundlatch4_clear_w(space,0,0);
|
||||
I8035_P1_W(space,0x00); /* Input port */
|
||||
I8035_P2_W(space,0xff); /* Port is in high impedance state after reset */
|
||||
soundlatch_clear_w(space, 0, 0);
|
||||
soundlatch2_clear_w(space, 0, 0);
|
||||
soundlatch3_clear_w(space, 0, 0);
|
||||
soundlatch4_clear_w(space, 0, 0);
|
||||
I8035_P1_W(space, 0x00); /* Input port */
|
||||
I8035_P2_W(space, 0xff); /* Port is in high impedance state after reset */
|
||||
|
||||
state->last = 0;
|
||||
}
|
||||
@ -524,12 +472,12 @@ static READ8_HANDLER( mario_sh_p2_r )
|
||||
|
||||
static READ8_HANDLER( mario_sh_t0_r )
|
||||
{
|
||||
return I8035_T_R(space,0);
|
||||
return I8035_T_R(space, 0);
|
||||
}
|
||||
|
||||
static READ8_HANDLER( mario_sh_t1_r )
|
||||
{
|
||||
return I8035_T_R(space,1);
|
||||
return I8035_T_R(space, 1);
|
||||
}
|
||||
|
||||
static READ8_HANDLER( mario_sh_tune_r )
|
||||
@ -539,24 +487,24 @@ static READ8_HANDLER( mario_sh_tune_r )
|
||||
UINT8 p2 = I8035_P2_R(space);
|
||||
|
||||
if ((p2 >> 7) & 1)
|
||||
return soundlatch_r(space,offset);
|
||||
return soundlatch_r(space, offset);
|
||||
else
|
||||
return (SND[(0x1000 + (p2 & 0x0f)*256+offset) & mask]);
|
||||
return (SND[(0x1000 + (p2 & 0x0f) * 256 + offset) & mask]);
|
||||
}
|
||||
|
||||
static WRITE8_DEVICE_HANDLER( mario_sh_sound_w )
|
||||
{
|
||||
discrete_sound_w(device,DS_DAC,data);
|
||||
discrete_sound_w(device, DS_DAC, data);
|
||||
}
|
||||
|
||||
static WRITE8_HANDLER( mario_sh_p1_w )
|
||||
{
|
||||
I8035_P1_W(space,data);
|
||||
I8035_P1_W(space, data);
|
||||
}
|
||||
|
||||
static WRITE8_HANDLER( mario_sh_p2_w )
|
||||
{
|
||||
I8035_P2_W(space,data);
|
||||
I8035_P2_W(space, data);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
@ -572,7 +520,7 @@ WRITE8_HANDLER( masao_sh_irqtrigger_w )
|
||||
if (state->last == 1 && data == 0)
|
||||
{
|
||||
/* setting bit 0 high then low triggers IRQ on the sound CPU */
|
||||
cputag_set_input_line_and_vector(space->machine, "audiocpu",0,HOLD_LINE,0xff);
|
||||
cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
|
||||
}
|
||||
|
||||
state->last = data;
|
||||
@ -580,7 +528,7 @@ WRITE8_HANDLER( masao_sh_irqtrigger_w )
|
||||
|
||||
WRITE8_HANDLER( mario_sh_tuneselect_w )
|
||||
{
|
||||
soundlatch_w(space,offset,data);
|
||||
soundlatch_w(space, offset, data);
|
||||
}
|
||||
|
||||
/* Sound 0 and 1 are pulsed !*/
|
||||
@ -588,13 +536,13 @@ WRITE8_HANDLER( mario_sh_tuneselect_w )
|
||||
/* Mario running sample */
|
||||
WRITE8_DEVICE_HANDLER( mario_sh1_w )
|
||||
{
|
||||
discrete_sound_w(device,DS_SOUND0_INP, 0);
|
||||
discrete_sound_w(device, DS_SOUND0_INP, 0);
|
||||
}
|
||||
|
||||
/* Luigi running sample */
|
||||
WRITE8_DEVICE_HANDLER( mario_sh2_w )
|
||||
{
|
||||
discrete_sound_w(device,DS_SOUND1_INP, 0);
|
||||
discrete_sound_w(device, DS_SOUND1_INP, 0);
|
||||
}
|
||||
|
||||
/* Misc samples */
|
||||
@ -611,25 +559,25 @@ WRITE8_HANDLER( mario_sh3_w )
|
||||
cputag_set_input_line(space->machine, "audiocpu",0,CLEAR_LINE);
|
||||
break;
|
||||
case 1: /* get coin */
|
||||
I8035_T_W_AH(space,0,data & 1);
|
||||
I8035_T_W_AH(space, 0,data & 1);
|
||||
break;
|
||||
case 2: /* ice */
|
||||
I8035_T_W_AH(space,1,data & 1);
|
||||
I8035_T_W_AH(space, 1, data & 1);
|
||||
break;
|
||||
case 3: /* crab */
|
||||
I8035_P1_W_AH(space,0,data & 1);
|
||||
I8035_P1_W_AH(space, 0, data & 1);
|
||||
break;
|
||||
case 4: /* turtle */
|
||||
I8035_P1_W_AH(space,1,data & 1);
|
||||
I8035_P1_W_AH(space, 1, data & 1);
|
||||
break;
|
||||
case 5: /* fly */
|
||||
I8035_P1_W_AH(space,2,data & 1);
|
||||
I8035_P1_W_AH(space, 2, data & 1);
|
||||
break;
|
||||
case 6: /* coin */
|
||||
I8035_P1_W_AH(space,3,data & 1);
|
||||
I8035_P1_W_AH(space, 3, data & 1);
|
||||
break;
|
||||
case 7: /* skid */
|
||||
discrete_sound_w(space->machine->device("discrete"),DS_SOUND7_INP,data & 1);
|
||||
discrete_sound_w(space->machine->device("discrete"), DS_SOUND7_INP, data & 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -699,13 +647,13 @@ MACHINE_CONFIG_FRAGMENT( mario_audio )
|
||||
MDRV_SPEAKER_STANDARD_MONO("mono")
|
||||
MDRV_SOUND_ADD("discrete", DISCRETE, 0)
|
||||
MDRV_SOUND_CONFIG_DISCRETE(mario)
|
||||
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.5)
|
||||
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1)
|
||||
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
MACHINE_CONFIG_FRAGMENT( masao_audio )
|
||||
|
||||
MDRV_CPU_ADD("audiocpu", Z80,24576000/16) /* ???? */
|
||||
MDRV_CPU_ADD("audiocpu", Z80, 24576000/16) /* ???? */
|
||||
MDRV_CPU_PROGRAM_MAP(masao_sound_map)
|
||||
|
||||
MDRV_SOUND_START(mario)
|
||||
|
@ -151,9 +151,9 @@ struct skyraid_missle_custom_charge_context
|
||||
/* the high charge is clamped by the diode to 0.7V above the 5V line */
|
||||
#define SKYRAID_MISSLE_CHARGE_PLUS (5.0 + 0.7)
|
||||
|
||||
static DISCRETE_STEP( skyraid_missle_custom_charge )
|
||||
DISCRETE_STEP( skyraid_missle_custom_charge )
|
||||
{
|
||||
struct skyraid_missle_custom_charge_context *context = (struct skyraid_missle_custom_charge_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(skyraid_missle_custom_charge)
|
||||
|
||||
int in_1 = (SKYRAID_MISSLE_CUSTOM_IN1 == 0) ? 0 : 1;
|
||||
|
||||
@ -163,9 +163,9 @@ static DISCRETE_STEP( skyraid_missle_custom_charge )
|
||||
node->output[0] = SKYRAID_MISSLE_CHARGE_PLUS - context->v_cap;
|
||||
}
|
||||
|
||||
static DISCRETE_RESET( skyraid_missle_custom_charge )
|
||||
DISCRETE_RESET( skyraid_missle_custom_charge )
|
||||
{
|
||||
struct skyraid_missle_custom_charge_context *context = (struct skyraid_missle_custom_charge_context *)node->context;
|
||||
DISCRETE_DECLARE_CONTEXT(skyraid_missle_custom_charge)
|
||||
|
||||
/* everything is based on the input to the O.C. inverter */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user