diff options
Diffstat (limited to 'src/emu/machine/netlist.c')
-rw-r--r-- | src/emu/machine/netlist.c | 77 |
1 files changed, 44 insertions, 33 deletions
diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c index 125f34c9f33..8db7fa3feb4 100644 --- a/src/emu/machine/netlist.c +++ b/src/emu/machine/netlist.c @@ -13,6 +13,7 @@ #include "netlist/nl_base.h" #include "netlist/nl_setup.h" #include "netlist/nl_factory.h" +#include "netlist/nl_parser.h" #include "netlist/devices/net_lib.h" #include "debugger.h" @@ -62,8 +63,8 @@ void netlist_mame_analog_input_t::static_set_name(device_t &device, const char * void netlist_mame_analog_input_t::device_start() { LOG_DEV_CALLS(("start %s\n", tag())); - netlist_param_t *p = this->nl_owner().setup().find_param(m_param_name); - m_param = dynamic_cast<netlist_param_double_t *>(p); + netlist::param_t *p = this->nl_owner().setup().find_param(m_param_name); + m_param = dynamic_cast<netlist::param_double_t *>(p); if (m_param == NULL) { fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr()); @@ -94,12 +95,12 @@ void netlist_mame_analog_output_t::static_set_params(device_t &device, const cha netlist.m_delegate = adelegate; } -void netlist_mame_analog_output_t::custom_netlist_additions(netlist_setup_t &setup) +void netlist_mame_analog_output_t::custom_netlist_additions(netlist::setup_t &setup) { pstring dname = "OUT_" + m_in; m_delegate.bind_relative_to(owner()->machine().root_device()); NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>( - setup.register_dev("nld_analog_callback", dname)); + setup.register_dev("NETDEV_CALLBACK", dname)); dev->register_callback(m_delegate); setup.register_link(dname + ".IN", m_in); @@ -136,8 +137,8 @@ void netlist_mame_logic_input_t::static_set_params(device_t &device, const char void netlist_mame_logic_input_t::device_start() { LOG_DEV_CALLS(("start %s\n", tag())); - netlist_param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name); - m_param = dynamic_cast<netlist_param_int_t *>(p); + netlist::param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name); + m_param = dynamic_cast<netlist::param_int_t *>(p); if (m_param == NULL) { fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr()); @@ -168,11 +169,11 @@ void netlist_mame_stream_input_t::device_start() LOG_DEV_CALLS(("start %s\n", tag())); } -void netlist_mame_stream_input_t::custom_netlist_additions(netlist_setup_t &setup) +void netlist_mame_stream_input_t::custom_netlist_additions(netlist::setup_t &setup) { NETLIB_NAME(sound_in) *snd_in = setup.netlist().get_first_device<NETLIB_NAME(sound_in)>(); if (snd_in == NULL) - snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.register_dev("nld_sound_in", "STREAM_INPUT")); + snd_in = dynamic_cast<NETLIB_NAME(sound_in) *>(setup.register_dev("NETDEV_SOUND_IN", "STREAM_INPUT")); pstring sparam = pstring::sprintf("STREAM_INPUT.CHAN%d", m_channel); setup.register_param(sparam, m_param_name); @@ -206,13 +207,13 @@ void netlist_mame_stream_output_t::device_start() LOG_DEV_CALLS(("start %s\n", tag())); } -void netlist_mame_stream_output_t::custom_netlist_additions(netlist_setup_t &setup) +void netlist_mame_stream_output_t::custom_netlist_additions(netlist::setup_t &setup) { //NETLIB_NAME(sound_out) *snd_out; pstring sname = pstring::sprintf("STREAM_OUT_%d", m_channel); //snd_out = dynamic_cast<NETLIB_NAME(sound_out) *>(setup.register_dev("nld_sound_out", sname)); - setup.register_dev("nld_sound_out", sname); + setup.register_dev("NETDEV_SOUND_OUT", sname); setup.register_param(sname + ".CHAN" , m_channel); setup.register_param(sname + ".MULT", m_mult); @@ -256,7 +257,7 @@ netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, cons m_icount(0), m_div(0), m_rem(0), - m_old(netlist_time::zero), + m_old(netlist::netlist_time::zero), m_netlist(NULL), m_setup(NULL), m_setup_func(NULL) @@ -268,14 +269,14 @@ netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, devi m_icount(0), m_div(0), m_rem(0), - m_old(netlist_time::zero), + m_old(netlist::netlist_time::zero), m_netlist(NULL), m_setup(NULL), m_setup_func(NULL) { } -void netlist_mame_device_t::static_set_constructor(device_t &device, void (*setup_func)(netlist_setup_t &)) +void netlist_mame_device_t::static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &)) { LOG_DEV_CALLS(("static_set_constructor\n")); netlist_mame_device_t &netlist = downcast<netlist_mame_device_t &>(device); @@ -293,8 +294,8 @@ void netlist_mame_device_t::device_start() //printf("clock is %d\n", clock()); - m_netlist = global_alloc_clear(netlist_mame_t(*this)); - m_setup = global_alloc_clear(netlist_setup_t(*m_netlist)); + m_netlist = global_alloc(netlist_mame_t(*this)); + m_setup = global_alloc(netlist::setup_t(m_netlist)); netlist().init_object(*m_netlist, "netlist"); m_setup->init(); @@ -324,7 +325,7 @@ void netlist_mame_device_t::device_start() save_state(); - m_old = netlist_time::zero; + m_old = netlist::netlist_time::zero; m_rem = 0; } @@ -332,7 +333,7 @@ void netlist_mame_device_t::device_start() void netlist_mame_device_t::device_clock_changed() { //printf("device_clock_changed\n"); - m_div = netlist_time::from_hz(clock()).as_raw(); + m_div = netlist::netlist_time::from_hz(clock()).as_raw(); //m_rem = 0; //NL_VERBOSE_OUT(("Setting clock %" I64FMT "d and divisor %d\n", clock(), m_div)); NL_VERBOSE_OUT(("Setting clock %d and divisor %d\n", clock(), m_div)); @@ -343,7 +344,7 @@ void netlist_mame_device_t::device_clock_changed() void netlist_mame_device_t::device_reset() { LOG_DEV_CALLS(("device_reset\n")); - m_old = netlist_time::zero; + m_old = netlist::netlist_time::zero; m_rem = 0; netlist().do_reset(); } @@ -382,7 +383,7 @@ void netlist_mame_device_t::device_timer(emu_timer &timer, device_timer_id id, i ATTR_HOT ATTR_ALIGN void netlist_mame_device_t::update_time_x() { - const netlist_time delta = netlist().time() - m_old + netlist_time::from_raw(m_rem); + const netlist::netlist_time delta = netlist().time() - m_old + netlist::netlist_time::from_raw(m_rem); m_old = netlist().time(); m_icount -= divu_64x32_rem(delta.as_raw(), m_div, &m_rem); } @@ -458,7 +459,7 @@ void netlist_mame_cpu_device_t::device_start() { netlist_mame_device_t::device_start(); - LOG_DEV_CALLS(("device_start %s\n", tag())); + LOG_DEV_CALLS(("cpu device_start %s\n", tag())); // State support @@ -466,14 +467,14 @@ void netlist_mame_cpu_device_t::device_start() for (int i=0; i < netlist().m_nets.size(); i++) { - netlist_net_t *n = netlist().m_nets[i]; - if (n->isFamily(netlist_object_t::LOGIC)) + netlist::net_t *n = netlist().m_nets[i]; + if (n->isFamily(netlist::object_t::LOGIC)) { - state_add(i*2, n->name(), downcast<netlist_logic_net_t *>(n)->Q_state_ptr()); + state_add(i*2, n->name(), downcast<netlist::logic_net_t *>(n)->Q_state_ptr()); } else { - state_add(i*2+1, n->name(), downcast<netlist_analog_net_t *>(n)->Q_Analog_state_ptr()).formatstr("%20s"); + state_add(i*2+1, n->name(), downcast<netlist::analog_net_t *>(n)->Q_Analog_state_ptr()).formatstr("%20s"); } } @@ -528,13 +529,13 @@ ATTR_HOT void netlist_mame_cpu_device_t::execute_run() m_genPC++; m_genPC &= 255; debugger_instruction_hook(this, m_genPC); - netlist().process_queue(netlist_time::from_raw(m_div)); + netlist().process_queue(netlist::netlist_time::from_raw(m_div)); update_time_x(); } } else { - netlist().process_queue(netlist_time::from_raw(m_div) * m_icount); + netlist().process_queue(netlist::netlist_time::from_raw(m_div) * m_icount); update_time_x(); } } @@ -549,12 +550,11 @@ netlist_mame_sound_device_t::netlist_mame_sound_device_t(const machine_config &m { } - void netlist_mame_sound_device_t::device_start() { netlist_mame_device_t::device_start(); - LOG_DEV_CALLS(("device_start %s\n", tag())); + LOG_DEV_CALLS(("sound device_start %s\n", tag())); // Configure outputs @@ -575,7 +575,7 @@ void netlist_mame_sound_device_t::device_start() if (chan < 0 || chan >= MAX_OUT || chan >= outdevs.size()) fatalerror("illegal channel number"); m_out[chan] = outdevs[i]; - m_out[chan]->m_sample = netlist_time::from_hz(clock()); + m_out[chan]->m_sample = netlist::netlist_time::from_hz(clock()); m_out[chan]->m_buffer = NULL; } @@ -591,7 +591,7 @@ void netlist_mame_sound_device_t::device_start() { m_in = indevs[0]; m_num_inputs = m_in->resolve(); - m_in->m_inc = netlist_time::from_hz(clock()); + m_in->m_inc = netlist::netlist_time::from_hz(clock()); } /* initialize the stream(s) */ @@ -621,11 +621,11 @@ void netlist_mame_sound_device_t::sound_stream_update(sound_stream &stream, stre m_in->m_buffer[i] = inputs[i]; } - netlist_time cur = netlist().time(); + netlist::netlist_time cur = netlist().time(); - netlist().process_queue(netlist_time::from_raw(m_div) * samples); + netlist().process_queue(netlist::netlist_time::from_raw(m_div) * samples); - cur += (netlist_time::from_raw(m_div) * samples); + cur += (netlist::netlist_time::from_raw(m_div) * samples); for (int i=0; i < m_num_outputs; i++) { @@ -633,3 +633,14 @@ void netlist_mame_sound_device_t::sound_stream_update(sound_stream &stream, stre m_out[i]->buffer_reset(cur); } } + +// ---------------------------------------------------------------------------------------- +// memregion source support +// ---------------------------------------------------------------------------------------- + +bool netlist_source_memregion_t::parse(netlist::setup_t *setup, const pstring name) +{ + const char *mem = (const char *)downcast<netlist_mame_t &>(setup->netlist()).machine().root_device().memregion(m_name.cstr())->base(); + netlist::parser_t p(*setup); + return p.parse(mem, name); +} |