Remove dependencies on mame headers in netlist code. (nw)

This commit is contained in:
couriersud 2015-01-17 14:35:34 +01:00
parent 597f5e536b
commit 9092d623d6
24 changed files with 118 additions and 87 deletions

View File

@ -75,7 +75,7 @@ NETLIB_START(QBJT_switch)
connect(m_RB.m_P, m_BC_dummy.m_P);
connect(m_RC.m_P, m_BC_dummy.m_N);
save(NAME(m_state_on));
save(NLNAME(m_state_on));
m_RB.set(netlist().gmin(), 0.0, 0.0);
m_RC.set(netlist().gmin(), 0.0, 0.0);

View File

@ -88,7 +88,7 @@ public:
vector_ops_impl_t(int size)
: vector_ops_t(size)
{
assert(m_N == 0);
nl_assert(m_N == 0);
}
virtual ~vector_ops_impl_t() {}

View File

@ -51,7 +51,7 @@ NETLIB_START(4020_sub)
register_output("Q13", m_Q[12]);
register_output("Q14", m_Q[13]);
save(NAME(m_cnt));
save(NLNAME(m_cnt));
}
NETLIB_RESET(4020_sub)

View File

@ -11,9 +11,9 @@ NETLIB_START(74107Asub)
register_output("Q", m_Q);
register_output("QQ", m_QQ);
save(NAME(m_Q1));
save(NAME(m_Q2));
save(NAME(m_F));
save(NLNAME(m_Q1));
save(NLNAME(m_Q2));
save(NLNAME(m_F));
}
NETLIB_RESET(74107Asub)

View File

@ -32,9 +32,9 @@ NETLIB_START(74123)
connect(m_RN.m_P, m_RP.m_N);
connect(m_CV, m_RN.m_P);
save(NAME(m_last_trig));
save(NAME(m_state));
save(NAME(m_KP));
save(NLNAME(m_last_trig));
save(NLNAME(m_state));
save(NLNAME(m_KP));
m_KP = 1.0 / (1.0 + exp(m_K.Value()));
}

View File

@ -22,7 +22,7 @@ NETLIB_START(74153sub)
m_chan = 0;
save(NAME(m_chan));
save(NLNAME(m_chan));
}
NETLIB_RESET(74153sub)

View File

@ -78,7 +78,7 @@ NETLIB_START(7448_sub)
register_output("f", m_f);
register_output("g", m_g);
save(NAME(m_state));
save(NLNAME(m_state));
}
NETLIB_RESET(7448_sub)
@ -98,7 +98,7 @@ NETLIB_UPDATE(7448_sub)
NETLIB_FUNC_VOID(7448_sub, update_outputs, (UINT8 v))
{
assert(v<16);
nl_assert(v<16);
if (v != m_state)
{
// max transfer time is 100 NS */

View File

@ -76,7 +76,7 @@ NETLIB_START(7474sub)
register_output("Q", m_Q);
register_output("QQ", m_QQ);
save(NAME(m_nextD));
save(NLNAME(m_nextD));
}
NETLIB_RESET(7474sub)

View File

@ -23,7 +23,7 @@ NETLIB_START(7483)
register_output("S4", m_S4);
register_output("C4", m_C4);
save(NAME(m_lastr));
save(NLNAME(m_lastr));
}
NETLIB_RESET(7483)

View File

@ -19,9 +19,9 @@ NETLIB_START(7490)
register_output("QC", m_Q[2]);
register_output("QD", m_Q[3]);
save(NAME(m_cnt));
save(NAME(m_last_A));
save(NAME(m_last_B));
save(NLNAME(m_cnt));
save(NLNAME(m_last_A));
save(NLNAME(m_last_B));
}

View File

@ -40,7 +40,7 @@ NETLIB_START(7493ff)
register_input("CLK", m_I);
register_output("Q", m_Q);
save(NAME(m_reset));
save(NLNAME(m_reset));
}
NETLIB_RESET(7493ff)

View File

@ -49,9 +49,9 @@ NETLIB_START(SN74LS629clk)
reset();
save(NAME(m_enableq));
save(NAME(m_inc));
save(NAME(m_out));
save(NLNAME(m_enableq));
save(NLNAME(m_inc));
save(NLNAME(m_out));
}
NETLIB_RESET(SN74LS629clk)

View File

@ -73,9 +73,9 @@ NETLIB_START(9316_sub)
register_output("QD", m_QD);
register_output("RC", m_RC);
save(NAME(m_cnt.ref()));
save(NAME(m_loadq.ref()));
save(NAME(m_ent.ref()));
save(NLNAME(m_cnt.ref()));
save(NLNAME(m_loadq.ref()));
save(NLNAME(m_ent.ref()));
}
NETLIB_RESET(9316_sub)

View File

@ -42,7 +42,7 @@ NETLIB_START(NE555)
connect(m_R2.m_N, m_R3.m_P);
connect(m_RDIS.m_N, m_R3.m_N);
save(NAME(m_last_out));
save(NLNAME(m_last_out));
}
NETLIB_RESET(NE555)

View File

@ -44,7 +44,7 @@ public:
{
register_input(sIN[i], m_i[i]);
}
save(NAME(m_active));
save(NLNAME(m_active));
}
ATTR_COLD void reset()
@ -118,7 +118,7 @@ public:
register_input("A", m_i[0]);
register_input("B", m_i[1]);
save(NAME(m_active));
save(NLNAME(m_active));
}
ATTR_COLD void reset()

View File

@ -198,7 +198,7 @@ public:
ATTR_COLD nld_a_to_d_proxy(netlist_input_t &in_proxied)
: netlist_device_t()
{
assert(in_proxied.family() == LOGIC);
nl_assert(in_proxied.family() == LOGIC);
m_I.m_logic_family = in_proxied.m_logic_family;
}
@ -240,7 +240,7 @@ public:
ATTR_COLD nld_base_d_to_a_proxy(netlist_output_t &out_proxied)
: netlist_device_t()
{
assert(out_proxied.family() == LOGIC);
nl_assert(out_proxied.family() == LOGIC);
m_logic_family = out_proxied.m_logic_family;
}

View File

@ -50,11 +50,11 @@ public:
{
nl_util::pstring_list io = nl_util::split(ttline,"|");
// checks
assert(io.count() == 2);
nl_assert(io.count() == 2);
nl_util::pstring_list inout = nl_util::split(io[0], ",");
assert(inout.count() == m_num_bits);
nl_assert(inout.count() == m_num_bits);
nl_util::pstring_list out = nl_util::split(io[1], ",");
assert(out.count() == m_NO);
nl_assert(out.count() == m_NO);
for (int i=0; i < m_NI; i++)
{
@ -133,13 +133,13 @@ public:
{
nl_util::pstring_list io = nl_util::split(ttline,"|");
// checks
assert(io.count() == 3);
nl_assert(io.count() == 3);
nl_util::pstring_list inout = nl_util::split(io[0], ",");
assert(inout.count() == m_num_bits);
nl_assert(inout.count() == m_num_bits);
nl_util::pstring_list out = nl_util::split(io[1], ",");
assert(out.count() == m_NO);
nl_assert(out.count() == m_NO);
nl_util::pstring_list times = nl_util::split(io[2], ",");
assert(times.count() == m_NO);
nl_assert(times.count() == m_NO);
UINT16 val = 0;
UINT8 tindex[m_NO];

View File

@ -9,6 +9,8 @@
#include "pstring.h"
#include "nl_util.h"
#include <stdlib.h> // FIXME: only included for atof
const netlist_time netlist_time::zero = netlist_time::from_raw(0);
netlist_logic_family_desc_t netlist_family_TTL =
@ -164,7 +166,7 @@ netlist_base_t::~netlist_base_t()
ATTR_COLD void netlist_base_t::save_register()
{
save(static_cast<pstate_callback_t &>(m_queue), "m_queue");
save(NAME(m_time));
save(NLNAME(m_time));
netlist_object_t::save_register();
}
@ -529,7 +531,7 @@ ATTR_HOT void netlist_net_t::dec_active(netlist_core_terminal_t &term)
ATTR_COLD void netlist_net_t::register_railterminal(netlist_output_t &mr)
{
assert(m_railterminal == NULL);
nl_assert(m_railterminal == NULL);
m_railterminal = &mr;
}
@ -545,12 +547,12 @@ ATTR_COLD void netlist_net_t::rebuild_list()
ATTR_COLD void netlist_net_t::save_register()
{
save(NAME(m_time));
save(NAME(m_active));
save(NAME(m_in_queue));
save(NAME(m_cur_Analog));
save(NAME(m_cur_Q));
save(NAME(m_new_Q));
save(NLNAME(m_time));
save(NLNAME(m_active));
save(NLNAME(m_in_queue));
save(NLNAME(m_cur_Analog));
save(NLNAME(m_cur_Q));
save(NLNAME(m_new_Q));
netlist_object_t::save_register();
}
@ -569,7 +571,7 @@ ATTR_HOT ATTR_ALIGN static inline void update_dev(const netlist_core_terminal_t
ATTR_HOT ATTR_ALIGN inline void netlist_net_t::update_devs()
{
//assert(m_num_cons != 0);
assert(this->isRailNet());
nl_assert(this->isRailNet());
const UINT32 masks[4] = { 1, 5, 3, 1 };
const UINT32 mask = masks[ (m_cur_Q << 1) | m_new_Q ];
@ -707,8 +709,8 @@ ATTR_COLD void netlist_analog_net_t::reset()
ATTR_COLD void netlist_analog_net_t::save_register()
{
save(NAME(m_DD_n_m_1));
save(NAME(m_h_n_m_1));
save(NLNAME(m_DD_n_m_1));
save(NLNAME(m_h_n_m_1));
netlist_net_t::save_register();
}
@ -803,9 +805,9 @@ ATTR_COLD void netlist_terminal_t::reset()
ATTR_COLD void netlist_terminal_t::save_register()
{
save(NAME(m_Idr1));
save(NAME(m_go1));
save(NAME(m_gt1));
save(NLNAME(m_Idr1));
save(NLNAME(m_go1));
save(NLNAME(m_gt1));
netlist_core_terminal_t::save_register();
}

View File

@ -444,7 +444,7 @@ public:
ATTR_HOT inline const state_e state() const { return m_state; }
ATTR_HOT inline void set_state(const state_e astate)
{
assert(astate != STATE_NONEX);
nl_assert(astate != STATE_NONEX);
m_state = astate;
}
@ -453,7 +453,7 @@ public:
protected:
ATTR_COLD virtual void save_register()
{
save(NAME(m_state));
save(NLNAME(m_state));
netlist_owned_object_t::save_register();
}
@ -710,7 +710,7 @@ public:
*/
ATTR_COLD inline netlist_sig_t &Q_state_ptr()
{
assert(family() == LOGIC);
nl_assert(family() == LOGIC);
return m_cur_Q;
}
@ -738,15 +738,15 @@ public:
ATTR_HOT inline const double Q_Analog() const
{
//assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
assert(family() == ANALOG);
//nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
nl_assert(family() == ANALOG);
return m_cur_Analog;
}
ATTR_COLD inline double &Q_Analog_state_ptr()
{
//assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
assert(family() == ANALOG);
//nl_assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
nl_assert(family() == ANALOG);
return m_cur_Analog;
}
@ -883,7 +883,7 @@ public:
protected:
ATTR_COLD virtual void save_register()
{
save(NAME(m_param));
save(NLNAME(m_param));
netlist_param_t::save_register();
}
@ -905,7 +905,7 @@ public:
protected:
ATTR_COLD virtual void save_register()
{
save(NAME(m_param));
save(NLNAME(m_param));
netlist_param_t::save_register();
}
@ -988,7 +988,7 @@ public:
ATTR_HOT inline const netlist_sig_t INPLOGIC(const netlist_logic_input_t &inp) const
{
assert(inp.state() != netlist_input_t::STATE_INP_PASSIVE);
nl_assert(inp.state() != netlist_input_t::STATE_INP_PASSIVE);
return inp.Q();
}
@ -1262,25 +1262,25 @@ ATTR_HOT inline void netlist_param_double_t::setTo(const double param)
ATTR_HOT inline netlist_logic_net_t & RESTRICT netlist_net_t::as_logic()
{
assert(family() == LOGIC);
nl_assert(family() == LOGIC);
return static_cast<netlist_logic_net_t &>(*this);
}
ATTR_HOT inline const netlist_logic_net_t & RESTRICT netlist_net_t::as_logic() const
{
assert(family() == LOGIC);
nl_assert(family() == LOGIC);
return static_cast<const netlist_logic_net_t &>(*this);
}
ATTR_HOT inline netlist_analog_net_t & RESTRICT netlist_net_t::as_analog()
{
assert(family() == ANALOG);
nl_assert(family() == ANALOG);
return static_cast<netlist_analog_net_t &>(*this);
}
ATTR_HOT inline const netlist_analog_net_t & RESTRICT netlist_net_t::as_analog() const
{
assert(family() == ANALOG);
nl_assert(family() == ANALOG);
return static_cast<const netlist_analog_net_t &>(*this);
}

View File

@ -10,7 +10,11 @@
/* FIXME: at some time, make it compile on it's own */
#include "emu.h"
#include "osdcore.h"
#include "corealloc.h"
#include <math.h>
#include <exception>
#include <typeinfo>
//============================================================
// SETUP
@ -102,6 +106,38 @@
#define end_timing(v) do { } while (0)
#endif
// this macro passes an item followed by a string version of itself as two consecutive parameters
#define NLNAME(x) x, #x
// emu_fatalerror is a generic fatal exception that provides an error string
class nl_fatalerror : public std::exception
{
public:
nl_fatalerror(const char *format, ...) ATTR_PRINTF(2,3)
{
char text[1024];
va_list ap;
va_start(ap, format);
vsprintf(text, format, ap);
va_end(ap);
osd_printf_error("%s\n", text);
}
nl_fatalerror(const char *format, va_list ap)
{
char text[1024];
vsprintf(text, format, ap);
osd_printf_error("%s\n", text);
}
};
#ifdef MAME_DEBUG
#define nl_assert(x) do { if (!(x)) throw nl_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0)
#define nl_assert_always(x, msg) do { if (!(x)) throw nl_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0)
#else
#define nl_assert(x) do { } while (0)
//#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0)
#define nl_assert_always(x, msg) do { } while (0)
#endif
//============================================================
// Compiling standalone
@ -110,7 +146,7 @@
// Compiling without mame ?
#ifndef ATTR_HOT
//#warning ATTR_HOT not defined
#warning ATTR_HOT not defined
// standard C includes
#include <math.h>
@ -132,9 +168,6 @@
#define UNEXPECTED
#define ATTR_UNUSED __attribute__((__unused__))
// this macro passes an item followed by a string version of itself as two consecutive parameters
#define NAME(x) x, #x
/* 8-bit values */
typedef unsigned char UINT8;
typedef signed char INT8;
@ -160,15 +193,6 @@ __extension__ typedef signed long long INT64;
#endif
#endif
#ifdef MAME_DEBUG
#define assert(x) do { if (!(x)) throw emu_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0)
#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0)
#else
#define assert(x) do { } while (0)
//#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0)
#define assert_always(x, msg) do { } while (0)
#endif
/* U64 and S64 are used to wrap long integer constants. */
#if defined(__GNUC__) || defined(_MSC_VER)
#define U64(val) val##ULL

View File

@ -59,7 +59,7 @@ public:
}
*i = e;
inc_stat(m_prof_sort);
assert(m_end - m_list < _Size);
nl_assert(m_end - m_list < _Size);
}
ATTR_HOT inline const entry_t *pop()

View File

@ -14,6 +14,9 @@
#include "analog/nld_solver.h"
#include "analog/nld_twoterm.h"
//FIXME: we need a nl_getenv
#include <stdlib.h>
static NETLIST_START(base)
TTL_INPUT(ttlhigh, 1)
TTL_INPUT(ttllow, 0)
@ -378,7 +381,7 @@ netlist_param_t *netlist_setup_t::find_param(const pstring &param_in, bool requi
nld_base_d_to_a_proxy *netlist_setup_t::get_d_a_proxy(netlist_output_t &out)
{
assert(out.isFamily(netlist_terminal_t::LOGIC));
nl_assert(out.isFamily(netlist_terminal_t::LOGIC));
//printf("proxy for %s\n", out.name().cstr());;
netlist_logic_output_t &out_cast = dynamic_cast<netlist_logic_output_t &>(out);
@ -499,8 +502,8 @@ void netlist_setup_t::connect_terminal_output(netlist_terminal_t &in, netlist_ou
void netlist_setup_t::connect_terminals(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2)
{
//assert(in.isType(netlist_terminal_t::TERMINAL));
//assert(out.isType(netlist_terminal_t::TERMINAL));
//nl_assert(in.isType(netlist_terminal_t::TERMINAL));
//nl_assert(out.isType(netlist_terminal_t::TERMINAL));
if (t1.has_net() && t2.has_net())
{
@ -683,6 +686,7 @@ void netlist_setup_t::resolve_inputs()
void netlist_setup_t::start_devices()
{
//FIXME: we need a nl_getenv
if (getenv("NL_LOGS"))
{
NL_VERBOSE_OUT(("Creating dynamic logs ...\n"));

View File

@ -108,7 +108,7 @@ public:
ATTR_HOT inline void remove_at(const int pos)
{
assert((pos>=0) && (pos<m_count));
nl_assert((pos>=0) && (pos<m_count));
m_count--;
for (int i = pos; i < m_count; i++)
{
@ -118,8 +118,8 @@ public:
ATTR_HOT inline void swap(const int pos1, const int pos2)
{
assert((pos1>=0) && (pos1<m_count));
assert((pos2>=0) && (pos2<m_count));
nl_assert((pos1>=0) && (pos1<m_count));
nl_assert((pos2>=0) && (pos2<m_count));
_ListClass tmp = m_list[pos1];
m_list[pos1] = m_list[pos2];
m_list[pos2] =tmp;
@ -331,7 +331,7 @@ public:
}
p = p->m_next;
}
assert_always(false, "element not found");
nl_assert_always(false, "element not found");
}
}
@ -357,7 +357,7 @@ public:
_ListClass **p = &m_head;
while (*p != &elem)
{
assert(*p != NULL);
nl_assert(*p != NULL);
p = &((*p)->m_next);
}
(*p) = elem.m_next;

View File

@ -5,6 +5,7 @@
#include "pstring.h"
#include <cstdio>
#include <stdlib.h>
// The following will work on linux, however not on Windows ....