summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Couriersud <couriersud@users.noreply.github.com>2011-01-23 23:18:59 +0000
committer Couriersud <couriersud@users.noreply.github.com>2011-01-23 23:18:59 +0000
commitcff7d94c91c98ae84a14b79513b0a403b4fe3b9d (patch)
tree1c9b3aa60c613b4639dce08c823ea0b703e2b7a5 /src
parentce4abf541f065da7f89d210bdab01b8be3d47ce5 (diff)
Carved out a discrete_sound_device from discrete_device.
This now has all the stream related code. discrete_device thus now contains all the generic code and may be used going forward to implement not sound related use cases. [Couriersud]
Diffstat (limited to 'src')
-rw-r--r--src/emu/sound/disc_cls.h18
-rw-r--r--src/emu/sound/disc_inp.c30
-rw-r--r--src/emu/sound/discrete.c231
-rw-r--r--src/emu/sound/discrete.h150
4 files changed, 278 insertions, 151 deletions
diff --git a/src/emu/sound/disc_cls.h b/src/emu/sound/disc_cls.h
index cab909e3125..dfb36fea2a0 100644
--- a/src/emu/sound/disc_cls.h
+++ b/src/emu/sound/disc_cls.h
@@ -40,7 +40,7 @@ class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_ste
public: \
void step(void); \
void reset(void); \
- int max_output(void) { return _maxout; } \
+ int max_output(void) { return _maxout; } \
private: \
_priv \
}
@@ -53,7 +53,7 @@ class DISCRETE_CLASS_NAME(_name): public discrete_base_node, public discrete_ste
public: \
void step(void); \
void reset(void) { this->step(); } \
- int max_output(void) { return _maxout; } \
+ int max_output(void) { return _maxout; } \
private: \
_priv \
}
@@ -65,7 +65,7 @@ class DISCRETE_CLASS_NAME(_name): public discrete_base_node \
DISCRETE_CLASS_DESTRUCTOR(_name) \
public: \
void reset(void); \
- int max_output(void) { return _maxout; } \
+ int max_output(void) { return _maxout; } \
}
#define DISCRETE_CLASS(_name, _maxout, _priv) \
@@ -78,7 +78,7 @@ public: \
void reset(void); \
void start(void); \
void stop(void); \
- int max_output(void) { return _maxout; } \
+ int max_output(void) { return _maxout; } \
private: \
_priv \
}
@@ -105,7 +105,9 @@ public:
*
*************************************/
-class DISCRETE_CLASS_NAME(dso_output): public discrete_base_node, public discrete_output_interface, public discrete_step_interface
+class DISCRETE_CLASS_NAME(dso_output): public discrete_base_node,
+ public discrete_sound_output_interface,
+ public discrete_step_interface
{
DISCRETE_CLASS_CONSTRUCTOR(dso_output, base)
DISCRETE_CLASS_DESTRUCTOR(dso_output)
@@ -117,7 +119,7 @@ public:
*m_ptr++ = val;
}
int max_output(void) { return 0; }
- void set_output(stream_sample_t *ptr) { m_ptr = ptr; }
+ void set_output_ptr(stream_sample_t *ptr) { m_ptr = ptr; }
private:
stream_sample_t *m_ptr;
};
@@ -220,6 +222,10 @@ public:
void start(void);
void input_write(int sub_node, UINT8 data );
virtual bool is_buffered(void) { return false; }
+
+ /* This is called by discrete_sound_device */
+ void stream_start(void);
+
//protected:
UINT32 m_stream_in_number;
stream_sample_t *m_ptr; /* current in ptr for stream */
diff --git a/src/emu/sound/disc_inp.c b/src/emu/sound/disc_inp.c
index 1c8cb8dd7e3..57aad660197 100644
--- a/src/emu/sound/disc_inp.c
+++ b/src/emu/sound/disc_inp.c
@@ -148,7 +148,7 @@ void DISCRETE_CLASS_FUNC(dss_input_data, input_write)(int sub_node, UINT8 data )
if (m_data != new_data)
{
/* Bring the system up to now */
- m_device->update();
+ m_device->update_to_current_time();
m_data = new_data;
@@ -175,7 +175,7 @@ void DISCRETE_CLASS_FUNC(dss_input_logic, input_write)(int sub_node, UINT8 data
if (m_data != new_data)
{
/* Bring the system up to now */
- m_device->update();
+ m_device->update_to_current_time();
m_data = new_data;
@@ -202,7 +202,7 @@ void DISCRETE_CLASS_FUNC(dss_input_not, input_write)(int sub_node, UINT8 data )
if (m_data != new_data)
{
/* Bring the system up to now */
- m_device->update();
+ m_device->update_to_current_time();
m_data = new_data;
@@ -235,7 +235,7 @@ void DISCRETE_CLASS_FUNC(dss_input_pulse, input_write)(int sub_node, UINT8 data
if (m_data != new_data)
{
/* Bring the system up to now */
- m_device->update();
+ m_device->update_to_current_time();
m_data = new_data;
}
}
@@ -302,7 +302,7 @@ void DISCRETE_CLASS_FUNC(dss_input_stream, input_write)(int sub_node, UINT8 data
else
{
/* Bring the system up to now */
- m_device->update();
+ m_device->update_to_current_time();
m_data = new_data;
@@ -316,8 +316,6 @@ DISCRETE_START(dss_input_stream)
{
discrete_base_node::start();
- assert(DSS_INPUT_STREAM__STREAM < m_device->m_input_stream_list.count());
-
/* Stream out number is set during start */
m_stream_in_number = DSS_INPUT_STREAM__STREAM;
m_gain = DSS_INPUT_STREAM__GAIN;
@@ -325,16 +323,20 @@ DISCRETE_START(dss_input_stream)
m_ptr = NULL;
m_is_buffered = is_buffered();
+ m_buffer_stream = NULL;
+}
+
+void DISCRETE_CLASS_NAME(dss_input_stream)::stream_start(void)
+{
if (m_is_buffered)
{
- m_buffer_stream = stream_create(m_device, 0, 1, this->sample_rate(), this, static_stream_generate);
+ /* stream_buffered input only supported for sound devices */
+ discrete_sound_device *snd_device = downcast<discrete_sound_device *>(m_device);
+ //assert(DSS_INPUT_STREAM__STREAM < snd_device->m_input_stream_list.count());
+
+ m_buffer_stream = stream_create(snd_device, 0, 1, this->sample_rate(), this, static_stream_generate);
- stream_set_input(m_device->m_stream, m_stream_in_number,
+ stream_set_input(snd_device->get_stream(), m_stream_in_number,
m_buffer_stream, 0, 1.0);
}
- else
- {
- m_buffer_stream = NULL;
- }
}
-
diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c
index 7cd16eb84c1..c1477911f09 100644
--- a/src/emu/sound/discrete.c
+++ b/src/emu/sound/discrete.c
@@ -67,14 +67,13 @@
#define DISCRETE_DEBUGLOG (0)
-
/*************************************
*
- * Profiling Nodes
+ * Use tasks ?
*
*************************************/
-#define DISCRETE_PROFILING (0)
+#define USE_DISCRETE_TASKS (1)
/*************************************
*
@@ -365,7 +364,7 @@ discrete_base_node::~discrete_base_node(void)
/* currently noting */
}
-void discrete_base_node::init(discrete_device *pdev, const discrete_sound_block *xblock)
+void discrete_base_node::init(discrete_device *pdev, const discrete_block *xblock)
{
m_device = pdev;
m_block = xblock;
@@ -375,7 +374,7 @@ void discrete_base_node::init(discrete_device *pdev, const discrete_sound_block
m_step_intf = dynamic_cast<discrete_step_interface *>(this);
m_input_intf = dynamic_cast<discrete_input_interface *>(this);
- m_output_intf = dynamic_cast<discrete_output_interface *>(this);
+ m_output_intf = dynamic_cast<discrete_sound_output_interface *>(this);
if (m_step_intf)
{
@@ -390,7 +389,7 @@ void discrete_base_node::save_state(void)
state_save_register_device_item_array(m_device, m_block->node, m_output);
}
-const discrete_base_node *discrete_device::discrete_find_node(int node)
+discrete_base_node *discrete_device::discrete_find_node(int node)
{
if (node < NODE_START || node > NODE_END) return NULL;
return m_indexed_node[NODE_INDEX(node)];
@@ -408,7 +407,8 @@ void discrete_base_node::resolve_input_nodes(void)
/* if this input is node-based, find the node in the indexed list */
if IS_VALUE_A_NODE(inputnode)
{
- discrete_base_node *node_ref = m_device->m_indexed_node[NODE_INDEX(inputnode)];
+ //discrete_base_node *node_ref = m_device->m_indexed_node[NODE_INDEX(inputnode)];
+ discrete_base_node *node_ref = m_device->discrete_find_node(inputnode);
if (!node_ref)
fatalerror("discrete_start - NODE_%02d referenced a non existent node NODE_%02d", index(), NODE_INDEX(inputnode));
@@ -486,7 +486,7 @@ void CLIB_DECL ATTR_PRINTF(2,3) discrete_device::discrete_log(const char *text,
// discrete_build_list: Build import list
//-------------------------------------------------
-void discrete_device::discrete_build_list(const discrete_sound_block *intf, sound_block_list_t &block_list)
+void discrete_device::discrete_build_list(const discrete_block *intf, sound_block_list_t &block_list)
{
int node_count = 0;
@@ -496,7 +496,7 @@ void discrete_device::discrete_build_list(const discrete_sound_block *intf, soun
if (intf[node_count].type == DSO_IMPORT)
{
discrete_log("discrete_build_list() - DISCRETE_IMPORT @ NODE_%02d", NODE_INDEX(intf[node_count].node) );
- discrete_build_list((discrete_sound_block *) intf[node_count].custom, block_list);
+ discrete_build_list((discrete_block *) intf[node_count].custom, block_list);
}
else if (intf[node_count].type == DSO_REPLACE)
{
@@ -507,7 +507,7 @@ void discrete_device::discrete_build_list(const discrete_sound_block *intf, soun
for (int i=0; i < block_list.count(); i++)
{
- const discrete_sound_block *block = block_list[i];
+ const discrete_block *block = block_list[i];
if (block->type != NODE_SPECIAL )
if (block->node == intf[node_count].node)
@@ -529,7 +529,7 @@ void discrete_device::discrete_build_list(const discrete_sound_block *intf, soun
for (int i=0; i<block_list.count(); i++)
{
- const discrete_sound_block *block = block_list[i];
+ const discrete_block *block = block_list[i];
if ((block->node >= intf[node_count].input_node[0]) &&
(block->node <= intf[node_count].input_node[1]))
@@ -562,7 +562,7 @@ void discrete_device::discrete_sanity_check(const sound_block_list_t &block_list
discrete_log("discrete_start() - Doing node list sanity check");
for (int i=0; i < block_list.count(); i++)
{
- const discrete_sound_block *block = block_list[i];
+ const discrete_block *block = block_list[i];
/* make sure we don't have too many nodes overall */
if (node_count > DISCRETE_MAX_NODES)
@@ -675,10 +675,13 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
int has_tasks = 0;
/* check whether we have tasks ... */
- for (int i = 0; i < block_list.count(); i++)
+ if (USE_DISCRETE_TASKS)
{
- if (block_list[i]->type == DSO_TASK_START)
- has_tasks = 1;
+ for (int i = 0; i < block_list.count(); i++)
+ {
+ if (block_list[i]->type == DSO_TASK_START)
+ has_tasks = 1;
+ }
}
if (!has_tasks)
@@ -693,7 +696,7 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
/* loop over all nodes */
for (int i = 0; i < block_list.count(); i++)
{
- const discrete_sound_block *block = block_list[i];
+ const discrete_block *block = block_list[i];
discrete_base_node *node = block->factory->Create(this, block);
/* keep track of special nodes */
@@ -716,19 +719,25 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
/* Task processing */
case DSO_TASK_START:
- if (task != NULL)
- fatalerror("init_nodes() - Nested DISCRETE_START_TASK.");
- task = auto_alloc_clear(machine, discrete_task(*this));
- task->task_group = block->initial[0];
- if (task->task_group < 0 || task->task_group >= DISCRETE_MAX_TASK_GROUPS)
- fatalerror("discrete_dso_task: illegal task_group %d", task->task_group);
- //printf("task group %d\n", task->task_group);
- task_list.add(task);
+ if (USE_DISCRETE_TASKS)
+ {
+ if (task != NULL)
+ fatalerror("init_nodes() - Nested DISCRETE_START_TASK.");
+ task = auto_alloc_clear(machine, discrete_task(*this));
+ task->task_group = block->initial[0];
+ if (task->task_group < 0 || task->task_group >= DISCRETE_MAX_TASK_GROUPS)
+ fatalerror("discrete_dso_task: illegal task_group %d", task->task_group);
+ //printf("task group %d\n", task->task_group);
+ task_list.add(task);
+ }
break;
case DSO_TASK_END:
- if (task == NULL)
- fatalerror("init_nodes() - NO DISCRETE_START_TASK.");
+ if (USE_DISCRETE_TASKS)
+ {
+ if (task == NULL)
+ fatalerror("init_nodes() - NO DISCRETE_START_TASK.");
+ }
break;
default:
@@ -744,13 +753,6 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
m_indexed_node[NODE_INDEX(block->node)] = node;
}
- /* if we are an stream input node, track that */
- discrete_dss_input_stream_node *input_stream = dynamic_cast<discrete_dss_input_stream_node *>(node);
- if (input_stream != NULL)
- {
- m_input_stream_list.add(input_stream);
- }
-
/* add to node list */
m_node_list.add(node);
@@ -766,13 +768,7 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
task->step_list.add(step);
}
- /* if this is an output interface, add it the output list */
- discrete_output_interface *out;
- if (node->interface(out))
- m_output_list.add(out);
-
-
- if (block->type == DSO_TASK_END)
+ if (USE_DISCRETE_TASKS && block->type == DSO_TASK_END)
{
task = NULL;
}
@@ -784,10 +780,6 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list)
if (!has_tasks)
{
}
-
- /* if no outputs, give an error */
- if (m_output_list.count() == 0)
- fatalerror("init_nodes() - Couldn't find an output node");
}
@@ -817,7 +809,7 @@ int discrete_device::same_module_index(const discrete_base_node &node)
// GLOBAL VARIABLES
//**************************************************************************
-const device_type DISCRETE = discrete_device_config::static_alloc_device_config;
+const device_type DISCRETE = discrete_sound_device_config::static_alloc_device_config;
//**************************************************************************
// DEVICE CONFIGURATION
@@ -828,7 +820,7 @@ const device_type DISCRETE = discrete_device_config::static_alloc_device_config;
// the interface
//-------------------------------------------------
-void discrete_device_config::static_set_intf(device_config *device, const discrete_sound_block *intf)
+void discrete_device_config::static_set_intf(device_config *device, const discrete_block *intf)
{
discrete_device_config *disc = downcast<discrete_device_config *>(device);
disc->m_intf = intf;
@@ -837,13 +829,16 @@ void discrete_device_config::static_set_intf(device_config *device, const discre
//-------------------------------------------------
// discrete_device_config - constructor
//-------------------------------------------------
-
-discrete_device_config::discrete_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
- : device_config(mconfig, static_alloc_device_config, "DISCRETE", tag, owner, clock),
- device_config_sound_interface(mconfig, *this), m_intf(NULL)
+discrete_device_config::discrete_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock)
+ : device_config(mconfig, type, name, tag, owner, clock), m_intf(NULL)
{
}
+discrete_sound_device_config::discrete_sound_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+ : discrete_device_config(mconfig, static_alloc_device_config, "DISCRETE", tag, owner, clock),
+ device_config_sound_interface(mconfig, *this)
+{
+}
//-------------------------------------------------
// static_alloc_device_config - allocate a new
@@ -852,7 +847,12 @@ discrete_device_config::discrete_device_config(const machine_config &mconfig, co
device_config *discrete_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
{
- return global_alloc(discrete_device_config(mconfig, tag, owner, clock));
+ return global_alloc(discrete_device_config(mconfig, static_alloc_device_config, "PUREDISC", tag, owner, clock));
+}
+
+device_config *discrete_sound_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
+{
+ return global_alloc(discrete_sound_device_config(mconfig, tag, owner, clock));
}
@@ -865,6 +865,11 @@ device_t *discrete_device_config::alloc_device(running_machine &machine) const
return auto_alloc(&machine, discrete_device(machine, *this));
}
+device_t *discrete_sound_device_config::alloc_device(running_machine &machine) const
+{
+ return auto_alloc(&machine, discrete_sound_device(machine, *this));
+}
+
//-------------------------------------------------
// discrete_device - constructor
@@ -872,11 +877,14 @@ device_t *discrete_device_config::alloc_device(running_machine &machine) const
discrete_device::discrete_device(running_machine &_machine, const discrete_device_config &config)
: device_t(_machine, config),
- device_sound_interface(_machine, config, *this),
m_config(config)
{
- //memset(&m_info, 0, sizeof(m_info));
+}
+discrete_sound_device::discrete_sound_device(running_machine &_machine, const discrete_sound_device_config &config)
+ : discrete_device(_machine, config),
+ device_sound_interface(_machine, config, *this)
+{
}
discrete_device::~discrete_device(void)
@@ -913,7 +921,7 @@ void discrete_device::device_start()
// create the stream
//m_stream = stream_create(this, 0, 2, 22257, this, static_stream_generate);
- const discrete_sound_block *intf_start = (m_config.m_intf != NULL) ? m_config.m_intf : (discrete_sound_block *) baseconfig().static_config();
+ const discrete_block *intf_start = (m_config.m_intf != NULL) ? m_config.m_intf : (discrete_block *) baseconfig().static_config();
char name[32];
/* If a clock is specified we will use it, otherwise run at the audio sample rate. */
@@ -946,8 +954,6 @@ void discrete_device::device_start()
/* Start with empty lists */
m_node_list.clear();
- m_output_list.clear();
- m_input_stream_list.clear();
/* allocate memory to hold pointers to nodes by index */
m_indexed_node = auto_alloc_array_clear(this->machine, discrete_base_node *, DISCRETE_MAX_NODES);
@@ -961,22 +967,16 @@ void discrete_device::device_start()
(*node)->resolve_input_nodes();
}
- /* initialize the stream(s) */
- m_stream = stream_create(*this,m_input_stream_list.count(), m_output_list.count(), m_sample_rate);
-
/* allocate a queue */
-
m_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_MULTI | WORK_QUEUE_FLAG_HIGH_FREQ);
/* Process nodes which have a start func */
-
for_each(discrete_base_node **, node, &m_node_list)
{
(*node)->start();
}
/* Now set up tasks */
-
for_each(discrete_task **, task, &task_list)
{
for_each(discrete_task **, dest_task, &task_list)
@@ -987,6 +987,48 @@ void discrete_device::device_start()
}
}
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void discrete_sound_device::device_start()
+{
+ m_input_stream_list.clear();
+ m_output_list.clear();
+
+ /* call the parent */
+ discrete_device::device_start();
+
+ /* look for input stream nodes */
+ for_each(discrete_base_node **, node, &m_node_list)
+ {
+ /* if we are an stream input node, track that */
+ discrete_dss_input_stream_node *input_stream = dynamic_cast<discrete_dss_input_stream_node *>(*node);
+ if (input_stream != NULL)
+ {
+ m_input_stream_list.add(input_stream);
+ }
+ /* if this is an output interface, add it the output list */
+ discrete_sound_output_interface *out;
+ if ((*node)->interface(out))
+ m_output_list.add(out);
+ }
+
+ /* if no outputs, give an error */
+ if (m_output_list.count() == 0)
+ fatalerror("init_nodes() - Couldn't find an output node");
+
+ /* initialize the stream(s) */
+ m_stream = stream_create(*this,m_input_stream_list.count(), m_output_list.count(), m_sample_rate);
+
+ /* Finalize stream_input_nodes */
+ for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
+ {
+ (*node)->stream_start();
+ }
+
+
+}
//-------------------------------------------------
// device_reset - device-specific reset
@@ -995,7 +1037,7 @@ void discrete_device::device_start()
void discrete_device::device_reset()
{
- update();
+ update_to_current_time();
/* loop over all nodes */
for_each (discrete_base_node **, node, &m_node_list)
@@ -1007,31 +1049,25 @@ void discrete_device::device_reset()
}
}
+void discrete_sound_device::device_reset()
+{
+
+ discrete_device::device_reset();
+}
+
//-------------------------------------------------
-// stream_update - handle update requests for
-// our sound stream
+// discrete_device_process - process a number of
+// samples.
+//
+// input / output buffers are stream_sample_t
+// to not to have to convert the buffers.
+// a "discrete cpu" device will pass NULL here
//-------------------------------------------------
-void discrete_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+void discrete_device::process(int samples)
{
- int outputnum;
- //, task_group;
-
if (samples == 0)
return;
- /* Setup any output streams */
- outputnum = 0;
- for_each(discrete_output_interface **, node, &m_output_list)
- {
- (*node)->set_output(outputs[outputnum]);
- outputnum++;
- }
-
- /* Setup any input streams */
- for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
- {
- (*node)->m_ptr = (stream_sample_t *) inputs[(*node)->m_stream_in_number];
- }
/* Setup tasks */
for_each(discrete_task **, task, &task_list)
@@ -1057,6 +1093,35 @@ void discrete_device::sound_stream_update(sound_stream &stream, stream_sample_t
}
//-------------------------------------------------
+// sound_stream_update - handle update requests for
+// our sound stream
+//-------------------------------------------------
+
+void discrete_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+{
+ int outputnum = 0;
+
+ if (samples == 0)
+ return;
+
+ /* Setup any output streams */
+ for_each(discrete_sound_output_interface **, node, &m_output_list)
+ {
+ (*node)->set_output_ptr(outputs[outputnum]);
+ outputnum++;
+ }
+
+ /* Setup any input streams */
+ for_each(discrete_dss_input_stream_node **, node, &m_input_stream_list)
+ {
+ (*node)->m_ptr = (stream_sample_t *) inputs[(*node)->m_stream_in_number];
+ }
+
+ /* just process it */
+ process(samples);
+}
+
+//-------------------------------------------------
// read - read from the chip's registers and internal RAM
//-------------------------------------------------
@@ -1070,7 +1135,7 @@ READ8_MEMBER( discrete_device::read )
if (node)
{
/* Bring the system up to now */
- stream_update(m_stream);
+ update_to_current_time();
data = (UINT8) node->m_output[NODE_CHILD_NODE_NUM(offset)];
}
diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h
index 213f8875776..885f11c5d1f 100644
--- a/src/emu/sound/discrete.h
+++ b/src/emu/sound/discrete.h
@@ -4193,7 +4193,7 @@ typedef enum
*
*************************************/
-typedef struct _discrete_sound_block discrete_sound_block;
+typedef struct _discrete_sound_block discrete_block;
class discrete_node_base_factory;
class discrete_task;
class discrete_base_node;
@@ -4230,7 +4230,7 @@ struct _discrete_sound_block
const char * name; /* Node Name */
const char * mod_name; /* Module / class name */
};
-typedef dynamic_array_t<const discrete_sound_block *> sound_block_list_t;
+typedef dynamic_array_t<const discrete_block *> sound_block_list_t;
/*************************************
*
@@ -4257,12 +4257,12 @@ public:
virtual void input_write(int sub_node, UINT8 data ) = 0;
};
-class discrete_output_interface
+class discrete_sound_output_interface
{
public:
- virtual ~discrete_output_interface() { }
+ virtual ~discrete_sound_output_interface() { }
- virtual void set_output(stream_sample_t *ptr) = 0;
+ virtual void set_output_ptr(stream_sample_t *ptr) = 0;
};
@@ -4288,7 +4288,7 @@ READ8_DEVICE_HANDLER( discrete_sound_r );
MCFG_DISCRETE_INTF(_intf)
#define MCFG_DISCRETE_INTF(_intf) \
- discrete_device_config::static_set_intf(device, (const discrete_sound_block *)&(_intf##_discrete_interface)); \
+ discrete_device_config::static_set_intf(device, (const discrete_block *)&(_intf##_discrete_interface)); \
#define MCFG_SOUND_CONFIG_DISCRETE(name) MCFG_SOUND_CONFIG(name##_discrete_interface)
@@ -4298,39 +4298,40 @@ READ8_DEVICE_HANDLER( discrete_sound_r );
// ======================> discrete_device_config
-class discrete_device_config : public device_config, public device_config_sound_interface
+class discrete_device_config : public device_config
{
friend class discrete_device;
+protected:
// construction/destruction
- discrete_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+ discrete_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock);
public:
// allocators
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+
virtual device_t *alloc_device(running_machine &machine) const;
// inline configuration helpers
- static void static_set_intf(device_config *device, const discrete_sound_block *intf);
+ static void static_set_intf(device_config *device, const discrete_block *intf);
protected:
- const discrete_sound_block *m_intf;
+ const discrete_block *m_intf;
// inline data
};
-class discrete_output_interface;
-typedef dynamic_array_t<discrete_output_interface *> node_output_list_t;
+class discrete_sound_output_interface;
+typedef dynamic_array_t<discrete_sound_output_interface *> node_output_list_t;
// ======================> discrete_device
-class discrete_device : public device_t, public device_sound_interface
+class discrete_device : public device_t
{
friend class discrete_device_config;
- friend class discrete_base_node;
- friend class discrete_task;
- friend class discrete_dss_input_stream_node;
+ //friend class discrete_base_node;
+protected:
// construction/destruction
discrete_device(running_machine &_machine, const discrete_device_config &config);
@@ -4341,17 +4342,29 @@ public:
/* --------------------------------- */
+ virtual void update_to_current_time(void) const { }
+
+ /* process a number of samples */
+ void process(int samples);
+
+ /* access to the discrete_logging facility */
void CLIB_DECL ATTR_PRINTF(2,3) discrete_log(const char *text, ...) const;
+
+ /* get pointer to a info struct node ref */
const double *node_output_ptr(int onode);
/* FIXME: this is used by csv and wav logs - going forward, identifiers should be explicitly passed */
int same_module_index(const discrete_base_node &node);
+ /* get node */
+ discrete_base_node *discrete_find_node(int node);
+
+ /* are we profiling */
inline int profiling(void) { return m_profiling; }
- void update(void) const { stream_update(m_stream); }
+ inline int sample_rate(void) { return m_sample_rate; }
+ inline double sample_time(void) { return m_sample_time; }
- /* FIXME: theses should be protected */
protected:
@@ -4359,27 +4372,21 @@ protected:
virtual void device_start();
virtual void device_reset();
- // sound interface overrides
- virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-
- const discrete_base_node *discrete_find_node(int node);
-
// internal state
const discrete_device_config &m_config;
/* --------------------------------- */
- /* the output stream */
- sound_stream *m_stream;
-
/* emulation info */
int m_sample_rate;
double m_sample_time;
double m_neg_sample_time;
+ /* list of all nodes */
+ node_list_t m_node_list; /* node_description * */
private:
- void discrete_build_list(const discrete_sound_block *intf, sound_block_list_t &block_list);
+ void discrete_build_list(const discrete_block *intf, sound_block_list_t &block_list);
void discrete_sanity_check(const sound_block_list_t &block_list);
void display_profiling(void);
void init_nodes(const sound_block_list_t &block_list);
@@ -4387,18 +4394,9 @@ private:
/* internal node tracking */
discrete_base_node ** m_indexed_node;
- /* list of all nodes */
- node_list_t m_node_list; /* node_description * */
-
/* tasks */
task_list_t task_list; /* discrete_task_context * */
- /* the input streams */
- istream_node_list_t m_input_stream_list;
-
- /* output node tracking */
- node_output_list_t m_output_list;
-
/* debugging statistics */
FILE * m_disclogfile;
@@ -4411,6 +4409,62 @@ private:
UINT64 m_total_stream_updates;
};
+// ======================> discrete_sound_device_config
+
+class discrete_sound_device_config : public discrete_device_config,
+ public device_config_sound_interface
+{
+ friend class discrete_sound_device;
+ // construction/destruction
+ discrete_sound_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+
+public:
+ // allocators
+ static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
+ virtual device_t *alloc_device(running_machine &machine) const;
+
+};
+
+// ======================> discrete_sound_device
+
+class discrete_sound_device : public discrete_device,
+ public device_sound_interface
+{
+ friend class discrete_sound_device_config;
+
+ // construction/destruction
+ discrete_sound_device(running_machine &_machine, const discrete_sound_device_config &config);
+
+public:
+ virtual ~discrete_sound_device(void) { };
+
+ /* --------------------------------- */
+
+ virtual void update_to_current_time(void) const { stream_update(m_stream); }
+
+ sound_stream *get_stream(void) { return m_stream; }
+protected:
+
+ // device-level overrides
+ virtual void device_start();
+ virtual void device_reset();
+
+ // sound interface overrides
+ virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
+
+ // internal state
+ //const discrete_device_config &m_config;
+
+private:
+ /* the output stream */
+ sound_stream *m_stream;
+
+ /* the input streams */
+ istream_node_list_t m_input_stream_list;
+ /* output node tracking */
+ node_output_list_t m_output_list;
+};
+
// device type definition
extern const device_type DISCRETE;
@@ -4437,7 +4491,7 @@ public:
inline bool interface(discrete_step_interface *&intf) const { intf = m_step_intf; return (intf != NULL); }
inline bool interface(discrete_input_interface *&intf) const { intf = m_input_intf; return (intf != NULL); }
- inline bool interface(discrete_output_interface *&intf) const { intf = m_output_intf; return (intf != NULL); }
+ inline bool interface(discrete_sound_output_interface *&intf) const { intf = m_output_intf; return (intf != NULL); }
/* get the input value from node #n */
inline double input(int n) { return *(m_input[n]); }
@@ -4459,10 +4513,10 @@ public:
/* Number of active inputs on this node type */
inline int active_inputs(void) { return m_active_inputs; }
/* Bit Flags. 1 in bit location means input_is_node */
- inline int input_is_node(void) { return m_input_is_node; };
+ inline int input_is_node(void) { return m_input_is_node; }
- inline double sample_time(void) { return m_device->m_sample_time; }
- inline int sample_rate(void) { return m_device->m_sample_rate; }
+ inline double sample_time(void) { return m_device->sample_time(); }
+ inline int sample_rate(void) { return m_device->sample_rate(); }
const char * module_name(void) { return m_block->mod_name; }
inline int module_type(void) const { return m_block->type; }
@@ -4473,7 +4527,7 @@ protected:
virtual ~discrete_base_node();
/* finish node setup after allocation is complete */
- void init(discrete_device * pdev, const discrete_sound_block *block);
+ void init(discrete_device * pdev, const discrete_block *block);
void resolve_input_nodes(void);
@@ -4483,7 +4537,7 @@ protected:
private:
- const discrete_sound_block * m_block; /* Points to the node's setup block. */
+ const discrete_block * m_block; /* Points to the node's setup block. */
int m_active_inputs; /* Number of active inputs on this node type */
const void * m_custom; /* Custom function specific initialisation data */
@@ -4491,24 +4545,24 @@ private:
discrete_step_interface * m_step_intf;
discrete_input_interface * m_input_intf;
- discrete_output_interface * m_output_intf;
+ discrete_sound_output_interface * m_output_intf;
};
class discrete_node_base_factory
{
public:
- virtual discrete_base_node *Create(discrete_device * pdev, const discrete_sound_block *block) = 0;
+ virtual discrete_base_node *Create(discrete_device * pdev, const discrete_block *block) = 0;
virtual ~discrete_node_base_factory() {}
};
template <class C>
class discrete_node_factory : public discrete_node_base_factory
{
- discrete_base_node *Create(discrete_device * pdev, const discrete_sound_block *block);
+ discrete_base_node *Create(discrete_device * pdev, const discrete_block *block);
};
template <class C>
-discrete_base_node * discrete_node_factory<C>::Create(discrete_device * pdev, const discrete_sound_block *block)
+discrete_base_node * discrete_node_factory<C>::Create(discrete_device * pdev, const discrete_block *block)
{
discrete_base_node *r = auto_alloc_clear(pdev->machine, C);
@@ -4531,8 +4585,8 @@ discrete_base_node * discrete_node_factory<C>::Create(discrete_device * pdev, co
*
*************************************/
-#define DISCRETE_SOUND_EXTERN(name) extern const discrete_sound_block name##_discrete_interface[]
-#define DISCRETE_SOUND_START(name) const discrete_sound_block name##_discrete_interface[] = {
+#define DISCRETE_SOUND_EXTERN(name) extern const discrete_block name##_discrete_interface[]
+#define DISCRETE_SOUND_START(name) const discrete_block name##_discrete_interface[] = {
#define DSC_SND_ENTRY(_nod, _class, _dss, _num, _iact, _iinit, _custom, _name) { _nod, new discrete_node_factory< DISCRETE_CLASS_NAME(_class) >, _dss, _num, _iact, _iinit, _custom, _name, # _class }