diff --git a/src/emu/sound/disc_cls.h b/src/emu/sound/disc_cls.h index f48bbd76ca8..3ab13fb5c86 100644 --- a/src/emu/sound/disc_cls.h +++ b/src/emu/sound/disc_cls.h @@ -15,12 +15,14 @@ * * Additions/bugfix February 2003 - D.Renaud, F.Palazzolo, K.Wilkins * Discrete parallel tasks 2009 - Couriersud + * Discrete classes 2010 - Couriersud * ***********************************************************************/ #define DISCRETE_CLASS_NAME(_name) discrete_ ## _name ## _node #define DISCRETE_CLASS_CONSTRUCTOR(_name, _base) \ + public: \ DISCRETE_CLASS_NAME(_name)() \ : DISCRETE_CLASS_NAME(_base)() { } @@ -28,28 +30,28 @@ public: \ virtual ~ DISCRETE_CLASS_NAME(_name)(void) { } -#define DISCRETE_CLASS_STEP_RESETA(_name, _maxout, _priv) \ +#define DISCRETE_CLASS_STEP_RESET(_name, _maxout, _priv) \ class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_step_interface \ { \ -public: \ DISCRETE_CLASS_CONSTRUCTOR(_name, base) \ + DISCRETE_CLASS_DESTRUCTOR(_name) \ +public: \ void step(void); \ void reset(void); \ int max_output(void) { return _maxout; } \ - DISCRETE_CLASS_DESTRUCTOR(_name) \ private: \ _priv \ } -#define DISCRETE_CLASS_STEPA(_name, _maxout, _priv) \ +#define DISCRETE_CLASS_STEP(_name, _maxout, _priv) \ class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_step_interface \ { \ -public: \ DISCRETE_CLASS_CONSTRUCTOR(_name, base) \ + DISCRETE_CLASS_DESTRUCTOR(_name) \ +public: \ void step(void); \ void reset(void) { this->step(); } \ int max_output(void) { return _maxout; } \ - DISCRETE_CLASS_DESTRUCTOR(_name) \ private: \ _priv \ } @@ -57,42 +59,42 @@ private: \ #define DISCRETE_CLASS_RESET(_name, _maxout) \ class DISCRETE_CLASS_NAME(_name): public discrete_base_node \ { \ -public: \ DISCRETE_CLASS_CONSTRUCTOR(_name, base) \ + DISCRETE_CLASS_DESTRUCTOR(_name) \ +public: \ void reset(void); \ int max_output(void) { return _maxout; } \ - DISCRETE_CLASS_DESTRUCTOR(_name) \ } -#define DISCRETE_CLASSA(_name, _maxout, _priv) \ +#define DISCRETE_CLASS(_name, _maxout, _priv) \ class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_step_interface \ { \ -public: \ + DISCRETE_CLASS_DESTRUCTOR(_name) \ DISCRETE_CLASS_CONSTRUCTOR(_name, base) \ +public: \ void step(void); \ void reset(void); \ void start(void); \ void stop(void); \ int max_output(void) { return _maxout; } \ - DISCRETE_CLASS_DESTRUCTOR(_name) \ private: \ _priv \ } class DISCRETE_CLASS_NAME(special): public discrete_base_node { -public: DISCRETE_CLASS_CONSTRUCTOR(special, base) - int max_output(void) { return 0; } DISCRETE_CLASS_DESTRUCTOR(special) +public: + int max_output(void) { return 0; } }; class DISCRETE_CLASS_NAME(unimplemented): public discrete_base_node { -public: DISCRETE_CLASS_CONSTRUCTOR(unimplemented, base) - int max_output(void) { return 0; } DISCRETE_CLASS_DESTRUCTOR(unimplemented) +public: + int max_output(void) { return 0; } }; /************************************* @@ -103,8 +105,9 @@ public: class DISCRETE_CLASS_NAME(dso_output): public discrete_base_node, public discrete_output_interface, public discrete_step_interface { -public: DISCRETE_CLASS_CONSTRUCTOR(dso_output, base) + DISCRETE_CLASS_DESTRUCTOR(dso_output) +public: void step(void) { /* Add gain to the output and put into the buffers */ /* Clipping will be handled by the main sound system */ @@ -113,18 +116,17 @@ public: } int max_output(void) { return 0; } void set_output(stream_sample_t *ptr) { m_ptr = ptr; } - DISCRETE_CLASS_DESTRUCTOR(dso_output) private: stream_sample_t *m_ptr; }; -DISCRETE_CLASSA(dso_csvlog, 0, +DISCRETE_CLASS(dso_csvlog, 0, FILE *m_csv_file; INT64 m_sample_num; char m_name[32]; ); -DISCRETE_CLASSA(dso_wavlog, 0, +DISCRETE_CLASS(dso_wavlog, 0, wav_file *m_wavfile; char m_name[32]; ); @@ -137,8 +139,9 @@ DISCRETE_CLASSA(dso_wavlog, 0, class DISCRETE_CLASS_NAME(dss_adjustment): public discrete_base_node, public discrete_step_interface { -public: DISCRETE_CLASS_CONSTRUCTOR(dss_adjustment, base) + DISCRETE_CLASS_DESTRUCTOR(dss_adjustment) +public: void step(void); void reset(void); private: @@ -148,18 +151,17 @@ private: double m_pscale; double m_min; double m_scale; - DISCRETE_CLASS_DESTRUCTOR(dss_adjustment) }; DISCRETE_CLASS_RESET(dss_constant, 1); class DISCRETE_CLASS_NAME(dss_input_data): public discrete_base_node, public discrete_input_interface { -public: + DISCRETE_CLASS_DESTRUCTOR(dss_input_data) DISCRETE_CLASS_CONSTRUCTOR(dss_input_data, base) +public: void reset(void); void input_write(int sub_node, UINT8 data ); - DISCRETE_CLASS_DESTRUCTOR(dss_input_data) private: double m_gain; /* node gain */ double m_offset; /* node offset */ @@ -168,11 +170,11 @@ private: class DISCRETE_CLASS_NAME(dss_input_logic): public discrete_base_node, public discrete_input_interface { -public: DISCRETE_CLASS_CONSTRUCTOR(dss_input_logic, base) + DISCRETE_CLASS_DESTRUCTOR(dss_input_logic) +public: void reset(void); void input_write(int sub_node, UINT8 data ); - DISCRETE_CLASS_DESTRUCTOR(dss_input_logic) private: double m_gain; /* node gain */ double m_offset; /* node offset */ @@ -181,11 +183,11 @@ private: class DISCRETE_CLASS_NAME(dss_input_not): public discrete_base_node, public discrete_input_interface { -public: DISCRETE_CLASS_CONSTRUCTOR(dss_input_not, base) + DISCRETE_CLASS_DESTRUCTOR(dss_input_not) +public: void reset(void); void input_write(int sub_node, UINT8 data ); - DISCRETE_CLASS_DESTRUCTOR(dss_input_not) private: double m_gain; /* node gain */ double m_offset; /* node offset */ @@ -194,12 +196,12 @@ private: class DISCRETE_CLASS_NAME(dss_input_pulse): public discrete_base_node, public discrete_input_interface, public discrete_step_interface { -public: DISCRETE_CLASS_CONSTRUCTOR(dss_input_pulse, base) + DISCRETE_CLASS_DESTRUCTOR(dss_input_pulse) +public: void step(void); void reset(void); void input_write(int sub_node, UINT8 data ); - DISCRETE_CLASS_DESTRUCTOR(dss_input_pulse) private: double m_gain; /* node gain */ double m_offset; /* node offset */ @@ -208,8 +210,9 @@ private: class DISCRETE_CLASS_NAME(dss_input_stream): public discrete_base_node, public discrete_input_interface, public discrete_step_interface { -public: DISCRETE_CLASS_CONSTRUCTOR(dss_input_stream, base) + DISCRETE_CLASS_DESTRUCTOR(dss_input_stream) +public: void step(void); void reset(void); void start(void); @@ -218,7 +221,6 @@ public: //protected: UINT32 m_stream_in_number; stream_sample_t *m_ptr; /* current in ptr for stream */ - DISCRETE_CLASS_DESTRUCTOR(dss_input_stream) private: static STREAM_UPDATE( static_stream_generate ); void stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples); @@ -233,10 +235,10 @@ private: class DISCRETE_CLASS_NAME(dss_input_buffer): public DISCRETE_CLASS_NAME(dss_input_stream) { -public: DISCRETE_CLASS_CONSTRUCTOR(dss_input_buffer, dss_input_stream) - bool is_buffered(void) { return true; } DISCRETE_CLASS_DESTRUCTOR(dss_input_buffer) +public: + bool is_buffered(void) { return true; } }; #include "disc_wav.h" diff --git a/src/emu/sound/disc_dev.c b/src/emu/sound/disc_dev.c index 2a2fce139c3..385002cbd74 100644 --- a/src/emu/sound/disc_dev.c +++ b/src/emu/sound/disc_dev.c @@ -154,9 +154,9 @@ DISCRETE_STEP(dsd_555_astbl) m_t_rc_bleed = DSD_555_ASTBL_T_RC_BLEED; m_t_rc_charge = DSD_555_ASTBL_T_RC_CHARGE; m_t_rc_discharge = DSD_555_ASTBL_T_RC_DISCHARGE; - m_exp_bleed = RC_CHARGE_EXP_CLASS(m_t_rc_bleed); - m_exp_charge = RC_CHARGE_EXP_CLASS(m_t_rc_charge); - m_exp_discharge = RC_CHARGE_EXP_CLASS(m_t_rc_discharge); + m_exp_bleed = RC_CHARGE_EXP(m_t_rc_bleed); + m_exp_charge = RC_CHARGE_EXP(m_t_rc_charge); + m_exp_discharge = RC_CHARGE_EXP(m_t_rc_discharge); m_last_r1 = DSD_555_ASTBL__R1; m_last_r2 = DSD_555_ASTBL__R2; m_last_c = DSD_555_ASTBL__C; @@ -319,11 +319,11 @@ DISCRETE_RESET(dsd_555_astbl) else { m_t_rc_bleed = DSD_555_ASTBL_T_RC_BLEED; - m_exp_bleed = RC_CHARGE_EXP_CLASS(m_t_rc_bleed); + m_exp_bleed = RC_CHARGE_EXP(m_t_rc_bleed); m_t_rc_charge = DSD_555_ASTBL_T_RC_CHARGE; - m_exp_charge = RC_CHARGE_EXP_CLASS(m_t_rc_charge); + m_exp_charge = RC_CHARGE_EXP(m_t_rc_charge); m_t_rc_discharge = DSD_555_ASTBL_T_RC_DISCHARGE; - m_exp_discharge = RC_CHARGE_EXP_CLASS(m_t_rc_discharge); + m_exp_discharge = RC_CHARGE_EXP(m_t_rc_discharge); } m_output_is_ac = info->options & DISC_555_OUT_AC; @@ -533,7 +533,7 @@ DISCRETE_RESET(dsd_555_mstbl) if (this->input_is_node() & DSD_555_MSTBL_RC_MASK) m_has_rc_nodes = 1; else - m_exp_charge = RC_CHARGE_EXP_CLASS(DSD_555_MSTBL__R * DSD_555_MSTBL__C); + m_exp_charge = RC_CHARGE_EXP(DSD_555_MSTBL__R * DSD_555_MSTBL__C); this->output[0] = 0; } @@ -958,15 +958,15 @@ DISCRETE_RESET(dsd_555_cc) break; } - m_exp_bleed = RC_CHARGE_EXP_CLASS(DSD_555_CC_T_RC_BLEED); + m_exp_bleed = RC_CHARGE_EXP(DSD_555_CC_T_RC_BLEED); m_t_rc_discharge_01 = DSD_555_CC_T_RC_DISCHARGE_01; - m_exp_discharge_01 = RC_CHARGE_EXP_CLASS(m_t_rc_discharge_01); + m_exp_discharge_01 = RC_CHARGE_EXP(m_t_rc_discharge_01); m_t_rc_discharge_no_i = DSD_555_CC_T_RC_DISCHARGE_NO_I; - m_exp_discharge_no_i = RC_CHARGE_EXP_CLASS(m_t_rc_discharge_no_i); + m_exp_discharge_no_i = RC_CHARGE_EXP(m_t_rc_discharge_no_i); m_t_rc_charge = DSD_555_CC_T_RC_CHARGE; - m_exp_charge = RC_CHARGE_EXP_CLASS(m_t_rc_charge); + m_exp_charge = RC_CHARGE_EXP(m_t_rc_charge); m_t_rc_discharge = DSD_555_CC_T_RC_DISCHARGE; - m_exp_discharge = RC_CHARGE_EXP_CLASS(m_t_rc_discharge); + m_exp_discharge = RC_CHARGE_EXP(m_t_rc_discharge); } /* Step to set the output */ @@ -1753,7 +1753,7 @@ DISCRETE_RESET(dsd_ls624) if (DSD_LS624__C_FREQ_IN > 0) { m_has_freq_in_cap = 1; - m_exponent = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(DSD_LS624__R_FREQ_IN, LS624_IN_R) * DSD_LS624__C_FREQ_IN); + m_exponent = RC_CHARGE_EXP(RES_2_PARALLEL(DSD_LS624__R_FREQ_IN, LS624_IN_R) * DSD_LS624__C_FREQ_IN); m_v_cap_freq_in = 0; } else diff --git a/src/emu/sound/disc_dev.h b/src/emu/sound/disc_dev.h index 91271a9915e..01e79c76da2 100644 --- a/src/emu/sound/disc_dev.h +++ b/src/emu/sound/disc_dev.h @@ -21,55 +21,55 @@ #include "discrete.h" -DISCRETE_CLASS_STEP_RESETA(dsd_555_astbl, 1, - int m_use_ctrlv; - int m_output_type; - int m_output_is_ac; - double m_ac_shift; /* DC shift needed to make waveform ac */ - int m_flip_flop; /* 555 flip/flop output state */ - double m_cap_voltage; /* voltage on cap */ - double m_threshold; - double m_trigger; - double m_v_out_high; /* Logic 1 voltage level */ - double m_v_charge; - const double *m_v_charge_node; /* point to output of node */ - int m_has_rc_nodes; - double m_exp_bleed; - double m_exp_charge; - double m_exp_discharge; - double m_t_rc_bleed; - double m_t_rc_charge; - double m_t_rc_discharge; - double m_last_r1; - double m_last_r2; - double m_last_c; +DISCRETE_CLASS_STEP_RESET(dsd_555_astbl, 1, + int m_use_ctrlv; + int m_output_type; + int m_output_is_ac; + double m_ac_shift; /* DC shift needed to make waveform ac */ + int m_flip_flop; /* 555 flip/flop output state */ + double m_cap_voltage; /* voltage on cap */ + double m_threshold; + double m_trigger; + double m_v_out_high; /* Logic 1 voltage level */ + double m_v_charge; + const double *m_v_charge_node; /* point to output of node */ + int m_has_rc_nodes; + double m_exp_bleed; + double m_exp_charge; + double m_exp_discharge; + double m_t_rc_bleed; + double m_t_rc_charge; + double m_t_rc_discharge; + double m_last_r1; + double m_last_r2; + double m_last_c; ); -DISCRETE_CLASS_STEP_RESETA(dsd_555_mstbl, 1, - int m_trig_is_logic; - int m_trig_discharges_cap; - int m_output_type; - double m_ac_shift; /* DC shift needed to make waveform ac */ - int m_flip_flop; /* 555 flip/flop output state */ - int m_has_rc_nodes; - double m_exp_charge; - double m_cap_voltage; /* voltage on cap */ - double m_threshold; - double m_trigger; - double m_v_out_high; /* Logic 1 voltage level */ - double m_v_charge; +DISCRETE_CLASS_STEP_RESET(dsd_555_mstbl, 1, + int m_trig_is_logic; + int m_trig_discharges_cap; + int m_output_type; + double m_ac_shift; /* DC shift needed to make waveform ac */ + int m_flip_flop; /* 555 flip/flop output state */ + int m_has_rc_nodes; + double m_exp_charge; + double m_cap_voltage; /* voltage on cap */ + double m_threshold; + double m_trigger; + double m_v_out_high; /* Logic 1 voltage level */ + double m_v_charge; ); -DISCRETE_CLASS_STEP_RESETA(dsd_555_cc, 1, - unsigned int m_type; /* type of 555cc circuit */ +DISCRETE_CLASS_STEP_RESET(dsd_555_cc, 1, + unsigned int m_type; /* type of 555cc circuit */ int m_output_type; int m_output_is_ac; - double m_ac_shift; /* DC shift needed to make waveform ac */ - int m_flip_flop; /* 555 flip/flop output state */ - double m_cap_voltage; /* voltage on cap */ + double m_ac_shift; /* DC shift needed to make waveform ac */ + int m_flip_flop; /* 555 flip/flop output state */ + double m_cap_voltage; /* voltage on cap */ double m_threshold; double m_trigger; - double m_v_out_high; /* Logic 1 voltage level */ + double m_v_out_high; /* Logic 1 voltage level */ double m_v_cc_source; int m_has_rc_nodes; double m_exp_bleed; @@ -83,37 +83,37 @@ DISCRETE_CLASS_STEP_RESETA(dsd_555_cc, 1, double m_t_rc_discharge_no_i; ); -DISCRETE_CLASS_STEP_RESETA(dsd_555_vco1, 1, - int m_ctrlv_is_node; - int m_output_type; - int m_output_is_ac; - double m_ac_shift; /* DC shift needed to make waveform ac */ - int m_flip_flop; /* flip/flop output state */ - double m_v_out_high; /* 555 high voltage */ - double m_threshold; /* falling threshold */ - double m_trigger; /* rising threshold */ - double m_i_charge; /* charge current */ - double m_i_discharge; /* discharge current */ - double m_cap_voltage; /* current capacitor voltage */ +DISCRETE_CLASS_STEP_RESET(dsd_555_vco1, 1, + int m_ctrlv_is_node; + int m_output_type; + int m_output_is_ac; + double m_ac_shift; /* DC shift needed to make waveform ac */ + int m_flip_flop; /* flip/flop output state */ + double m_v_out_high; /* 555 high voltage */ + double m_threshold; /* falling threshold */ + double m_trigger; /* rising threshold */ + double m_i_charge; /* charge current */ + double m_i_discharge; /* discharge current */ + double m_cap_voltage; /* current capacitor voltage */ ); -DISCRETE_CLASS_STEP_RESETA(dsd_566, 1, - unsigned int m_state[2]; /* keeps track of excess flip_flop changes during the current step */ - int m_flip_flop; /* 566 flip/flop output state */ - double m_cap_voltage; /* voltage on cap */ - double m_v_sqr_low; /* voltage for a squarewave at low */ - double m_v_sqr_high; /* voltage for a squarewave at high */ +DISCRETE_CLASS_STEP_RESET(dsd_566, 1, + unsigned int m_state[2]; /* keeps track of excess flip_flop changes during the current step */ + int m_flip_flop; /* 566 flip/flop output state */ + double m_cap_voltage; /* voltage on cap */ + double m_v_sqr_low; /* voltage for a squarewave at low */ + double m_v_sqr_high; /* voltage for a squarewave at high */ double m_v_sqr_diff; - double m_threshold_low; /* falling threshold */ - double m_threshold_high; /* rising threshold */ - double m_ac_shift; /* used to fake AC */ + double m_threshold_low; /* falling threshold */ + double m_threshold_high; /* rising threshold */ + double m_ac_shift; /* used to fake AC */ double m_v_osc_stable; double m_v_osc_stop; int m_fake_ac; int m_out_type; ); -DISCRETE_CLASS_STEP_RESETA(dsd_ls624, 1, +DISCRETE_CLASS_STEP_RESET(dsd_ls624, 1, double m_exponent; double m_t_used; double m_v_cap_freq_in; diff --git a/src/emu/sound/disc_flt.c b/src/emu/sound/disc_flt.c index 189d3faa55c..0aee0b9c1bf 100644 --- a/src/emu/sound/disc_flt.c +++ b/src/emu/sound/disc_flt.c @@ -52,7 +52,7 @@ DISCRETE_STEP(dst_crfilter) if (rc != m_rc) { m_rc = rc; - m_exponent = RC_CHARGE_EXP_CLASS(rc); + m_exponent = RC_CHARGE_EXP(rc); } } @@ -66,7 +66,7 @@ DISCRETE_RESET(dst_crfilter) { m_has_rc_nodes = this->input_is_node() & 0x6; m_rc = DST_CRFILTER__R * DST_CRFILTER__C; - m_exponent = RC_CHARGE_EXP_CLASS(m_rc); + m_exponent = RC_CHARGE_EXP(m_rc); m_vCap = 0; this->output[0] = DST_CRFILTER__IN; } @@ -385,16 +385,16 @@ DISCRETE_RESET(dst_op_amp_filt) { case DISC_OP_AMP_FILTER_IS_LOW_PASS_1: case DISC_OP_AMP_FILTER_IS_LOW_PASS_1_A: - m_exponentC1 = RC_CHARGE_EXP_CLASS(info->rF * info->c1); + m_exponentC1 = RC_CHARGE_EXP(info->rF * info->c1); m_exponentC2 = 0; break; case DISC_OP_AMP_FILTER_IS_HIGH_PASS_1: - m_exponentC1 = RC_CHARGE_EXP_CLASS(m_rTotal * info->c1); + m_exponentC1 = RC_CHARGE_EXP(m_rTotal * info->c1); m_exponentC2 = 0; break; case DISC_OP_AMP_FILTER_IS_BAND_PASS_1: - m_exponentC1 = RC_CHARGE_EXP_CLASS(info->rF * info->c1); - m_exponentC2 = RC_CHARGE_EXP_CLASS(m_rTotal * info->c2); + m_exponentC1 = RC_CHARGE_EXP(info->rF * info->c1); + m_exponentC2 = RC_CHARGE_EXP(m_rTotal * info->c2); break; case DISC_OP_AMP_FILTER_IS_BAND_PASS_1M | DISC_OP_AMP_IS_NORTON: if (info->r2 == 0) @@ -420,12 +420,12 @@ DISCRETE_RESET(dst_op_amp_filt) break; } case DISC_OP_AMP_FILTER_IS_BAND_PASS_0 | DISC_OP_AMP_IS_NORTON: - m_exponentC1 = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(info->r1, info->r2 + info->r3 + info->r4) * info->c1); - m_exponentC2 = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(info->r1 + info->r2, info->r3 + info->r4) * info->c2); - m_exponentC3 = RC_CHARGE_EXP_CLASS((info->r1 + info->r2 + info->r3 + info->r4) * info->c3); + m_exponentC1 = RC_CHARGE_EXP(RES_2_PARALLEL(info->r1, info->r2 + info->r3 + info->r4) * info->c1); + m_exponentC2 = RC_CHARGE_EXP(RES_2_PARALLEL(info->r1 + info->r2, info->r3 + info->r4) * info->c2); + m_exponentC3 = RC_CHARGE_EXP((info->r1 + info->r2 + info->r3 + info->r4) * info->c3); break; case DISC_OP_AMP_FILTER_IS_HIGH_PASS_0 | DISC_OP_AMP_IS_NORTON: - m_exponentC1 = RC_CHARGE_EXP_CLASS(info->r1 * info->c1); + m_exponentC1 = RC_CHARGE_EXP(info->r1 * info->c1); break; } @@ -489,11 +489,11 @@ DISCRETE_RESET( dst_rc_circuit_1 ) /* precalculate charging exponents */ /* discharge cap - in1 = 0, in2 = 1*/ - m_exp_2 = RC_CHARGE_EXP_CLASS((CD4066_R_ON + DST_RC_CIRCUIT_1__R) * DST_RC_CIRCUIT_1__C); + m_exp_2 = RC_CHARGE_EXP((CD4066_R_ON + DST_RC_CIRCUIT_1__R) * DST_RC_CIRCUIT_1__C); /* charge cap - in1 = 1, in2 = 0 */ - m_exp_1 = RC_CHARGE_EXP_CLASS(CD4066_R_ON * DST_RC_CIRCUIT_1__C); + m_exp_1 = RC_CHARGE_EXP(CD4066_R_ON * DST_RC_CIRCUIT_1__C); /* charge cap - in1 = 1, in2 = 1 */ - m_exp_1_2 = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(CD4066_R_ON, CD4066_R_ON + DST_RC_CIRCUIT_1__R) * DST_RC_CIRCUIT_1__C); + m_exp_1_2 = RC_CHARGE_EXP(RES_2_PARALLEL(CD4066_R_ON, CD4066_R_ON + DST_RC_CIRCUIT_1__R) * DST_RC_CIRCUIT_1__C); /* starts at 0 until cap starts charging */ this->output[0] = 0; @@ -588,8 +588,8 @@ DISCRETE_RESET(dst_rcdisc2) m_state = 0; m_t = 0; - m_exponent0 = RC_DISCHARGE_EXP_CLASS(DST_RCDISC2__R0 * DST_RCDISC2__C); - m_exponent1 = RC_DISCHARGE_EXP_CLASS(DST_RCDISC2__R1 * DST_RCDISC2__C); + m_exponent0 = RC_DISCHARGE_EXP(DST_RCDISC2__R0 * DST_RCDISC2__C); + m_exponent1 = RC_DISCHARGE_EXP(DST_RCDISC2__R1 * DST_RCDISC2__C); } /************************************************************************ @@ -666,8 +666,8 @@ DISCRETE_RESET(dst_rcdisc3) m_state = 0; m_t = 0; m_v_diode = DST_RCDISC3__DJV; - m_exponent0 = RC_CHARGE_EXP_CLASS(DST_RCDISC3__R1 * DST_RCDISC3__C); - m_exponent1 = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(DST_RCDISC3__R1, DST_RCDISC3__R2) * DST_RCDISC3__C); + m_exponent0 = RC_CHARGE_EXP(DST_RCDISC3__R1 * DST_RCDISC3__C); + m_exponent1 = RC_CHARGE_EXP(RES_2_PARALLEL(DST_RCDISC3__R1, DST_RCDISC3__R2) * DST_RCDISC3__C); } @@ -759,14 +759,14 @@ DISCRETE_RESET( dst_rcdisc4) i = v / rT; m_v[1] = i * r + .5; rT = RES_2_PARALLEL(DST_RCDISC4__R2, r); - m_exp[1] = RC_CHARGE_EXP_CLASS(rT * DST_RCDISC4__C1); + m_exp[1] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1); /* When the input is 0, R1 is out of circuit. */ rT = DST_RCDISC4__R2 + DST_RCDISC4__R3; i = v / rT; m_v[0] = i * DST_RCDISC4__R3 + .5; rT = RES_2_PARALLEL(DST_RCDISC4__R2, DST_RCDISC4__R3); - m_exp[0] = RC_CHARGE_EXP_CLASS(rT * DST_RCDISC4__C1); + m_exp[0] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1); break; case 3: @@ -777,11 +777,11 @@ DISCRETE_RESET( dst_rcdisc4) r = 500.0 + DST_RCDISC4__R1; m_v[1] = RES_VOLTAGE_DIVIDER(r, DST_RCDISC4__R2) * (5.0 - 0.5); rT = RES_2_PARALLEL(r, DST_RCDISC4__R2); - m_exp[1] = RC_CHARGE_EXP_CLASS(rT * DST_RCDISC4__C1); + m_exp[1] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1); /* When the input is 0, R1 is out of circuit. */ m_v[0] = 0; - m_exp[0] = RC_CHARGE_EXP_CLASS(DST_RCDISC4__R2 * DST_RCDISC4__C1); + m_exp[0] = RC_CHARGE_EXP(DST_RCDISC4__R2 * DST_RCDISC4__C1); break; } } @@ -837,7 +837,7 @@ DISCRETE_RESET( dst_rcdisc5) m_state = 0; m_t = 0; m_v_cap = 0; - m_exponent0 = RC_CHARGE_EXP_CLASS(DST_RCDISC5__R * DST_RCDISC5__C); + m_exponent0 = RC_CHARGE_EXP(DST_RCDISC5__R * DST_RCDISC5__C); } @@ -906,28 +906,28 @@ DISCRETE_RESET(dst_rcdisc_mod) /* DST_RCDISC_MOD__IN1 <= 0.5 */ rc[0] = DST_RCDISC_MOD__R1 + DST_RCDISC_MOD__R2; if (rc[0] < 1) rc[0] = 1; - m_exp_low[0] = RC_DISCHARGE_EXP_CLASS(DST_RCDISC_MOD__C * rc[0]); + m_exp_low[0] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * rc[0]); m_gain[0] = RES_VOLTAGE_DIVIDER(rc[0], DST_RCDISC_MOD__R4); /* DST_RCDISC_MOD__IN1 > 0.5 */ rc[1] = DST_RCDISC_MOD__R2; if (rc[1] < 1) rc[1] = 1; - m_exp_low[1] = RC_DISCHARGE_EXP_CLASS(DST_RCDISC_MOD__C * rc[1]); + m_exp_low[1] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * rc[1]); m_gain[1] = RES_VOLTAGE_DIVIDER(rc[1], DST_RCDISC_MOD__R4); /* DST_RCDISC_MOD__IN2 <= 0.6 */ rc2[0] = DST_RCDISC_MOD__R4; /* DST_RCDISC_MOD__IN2 > 0.6 */ rc2[1] = RES_2_PARALLEL(DST_RCDISC_MOD__R3, DST_RCDISC_MOD__R4); /* DST_RCDISC_MOD__IN1 <= 0.5 && DST_RCDISC_MOD__IN2 <= 0.6 */ - m_exp_high[0] = RC_DISCHARGE_EXP_CLASS(DST_RCDISC_MOD__C * (rc[0] + rc2[0])); + m_exp_high[0] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[0] + rc2[0])); m_vd_gain[0] = RES_VOLTAGE_DIVIDER(rc[0], rc2[0]); /* DST_RCDISC_MOD__IN1 > 0.5 && DST_RCDISC_MOD__IN2 <= 0.6 */ - m_exp_high[1] = RC_DISCHARGE_EXP_CLASS(DST_RCDISC_MOD__C * (rc[1] + rc2[0])); + m_exp_high[1] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[1] + rc2[0])); m_vd_gain[1] = RES_VOLTAGE_DIVIDER(rc[1], rc2[0]); /* DST_RCDISC_MOD__IN1 <= 0.5 && DST_RCDISC_MOD__IN2 > 0.6 */ - m_exp_high[2] = RC_DISCHARGE_EXP_CLASS(DST_RCDISC_MOD__C * (rc[0] + rc2[1])); + m_exp_high[2] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[0] + rc2[1])); m_vd_gain[2] = RES_VOLTAGE_DIVIDER(rc[0], rc2[1]); /* DST_RCDISC_MOD__IN1 > 0.5 && DST_RCDISC_MOD__IN2 > 0.6 */ - m_exp_high[3] = RC_DISCHARGE_EXP_CLASS(DST_RCDISC_MOD__C * (rc[1] + rc2[1])); + m_exp_high[3] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[1] + rc2[1])); m_vd_gain[3] = RES_VOLTAGE_DIVIDER(rc[1], rc2[1]); m_v_cap = 0; @@ -962,7 +962,7 @@ DISCRETE_STEP(dst_rcfilter) if (rc != m_rc) { m_rc = rc; - m_exponent = RC_CHARGE_EXP_CLASS(rc); + m_exponent = RC_CHARGE_EXP(rc); } } @@ -980,7 +980,7 @@ DISCRETE_RESET(dst_rcfilter) { m_has_rc_nodes = this->input_is_node() & 0x6; m_rc = DST_RCFILTER__R * DST_RCFILTER__C; - m_exponent = RC_CHARGE_EXP_CLASS(m_rc); + m_exponent = RC_CHARGE_EXP(m_rc); m_vCap = 0; this->output[0] = 0; /* FIXME --> we really need another class here */ @@ -1067,7 +1067,7 @@ DISCRETE_RESET(dst_rcfilter_sw) for (i = 0; i < 4; i++) { m_vCap[i] = 0; - m_exp[i] = RC_CHARGE_EXP_CLASS( CD4066_ON_RES * DST_RCFILTER_SW__C(i)); + m_exp[i] = RC_CHARGE_EXP( CD4066_ON_RES * DST_RCFILTER_SW__C(i)); } for (bits=0; bits < 15; bits++) @@ -1085,8 +1085,8 @@ DISCRETE_RESET(dst_rcfilter_sw) /* fast cases */ - m_exp0 = RC_CHARGE_EXP_CLASS((CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(0)); - m_exp1 = RC_CHARGE_EXP_CLASS((CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(1)); + m_exp0 = RC_CHARGE_EXP((CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(0)); + m_exp1 = RC_CHARGE_EXP((CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(1)); m_factor = RES_VOLTAGE_DIVIDER(DST_RCFILTER_SW__R, CD4066_ON_RES); this->output[0] = 0; diff --git a/src/emu/sound/disc_flt.h b/src/emu/sound/disc_flt.h index a2a5435ee19..69dc0cf6fb5 100644 --- a/src/emu/sound/disc_flt.h +++ b/src/emu/sound/disc_flt.h @@ -30,152 +30,144 @@ struct discrete_filter_coeff }; -DISCRETE_CLASS_STEP_RESETA(dst_filter1, 1, +DISCRETE_CLASS_STEP_RESET(dst_filter1, 1, /* uses x1, y1, a1, b0, b1 */ struct discrete_filter_coeff m_fc; ); -DISCRETE_CLASS_STEP_RESETA(dst_filter2, 1, +DISCRETE_CLASS_STEP_RESET(dst_filter2, 1, struct discrete_filter_coeff m_fc; ); -DISCRETE_CLASS_STEP_RESETA(dst_sallen_key, 1, +DISCRETE_CLASS_STEP_RESET(dst_sallen_key, 1, struct discrete_filter_coeff m_fc; ); -DISCRETE_CLASS_STEP_RESETA(dst_crfilter, 1, - double m_vCap; - double m_rc; - double m_exponent; - UINT8 m_has_rc_nodes; - UINT8 m_is_fast; +DISCRETE_CLASS_STEP_RESET(dst_crfilter, 1, + double m_vCap; + double m_rc; + double m_exponent; + UINT8 m_has_rc_nodes; + UINT8 m_is_fast; ); -DISCRETE_CLASS_STEP_RESETA(dst_op_amp_filt, 1, - int m_type; /* What kind of filter */ - int m_is_norton; /* 1 = Norton op-amps */ - double m_vRef; - double m_vP; - double m_vN; - double m_rTotal; /* All input resistance in parallel. */ - double m_iFixed; /* Current supplied by r3 & r4 if used. */ - double m_exponentC1; - double m_exponentC2; - double m_exponentC3; - double m_rRatio; /* divide ratio of resistance network */ - double m_vC1; /* Charge on C1 */ - double m_vC1b; /* Charge on C1, part of C1 charge if needed */ - double m_vC2; /* Charge on C2 */ - double m_vC3; /* Charge on C2 */ - double m_gain; /* Gain of the filter */ +DISCRETE_CLASS_STEP_RESET(dst_op_amp_filt, 1, + int m_type; /* What kind of filter */ + int m_is_norton; /* 1 = Norton op-amps */ + double m_vRef; + double m_vP; + double m_vN; + double m_rTotal; /* All input resistance in parallel. */ + double m_iFixed; /* Current supplied by r3 & r4 if used. */ + double m_exponentC1; + double m_exponentC2; + double m_exponentC3; + double m_rRatio; /* divide ratio of resistance network */ + double m_vC1; /* Charge on C1 */ + double m_vC1b; /* Charge on C1, part of C1 charge if needed */ + double m_vC2; /* Charge on C2 */ + double m_vC3; /* Charge on C2 */ + double m_gain; /* Gain of the filter */ struct discrete_filter_coeff m_fc; ); -DISCRETE_CLASS_STEP_RESETA(dst_rc_circuit_1, 1, - double m_v_cap; - double m_v_charge_1_2; - double m_v_drop; - double m_exp_1; - double m_exp_1_2; - double m_exp_2; +DISCRETE_CLASS_STEP_RESET(dst_rc_circuit_1, 1, + double m_v_cap; + double m_v_charge_1_2; + double m_v_drop; + double m_exp_1; + double m_exp_1_2; + double m_exp_2; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdisc, 1, - int m_state; - double m_t; /* time */ - double m_exponent0; - double m_exponent1; - double m_v_cap; /* rcdisc5 */ - double m_v_diode; /* rcdisc3 */ +DISCRETE_CLASS_STEP_RESET(dst_rcdisc, 1, + int m_state; + double m_t; /* time */ + double m_exponent0; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdisc2, 1, - int m_state; - double m_t; /* time */ - double m_exponent0; - double m_exponent1; - double m_v_cap; /* rcdisc5 */ - double m_v_diode; /* rcdisc3 */ +DISCRETE_CLASS_STEP_RESET(dst_rcdisc2, 1, + int m_state; + double m_t; /* time */ + double m_exponent0; + double m_exponent1; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdisc3, 1, - int m_state; - double m_t; /* time */ - double m_exponent0; - double m_exponent1; - double m_v_cap; /* rcdisc5 */ - double m_v_diode; /* rcdisc3 */ +DISCRETE_CLASS_STEP_RESET(dst_rcdisc3, 1, + int m_state; + double m_t; /* time */ + double m_exponent0; + double m_exponent1; + double m_v_diode; /* rcdisc3 */ ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdisc4, 1, - int m_type; - double m_max_out; - double m_vC1; - double m_v[2]; - double m_exp[2]; +DISCRETE_CLASS_STEP_RESET(dst_rcdisc4, 1, + int m_type; + double m_max_out; + double m_vC1; + double m_v[2]; + double m_exp[2]; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdisc5, 1, - int m_state; - double m_t; /* time */ - double m_exponent0; - double m_exponent1; - double m_v_cap; /* rcdisc5 */ - double m_v_diode; /* rcdisc3 */ +DISCRETE_CLASS_STEP_RESET(dst_rcdisc5, 1, + int m_state; + double m_t; /* time */ + double m_exponent0; + double m_v_cap; /* rcdisc5 */ ); -DISCRETE_CLASS_STEP_RESETA(dst_rcintegrate, 1, - int m_type; - double m_gain_r1_r2; - double m_f; /* r2,r3 gain */ - double m_vCap; - double m_vCE; - double m_exponent0; - double m_exponent1; - double m_exp_exponent0; - double m_exp_exponent1; - double m_c_exp0; - double m_c_exp1; +DISCRETE_CLASS_STEP_RESET(dst_rcintegrate, 1, + int m_type; + double m_gain_r1_r2; + double m_f; /* r2,r3 gain */ + double m_vCap; + double m_vCE; + double m_exponent0; + double m_exponent1; + double m_exp_exponent0; + double m_exp_exponent1; + double m_c_exp0; + double m_c_exp1; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdisc_mod, 1, - double m_v_cap; - double m_exp_low[2]; - double m_exp_high[4]; - double m_gain[2]; - double m_vd_gain[4]; +DISCRETE_CLASS_STEP_RESET(dst_rcdisc_mod, 1, + double m_v_cap; + double m_exp_low[2]; + double m_exp_high[4]; + double m_gain[2]; + double m_vd_gain[4]; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcfilter, 1, - double m_vCap; - double m_rc; - double m_exponent; - UINT8 m_has_rc_nodes; - UINT8 m_is_fast; +DISCRETE_CLASS_STEP_RESET(dst_rcfilter, 1, + double m_vCap; + double m_rc; + double m_exponent; + UINT8 m_has_rc_nodes; + UINT8 m_is_fast; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcfilter_sw, 1, - double m_vCap[4]; - double m_exp[4]; - double m_exp0; /* fast case bit 0 */ - double m_exp1; /* fast case bit 1 */ - double m_factor; /* fast case */ - double m_f1[16]; - double m_f2[16]; +DISCRETE_CLASS_STEP_RESET(dst_rcfilter_sw, 1, + double m_vCap[4]; + double m_exp[4]; + double m_exp0; /* fast case bit 0 */ + double m_exp1; /* fast case bit 1 */ + double m_factor; /* fast case */ + double m_f1[16]; + double m_f2[16]; ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdiscN, 1, - double m_x1; /* x[k-1], previous input value */ - double m_y1; /* y[k-1], previous output value */ - double m_a1; /* digital filter coefficients, denominator */ - double m_b[2]; /* digital filter coefficients, numerator */ +DISCRETE_CLASS_STEP_RESET(dst_rcdiscN, 1, + double m_x1; /* x[k-1], previous input value */ + double m_y1; /* y[k-1], previous output value */ + double m_a1; /* digital filter coefficients, denominator */ + double m_b[2]; /* digital filter coefficients, numerator */ ); -DISCRETE_CLASS_STEP_RESETA(dst_rcdisc2N, 1, +DISCRETE_CLASS_STEP_RESET(dst_rcdisc2N, 1, struct discrete_filter_coeff m_fc0; struct discrete_filter_coeff m_fc1; - double m_x1; - double m_y1; + double m_x1; + double m_y1; ); diff --git a/src/emu/sound/disc_mth.c b/src/emu/sound/disc_mth.c index 61382b518c2..46a0d14b702 100644 --- a/src/emu/sound/disc_mth.c +++ b/src/emu/sound/disc_mth.c @@ -260,7 +260,7 @@ DISCRETE_RESET(dst_dac_r1) { m_has_c_filter = 1; /* Setup filter constant */ - m_exponent = RC_CHARGE_EXP_CLASS(r_total * info->cFilter); + m_exponent = RC_CHARGE_EXP(r_total * info->cFilter); } else m_has_c_filter = 0; @@ -1057,7 +1057,7 @@ DISCRETE_STEP(dst_mixer) /* Re-calculate exponent if resistor is a node and has changed value */ if (*m_r_node[bit] != m_r_last[bit]) { - m_exponent_rc[bit] = RC_CHARGE_EXP_CLASS(rTemp2 * info->c[bit]); + m_exponent_rc[bit] = RC_CHARGE_EXP(rTemp2 * info->c[bit]); m_r_last[bit] = *m_r_node[bit]; } } @@ -1127,7 +1127,7 @@ DISCRETE_STEP(dst_mixer) if (UNEXPECTED(r_node_bit_flag != 0)) { /* Re-calculate exponent if resistor nodes are used */ - m_exponent_c_f = RC_CHARGE_EXP_CLASS(r_total * info->cF); + m_exponent_c_f = RC_CHARGE_EXP(r_total * info->cF); } m_v_cap_f += (v - v_ref - m_v_cap_f) * m_exponent_c_f; v = m_v_cap_f; @@ -1217,7 +1217,7 @@ DISCRETE_RESET(dst_mixer) break; } /* Setup filter constants */ - m_exponent_rc[bit] = RC_CHARGE_EXP_CLASS(rTemp * info->c[bit]); + m_exponent_rc[bit] = RC_CHARGE_EXP(rTemp * info->c[bit]); } } @@ -1232,7 +1232,7 @@ DISCRETE_RESET(dst_mixer) if (info->cF != 0) { /* Setup filter constants */ - m_exponent_c_f = RC_CHARGE_EXP_CLASS(((info->type == DISC_MIXER_IS_OP_AMP) ? info->rF : (1.0 / m_r_total)) * info->cF); + m_exponent_c_f = RC_CHARGE_EXP(((info->type == DISC_MIXER_IS_OP_AMP) ? info->rF : (1.0 / m_r_total)) * info->cF); } m_v_cap_amp = 0; @@ -1242,7 +1242,7 @@ DISCRETE_RESET(dst_mixer) /* Setup filter constants */ /* We will use 100k ohms as an average final stage impedance. */ /* Your amp/speaker system will have more effect on incorrect filtering then any value used here. */ - m_exponent_c_amp = RC_CHARGE_EXP_CLASS(RES_K(100) * info->cAmp); + m_exponent_c_amp = RC_CHARGE_EXP(RES_K(100) * info->cAmp); } if (m_type == DISC_MIXER_IS_OP_AMP_WITH_RI) m_gain = info->rF / info->rI; @@ -1757,7 +1757,7 @@ DISCRETE_RESET(dst_op_amp) if (m_has_r4) { /* exponential charge */ - m_exponent = RC_CHARGE_EXP_CLASS(info->r4 * info->c); + m_exponent = RC_CHARGE_EXP(info->r4 * info->c); } else /* linear charge */ @@ -1826,9 +1826,9 @@ DISCRETE_RESET(dst_op_amp_1sht) { DISCRETE_DECLARE_INFO(discrete_op_amp_1sht_info) - m_exponent1c = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(info->r3, info->r4) * info->c1); - m_exponent1d = RC_CHARGE_EXP_CLASS(info->r4 * info->c1); - m_exponent2 = RC_CHARGE_EXP_CLASS(info->r2 * info->c2); + m_exponent1c = RC_CHARGE_EXP(RES_2_PARALLEL(info->r3, info->r4) * info->c1); + m_exponent1d = RC_CHARGE_EXP(info->r4 * info->c1); + m_exponent2 = RC_CHARGE_EXP(info->r2 * info->c2); m_i_fixed = (info->vP - OP_AMP_NORTON_VBE) / info->r1; m_v_cap1 = m_v_cap2 = 0; m_v_max = info->vP - OP_AMP_NORTON_VBE; @@ -1971,28 +1971,28 @@ DISCRETE_RESET(dst_tvca_op_amp) m_v_cap1 = 0; /* Charge rate thru r5 */ /* There can be a different charge rates depending on function F3. */ - m_exponent_c[0] = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(info->r5, info->r6) * info->c1); - m_exponent_c[1] = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(info->r5, m_r67) * info->c1); + m_exponent_c[0] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r5, info->r6) * info->c1); + m_exponent_c[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r5, m_r67) * info->c1); /* Discharge rate thru r6 + r7 */ - m_exponent_d[1] = RC_CHARGE_EXP_CLASS(m_r67 * info->c1); + m_exponent_d[1] = RC_CHARGE_EXP(m_r67 * info->c1); /* Discharge rate thru r6 */ if (info->r6 != 0) { - m_exponent_d[0] = RC_CHARGE_EXP_CLASS(info->r6 * info->c1); + m_exponent_d[0] = RC_CHARGE_EXP(info->r6 * info->c1); } m_v_cap2 = 0; m_v_trig2 = (info->v2 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r8, info->r9); - m_exponent2[0] = RC_CHARGE_EXP_CLASS(info->r9 * info->c2); - m_exponent2[1] = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(info->r8, info->r9) * info->c2); + m_exponent2[0] = RC_CHARGE_EXP(info->r9 * info->c2); + m_exponent2[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r8, info->r9) * info->c2); m_v_cap3 = 0; m_v_trig3 = (info->v3 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r10, info->r11); - m_exponent3[0] = RC_CHARGE_EXP_CLASS(info->r11 * info->c3); - m_exponent3[1] = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(info->r10, info->r11) * info->c3); + m_exponent3[0] = RC_CHARGE_EXP(info->r11 * info->c3); + m_exponent3[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r10, info->r11) * info->c3); m_v_cap4 = 0; if (info->r4 != 0) m_has_r4 = 1; if (info->c4 != 0) m_has_c4 = 1; if (m_has_r4 && m_has_c4) - m_exponent4 = RC_CHARGE_EXP_CLASS(info->r4 * info->c4); + m_exponent4 = RC_CHARGE_EXP(info->r4 * info->c4); this->step(); } diff --git a/src/emu/sound/disc_mth.h b/src/emu/sound/disc_mth.h index 2c90282429a..cc0bce53d02 100644 --- a/src/emu/sound/disc_mth.h +++ b/src/emu/sound/disc_mth.h @@ -21,175 +21,175 @@ #include "discrete.h" -DISCRETE_CLASS_STEPA(dst_adder, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_adder, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_clamp, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_clamp, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_divide, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_divide, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_gain, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_gain, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_logic_inv, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_logic_inv, 1, /* no context */ ); -DISCRETE_CLASS_STEP_RESETA(dst_bits_decode, 8, - int m_count; - int m_decode_x_time; - int m_from; - int m_last_val; - int m_last_had_x_time; +DISCRETE_CLASS_STEP_RESET(dst_bits_decode, 8, + int m_count; + int m_decode_x_time; + int m_from; + int m_last_val; + int m_last_had_x_time; ); -DISCRETE_CLASS_STEPA(dst_logic_and, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_logic_and, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_logic_nand, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_logic_nand, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_logic_or, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_logic_or, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_logic_nor, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_logic_nor, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_logic_xor, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_logic_xor, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_logic_nxor, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_logic_nxor, 1, /* no context */ ); -DISCRETE_CLASS_STEP_RESETA(dst_logic_dff, 1, - int m_last_clk; +DISCRETE_CLASS_STEP_RESET(dst_logic_dff, 1, + int m_last_clk; ); -DISCRETE_CLASS_STEP_RESETA(dst_logic_jkff, 1, - int m_last_clk; +DISCRETE_CLASS_STEP_RESET(dst_logic_jkff, 1, + int m_last_clk; ); -DISCRETE_CLASS_STEP_RESETA(dst_logic_shift, 1, - double m_t_left; /* time unused during last sample in seconds */ - UINT32 m_shift_data; - UINT32 m_bit_mask; - UINT8 m_clock_type; - UINT8 m_reset_on_high; - UINT8 m_shift_r; - UINT8 m_last; +DISCRETE_CLASS_STEP_RESET(dst_logic_shift, 1, + double m_t_left; /* time unused during last sample in seconds */ + UINT32 m_shift_data; + UINT32 m_bit_mask; + UINT8 m_clock_type; + UINT8 m_reset_on_high; + UINT8 m_shift_r; + UINT8 m_last; ); -DISCRETE_CLASS_STEPA(dst_lookup_table, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_lookup_table, 1, /* no context */ ); -DISCRETE_CLASS_STEP_RESETA(dst_multiplex, 1, - int m_size; +DISCRETE_CLASS_STEP_RESET(dst_multiplex, 1, + int m_size; ); -DISCRETE_CLASS_STEP_RESETA(dst_oneshot, 1, - double m_countdown; - int m_state; - int m_last_trig; - int m_type; +DISCRETE_CLASS_STEP_RESET(dst_oneshot, 1, + double m_countdown; + int m_state; + int m_last_trig; + int m_type; ); -DISCRETE_CLASS_STEP_RESETA(dst_ramp, 1, - double m_step; - int m_dir; /* 1 if End is higher then Start */ - int m_last_en; /* Keep track of the last enable value */ +DISCRETE_CLASS_STEP_RESET(dst_ramp, 1, + double m_step; + int m_dir; /* 1 if End is higher then Start */ + int m_last_en; /* Keep track of the last enable value */ ); -DISCRETE_CLASS_STEP_RESETA(dst_samphold, 1, - double m_last_input; - int m_clocktype; +DISCRETE_CLASS_STEP_RESET(dst_samphold, 1, + double m_last_input; + int m_clocktype; ); -DISCRETE_CLASS_STEPA(dst_switch, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_switch, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_aswitch, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_aswitch, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_transform, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_transform, 1, /* no context */ ); /* Component specific */ -DISCRETE_CLASS_STEP_RESETA(dst_comp_adder, 1, - double m_total[256]; +DISCRETE_CLASS_STEP_RESET(dst_comp_adder, 1, + double m_total[256]; ); -DISCRETE_CLASS_STEP_RESETA(dst_dac_r1, 1, - double m_exponent; - double m_last_v; - double m_v_step[256]; - int m_has_c_filter; +DISCRETE_CLASS_STEP_RESET(dst_dac_r1, 1, + double m_exponent; + double m_last_v; + double m_v_step[256]; + int m_has_c_filter; ); -DISCRETE_CLASS_STEP_RESETA(dst_diode_mix, 1, - int m_size; - double m_v_junction[8]; +DISCRETE_CLASS_STEP_RESET(dst_diode_mix, 1, + int m_size; + double m_v_junction[8]; ); -DISCRETE_CLASS_STEP_RESETA(dst_integrate, 1, - double m_change; - double m_v_max_in; /* v1 - norton VBE */ - double m_v_max_in_d; /* v1 - norton VBE - diode drop */ - double m_v_max_out; +DISCRETE_CLASS_STEP_RESET(dst_integrate, 1, + double m_change; + double m_v_max_in; /* v1 - norton VBE */ + double m_v_max_in_d; /* v1 - norton VBE - diode drop */ + double m_v_max_out; ); #define DISC_MIXER_MAX_INPS 8 -DISCRETE_CLASS_STEP_RESETA(dst_mixer, 1, - int m_type; - int m_size; - int m_r_node_bit_flag; - int m_c_bit_flag; - double m_r_total; - const double *m_r_node[DISC_MIXER_MAX_INPS]; /* Either pointer to resistance node output OR NULL */ - double m_r_last[DISC_MIXER_MAX_INPS]; - double m_exponent_rc[DISC_MIXER_MAX_INPS]; /* For high pass filtering cause by cIn */ - double m_v_cap[DISC_MIXER_MAX_INPS]; /* cap voltage of each input */ - double m_exponent_c_f; /* Low pass on mixed inputs */ - double m_exponent_c_amp; /* Final high pass caused by out cap and amp input impedance */ - double m_v_cap_f; /* cap voltage of cF */ - double m_v_cap_amp; /* cap voltage of cAmp */ - double m_gain; /* used for DISC_MIXER_IS_OP_AMP_WITH_RI */ +DISCRETE_CLASS_STEP_RESET(dst_mixer, 1, + int m_type; + int m_size; + int m_r_node_bit_flag; + int m_c_bit_flag; + double m_r_total; + const double * m_r_node[DISC_MIXER_MAX_INPS]; /* Either pointer to resistance node output OR NULL */ + double m_r_last[DISC_MIXER_MAX_INPS]; + double m_exponent_rc[DISC_MIXER_MAX_INPS]; /* For high pass filtering cause by cIn */ + double m_v_cap[DISC_MIXER_MAX_INPS]; /* cap voltage of each input */ + double m_exponent_c_f; /* Low pass on mixed inputs */ + double m_exponent_c_amp; /* Final high pass caused by out cap and amp input impedance */ + double m_v_cap_f; /* cap voltage of cF */ + double m_v_cap_amp; /* cap voltage of cAmp */ + double m_gain; /* used for DISC_MIXER_IS_OP_AMP_WITH_RI */ ); -DISCRETE_CLASS_STEP_RESETA(dst_op_amp, 1, - UINT8 m_has_cap; - UINT8 m_has_r1; - UINT8 m_has_r4; - double m_v_max; - double m_i_fixed; - double m_v_cap; - double m_exponent; +DISCRETE_CLASS_STEP_RESET(dst_op_amp, 1, + UINT8 m_has_cap; + UINT8 m_has_r1; + UINT8 m_has_r4; + double m_v_max; + double m_i_fixed; + double m_v_cap; + double m_exponent; ); -DISCRETE_CLASS_STEP_RESETA(dst_op_amp_1sht, 1, - double m_i_fixed; - double m_v_max; - double m_r34ratio; - double m_v_cap1; - double m_v_cap2; - double m_exponent1c; - double m_exponent1d; - double m_exponent2; +DISCRETE_CLASS_STEP_RESET(dst_op_amp_1sht, 1, + double m_i_fixed; + double m_v_max; + double m_r34ratio; + double m_v_cap1; + double m_v_cap2; + double m_exponent1c; + double m_exponent1d; + double m_exponent2; ); -DISCRETE_CLASS_STEP_RESETA(dst_tvca_op_amp, 1, - double m_v_out_max; /* Maximum output voltage */ - double m_v_trig[2]; /* Voltage used to charge cap1 based on function F3 */ - double m_v_trig2; /* Voltage used to charge cap2 */ - double m_v_trig3; /* Voltage used to charge cap3 */ - double m_i_fixed; /* Fixed current going into - input */ - double m_exponent_c[2]; /* Charge exponents based on function F3 */ - double m_exponent_d[2]; /* Discharge exponents based on function F3 */ - double m_exponent2[2]; /* Discharge/charge exponents based on function F4 */ - double m_exponent3[2]; /* Discharge/charge exponents based on function F5 */ - double m_exponent4; /* Discharge/charge exponents for c4 */ - double m_v_cap1; /* charge on cap c1 */ - double m_v_cap2; /* charge on cap c2 */ - double m_v_cap3; /* charge on cap c3 */ - double m_v_cap4; /* charge on cap c4 */ - double m_r67; /* = r6 + r7 (for easy use later) */ - UINT8 m_has_c4; - UINT8 m_has_r4; +DISCRETE_CLASS_STEP_RESET(dst_tvca_op_amp, 1, + double m_v_out_max; /* Maximum output voltage */ + double m_v_trig[2]; /* Voltage used to charge cap1 based on function F3 */ + double m_v_trig2; /* Voltage used to charge cap2 */ + double m_v_trig3; /* Voltage used to charge cap3 */ + double m_i_fixed; /* Fixed current going into - input */ + double m_exponent_c[2]; /* Charge exponents based on function F3 */ + double m_exponent_d[2]; /* Discharge exponents based on function F3 */ + double m_exponent2[2]; /* Discharge/charge exponents based on function F4 */ + double m_exponent3[2]; /* Discharge/charge exponents based on function F5 */ + double m_exponent4; /* Discharge/charge exponents for c4 */ + double m_v_cap1; /* charge on cap c1 */ + double m_v_cap2; /* charge on cap c2 */ + double m_v_cap3; /* charge on cap c3 */ + double m_v_cap4; /* charge on cap c4 */ + double m_r67; /* = r6 + r7 (for easy use later) */ + UINT8 m_has_c4; + UINT8 m_has_r4; ); -DISCRETE_CLASS_STEPA(dst_xtime_buffer, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_xtime_buffer, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_xtime_and, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_xtime_and, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_xtime_or, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_xtime_or, 1, /* no context */ ); -DISCRETE_CLASS_STEPA(dst_xtime_xor, 1, /* no context */ ); +DISCRETE_CLASS_STEP(dst_xtime_xor, 1, /* no context */ ); #endif /* __DISC_WAV_H__ */ diff --git a/src/emu/sound/disc_wav.c b/src/emu/sound/disc_wav.c index fdb9ea772e4..369219a3bb1 100644 --- a/src/emu/sound/disc_wav.c +++ b/src/emu/sound/disc_wav.c @@ -975,8 +975,8 @@ DISCRETE_RESET(dss_op_amp_osc) m_charge_rc[0] *= info->c; m_charge_rc[1] *= info->c; - m_charge_exp[0] = RC_CHARGE_EXP_CLASS(m_charge_rc[0]); - m_charge_exp[1] = RC_CHARGE_EXP_CLASS(m_charge_rc[1]); + m_charge_exp[0] = RC_CHARGE_EXP(m_charge_rc[0]); + m_charge_exp[1] = RC_CHARGE_EXP(m_charge_rc[1]); m_threshold_low = (info->vP - OP_AMP_NORTON_VBE) / info->r4; m_threshold_high = m_threshold_low + (info->vP - 2 * OP_AMP_NORTON_VBE) / info->r3;; m_threshold_low = m_threshold_low * info->r2 + OP_AMP_NORTON_VBE; @@ -1224,7 +1224,7 @@ DISCRETE_RESET(dss_schmitt_osc) * So use this for the RC charge constant. */ rSource = 1.0 / ((1.0 / info->rIn) + (1.0 / info->rFeedback)); m_rc = rSource * info->c; - m_exponent = RC_CHARGE_EXP_CLASS(m_rc); + m_exponent = RC_CHARGE_EXP(m_rc); /* Cap is at 0V on power up. Causing output to be high. */ m_v_cap = 0; diff --git a/src/emu/sound/disc_wav.h b/src/emu/sound/disc_wav.h index bf25279444a..4827158560d 100644 --- a/src/emu/sound/disc_wav.h +++ b/src/emu/sound/disc_wav.h @@ -21,24 +21,24 @@ #include "discrete.h" -DISCRETE_CLASS_STEP_RESETA(dss_counter, 1, - int m_clock_type; - int m_out_type; - int m_is_7492; - int m_last_clock; - UINT32 m_last_count; - UINT32 m_last; /* Last clock state */ - UINT32 m_min; - UINT32 m_max; - UINT32 m_diff; - double m_t_left; /* time unused during last sample in seconds */ +DISCRETE_CLASS_STEP_RESET(dss_counter, 1, + int m_clock_type; + int m_out_type; + int m_is_7492; + int m_last_clock; + UINT32 m_last_count; + UINT32 m_last; /* Last clock state */ + UINT32 m_min; + UINT32 m_max; + UINT32 m_diff; + double m_t_left; /* time unused during last sample in seconds */ ); -DISCRETE_CLASS_STEP_RESETA(dss_lfsr_noise, 2, +DISCRETE_CLASS_STEP_RESET(dss_lfsr_noise, 2, unsigned int m_lfsr_reg; - int m_last; /* Last clock state */ - double m_t_clock; /* fixed counter clock in seconds */ - double m_t_left; /* time unused during last sample in seconds */ + int m_last; /* Last clock state */ + double m_t_clock; /* fixed counter clock in seconds */ + double m_t_left; /* time unused during last sample in seconds */ double m_sample_step; double m_t; UINT8 m_reset_on_high; @@ -47,50 +47,50 @@ DISCRETE_CLASS_STEP_RESETA(dss_lfsr_noise, 2, UINT8 m_out_lfsr_reg; ); -DISCRETE_CLASS_STEP_RESETA(dss_noise, 2, - double m_phase; +DISCRETE_CLASS_STEP_RESET(dss_noise, 2, + double m_phase; ); -DISCRETE_CLASS_STEP_RESETA(dss_note, 1, - int m_clock_type; - int m_out_type; - int m_last; /* Last clock state */ - double m_t_clock; /* fixed counter clock in seconds */ - double m_t_left; /* time unused during last sample in seconds */ - int m_max1; /* Max 1 Count stored as int for easy use. */ - int m_max2; /* Max 2 Count stored as int for easy use. */ - int m_count1; /* current count1 */ - int m_count2; /* current count2 */ +DISCRETE_CLASS_STEP_RESET(dss_note, 1, + int m_clock_type; + int m_out_type; + int m_last; /* Last clock state */ + double m_t_clock; /* fixed counter clock in seconds */ + double m_t_left; /* time unused during last sample in seconds */ + int m_max1; /* Max 1 Count stored as int for easy use. */ + int m_max2; /* Max 2 Count stored as int for easy use. */ + int m_count1; /* current count1 */ + int m_count2; /* current count2 */ ); -DISCRETE_CLASS_STEP_RESETA(dss_sawtoothwave, 1, - double m_phase; - int m_type; +DISCRETE_CLASS_STEP_RESET(dss_sawtoothwave, 1, + double m_phase; + int m_type; ); -DISCRETE_CLASS_STEP_RESETA(dss_sinewave, 1, - double m_phase; +DISCRETE_CLASS_STEP_RESET(dss_sinewave, 1, + double m_phase; ); -DISCRETE_CLASS_STEP_RESETA(dss_squarewave, 1, - double m_phase; - double m_trigger; +DISCRETE_CLASS_STEP_RESET(dss_squarewave, 1, + double m_phase; + double m_trigger; ); -DISCRETE_CLASS_STEP_RESETA(dss_squarewfix, 1, - int m_flip_flop; - double m_sample_step; - double m_t_left; - double m_t_off; - double m_t_on; +DISCRETE_CLASS_STEP_RESET(dss_squarewfix, 1, + int m_flip_flop; + double m_sample_step; + double m_t_left; + double m_t_off; + double m_t_on; ); -DISCRETE_CLASS_STEP_RESETA(dss_squarewave2, 1, - double m_phase; - double m_trigger; +DISCRETE_CLASS_STEP_RESET(dss_squarewave2, 1, + double m_phase; + double m_trigger; ); -DISCRETE_CLASS_STEP_RESETA(dss_trianglewave, 1, - double m_phase; +DISCRETE_CLASS_STEP_RESET(dss_trianglewave, 1, + double m_phase; ); /* Component specific modules */ @@ -98,64 +98,65 @@ DISCRETE_CLASS_STEP_RESETA(dss_trianglewave, 1, class DISCRETE_CLASS_NAME(dss_inverter_osc): public discrete_base_node, public discrete_step_interface { + DISCRETE_CLASS_CONSTRUCTOR(dss_inverter_osc, base) + DISCRETE_CLASS_DESTRUCTOR(dss_inverter_osc) +public: + void step(void); + void reset(void); protected: inline double tftab(double x); inline double tf(double x); -public: - DISCRETE_CLASS_CONSTRUCTOR(dss_inverter_osc, base) - void step(void); - void reset(void); private: - double mc_v_cap; - double mc_v_g2_old; - double mc_w; - double mc_wc; - double mc_rp; - double mc_r1; - double mc_r2; - double mc_c; - double mc_tf_a; - double mc_tf_b; - double mc_tf_tab[DSS_INV_TAB_SIZE]; + double mc_v_cap; + double mc_v_g2_old; + double mc_w; + double mc_wc; + double mc_rp; + double mc_r1; + double mc_r2; + double mc_c; + double mc_tf_a; + double mc_tf_b; + double mc_tf_tab[DSS_INV_TAB_SIZE]; }; -DISCRETE_CLASS_STEP_RESETA(dss_op_amp_osc, 1, - const double *m_r[8]; /* pointers to resistor values */ - int m_type; - UINT8 m_flip_flop; /* flip/flop output state */ - UINT8 m_flip_flop_xor; /* flip_flop ^ flip_flop_xor, 0 = discharge, 1 = charge */ - UINT8 m_output_type; - UINT8 m_has_enable; - double m_v_out_high; - double m_threshold_low; /* falling threshold */ - double m_threshold_high; /* rising threshold */ - double m_v_cap; /* current capacitor voltage */ - double m_r_total; /* all input resistors in parallel */ - double m_i_fixed; /* fixed current at the input */ - double m_i_enable; /* fixed current at the input if enabled */ - double m_temp1; /* Multi purpose */ - double m_temp2; /* Multi purpose */ - double m_temp3; /* Multi purpose */ - double m_is_linear_charge; - double m_charge_rc[2]; - double m_charge_exp[2]; - double m_charge_v[2]; +DISCRETE_CLASS_STEP_RESET(dss_op_amp_osc, 1, + const double * m_r[8]; /* pointers to resistor values */ + int m_type; + UINT8 m_flip_flop; /* flip/flop output state */ + UINT8 m_flip_flop_xor; /* flip_flop ^ flip_flop_xor, 0 = discharge, 1 = charge */ + UINT8 m_output_type; + UINT8 m_has_enable; + double m_v_out_high; + double m_threshold_low; /* falling threshold */ + double m_threshold_high; /* rising threshold */ + double m_v_cap; /* current capacitor voltage */ + double m_r_total; /* all input resistors in parallel */ + double m_i_fixed; /* fixed current at the input */ + double m_i_enable; /* fixed current at the input if enabled */ + double m_temp1; /* Multi purpose */ + double m_temp2; /* Multi purpose */ + double m_temp3; /* Multi purpose */ + double m_is_linear_charge; + double m_charge_rc[2]; + double m_charge_exp[2]; + double m_charge_v[2]; ); -DISCRETE_CLASS_STEP_RESETA(dss_schmitt_osc, 1, - double m_ration_in; /* ratio of total charging voltage that comes from the input */ - double m_ratio_feedback; /* ratio of total charging voltage that comes from the feedback */ - double m_v_cap; /* current capacitor voltage */ - double m_rc; /* r*c */ - double m_exponent; - int m_state; /* state of the output */ - int m_enable_type; - UINT8 m_input_is_voltage; +DISCRETE_CLASS_STEP_RESET(dss_schmitt_osc, 1, + double m_ration_in; /* ratio of total charging voltage that comes from the input */ + double m_ratio_feedback; /* ratio of total charging voltage that comes from the feedback */ + double m_v_cap; /* current capacitor voltage */ + double m_rc; /* r*c */ + double m_exponent; + int m_state; /* state of the output */ + int m_enable_type; + UINT8 m_input_is_voltage; ); /* Not yet implemented */ -DISCRETE_CLASS_STEP_RESETA(dss_adsrenv, 1, - double m_phase; +DISCRETE_CLASS_STEP_RESET(dss_adsrenv, 1, + double m_phase; ); diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index 973c9559fe8..fa371a35d52 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -3476,15 +3476,13 @@ *************************************/ /* calculate charge exponent using discrete sample time */ -#define RC_CHARGE_EXP(rc) (1.0 - exp(-(node)->sample_time() / (rc))) -#define RC_CHARGE_EXP_CLASS(rc) (1.0 - exp(-this->sample_time() / (rc))) +#define RC_CHARGE_EXP(rc) (1.0 - exp(-this->sample_time() / (rc))) /* calculate charge exponent using given sample time */ #define RC_CHARGE_EXP_DT(rc, dt) (1.0 - exp(-(dt) / (rc))) #define RC_CHARGE_NEG_EXP_DT(rc, dt) (1.0 - exp((dt) / (rc))) /* calculate discharge exponent using discrete sample time */ -#define RC_DISCHARGE_EXP(rc) (exp(-(node)->sample_time() / (rc))) -#define RC_DISCHARGE_EXP_CLASS(rc) (exp(-this->sample_time() / (rc))) +#define RC_DISCHARGE_EXP(rc) (exp(-this->sample_time() / (rc))) /* calculate discharge exponent using given sample time */ #define RC_DISCHARGE_EXP_DT(rc, dt) (exp(-(dt) / (rc))) #define RC_DISCHARGE_NEG_EXP_DT(rc, dt) (exp((dt) / (rc))) @@ -3499,14 +3497,11 @@ #define DISCRETE_CLASS_FUNC(_class, _func) DISCRETE_CLASS_NAME(_class) :: _func -#define DISCRETE_STEP(_class) void DISCRETE_CLASS_FUNC(_class, step)(void) -#define DISCRETE_RESET(_class) void DISCRETE_CLASS_FUNC(_class, reset)(void) -#define DISCRETE_START(_class) void DISCRETE_CLASS_FUNC(_class, start)(void) -#define DISCRETE_STOP(_class) void DISCRETE_CLASS_FUNC(_class, stop)(void) -#define DISCRETE_IS_STEPPING(_class) bool DISCRETE_CLASS_FUNC(_class, is_stepping)(void) - -#define DISCRETE_DECLARE_CONTEXT(_name) struct _name##_context *context = (struct _name##_context *)this->m_context; -#define DISCRETE_DECLARE_INFO(_name) const _name *info = (const _name *)this->custom_data(); +#define DISCRETE_STEP(_class) void DISCRETE_CLASS_FUNC(_class, step)(void) +#define DISCRETE_RESET(_class) void DISCRETE_CLASS_FUNC(_class, reset)(void) +#define DISCRETE_START(_class) void DISCRETE_CLASS_FUNC(_class, start)(void) +#define DISCRETE_STOP(_class) void DISCRETE_CLASS_FUNC(_class, stop)(void) +#define DISCRETE_DECLARE_INFO(_name) const _name *info = (const _name *)this->custom_data(); #define DISCRETE_INPUT(_num) (*(this->m_input[_num])) @@ -3519,7 +3514,7 @@ #define DISCRETE_MAX_NODES 300 #define DISCRETE_MAX_INPUTS 10 #define DISCRETE_MAX_OUTPUTS 8 -#define DISCRETE_MAX_TASK_OUTPUTS 8 + #define DISCRETE_MAX_TASK_GROUPS 10 @@ -4163,8 +4158,6 @@ enum { #error "DISCRETE_MAX_OUTPUTS != 8" #endif -//#define NODE_BLOCKINDEX(_node) NODE_INDEX((_node)->block->node) - #define NODE_RELATIVE(_x, _y) (NODE(NODE_INDEX(_x) + (_y))) #define NODE_NC NODE_00 diff --git a/src/mame/audio/bzone.c b/src/mame/audio/bzone.c index f8382465e4d..072061f6ea1 100644 --- a/src/mame/audio/bzone.c +++ b/src/mame/audio/bzone.c @@ -229,7 +229,7 @@ static const discrete_mixer_desc bzone_final_mixer_desc = #define CD4066_R_ON 270 -DISCRETE_CLASS_STEP_RESETA(bzone_custom_filter, 1, +DISCRETE_CLASS_STEP_RESET(bzone_custom_filter, 1, double m_v_in1_gain; double m_v_p; double m_exponent; @@ -259,7 +259,7 @@ DISCRETE_RESET(bzone_custom_filter) m_gain[1] = BZONE_CUSTOM_FILTER__R5 / m_gain[1] + 1; m_v_in1_gain = RES_VOLTAGE_DIVIDER(BZONE_CUSTOM_FILTER__R3, BZONE_CUSTOM_FILTER__R4); m_v_p = BZONE_CUSTOM_FILTER__VP - OP_AMP_VP_RAIL_OFFSET; - m_exponent = RC_CHARGE_EXP_CLASS(BZONE_CUSTOM_FILTER__R5 * BZONE_CUSTOM_FILTER__C);; + m_exponent = RC_CHARGE_EXP(BZONE_CUSTOM_FILTER__R5 * BZONE_CUSTOM_FILTER__C);; this->output[0] = 0; } diff --git a/src/mame/audio/copsnrob.c b/src/mame/audio/copsnrob.c index 0302df725b2..bd0458e1cbc 100644 --- a/src/mame/audio/copsnrob.c +++ b/src/mame/audio/copsnrob.c @@ -265,7 +265,7 @@ static const discrete_555_cc_desc copsnrob_motor01_555cc = ************************************************/ #define COPSNROB_CUSTOM_NOISE__FREQ DISCRETE_INPUT(0) -DISCRETE_CLASS_STEP_RESETA(copsnrob_custom_noise, 2, +DISCRETE_CLASS_STEP_RESET(copsnrob_custom_noise, 2, int m_flip_flop; int m_noise1_had_xtime; int m_noise2_had_xtime; @@ -371,7 +371,7 @@ DISCRETE_RESET(copsnrob_custom_noise) #define COPSNROB_CUSTOM_ZINGS_555_MONOSTABLE__R DISCRETE_INPUT(1) #define COPSNROB_CUSTOM_ZINGS_555_MONOSTABLE__C DISCRETE_INPUT(2) -DISCRETE_CLASS_STEP_RESETA(copsnrob_zings_555_monostable, 1, +DISCRETE_CLASS_STEP_RESET(copsnrob_zings_555_monostable, 1, double m_rc; double m_exponent; double m_v_cap; @@ -445,7 +445,7 @@ DISCRETE_STEP(copsnrob_zings_555_monostable) DISCRETE_RESET(copsnrob_zings_555_monostable) { m_rc = COPSNROB_CUSTOM_ZINGS_555_MONOSTABLE__R * COPSNROB_CUSTOM_ZINGS_555_MONOSTABLE__C; - m_exponent = RC_CHARGE_EXP_CLASS(m_rc); + m_exponent = RC_CHARGE_EXP(m_rc); m_v_cap = 0; m_flip_flop = 0; this->output[0] = 0; @@ -468,7 +468,7 @@ DISCRETE_RESET(copsnrob_zings_555_monostable) #define COPSNROB_CUSTOM_ZINGS_555_ASTABLE__HIGH 4.5 -DISCRETE_CLASS_STEP_RESETA(copsnrob_zings_555_astable, 1, +DISCRETE_CLASS_STEP_RESET(copsnrob_zings_555_astable, 1, double m_r2c2; double m_r_total_cv; double m_exponent1; @@ -574,8 +574,8 @@ DISCRETE_RESET(copsnrob_zings_555_astable) { m_r_total_cv = RES_3_PARALLEL(COPSNROB_CUSTOM_ZINGS_555_ASTABLE__R1, RES_K(10), RES_K(5)); m_r2c2 = COPSNROB_CUSTOM_ZINGS_555_ASTABLE__R2 * COPSNROB_CUSTOM_ZINGS_555_ASTABLE__C2; - m_exponent1 = RC_CHARGE_EXP_CLASS(COPSNROB_CUSTOM_ZINGS_555_ASTABLE__R1 * COPSNROB_CUSTOM_ZINGS_555_ASTABLE__C1); - m_exponent2 = RC_CHARGE_EXP_CLASS(m_r2c2); + m_exponent1 = RC_CHARGE_EXP(COPSNROB_CUSTOM_ZINGS_555_ASTABLE__R1 * COPSNROB_CUSTOM_ZINGS_555_ASTABLE__C1); + m_exponent2 = RC_CHARGE_EXP(m_r2c2); m_v_cap1 = 0; m_flip_flop = 0; this->output[0] = 0; /* charge on C2 */ diff --git a/src/mame/audio/dkong.c b/src/mame/audio/dkong.c index 92cb08540c0..dcdba71433b 100644 --- a/src/mame/audio/dkong.c +++ b/src/mame/audio/dkong.c @@ -294,7 +294,7 @@ static const discrete_op_amp_filt_info dkong_sallen_key_info = #define DKONG_CUSTOM_C DISCRETE_INPUT(6) #define DKONG_CUSTOM_V DISCRETE_INPUT(7) -DISCRETE_CLASS_STEP_RESETA(dkong_custom_mixer, 1, +DISCRETE_CLASS_STEP_RESET(dkong_custom_mixer, 1, double m_i_in1[2]; double m_r_in[2]; double m_r_total[2]; @@ -331,8 +331,8 @@ DISCRETE_RESET( dkong_custom_mixer ) m_r_total[0] = RES_2_PARALLEL(m_r_in[0] + DKONG_CUSTOM_R4, NE555_CV_R); m_r_total[1] = RES_2_PARALLEL((m_r_in[1] + DKONG_CUSTOM_R4), NE555_CV_R); /* precalculate charging exponents */ - m_exp[0] = RC_CHARGE_EXP_CLASS(m_r_total[0] * DKONG_CUSTOM_C); - m_exp[1] = RC_CHARGE_EXP_CLASS(m_r_total[1] * DKONG_CUSTOM_C); + m_exp[0] = RC_CHARGE_EXP(m_r_total[0] * DKONG_CUSTOM_C); + m_exp[1] = RC_CHARGE_EXP(m_r_total[1] * DKONG_CUSTOM_C); this->output[0] = 0; } diff --git a/src/mame/audio/skyraid.c b/src/mame/audio/skyraid.c index a2466dc8770..f72a8e8555e 100644 --- a/src/mame/audio/skyraid.c +++ b/src/mame/audio/skyraid.c @@ -141,7 +141,7 @@ static const discrete_mixer_desc skyraid_mixer = #define SKYRAID_MISSLE_CUSTOM_R3 DISCRETE_INPUT(3) #define SKYRAID_MISSLE_CUSTOM_C DISCRETE_INPUT(4) -DISCRETE_CLASS_STEP_RESETA(skyraid_missle_custom_charge, 2, +DISCRETE_CLASS_STEP_RESET(skyraid_missle_custom_charge, 2, double m_v_charge[2]; double m_v_cap; double m_exp[2]; @@ -172,9 +172,9 @@ DISCRETE_RESET( skyraid_missle_custom_charge ) /* precalculate charging exponents */ /* discharge cap */ - m_exp[0] = RC_CHARGE_EXP_CLASS(SKYRAID_MISSLE_CUSTOM_R2 * SKYRAID_MISSLE_CUSTOM_C); + m_exp[0] = RC_CHARGE_EXP(SKYRAID_MISSLE_CUSTOM_R2 * SKYRAID_MISSLE_CUSTOM_C); /* charge cap */ - m_exp[1] = RC_CHARGE_EXP_CLASS(RES_2_PARALLEL(SKYRAID_MISSLE_CUSTOM_R1 + SKYRAID_MISSLE_CUSTOM_R2, SKYRAID_MISSLE_CUSTOM_R3) * SKYRAID_MISSLE_CUSTOM_C); + m_exp[1] = RC_CHARGE_EXP(RES_2_PARALLEL(SKYRAID_MISSLE_CUSTOM_R1 + SKYRAID_MISSLE_CUSTOM_R2, SKYRAID_MISSLE_CUSTOM_R3) * SKYRAID_MISSLE_CUSTOM_C); /* starts at full voltage until cap starts charging */ this->output[0] = SKYRAID_MISSLE_CHARGE_PLUS;