summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Couriersud <couriersud@users.noreply.github.com>2013-12-16 21:50:54 +0000
committer Couriersud <couriersud@users.noreply.github.com>2013-12-16 21:50:54 +0000
commit210a6c984614ac369bce5b4d3fc334c59bdb6c06 (patch)
treeec3a9963b336f064e6945e2d8ea1804cb56acac7 /src
parent5767d13911ee915ed2cbbbb32a06110c0e268159 (diff)
Netlist & pong:
- update the parser code - the "rom" netlist and preprocessor netlist are now aligned again. - got rid of fatalerror in netlist/* code. Implementing applications have to implement fatalerror in a derived class from netlist_base_t now.
Diffstat (limited to 'src')
-rw-r--r--src/emu/machine/netlist.c2
-rw-r--r--src/emu/machine/netlist.h8
-rw-r--r--src/emu/netlist/devices/net_lib.c4
-rw-r--r--src/emu/netlist/devices/nld_solver.c11
-rw-r--r--src/emu/netlist/devices/nld_solver.h14
-rw-r--r--src/emu/netlist/nl_base.c26
-rw-r--r--src/emu/netlist/nl_base.h10
-rw-r--r--src/emu/netlist/nl_config.h2
-rw-r--r--src/emu/netlist/nl_parser.c71
-rw-r--r--src/emu/netlist/nl_parser.h2
-rw-r--r--src/emu/netlist/nl_setup.c40
-rw-r--r--src/emu/netlist/nl_setup.h1
-rw-r--r--src/emu/netlist/pstring.c10
-rw-r--r--src/emu/netlist/pstring.h4
-rw-r--r--src/mame/drivers/pong.c76
15 files changed, 171 insertions, 110 deletions
diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c
index 94024f86355..7ff8e043be8 100644
--- a/src/emu/machine/netlist.c
+++ b/src/emu/machine/netlist.c
@@ -97,7 +97,7 @@ void netlist_mame_device::device_start()
allok &= ods->object()->OnDeviceStart();
if (!allok)
- fatalerror("required elements not found\n");
+ m_netlist->xfatalerror("required elements not found\n");
m_setup->resolve_inputs();
diff --git a/src/emu/machine/netlist.h b/src/emu/machine/netlist.h
index 3ee8526af38..ec27f63273c 100644
--- a/src/emu/machine/netlist.h
+++ b/src/emu/machine/netlist.h
@@ -99,6 +99,14 @@ public:
netlist_mame_device &parent() { return m_parent; }
+protected:
+
+ void vfatalerror(const char *format, va_list ap) const
+ {
+ emu_fatalerror error(format, ap);
+ throw error;
+ }
+
private:
netlist_mame_device &m_parent;
};
diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c
index 3082082ca43..93694000426 100644
--- a/src/emu/netlist/devices/net_lib.c
+++ b/src/emu/netlist/devices/net_lib.c
@@ -410,7 +410,7 @@ netlist_device_t *netlist_factory::new_device_by_classname(const pstring &classn
}
p++;
}
- fatalerror("Class %s not found!\n", classname.cstr());
+ setup.netlist().xfatalerror("Class %s not found!\n", classname.cstr());
return NULL; // appease code analysis
}
@@ -426,7 +426,7 @@ netlist_device_t *netlist_factory::new_device_by_name(const pstring &name, netli
}
p++;
}
- fatalerror("Class %s not found!\n", name.cstr());
+ setup.netlist().xfatalerror("Class %s not found!\n", name.cstr());
return NULL; // appease code analysis
}
diff --git a/src/emu/netlist/devices/nld_solver.c b/src/emu/netlist/devices/nld_solver.c
index 1371a91a881..879e09dd691 100644
--- a/src/emu/netlist/devices/nld_solver.c
+++ b/src/emu/netlist/devices/nld_solver.c
@@ -11,8 +11,9 @@
// ----------------------------------------------------------------------------------------
-ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets)
+ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &aowner)
{
+ m_owner = &aowner;
for (netlist_net_t::list_t::entry_t *pn = nets.first(); pn != NULL; pn = nets.next(pn))
{
NL_VERBOSE_OUT(("setting up net\n"));
@@ -49,7 +50,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets)
NL_VERBOSE_OUT(("Added input\n"));
break;
default:
- fatalerror("unhandled element found\n");
+ owner().netlist().xfatalerror("unhandled element found\n");
break;
}
}
@@ -158,7 +159,7 @@ ATTR_HOT inline bool netlist_matrix_solver_t::solve()
net->m_cur.Analog = net->m_new.Analog = new_val;
NL_VERBOSE_OUT(("Info: %d\n", pn->object()->m_num_cons));
- NL_VERBOSE_OUT(("New: %lld %f %f\n", netlist().time().as_raw(), netlist().time().as_double(), new_val));
+ //NL_VERBOSE_OUT(("New: %lld %f %f\n", netlist().time().as_raw(), netlist().time().as_double(), new_val));
}
return resched;
}
@@ -278,10 +279,10 @@ NETLIB_FUNC_VOID(solver, post_start, ())
printf("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count());
for (int i = 0; i <= cur_group; i++)
{
- netlist_matrix_solver_t *ms = new netlist_matrix_solver_t;
+ netlist_matrix_solver_t *ms = new netlist_matrix_solver_t();
ms->m_accuracy = m_accuracy.Value();
ms->m_convergence_factor = m_convergence.Value();
- ms->setup(groups[i]);
+ ms->setup(groups[i], *this);
m_mat_solvers.add(ms);
printf("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr());
printf(" has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic");
diff --git a/src/emu/netlist/devices/nld_solver.h b/src/emu/netlist/devices/nld_solver.h
index 04f9212f7ee..2598e4632f4 100644
--- a/src/emu/netlist/devices/nld_solver.h
+++ b/src/emu/netlist/devices/nld_solver.h
@@ -20,12 +20,15 @@
// solver
// ----------------------------------------------------------------------------------------
+class NETLIB_NAME(solver);
+
class netlist_matrix_solver_t
{
public:
typedef netlist_list_t<netlist_matrix_solver_t *> list_t;
typedef netlist_core_device_t::list_t dev_list_t;
- ATTR_COLD void setup(netlist_net_t::list_t &nets);
+
+ ATTR_COLD void setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &owner);
// return true if a reschedule is needed ...
ATTR_HOT bool solve();
@@ -34,6 +37,8 @@ public:
ATTR_HOT inline bool is_dynamic() { return m_dynamic.count() > 0; }
+ inline const NETLIB_NAME(solver) &owner() const;
+
double m_accuracy;
double m_convergence_factor;
@@ -42,6 +47,8 @@ private:
dev_list_t m_dynamic;
dev_list_t m_inps;
dev_list_t m_steps;
+
+ NETLIB_NAME(solver) *m_owner;
};
NETLIB_DEVICE_WITH_PARAMS(solver,
@@ -81,5 +88,10 @@ inline void NETLIB_NAME(solver)::schedule()
m_Q_sync.net().push_to_queue(m_nt_sync_delay);
}
+inline const NETLIB_NAME(solver) &netlist_matrix_solver_t::owner() const
+{
+ return *m_owner;
+}
+
#endif /* NLD_SOLVER_H_ */
diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c
index e6d7b628721..699ddc04914 100644
--- a/src/emu/netlist/nl_base.c
+++ b/src/emu/netlist/nl_base.c
@@ -34,7 +34,7 @@ ATTR_COLD void netlist_object_t::init_object(netlist_base_t &nl, const pstring &
ATTR_COLD const pstring &netlist_object_t::name() const
{
if (m_name == "")
- fatalerror("object not initialized");
+ netlist().xfatalerror("object not initialized");
return m_name;
}
@@ -139,7 +139,7 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(INT32 &atime)
if (FATAL_ERROR_AFTER_NS)
if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
- fatalerror("Stopped");
+ xfatalerror("Stopped");
}
if (atime > 0)
@@ -175,7 +175,7 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(INT32 &atime)
}
if (FATAL_ERROR_AFTER_NS)
if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
- fatalerror("Stopped");
+ xfatalerror("Stopped");
add_to_stat(m_perf_out_processed, 1);
}
@@ -188,6 +188,17 @@ ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(INT32 &atime)
}
}
+ATTR_COLD void netlist_base_t::xfatalerror(const char *format, ...) const
+{
+ va_list ap;
+ va_start(ap, format);
+ //emu_fatalerror error(format, ap);
+ vfatalerror(format, ap);
+ va_end(ap);
+ //throw error;
+}
+
+
// ----------------------------------------------------------------------------------------
// Default netlist elements ...
// ----------------------------------------------------------------------------------------
@@ -325,7 +336,7 @@ static void init_term(netlist_core_device_t &dev, netlist_core_terminal_t &term,
dynamic_cast<netlist_terminal_t &>(term).init_object(dev, "internal terminal", aState);
break;
default:
- fatalerror("Unknown terminal type");
+ dev.netlist().xfatalerror("Unknown terminal type");
break;
}
}
@@ -373,9 +384,6 @@ ATTR_COLD netlist_net_t::netlist_net_t(const type_t atype, const family_t afamil
, m_in_queue(2)
, m_railterminal(NULL)
{
- m_cur.Q = 0;
- m_new.Q = 0;
- m_last.Q = 0;
};
ATTR_COLD void netlist_net_t::register_railterminal(netlist_output_t &mr)
@@ -391,7 +399,7 @@ ATTR_COLD void netlist_net_t::merge_net(netlist_net_t *othernet)
return; // Nothing to do
if (this->isRailNet() && othernet->isRailNet())
- fatalerror("Trying to merge to rail nets\n");
+ netlist().xfatalerror("Trying to merge to rail nets\n");
if (othernet->isRailNet())
{
@@ -565,7 +573,7 @@ ATTR_COLD double netlist_param_model_t::dValue(const pstring &entity, const doub
tmp = tmp.substr(p, pblank - p);
int pequal = tmp.find("=", 0);
if (pequal < 0)
- fatalerror("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr());
+ netlist().xfatalerror("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr());
tmp = tmp.substr(pequal+1);
double factor = 1.0;
switch (*(tmp.right(1).cstr()))
diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h
index e194ed04b9b..f140b1e0f11 100644
--- a/src/emu/netlist/nl_base.h
+++ b/src/emu/netlist/nl_base.h
@@ -489,11 +489,12 @@ public:
friend class netlist_analog_output_t;
// FIXME: union does not work
- typedef struct
+ struct hybrid_t
{
+ inline hybrid_t() : Q(0), Analog(0.0) {}
netlist_sig_t Q;
double Analog;
- } hybrid_t;
+ };
ATTR_COLD netlist_net_t(const type_t atype, const family_t afamily);
@@ -939,7 +940,12 @@ public:
ATTR_COLD void reset();
+ ATTR_COLD void xfatalerror(const char *format, ...) const;
+
protected:
+
+ // any derived netlist must override this ...
+ virtual void vfatalerror(const char *format, va_list ap) const = 0;
#if (NL_KEEP_STATISTICS)
// performance
int m_perf_out_processed;
diff --git a/src/emu/netlist/nl_config.h b/src/emu/netlist/nl_config.h
index d6c26c851d1..63f8e8c8c6c 100644
--- a/src/emu/netlist/nl_config.h
+++ b/src/emu/netlist/nl_config.h
@@ -47,6 +47,8 @@ typedef UINT8 netlist_sig_t;
// DEBUGGING
//============================================================
+#define fatalerror xxbreakme
+
#define NL_VERBOSE (0)
#define NL_KEEP_STATISTICS (0)
#define FATAL_ERROR_AFTER_NS (0) //(1000)
diff --git a/src/emu/netlist/nl_parser.c b/src/emu/netlist/nl_parser.c
index 71bf1785e69..b1ef2cf33bd 100644
--- a/src/emu/netlist/nl_parser.c
+++ b/src/emu/netlist/nl_parser.c
@@ -23,8 +23,18 @@ void netlist_parser::parse(char *buf)
NL_VERBOSE_OUT(("Parser: Device: %s\n", n.cstr()));
if (n == "NET_ALIAS")
net_alias();
+ else if (n == "NET_C")
+ net_c();
else if (n == "NETDEV_PARAM")
netdev_param();
+ else if (n == "NETDEV_R")
+ netdev_device(n, "R");
+ else if (n == "NETDEV_C")
+ netdev_device(n, "C");
+ else if (n == "NETDEV_POT")
+ netdev_device(n, "R");
+ else if (n == "NETDEV_D")
+ netdev_device(n, "model", true);
else if ((n == "NETDEV_TTL_CONST") || (n == "NETDEV_ANALOG_CONST"))
netdev_const(n);
else
@@ -44,6 +54,18 @@ void netlist_parser::net_alias()
m_setup.register_alias(alias, out);
}
+void netlist_parser::net_c()
+{
+ pstring t1;
+ pstring t2;
+ skipws();
+ t1 = getname(',');
+ skipws();
+ t2 = getname(')');
+ NL_VERBOSE_OUT(("Parser: Connect: %s %s\n", t1.cstr(), t2.cstr()));
+ m_setup.register_link(t1 , t2);
+}
+
void netlist_parser::netdev_param()
{
pstring param;
@@ -113,6 +135,39 @@ void netlist_parser::netdev_device(const pstring &dev_type)
check_char(')');
}
+void netlist_parser::netdev_device(const pstring &dev_type, const pstring &default_param, bool isString)
+{
+ netlist_device_t *dev;
+
+ skipws();
+ pstring devname = getname2(',', ')');
+ pstring defparam = devname + "." + default_param;
+ dev = m_setup.factory().new_device_by_name(dev_type, m_setup);
+ m_setup.register_dev(dev, devname);
+ skipws();
+ NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr()));
+ if (*m_p != ')')
+ {
+ // have a default param
+ m_p++;
+ skipws();
+ if (isString)
+ {
+ pstring val = getname(')');
+ m_p--;
+ NL_VERBOSE_OUT(("Parser: Default param: %s %s\n", defparam.cstr(), val.cstr()));
+ m_setup.register_param(defparam, val);
+ }
+ else
+ {
+ double val = eval_param();
+ NL_VERBOSE_OUT(("Parser: Default param: %s %f\n", defparam.cstr(), val));
+ m_setup.register_param(defparam, val);
+ }
+ }
+ check_char(')');
+}
+
// ----------------------------------------------------------------------------------------
// private
// ----------------------------------------------------------------------------------------
@@ -146,7 +201,17 @@ void netlist_parser::skipws()
break;
case '/':
if (*(m_p+1) == '/')
- skipeol();
+ {
+ skipeol();
+ }
+ else if (*(m_p+1) == '*')
+ {
+ m_p+=2;
+ while (*m_p && !(*m_p == '*' && *(m_p + 1) == '/' ))
+ m_p++;
+ if (*m_p)
+ m_p += 2;
+ }
break;
default:
return;
@@ -185,7 +250,7 @@ void netlist_parser::check_char(char ctocheck)
m_p++;
return;
}
- fatalerror("Parser: expected '%c' found '%c'\n", ctocheck, *m_p);
+ m_setup.netlist().xfatalerror("Parser: expected '%c' found '%c'\n", ctocheck, *m_p);
}
double netlist_parser::eval_param()
@@ -203,7 +268,7 @@ double netlist_parser::eval_param()
f = i;
ret = strtod(s+strlen(macs[f]), &e);
if ((f>0) && (*e != ')'))
- fatalerror("Parser: Error with parameter ...\n");
+ m_setup.netlist().xfatalerror("Parser: Error with parameter ...\n");
if (f>0)
e++;
m_p = e;
diff --git a/src/emu/netlist/nl_parser.h b/src/emu/netlist/nl_parser.h
index 892c167c660..690a5d03b26 100644
--- a/src/emu/netlist/nl_parser.h
+++ b/src/emu/netlist/nl_parser.h
@@ -19,8 +19,10 @@ public:
void parse(char *buf);
void net_alias();
void netdev_param();
+ void net_c();
void netdev_const(const pstring &dev_name);
void netdev_device(const pstring &dev_type);
+ void netdev_device(const pstring &dev_type, const pstring &default_param, bool isString = false);
private:
diff --git a/src/emu/netlist/nl_setup.c b/src/emu/netlist/nl_setup.c
index 0e8d18aaf3a..86c847e7fa0 100644
--- a/src/emu/netlist/nl_setup.c
+++ b/src/emu/netlist/nl_setup.c
@@ -62,7 +62,7 @@ netlist_setup_t::~netlist_setup_t()
netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const pstring &name)
{
if (!(m_devices.add(name, dev, false)==TMERR_NONE))
- fatalerror("Error adding %s to device list\n", name.cstr());
+ netlist().xfatalerror("Error adding %s to device list\n", name.cstr());
return dev;
}
@@ -88,7 +88,7 @@ void netlist_setup_t::remove_dev(const pstring &name)
netlist_device_t *dev = m_devices.find(name);
pstring temp = name + ".";
if (dev == NULL)
- fatalerror("Device %s does not exist\n", name.cstr());
+ netlist().xfatalerror("Device %s does not exist\n", name.cstr());
//remove_start_with<tagmap_input_t>(m_inputs, temp);
remove_start_with<tagmap_terminal_t>(m_terminals, temp);
@@ -124,7 +124,7 @@ void netlist_setup_t::register_alias(const pstring &alias, const pstring &out)
{
//if (!(m_alias.add(alias, new nstring(out), false)==TMERR_NONE))
if (!(m_alias.add(alias, out, false)==TMERR_NONE))
- fatalerror("Error adding alias %s to alias list\n", alias.cstr());
+ netlist().xfatalerror("Error adding alias %s to alias list\n", alias.cstr());
}
pstring netlist_setup_t::objtype_as_astr(netlist_object_t &in)
@@ -150,7 +150,9 @@ pstring netlist_setup_t::objtype_as_astr(netlist_object_t &in)
return "DEVICE";
break;
}
- fatalerror("Unknown object type %d\n", in.type());
+ // FIXME: noreturn
+ netlist().xfatalerror("Unknown object type %d\n", in.type());
+ return "Error";
}
void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device_t &upd_dev, const pstring &name, netlist_object_t &obj, const netlist_input_t::state_e state)
@@ -168,7 +170,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
term.init_object(upd_dev, dev.name() + "." + name, state);
if (!(m_terminals.add(term.name(), &term, false)==TMERR_NONE))
- fatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr());
+ netlist().xfatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr());
NL_VERBOSE_OUT(("%s %s\n", objtype_as_astr(term).cstr(), name.cstr()));
}
break;
@@ -189,7 +191,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
//printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
double vald = 0;
if (sscanf(val.cstr(), "%lf", &vald) != 1)
- fatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
+ netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
dynamic_cast<netlist_param_double_t &>(param).initial(vald);
}
break;
@@ -199,7 +201,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
//printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
int vald = 0;
if (sscanf(val.cstr(), "%d", &vald) != 1)
- fatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
+ netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
dynamic_cast<netlist_param_int_t &>(param).initial(vald);
}
break;
@@ -224,15 +226,15 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
}
}
if (!found)
- fatalerror("Model %s not found\n", val.cstr());
+ netlist().xfatalerror("Model %s not found\n", val.cstr());
}
break;
default:
- fatalerror("Parameter is not supported %s : %s\n", temp.cstr(), val.cstr());
+ netlist().xfatalerror("Parameter is not supported %s : %s\n", temp.cstr(), val.cstr());
}
}
if (!(m_params.add(temp, &param, false)==TMERR_NONE))
- fatalerror("Error adding parameter %s to parameter list\n", name.cstr());
+ netlist().xfatalerror("Error adding parameter %s to parameter list\n", name.cstr());
}
break;
case netlist_terminal_t::DEVICE:
@@ -259,7 +261,7 @@ void netlist_setup_t::register_param(const pstring &param, const pstring &value)
{
//if (!(m_params_temp.add(param, new nstring(value), false)==TMERR_NONE))
if (!(m_params_temp.add(param, value, false)==TMERR_NONE))
- fatalerror("Error adding parameter %s to parameter list\n", param.cstr());
+ netlist().xfatalerror("Error adding parameter %s to parameter list\n", param.cstr());
}
const pstring netlist_setup_t::resolve_alias(const pstring &name) const
@@ -279,7 +281,7 @@ const pstring netlist_setup_t::resolve_alias(const pstring &name) const
pstring dname = ret;
netlist_device_t *dev = m_devices.find(dname.substr(0,p));
if (dev == NULL)
- fatalerror("Device for %s not found\n", name.cstr());
+ netlist().xfatalerror("Device for %s not found\n", name.cstr());
int c = atoi(ret.substr(p+2,ret.len()-p-3));
temp = dev->name() + "." + dev->m_terminals[c];
// reresolve ....
@@ -307,7 +309,7 @@ netlist_core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_
ret = m_terminals.find(s);
}
if (ret == NULL && required)
- fatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
+ netlist().xfatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
if (ret != NULL)
NL_VERBOSE_OUT(("Found input %s\n", tname.cstr()));
return ret;
@@ -327,11 +329,11 @@ netlist_core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_
ret = m_terminals.find(s);
}
if (ret == NULL && required)
- fatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
+ netlist().xfatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
if (ret != NULL && ret->type() != atype)
{
if (required)
- fatalerror("object %s(%s) found but wrong type\n", terminal_in.cstr(), tname.cstr());
+ netlist().xfatalerror("object %s(%s) found but wrong type\n", terminal_in.cstr(), tname.cstr());
else
ret = NULL;
}
@@ -347,7 +349,7 @@ netlist_param_t *netlist_setup_t::find_param(const pstring &param_in, bool requi
ret = m_params.find(outname);
if (ret == NULL && required)
- fatalerror("parameter %s(%s) not found!\n", param_in.cstr(), outname.cstr());
+ netlist().xfatalerror("parameter %s(%s) not found!\n", param_in.cstr(), outname.cstr());
if (ret != NULL)
NL_VERBOSE_OUT(("Found parameter %s\n", outname.cstr()));
return ret;
@@ -414,7 +416,7 @@ void netlist_setup_t::connect_terminal_input(netlist_terminal_t &term, netlist_i
}
else
{
- fatalerror("Netlist: Severe Error");
+ netlist().xfatalerror("Netlist: Severe Error");
}
}
@@ -449,7 +451,7 @@ void netlist_setup_t::connect_terminal_output(netlist_terminal_t &in, netlist_ou
}
else
{
- fatalerror("Netlist: Severe Error");
+ netlist().xfatalerror("Netlist: Severe Error");
}
}
@@ -524,7 +526,7 @@ void netlist_setup_t::connect(netlist_core_terminal_t &t1, netlist_core_terminal
connect_terminals(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_terminal_t &>(t2));
}
else
- fatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr());
+ netlist().xfatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr());
}
void netlist_setup_t::resolve_inputs(void)
diff --git a/src/emu/netlist/nl_setup.h b/src/emu/netlist/nl_setup.h
index aef51dddf31..bdb4324e9a0 100644
--- a/src/emu/netlist/nl_setup.h
+++ b/src/emu/netlist/nl_setup.h
@@ -103,6 +103,7 @@ public:
~netlist_setup_t();
netlist_base_t &netlist() { return m_netlist; }
+ const netlist_base_t &netlist() const { return m_netlist; }
netlist_factory &factory() { return m_factory; }
netlist_device_t *register_dev(netlist_device_t *dev, const pstring &name);
diff --git a/src/emu/netlist/pstring.c b/src/emu/netlist/pstring.c
index 2499a8346b0..7588fa9a7b6 100644
--- a/src/emu/netlist/pstring.c
+++ b/src/emu/netlist/pstring.c
@@ -154,9 +154,9 @@ void *pblockpool::alloc(const std::size_t n)
return (char *) malloc(n);
else
{
- int min_alloc = MAX(m_blocksize, n+sizeof(memblock)-8);
- char *ret = NULL;
int memsize = ((n + m_align - 1) / m_align) * m_align;
+ int min_alloc = MAX(m_blocksize, memsize+sizeof(memblock)-MINDATASIZE);
+ char *ret = NULL;
//std::printf("m_first %p\n", m_first);
for (memblock *p = m_first; p != NULL && ret == NULL; p = p->next)
{
@@ -175,7 +175,7 @@ void *pblockpool::alloc(const std::size_t n)
memblock *p = (memblock *) malloc(min_alloc); //new char[min_alloc];
p->allocated = 0;
p->cur = &p->data[0];
- p->size = p->remaining = min_alloc - sizeof(memblock);
+ p->size = p->remaining = min_alloc - (sizeof(memblock)-MINDATASIZE);
p->next = m_first;
//std::printf("allocated block size %d\n", sizeof(p->data));
@@ -203,7 +203,7 @@ void pblockpool::dealloc(void *ptr)
{
p->allocated -= 1;
if (p->allocated < 0)
- fatalerror("nstring: memory corruption\n");
+ std::fprintf(stderr, "nstring: memory corruption - crash likely\n");
if (p->allocated == 0)
{
//std::printf("Block entirely freed\n");
@@ -216,7 +216,7 @@ void pblockpool::dealloc(void *ptr)
return;
}
}
- fatalerror("nstring: string <%p> not found\n", ptr);
+ std::fprintf(stderr, "nstring: string <%p> not found on free\n", ptr);
}
}
diff --git a/src/emu/netlist/pstring.h b/src/emu/netlist/pstring.h
index 04fba576b9a..65147f87a31 100644
--- a/src/emu/netlist/pstring.h
+++ b/src/emu/netlist/pstring.h
@@ -16,6 +16,8 @@
struct pblockpool {
+ static const int MINDATASIZE = 8;
+
struct memblock
{
memblock *next;
@@ -23,7 +25,7 @@ struct pblockpool {
int allocated;
int remaining;
char *cur;
- char data[8];
+ char data[MINDATASIZE];
};
pblockpool();
diff --git a/src/mame/drivers/pong.c b/src/mame/drivers/pong.c
index 132163b93e0..1ff4066a4b8 100644
--- a/src/mame/drivers/pong.c
+++ b/src/mame/drivers/pong.c
@@ -795,15 +795,10 @@ public:
m_srst(*this, "maincpu", "SRST"),
m_p_P0(*this, "maincpu", "ic_b9_POT.DIAL"),
m_p_P1(*this, "maincpu", "ic_a9_POT.DIAL"),
- m_p_V0(*this, "maincpu", "P1"), // pong - legacy
- m_p_V1(*this, "maincpu", "P2"), // pong - legacy
m_sw1a(*this, "maincpu", "sw1a.POS"),
m_sw1b(*this, "maincpu", "sw1b.POS"),
m_p_R0(*this, "maincpu", "ic_a9_R.R"),
- m_p_R1(*this, "maincpu", "ic_b9_R.R"),
- m_p_R0x(*this, "maincpu", "ic_a9.R"), // pong - legacy
- m_p_R1x(*this, "maincpu", "ic_b9.R"), // pong - legacy
- isRomPong(false)
+ m_p_R1(*this, "maincpu", "ic_b9_R.R")
{
}
@@ -814,18 +809,12 @@ public:
// sub devices
netlist_mame_device::required_output<netlist_logic_output_t> m_srst;
- netlist_mame_device::optional_param<netlist_param_double_t> m_p_P0;
- netlist_mame_device::optional_param<netlist_param_double_t> m_p_P1;
- netlist_mame_device::optional_output<netlist_analog_output_t> m_p_V0;
- netlist_mame_device::optional_output<netlist_analog_output_t> m_p_V1;
+ netlist_mame_device::required_param<netlist_param_double_t> m_p_P0;
+ netlist_mame_device::required_param<netlist_param_double_t> m_p_P1;
netlist_mame_device::required_param<netlist_param_int_t> m_sw1a;
netlist_mame_device::required_param<netlist_param_int_t> m_sw1b;
- netlist_mame_device::optional_param<netlist_param_double_t> m_p_R0;
- netlist_mame_device::optional_param<netlist_param_double_t> m_p_R1;
- netlist_mame_device::optional_param<netlist_param_double_t> m_p_R0x;
- netlist_mame_device::optional_param<netlist_param_double_t> m_p_R1x;
-
- bool isRomPong;
+ netlist_mame_device::required_param<netlist_param_double_t> m_p_R0;
+ netlist_mame_device::required_param<netlist_param_double_t> m_p_R1;
UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
@@ -876,10 +865,6 @@ NETLIST_END
void pong_state::machine_start()
{
- if (strcmp(this->shortname(),"pong")==0)
- {
- isRomPong = true;
- }
}
void pong_state::machine_reset()
@@ -894,10 +879,6 @@ void pong_state::video_start()
INPUT_CHANGED_MEMBER(pong_state::input_changed)
{
- static const double NE555_R = RES_K(5);
- static const double PRE_R = RES_R(470);
- static const double POT_R = RES_K(1);
-
double pad;
int numpad = (FPTR) (param);
@@ -910,29 +891,11 @@ INPUT_CHANGED_MEMBER(pong_state::input_changed)
double fac = (double) newval / (double) 256;
fac = (exp(fac) - 1.0) / (exp(1.0) -1.0) ;
- double R1 = fac * POT_R;
- double R3 = (1.0 - fac) * POT_R;
- double vA = 5.0 * R3 / (R3 + R1);
- double vB = 5.0 * 2 * NE555_R / (2 * NE555_R + NE555_R);
- double Req = RES_2_PARALLEL(R1, R3) + RES_2_PARALLEL(NE555_R, 2.0 * NE555_R);
- double pad = vA + (vB - vA)*PRE_R / (Req + PRE_R);
- if (!isRomPong)
- {
- switch (numpad)
- {
- case IC_PADDLE1: m_p_P0->setTo(fac); break;
- case IC_PADDLE2: m_p_P1->setTo(fac); break;
- }
- }
- else
- {
- switch (numpad)
- {
- case IC_PADDLE1: m_p_V0->set_Q(pad, NLTIME_FROM_NS(0)); break;
- case IC_PADDLE2: m_p_V1->set_Q(pad, NLTIME_FROM_NS(0)); break;
- }
- }
- //printf("%d %f\n", newval, (float) pad);
+ switch (numpad)
+ {
+ case IC_PADDLE1: m_p_P0->setTo(fac); break;
+ case IC_PADDLE2: m_p_P1->setTo(fac); break;
+ }
break;
}
case IC_SWITCH:
@@ -945,21 +908,10 @@ INPUT_CHANGED_MEMBER(pong_state::input_changed)
case IC_VR1:
case IC_VR2:
pad = (double) newval / (double) 100 * RES_K(50) + RES_K(56);
- if (!isRomPong)
- {
- switch (numpad)
- {
- case IC_VR1: m_p_R0->setTo(pad); break;
- case IC_VR2: m_p_R1->setTo(pad); break;
- }
- }
- else
+ switch (numpad)
{
- switch (numpad)
- {
- case IC_VR1: m_p_R0x->setTo(pad); break;
- case IC_VR2: m_p_R1x->setTo(pad); break;
- }
+ case IC_VR1: m_p_R0->setTo(pad); break;
+ case IC_VR2: m_p_R1->setTo(pad); break;
}
break;
}
@@ -1022,7 +974,7 @@ MACHINE_CONFIG_END
ROM_START( pong ) /* dummy to satisfy game entry*/
ROM_REGION( 0x10000, "maincpu", 0 ) /* enough for netlist */
- ROM_LOAD( "pong.netlist", 0x000000, 0x0029e4, CRC(e9c409a1) SHA1(1dc99437f49261c3cb3f46153c6258043bc720a0) )
+ ROM_LOAD( "pong.netlist", 0x000000, 0x003f24, CRC(cc99883b) SHA1(87ea6ec8772db7bf4047695d4c3513fa1a52b6b8) )
ROM_END
ROM_START( pongf ) /* dummy to satisfy game entry*/