-util/corealloc.h: Reduced make_unique_clear to a single variant for POD arrays.

* Enabled GCC lifetime dead store elimination optimisation.
* emu/device.h: Don't pre-clear memory for drivers.  Ivan Vangelista
  fixed at least the majority of things that crashed outright, and
  Robbbert initialised variables that coverity complained about.  It's
  unlikely anything will break due to this.
* sound/discrete.h: Explicitly initialise members of discrete "devices"
  to zero.  I don't see a way around doing this in headers due to the
  macro soup used to build the constructors.
* sound/mos6581.cpp: Moved creation of the SID core to device_start and
  explictly initialised members of the SID core structures.  These
  structures are in internal headers, so they won't cause downstream
  recompiles.

-Lua engine: Made I/O port manager type_seq a bit more tolerant of
 omitted arguments.
This commit is contained in:
Vas Crabb 2022-04-03 02:53:19 +10:00
parent 5255f96203
commit c4f9ff9790
22 changed files with 559 additions and 558 deletions

View File

@ -92,7 +92,6 @@ function addprojectflags()
if _OPTIONS["gcc"]~=nil and string.find(_OPTIONS["gcc"], "gcc") then
buildoptions_cpp {
"-Wsuggest-override",
"-flifetime-dse=1",
}
end
end

View File

@ -25,7 +25,7 @@
#define DISCRETE_CLASS_NAME(_name) discrete_ ## _name ## _node
#define DISCRETE_CLASS_INPUT(_name, _num) inline double _name (void) { return *(m_input[_num]); }
#define DISCRETE_CLASS_INPUT(_name, _num) inline double _name() { return *(m_input[_num]); }
#define DISCRETE_CLASS_CONSTRUCTOR(_name, _base) \
public: \
@ -34,7 +34,7 @@
#define DISCRETE_CLASS_DESTRUCTOR(_name) \
public: \
virtual ~ DISCRETE_CLASS_NAME(_name)(void) { }
virtual ~ DISCRETE_CLASS_NAME(_name)() { }
#define DISCRETE_CLASS_STEP_RESET(_name, _maxout, _priv) \
class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_step_interface \
@ -42,9 +42,9 @@ class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_ste
DISCRETE_CLASS_CONSTRUCTOR(_name, base) \
DISCRETE_CLASS_DESTRUCTOR(_name) \
public: \
virtual void step(void) override; \
virtual void reset(void) override; \
virtual int max_output(void) override { return _maxout; } \
virtual void step() override; \
virtual void reset() override; \
virtual int max_output() override { return _maxout; } \
private: \
_priv \
}
@ -55,34 +55,34 @@ class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_ste
DISCRETE_CLASS_CONSTRUCTOR(_name, base) \
DISCRETE_CLASS_DESTRUCTOR(_name) \
public: \
virtual void step(void) override; \
virtual void reset(void) override { this->step(); } \
virtual int max_output(void) override { return _maxout; } \
virtual void step() override; \
virtual void reset() override { this->step(); } \
virtual int max_output() override { return _maxout; } \
private: \
_priv \
}
#define DISCRETE_CLASS_RESET(_name, _maxout) \
#define DISCRETE_CLASS_RESET(_name, _maxout) \
class DISCRETE_CLASS_NAME(_name): public discrete_base_node \
{ \
DISCRETE_CLASS_CONSTRUCTOR(_name, base) \
DISCRETE_CLASS_DESTRUCTOR(_name) \
public: \
virtual void reset(void) override; \
virtual int max_output(void) override { return _maxout; } \
virtual void reset() override; \
virtual int max_output() override { return _maxout; } \
}
#define DISCRETE_CLASS(_name, _maxout, _priv) \
#define DISCRETE_CLASS(_name, _maxout, _priv) \
class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_step_interface \
{ \
DISCRETE_CLASS_DESTRUCTOR(_name) \
DISCRETE_CLASS_CONSTRUCTOR(_name, base) \
public: \
virtual void step(void) override; \
virtual void reset(void) override; \
virtual void start(void) override; \
virtual void stop(void) override; \
virtual int max_output(void) override { return _maxout; } \
virtual void step() override; \
virtual void reset() override; \
virtual void start() override; \
virtual void stop() override; \
virtual int max_output() override { return _maxout; } \
private: \
_priv \
}
@ -92,7 +92,7 @@ class DISCRETE_CLASS_NAME(special): public discrete_base_node
DISCRETE_CLASS_CONSTRUCTOR(special, base)
DISCRETE_CLASS_DESTRUCTOR(special)
public:
virtual int max_output(void) override { return 0; }
virtual int max_output() override { return 0; }
};
class DISCRETE_CLASS_NAME(unimplemented): public discrete_base_node
@ -100,7 +100,7 @@ class DISCRETE_CLASS_NAME(unimplemented): public discrete_base_node
DISCRETE_CLASS_CONSTRUCTOR(unimplemented, base)
DISCRETE_CLASS_DESTRUCTOR(unimplemented)
public:
virtual int max_output(void) override { return 0; }
virtual int max_output() override { return 0; }
};
/*************************************
@ -116,22 +116,22 @@ class DISCRETE_CLASS_NAME(dso_output): public discrete_base_node,
DISCRETE_CLASS_CONSTRUCTOR(dso_output, base)
DISCRETE_CLASS_DESTRUCTOR(dso_output)
public:
virtual void step(void) override {
virtual void step() override {
/* Add gain to the output and put into the buffers */
/* Clipping will be handled by the main sound system */
double val = DISCRETE_INPUT(0) * DISCRETE_INPUT(1);
m_outview->put(m_outview_sample++, val * (1.0 / 32768.0));
}
virtual int max_output(void) override { return 0; }
virtual int max_output() override { return 0; }
virtual void set_output_ptr(write_stream_view &view) override { m_outview = &view; m_outview_sample = 0; }
private:
write_stream_view *m_outview;
u32 m_outview_sample;
write_stream_view *m_outview = nullptr;
u32 m_outview_sample = 0U;
};
DISCRETE_CLASS(dso_csvlog, 0,
FILE *m_csv_file;
int64_t m_sample_num;
FILE *m_csv_file = nullptr;
int64_t m_sample_num = 0;
char m_name[32];
);
@ -151,15 +151,15 @@ class DISCRETE_CLASS_NAME(dss_adjustment): public discrete_base_node, public dis
DISCRETE_CLASS_CONSTRUCTOR(dss_adjustment, base)
DISCRETE_CLASS_DESTRUCTOR(dss_adjustment)
public:
virtual void step(void) override;
virtual void reset(void) override;
virtual void step() override;
virtual void reset() override;
private:
ioport_port *m_port;
int32_t m_lastpval;
int32_t m_pmin;
double m_pscale;
double m_min;
double m_scale;
ioport_port *m_port = 0;
int32_t m_lastpval = 0;
int32_t m_pmin = 0;
double m_pscale = 0.0;
double m_min = 0.0;
double m_scale = 0.0;
};
DISCRETE_CLASS_RESET(dss_constant, 1);
@ -169,12 +169,12 @@ class DISCRETE_CLASS_NAME(dss_input_data): public discrete_base_node, public dis
DISCRETE_CLASS_DESTRUCTOR(dss_input_data)
DISCRETE_CLASS_CONSTRUCTOR(dss_input_data, base)
public:
virtual void reset(void) override;
virtual void reset() override;
virtual void input_write(int sub_node, uint8_t data ) override;
private:
double m_gain; /* node gain */
double m_offset; /* node offset */
uint8_t m_data; /* data written */
double m_gain = 0.0; /* node gain */
double m_offset = 0.0; /* node offset */
uint8_t m_data = 0; /* data written */
};
class DISCRETE_CLASS_NAME(dss_input_logic): public discrete_base_node, public discrete_input_interface
@ -182,12 +182,12 @@ class DISCRETE_CLASS_NAME(dss_input_logic): public discrete_base_node, public di
DISCRETE_CLASS_CONSTRUCTOR(dss_input_logic, base)
DISCRETE_CLASS_DESTRUCTOR(dss_input_logic)
public:
virtual void reset(void) override;
virtual void reset() override;
virtual void input_write(int sub_node, uint8_t data ) override;
private:
double m_gain; /* node gain */
double m_offset; /* node offset */
uint8_t m_data; /* data written */
double m_gain = 0.0; /* node gain */
double m_offset = 0.0; /* node offset */
uint8_t m_data = 0; /* data written */
};
class DISCRETE_CLASS_NAME(dss_input_not): public discrete_base_node, public discrete_input_interface
@ -195,12 +195,12 @@ class DISCRETE_CLASS_NAME(dss_input_not): public discrete_base_node, public disc
DISCRETE_CLASS_CONSTRUCTOR(dss_input_not, base)
DISCRETE_CLASS_DESTRUCTOR(dss_input_not)
public:
virtual void reset(void) override;
virtual void reset() override;
virtual void input_write(int sub_node, uint8_t data ) override;
private:
double m_gain; /* node gain */
double m_offset; /* node offset */
uint8_t m_data; /* data written */
double m_gain = 0.0; /* node gain */
double m_offset = 0.0; /* node offset */
uint8_t m_data = 0; /* data written */
};
class DISCRETE_CLASS_NAME(dss_input_pulse): public discrete_base_node, public discrete_input_interface, public discrete_step_interface
@ -208,13 +208,13 @@ class DISCRETE_CLASS_NAME(dss_input_pulse): public discrete_base_node, public di
DISCRETE_CLASS_CONSTRUCTOR(dss_input_pulse, base)
DISCRETE_CLASS_DESTRUCTOR(dss_input_pulse)
public:
virtual void step(void) override;
virtual void reset(void) override;
virtual void step() override;
virtual void reset() override;
virtual void input_write(int sub_node, uint8_t data ) override;
private:
//double m_gain; /* node gain */
//double m_offset; /* node offset */
uint8_t m_data; /* data written */
//double m_gain = 0.0; /* node gain */
//double m_offset = 0.0; /* node offset */
uint8_t m_data = 0; /* data written */
};
class DISCRETE_CLASS_NAME(dss_input_stream): public discrete_base_node, public discrete_input_interface, public discrete_step_interface
@ -222,28 +222,28 @@ class DISCRETE_CLASS_NAME(dss_input_stream): public discrete_base_node, public d
DISCRETE_CLASS_CONSTRUCTOR(dss_input_stream, base)
DISCRETE_CLASS_DESTRUCTOR(dss_input_stream)
public:
virtual void step(void) override;
virtual void reset(void) override;
virtual void start(void) override;
virtual void step() override;
virtual void reset() override;
virtual void start() override;
virtual void input_write(int sub_node, uint8_t data ) override;
virtual bool is_buffered(void) { return false; }
virtual bool is_buffered() { return false; }
/* This is called by discrete_sound_device */
void stream_start(void);
void stream_start();
//protected:
uint32_t m_stream_in_number;
read_stream_view const *m_inview; /* current in ptr for stream */
uint32_t m_inview_sample;
uint32_t m_stream_in_number = 0;
read_stream_view const *m_inview = nullptr; /* current in ptr for stream */
uint32_t m_inview_sample = 0;
private:
void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs);
double m_gain; /* node gain */
double m_offset; /* node offset */
uint8_t m_data; /* data written */
uint8_t m_is_buffered;
double m_gain = 0.0; /* node gain */
double m_offset = 0.0; /* node offset */
uint8_t m_data = 0; /* data written */
uint8_t m_is_buffered = 0;
/* the buffer stream */
sound_stream *m_buffer_stream;
sound_stream *m_buffer_stream = nullptr;
};
class DISCRETE_CLASS_NAME(dss_input_buffer): public DISCRETE_CLASS_NAME(dss_input_stream)
@ -251,7 +251,7 @@ class DISCRETE_CLASS_NAME(dss_input_buffer): public DISCRETE_CLASS_NAME(dss_inpu
DISCRETE_CLASS_CONSTRUCTOR(dss_input_buffer, dss_input_stream)
DISCRETE_CLASS_DESTRUCTOR(dss_input_buffer)
public:
virtual bool is_buffered(void) override { return true; }
virtual bool is_buffered() override { return true; }
};
#include "disc_wav.h"

View File

@ -63,13 +63,13 @@ DISCRETE_STEP(dsd_555_astbl)
int count_f = 0;
int count_r = 0;
double dt; /* change in time */
double x_time = 0; /* time since change happened */
double dt; /* change in time */
double x_time = 0; /* time since change happened */
double v_cap = m_cap_voltage; /* Current voltage on capacitor, before dt */
double v_cap_next = 0; /* Voltage on capacitor, after dt */
double v_cap_next = 0; /* Voltage on capacitor, after dt */
double v_charge, exponent = 0;
uint8_t flip_flop = m_flip_flop;
uint8_t update_exponent = 0;
uint8_t flip_flop = m_flip_flop;
uint8_t update_exponent = 0;
double v_out = 0.0;
/* put commonly used stuff in local variables for speed */

View File

@ -25,155 +25,155 @@
struct discrete_filter_coeff
{
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 */
double a1, a2; /* digital filter coefficients, denominator */
double b0, b1, b2; /* digital filter coefficients, numerator */
double x1 = 0.0, x2 = 0.0; /* x[k-1], x[k-2], previous 2 input values */
double y1 = 0.0, y2 = 0.0; /* y[k-1], y[k-2], previous 2 output values */
double a1 = 0.0, a2 = 0.0; /* digital filter coefficients, denominator */
double b0 = 0.0, b1 = 0.0, b2 = 0.0; /* digital filter coefficients, numerator */
};
DISCRETE_CLASS_STEP_RESET(dst_filter1, 1,
/* uses x1, y1, a1, b0, b1 */
struct discrete_filter_coeff m_fc;
discrete_filter_coeff m_fc;
);
DISCRETE_CLASS_STEP_RESET(dst_filter2, 1,
struct discrete_filter_coeff m_fc;
discrete_filter_coeff m_fc;
);
DISCRETE_CLASS_STEP_RESET(dst_sallen_key, 1,
struct discrete_filter_coeff m_fc;
discrete_filter_coeff m_fc;
);
DISCRETE_CLASS_STEP_RESET(dst_crfilter, 1,
double m_vCap;
double m_rc;
double m_exponent;
uint8_t m_has_rc_nodes;
//uint8_t m_is_fast;
double m_vCap = 0.0;
double m_rc = 0.0;
double m_exponent = 0.0;
uint8_t m_has_rc_nodes = 0;
//uint8_t m_is_fast = 0;
);
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;
int m_type = 0; /* What kind of filter */
int m_is_norton = 0; /* 1 = Norton op-amps */
double m_vRef = 0.0;
double m_vP = 0.0;
double m_vN = 0.0;
double m_rTotal = 0.0; /* All input resistance in parallel. */
double m_iFixed = 0.0; /* Current supplied by r3 & r4 if used. */
double m_exponentC1 = 0.0;
double m_exponentC2 = 0.0;
double m_exponentC3 = 0.0;
double m_rRatio = 0.0; /* divide ratio of resistance network */
double m_vC1 = 0.0; /* Charge on C1 */
double m_vC1b = 0.0; /* Charge on C1, part of C1 charge if needed */
double m_vC2 = 0.0; /* Charge on C2 */
double m_vC3 = 0.0; /* Charge on C2 */
double m_gain = 0.0; /* Gain of the filter */
discrete_filter_coeff m_fc;
);
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;
double m_v_cap = 0.0;
double m_v_charge_1_2 = 0.0;
double m_v_drop = 0.0;
double m_exp_1 = 0.0;
double m_exp_1_2 = 0.0;
double m_exp_2 = 0.0;
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc, 1,
int m_state;
double m_t; /* time */
double m_exponent0;
int m_state = 0;
double m_t = 0.0; /* time */
double m_exponent0 = 0.0;
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc2, 1,
int m_state;
double m_v_out;
double m_t; /* time */
double m_exponent0;
double m_exponent1;
int m_state = 0;
double m_v_out = 0.0;
double m_t = 0.0; /* time */
double m_exponent0 = 0.0;
double m_exponent1 = 0.0;
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc3, 1,
int m_state;
double m_v_out;
double m_t; /* time */
double m_exponent0;
double m_exponent1;
double m_v_diode; /* rcdisc3 */
int m_state = 0;
double m_v_out = 0.0;
double m_t = 0.0; /* time */
double m_exponent0 = 0.0;
double m_exponent1 = 0.0;
double m_v_diode = 0.0; /* rcdisc3 */
);
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];
int m_type = 0;
double m_max_out = 0.0;
double m_vC1 = 0.0;
double m_v[2]{ 0.0 };
double m_exp[2]{ 0.0 };
);
DISCRETE_CLASS_STEP_RESET(dst_rcdisc5, 1,
int m_state;
double m_t; /* time */
double m_exponent0;
double m_v_cap; /* rcdisc5 */
int m_state = 0;
double m_t = 0.0; /* time */
double m_exponent0 = 0.0;
double m_v_cap = 0.0; /* rcdisc5 */
);
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;
double m_EM_IC_0_7;
int m_type = 0;
double m_gain_r1_r2 = 0.0;
double m_f = 0.0; /* r2,r3 gain */
double m_vCap = 0.0;
double m_vCE = 0.0;
double m_exponent0 = 0.0;
double m_exponent1 = 0.0;
double m_exp_exponent0 = 0.0;
double m_exp_exponent1 = 0.0;
double m_c_exp0 = 0.0;
double m_c_exp1 = 0.0;
double m_EM_IC_0_7 = 0.0;
);
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];
double m_v_cap = 0.0;
double m_exp_low[2]{ 0.0 };
double m_exp_high[4]{ 0.0 };
double m_gain[2]{ 0.0 };
double m_vd_gain[4]{ 0.0 };
);
DISCRETE_CLASS_STEP_RESET(dst_rcfilter, 1,
double m_v_out;
double m_vCap;
double m_rc;
double m_exponent;
uint8_t m_has_rc_nodes;
uint8_t m_is_fast;
double m_v_out = 0.0;
double m_vCap = 0.0;
double m_rc = 0.0;
double m_exponent = 0.0;
uint8_t m_has_rc_nodes = 0;
uint8_t m_is_fast = 0;
);
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];
double m_vCap[4]{ 0.0 };
double m_exp[4]{ 0.0 };
double m_exp0 = 0.0; /* fast case bit 0 */
double m_exp1 = 0.0; /* fast case bit 1 */
double m_factor = 0.0; /* fast case */
double m_f1[16]{ 0.0 };
double m_f2[16]{ 0.0 };
);
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 */
double m_x1 = 0.0; /* x[k-1], previous input value */
double m_y1 = 0.0; /* y[k-1], previous output value */
double m_a1 = 0.0; /* digital filter coefficients, denominator */
//double m_b[2]{ 0.0 }; /* digital filter coefficients, numerator */
);
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;
discrete_filter_coeff m_fc0;
discrete_filter_coeff m_fc1;
double m_x1 = 0.0;
double m_y1 = 0.0;
);

View File

@ -34,11 +34,11 @@ DISCRETE_CLASS_STEP(dst_gain, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_inv, 1, /* no context */ );
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;
int m_count = 0;
int m_decode_x_time = 0;
int m_from = 0;
int m_last_val = 0;
int m_last_had_x_time = 0;
);
DISCRETE_CLASS_STEP(dst_logic_and, 1, /* no context */ );
@ -54,47 +54,47 @@ DISCRETE_CLASS_STEP(dst_logic_xor, 1, /* no context */ );
DISCRETE_CLASS_STEP(dst_logic_nxor, 1, /* no context */ );
DISCRETE_CLASS_STEP_RESET(dst_logic_dff, 1,
int m_last_clk;
int m_last_clk = 0;
);
DISCRETE_CLASS_STEP_RESET(dst_logic_jkff, 1,
double m_v_out;
int m_last_clk;
double m_v_out = 0;
int m_last_clk = 0;
);
DISCRETE_CLASS_STEP_RESET(dst_logic_shift, 1,
double m_t_left; /* time unused during last sample in seconds */
uint32_t m_shift_data;
uint32_t m_bit_mask;
uint8_t m_clock_type;
uint8_t m_reset_on_high;
uint8_t m_shift_r;
uint8_t m_last;
double m_t_left = 0.0; /* time unused during last sample in seconds */
uint32_t m_shift_data = 0;
uint32_t m_bit_mask = 0;
uint8_t m_clock_type = 0;
uint8_t m_reset_on_high = 0;
uint8_t m_shift_r = 0;
uint8_t m_last = 0;
);
DISCRETE_CLASS_STEP(dst_lookup_table, 1, /* no context */ );
DISCRETE_CLASS_STEP_RESET(dst_multiplex, 1,
int m_size;
int m_size = 0;
);
DISCRETE_CLASS_STEP_RESET(dst_oneshot, 1,
double m_countdown;
int m_state;
int m_last_trig;
int m_type;
double m_countdown = 0.0;
int m_state = 0;
int m_last_trig = 0;
int m_type = 0;
);
DISCRETE_CLASS_STEP_RESET(dst_ramp, 1,
double m_v_out;
double m_step;
int m_dir; /* 1 if End is higher then Start */
int m_last_en; /* Keep track of the last enable value */
double m_v_out = 0.0;
double m_step = 0.0;
int m_dir = 0; /* 1 if End is higher then Start */
int m_last_en = 0; /* Keep track of the last enable value */
);
DISCRETE_CLASS_STEP_RESET(dst_samphold, 1,
double m_last_input;
int m_clocktype;
double m_last_input = 0.0;
int m_clocktype = 0;
);
DISCRETE_CLASS_STEP(dst_switch, 1, /* no context */ );
@ -129,102 +129,102 @@ public:
TOK_OR, /* Bitwise OR */
TOK_XOR /* Bitwise XOR */
};
void step(void) override;
void reset(void) override;
void step() override;
void reset() override;
private:
DISCRETE_CLASS_INPUT(I_IN0, 0);
DISCRETE_CLASS_INPUT(I_IN1, 1);
DISCRETE_CLASS_INPUT(I_IN2, 2);
DISCRETE_CLASS_INPUT(I_IN3, 3);
DISCRETE_CLASS_INPUT(I_IN4, 4);
enum token precomp[32];
enum token precomp[32]{ TOK_END };
};
/* Component specific */
DISCRETE_CLASS_STEP_RESET(dst_comp_adder, 1,
double m_total[256];
double m_total[256]{ 0.0 };
);
DISCRETE_CLASS_STEP_RESET(dst_dac_r1, 1,
double m_v_out;
double m_exponent;
double m_last_v;
double m_v_step[256];
int m_has_c_filter;
double m_v_out = 0.0;
double m_exponent = 0.0;
double m_last_v = 0.0;
double m_v_step[256]{ 0.0 };
int m_has_c_filter = 0;
);
DISCRETE_CLASS_STEP_RESET(dst_diode_mix, 1,
int m_size;
double m_v_junction[8];
int m_size = 0;
double m_v_junction[8]{ 0.0 };
);
DISCRETE_CLASS_STEP_RESET(dst_integrate, 1,
double m_v_out;
double m_change;
double m_v_max_in; /* v1 - norton VBE */
double m_v_max_in_d; /* v1 - norton VBE - diode drop */
double m_v_max_out;
double m_v_out = 0.0;
double m_change = 0.0;
double m_v_max_in = 0.0; /* v1 - norton VBE */
double m_v_max_in_d = 0.0; /* v1 - norton VBE - diode drop */
double m_v_max_out = 0.0;
);
#define DISC_MIXER_MAX_INPS 8
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 nullptr */
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 */
int m_type = 0;
int m_size = 0;
int m_r_node_bit_flag = 0;
int m_c_bit_flag = 0;
double m_r_total = 0.0;
const double * m_r_node[DISC_MIXER_MAX_INPS]{ nullptr }; /* Either pointer to resistance node output OR nullptr */
double m_r_last[DISC_MIXER_MAX_INPS]{ 0.0 };
double m_exponent_rc[DISC_MIXER_MAX_INPS]{ 0.0 }; /* For high pass filtering cause by cIn */
double m_v_cap[DISC_MIXER_MAX_INPS]{ 0.0 }; /* cap voltage of each input */
double m_exponent_c_f = 0.0; /* Low pass on mixed inputs */
double m_exponent_c_amp = 0.0; /* Final high pass caused by out cap and amp input impedance */
double m_v_cap_f = 0.0; /* cap voltage of cF */
double m_v_cap_amp = 0.0; /* cap voltage of cAmp */
double m_gain = 0.0; /* used for DISC_MIXER_IS_OP_AMP_WITH_RI */
);
DISCRETE_CLASS_STEP_RESET(dst_op_amp, 1,
uint8_t m_has_cap;
uint8_t m_has_r1;
uint8_t m_has_r4;
double m_v_max;
double m_i_fixed;
double m_v_cap;
double m_exponent;
uint8_t m_has_cap = 0;
uint8_t m_has_r1 = 0;
uint8_t m_has_r4 = 0;
double m_v_max = 0.0;
double m_i_fixed = 0.0;
double m_v_cap = 0.0;
double m_exponent = 0.0;
);
DISCRETE_CLASS_STEP_RESET(dst_op_amp_1sht, 1,
double m_v_out;
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;
double m_v_out = 0.0;
double m_i_fixed = 0.0;
double m_v_max = 0.0;
double m_r34ratio = 0.0;
double m_v_cap1 = 0.0;
double m_v_cap2 = 0.0;
double m_exponent1c = 0.0;
double m_exponent1d = 0.0;
double m_exponent2 = 0.0;
);
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_t m_has_c4;
uint8_t m_has_r4;
double m_v_out_max = 0.0; /* Maximum output voltage */
double m_v_trig[2]{ 0.0 }; /* Voltage used to charge cap1 based on function F3 */
double m_v_trig2 = 0.0; /* Voltage used to charge cap2 */
double m_v_trig3 = 0.0; /* Voltage used to charge cap3 */
double m_i_fixed = 0.0; /* Fixed current going into - input */
double m_exponent_c[2]{ 0.0 }; /* Charge exponents based on function F3 */
double m_exponent_d[2]{ 0.0 }; /* Discharge exponents based on function F3 */
double m_exponent2[2]{ 0.0 }; /* Discharge/charge exponents based on function F4 */
double m_exponent3[2]{ 0.0 }; /* Discharge/charge exponents based on function F5 */
double m_exponent4 = 0.0; /* Discharge/charge exponents for c4 */
double m_v_cap1 = 0.0; /* charge on cap c1 */
double m_v_cap2 = 0.0; /* charge on cap c2 */
double m_v_cap3 = 0.0; /* charge on cap c3 */
double m_v_cap4 = 0.0; /* charge on cap c4 */
double m_r67 = 0.0; /* = r6 + r7 (for easy use later) */
uint8_t m_has_c4 = 0;
uint8_t m_has_r4 = 0;
);
DISCRETE_CLASS_STEP(dst_xtime_buffer, 1, /* no context */ );

View File

@ -24,75 +24,75 @@
#include "discrete.h"
DISCRETE_CLASS_STEP_RESET(dss_counter, 1,
int m_clock_type;
int m_out_type;
int m_is_7492;
int m_last_clock;
uint32_t m_last_count;
//uint32_t m_last; /* Last clock state */
uint32_t m_min;
uint32_t m_max;
uint32_t m_diff;
double m_t_left; /* time unused during last sample in seconds */
int m_clock_type = 0;
int m_out_type = 0;
int m_is_7492 = 0;
int m_last_clock = 0;
uint32_t m_last_count = 0;
//uint32_t m_last = 0; /* Last clock state */
uint32_t m_min = 0;
uint32_t m_max = 0;
uint32_t m_diff = 0;
double m_t_left = 0.0; /* time unused during last sample in seconds */
);
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 */
//double m_sample_step;
//double m_t;
uint8_t m_reset_on_high;
uint8_t m_invert_output;
uint8_t m_out_is_f0;
uint8_t m_out_lfsr_reg;
unsigned int m_lfsr_reg = 0;
int m_last = 0; /* Last clock state */
double m_t_clock = 0.0; /* fixed counter clock in seconds */
double m_t_left = 0.0; /* time unused during last sample in seconds */
//double m_sample_step = 0.0;
//double m_t = 0.0;
uint8_t m_reset_on_high = 0;
uint8_t m_invert_output = 0;
uint8_t m_out_is_f0 = 0;
uint8_t m_out_lfsr_reg = 0;
);
DISCRETE_CLASS_STEP_RESET(dss_noise, 2,
double m_phase;
double m_phase = 0.0;
);
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 */
int m_clock_type = 0;
int m_out_type = 0;
int m_last = 0; /* Last clock state */
double m_t_clock = 0.0; /* fixed counter clock in seconds */
double m_t_left = 0.0; /* time unused during last sample in seconds */
int m_max1 = 0; /* Max 1 Count stored as int for easy use. */
int m_max2 = 0; /* Max 2 Count stored as int for easy use. */
int m_count1 = 0; /* current count1 */
int m_count2 = 0; /* current count2 */
);
DISCRETE_CLASS_STEP_RESET(dss_sawtoothwave, 1,
double m_phase;
int m_type;
double m_phase = 0.0;
int m_type = 0;
);
DISCRETE_CLASS_STEP_RESET(dss_sinewave, 1,
double m_phase;
double m_phase = 0.0;
);
DISCRETE_CLASS_STEP_RESET(dss_squarewave, 1,
double m_phase;
double m_trigger;
double m_phase = 0.0;
double m_trigger = 0.0;
);
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;
int m_flip_flop = 0;
double m_sample_step = 0.0;
double m_t_left = 0.0;
double m_t_off = 0.0;
double m_t_on = 0.0;
);
DISCRETE_CLASS_STEP_RESET(dss_squarewave2, 1,
double m_phase;
double m_trigger;
double m_phase = 0.0;
double m_trigger = 0.0;
);
DISCRETE_CLASS_STEP_RESET(dss_trianglewave, 1,
double m_phase;
double m_phase = 0.0;
);
/* Component specific modules */
@ -107,13 +107,13 @@ class DISCRETE_CLASS_NAME(dss_inverter_osc): public discrete_base_node, public d
public:
struct description
{
double vB;
double vOutLow;
double vOutHigh;
double vInFall; // voltage that triggers the gate input to go low (0V) on fall
double vInRise; // voltage that triggers the gate input to go high (vGate) on rise
double clamp; // voltage is clamped to -clamp ... vb+clamp if clamp>= 0;
int options; // bitmapped options
double vB = 0.0;
double vOutLow = 0.0;
double vOutHigh = 0.0;
double vInFall = 0.0; // voltage that triggers the gate input to go low (0V) on fall
double vInRise = 0.0; // voltage that triggers the gate input to go high (vGate) on rise
double clamp = 0.0; // voltage is clamped to -clamp ... vb+clamp if clamp>= 0;
int options = 0.0; // bitmapped options
};
enum {
IS_TYPE1 = 0x00,
@ -124,8 +124,8 @@ public:
TYPE_MASK = 0x0f,
OUT_IS_LOGIC = 0x10
};
void step(void) override;
void reset(void) override;
void step() override;
void reset() override;
protected:
inline double tftab(double x);
inline double tf(double x);
@ -137,56 +137,56 @@ private:
DISCRETE_CLASS_INPUT(I_C, 4);
DISCRETE_CLASS_INPUT(I_R2, 5);
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 = 0.0;
double mc_v_g2_old = 0.0;
double mc_w = 0.0;
double mc_wc = 0.0;
double mc_rp = 0.0;
double mc_r1 = 0.0;
double mc_r2 = 0.0;
double mc_c = 0.0;
double mc_tf_a = 0.0;
double mc_tf_b = 0.0;
double mc_tf_tab[DSS_INV_TAB_SIZE]{ 0.0 };
};
DISCRETE_CLASS_STEP_RESET(dss_op_amp_osc, 1,
const double * m_r[8]; /* pointers to resistor values */
int m_type;
uint8_t m_flip_flop; /* flip/flop output state */
uint8_t m_flip_flop_xor; /* flip_flop ^ flip_flop_xor, 0 = discharge, 1 = charge */
uint8_t m_output_type;
uint8_t 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];
const double * m_r[8]{ nullptr }; /* pointers to resistor values */
int m_type = 0;
uint8_t m_flip_flop = 0; /* flip/flop output state */
uint8_t m_flip_flop_xor = 0; /* flip_flop ^ flip_flop_xor, 0 = discharge, 1 = charge */
uint8_t m_output_type = 0;
uint8_t m_has_enable = 0;
double m_v_out_high = 0.0;
double m_threshold_low = 0.0; /* falling threshold */
double m_threshold_high = 0.0; /* rising threshold */
double m_v_cap = 0.0; /* current capacitor voltage */
double m_r_total = 0.0; /* all input resistors in parallel */
double m_i_fixed = 0.0; /* fixed current at the input */
double m_i_enable = 0.0; /* fixed current at the input if enabled */
double m_temp1 = 0.0; /* Multi purpose */
double m_temp2 = 0.0; /* Multi purpose */
double m_temp3 = 0.0; /* Multi purpose */
double m_is_linear_charge = 0.0;
double m_charge_rc[2]{ 0.0 };
double m_charge_exp[2]{ 0.0 };
double m_charge_v[2]{ 0.0 };
);
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_t m_input_is_voltage;
double m_ration_in = 0.0; /* ratio of total charging voltage that comes from the input */
double m_ratio_feedback = 0.0; /* ratio of total charging voltage that comes from the feedback */
double m_v_cap = 0.0; /* current capacitor voltage */
double m_rc = 0.0; /* r*c */
double m_exponent = 0.0;
int m_state = 0; /* state of the output */
int m_enable_type = 0;
uint8_t m_input_is_voltage = 0;
);
/* Not yet implemented */
DISCRETE_CLASS_STEP_RESET(dss_adsrenv, 1,
//double m_phase;
//double m_phase = 0.0;
);

View File

@ -7,6 +7,7 @@
#include "machine/rescap.h"
#include <memory>
#include <vector>
@ -4177,8 +4178,6 @@ class discrete_sound_output_interface;
class discrete_device : public device_t
{
//friend class discrete_base_node;
protected:
// construction/destruction
discrete_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
@ -4410,7 +4409,7 @@ class discrete_node_factory
public:
static std::unique_ptr<discrete_base_node> create(discrete_device &pdev, const discrete_block &block)
{
std::unique_ptr<discrete_base_node> r = make_unique_clear<C>();
std::unique_ptr<discrete_base_node> r = std::make_unique<C>();
r->init(&pdev, &block);
return r;

View File

@ -45,7 +45,6 @@ mos6581_device::mos6581_device(const machine_config &mconfig, device_type type,
, m_read_poty(*this)
, m_stream(nullptr)
, m_variant(variant)
, m_token(make_unique_clear<SID6581_t>())
{
}
@ -202,6 +201,7 @@ void mos6581_device::device_start()
m_stream = stream_alloc(0, 1, machine().sample_rate());
// initialize SID engine
m_token = std::make_unique<SID6581_t>();
m_token->device = this;
m_token->mixer_channel = m_stream;
m_token->PCMfreq = machine().sample_rate();

View File

@ -17,42 +17,42 @@ struct SID6581_t
{
static constexpr uint8_t max_voices = 3;
device_t *device;
sound_stream *mixer_channel; // mame stream/ mixer channel
device_t *device = nullptr;
sound_stream *mixer_channel = nullptr; // mame stream/ mixer channel
int type;
uint32_t clock;
int type = 0;
uint32_t clock = 0;
uint16_t PCMfreq; // samplerate of the current systems soundcard/DAC
uint32_t PCMsid, PCMsidNoise;
uint16_t PCMfreq = 0; // samplerate of the current systems soundcard/DAC
uint32_t PCMsid = 0, PCMsidNoise = 0;
#if 0
/* following depends on type */
ptr2sidVoidFunc ModeNormalTable[16];
ptr2sidVoidFunc ModeRingTable[16];
ptr2sidVoidFunc ModeNormalTable[16]{ nullptr };
ptr2sidVoidFunc ModeRingTable[16]{ nullptr };
// for speed reason it could be better to make them global!
uint8_t* waveform30;
uint8_t* waveform50;
uint8_t* waveform60;
uint8_t* waveform70;
uint8_t *waveform30 = nullptr;
uint8_t *waveform50 = nullptr;
uint8_t *waveform60 = nullptr;
uint8_t *waveform70 = nullptr;
#endif
int reg[0x20];
int reg[0x20]{ 0 };
// bool sidKeysOn[0x20], sidKeysOff[0x20];
// bool sidKeysOn[0x20]{ false }, sidKeysOff[0x20]{ false };
uint8_t masterVolume;
uint16_t masterVolumeAmplIndex;
uint8_t masterVolume = 0;
uint16_t masterVolumeAmplIndex = 0;
struct
{
int Enabled;
uint8_t Type, CurType;
float Dy, ResDy;
uint16_t Value;
int Enabled = 0;
uint8_t Type = 0, CurType = 0;
float Dy = 0.0, ResDy = 0.0;
uint16_t Value = 0;
} filter;
sidOperator optr[max_voices];
int optr3_outputmask;
int optr3_outputmask = 0;
void init();

View File

@ -16,81 +16,81 @@ struct sidOperator
{
struct sw_storage
{
uint16_t len;
uint16_t len = 0;
#if defined(DIRECT_FIXPOINT)
uint32_t stp;
uint32_t stp = 0;
#else
uint32_t pnt;
int16_t stp;
uint32_t pnt = 0;
int16_t stp = 0;
#endif
};
SID6581_t *sid;
uint8_t reg[7];
uint32_t SIDfreq;
uint16_t SIDpulseWidth;
uint8_t SIDctrl;
uint8_t SIDAD, SIDSR;
SID6581_t *sid = nullptr;
uint8_t reg[7]{ 0 };
uint32_t SIDfreq = 0;
uint16_t SIDpulseWidth = 0;
uint8_t SIDctrl = 0;
uint8_t SIDAD = 0, SIDSR = 0;
sidOperator* carrier;
sidOperator* modulator;
int sync;
sidOperator *carrier = nullptr;
sidOperator *modulator = nullptr;
int sync = 0;
uint16_t pulseIndex, newPulseIndex;
uint16_t curSIDfreq;
uint16_t curNoiseFreq;
uint16_t pulseIndex = 0, newPulseIndex = 0;
uint16_t curSIDfreq = 0;
uint16_t curNoiseFreq = 0;
uint8_t output;//, outputMask;
uint8_t output = 0/*, outputMask = 0*/;
char filtVoiceMask;
int filtEnabled;
float filtLow, filtRef;
int8_t filtIO;
char filtVoiceMask = 0;
int filtEnabled = 0;
float filtLow = 0, filtRef = 0;
int8_t filtIO = 0;
int32_t cycleLenCount;
int32_t cycleLenCount = 0;
#if defined(DIRECT_FIXPOINT)
PAIR cycleLen, cycleAddLen;
#else
uint32_t cycleAddLenPnt;
uint16_t cycleLen, cycleLenPnt;
uint32_t cycleAddLenPnt = 0;
uint16_t cycleLen, cycleLenPnt = 0;
#endif
int8_t (*outProc)(sidOperator *);
void (*waveProc)(sidOperator *);
int8_t (*outProc)(sidOperator *) = nullptr;
void (*waveProc)(sidOperator *) = nullptr;
#if defined(DIRECT_FIXPOINT)
PAIR waveStep, waveStepAdd;
#else
uint16_t waveStep, waveStepAdd;
uint32_t waveStepPnt, waveStepAddPnt;
uint16_t waveStep = 0, waveStepAdd = 0;
uint32_t waveStepPnt = 0, waveStepAddPnt = 0;
#endif
uint16_t waveStepOld;
uint16_t waveStepOld = 0;
sw_storage wavePre[2];
#if defined(DIRECT_FIXPOINT)
PAIR noiseReg;
#else
uint32_t noiseReg;
uint32_t noiseReg = 0;
#endif
uint32_t noiseStep, noiseStepAdd;
uint8_t noiseOutput;
int noiseIsLocked;
uint32_t noiseStep = 0, noiseStepAdd = 0;
uint8_t noiseOutput = 0;
int noiseIsLocked = 0;
uint8_t ADSRctrl;
uint8_t ADSRctrl = 0;
// int gateOnCtrl, gateOffCtrl;
uint16_t (*ADSRproc)(sidOperator *);
uint16_t (*ADSRproc)(sidOperator *) = nullptr;
#ifdef SID_FPUENVE
float fenveStep, fenveStepAdd;
uint32_t enveStep;
float fenveStep = 0.0, fenveStepAdd = 0.0;
uint32_t enveStep = 0;
#elif defined(DIRECT_FIXPOINT)
PAIR enveStep, enveStepAdd;
#else
uint16_t enveStep, enveStepAdd;
uint32_t enveStepPnt, enveStepAddPnt;
uint16_t enveStep = 0, enveStepAdd = 0;
uint32_t enveStepPnt = 0, enveStepAddPnt = 0;
#endif
uint8_t enveVol, enveSusVol;
uint16_t enveShortAttackCount;
uint8_t enveVol = 0, enveSusVol = 0;
uint16_t enveShortAttackCount = 0;
void clear();

View File

@ -210,7 +210,7 @@ private:
assert(!owner);
assert(!clock);
return make_unique_clear<DriverClass>(mconfig, type, tag);
return std::make_unique<DriverClass>(mconfig, type, tag);
}
create_func const m_creator;

View File

@ -38,7 +38,6 @@
#include "profiler.h"
// commonly-referenced utilities imported from lib/util
#include "corealloc.h"
#include "corefile.h"
#include "delegate.h"
#include "hash.h"

View File

@ -13,35 +13,38 @@
#pragma once
// standard C includes
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstdarg>
// some cleanups for Solaris for things defined in stdlib.h
#if defined(__sun__) && defined(__svr4__)
#undef si_status
#undef WWORD
#endif
// centralised forward declarations
#include "emufwd.h"
// common stuff from lib/util
#include "corealloc.h"
#include "coretmpl.h"
#include "bitmap.h"
#include "endianness.h"
#include "strformat.h"
#include "vecstream.h"
// common stuff from osd
#include "osdcomm.h"
// standard C++ includes
#include <exception>
#include <string>
#include <type_traits>
#include <typeinfo>
// core system includes
#include "osdcomm.h"
#include "coretmpl.h"
#include "bitmap.h"
#include "endianness.h"
#include "strformat.h"
#include "vecstream.h"
#include "emufwd.h"
// standard C includes
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//**************************************************************************
@ -421,4 +424,11 @@ inline u64 d2u(double d)
return u.vv;
}
//**************************************************************************
// USEFUL UTILITIES
//**************************************************************************
using util::make_unique_clear;
#endif // MAME_EMU_EMUCORE_H

View File

@ -160,10 +160,20 @@ void lua_engine::initialize_input(sol::table &emu)
input_seq_type seq_type = seq_type_string ? s_seq_type_parser(*seq_type_string) : SEQ_TYPE_STANDARD;
return im.type_seq(type, *player, seq_type);
},
[] (ioport_manager &im, ioport_type type, std::optional<int> player)
{
if (!player)
player = 0;
return im.type_seq(type, *player);
},
[] (ioport_manager &im, input_type_entry const &type, std::optional<char const *> seq_type_string)
{
input_seq_type seq_type = seq_type_string ? s_seq_type_parser(*seq_type_string) : SEQ_TYPE_STANDARD;
return im.type_seq(type.type(), type.player(), seq_type);
},
[] (ioport_manager &im, input_type_entry const &type)
{
return im.type_seq(type.type(), type.player());
});
ioport_manager_type["set_type_seq"] = sol::overload(
[] (ioport_manager &im, ioport_type type, std::optional<int> player, std::optional<char const *> seq_type_string, input_seq const &seq)

View File

@ -11,7 +11,7 @@
#include "cassimg.h"
#include "imageutl.h"
#include "corealloc.h" // make_unique_clear
#include "corealloc.h" // util::make_unique_clear
#include <algorithm>
#include <cassert>
@ -191,7 +191,7 @@ cassette_image::error cassette_image::lookup_sample(int channel, size_t sample,
m_blocks.resize(sample_blocknum + 1);
if (!m_blocks[sample_blocknum])
m_blocks[sample_blocknum] = make_unique_clear<int32_t []>(SAMPLES_PER_BLOCK);
m_blocks[sample_blocknum] = util::make_unique_clear<int32_t []>(SAMPLES_PER_BLOCK);
ptr = &m_blocks[sample_blocknum][sample_index];
return error::SUCCESS;

View File

@ -13,54 +13,37 @@
#pragma once
#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <new>
#include <type_traits>
#include <utility>
// global allocation helpers
template<typename Tp> struct MakeUniqClearT { typedef std::unique_ptr<Tp> single_object; };
namespace util {
template<typename Tp> struct MakeUniqClearT<Tp[]> { typedef std::unique_ptr<Tp[]> array; };
namespace detail {
template<typename Tp, size_t Bound> struct MakeUniqClearT<Tp[Bound]> { struct invalid_type { }; };
template <typename Tp> struct make_unique_clear_traits { };
template <typename Tp> struct make_unique_clear_traits<Tp []> { using unbounded_array_ptr = std::unique_ptr<Tp []>; };
template <typename Tp, size_t Bound> struct make_unique_clear_traits<Tp [Bound]> { };
/// make_unique_clear for single objects
template<typename Tp, typename... Params>
inline typename MakeUniqClearT<Tp>::single_object make_unique_clear(Params&&... args)
{
void *const ptr = ::operator new(sizeof(Tp)); // allocate memory
std::memset(ptr, 0, sizeof(Tp));
return std::unique_ptr<Tp>(new(ptr) Tp(std::forward<Params>(args)...));
}
} // namespace detail
/// make_unique_clear for arrays of unknown bound
template<typename Tp>
inline typename MakeUniqClearT<Tp>::array make_unique_clear(size_t num)
template <typename Tp>
inline typename detail::make_unique_clear_traits<Tp>::unbounded_array_ptr make_unique_clear(size_t num)
{
auto size = sizeof(std::remove_extent_t<Tp>) * num;
unsigned char* ptr = new unsigned char[size]; // allocate memory
static_assert(std::is_trivially_constructible_v<std::remove_extent_t<Tp> >, "make_unique_clear is only suitable for trivially constructible types");
auto const size = sizeof(std::remove_extent_t<Tp>) * num;
unsigned char* ptr = new unsigned char [size]; // allocate memory - this assumes new expression overhead is the same for all array types
std::memset(ptr, 0, size);
return std::unique_ptr<Tp>(new(ptr) std::remove_extent_t<Tp>[num]());
return std::unique_ptr<Tp>(new (ptr) std::remove_extent_t<Tp> [num]);
}
template<typename Tp, unsigned char F>
inline typename MakeUniqClearT<Tp>::array make_unique_clear(size_t num)
{
auto size = sizeof(std::remove_extent_t<Tp>) * num;
unsigned char* ptr = new unsigned char[size]; // allocate memory
std::memset(ptr, F, size);
return std::unique_ptr<Tp>(new(ptr) std::remove_extent_t<Tp>[num]());
}
/// Disable make_unique_clear for arrays of known bound
template<typename Tp, typename... Params>
inline typename MakeUniqClearT<Tp>::invalid_type make_unique_clear(Params&&...) = delete;
} // namespace util
#endif // MAME_LIB_UTIL_COREALLOC_H

View File

@ -271,8 +271,8 @@ DISCRETE_CLASS_STEP_RESET(copsnrob_custom_noise, 2,
int m_flip_flop = 0;
int m_noise1_had_xtime = 0;
int m_noise2_had_xtime = 0;
uint8_t m_high_byte = 0;
uint8_t m_low_byte = 0;
uint8_t m_high_byte = 0;
uint8_t m_low_byte = 0;
double m_t_used = 0;
double m_t1 = 0;
);
@ -284,9 +284,9 @@ DISCRETE_STEP(copsnrob_custom_noise)
double t_used = m_t_used;
double t1 = m_t1;
double x_time = 0;
uint8_t low_byte = m_low_byte;
uint8_t high_byte = m_high_byte;
uint8_t xnor_out; /* IC F2, pin 2 */
uint8_t low_byte = m_low_byte;
uint8_t high_byte = m_high_byte;
uint8_t xnor_out; /* IC F2, pin 2 */
int last_noise1_bit = (low_byte >> 4) & 0x01;
int last_noise2_bit = (low_byte >> 5) & 0x01;

View File

@ -294,10 +294,10 @@ static const discrete_op_amp_filt_info dkong_sallen_key_info =
#define DKONG_CUSTOM_V DISCRETE_INPUT(7)
DISCRETE_CLASS_STEP_RESET(dkong_custom_mixer, 1,
double m_i_in1[2]{};
double m_r_in[2]{};
double m_r_total[2]{};
double m_exp[2]{};
double m_i_in1[2]{ 0.0 };
double m_r_in[2]{ 0.0 };
double m_r_total[2]{ 0.0 };
double m_exp[2]{ 0.0 };
double m_out_v = 0;
);

View File

@ -144,9 +144,9 @@ static const discrete_mixer_desc skyraid_mixer =
#define SKYRAID_MISSLE_CUSTOM_C DISCRETE_INPUT(4)
DISCRETE_CLASS_STEP_RESET(skyraid_missle_custom_charge, 2,
double m_v_charge[2]{};
double m_v_cap = 0;
double m_exp[2]{};
double m_v_charge[2]{ 0.0 };
double m_v_cap = 0.0;
double m_exp[2]{ 0.0 };
);
/* the high charge is clamped by the diode to 0.7V above the 5V line */
@ -154,7 +154,7 @@ DISCRETE_CLASS_STEP_RESET(skyraid_missle_custom_charge, 2,
DISCRETE_STEP( skyraid_missle_custom_charge )
{
int in_1 = (SKYRAID_MISSLE_CUSTOM_IN1 == 0) ? 0 : 1;
int const in_1 = (SKYRAID_MISSLE_CUSTOM_IN1 == 0) ? 0 : 1;
/* charge/discharge cap */
m_v_cap += (m_v_charge[in_1] - m_v_cap) * m_exp[in_1];

View File

@ -274,7 +274,8 @@ void segas32_state::device_start()
/* allocate pre-rendered solid lines of 0's and ffff's */
m_solid_0000 = make_unique_clear<uint16_t[]>(512);
m_solid_ffff = make_unique_clear<uint16_t[],0xff>(512);
m_solid_ffff = std::make_unique<uint16_t[]>(512);
std::fill_n(m_solid_ffff.get(), 512, ~uint16_t(0));
/* allocate background color per line*/
m_prev_bgstartx = std::make_unique<int32_t[]>(512);

View File

@ -505,7 +505,7 @@ bool shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r
snap_width = winoptions.d3d_snap_width();
snap_height = winoptions.d3d_snap_height();
this->options = make_unique_clear<hlsl_options>().release();
this->options = new hlsl_options;
this->options->params_init = false;
// copy last options if initialized

View File

@ -175,92 +175,92 @@ class movie_recorder;
/* in the future this will be moved into an OSD/emu shared buffer */
struct hlsl_options
{
bool params_init;
bool params_dirty;
int shadow_mask_tile_mode;
float shadow_mask_alpha;
char shadow_mask_texture[1024];
int shadow_mask_count_x;
int shadow_mask_count_y;
float shadow_mask_u_size;
float shadow_mask_v_size;
float shadow_mask_u_offset;
float shadow_mask_v_offset;
float distortion;
float cubic_distortion;
float distort_corner;
float round_corner;
float smooth_border;
float reflection;
float vignetting;
float scanline_alpha;
float scanline_scale;
float scanline_height;
float scanline_variation;
float scanline_bright_scale;
float scanline_bright_offset;
float scanline_jitter;
float hum_bar_alpha;
float defocus[2];
float converge_x[3];
float converge_y[3];
float radial_converge_x[3];
float radial_converge_y[3];
float red_ratio[3];
float grn_ratio[3];
float blu_ratio[3];
float offset[3];
float scale[3];
float power[3];
float floor[3];
float phosphor[3];
float saturation;
int chroma_mode;
float chroma_a[2];
float chroma_b[2];
float chroma_c[2];
float chroma_conversion_gain[3];
float chroma_y_gain[3];
bool params_init = false;
bool params_dirty = false;
int shadow_mask_tile_mode = 0;
float shadow_mask_alpha = 0.0;
char shadow_mask_texture[1024]{ 0 };
int shadow_mask_count_x = 0;
int shadow_mask_count_y = 0;
float shadow_mask_u_size = 0.0;
float shadow_mask_v_size = 0.0;
float shadow_mask_u_offset = 0.0;
float shadow_mask_v_offset = 0.0;
float distortion = 0.0;
float cubic_distortion = 0.0;
float distort_corner = 0.0;
float round_corner = 0.0;
float smooth_border = 0.0;
float reflection = 0.0;
float vignetting = 0.0;
float scanline_alpha = 0.0;
float scanline_scale = 0.0;
float scanline_height = 0.0;
float scanline_variation = 0.0;
float scanline_bright_scale = 0.0;
float scanline_bright_offset = 0.0;
float scanline_jitter = 0.0;
float hum_bar_alpha = 0.0;
float defocus[2]{ 0.0 };
float converge_x[3]{ 0.0 };
float converge_y[3]{ 0.0 };
float radial_converge_x[3]{ 0.0 };
float radial_converge_y[3]{ 0.0 };
float red_ratio[3]{ 0.0 };
float grn_ratio[3]{ 0.0 };
float blu_ratio[3]{ 0.0 };
float offset[3]{ 0.0 };
float scale[3]{ 0.0 };
float power[3]{ 0.0 };
float floor[3]{ 0.0 };
float phosphor[3]{ 0.0 };
float saturation = 0.0;
int chroma_mode = 0;
float chroma_a[2]{ 0.0 };
float chroma_b[2]{ 0.0 };
float chroma_c[2]{ 0.0 };
float chroma_conversion_gain[3]{ 0.0 };
float chroma_y_gain[3]{ 0.0 };
// NTSC
int yiq_enable;
float yiq_jitter;
float yiq_cc;
float yiq_a;
float yiq_b;
float yiq_o;
float yiq_p;
float yiq_n;
float yiq_y;
float yiq_i;
float yiq_q;
float yiq_scan_time;
int yiq_phase_count;
int yiq_enable = 0;
float yiq_jitter = 0.0;
float yiq_cc = 0.0;
float yiq_a = 0.0;
float yiq_b = 0.0;
float yiq_o = 0.0;
float yiq_p = 0.0;
float yiq_n = 0.0;
float yiq_y = 0.0;
float yiq_i = 0.0;
float yiq_q = 0.0;
float yiq_scan_time = 0.0;
int yiq_phase_count = 0;
// Vectors
float vector_beam_smooth;
float vector_length_scale;
float vector_length_ratio;
float vector_beam_smooth = 0.0;
float vector_length_scale = 0.0;
float vector_length_ratio = 0.0;
// Bloom
int bloom_blend_mode;
float bloom_scale;
float bloom_overdrive[3];
float bloom_level0_weight;
float bloom_level1_weight;
float bloom_level2_weight;
float bloom_level3_weight;
float bloom_level4_weight;
float bloom_level5_weight;
float bloom_level6_weight;
float bloom_level7_weight;
float bloom_level8_weight;
int bloom_blend_mode = 0;
float bloom_scale = 0.0;
float bloom_overdrive[3]{ 0.0 };
float bloom_level0_weight = 0.0;
float bloom_level1_weight = 0.0;
float bloom_level2_weight = 0.0;
float bloom_level3_weight = 0.0;
float bloom_level4_weight = 0.0;
float bloom_level5_weight = 0.0;
float bloom_level6_weight = 0.0;
float bloom_level7_weight = 0.0;
float bloom_level8_weight = 0.0;
// Final
char lut_texture[1024];
int lut_enable;
char ui_lut_texture[1024];
int ui_lut_enable;
char lut_texture[1024]{ 0 };
int lut_enable = 0;
char ui_lut_texture[1024]{ 0 };
int ui_lut_enable = 0;
};
struct slider_desc