From 1415421fd707ad02e0cfddf20bf70bbd045a9203 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 6 Jan 2019 13:17:20 +0100 Subject: More c++ alignment. pstring now behaves like std::string. (nw) This change removes all string extensions like trim, rpad, left, right, ... from pstring and replaces them by function templates. This aligns a lot better with the intentions of the standard library. --- src/lib/netlist/plib/pstring.h | 287 +++++++++++++++++++++++++++++++++-------- 1 file changed, 236 insertions(+), 51 deletions(-) (limited to 'src/lib/netlist/plib/pstring.h') diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index cabce0e7b93..22ccd3749e4 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -10,14 +10,19 @@ #include #include #include +#include // ---------------------------------------------------------------------------------------- // pstring: semi-immutable strings ... // // The only reason this class exists is the absence of support for multi-byte -// strings in std:: which I would consider usuable for the use-cases I encounter. +// strings in std:: which I would consider sub-optimal for the use-cases I encounter. // ---------------------------------------------------------------------------------------- +// enable this to use std::string instead of pstring globally. + +#define PSTRING_USE_STD_STRING (0) + template class pstring_const_iterator final { @@ -64,6 +69,7 @@ public: typedef typename traits_type::mem_t mem_t; typedef typename traits_type::code_t code_t; + typedef typename traits_type::code_t value_type; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef typename traits_type::string_type string_type; @@ -83,12 +89,6 @@ public: typedef const ref_value_type& const_reference; typedef const_reference reference; - enum enc_t - { - UTF8, - UTF16 - }; - // simple construction/destruction pstring_t() { @@ -98,12 +98,12 @@ public: } // FIXME: Do something with encoding - pstring_t(const mem_t *string, const enc_t enc) + pstring_t(const mem_t *string) : m_str(string) { } - pstring_t(const mem_t *string, const size_type len, const enc_t enc) + pstring_t(const mem_t *string, const size_type len) : m_str(string, len) { } @@ -122,7 +122,7 @@ public: : m_str(string.m_str) { } - explicit pstring_t(const string_type &string, const enc_t enc) + explicit pstring_t(const string_type &string) : m_str(string) { } @@ -201,49 +201,12 @@ public: const_reference at(const size_type pos) const { return *reinterpret_cast(F::nthcode(m_str.c_str(),pos)); } - /* The following is not compatible to std::string */ - - bool equals(const pstring_t &string) const { return (compare(string) == 0); } - - bool startsWith(const pstring_t &arg) const { return arg.mem_t_size() > mem_t_size() ? false : m_str.compare(0, arg.mem_t_size(), arg.m_str) == 0; } - bool endsWith(const pstring_t &arg) const { return arg.mem_t_size() > mem_t_size() ? false : m_str.compare(mem_t_size()-arg.mem_t_size(), arg.mem_t_size(), arg.m_str) == 0; } - - pstring_t replace_all(const pstring_t &search, const pstring_t &replace) const; - pstring_t cat(const pstring_t &s) const { return *this + s; } - pstring_t cat(code_t c) const { return *this + c; } - - // conversions - - double as_double(bool *error = nullptr) const; - long as_long(bool *error = nullptr) const; - /* the following are extensions to */ size_type mem_t_size() const { return m_str.size(); } - pstring_t left(size_type len) const { return substr(0, len); } - pstring_t right(size_type nlen) const - { - return nlen >= length() ? *this : substr(length() - nlen, nlen); - } - - pstring_t ltrim(const pstring_t &ws = pstring_t(" \t\n\r")) const - { - return substr(find_first_not_of(ws)); - } - - pstring_t rtrim(const pstring_t &ws = pstring_t(" \t\n\r")) const - { - auto f = find_last_not_of(ws); - return f == npos ? pstring_t() : substr(0, f + 1); - } - - pstring_t trim(const pstring_t &ws = pstring_t(" \t\n\r")) const { return this->ltrim(ws).rtrim(ws); } - pstring_t rpad(const pstring_t &ws, const size_type cnt) const; - pstring_t ucase() const; - const string_type &cpp_string() const { return m_str; } static const size_type npos = static_cast(-1); @@ -519,37 +482,259 @@ extern template struct pstring_t; extern template struct pstring_t; extern template struct pstring_t; +#if (PSTRING_USE_STD_STRING) +typedef std::string pstring; +#else typedef pstring_t pstring; +#endif +typedef pstring_t putf8string; typedef pstring_t pu16string; typedef pstring_t pwstring; namespace plib { + template + struct string_info + { + typedef typename T::mem_t mem_t; + }; + + template<> + struct string_info + { + typedef char mem_t; + }; + template pstring to_string(const T &v) { - return pstring(std::to_string(v), pstring::UTF8); + return pstring(std::to_string(v)); } template pwstring to_wstring(const T &v) { - return pwstring(std::to_wstring(v), pwstring::UTF16); + return pwstring(std::to_wstring(v)); + } + +#if (PSTRING_USE_STD_STRING) + inline double pstod(const std::string &str, std::size_t *e = nullptr) + { + return std::stod(str, e); + } + + inline long pstol(const std::string &str, std::size_t *e = nullptr, int base = 10) + { + return std::stol(str, e, base); + } +#else + template + double pstod(const T &str, std::size_t *e = nullptr) + { + return std::stod(str.cpp_string(), e); + } + + template + long pstol(const T &str, std::size_t *e = nullptr, int base = 10) + { + return std::stol(str.cpp_string(), e, base); + } +#endif + + template + bool pstol_ne(const T &str, R &ret) + { + try + { + std::size_t e = 0; + ret = pstol(str, &e); + return str.c_str()[e] == 0; + } + catch (...) + { + return false; + } + } + + template + bool pstod_ne(const T &str, R &ret) + { + try + { + std::size_t e = 0; + ret = pstod(str, &e); + return str.c_str()[e] == 0; + } + catch (...) + { + return false; + } + } + + template + typename T::size_type find_first_not_of(const T &str, const T &no) + { + typename T::size_type pos = 0; + for (auto it = str.begin(); it != str.end(); ++it, ++pos) + { + bool f = true; + for (typename T::value_type const jt : no) + { + if (*it == jt) + { + f = false; + break; + } + } + if (f) + return pos; + } + return T::npos; + } + + template + typename T::size_type find_last_not_of(const T &str, const T &no) + { + /* FIXME: reverse iterator */ + typename T::size_type last_found = T::npos; + typename T::size_type pos = 0; + for (auto it = str.begin(); it != str.end(); ++it, ++pos) + { + bool f = true; + for (typename T::value_type const jt : no) + { + if (*it == jt) + { + f = false; + break; + } + } + if (f) + last_found = pos; + } + return last_found; + } + + template + T ltrim(const T &str, const T &ws = T(" \t\n\r")) + { + auto f = find_first_not_of(str, ws); + return (f == T::npos) ? T() : str.substr(f); + } + + template + T rtrim(const T &str, const T &ws = T(" \t\n\r")) + { + auto f = find_last_not_of(str, ws); + return (f == T::npos) ? T() : str.substr(0, f + 1); + } + + template + T trim(const T &str, const T &ws = T(" \t\n\r")) + { + return rtrim(ltrim(str, ws), ws); + } + + template + T left(const T &str, typename T::size_type len) + { + return str.substr(0, len); + } + + template + T right(const T &str, typename T::size_type nlen) + { + return nlen >= str.length() ? str : str.substr(str.length() - nlen, nlen); + } + + template + bool startsWith(const T &str, const T &arg) + { + return (arg == left(str, arg.length())); + } + + template + bool endsWith(const T &str, const T &arg) + { + return (right(str, arg.length()) == arg); } + + template + bool startsWith(const T &str, const char *arg) + { + return (left(str, std::strlen(arg)) == arg); + } + + template + bool endsWith(const T &str, const char *arg) + { + return (right(str, std::strlen(arg)) == arg); + } + + template + T ucase(const T &str) + { + T ret; + for (const auto &c : str) + if (c >= 'a' && c <= 'z') + ret += (c - 'a' + 'A'); + else + ret += c; + return ret; + } + + template + T rpad(const T &str, const T &ws, const typename T::size_type cnt) + { + // FIXME: pstringbuffer ret(*this); + + T ret(str); + typename T::size_type wsl = ws.length(); + for (auto i = ret.length(); i < cnt; i+=wsl) + ret += ws; + return ret; + } + + template + T replace_all(const T &str, const T &search, const T &replace) + { + T ret; + const typename T::size_type slen = search.length(); + + typename T::size_type last_s = 0; + typename T::size_type s = str.find(search, last_s); + while (s != T::npos) + { + ret += str.substr(last_s, s - last_s); + ret += replace; + last_s = s + slen; + s = str.find(search, last_s); + } + ret += str.substr(last_s); + return ret; + } + + template + T replace_all(const T &str, const T1 &search, const T2 &replace) + { + return replace_all(str, T(search), T(replace)); + } + } // custom specialization of std::hash can be injected in namespace std namespace std { + template struct hash> { typedef pstring_t argument_type; typedef std::size_t result_type; result_type operator()(argument_type const& s) const { - const pstring::mem_t *string = s.c_str(); + const typename argument_type::mem_t *string = s.c_str(); result_type result = 5381; - for (pstring::mem_t c = *string; c != 0; c = *string++) + for (typename argument_type::mem_t c = *string; c != 0; c = *string++) result = ((result << 5) + result ) ^ (result >> (32 - 5)) ^ static_cast(c); return result; } -- cgit v1.2.3-70-g09d2 From ae6185e5f660531ae47545b9c80f6c7056f6ecbc Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 7 Jan 2019 19:14:21 +1100 Subject: add C++ standard library headers for things that are used (nw) --- src/lib/netlist/nl_setup.cpp | 2 ++ src/lib/netlist/plib/palloc.h | 4 +++- src/lib/netlist/plib/pstring.h | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/lib/netlist/plib/pstring.h') diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index c8e47cb17e3..cf89e4a8fae 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -17,6 +17,8 @@ #include "solver/nld_solver.h" #include "devices/nlid_truthtable.h" +#include + // ---------------------------------------------------------------------------------------- // setup_t // ---------------------------------------------------------------------------------------- diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index a35bc50ff17..3759d5819de 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -10,8 +10,10 @@ #include "pstring.h" -#include +#include #include +#include +#include namespace plib { diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 22ccd3749e4..67104a54213 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -7,10 +7,11 @@ #ifndef PSTRING_H_ #define PSTRING_H_ -#include +#include #include +#include #include -#include +#include // ---------------------------------------------------------------------------------------- // pstring: semi-immutable strings ... -- cgit v1.2.3-70-g09d2 From 4213a396d8652e7ea26c07c133932bd9f5a87faa Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 10 Jan 2019 00:30:51 +0100 Subject: Improve type safety on string->numeric conversions. (nw) Also fixed an issue with 7497. ./nltool -t 5 -f src/mame/machine/nl_tp1983.cpp -v now runs again. --- src/lib/netlist/devices/net_lib.cpp | 2 +- src/lib/netlist/devices/nlid_system.h | 4 +- src/lib/netlist/devices/nlid_truthtable.cpp | 3 +- src/lib/netlist/nl_base.cpp | 4 +- src/lib/netlist/nl_config.h | 1 - src/lib/netlist/nl_parser.cpp | 8 +-- src/lib/netlist/nl_setup.cpp | 13 +++-- src/lib/netlist/plib/pfunction.cpp | 4 +- src/lib/netlist/plib/poptions.cpp | 40 +------------ src/lib/netlist/plib/poptions.h | 91 ++++++++++++++++++++--------- src/lib/netlist/plib/pparser.cpp | 15 +++-- src/lib/netlist/plib/pstring.h | 77 ++++++++++++++---------- src/lib/netlist/plib/putil.cpp | 30 ++++++++++ src/lib/netlist/plib/putil.h | 5 ++ src/lib/netlist/prg/nltool.cpp | 18 +++--- src/lib/netlist/prg/nlwav.cpp | 4 +- src/lib/netlist/solver/nld_solver.cpp | 2 +- src/lib/netlist/tools/nl_convert.cpp | 9 +-- 18 files changed, 197 insertions(+), 133 deletions(-) (limited to 'src/lib/netlist/plib/pstring.h') diff --git a/src/lib/netlist/devices/net_lib.cpp b/src/lib/netlist/devices/net_lib.cpp index 30ddf3af84c..dd77be5a9a2 100644 --- a/src/lib/netlist/devices/net_lib.cpp +++ b/src/lib/netlist/devices/net_lib.cpp @@ -74,7 +74,7 @@ namespace netlist ENTRYX(7485, TTL_7485, "+A0,+A1,+A2,+A3,+B0,+B1,+B2,+B3,+LTIN,+EQIN,+GTIN") ENTRYX(7490, TTL_7490, "+A,+B,+R1,+R2,+R91,+R92") ENTRYX(7493, TTL_7493, "+CLKA,+CLKB,+R1,+R2") - ENTRYX(7497, TTL_7497, "+CLK,+STRB,+EN,+UNITY,+CLR,+B0,+B1,+B2,+B3,+B4,+B5") + ENTRYX(7497, TTL_7497, "+CLK,+STRBQ,+ENQ,+UNITYQ,+CLR,+B0,+B1,+B2,+B3,+B4,+B5") ENTRYX(74107, TTL_74107, "+CLK,+J,+K,+CLRQ") ENTRYX(74107A, TTL_74107A, "+CLK,+J,+K,+CLRQ") ENTRYX(74123, TTL_74123, "") diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 881cce03592..5a874aef3df 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -136,7 +136,9 @@ namespace netlist unsigned long total = 0; for (unsigned i=0; i(plib::pstol(pat[i])); + // FIXME: use pstonum_ne + //pati[i] = plib::pstonum(pat[i]); + pati[i] = plib::pstonum(pat[i]); total += pati[i]; } netlist_time ttotal = netlist_time::zero(); diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index c3449d5b604..dbb9401425d 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -407,7 +407,8 @@ void truthtable_parser::parse(const std::vector &truthtable) val.set(j); else nl_assert_always(outs == "0", "Unknown value (not 0 or 1"); - netlist_time t = netlist_time::from_nsec(static_cast(plib::pstol(plib::trim(times[j])))); + // FIXME: error handling + netlist_time t = netlist_time::from_nsec(plib::pstonum(plib::trim(times[j]))); uint_least8_t k=0; while (m_timing_nt[k] != netlist_time::zero() && m_timing_nt[k] != t) k++; diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 5b132ebd554..a0eabcc7fbe 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -343,8 +343,8 @@ void netlist_t::start() auto p = setup().m_param_values.find(d->name() + ".HINT_NO_DEACTIVATE"); if (p != setup().m_param_values.end()) { - //FIXME: turn this into a proper function - auto v = plib::pstod(p->second);; + //FIXME: check for errors ... + double v = plib::pstonum(p->second);; if (std::abs(v - std::floor(v)) > 1e-6 ) log().fatal(MF_1_HND_VAL_NOT_SUPPORTED, p->second); d->set_hint_deactivate(v == 0.0); diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index d2f4dc75511..20ddf5c71a3 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -26,7 +26,6 @@ * linear memory pool. This is based of the assumption that * due to enhanced locality there will be less cache misses. * Your mileage may vary. - * This will cause crashes on OSX and thus is ignored on OSX. * */ #define USE_MEMPOOL (0) diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index a6a805826ce..1ff6ef6c6b7 100644 --- a/src/lib/netlist/nl_parser.cpp +++ b/src/lib/netlist/nl_parser.cpp @@ -403,7 +403,6 @@ nl_double parser_t::eval_param(const token_t tok) int i; int f=0; nl_double ret; - pstring val; for (i=1; i<6;i++) if (tok.str() == macs[i]) @@ -416,9 +415,10 @@ nl_double parser_t::eval_param(const token_t tok) } else { - val = tok.str(); - if (!plib::pstod_ne(val, ret)) - error(plib::pfmt("Parameter value <{1}> not double \n")(val)); + bool err; + ret = plib::pstonum_ne(tok.str(), err); + if (err) + error(plib::pfmt("Parameter value <{1}> not double \n")(tok.str())); } return ret * facs[f]; diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index cf89e4a8fae..28385d984cf 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -159,8 +159,9 @@ double setup_t::get_initial_param_val(const pstring &name, const double def) auto i = m_param_values.find(name); if (i != m_param_values.end()) { - double vald = 0; - if (!plib::pstod_ne(i->second, vald)) + bool err = false; + double vald = plib::pstonum_ne(i->second, err); + if (err) log().fatal(MF_2_INVALID_NUMBER_CONVERSION_1_2, name, i->second); return vald; } @@ -173,8 +174,9 @@ int setup_t::get_initial_param_val(const pstring &name, const int def) auto i = m_param_values.find(name); if (i != m_param_values.end()) { - long vald = 0; - if (!plib::pstod_ne(i->second, vald)) + bool err; + double vald = plib::pstonum_ne(i->second, err); + if (err) log().fatal(MF_2_INVALID_NUMBER_CONVERSION_1_2, name, i->second); if (vald - std::floor(vald) != 0.0) log().fatal(MF_2_INVALID_NUMBER_CONVERSION_1_2, name, i->second); @@ -872,7 +874,8 @@ nl_double setup_t::model_value(detail::model_map_t &map, const pstring &entity) } if (factor != NL_FCONST(1.0)) tmp = plib::left(tmp, tmp.size() - 1); - return plib::pstod(tmp) * factor; + // FIXME: check for errors + return plib::pstonum(tmp) * factor; } class logic_family_std_proxy_t : public logic_family_desc_t diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp index e9e2de009c8..f2ef3522813 100644 --- a/src/lib/netlist/plib/pfunction.cpp +++ b/src/lib/netlist/plib/pfunction.cpp @@ -69,7 +69,9 @@ void pfunction::compile_postfix(const std::vector &inputs, if (rc.m_cmd != PUSH_INPUT) { rc.m_cmd = PUSH_CONST; - if (!plib::pstod_ne(cmd, rc.m_param)) + bool err; + rc.m_param = plib::pstonum_ne(cmd, err); + if (err) throw plib::pexception(plib::pfmt("nld_function: unknown/misformatted token <{1}> in <{2}>")(cmd)(expr)); stk += 1; } diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp index d576eff0bb2..c790d1f55af 100644 --- a/src/lib/netlist/plib/poptions.cpp +++ b/src/lib/netlist/plib/poptions.cpp @@ -46,49 +46,13 @@ namespace plib { return 0; } - int option_str_limit::parse(const pstring &argument) - { - if (plib::container::contains(m_limit, argument)) - { - m_val = argument; - return 0; - } - else - return 1; - } - int option_bool::parse(const pstring &argument) { + unused_var(argument); m_val = true; return 0; } - int option_double::parse(const pstring &argument) - { - try - { - m_val = plib::pstod(argument); - return 0; - } - catch (...) - { - return 1; - } - } - - int option_long::parse(const pstring &argument) - { - try - { - m_val = plib::pstol(argument); - return 0; - } - catch (...) - { - return 1; - } - } - int option_vec::parse(const pstring &argument) { bool err = false; @@ -233,7 +197,7 @@ namespace plib { if (opt->has_argument()) { line += "="; - option_str_limit *ol = dynamic_cast(opt); + option_str_limit_base *ol = dynamic_cast(opt); if (ol) { for (auto &v : ol->limit()) diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h index 491ac0b4d91..f3be4b061dd 100644 --- a/src/lib/netlist/plib/poptions.h +++ b/src/lib/netlist/plib/poptions.h @@ -102,72 +102,98 @@ private: pstring m_val; }; -class option_str_limit : public option +class option_str_limit_base : public option { public: - option_str_limit(options &parent, pstring ashort, pstring along, pstring defval, pstring limit, pstring help) - : option(parent, ashort, along, help, true), m_val(defval) - , m_limit(plib::psplit(limit, ":")) + option_str_limit_base(options &parent, pstring ashort, pstring along, std::vector &&limit, pstring help) + : option(parent, ashort, along, help, true) + , m_limit(limit) { } - - pstring operator ()() { return m_val; } - const std::vector &limit() { return m_limit; } + const std::vector &limit() const { return m_limit; } protected: - virtual int parse(const pstring &argument) override; private: - pstring m_val; std::vector m_limit; }; -class option_bool : public option + +template +class option_str_limit : public option_str_limit_base { public: - option_bool(options &parent, pstring ashort, pstring along, pstring help) - : option(parent, ashort, along, help, false), m_val(false) - {} + option_str_limit(options &parent, pstring ashort, pstring along, const T &defval, std::vector &&limit, pstring help) + : option_str_limit_base(parent, ashort, along, std::move(limit), help), m_val(defval) + { + } - bool operator ()() { return m_val; } + T operator ()() { return m_val; } + + pstring as_string() const { return limit()[m_val]; } protected: - virtual int parse(const pstring &argument) override; + virtual int parse(const pstring &argument) override + { + auto raw = plib::container::indexof(limit(), argument); + + if (raw != plib::container::npos) + { + m_val = static_cast(raw); + return 0; + } + else + return 1; + } private: - bool m_val; + T m_val; }; -class option_double : public option +class option_bool : public option { public: - option_double(options &parent, pstring ashort, pstring along, double defval, pstring help) - : option(parent, ashort, along, help, true), m_val(defval) + option_bool(options &parent, pstring ashort, pstring along, pstring help) + : option(parent, ashort, along, help, false), m_val(false) {} - double operator ()() { return m_val; } + bool operator ()() { return m_val; } protected: virtual int parse(const pstring &argument) override; private: - double m_val; + bool m_val; }; -class option_long : public option +template +class option_num : public option { public: - option_long(options &parent, pstring ashort, pstring along, long defval, pstring help) - : option(parent, ashort, along, help, true), m_val(defval) + option_num(options &parent, pstring ashort, pstring along, T defval, + pstring help, + T minval = std::numeric_limits::min(), + T maxval = std::numeric_limits::max() ) + : option(parent, ashort, along, help, true) + , m_val(defval) + , m_min(minval) + , m_max(maxval) {} - long operator ()() { return m_val; } + T operator ()() { return m_val; } protected: - virtual int parse(const pstring &argument) override; + virtual int parse(const pstring &argument) override + { + bool err; + m_val = pstonum_ne(argument, err); + return (err ? 1 : (m_val < m_min || m_val > m_max)); + } private: - long m_val; + T m_val; + T m_min; + T m_max; }; class option_vec : public option @@ -207,6 +233,17 @@ private: static pstring split_paragraphs(pstring text, unsigned width, unsigned indent, unsigned firstline_indent); + template + T *getopt_type() + { + for (auto & optbase : m_opts ) + { + if (auto opt = dynamic_cast(optbase)) + return opt; + } + return nullptr; + } + option *getopt_short(pstring arg); option *getopt_long(pstring arg); diff --git a/src/lib/netlist/plib/pparser.cpp b/src/lib/netlist/plib/pparser.cpp index 298fa589fba..b18b3265440 100644 --- a/src/lib/netlist/plib/pparser.cpp +++ b/src/lib/netlist/plib/pparser.cpp @@ -122,6 +122,7 @@ pstring ptokenizer::get_identifier_or_number() return tok.str(); } +// FIXME: combine into template double ptokenizer::get_number_double() { token_t tok = get_token(); @@ -129,9 +130,9 @@ double ptokenizer::get_number_double() { error(pfmt("Expected a number, got <{1}>")(tok.str()) ); } - double ret = 0.0; - - if (!plib::pstod_ne(tok.str(), ret)) + bool err; + double ret = plib::pstonum_ne(tok.str(), err); + if (err) error(pfmt("Expected a number, got <{1}>")(tok.str()) ); return ret; } @@ -143,8 +144,9 @@ long ptokenizer::get_number_long() { error(pfmt("Expected a long int, got <{1}>")(tok.str()) ); } - long ret = 0; - if (!plib::pstol_ne(tok.str(), ret)) + bool err; + long ret = plib::pstonum_ne(tok.str(), err); + if (err) error(pfmt("Expected a long int, got <{1}>")(tok.str()) ); return ret; } @@ -326,7 +328,8 @@ double ppreprocessor::expr(const std::vector &sexpr, std::size_t &start else { tok=sexpr[start]; - val = plib::pstod(tok); + // FIXME: error handling + val = plib::pstonum(tok); start++; } while (start < sexpr.size()) diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 67104a54213..677ce9e43b8 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -9,8 +9,10 @@ #include #include +#include #include #include +#include #include // ---------------------------------------------------------------------------------------- @@ -518,57 +520,72 @@ namespace plib return pwstring(std::to_wstring(v)); } -#if (PSTRING_USE_STD_STRING) - inline double pstod(const std::string &str, std::size_t *e = nullptr) - { - return std::stod(str, e); - } + template + struct pstonum_helper; - inline long pstol(const std::string &str, std::size_t *e = nullptr, int base = 10) + template + struct pstonum_helper::value + && std::is_signed::value>::type> { - return std::stol(str, e, base); - } -#else + template + long long operator()(const S &arg, std::size_t *idx) + { + return std::stoll(arg, idx); + } + }; + template - double pstod(const T &str, std::size_t *e = nullptr) + struct pstonum_helper::value + && !std::is_signed::value>::type> { - return std::stod(str.cpp_string(), e); - } + template + unsigned long long operator()(const S &arg, std::size_t *idx) + { + return std::stoull(arg, idx); + } + }; template - long pstol(const T &str, std::size_t *e = nullptr, int base = 10) + struct pstonum_helper::value>::type> { - return std::stol(str.cpp_string(), e, base); - } -#endif + template + long double operator()(const S &arg, std::size_t *idx) + { + return std::stold(arg, idx); + } + }; - template - bool pstol_ne(const T &str, R &ret) + template + T pstonum(const S &arg) { - try + decltype(arg.c_str()) cstr = arg.c_str(); + std::size_t idx(0); + auto ret = pstonum_helper()(cstr, &idx); + if (ret >= std::numeric_limits::lowest() && ret <= std::numeric_limits::max()) + //&& (ret == T(0) || std::abs(ret) >= std::numeric_limits::min() )) { - std::size_t e = 0; - ret = pstol(str, &e); - return str.c_str()[e] == 0; + if (cstr[idx] != 0) + throw std::invalid_argument(std::string("Continuation after numeric value ends: ") + cstr); } - catch (...) + else { - return false; + throw std::out_of_range(std::string("Out of range: ") + cstr); } + return static_cast(ret); } - template - bool pstod_ne(const T &str, R &ret) + template + R pstonum_ne(const T &str, bool &err) noexcept { try { - std::size_t e = 0; - ret = pstod(str, &e); - return str.c_str()[e] == 0; + err = false; + return pstonum(str); } catch (...) { - return false; + err = true; + return R(0); } } diff --git a/src/lib/netlist/plib/putil.cpp b/src/lib/netlist/plib/putil.cpp index 0d3a0ebca3f..92e0e6b3ab1 100644 --- a/src/lib/netlist/plib/putil.cpp +++ b/src/lib/netlist/plib/putil.cpp @@ -64,6 +64,36 @@ namespace plib return ret; } + std::vector psplit_r(const std::string &stri, + const std::string &token, + const std::size_t maxsplit) + { + std::string str(stri); + std::vector result; + std::size_t splits = 0; + + while(str.size()) + { + std::size_t index = str.rfind(token); + bool found = index!=std::string::npos; + if (found) + splits++; + if ((splits <= maxsplit || maxsplit == 0) && found) + { + result.push_back(str.substr(index+token.size())); + str = str.substr(0, index); + if (str.size()==0) + result.push_back(str); + } + else + { + result.push_back(str); + str = ""; + } + } + return result; + } + std::vector psplit(const pstring &str, const std::vector &onstrl) { pstring col = ""; diff --git a/src/lib/netlist/plib/putil.h b/src/lib/netlist/plib/putil.h index 8d59c0357e2..914d9820560 100644 --- a/src/lib/netlist/plib/putil.h +++ b/src/lib/netlist/plib/putil.h @@ -16,6 +16,11 @@ namespace plib { + + // Avoid unused variable warnings + template + inline void unused_var(Ts&&...) {} + namespace util { const pstring buildpath(std::initializer_list list ); diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index 4fcb4ebdc30..4395bd3bd17 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -23,7 +23,7 @@ public: tool_app_t() : plib::app(), opt_grp1(*this, "General options", "The following options apply to all commands."), - opt_cmd (*this, "c", "cmd", "run", "run:convert:listdevices:static:header:docheader", "run|convert|listdevices|static|header"), + opt_cmd (*this, "c", "cmd", 0, std::vector({"run","convert","listdevices","static","header","docheader"}), "run|convert|listdevices|static|header|docheader"), opt_file(*this, "f", "file", "-", "file to process (default is stdin)"), opt_defines(*this, "D", "define", "predefine value as macro, e.g. -Dname=value. If '=value' is omitted predefine it as 1. This option may be specified repeatedly."), opt_rfolders(*this, "r", "rom", "where to look for data files"), @@ -40,7 +40,7 @@ public: opt_loadstate(*this,"", "loadstate", "", "load state from file and continue from there"), opt_savestate(*this,"", "savestate", "", "save state to file at end of run"), opt_grp4(*this, "Options for convert command", "These options are only used by the convert command."), - opt_type(*this, "y", "type", "spice", "spice:eagle:rinf", "type of file to be converted: spice,eagle,rinf"), + opt_type(*this, "y", "type", 0, std::vector({"spice","eagle","rinf"}), "type of file to be converted: spice,eagle,rinf"), opt_ex1(*this, "nltool -c run -t 3.5 -f nl_examples/cdelay.c -n cap_delay", "Run netlist \"cap_delay\" from file nl_examples/cdelay.c for 3.5 seconds"), @@ -49,7 +49,7 @@ public: {} plib::option_group opt_grp1; - plib::option_str_limit opt_cmd; + plib::option_str_limit opt_cmd; plib::option_str opt_file; plib::option_vec opt_defines; plib::option_vec opt_rfolders; @@ -60,13 +60,13 @@ public: plib::option_group opt_grp2; plib::option_str opt_name; plib::option_group opt_grp3; - plib::option_double opt_ttr; + plib::option_num opt_ttr; plib::option_vec opt_logs; plib::option_str opt_inp; plib::option_str opt_loadstate; plib::option_str opt_savestate; plib::option_group opt_grp4; - plib::option_str_limit opt_type; + plib::option_str_limit opt_type; plib::option_example opt_ex1; plib::option_example opt_ex2; @@ -706,7 +706,7 @@ int tool_app_t::execute() try { - pstring cmd = opt_cmd(); + pstring cmd = opt_cmd.as_string(); if (cmd == "listdevices") listdevices(); else if (cmd == "run") @@ -734,19 +734,19 @@ int tool_app_t::execute() contents = ostrm.str(); pstring result; - if (opt_type() == "spice") + if (opt_type.as_string() == "spice") { nl_convert_spice_t c; c.convert(contents); result = c.result(); } - else if (opt_type() == "eagle") + else if (opt_type.as_string() == "eagle") { nl_convert_eagle_t c; c.convert(contents); result = c.result(); } - else if (opt_type() == "rinf") + else if (opt_type.as_string() == "rinf") { nl_convert_rinf_t c; c.convert(contents); diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp index 23491e88349..a1f14692364 100644 --- a/src/lib/netlist/prg/nlwav.cpp +++ b/src/lib/netlist/prg/nlwav.cpp @@ -24,8 +24,8 @@ public: {} plib::option_str opt_inp; plib::option_str opt_out; - plib::option_double opt_amp; - plib::option_long opt_rate; + plib::option_num opt_amp; + plib::option_num opt_rate; plib::option_bool opt_verb; plib::option_bool opt_quiet; plib::option_bool opt_version; diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index 2158d725694..ad62ba17c28 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -268,7 +268,7 @@ void NETLIB_NAME(solver)::post_start() // Override log statistics pstring p = plib::util::environment("NL_STATS", ""); if (p != "") - m_params.m_log_stats = plib::pstol(p); + m_params.m_log_stats = plib::pstonum(p); else m_params.m_log_stats = m_log_stats(); diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp index aff7d0da81b..4488396a131 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -214,7 +214,7 @@ double nl_convert_base_t::get_sp_val(const pstring &sin) ++p; pstring val = plib::left(sin, p); pstring unit = sin.substr(p); - double ret = get_sp_unit(unit) * plib::pstod(val); + double ret = get_sp_unit(unit) * plib::pstonum(val); return ret; } @@ -304,11 +304,12 @@ void nl_convert_spice_t::process_line(const pstring &line) /* check for fourth terminal ... should be numeric net * including "0" or start with "N" (ltspice) */ - long nval = 0; pstring model; pstring pins ="CBE"; + bool err; + ATTR_UNUSED long nval = plib::pstonum_ne(tt[4], err); - if ((!plib::pstol_ne(tt[4], nval) || plib::startsWith(tt[4], "N")) && tt.size() > 5) + if ((err || plib::startsWith(tt[4], "N")) && tt.size() > 5) model = tt[5]; else model = tt[4]; @@ -492,7 +493,7 @@ void nl_convert_eagle_t::convert(const pstring &contents) else if (plib::ucase(sval) == "LOW") add_device("TTL_INPUT", name, 0); else - add_device("ANALOG_INPUT", name, plib::pstod(sval)); + add_device("ANALOG_INPUT", name, plib::pstonum(sval)); add_pin_alias(name, "1", "Q"); break; case 'D': -- cgit v1.2.3-70-g09d2 From f12f735f54966b992d23d0502027e8e6d9e1dd95 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 11 Jan 2019 21:50:43 +0100 Subject: Fix clang-8 warnings. (nw) --- src/lib/netlist/build/makefile | 2 +- src/lib/netlist/devices/nld_7483.cpp | 6 +++--- src/lib/netlist/devices/nld_7490.cpp | 3 ++- src/lib/netlist/devices/nld_7497.cpp | 4 ++-- src/lib/netlist/devices/nld_82S16.cpp | 4 ++-- src/lib/netlist/devices/nld_9316.cpp | 2 +- src/lib/netlist/devices/nlid_truthtable.cpp | 2 +- src/lib/netlist/macro/nlm_base.cpp | 14 +++++++------- src/lib/netlist/nl_base.cpp | 4 +--- src/lib/netlist/nl_base.h | 2 +- src/lib/netlist/nl_factory.h | 1 + src/lib/netlist/nl_parser.cpp | 2 +- src/lib/netlist/plib/palloc.h | 2 +- src/lib/netlist/plib/pexception.h | 2 +- src/lib/netlist/plib/pfmtlog.cpp | 2 +- src/lib/netlist/plib/pfunction.cpp | 4 ++-- src/lib/netlist/plib/pomp.h | 10 +++++----- src/lib/netlist/plib/pstring.h | 4 +++- src/lib/netlist/plib/putil.h | 3 +++ src/lib/netlist/solver/nld_matrix_solver.h | 2 +- src/lib/netlist/solver/nld_ms_direct.h | 13 +++++-------- src/lib/netlist/solver/nld_ms_direct1.h | 2 +- src/lib/netlist/solver/nld_ms_direct2.h | 2 +- src/lib/netlist/solver/nld_ms_gmres.h | 11 +++++------ src/lib/netlist/solver/nld_solver.cpp | 9 +++++---- src/lib/netlist/solver/vector_base.h | 1 + src/lib/netlist/tools/nl_convert.cpp | 4 ++-- 27 files changed, 60 insertions(+), 57 deletions(-) (limited to 'src/lib/netlist/plib/pstring.h') diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 8c7a4bc59b5..84a0b77bf0a 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -204,7 +204,7 @@ maketree: $(sort $(OBJDIRS)) .PHONY: clang clang-5 mingw doc clang: - $(MAKE) CC=clang++ LD=clang++ CEXTRAFLAGS="-march=native -Weverything -Werror -override -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors" + $(MAKE) CC=clang++ LD=clang++ CEXTRAFLAGS="-march=native -Weverything -Werror -override -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wweak-template-vtables -Wno-exit-time-destructors" clang-5: $(MAKE) CC=clang++-5.0 LD=clang++-5.0 CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-inconsistent-missing-destructor-override -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors" diff --git a/src/lib/netlist/devices/nld_7483.cpp b/src/lib/netlist/devices/nld_7483.cpp index e3c31a691ae..395840b2549 100644 --- a/src/lib/netlist/devices/nld_7483.cpp +++ b/src/lib/netlist/devices/nld_7483.cpp @@ -95,19 +95,19 @@ namespace netlist NETLIB_HANDLER(7483, upd_a) { - m_a = (m_A1() << 0) | (m_A2() << 1) | (m_A3() << 2) | (m_A4() << 3); + m_a = static_cast((m_A1() << 0) | (m_A2() << 1) | (m_A3() << 2) | (m_A4() << 3)); NETLIB_NAME(7483)::update(); } NETLIB_HANDLER(7483, upd_b) { - m_b = (m_B1() << 0) | (m_B2() << 1) | (m_B3() << 2) | (m_B4() << 3); + m_b = static_cast((m_B1() << 0) | (m_B2() << 1) | (m_B3() << 2) | (m_B4() << 3)); NETLIB_NAME(7483)::update(); } inline NETLIB_UPDATE(7483) { - uint8_t r = m_a + m_b + m_C0(); + uint8_t r = static_cast(m_a + m_b + m_C0()); if (r != m_lastr) { diff --git a/src/lib/netlist/devices/nld_7490.cpp b/src/lib/netlist/devices/nld_7490.cpp index efec051f440..ccd839d83e9 100644 --- a/src/lib/netlist/devices/nld_7490.cpp +++ b/src/lib/netlist/devices/nld_7490.cpp @@ -83,7 +83,8 @@ namespace netlist NLTIME_FROM_NS(18), NLTIME_FROM_NS(36) - NLTIME_FROM_NS(18), NLTIME_FROM_NS(54) - NLTIME_FROM_NS(18), - NLTIME_FROM_NS(72) - NLTIME_FROM_NS(18)}; + NLTIME_FROM_NS(72) - NLTIME_FROM_NS(18) + }; NETLIB_UPDATE(7490) { diff --git a/src/lib/netlist/devices/nld_7497.cpp b/src/lib/netlist/devices/nld_7497.cpp index 12e77239d61..9b515c1a8eb 100644 --- a/src/lib/netlist/devices/nld_7497.cpp +++ b/src/lib/netlist/devices/nld_7497.cpp @@ -74,9 +74,9 @@ namespace netlist m_Y.push(y, out_delay_CLK_Y[y]); } - int rate() + uint8_t rate() { - int a = 0; + uint8_t a = 0; for (std::size_t i = 0; i < 6; i++) a |= (m_B[i]() << i); diff --git a/src/lib/netlist/devices/nld_82S16.cpp b/src/lib/netlist/devices/nld_82S16.cpp index fa9ac7b03c7..52385cf7e5b 100644 --- a/src/lib/netlist/devices/nld_82S16.cpp +++ b/src/lib/netlist/devices/nld_82S16.cpp @@ -49,14 +49,14 @@ namespace netlist { // FIXME: Outputs are tristate. This needs to be properly implemented m_DOUTQ.push(1, NLTIME_FROM_NS(20)); - for (int i=0; i<8; i++) + for (std::size_t i=0; i<8; i++) m_A[i].inactivate(); m_WEQ.inactivate(); m_DIN.inactivate(); } else if (last && !m_enq) { - for (int i=0; i<8; i++) + for (std::size_t i=0; i<8; i++) m_A[i].activate(); m_WEQ.activate(); m_DIN.activate(); diff --git a/src/lib/netlist/devices/nld_9316.cpp b/src/lib/netlist/devices/nld_9316.cpp index 972a575cd03..7b1be9aa48d 100644 --- a/src/lib/netlist/devices/nld_9316.cpp +++ b/src/lib/netlist/devices/nld_9316.cpp @@ -40,7 +40,7 @@ namespace netlist NETLIB_HANDLERI(clk); NETLIB_HANDLERI(abcd) { - m_abcd = (m_D() << 3) | (m_C() << 2) | (m_B() << 1) | (m_A() << 0); + m_abcd = static_cast((m_D() << 3) | (m_C() << 2) | (m_B() << 1) | (m_A() << 0)); } logic_input_t m_CLK; diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index 88291be0ad7..0b53652df6c 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -448,7 +448,7 @@ void truthtable_parser::parse(const std::vector &truthtable) { if (m_out_state[i] == m_out_state.mask()) throw nl_exception(plib::pfmt("truthtable: found element not set {1}\n").x(i) ); - m_out_state.set(i, m_out_state[i] | (ign[i] << m_NO));; + m_out_state.set(i, m_out_state[i] | (ign[i] << m_NO)); } *m_initialized = true; diff --git a/src/lib/netlist/macro/nlm_base.cpp b/src/lib/netlist/macro/nlm_base.cpp index 47a314f45ec..6a75f3ddc89 100644 --- a/src/lib/netlist/macro/nlm_base.cpp +++ b/src/lib/netlist/macro/nlm_base.cpp @@ -83,13 +83,13 @@ NETLIST_START(base) LOCAL_SOURCE(OPAMP_lib) LOCAL_SOURCE(otheric_lib) - INCLUDE(diode_models); - INCLUDE(bjt_models); - INCLUDE(family_models); - INCLUDE(TTL74XX_lib); - INCLUDE(CD4XXX_lib); - INCLUDE(OPAMP_lib); - INCLUDE(otheric_lib); + INCLUDE(diode_models) + INCLUDE(bjt_models) + INCLUDE(family_models) + INCLUDE(TTL74XX_lib) + INCLUDE(CD4XXX_lib) + INCLUDE(OPAMP_lib) + INCLUDE(otheric_lib) NETLIST_END() diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index f6f10acb4c5..cfca9bf271f 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -293,8 +293,6 @@ void netlist_t::remove_dev(core_device_t *dev) ); } - - void netlist_t::start() { setup().start_devices(); @@ -344,7 +342,7 @@ void netlist_t::start() if (p != setup().m_param_values.end()) { //FIXME: check for errors ... - double v = plib::pstonum(p->second);; + double v = plib::pstonum(p->second); if (std::abs(v - std::floor(v)) > 1e-6 ) log().fatal(MF_1_HND_VAL_NOT_SUPPORTED, p->second); d->set_hint_deactivate(v == 0.0); diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 4903807e15a..83caa98b84e 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -153,7 +153,7 @@ class NETLIB_NAME(name) : public device_t #define NETLIB_UPDATE(chip) NETLIB_HANDLER(chip, update) // FIXME: NETLIB_PARENT_UPDATE should disappear -#define NETLIB_PARENT_UPDATE(chip) NETLIB_NAME(chip) :: update(); +#define NETLIB_PARENT_UPDATE(chip) NETLIB_NAME(chip) :: update() #define NETLIB_RESET(chip) void NETLIB_NAME(chip) :: reset(void) diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index ed82090915e..2e5ba33c8b1 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -36,6 +36,7 @@ { \ return std::unique_ptr(plib::palloc>(name, classname, def_param, pstring(__FILE__))); \ } \ + \ factory::constructor_ptr_t decl_ ## chip = NETLIB_NAME(chip ## _c); namespace netlist { diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index 1ff6ef6c6b7..a2ab7623b3b 100644 --- a/src/lib/netlist/nl_parser.cpp +++ b/src/lib/netlist/nl_parser.cpp @@ -30,7 +30,7 @@ bool parser_t::parse(const pstring &nlname) set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"); set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers //set_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13)); - set_whitespace(pstring("") + ' ' + (char)9 + (char)10 + (char)13); + set_whitespace(pstring("") + ' ' + static_cast(9) + static_cast(10) + static_cast(13)); set_comment("/*", "*/", "//"); m_tok_param_left = register_token("("); m_tok_param_right = register_token(")"); diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 264cc656bbf..de992b7bc50 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -52,7 +52,7 @@ std::unique_ptr make_unique(Args&&... args) } template -static std::unique_ptr make_unique_base(Args&&... args) +std::unique_ptr make_unique_base(Args&&... args) { std::unique_ptr ret(new DC(std::forward(args)...)); return ret; diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h index 4827081b754..1a5957099fd 100644 --- a/src/lib/netlist/plib/pexception.h +++ b/src/lib/netlist/plib/pexception.h @@ -23,7 +23,7 @@ public: explicit pexception(const pstring &text); pexception(const pexception &e) : std::exception(e), m_text(e.m_text) { } - virtual ~pexception() noexcept; + virtual ~pexception() noexcept override; const pstring &text() { return m_text; } const char* what() const noexcept override { return m_text.c_str(); } diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp index 381c19bc349..2c120f6b7a4 100644 --- a/src/lib/netlist/plib/pfmtlog.cpp +++ b/src/lib/netlist/plib/pfmtlog.cpp @@ -69,7 +69,7 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) if (pstring("duxo").find(cfmt_spec) != pstring::npos) { if (pstring("duxo").find(pend) == pstring::npos) - fmt += (pstring(l) + (char) cfmt_spec); + fmt += (pstring(l) + static_cast(cfmt_spec)); else fmt = plib::left(fmt, fmt.size() - 1) + pstring(l) + plib::right(fmt, 1); } diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp index f2ef3522813..f08fa2c60ea 100644 --- a/src/lib/netlist/plib/pfunction.cpp +++ b/src/lib/netlist/plib/pfunction.cpp @@ -199,8 +199,8 @@ double pfunction::evaluate(const std::vector &values) OP(SUB, 1, ST2 - ST1) OP(DIV, 1, ST2 / ST1) OP(POW, 1, std::pow(ST2, ST1)) - OP(SIN, 0, std::sin(ST2)); - OP(COS, 0, std::cos(ST2)); + OP(SIN, 0, std::sin(ST2)) + OP(COS, 0, std::cos(ST2)) case RAND: stack[ptr++] = lfsr_random(); break; diff --git a/src/lib/netlist/plib/pomp.h b/src/lib/netlist/plib/pomp.h index 6559207f09d..221c0d61c00 100644 --- a/src/lib/netlist/plib/pomp.h +++ b/src/lib/netlist/plib/pomp.h @@ -18,8 +18,8 @@ namespace plib { namespace omp { -template -void for_static(const int start, const int end, const T &what) +template +void for_static(const I start, const I end, const T &what) { #if HAS_OPENMP && USE_OPENMP #pragma omp parallel @@ -28,19 +28,19 @@ void for_static(const int start, const int end, const T &what) #if HAS_OPENMP && USE_OPENMP #pragma omp for schedule(static) #endif - for (int i = start; i < end; i++) + for (I i = start; i < end; i++) what(i); } } -inline void set_num_threads(const int threads) +inline void set_num_threads(const std::size_t threads) { #if HAS_OPENMP && USE_OPENMP omp_set_num_threads(threads); #endif } -inline int get_max_threads() +inline std::size_t get_max_threads() { #if HAS_OPENMP && USE_OPENMP return omp_get_max_threads(); diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 677ce9e43b8..ebdca57c9a5 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -561,7 +561,9 @@ namespace plib decltype(arg.c_str()) cstr = arg.c_str(); std::size_t idx(0); auto ret = pstonum_helper()(cstr, &idx); - if (ret >= std::numeric_limits::lowest() && ret <= std::numeric_limits::max()) + typedef decltype(ret) ret_type; + if (ret >= static_cast(std::numeric_limits::lowest()) + && ret <= static_cast(std::numeric_limits::max())) //&& (ret == T(0) || std::abs(ret) >= std::numeric_limits::min() )) { if (cstr[idx] != 0) diff --git a/src/lib/netlist/plib/putil.h b/src/lib/netlist/plib/putil.h index 914d9820560..05cc44f5f68 100644 --- a/src/lib/netlist/plib/putil.h +++ b/src/lib/netlist/plib/putil.h @@ -74,6 +74,9 @@ namespace plib std::vector psplit(const pstring &str, const pstring &onstr, bool ignore_empty = false); std::vector psplit(const pstring &str, const std::vector &onstrl); + std::vector psplit_r(const std::string &stri, + const std::string &token, + const std::size_t maxsplit); } diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index da44370d0d9..d60a16499b6 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -232,7 +232,7 @@ void matrix_solver_t::build_LE_A() for (std::size_t k = 0; k < iN; k++) { terms_for_net_t *terms = m_terms[k].get(); - nl_double * Ak = &child.A(k, 0); + nl_double * Ak = &child.A(k, 0ul); for (std::size_t i=0; i < iN; i++) Ak[i] = 0.0; diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h index f03cb738028..639d9f4ee18 100644 --- a/src/lib/netlist/solver/nld_ms_direct.h +++ b/src/lib/netlist/solver/nld_ms_direct.h @@ -9,6 +9,7 @@ #define NLD_MS_DIRECT_H_ #include +#include #include "nld_solver.h" #include "nld_matrix_solver.h" @@ -55,15 +56,11 @@ protected: void LE_back_subst(T * RESTRICT x); #if (NL_USE_DYNAMIC_ALLOCATION) - template - nl_ext_double &A(const T1 &r, const T2 &c) { return m_A[r * m_pitch + c]; } - template - nl_ext_double &RHS(const T1 &r) { return m_A[r * m_pitch + N()]; } + nl_ext_double &A(const std::size_t r, const std::size_t c) { return m_A[r * m_pitch + c]; } + nl_ext_double &RHS(const std::size_t r) { return m_A[r * m_pitch + N()]; } #else - template - nl_ext_double &A(const T1 &r, const T2 &c) { return m_A[r][c]; } - template - nl_ext_double &RHS(const T1 &r) { return m_A[r][N()]; } + nl_ext_double &A(const std::size_t r, const std::size_t c) { return m_A[r][c]; } + nl_ext_double &RHS(const std::size_t r) { return m_A[r][N()]; } #endif nl_double m_last_RHS[storage_N]; // right hand side - contains currents diff --git a/src/lib/netlist/solver/nld_ms_direct1.h b/src/lib/netlist/solver/nld_ms_direct1.h index 6e1f99bad7d..4967a9dc637 100644 --- a/src/lib/netlist/solver/nld_ms_direct1.h +++ b/src/lib/netlist/solver/nld_ms_direct1.h @@ -30,7 +30,7 @@ public: // matrix_solver - Direct1 // ---------------------------------------------------------------------------------------- -inline unsigned matrix_solver_direct1_t::vsolve_non_dynamic(ATTR_UNUSED const bool newton_raphson) +inline unsigned matrix_solver_direct1_t::vsolve_non_dynamic(const bool newton_raphson) { build_LE_A(); build_LE_RHS(); diff --git a/src/lib/netlist/solver/nld_ms_direct2.h b/src/lib/netlist/solver/nld_ms_direct2.h index 4004bce9cc4..65cf30c0202 100644 --- a/src/lib/netlist/solver/nld_ms_direct2.h +++ b/src/lib/netlist/solver/nld_ms_direct2.h @@ -30,7 +30,7 @@ public: // matrix_solver - Direct2 // ---------------------------------------------------------------------------------------- -inline unsigned matrix_solver_direct2_t::vsolve_non_dynamic(ATTR_UNUSED const bool newton_raphson) +inline unsigned matrix_solver_direct2_t::vsolve_non_dynamic(const bool newton_raphson) { build_LE_A(); build_LE_RHS(); diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h index 2e4e447d14f..323def01d32 100644 --- a/src/lib/netlist/solver/nld_ms_gmres.h +++ b/src/lib/netlist/solver/nld_ms_gmres.h @@ -13,6 +13,7 @@ #define NLD_MS_GMRES_H_ #include +#include #include "mat_cr.h" #include "nld_ms_direct.h" @@ -167,21 +168,19 @@ unsigned matrix_solver_GMRES_t::vsolve_non_dynamic(const bool ne new_V[k] = this->m_nets[k]->Q_Analog(); } - mat.ia[iN] = static_cast(mat.nz_num); + mat.ia[iN] = static_cast(mat.nz_num); const nl_double accuracy = this->m_params.m_accuracy; - unsigned mr = iN; - if (iN > 3 ) - mr = static_cast(std::sqrt(iN) * 2.0); + const std::size_t mr = (iN > 3 ) ? static_cast(std::sqrt(iN) * 2.0) : iN; unsigned iter = std::max(1u, this->m_params.m_gs_loops); unsigned gsl = solve_ilu_gmres(new_V, RHS, iter, mr, accuracy); - unsigned failed = mr * iter; + const std::size_t failed = mr * iter; this->m_iterative_total += gsl; this->m_stat_calculations++; - if (gsl>=failed) + if (gsl >= failed) { this->m_iterative_fail++; return matrix_solver_direct_t::vsolve_non_dynamic(newton_raphson); diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index d639bc6c858..09f0173b339 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -93,17 +93,18 @@ NETLIB_UPDATE(solver) /* FIXME: Needs a more elegant solution */ bool force_solve = (netlist().time() < netlist_time::from_double(2 * m_params.m_max_timestep)); - std::size_t nthreads = std::min(m_parallel(), plib::omp::get_max_threads()); + std::size_t nthreads = std::min(static_cast(m_parallel()), plib::omp::get_max_threads()); std::size_t t_cnt = 0; - int solv[128]; - for (int i = 0; i < m_mat_solvers.size(); i++) + std::size_t solv[128]; + for (std::size_t i = 0; i < m_mat_solvers.size(); i++) if (m_mat_solvers[i]->has_timestep_devices() || force_solve) solv[t_cnt++] = i; if (nthreads > 1 && t_cnt > 1) { plib::omp::set_num_threads(nthreads); - plib::omp::for_static(0, t_cnt, [this, &solv](int i) { ATTR_UNUSED const netlist_time ts = this->m_mat_solvers[solv[i]]->solve(); }); + plib::omp::for_static(static_cast(0), t_cnt, [this, &solv](std::size_t i) + { ATTR_UNUSED const netlist_time ts = this->m_mat_solvers[solv[i]]->solve(); }); } else for (auto & solver : m_mat_solvers) diff --git a/src/lib/netlist/solver/vector_base.h b/src/lib/netlist/solver/vector_base.h index 28f5fa0dd44..218ae9d81f3 100644 --- a/src/lib/netlist/solver/vector_base.h +++ b/src/lib/netlist/solver/vector_base.h @@ -11,6 +11,7 @@ #define VECTOR_BASE_H_ #include +#include #include "../plib/pconfig.h" #if 0 diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp index 4488396a131..b89e94ca3e5 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -408,7 +408,7 @@ nl_convert_eagle_t::tokenizer::tokenizer(nl_convert_eagle_t &convert, plib::putf set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"); set_number_chars(".0123456789", "0123456789eE-."); //FIXME: processing of numbers //set_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13)); - set_whitespace(pstring("") + ' ' + (char)9 + (char)10 + (char)13); + set_whitespace(pstring("") + ' ' + static_cast(9) + static_cast(10) + static_cast(13)); /* FIXME: gnetlist doesn't print comments */ set_comment("/*", "*/", "//"); set_string_char('\''); @@ -546,7 +546,7 @@ nl_convert_rinf_t::tokenizer::tokenizer(nl_convert_rinf_t &convert, plib::putf8_ set_identifier_chars(".abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-"); set_number_chars("0123456789", "0123456789eE-."); //FIXME: processing of numbers //set_whitespace(pstring("").cat(' ').cat(9).cat(10).cat(13)); - set_whitespace(pstring("") + ' ' + (char)9 + (char)10 + (char)13); + set_whitespace(pstring("") + ' ' + static_cast(9) + static_cast(10) + static_cast(13)); /* FIXME: gnetlist doesn't print comments */ set_comment("","","//"); // FIXME:needs to be confirmed set_string_char('"'); -- cgit v1.2.3-70-g09d2 From 633528eb31e7f318e6934476c85126dcf02fd457 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 13 Jan 2019 00:08:47 +0100 Subject: Improve dealing ownership in pstreams. (nw) I am not really happy with this. But I am missing some creativity currently. --- src/lib/netlist/devices/nld_log.cpp | 4 +- src/lib/netlist/nl_parser.h | 4 +- src/lib/netlist/nl_setup.cpp | 14 +-- src/lib/netlist/nl_setup.h | 2 +- src/lib/netlist/plib/pmain.cpp | 4 +- src/lib/netlist/plib/pparser.cpp | 4 +- src/lib/netlist/plib/pparser.h | 4 +- src/lib/netlist/plib/pstream.cpp | 29 ++--- src/lib/netlist/plib/pstream.h | 210 +++++++++++++++++++++++++++++------ src/lib/netlist/plib/pstring.h | 2 + src/lib/netlist/prg/nltool.cpp | 9 +- src/lib/netlist/prg/nlwav.cpp | 27 +++-- src/lib/netlist/solver/nld_ms_gcr.h | 4 +- src/lib/netlist/tools/nl_convert.cpp | 22 ++-- src/lib/netlist/tools/nl_convert.h | 4 +- 15 files changed, 239 insertions(+), 104 deletions(-) (limited to 'src/lib/netlist/plib/pstring.h') diff --git a/src/lib/netlist/devices/nld_log.cpp b/src/lib/netlist/devices/nld_log.cpp index 8125dacafe8..1d3ea7b1b75 100644 --- a/src/lib/netlist/devices/nld_log.cpp +++ b/src/lib/netlist/devices/nld_log.cpp @@ -19,8 +19,8 @@ namespace netlist { NETLIB_CONSTRUCTOR(log) , m_I(*this, "I") - , m_strm(plib::pfmt("{1}.log")(this->name())) - , m_writer(m_strm) + , m_strm(pstring(plib::pfmt("{1}.log")(this->name()))) + , m_writer(&m_strm) { } diff --git a/src/lib/netlist/nl_parser.h b/src/lib/netlist/nl_parser.h index a813629faa0..872cfa11954 100644 --- a/src/lib/netlist/nl_parser.h +++ b/src/lib/netlist/nl_parser.h @@ -16,8 +16,8 @@ namespace netlist class parser_t : public plib::ptokenizer { public: - parser_t(plib::putf8_reader &strm, setup_t &setup) - : plib::ptokenizer(strm), m_setup(setup) {} + parser_t(plib::putf8_reader &&strm, setup_t &setup) + : plib::ptokenizer(std::move(strm)), m_setup(setup) {} bool parse(const pstring &nlname = ""); diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index 28385d984cf..a02d5f5bbae 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -965,15 +965,15 @@ std::unique_ptr setup_t::get_data_stream(const pstring &name) } -bool setup_t::parse_stream(plib::putf8_reader &istrm, const pstring &name) +bool setup_t::parse_stream(plib::putf8_reader &&istrm, const pstring &name) { plib::pomemstream ostrm; - plib::putf8_writer owrt(ostrm); + plib::putf8_writer owrt(&ostrm); plib::ppreprocessor(&m_defines).process(istrm, owrt); - plib::pimemstream istrm2(ostrm); - plib::putf8_reader reader2(istrm2); - return parser_t(reader2, *this).parse(name); + plib::putf8_reader reader2 = plib::putf8_reader(plib::pimemstream(ostrm)); + + return parser_t(std::move(reader2), *this).parse(name); } void setup_t::register_define(const pstring &defstr) @@ -996,8 +996,8 @@ bool source_t::parse(const pstring &name) else { auto rstream = stream(name); - plib::putf8_reader reader(*rstream); - return m_setup.parse_stream(reader, name); + plib::putf8_reader reader(rstream.get()); + return m_setup.parse_stream(std::move(reader), name); } } diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 4f7146b3995..cae829023a4 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -259,7 +259,7 @@ namespace netlist std::unique_ptr get_data_stream(const pstring &name); - bool parse_stream(plib::putf8_reader &istrm, const pstring &name); + bool parse_stream(plib::putf8_reader &&istrm, const pstring &name); /* register a source */ diff --git a/src/lib/netlist/plib/pmain.cpp b/src/lib/netlist/plib/pmain.cpp index 6edfe86b838..30b4a1948bd 100644 --- a/src/lib/netlist/plib/pmain.cpp +++ b/src/lib/netlist/plib/pmain.cpp @@ -37,8 +37,8 @@ namespace plib { : options() , pout_strm() , perr_strm() - , pout(pout_strm) - , perr(perr_strm) + , pout(&pout_strm) + , perr(&perr_strm) { } diff --git a/src/lib/netlist/plib/pparser.cpp b/src/lib/netlist/plib/pparser.cpp index b18b3265440..2d1a426f5a5 100644 --- a/src/lib/netlist/plib/pparser.cpp +++ b/src/lib/netlist/plib/pparser.cpp @@ -16,8 +16,8 @@ namespace plib { // A simple tokenizer // ---------------------------------------------------------------------------------------- -ptokenizer::ptokenizer(plib::putf8_reader &strm) -: m_strm(strm), m_lineno(0), m_cur_line(""), m_px(m_cur_line.begin()), m_unget(0), m_string('"') +ptokenizer::ptokenizer(plib::putf8_reader &&strm) +: m_strm(std::move(strm)), m_lineno(0), m_cur_line(""), m_px(m_cur_line.begin()), m_unget(0), m_string('"') { } diff --git a/src/lib/netlist/plib/pparser.h b/src/lib/netlist/plib/pparser.h index 0dc2eb7dfbc..eb4f253c79b 100644 --- a/src/lib/netlist/plib/pparser.h +++ b/src/lib/netlist/plib/pparser.h @@ -19,7 +19,7 @@ namespace plib { class ptokenizer : nocopyassignmove { public: - explicit ptokenizer(plib::putf8_reader &strm); + ptokenizer(plib::putf8_reader &&strm); virtual ~ptokenizer(); @@ -123,7 +123,7 @@ private: bool eof() { return m_strm.eof(); } - putf8_reader &m_strm; + putf8_reader m_strm; int m_lineno; pstring m_cur_line; diff --git a/src/lib/netlist/plib/pstream.cpp b/src/lib/netlist/plib/pstream.cpp index 50a39685f70..e0094e99e38 100644 --- a/src/lib/netlist/plib/pstream.cpp +++ b/src/lib/netlist/plib/pstream.cpp @@ -41,14 +41,6 @@ postream::~postream() { } -void postream::write(pistream &strm) -{ - char buf[1024]; - pos_type r; - while ((r=strm.read(buf, 1024)) > 0) - write(buf, r); -} - // ----------------------------------------------------------------------------- // Input file stream // ----------------------------------------------------------------------------- @@ -119,7 +111,7 @@ void pifilestream::vseek(const pos_type n) throw file_e("Generic file operation failed: {}", m_filename); } -pifilestream::pos_type pifilestream::vtell() +pifilestream::pos_type pifilestream::vtell() const { long ret = ftell(static_cast(m_file)); if (ret < 0) @@ -204,7 +196,7 @@ void pofilestream::vseek(const pos_type n) } } -pstream::pos_type pofilestream::vtell() +pstream::pos_type pofilestream::vtell() const { std::ptrdiff_t ret = ftell(static_cast(m_file)); if (ret < 0) @@ -263,6 +255,11 @@ pimemstream::pimemstream(const void *mem, const pos_type len) { } +pimemstream::pimemstream() + : pistream(FLAG_SEEKABLE), m_pos(0), m_len(0), m_mem(static_cast(nullptr)) +{ +} + pimemstream::pimemstream(const pomemstream &ostrm) : pistream(FLAG_SEEKABLE), m_pos(0), m_len(ostrm.size()), m_mem(reinterpret_cast(ostrm.memory())) { @@ -295,7 +292,7 @@ void pimemstream::vseek(const pos_type n) } -pimemstream::pos_type pimemstream::vtell() +pimemstream::pos_type pimemstream::vtell() const { return m_pos; } @@ -316,7 +313,8 @@ pomemstream::pomemstream() pomemstream::~pomemstream() { - pfree_array(m_mem); + if (m_mem != nullptr) + pfree_array(m_mem); } void pomemstream::vwrite(const void *buf, const pos_type n) @@ -359,7 +357,7 @@ void pomemstream::vseek(const pos_type n) } } -pstream::pos_type pomemstream::vtell() +pstream::pos_type pomemstream::vtell() const { return m_pos; } @@ -386,11 +384,6 @@ bool putf8_reader::readline(pstring &line) return true; } -putf8_fmt_writer::putf8_fmt_writer(postream &strm) -: pfmt_writer_t() -, putf8_writer(strm) -{ -} putf8_fmt_writer::~putf8_fmt_writer() { diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index a97ecd5cbd4..e8b6c38ac66 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -11,30 +11,51 @@ #include "pstring.h" #include "pfmtlog.h" #include "pexception.h" +#include "palloc.h" + +#define USE_CSTREAM (0) #include +#include + +#if USE_CSTREAM +#include +//#include +#include +#endif + namespace plib { + +#if USE_CSTREAM +typedef std::ostream postream; +typedef std::ofstream pofilestream; +typedef std::ostringstream postringstream; +typedef std::ostringstream pomemstream; + +#endif + // ----------------------------------------------------------------------------- // pstream: things common to all streams // ----------------------------------------------------------------------------- -class pstream : nocopyassignmove +class pstream : nocopyassign { public: using pos_type = std::size_t; + using size_type = std::size_t; static constexpr pos_type SEEK_EOF = static_cast(-1); bool seekable() const { return ((m_flags & FLAG_SEEKABLE) != 0); } - void seek(const pos_type n) + void seekp(const pos_type n) { - return vseek(n); + vseek(n); } - pos_type tell() + pos_type tellp() const { return vtell(); } @@ -43,10 +64,13 @@ protected: explicit pstream(const unsigned flags) : m_flags(flags) { } + pstream(pstream &&src) : m_flags(src.m_flags) + { + } ~pstream(); virtual void vseek(const pos_type n) = 0; - virtual pos_type vtell() = 0; + virtual pos_type vtell() const = 0; static constexpr unsigned FLAG_EOF = 0x01; static constexpr unsigned FLAG_SEEKABLE = 0x04; @@ -84,8 +108,9 @@ public: protected: explicit pistream(const unsigned flags) : pstream(flags) {} + explicit pistream(pistream &&src) : pstream(std::move(src)) {} /* read up to n bytes from stream */ - virtual pos_type vread(void *buf, const pos_type n) = 0; + virtual size_type vread(void *buf, const size_type n) = 0; }; @@ -93,23 +118,23 @@ protected: // postream: output stream // ----------------------------------------------------------------------------- +#if !USE_CSTREAM class postream : public pstream { public: virtual ~postream(); - void write(const void *buf, const pos_type n) + void write(const char *buf, const size_type n) { vwrite(buf, n); } - void write(pistream &strm); - protected: explicit postream(unsigned flags) : pstream(flags) {} + explicit postream(postream &&src) : pstream(std::move(src)) {} /* write n bytes to stream */ - virtual void vwrite(const void *buf, const pos_type n) = 0; + virtual void vwrite(const void *buf, const size_type n) = 0; private: }; @@ -123,6 +148,17 @@ class pomemstream : public postream public: pomemstream(); + + pomemstream(pomemstream &&src) + : postream(std::move(src)) + , m_pos(src.m_pos) + , m_capacity(src.m_capacity) + , m_size(src.m_size) + , m_mem(src.m_mem) + { + src.m_mem = nullptr; + } + virtual ~pomemstream() override; char *memory() const { return m_mem; } @@ -132,7 +168,7 @@ protected: /* write n bytes to stream */ virtual void vwrite(const void *buf, const pos_type) override; virtual void vseek(const pos_type n) override; - virtual pos_type vtell() override; + virtual pos_type vtell() const override; private: pos_type m_pos; @@ -146,6 +182,11 @@ class postringstream : public postream public: postringstream() : postream(0) { } + postringstream(postringstream &&src) + : postream(std::move(src)) + , m_buf(src.m_buf) + { src.m_buf = ""; } + virtual ~postringstream() override; const pstring &str() { return m_buf; } @@ -157,7 +198,7 @@ protected: m_buf += pstring(static_cast(buf), n); } virtual void vseek(const pos_type n) override { } - virtual pos_type vtell() override { return m_buf.size(); } + virtual pos_type vtell() const override { return m_buf.size(); } private: pstring m_buf; @@ -171,7 +212,18 @@ class pofilestream : public postream { public: - explicit pofilestream(const pstring &fname); + pofilestream(const pstring &fname); + pofilestream(pofilestream &&src) + : postream(std::move(src)) + , m_file(src.m_file) + , m_pos(src.m_pos) + , m_actually_close(src.m_actually_close) + , m_filename(src.m_filename) + { + src.m_file = nullptr; + src.m_actually_close = false; + } + virtual ~pofilestream() override; protected: @@ -179,7 +231,7 @@ protected: /* write n bytes to stream */ virtual void vwrite(const void *buf, const pos_type n) override; virtual void vseek(const pos_type n) override; - virtual pos_type vtell() override; + virtual pos_type vtell() const override; private: void *m_file; @@ -193,6 +245,7 @@ private: // ----------------------------------------------------------------------------- // pstderr: write to stderr // ----------------------------------------------------------------------------- +#endif class pstderr : public pofilestream { @@ -220,16 +273,27 @@ class pifilestream : public pistream { public: - explicit pifilestream(const pstring &fname); + pifilestream(const pstring &fname); virtual ~pifilestream() override; + pifilestream(pifilestream &&src) + : pistream(std::move(src)) + , m_file(src.m_file) + , m_pos(src.m_pos) + , m_actually_close(src.m_actually_close) + , m_filename(src.m_filename) + { + src.m_actually_close = false; + src.m_file = nullptr; + } + protected: pifilestream(void *file, const pstring &name, const bool do_close); /* read up to n bytes from stream */ virtual pos_type vread(void *buf, const pos_type n) override; virtual void vseek(const pos_type n) override; - virtual pos_type vtell() override; + virtual pos_type vtell() const override; private: void *m_file; @@ -261,15 +325,34 @@ class pimemstream : public pistream public: pimemstream(const void *mem, const pos_type len); + pimemstream(); + + pimemstream(pimemstream &&src) + : pistream(std::move(src)) + , m_pos(src.m_pos) + , m_len(src.m_len) + , m_mem(src.m_mem) + { + src.m_mem = nullptr; + } + explicit pimemstream(const pomemstream &ostrm); + virtual ~pimemstream() override; pos_type size() const { return m_len; } protected: + + void set_mem(const void *mem, const pos_type len) + { + m_mem = static_cast(mem); + m_len = len; + } + /* read up to n bytes from stream */ virtual pos_type vread(void *buf, const pos_type n) override; virtual void vseek(const pos_type n) override; - virtual pos_type vtell() override; + virtual pos_type vtell() const override; private: pos_type m_pos; @@ -284,12 +367,22 @@ private: class pistringstream : public pimemstream { public: - explicit pistringstream(const pstring &str) : pimemstream(str.c_str(), std::strlen(str.c_str())), m_str(str) { } + pistringstream(const pstring &str) + : pimemstream() + , m_str(str) + { + set_mem(m_str.c_str(), std::strlen(m_str.c_str())); + } + pistringstream(pistringstream &&src) + : pimemstream(std::move(src)), m_str(src.m_str) + { + set_mem(m_str.c_str(), std::strlen(m_str.c_str())); + } virtual ~pistringstream() override; private: /* only needed for a reference till destruction */ - pstring m_str; + const pstring m_str; }; // ----------------------------------------------------------------------------- @@ -298,35 +391,62 @@ private: /* this digests linux & dos/windows text files */ -class putf8_reader : plib::nocopyassignmove +class putf8_reader : plib::nocopyassign { public: - explicit putf8_reader(pistream &strm) : m_strm(strm) {} - virtual ~putf8_reader() {} + putf8_reader(pistream *strm) : m_strm(strm), m_stream_owned(false) {} + virtual ~putf8_reader() + { + if (m_stream_owned && m_strm != nullptr) + pfree(m_strm); + } + + putf8_reader(putf8_reader &&src) : m_strm(src.m_strm), m_stream_owned(src.m_stream_owned) + { + src.m_strm = nullptr; + src.m_stream_owned = false; + } + + putf8_reader(pimemstream &&strm) + : m_strm(palloc(std::move(strm))), + m_stream_owned(true) + {} - bool eof() const { return m_strm.eof(); } + putf8_reader(pifilestream &&strm) + : m_strm(palloc(std::move(strm))), + m_stream_owned(true) + {} + + putf8_reader(pistringstream &&strm) + : m_strm(palloc(std::move(strm))), + m_stream_owned(true) + {} + + + bool eof() const { return m_strm->eof(); } bool readline(pstring &line); bool readbyte1(char &b) { - return (m_strm.read(&b, 1) == 1); + return (m_strm->read(&b, 1) == 1); } bool readcode(putf8string::traits_type::code_t &c) { char b[4]; - if (m_strm.read(&b[0], 1) != 1) + if (m_strm->read(&b[0], 1) != 1) return false; const std::size_t l = putf8string::traits_type::codelen(b); for (std::size_t i = 1; i < l; i++) - if (m_strm.read(&b[i], 1) != 1) + if (m_strm->read(&b[i], 1) != 1) return false; c = putf8string::traits_type::code(b); return true; } private: - pistream &m_strm; + pistream *m_strm; + bool m_stream_owned; putf8string m_linebuf; }; @@ -334,10 +454,12 @@ private: // putf8writer_t: writer on top of ostream // ----------------------------------------------------------------------------- -class putf8_writer : plib::nocopyassignmove +class putf8_writer : plib::nocopyassign { public: - explicit putf8_writer(postream &strm) : m_strm(strm) {} + explicit putf8_writer(postream *strm) : m_strm(strm) {} + + putf8_writer(putf8_writer &&src) : m_strm(src.m_strm) {} virtual ~putf8_writer() {} void writeline(const pstring &line) const @@ -349,7 +471,7 @@ public: void write(const pstring &text) const { putf8string conv_utf8(text); - m_strm.write(conv_utf8.c_str(), conv_utf8.mem_t_size()); + m_strm->write(conv_utf8.c_str(), conv_utf8.mem_t_size()); } void write(const pstring::value_type c) const @@ -359,14 +481,19 @@ public: } private: - postream &m_strm; + postream *m_strm; }; class putf8_fmt_writer : public pfmt_writer_t, public putf8_writer { public: - explicit putf8_fmt_writer(postream &strm); + explicit putf8_fmt_writer(postream *strm) + : pfmt_writer_t() + , putf8_writer(strm) + { + } + virtual ~putf8_fmt_writer() override; //protected: @@ -379,16 +506,17 @@ private: // pbinary_writer_t: writer on top of ostream // ----------------------------------------------------------------------------- -class pbinary_writer : plib::nocopyassignmove +class pbinary_writer : plib::nocopyassign { public: explicit pbinary_writer(postream &strm) : m_strm(strm) {} + pbinary_writer(pbinary_writer &&src) : m_strm(src.m_strm) {} virtual ~pbinary_writer() {} template - void write(const T val) + void write(const T &val) { - m_strm.write(&val, sizeof(T)); + m_strm.write(reinterpret_cast(&val), sizeof(T)); } void write(const pstring &s) @@ -411,10 +539,11 @@ private: postream &m_strm; }; -class pbinary_reader : plib::nocopyassignmove +class pbinary_reader : plib::nocopyassign { public: explicit pbinary_reader(pistream &strm) : m_strm(strm) {} + pbinary_reader(pbinary_reader &&src) : m_strm(src.m_strm) { } virtual ~pbinary_reader() {} template @@ -447,6 +576,15 @@ private: pistream &m_strm; }; +inline void copystream(postream &dest, pistream &src) +{ + char buf[1024]; + pstream::pos_type r; + while ((r=src.read(buf, 1024)) > 0) + dest.write(buf, r); +} + + } #endif /* PSTREAM_H_ */ diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index ebdca57c9a5..515bbe70a57 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -147,6 +147,8 @@ public: *this += static_cast(c); // FIXME: codepage conversion for u8 } + operator string_type () const { return m_str; } + pstring_t &operator=(const pstring_t &string) { m_str = string.m_str; return *this; } template read_input(const netlist::setup_t &setup, pstring fn std::vector ret; if (fname != "") { - plib::pifilestream f(fname); - plib::putf8_reader r(f); + plib::putf8_reader r = plib::putf8_reader(plib::pifilestream(fname)); pstring l; while (r.readline(l)) { @@ -402,7 +401,7 @@ void tool_app_t::static_compile() opt_logs(), opt_defines(), opt_rfolders()); - plib::putf8_writer w(pout_strm); + plib::putf8_writer w(&pout_strm); std::map mp; nt.solver()->create_solver_code(mp); @@ -724,12 +723,12 @@ int tool_app_t::execute() if (opt_file() == "-") { plib::pstdin f; - ostrm.write(f); + plib::copystream(ostrm, f); } else { plib::pifilestream f(opt_file()); - ostrm.write(f); + plib::copystream(ostrm, f); } contents = ostrm.str(); diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp index 17d385f2c1a..1bc3505c206 100644 --- a/src/lib/netlist/prg/nlwav.cpp +++ b/src/lib/netlist/prg/nlwav.cpp @@ -51,38 +51,45 @@ private: * and data chunk length to the file. */ /* http://de.wikipedia.org/wiki/RIFF_WAVE */ + class wav_t { public: wav_t(plib::postream &strm, unsigned sr) : m_f(strm) { initialize(sr); - m_f.write(&m_fh, sizeof(m_fh)); - m_f.write(&m_fmt, sizeof(m_fmt)); - m_f.write(&m_data, sizeof(m_data)); + write(m_fh); + write(m_fmt); + write(m_data); } ~wav_t() { if (m_f.seekable()) { m_fh.filelen = m_data.len + sizeof(m_data) + sizeof(m_fh) + sizeof(m_fmt) - 8; - m_f.seek(0); - m_f.write(&m_fh, sizeof(m_fh)); - m_f.write(&m_fmt, sizeof(m_fmt)); + m_f.seekp(0); + write(m_fh); + write(m_fmt); //data.len = fmt.block_align * n; - m_f.write(&m_data, sizeof(m_data)); + write(m_data); } } unsigned channels() { return m_fmt.channels; } unsigned sample_rate() { return m_fmt.sample_rate; } + template + void write(const T &val) + { + m_f.write(reinterpret_cast(&val), sizeof(T)); + } + void write_sample(int sample) { m_data.len += m_fmt.block_align; int16_t ps = static_cast(sample); /* 16 bit sample, FIXME: Endianess? */ - m_f.write(&ps, sizeof(ps)); + write(ps); } private: @@ -150,7 +157,7 @@ public: void process() { - plib::putf8_reader reader(m_is); + plib::putf8_reader reader(&m_is); pstring line; while(reader.readline(line)) @@ -248,7 +255,7 @@ void nlwav_app::convert(long sample_rate) { plib::postream *fo = (opt_out() == "-" ? &pout_strm : plib::palloc(opt_out())); plib::pistream *fin = (opt_inp() == "-" ? &pin_strm : plib::palloc(opt_inp())); - plib::putf8_reader reader(*fin); + plib::putf8_reader reader(fin); wav_t *wo = plib::palloc(*fo, static_cast(sample_rate)); double dt = 1.0 / static_cast(wo->sample_rate()); diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h index a17ca1ec282..dee76dd8281 100644 --- a/src/lib/netlist/solver/nld_ms_gcr.h +++ b/src/lib/netlist/solver/nld_ms_gcr.h @@ -298,7 +298,7 @@ template pstring matrix_solver_GCR_t::static_compile_name() { plib::postringstream t; - plib::putf8_fmt_writer w(t); + plib::putf8_fmt_writer w(&t); csc_private(w); std::hash h; @@ -309,7 +309,7 @@ template std::pair matrix_solver_GCR_t::create_solver_code() { plib::postringstream t; - plib::putf8_fmt_writer strm(t); + plib::putf8_fmt_writer strm(&t); pstring name = static_compile_name(); strm.writeline(plib::pfmt("extern \"C\" void {1}(double * __restrict m_A, double * __restrict RHS, double * __restrict V)\n")(name)); diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp index b89e94ca3e5..6b6f3925a5a 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -42,8 +42,7 @@ using lib_map_t = std::unordered_map; static lib_map_t read_lib_map(const pstring &lm) { - plib::pistringstream istrm(lm); - plib::putf8_reader reader(istrm); + auto reader = plib::putf8_reader(plib::pistringstream(lm)); lib_map_t m; pstring line; while (reader.readline(line)) @@ -59,7 +58,7 @@ static lib_map_t read_lib_map(const pstring &lm) -------------------------------------------------*/ nl_convert_base_t::nl_convert_base_t() - : out(m_buf) + : out(&m_buf) , m_numberchars("0123456789-+e.") { } @@ -401,8 +400,8 @@ void nl_convert_spice_t::process_line(const pstring &line) Eagle converter -------------------------------------------------*/ -nl_convert_eagle_t::tokenizer::tokenizer(nl_convert_eagle_t &convert, plib::putf8_reader &strm) - : plib::ptokenizer(strm) +nl_convert_eagle_t::tokenizer::tokenizer(nl_convert_eagle_t &convert, plib::putf8_reader &&strm) + : plib::ptokenizer(std::move(strm)) , m_convert(convert) { set_identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-"); @@ -429,9 +428,8 @@ void nl_convert_eagle_t::tokenizer::verror(const pstring &msg, int line_num, con //FIXME: should accept a stream as well void nl_convert_eagle_t::convert(const pstring &contents) { - plib::pistringstream istrm(contents); - plib::putf8_reader reader(istrm); - tokenizer tok(*this, reader); + + tokenizer tok(*this, plib::putf8_reader(plib::pistringstream(contents))); out("NETLIST_START(dummy)\n"); add_term("GND", "GND"); @@ -539,8 +537,8 @@ void nl_convert_eagle_t::convert(const pstring &contents) RINF converter -------------------------------------------------*/ -nl_convert_rinf_t::tokenizer::tokenizer(nl_convert_rinf_t &convert, plib::putf8_reader &strm) - : plib::ptokenizer(strm) +nl_convert_rinf_t::tokenizer::tokenizer(nl_convert_rinf_t &convert, plib::putf8_reader &&strm) + : plib::ptokenizer(std::move(strm)) , m_convert(convert) { set_identifier_chars(".abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-"); @@ -579,9 +577,7 @@ void nl_convert_rinf_t::tokenizer::verror(const pstring &msg, int line_num, cons void nl_convert_rinf_t::convert(const pstring &contents) { - plib::pistringstream istrm(contents); - plib::putf8_reader reader(istrm); - tokenizer tok(*this, reader); + tokenizer tok(*this, plib::putf8_reader(plib::pistringstream(contents))); auto lm = read_lib_map(s_lib_map); out("NETLIST_START(dummy)\n"); diff --git a/src/lib/netlist/tools/nl_convert.h b/src/lib/netlist/tools/nl_convert.h index d3881320678..1433f75664c 100644 --- a/src/lib/netlist/tools/nl_convert.h +++ b/src/lib/netlist/tools/nl_convert.h @@ -166,7 +166,7 @@ public: class tokenizer : public plib::ptokenizer { public: - tokenizer(nl_convert_eagle_t &convert, plib::putf8_reader &strm); + tokenizer(nl_convert_eagle_t &convert, plib::putf8_reader &&strm); token_id_t m_tok_ADD; token_id_t m_tok_VALUE; @@ -202,7 +202,7 @@ public: class tokenizer : public plib::ptokenizer { public: - tokenizer(nl_convert_rinf_t &convert, plib::putf8_reader &strm); + tokenizer(nl_convert_rinf_t &convert, plib::putf8_reader &&strm); token_id_t m_tok_HEA; token_id_t m_tok_APP; -- cgit v1.2.3-70-g09d2 From 76323eb770cca3655f40d400fe5f34fbaa573d6c Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 27 Jan 2019 14:22:20 +1100 Subject: srcclean and cleanup (nw) --- hash/apple2_flop_orig.xml | 6224 ++++++++++++++-------------- hash/clickstart_cart.xml | 14 +- hash/ekara_japan.xml | 60 +- hash/ekara_japan_d.xml | 6 +- hash/ekara_japan_en.xml | 12 +- hash/ekara_japan_g.xml | 36 +- hash/ekara_japan_m.xml | 4 +- hash/ekara_japan_p.xml | 8 +- hash/ekara_japan_s.xml | 6 +- hash/ekara_japan_sp.xml | 10 +- hash/ekara_us.xml | 2 +- hash/jakks_gamekey_dy.xml | 34 +- hash/jakks_gamekey_nk.xml | 10 +- hash/jakks_gamekey_sw.xml | 8 +- hash/pce_tourvision.xml | 18 +- hash/vsmile_cart.xml | 2 +- hash/vtech_storio_cart.xml | 10 +- scripts/src/machine.lua | 2 +- src/devices/bus/bbc/rom/dfs.cpp | 2 +- src/devices/bus/ekara/rom.cpp | 2 +- src/devices/bus/electron/romboxp.cpp | 4 +- src/devices/bus/nubus/nubus_specpdq.cpp | 39 +- src/devices/bus/vsmile/vsmile_slot.h | 4 +- src/devices/cpu/alpha/alpha.cpp | 4 +- src/devices/cpu/dspp/dspp.h | 18 +- src/devices/cpu/dspp/dsppdrc.cpp | 334 +- src/devices/cpu/m6502/xavix2000.cpp | 12 +- src/devices/cpu/mips/mips3.cpp | 8 +- src/devices/cpu/mips/mips3.h | 2 +- src/devices/cpu/mips/mips3drc.cpp | 10 +- src/devices/cpu/unsp/unsp.h | 12 +- src/devices/cpu/unsp/unspdefs.h | 10 +- src/devices/cpu/unsp/unspdrc.cpp | 12 +- src/devices/machine/nsc810.h | 2 +- src/devices/machine/smc91c9x.cpp | 64 +- src/devices/machine/smc91c9x.h | 6 +- src/devices/machine/spg110.cpp | 8 +- src/devices/machine/spg2xx.cpp | 30 +- src/devices/machine/wd33c9x.cpp | 8 +- src/devices/video/fixfreq.cpp | 2 +- src/emu/devfind.cpp | 2 +- src/frontend/mame/ui/icorender.cpp | 4 +- src/frontend/mame/ui/selgame.cpp | 9 +- src/lib/netlist/devices/net_lib.cpp | 2 +- src/lib/netlist/devices/nld_74107.cpp | 6 +- src/lib/netlist/devices/nld_7450.cpp | 4 +- src/lib/netlist/devices/nld_7490.cpp | 4 +- src/lib/netlist/devices/nld_7493.cpp | 2 +- src/lib/netlist/devices/nld_7497.cpp | 2 +- src/lib/netlist/devices/nld_7497.h | 4 +- src/lib/netlist/nl_base.cpp | 2 +- src/lib/netlist/nl_base.h | 10 +- src/lib/netlist/nl_errstr.h | 2 +- src/lib/netlist/nl_lists.h | 6 +- src/lib/netlist/nl_setup.h | 2 +- src/lib/netlist/plib/parray.h | 36 +- src/lib/netlist/plib/pparser.cpp | 16 +- src/lib/netlist/plib/pstring.h | 2 +- src/lib/netlist/prg/nltool.cpp | 2 +- src/lib/netlist/prg/nlwav.cpp | 12 +- src/lib/netlist/solver/nld_matrix_solver.h | 2 +- src/lib/netlist/solver/nld_ms_gmres.h | 10 +- src/mame/drivers/5clown.cpp | 12 +- src/mame/drivers/aerofgt.cpp | 2 +- src/mame/drivers/alg.cpp | 2 +- src/mame/drivers/argus.cpp | 4 +- src/mame/drivers/avt.cpp | 12 +- src/mame/drivers/battlane.cpp | 4 +- src/mame/drivers/bigevglf.cpp | 2 +- src/mame/drivers/blktiger.cpp | 4 +- src/mame/drivers/brkthru.cpp | 8 +- src/mame/drivers/chinagat.cpp | 18 +- src/mame/drivers/clickstart.cpp | 20 +- src/mame/drivers/dacholer.cpp | 2 +- src/mame/drivers/ddragon.cpp | 16 +- src/mame/drivers/deniam.cpp | 6 +- src/mame/drivers/discoboy.cpp | 2 +- src/mame/drivers/drmicro.cpp | 2 +- src/mame/drivers/dynax.cpp | 34 +- src/mame/drivers/fantland.cpp | 8 +- src/mame/drivers/fcrash.cpp | 32 +- src/mame/drivers/firetrap.cpp | 18 +- src/mame/drivers/fromance.cpp | 18 +- src/mame/drivers/fuukifg2.cpp | 4 +- src/mame/drivers/gaiden.cpp | 2 +- src/mame/drivers/galspnbl.cpp | 6 +- src/mame/drivers/gladiatr.cpp | 18 +- src/mame/drivers/goal92.cpp | 2 +- src/mame/drivers/gsword.cpp | 10 +- src/mame/drivers/hnayayoi.cpp | 2 +- src/mame/drivers/hp_ipc.cpp | 2 +- src/mame/drivers/hyperspt.cpp | 14 +- src/mame/drivers/indy_indigo2.cpp | 22 +- src/mame/drivers/karnov.cpp | 4 +- src/mame/drivers/kchamp.cpp | 12 +- src/mame/drivers/klax.cpp | 6 +- src/mame/drivers/konamim2.cpp | 2 +- src/mame/drivers/kungfur.cpp | 8 +- src/mame/drivers/kurukuru.cpp | 2 +- src/mame/drivers/lkage.cpp | 2 +- src/mame/drivers/lucky74.cpp | 16 +- src/mame/drivers/lwings.cpp | 20 +- src/mame/drivers/m90.cpp | 2 +- src/mame/drivers/matmania.cpp | 4 +- src/mame/drivers/megadriv_acbl.cpp | 2 +- src/mame/drivers/mermaid.cpp | 2 +- src/mame/drivers/metlclsh.cpp | 4 +- src/mame/drivers/mgavegas.cpp | 2 +- src/mame/drivers/miniboy7.cpp | 14 +- src/mame/drivers/mitchell.cpp | 10 +- src/mame/drivers/mjkjidai.cpp | 2 +- src/mame/drivers/namcond1.cpp | 2 +- src/mame/drivers/nmg5.cpp | 4 +- src/mame/drivers/ojankohs.cpp | 24 +- src/mame/drivers/opwolf.cpp | 16 +- src/mame/drivers/pachifev.cpp | 4 +- src/mame/drivers/palestra.cpp | 2 +- src/mame/drivers/pc9801.cpp | 2 +- src/mame/drivers/pcktgal.cpp | 2 +- src/mame/drivers/peplus.cpp | 8 +- src/mame/drivers/r9751.cpp | 4 +- src/mame/drivers/rad_eu3a14.cpp | 18 +- src/mame/drivers/rainbow.cpp | 6 +- src/mame/drivers/rastan.cpp | 8 +- src/mame/drivers/rmhaihai.cpp | 2 +- src/mame/drivers/sanremo.cpp | 24 +- src/mame/drivers/seta.cpp | 4 +- src/mame/drivers/sf.cpp | 8 +- src/mame/drivers/smc777.cpp | 18 +- src/mame/drivers/sms_bootleg.cpp | 2 +- src/mame/drivers/sothello.cpp | 4 +- src/mame/drivers/spg110.cpp | 10 +- src/mame/drivers/splash.cpp | 10 +- src/mame/drivers/srmp2.cpp | 22 +- src/mame/drivers/storio.cpp | 18 +- src/mame/drivers/suprgolf.cpp | 4 +- src/mame/drivers/system16.cpp | 2 +- src/mame/drivers/taito_l.cpp | 20 +- src/mame/drivers/taitoair.cpp | 4 +- src/mame/drivers/tbowl.cpp | 4 +- src/mame/drivers/tehkanwc.cpp | 8 +- src/mame/drivers/testpat.cpp | 8 +- src/mame/drivers/toaplan1.cpp | 8 +- src/mame/drivers/topspeed.cpp | 4 +- src/mame/drivers/trackfld.cpp | 12 +- src/mame/drivers/trkfldch.cpp | 4 +- src/mame/drivers/tubep.cpp | 18 +- src/mame/drivers/twincobr.cpp | 4 +- src/mame/drivers/vigilant.cpp | 2 +- src/mame/drivers/vii.cpp | 40 +- src/mame/drivers/wacky_gator.cpp | 10 +- src/mame/drivers/wardner.cpp | 6 +- src/mame/drivers/warriorb.cpp | 8 +- src/mame/drivers/wc90b.cpp | 4 +- src/mame/drivers/welltris.cpp | 4 +- src/mame/drivers/wgp.cpp | 6 +- src/mame/drivers/xavix.cpp | 76 +- src/mame/drivers/yunsung8.cpp | 8 +- src/mame/includes/vsmile.h | 18 +- src/mame/includes/xavix.h | 6 +- src/mame/machine/hpc1.cpp | 24 +- src/mame/machine/hpc1.h | 4 +- src/mame/machine/hpc3.cpp | 30 +- src/mame/machine/hpc3.h | 4 +- src/mame/machine/mbc55x_kbd.cpp | 6 +- src/mame/machine/nl_palestra.cpp | 14 +- src/mame/machine/nl_tp1983.cpp | 8 +- src/mame/machine/nl_tp1985.cpp | 18 +- src/mame/machine/pce_cd.cpp | 4 +- src/mame/machine/taitocchip.cpp | 8 +- src/mame/machine/xavix.cpp | 4 +- src/mame/machine/xavix2002_io.cpp | 2 +- src/mame/machine/xavix2002_io.h | 2 +- src/mame/machine/xbox_pci.cpp | 2 +- src/mame/video/arabian.cpp | 8 +- src/mame/video/funworld.cpp | 6 +- src/mame/video/tia.cpp | 192 +- src/mame/video/xavix.cpp | 2 +- 178 files changed, 4239 insertions(+), 4231 deletions(-) (limited to 'src/lib/netlist/plib/pstring.h') diff --git a/hash/apple2_flop_orig.xml b/hash/apple2_flop_orig.xml index 92c0f8da1ac..ce26055f178 100644 --- a/hash/apple2_flop_orig.xml +++ b/hash/apple2_flop_orig.xml @@ -3,3123 +3,3123 @@ - - Agent USA - 1984 - Scholastic - - - - - - - - - - - - - Airheart - 1986 - Broderbund Software - - - - - - - - - - - - - Alien Ambush - 1981 - Micro Distributors - - - - - - - - - - - - - Ankh - 1983 - Datamost - - - - - - - - - - - - - Apple Cider Spider - 1983 - Sierra On-Line - - - - - - - - - - - - - Apple Galaxian - 1980 - Broderbund Software - - - - - - - - - - - - - Aquatron - 1983 - Sierra On-Line - - - - - - - - - - - - - Archon: The Light and The Dark - 1984 - Electronic Arts - - - - - - - - - - - - - Ardy the Aardvark - 1983 - Datamost - - - - - - - - - - - - - Autobahn - 1981 - Sirius Software - - - - - - - - - - - - - Axis Assassin - 1982 - Electronic Arts - - - - - - - - - - - - - Aztec - 1982 - Datamost - - - - - - - - - - - - - Bad Dudes - 1988 - Data East USA - - - - - - - - - - - - - - - - - - - - Ballblazer - 1985 - Epyx - - - - - - - - - - - - - Batman: The Caped Crusader - 1985 - Data East USA - - - - - - - - - - - - - - - - - - - - BC's Quest for Tires - 1983 - Sierra On-Line - - - - - - - - - - - - - Bellhop - 1982 - Hayden Book Company - - - - - - - - - - - - - Below the Root - 1984 - Hayden Book Company - - - - - - - - - - - - - - - - - - - - The Bilestoad - 1983 - Datamost - - - - - - - - - - - - - Bug Battle - 1982 - United Software of America - - - - - - - - - - - - - Cannonball Blitz - 1982 - On-Line Systems - - - - - - - - - - - - - Caverns of Callisto - 1983 - Origin Systems - - - - - - - - - - - - - Ceiling Zero - 1981 - Turnkey Software - - - - - - - - - - - - - Centipede - 1983 - Atarisoft - - - - - - - - - - - - - Commando - 1987 - Data East USA - - - - - - - - - - - - - Congo Bongo - 1987 - SEGA Enterprises - - - - - - - - - - - - - Conquering Worlds - 1983 - Datamost - - - - - - - - - - - - - Copts and Robbers - 1981 - Sirius Software - - - - - - - - - - - - - County Fair - 1981 - Datamost - - - - - - - - - - - - - Crazy Mazey - 1982 - Datamost - - - - - - - - - - - - - Crisis Mountain - 1982 - Micro Fun - - - - - - - - - - - - - Crossfire - 1981 - On-Line Systems - - - - - - - - - - - - - Cubit - 1983 - Micromax - - - - - - - - - - - - - Cyber Strike - 1980 - Sirius Software - - - - - - - - - - - - - The Dam Busters - 1985 - Accolade - - - - - - - - - - - - - Death Sword - 1987 - Epyx - - - - - - - - - - - - - Defender II: Stargate - 1983 - Atarisoft - - - - - - - - - - - - - Destroyer - 1986 - Epyx - - - - - - - - - - - - - Dino Eggs - 1983 - Micro Fun - - - - - - - - - - - - - Dive Bomber - 1988 - Epyx - - - - - - - - - - - - - Donkey Kong - 1983 - Atarisoft - - - - - - - - - - - - - Drol - 1983 - Broderbund Software - - - - - - - - - - - - - Dung Beetles - 1982 - Datasoft - - - - - - - - - - - - - The Eidolon - 1985 - Epyx - - - - - - - - - - - - - Epoch - 1981 - Sirius Software - - - - - - - - - - - - - Falcons - 1981 - Piccadilly Software - - - - - - - - - - - - - - Fight Night - 1985 - Accolade - - - - - - - - - - - - - Flight Simulator II (v2.0) - 1985 - Accolade - - - - - - - - - - - - - Flip Out - 1982 - Sirius Software - - - - - - - - - - - - - Force 7 - 1987 - Datasoft - - - - - - - - - - - - - Formula 1 Racer - 1983 - Gentry Software - - - - - - - - - - - - - Free Fall - 1982 - Sirius Software - - - - - - - - - - - - - Frogger - 1981 - Sierra On-Line - - - - - - - - - - - - - Frogger II: Threedeep - 1984 - SEGA Enterprises - - - - - - - - - - - - - G.I. Joe - 1985 - Epyx - - - - - - - - - - - - - - - - - - - - The Games - Summer Edition - 1988 - Epyx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GATO - 1985 - Spectrum Holobyte - - - - - - - - - - - - - Genetic Drift - 1981 - Broderbund Software - - - - - - - - - - - - - Gobbler - 1981 - On-Line Systems - - - - - - - - - - - - - The Goonies - 1985 - Datasoft - - - - - - - - - - - - - Gumball - 1983 - Broderbund Software - - - - - - - - - - - - - The Heist - 1983 - Micro Fun - - - - - - - - - - - - - HERO - Helicopter Emergency Rescue Operation - 1983 - Activision - - - - - - - - - - - - - Hadron - 1981 - Sirius Software - - - - - - - - - - - - - Hard Hat Mack - 1983 - Electronic Arts - - - - - - - - - - - - Hardball - 1985 - Accolade - - - - - - - - - - - - - Head On - 1980 - California Pacific Computers - - - - - - - - - - - - - High Rise - 1983 - Micro Fun - - - - - - - - - - - - - Ikari Warriors - 1983 - Data East USA - - - - - - - - - - - - - - - - - - - - Ikari Warriors 2: Victory Road - 1981 - Sirius Software - - - - - - - - - - - - - - - - - + + Agent USA + 1984 + Scholastic + + + + + + + + + + + + + Airheart + 1986 + Broderbund Software + + + + + + + + + + + + + Alien Ambush + 1981 + Micro Distributors + + + + + + + + + + + + + Ankh + 1983 + Datamost + + + + + + + + + + + + + Apple Cider Spider + 1983 + Sierra On-Line + + + + + + + + + + + + + Apple Galaxian + 1980 + Broderbund Software + + + + + + + + + + + + + Aquatron + 1983 + Sierra On-Line + + + + + + + + + + + + + Archon: The Light and The Dark + 1984 + Electronic Arts + + + + + + + + + + + + + Ardy the Aardvark + 1983 + Datamost + + + + + + + + + + + + + Autobahn + 1981 + Sirius Software + + + + + + + + + + + + + Axis Assassin + 1982 + Electronic Arts + + + + + + + + + + + + + Aztec + 1982 + Datamost + + + + + + + + + + + + + Bad Dudes + 1988 + Data East USA + + + + + + + + + + + + + + + + + + + + Ballblazer + 1985 + Epyx + + + + + + + + + + + + + Batman: The Caped Crusader + 1985 + Data East USA + + + + + + + + + + + + + + + + + + + + BC's Quest for Tires + 1983 + Sierra On-Line + + + + + + + + + + + + + Bellhop + 1982 + Hayden Book Company + + + + + + + + + + + + + Below the Root + 1984 + Hayden Book Company + + + + + + + + + + + + + + + + + + + + The Bilestoad + 1983 + Datamost + + + + + + + + + + + + + Bug Battle + 1982 + United Software of America + + + + + + + + + + + + + Cannonball Blitz + 1982 + On-Line Systems + + + + + + + + + + + + + Caverns of Callisto + 1983 + Origin Systems + + + + + + + + + + + + + Ceiling Zero + 1981 + Turnkey Software + + + + + + + + + + + + + Centipede + 1983 + Atarisoft + + + + + + + + + + + + + Commando + 1987 + Data East USA + + + + + + + + + + + + + Congo Bongo + 1987 + SEGA Enterprises + + + + + + + + + + + + + Conquering Worlds + 1983 + Datamost + + + + + + + + + + + + + Copts and Robbers + 1981 + Sirius Software + + + + + + + + + + + + + County Fair + 1981 + Datamost + + + + + + + + + + + + + Crazy Mazey + 1982 + Datamost + + + + + + + + + + + + + Crisis Mountain + 1982 + Micro Fun + + + + + + + + + + + + + Crossfire + 1981 + On-Line Systems + + + + + + + + + + + + + Cubit + 1983 + Micromax + + + + + + + + + + + + + Cyber Strike + 1980 + Sirius Software + + + + + + + + + + + + + The Dam Busters + 1985 + Accolade + + + + + + + + + + + + + Death Sword + 1987 + Epyx + + + + + + + + + + + + + Defender II: Stargate + 1983 + Atarisoft + + + + + + + + + + + + + Destroyer + 1986 + Epyx + + + + + + + + + + + + + Dino Eggs + 1983 + Micro Fun + + + + + + + + + + + + + Dive Bomber + 1988 + Epyx + + + + + + + + + + + + + Donkey Kong + 1983 + Atarisoft + + + + + + + + + + + + + Drol + 1983 + Broderbund Software + + + + + + + + + + + + + Dung Beetles + 1982 + Datasoft + + + + + + + + + + + + + The Eidolon + 1985 + Epyx + + + + + + + + + + + + + Epoch + 1981 + Sirius Software + + + + + + + + + + + + + Falcons + 1981 + Piccadilly Software + + + + + + + + + + + + + + Fight Night + 1985 + Accolade + + + + + + + + + + + + + Flight Simulator II (v2.0) + 1985 + Accolade + + + + + + + + + + + + + Flip Out + 1982 + Sirius Software + + + + + + + + + + + + + Force 7 + 1987 + Datasoft + + + + + + + + + + + + + Formula 1 Racer + 1983 + Gentry Software + + + + + + + + + + + + + Free Fall + 1982 + Sirius Software + + + + + + + + + + + + + Frogger + 1981 + Sierra On-Line + + + + + + + + + + + + + Frogger II: Threedeep + 1984 + SEGA Enterprises + + + + + + + + + + + + + G.I. Joe + 1985 + Epyx + + + + + + + + + + + + + + + + + + + + The Games - Summer Edition + 1988 + Epyx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GATO + 1985 + Spectrum Holobyte + + + + + + + + + + + + + Genetic Drift + 1981 + Broderbund Software + + + + + + + + + + + + + Gobbler + 1981 + On-Line Systems + + + + + + + + + + + + + The Goonies + 1985 + Datasoft + + + + + + + + + + + + + Gumball + 1983 + Broderbund Software + + + + + + + + + + + + + The Heist + 1983 + Micro Fun + + + + + + + + + + + + + HERO - Helicopter Emergency Rescue Operation + 1983 + Activision + + + + + + + + + + + + + Hadron + 1981 + Sirius Software + + + + + + + + + + + + + Hard Hat Mack + 1983 + Electronic Arts + + + + + + + + + + + + Hardball + 1985 + Accolade + + + + + + + + + + + + + Head On + 1980 + California Pacific Computers + + + + + + + + + + + + + High Rise + 1983 + Micro Fun + + + + + + + + + + + + + Ikari Warriors + 1983 + Data East USA + + + + + + + + + + + + + + + + + + + + Ikari Warriors 2: Victory Road + 1981 + Sirius Software + + + + + + + + + + + + + + + + + - International Gran Prix - 1982 - MUSE Software - - - - - - - - - - - - - Jawbreaker - 1981 - On-Line Systems - - - - - - - - - - - - - Jawbreaker ][ - 1982 - Sierra On-Line - - - - - - - - - - - - - The Jet - 1986 - subLOGIC - - - - - - - - - - - - - Joust - 1983 - Atarisoft - - - - - - - - - - - - - Julius Erving and Larry Bird Go One on One - 1983 - Electronic Arts - - - - - - - - - - - - - Jungle Hunt - 1984 - Atarisoft - - - - - - - - - - - - - Karate Champ - 1985 - Data East - - - - - - - - - - - - - Karateka - 1984 - Broderbund Software - - - - - - - - - - - - - - - - - - - - Kid Niki - 1987 - Data East - - - - - - - - - - - - - - - - - - - - Kung Fu Master - 1985 - Data East - - - - - - - - - - - - - L.A. Crackdown - 1988 - Epyx - - - - - - - - - - - - - - - - - - - - Lock 'n Chase - 1982 - Mattel Electronics - - - - - - - - - - - - - Lode Runner - 1983 - Broderbund - - - - - - - - - - + International Gran Prix + 1982 + MUSE Software + + + + + + + + + + + + + Jawbreaker + 1981 + On-Line Systems + + + + + + + + + + + + + Jawbreaker ][ + 1982 + Sierra On-Line + + + + + + + + + + + + + The Jet + 1986 + subLOGIC + + + + + + + + + + + + + Joust + 1983 + Atarisoft + + + + + + + + + + + + + Julius Erving and Larry Bird Go One on One + 1983 + Electronic Arts + + + + + + + + + + + + + Jungle Hunt + 1984 + Atarisoft + + + + + + + + + + + + + Karate Champ + 1985 + Data East + + + + + + + + + + + + + Karateka + 1984 + Broderbund Software + + + + + + + + + + + + + + + + + + + + Kid Niki + 1987 + Data East + + + + + + + + + + + + + + + + + + + + Kung Fu Master + 1985 + Data East + + + + + + + + + + + + + L.A. Crackdown + 1988 + Epyx + + + + + + + + + + + + + + + + + + + + Lock 'n Chase + 1982 + Mattel Electronics + + + + + + + + + + + + + Lode Runner + 1983 + Broderbund + + + + + + + + + + - Lost Tomb - 1984 - Datasoft - - - - - - - - - - - - - Marauder - 1982 - On-Line Systems - - - - - - - - - - - - - Marble Madness - 1986 - Electronic Arts - - - - - - - - - - - - - - - - - - - - Mars Cars - 1982 - Datamost - - - - - - - - - - - - - Mating Zone - 1982 - Datamost - - - - - - - - - - - - - Megabots - 1986 - Neosoft - - - - - - - - - - - - - Might and Magic - 1986 - New World Computing - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Miner 2049er - 1982 - Micro Fun - - - - - - - - - - - - - Minit Man - 1983 - Penguin Software - - - - - - - - - - - - - Impossible Mission II - 1988 - Epyx - - - - - - - - - - - - - - - - - - - - Money Muncher - 1982 - Datamost - - - - - - - - - - - - - Monster Smash - 1983 - Datamost - - - - - - - - - - - - - Montezuma's Revenge - 1984 - Parker Brothers - - - - - - - - - - - - - Moon Patrol - 1983 - Atarisoft - - - - - - - - - - - - - The Movie Monster Game - 1986 - Epyx - - - - - - - - - - - - - - - - - - - - Mr. Robot and his Robot Factory - 1984 - Datamost - - - - - - - - - - - - - Ms. Pac-Man - 1983 - Atarisoft - - - - - - - - - - - - - Night Mission Pinball - 1982 - subLOGIC - - - - - - - - - - - - - Night Stalker - 1982 - Mattel Electronics - - - - - - - - - - - - - Orbitron - 1981 - Sirius Software - - - - - - - - - - - - - O'Riley's Mine - 1981 - Datasoft - - - - - - - - - - - - - Outpost - 1981 - Sirius Software - - - - - - - - - - - - - Paperboy - 1988 - Mindscape - - - - - - - - - - - - - Pest Patrol - 1982 - Sierra On-Line - - - - - - - - - - - - - Phantoms Five - 1980 - Sirius Software - - - - - - - - - - - - - Picnic Paranoia - 1982 - Synapse Software - - - - - - - - - - - - - Pitfall II: Lost Caverns - 1984 - Activision - - - - - - - - - - - - - Pitstop II - 1984 - Epyx - - - - - - - - - - - - - Planetfall (r10) - 1988 - Infocom - - - - - - - - - - - - - - - - - - - - Plasmania - 1983 - Sirius Software - - - - - - - - - - - - - Platoon - 1988 - Data East USA - - - - - - - - - - - - - - - - - - - - Pool 1.5 - 1981 - Innovative Design Software, Inc. - - - - - - - - - - - - - Pooyan - 1984 - Datasoft - - - - - - - - - - - - - Prince of Persia - 1989 - Broderbund - - - - - - - - - - - - - - - - - - - - Qix - 1989 - Taito America - - - - - - - - - - - - - Rad Warrior - 1987 - Epyx - - - - - - - - - - - - - Rampage - 1988 - Activision - - - - - - - - - - - - - Raster Blaster - 1981 - BudgeCo - - - - - - - - - - - - - Red Alert - 1981 - Broderbund - - - - - - - - - - - - - Repton - 1982 - Sirius Software - - - - - - - - - - - - - Rescue Raiders - 1984 - Sir-Tech - - - - - - - - - - - - - RoboCop - 1988 - Data East USA - - - - - - - - - - - - - - - - - - - - Robotron 2084 - 1983 - Atarisoft - - - - - - - - - - - - - Roundabout - 1983 - Datamost - - - - - - - - - - - - - Russki Duck - 1982 - Gebelli Software - - - - - - - - - - - - - Sabotage - 1981 - On-Line Systems - - - - - - - - - - - - - Sammy Lightfoot - 1983 - Sierra On-Line - - - - - - - - - - - - - Sargon III - 1983 - Hayden Book Company - - - - - - - - - - - - - Sea Dragon - 1982 - Adventure International - - - - - - - - - - - - - Shadowkeep - 1983 - Trillium - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Shanghai - 1986 - Activision - - - - - - - - - - + Lost Tomb + 1984 + Datasoft + + + + + + + + + + + + + Marauder + 1982 + On-Line Systems + + + + + + + + + + + + + Marble Madness + 1986 + Electronic Arts + + + + + + + + + + + + + + + + + + + + Mars Cars + 1982 + Datamost + + + + + + + + + + + + + Mating Zone + 1982 + Datamost + + + + + + + + + + + + + Megabots + 1986 + Neosoft + + + + + + + + + + + + + Might and Magic + 1986 + New World Computing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Miner 2049er + 1982 + Micro Fun + + + + + + + + + + + + + Minit Man + 1983 + Penguin Software + + + + + + + + + + + + + Impossible Mission II + 1988 + Epyx + + + + + + + + + + + + + + + + + + + + Money Muncher + 1982 + Datamost + + + + + + + + + + + + + Monster Smash + 1983 + Datamost + + + + + + + + + + + + + Montezuma's Revenge + 1984 + Parker Brothers + + + + + + + + + + + + + Moon Patrol + 1983 + Atarisoft + + + + + + + + + + + + + The Movie Monster Game + 1986 + Epyx + + + + + + + + + + + + + + + + + + + + Mr. Robot and his Robot Factory + 1984 + Datamost + + + + + + + + + + + + + Ms. Pac-Man + 1983 + Atarisoft + + + + + + + + + + + + + Night Mission Pinball + 1982 + subLOGIC + + + + + + + + + + + + + Night Stalker + 1982 + Mattel Electronics + + + + + + + + + + + + + Orbitron + 1981 + Sirius Software + + + + + + + + + + + + + O'Riley's Mine + 1981 + Datasoft + + + + + + + + + + + + + Outpost + 1981 + Sirius Software + + + + + + + + + + + + + Paperboy + 1988 + Mindscape + + + + + + + + + + + + + Pest Patrol + 1982 + Sierra On-Line + + + + + + + + + + + + + Phantoms Five + 1980 + Sirius Software + + + + + + + + + + + + + Picnic Paranoia + 1982 + Synapse Software + + + + + + + + + + + + + Pitfall II: Lost Caverns + 1984 + Activision + + + + + + + + + + + + + Pitstop II + 1984 + Epyx + + + + + + + + + + + + + Planetfall (r10) + 1988 + Infocom + + + + + + + + + + + + + + + + + + + + Plasmania + 1983 + Sirius Software + + + + + + + + + + + + + Platoon + 1988 + Data East USA + + + + + + + + + + + + + + + + + + + + Pool 1.5 + 1981 + Innovative Design Software, Inc. + + + + + + + + + + + + + Pooyan + 1984 + Datasoft + + + + + + + + + + + + + Prince of Persia + 1989 + Broderbund + + + + + + + + + + + + + + + + + + + + Qix + 1989 + Taito America + + + + + + + + + + + + + Rad Warrior + 1987 + Epyx + + + + + + + + + + + + + Rampage + 1988 + Activision + + + + + + + + + + + + + Raster Blaster + 1981 + BudgeCo + + + + + + + + + + + + + Red Alert + 1981 + Broderbund + + + + + + + + + + + + + Repton + 1982 + Sirius Software + + + + + + + + + + + + + Rescue Raiders + 1984 + Sir-Tech + + + + + + + + + + + + + RoboCop + 1988 + Data East USA + + + + + + + + + + + + + + + + + + + + Robotron 2084 + 1983 + Atarisoft + + + + + + + + + + + + + Roundabout + 1983 + Datamost + + + + + + + + + + + + + Russki Duck + 1982 + Gebelli Software + + + + + + + + + + + + + Sabotage + 1981 + On-Line Systems + + + + + + + + + + + + + Sammy Lightfoot + 1983 + Sierra On-Line + + + + + + + + + + + + + Sargon III + 1983 + Hayden Book Company + + + + + + + + + + + + + Sea Dragon + 1982 + Adventure International + + + + + + + + + + + + + Shadowkeep + 1983 + Trillium + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shanghai + 1986 + Activision + + + + + + + + + + - Shuffleboard - 1981 - IDSI - - - - - - - - - - - - - Skyfox - 1984 - Electronic Arts - - - - - - - - - - - - - Snack Attack - 1981 - Datamost - - - - - - - - - - - - - Snake Byte - 1981 - Sirius Software - - - - - - - - - - - - - Sneakers - 1981 - Sirius Software - - - - - - - - - - - - - - Space Eggs - 1981 - Sirius Software - - - - - - - - - - - - - Space Quarks - 1981 - Broderbund Software - - - - - - - - - - - - - Spare Change - 1983 - Broderbund Software - - - - - - - - - - - - - Spiderbot - 1988 - Epyx - - - - - - - - - - - - - Spindizzy - 1986 - Activision - - - - - - - - - - - - - Spy Hunter - 1983 - Bally Midway - - - - - - - - - - - - - The Spy Strikes Back - 1983 - Penguin Software - - - - - - - - - - - - - Spy vs Spy III: Arctic Antics - 1983 - Bally Midway - - - - - - - - - - - - - Spy's Demise - 1982 - Penguin - - - - - - - - - - - - - Star Cruiser - 1980 - Sirius Software - - - - - - - - - - - - - Star Thief - 1981 - Cavalier Computer - - - - - - - - - - - - - Stellar 7 - 1984 - Penguin Software - - - - - - - - - - - - - Street Sports Baseball - 1987 - Epyx - - - - - - - - - - - - - Street Sports Basketball - 1987 - Epyx - - - - - - - - - - - - - - - - - - - - Street Sports Football - 1988 - Epyx - - - - - - - - - - - - - - - - - - - - Street Sports Soccer - 1988 - Epyx - - - - - - - - - - - - - Sub Battle Simulator - 1986 - Epyx - - - - - - - - - - - - - - - - - - - - Suicide - 1981 - Piccadilly Software - - - - - - - - - - - - - Summer Games - 1984 - Epyx - - - - - - - - - - - - - - - - - - - - Swiss Family Robinson - 1984 - Windham Classics - - - - - - - - - - - - - Tag Team Wrestling - 1986 - Data East USA - - - - - - - - - - - - - Temple of Apshai Trilogy - 1985 - Epyx - - - - - - - - - - - - - Test Drive - 1985 - Accolade - - - - - - - - - - - - - - - - - - - - Tetris (128K) - 1987 - Spectrum HoloByte - - - - - - - - - - - - - Tharolian Tunnels - 1982 - Datamost - - - - - - - - - - - - - Thunder Bombs - 1982 - Penguin Software - - - - - - - - - - - - - Thunderchopper - 1987 - ActionSoft - - - - - - - - - - - - - Tomahawk - 1987 - Datasoft - - - - - - - - - - - - - Trick Shot - 1981 - IDSI - - - - - - - - - - - - - - - - - - - - Tubeway II - 1982 - Datamost - - - - - - - - - - - - - Twerps - 1981 - Sirius Software - - - - - - - - - - - - - Ultima IV: Quest of the Avatar - 1985 - Origin Systems - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ultima V: Warriors of Destiny - 1988 - Origin Systems - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Up 'N Down - 1981 - Bally Midway - - - - - - - - - - - - - Vindicator - 1983 - H.A.L. Labs - - - - - - - - - - - - - Wavy Navy - 1982 - Sirius Software - - - - - - - - - - - - - Wayout - 1982 - Sirius Software - - - - - - - - - - - - - Where in the USA is Carmen Sandiego - 1986 - Broderbund - - - - - - - - - - - - - - - - - - - - Wings of Fury - 1987 - Broderbund - - - - - - - - - - - - - - - - - - - - Wishbringer (r23) - 1988 - Infocom - - - - - - - - - - - - - - - - - - - - World Karate Championship - 1986 - Epyx - - - - - - - - - - - - - The World's Greatest Baseball Game - 1984 - Epyx - - - - - - - - - - - - - The World's Greatest Football Game - 1985 - Epyx - - - - - - - - - - - - - - - - - - - - Xevious - 1984 - Mindscape - - - - - - - - - - - - - Zendar - 1982 - subLOGIC - - - - - - - - - - - - - Zorro - 1985 - Datasoft - - - - - - - - - - + Shuffleboard + 1981 + IDSI + + + + + + + + + + + + + Skyfox + 1984 + Electronic Arts + + + + + + + + + + + + + Snack Attack + 1981 + Datamost + + + + + + + + + + + + + Snake Byte + 1981 + Sirius Software + + + + + + + + + + + + + Sneakers + 1981 + Sirius Software + + + + + + + + + + + + + + Space Eggs + 1981 + Sirius Software + + + + + + + + + + + + + Space Quarks + 1981 + Broderbund Software + + + + + + + + + + + + + Spare Change + 1983 + Broderbund Software + + + + + + + + + + + + + Spiderbot + 1988 + Epyx + + + + + + + + + + + + + Spindizzy + 1986 + Activision + + + + + + + + + + + + + Spy Hunter + 1983 + Bally Midway + + + + + + + + + + + + + The Spy Strikes Back + 1983 + Penguin Software + + + + + + + + + + + + + Spy vs Spy III: Arctic Antics + 1983 + Bally Midway + + + + + + + + + + + + + Spy's Demise + 1982 + Penguin + + + + + + + + + + + + + Star Cruiser + 1980 + Sirius Software + + + + + + + + + + + + + Star Thief + 1981 + Cavalier Computer + + + + + + + + + + + + + Stellar 7 + 1984 + Penguin Software + + + + + + + + + + + + + Street Sports Baseball + 1987 + Epyx + + + + + + + + + + + + + Street Sports Basketball + 1987 + Epyx + + + + + + + + + + + + + + + + + + + + Street Sports Football + 1988 + Epyx + + + + + + + + + + + + + + + + + + + + Street Sports Soccer + 1988 + Epyx + + + + + + + + + + + + + Sub Battle Simulator + 1986 + Epyx + + + + + + + + + + + + + + + + + + + + Suicide + 1981 + Piccadilly Software + + + + + + + + + + + + + Summer Games + 1984 + Epyx + + + + + + + + + + + + + + + + + + + + Swiss Family Robinson + 1984 + Windham Classics + + + + + + + + + + + + + Tag Team Wrestling + 1986 + Data East USA + + + + + + + + + + + + + Temple of Apshai Trilogy + 1985 + Epyx + + + + + + + + + + + + + Test Drive + 1985 + Accolade + + + + + + + + + + + + + + + + + + + + Tetris (128K) + 1987 + Spectrum HoloByte + + + + + + + + + + + + + Tharolian Tunnels + 1982 + Datamost + + + + + + + + + + + + + Thunder Bombs + 1982 + Penguin Software + + + + + + + + + + + + + Thunderchopper + 1987 + ActionSoft + + + + + + + + + + + + + Tomahawk + 1987 + Datasoft + + + + + + + + + + + + + Trick Shot + 1981 + IDSI + + + + + + + + + + + + + + + + + + + + Tubeway II + 1982 + Datamost + + + + + + + + + + + + + Twerps + 1981 + Sirius Software + + + + + + + + + + + + + Ultima IV: Quest of the Avatar + 1985 + Origin Systems + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Ultima V: Warriors of Destiny + 1988 + Origin Systems + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Up 'N Down + 1981 + Bally Midway + + + + + + + + + + + + + Vindicator + 1983 + H.A.L. Labs + + + + + + + + + + + + + Wavy Navy + 1982 + Sirius Software + + + + + + + + + + + + + Wayout + 1982 + Sirius Software + + + + + + + + + + + + + Where in the USA is Carmen Sandiego + 1986 + Broderbund + + + + + + + + + + + + + + + + + + + + Wings of Fury + 1987 + Broderbund + + + + + + + + + + + + + + + + + + + + Wishbringer (r23) + 1988 + Infocom + + + + + + + + + + + + + + + + + + + + World Karate Championship + 1986 + Epyx + + + + + + + + + + + + + The World's Greatest Baseball Game + 1984 + Epyx + + + + + + + + + + + + + The World's Greatest Football Game + 1985 + Epyx + + + + + + + + + + + + + + + + + + + + Xevious + 1984 + Mindscape + + + + + + + + + + + + + Zendar + 1982 + subLOGIC + + + + + + + + + + + + + Zorro + 1985 + Datasoft + + + + + + + + + + diff --git a/hash/clickstart_cart.xml b/hash/clickstart_cart.xml index 156e3e16df2..43b1151435b 100644 --- a/hash/clickstart_cart.xml +++ b/hash/clickstart_cart.xml @@ -158,7 +158,7 @@ - + Toy Story (SP) 2007 @@ -171,8 +171,8 @@ - - + + Bob the Builder (UK) 2007 @@ -185,8 +185,8 @@ - - + + Thomas & Friends (UK) 2007 @@ -199,7 +199,7 @@ - + Dora the Explorer (UK) @@ -213,6 +213,6 @@ - + diff --git a/hash/ekara_japan.xml b/hash/ekara_japan.xml index 34691abfb53..a6e6faa2e08 100644 --- a/hash/ekara_japan.xml +++ b/hash/ekara_japan.xml @@ -7,9 +7,9 @@ Japanese e-kara carts appear to have a number of different genres split across various cart sub-series (often supporting different hw types) special releases etc. - + This file is for the base set (number on case, ECxxxx-xxx part numbers) - + The genres in the Japanese games are represented by the code after the EC/DC/MC/GC/PC etc. number JPM = J-Pop Mix ATS = Artist Selection (all songs by a single artist) @@ -27,21 +27,21 @@ ATM = unknown (used by the M series 'mini' carts) TPJ = TV Pop MIN = unknown - + Some Japanese carts have a number starting with S (S-x on case, SCxxxx-xxx part numbers) (see ekara_japan_s.xml) (for e-kara - custom presentation) M (M-x on case, MCxxxx-xxx part numbers) (see ekara_japan_m.xml) (for e-kara - custom presentation) - EN (EN-X on case, no part numbers) (see ekara_japan_en.xml) (for e-kara - custom presentation) (check other compatibility) + EN (EN-X on case, no part numbers) (see ekara_japan_en.xml) (for e-kara - custom presentation) (check other compatibility) G (G-x on case, GCxxxx-xxx part numbers) (see ekara_japan_g.xml) (for e-kara, Popira / 2) P (P-x on case, PCxxxx-xxx part numbers) (see ekara_japan_p.xml) (for e-kara, Popira / 2, DDR Family Mat) - D (D-x on case, DCxxxx-xxx part numbers) (see ekara_japan_d.xml) (for e-kara, Popira / 2, Taiko De Popira) + D (D-x on case, DCxxxx-xxx part numbers) (see ekara_japan_d.xml) (for e-kara, Popira / 2, Taiko De Popira) SP (SP-x on case, no part numbers) (see ekara_japan_sp.xml) (for e-kara, Popira / 2, Taiko de Popira, Jumping Popira) these exist but haven't got any Some Japanese carts have a number starting with JP (for Jumping Popira Only?) A (for Pichi Pichi Pitch Only?) KE (for Kids Lyric book device Only?) - KD (for e-kara?) - + KD (for e-kara?) + (there are others, need to document them) @@ -50,7 +50,7 @@ Genres can cross multiple cart types, eg. TV Pop 1,3,4,5,6 are in the 'G' series, while TV Pop 2 is in the 'P' series, and TV Pop 9 is in the 'D' series (where are 7,8?) for non-Japanese carts see ekara_us.xml and ekara_pal.xml, the PAL ones are noteworthy for using a different timing system - + *********************************************************************************** Japanese cart listing (by 'just number' code) (number on cartridge / box, EC in cart identifier code) @@ -312,7 +312,7 @@ - + Kid's Mix Volume 1 (Japan) (EC0010-KID) 2000 @@ -369,7 +369,7 @@ - + @@ -386,7 +386,7 @@ - + J-Pop Mix Volume 9 (Japan) (EC0021-JPM) 2000 @@ -604,7 +604,7 @@ - + @@ -740,11 +740,11 @@ - + - + - + J-Pop Mix Volume 33 (Japan) (EC0068-JPM) 2001 @@ -783,9 +783,9 @@ - - - + + + @@ -798,11 +798,11 @@ - + - + - + ETZ (Japan) (EC0079-ETZ) 2002 @@ -812,12 +812,12 @@ - - + + - + - + Matthew's Best Hit Selection (Japan) (EC0082-MBH) 2003 @@ -827,12 +827,12 @@ - - + + - + - + - + diff --git a/hash/ekara_japan_d.xml b/hash/ekara_japan_d.xml index 859ccb93a85..cfaa6844b09 100644 --- a/hash/ekara_japan_d.xml +++ b/hash/ekara_japan_d.xml @@ -21,12 +21,12 @@ D-3 DC0003-BHT BHT (Best Artists?) Volume 9? (most other BHT carts are in G series, or P series) D-4 DC0004- (unknown) *D-5 DC0005-TPJ TV Pop Volume 9 - D-6 DC0006- (seen) + D-6 DC0006- (seen) D-7 DC0007- (seen) D-8 DC0008- (seen) - + (more? what's the D highest number?) - + --> diff --git a/hash/ekara_japan_en.xml b/hash/ekara_japan_en.xml index 63533f411bb..f23b7117b31 100644 --- a/hash/ekara_japan_en.xml +++ b/hash/ekara_japan_en.xml @@ -5,11 +5,11 @@ - + EN-3 (Japan) 2004 @@ -27,6 +27,6 @@ - - + + diff --git a/hash/ekara_japan_g.xml b/hash/ekara_japan_g.xml index 1191b84109c..42acff7a551 100644 --- a/hash/ekara_japan_g.xml +++ b/hash/ekara_japan_g.xml @@ -32,7 +32,7 @@ (more? what's the G highest number?) --> - + BAT Volume 1 (Japan) (GC0001-BAT) 2000 @@ -65,7 +65,7 @@ - + BHT Volume 2 (Japan) (GC0004-BHT) 2000 @@ -76,7 +76,7 @@ - + BHT Volume 3 (Japan) (GC0006-BHT) 2000 @@ -87,18 +87,18 @@ - + + Unless Popira 2 is different (unlikely) it doesn't look like the SEEPROM in this cartridge can be used (unfinished design?) --> BAT Volume 4 (Japan) (GC0010-BAT) 2002 @@ -109,9 +109,9 @@ - - - + + + BAT Volume 5 (Japan) (GC0015-BAT) @@ -123,8 +123,8 @@ - - + + TV Pop Volume 5 (Japan) (GC0016-TPJ) 2002 @@ -135,6 +135,6 @@ - - + + diff --git a/hash/ekara_japan_m.xml b/hash/ekara_japan_m.xml index f068d1edd87..9f08af0b1e8 100644 --- a/hash/ekara_japan_m.xml +++ b/hash/ekara_japan_m.xml @@ -18,11 +18,11 @@ M-11 M-12 M-13 MC0013-KSM KSM Mini Volume 5 - + (more? what's the M highest number?) --> - + diff --git a/hash/ekara_japan_p.xml b/hash/ekara_japan_p.xml index a6736fff155..55f8c2fe06f 100644 --- a/hash/ekara_japan_p.xml +++ b/hash/ekara_japan_p.xml @@ -39,17 +39,17 @@ - + BHT Volume 7 (Japan) (PC0004-BHT) 2002 Takara - + - + - + diff --git a/hash/ekara_japan_s.xml b/hash/ekara_japan_s.xml index bf95c5d9826..ead455a7582 100644 --- a/hash/ekara_japan_s.xml +++ b/hash/ekara_japan_s.xml @@ -13,7 +13,7 @@ S-1 SC0001- Hello Kitty Special S-2 SC0002- (unknown) S-3 SC0003- (unknown) - S-4 *SC0004-SAI SAI (series 1) Volume 1 + S-4 *SC0004-SAI SAI (series 1) Volume 1 S-5 *SC0005-SAI SAI (series 2) Volume 1 (same series as 6,9,19,21,22) S-6 *SC0006-SAI SAI (series 2) Volume 2 (same series as 5,9,19,21,22) S-7 SC0007- (unknown) @@ -21,7 +21,7 @@ S-9 *SC0009-SAI SAI (series 2) Volume 3 (same series as 5,6,19,21,22) S-10 *SC0010-HWK HWK (untranslated) S-11 SC0011- (unknown) - S-12 *SC0012-SAI SAI (series 3) Volume 3 + S-12 *SC0012-SAI SAI (series 3) Volume 3 S-13 SC0013- (unknown) S-14 SC0014- (unknown) S-15 SC0015- (unknown) @@ -35,7 +35,7 @@ S-23 SC0023- (unknown) (more? what's the S highest number?) - + --> diff --git a/hash/ekara_japan_sp.xml b/hash/ekara_japan_sp.xml index efb6ea08554..d9e1bc16492 100644 --- a/hash/ekara_japan_sp.xml +++ b/hash/ekara_japan_sp.xml @@ -7,7 +7,7 @@ *********************************************************************************** Japanese cart listing (by SP code) * = dumped - + These don't seem to have a secondary numbering scheme (eg SPxxxx-xxx) These are for use with 5 different units @@ -16,14 +16,14 @@ 3. Popira 2 (Blue/Green) ( https://www.youtube.com/watch?v=iY1I-jfXw7U ) 4. Taiko de Popira 5. Jumping Popira (Stepping Mat type thing) ( https://www.youtube.com/watch?v=yJruMOBdLFY ) - + If you plug this into a DDR Family Mat you get the message (in Japanese) - + "please play this cartridge on e-kara series, popira, popira 2, taiko de popira or jumping popira" gives 'memory error' if plugged into Popira (needs cartridge SEEPROM emulating) gives 'eep-rom error' if plugged into Taiko de Popira (same reason) - + SP-01 (unknown) *SP-02 'Super Cartridge' SP-2 SP-03 (unknown) @@ -46,5 +46,5 @@ - + diff --git a/hash/ekara_us.xml b/hash/ekara_us.xml index e16a244b617..69af8ccac8d 100644 --- a/hash/ekara_us.xml +++ b/hash/ekara_us.xml @@ -229,5 +229,5 @@ - + diff --git a/hash/jakks_gamekey_dy.xml b/hash/jakks_gamekey_dy.xml index 1eb4a801760..00e041cea04 100644 --- a/hash/jakks_gamekey_dy.xml +++ b/hash/jakks_gamekey_dy.xml @@ -1,12 +1,12 @@ - + - + - + Sports Bowling & Goofy's Underwater Adventure 2005 @@ -14,9 +14,9 @@ - - - + + + @@ -28,13 +28,13 @@ - - - - + + + + - + Sports Tennis & Face Chase & Riches of Agrabah 2005 @@ -42,11 +42,11 @@ - - - - + + + + - - + + diff --git a/hash/jakks_gamekey_nk.xml b/hash/jakks_gamekey_nk.xml index d95389638ab..da91e1abcbf 100644 --- a/hash/jakks_gamekey_nk.xml +++ b/hash/jakks_gamekey_nk.xml @@ -1,9 +1,9 @@ - + - + Soccer Shootout & Juego De Futbol De Dora & Dora's Star Mountain Adventure 2005 @@ -11,9 +11,9 @@ - - - + + + diff --git a/hash/jakks_gamekey_sw.xml b/hash/jakks_gamekey_sw.xml index 1485cb87b70..831d5eb8df1 100644 --- a/hash/jakks_gamekey_sw.xml +++ b/hash/jakks_gamekey_sw.xml @@ -1,12 +1,12 @@ - + - + - + Turret Defense & Yoda's Escape 2005 @@ -20,5 +20,5 @@ - + diff --git a/hash/pce_tourvision.xml b/hash/pce_tourvision.xml index 510ebc7abd9..58b3f4ea510 100644 --- a/hash/pce_tourvision.xml +++ b/hash/pce_tourvision.xml @@ -898,10 +898,10 @@ Parasol Stars - + @@ -1041,7 +1041,7 @@ Parasol Stars Pro Yakyuu World Stadium '91 (TourVision PCE bootleg) 1991 bootleg (TourVision) / Namcot - + @@ -1067,7 +1067,7 @@ Parasol Stars Puzzle Boy (TourVision PCE bootleg) 1991 bootleg (TourVision) / Nihon Telenet - + @@ -1080,11 +1080,11 @@ Parasol Stars Puzznic (TourVision PCE bootleg) 1990 bootleg (TourVision) / Taito - + - + @@ -1123,7 +1123,7 @@ Parasol Stars - + diff --git a/hash/vsmile_cart.xml b/hash/vsmile_cart.xml index bb7ab418a3a..f097cf4ded7 100644 --- a/hash/vsmile_cart.xml +++ b/hash/vsmile_cart.xml @@ -1892,7 +1892,7 @@ Game cartridges - + Superman - Der Superheld (Ger) 200? diff --git a/hash/vtech_storio_cart.xml b/hash/vtech_storio_cart.xml index 32d6e17d970..1d901cf1ff0 100644 --- a/hash/vtech_storio_cart.xml +++ b/hash/vtech_storio_cart.xml @@ -1,10 +1,10 @@ - + - + NC // register_subalias("5", ); --> VCC - register_subalias("6", m_R91); - register_subalias("7", m_R92); + register_subalias("6", "R91"); + register_subalias("7", "R92"); - register_subalias("8", m_Q[2]); - register_subalias("9", m_Q[1]); + register_subalias("8", "QC"); + register_subalias("9", "QB"); // register_subalias("10", ); --> GND - register_subalias("11", m_Q[3]); - register_subalias("12", m_Q[0]); + register_subalias("11", "QD"); + register_subalias("12", "QA"); // register_subalias("13", ); --> NC - register_subalias("14", m_A); + register_subalias("14", "A"); } }; diff --git a/src/lib/netlist/devices/nld_7493.cpp b/src/lib/netlist/devices/nld_7493.cpp index e19614329a9..f26e1c237d5 100644 --- a/src/lib/netlist/devices/nld_7493.cpp +++ b/src/lib/netlist/devices/nld_7493.cpp @@ -22,7 +22,6 @@ namespace netlist NETLIB_CONSTRUCTOR(7493) , m_R1(*this, "R1") , m_R2(*this, "R2") - , m_reset(*this, "_m_reset", 0) , m_a(*this, "_m_a", 0) , m_bcd(*this, "_m_b", 0) , m_CLKA(*this, "CLKA", NETLIB_DELEGATE(7493, updA)) @@ -35,34 +34,49 @@ namespace netlist } private: - NETLIB_RESETI(); - NETLIB_UPDATEI(); + NETLIB_RESETI() + { + m_a = m_bcd = 0; + m_CLKA.set_state(logic_t::STATE_INP_HL); + m_CLKB.set_state(logic_t::STATE_INP_HL); + } - NETLIB_HANDLERI(updA) + NETLIB_UPDATEI() { - //if (m_reset) + if (!(m_R1() & m_R2())) + { + m_CLKA.activate_hl(); + m_CLKB.activate_hl(); + } + else { - m_a ^= 1; - m_QA.push(m_a, out_delay); + m_CLKA.inactivate(); + m_CLKB.inactivate(); + m_QA.push(0, NLTIME_FROM_NS(40)); + m_QB.push(0, NLTIME_FROM_NS(40)); + m_QC.push(0, NLTIME_FROM_NS(40)); + m_QD.push(0, NLTIME_FROM_NS(40)); + m_a = m_bcd = 0; } } + NETLIB_HANDLERI(updA) + { + m_a ^= 1; + m_QA.push(m_a, out_delay); + } + NETLIB_HANDLERI(updB) { - //if (m_reset) - { - //++m_bcd &= 0x07; - auto cnt = (++m_bcd &= 0x07); - m_QD.push((cnt >> 2) & 1, out_delay3); - m_QC.push((cnt >> 1) & 1, out_delay2); - m_QB.push(cnt & 1, out_delay); - } + auto cnt = (++m_bcd &= 0x07); + m_QD.push((cnt >> 2) & 1, out_delay3); + m_QC.push((cnt >> 1) & 1, out_delay2); + m_QB.push(cnt & 1, out_delay); } logic_input_t m_R1; logic_input_t m_R2; - state_var_sig m_reset; state_var_sig m_a; state_var_u8 m_bcd; @@ -98,34 +112,6 @@ namespace netlist } }; - NETLIB_RESET(7493) - { - m_reset = 1; - m_a = m_bcd = 0; - m_CLKA.set_state(logic_t::STATE_INP_HL); - m_CLKB.set_state(logic_t::STATE_INP_HL); - } - - NETLIB_UPDATE(7493) - { - m_reset = (m_R1() & m_R2()) ^ 1; - - if (m_reset) - { - m_CLKA.activate_hl(); - m_CLKB.activate_hl(); - } - else - { - m_CLKA.inactivate(); - m_CLKB.inactivate(); - m_QA.push(0, NLTIME_FROM_NS(40)); - m_QB.push(0, NLTIME_FROM_NS(40)); - m_QC.push(0, NLTIME_FROM_NS(40)); - m_QD.push(0, NLTIME_FROM_NS(40)); - m_a = m_bcd = 0; - } - } NETLIB_DEVICE_IMPL(7493, "TTL_7493", "+CLKA,+CLKB,+R1,+R2") NETLIB_DEVICE_IMPL(7493_dip, "TTL_7493_DIP", "") diff --git a/src/lib/netlist/devices/nld_9316.cpp b/src/lib/netlist/devices/nld_9316.cpp index 390e3285fc2..2b17eabb3ec 100644 --- a/src/lib/netlist/devices/nld_9316.cpp +++ b/src/lib/netlist/devices/nld_9316.cpp @@ -20,6 +20,7 @@ namespace netlist NETLIB_CONSTRUCTOR(9316) , m_CLK(*this, "CLK", NETLIB_DELEGATE(9316, clk)) , m_ENT(*this, "ENT") + , m_RC(*this, "RC") , m_LOADQ(*this, "LOADQ") , m_ENP(*this, "ENP") , m_CLRQ(*this, "CLRQ") @@ -28,7 +29,6 @@ namespace netlist , m_C(*this, "C", NETLIB_DELEGATE(9316, abcd)) , m_D(*this, "D", NETLIB_DELEGATE(9316, abcd)) , m_Q(*this, {{ "QA", "QB", "QC", "QD" }}) - , m_RC(*this, "RC") , m_cnt(*this, "m_cnt", 0) , m_abcd(*this, "m_abcd", 0) , m_loadq(*this, "m_loadq", 0) @@ -37,17 +37,54 @@ namespace netlist } private: - NETLIB_RESETI(); - NETLIB_UPDATEI(); - NETLIB_HANDLERI(clk); + NETLIB_RESETI() + { + m_CLK.set_state(logic_t::STATE_INP_LH); + m_cnt = 0; + m_abcd = 0; + } + + NETLIB_UPDATEI() + { + const auto CLRQ(m_CLRQ()); + m_ent = m_ENT(); + m_loadq = m_LOADQ(); + + if (((m_loadq ^ 1) || (m_ent && m_ENP())) && CLRQ) + { + m_CLK.activate_lh(); + } + else + { + m_CLK.inactivate(); + if (!CLRQ && (m_cnt>0)) + { + m_cnt = 0; + update_outputs_all(m_cnt, NLTIME_FROM_NS(36)); + } + } + m_RC.push(m_ent && (m_cnt == MAXCNT), NLTIME_FROM_NS(27)); + } + + + NETLIB_HANDLERI(clk) + { + auto cnt = (m_loadq ? m_cnt + 1 : m_abcd) & MAXCNT; + m_RC.push(m_ent && (cnt == MAXCNT), NLTIME_FROM_NS(27)); + update_outputs_all(cnt, NLTIME_FROM_NS(20)); + m_cnt = cnt; + } + NETLIB_HANDLERI(abcd) { m_abcd = static_cast((m_D() << 3) | (m_C() << 2) | (m_B() << 1) | (m_A() << 0)); } logic_input_t m_CLK; - logic_input_t m_ENT; + + logic_output_t m_RC; + logic_input_t m_LOADQ; logic_input_t m_ENP; @@ -59,18 +96,15 @@ namespace netlist logic_input_t m_D; object_array_t m_Q; - logic_output_t m_RC; /* counter state */ - state_var_u8 m_cnt; - + state_var m_cnt; /* cached pins */ state_var_u8 m_abcd; state_var_sig m_loadq; state_var_sig m_ent; - private: - void update_outputs_all(const unsigned &cnt, const netlist_time &out_delay) noexcept + void update_outputs_all(unsigned cnt, netlist_time out_delay) noexcept { m_Q[0].push((cnt >> 0) & 1, out_delay); m_Q[1].push((cnt >> 1) & 1, out_delay); @@ -103,64 +137,6 @@ namespace netlist } }; - NETLIB_RESET(9316) - { - m_CLK.set_state(logic_t::STATE_INP_LH); - m_cnt = 0; - m_abcd = 0; - } - - NETLIB_HANDLER(9316, clk) - { - auto cnt(m_cnt); - if (m_loadq) - { - ++cnt &= MAXCNT; - //m_RC.push(m_ENT() && (cnt == MAXCNT), NLTIME_FROM_NS(27)); - if (cnt > 0 && cnt < MAXCNT) - update_outputs_all(cnt, NLTIME_FROM_NS(20)); - else if (cnt == 0) - { - m_RC.push(0, NLTIME_FROM_NS(27)); - update_outputs_all(0, NLTIME_FROM_NS(20)); - } - else - { - m_RC.push(m_ent, NLTIME_FROM_NS(27)); - update_outputs_all(MAXCNT, NLTIME_FROM_NS(20)); - } - } - else - { - cnt = m_abcd; - m_RC.push(m_ent && (cnt == MAXCNT), NLTIME_FROM_NS(27)); - update_outputs_all(cnt, NLTIME_FROM_NS(22)); - } - m_cnt = cnt; - } - - NETLIB_UPDATE(9316) - { - const netlist_sig_t CLRQ(m_CLRQ()); - m_ent = m_ENT(); - m_loadq = m_LOADQ(); - - if (((m_loadq ^ 1) || (m_ent && m_ENP())) && CLRQ) - { - m_CLK.activate_lh(); - } - else - { - m_CLK.inactivate(); - if (!CLRQ && (m_cnt>0)) - { - m_cnt = 0; - update_outputs_all(m_cnt, NLTIME_FROM_NS(36)); - } - } - m_RC.push(m_ent && (m_cnt == MAXCNT), NLTIME_FROM_NS(27)); - } - NETLIB_DEVICE_IMPL(9316, "TTL_9316", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D") NETLIB_DEVICE_IMPL(9316_dip, "TTL_9316_DIP", "") diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 4a48dc892b3..09e778762cd 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -192,13 +192,8 @@ namespace netlist } // namespace devices namespace detail { - class object_t; - class device_object_t; - struct netlist_ref; - class core_terminal_t; struct family_setter_t; class queue_t; - class net_t; } // namespace detail class logic_output_t; @@ -359,17 +354,17 @@ namespace netlist const T &value //!< Initial value after construction ); //! Copy Constructor. - state_array(const state_array &rhs) NL_NOEXCEPT = default; + state_array(const state_array &rhs) noexcept = default; //! Destructor. ~state_array() noexcept = default; //! Move Constructor. - state_array(state_array &&rhs) NL_NOEXCEPT = default; - state_array &operator=(const state_array &rhs) NL_NOEXCEPT = default; - state_array &operator=(state_array &&rhs) NL_NOEXCEPT = default; + state_array(state_array &&rhs) noexcept = default; + state_array &operator=(const state_array &rhs) noexcept = default; + state_array &operator=(state_array &&rhs) noexcept = default; - state_array &operator=(const T &rhs) NL_NOEXCEPT { m_value = rhs; return *this; } - T & operator[](const std::size_t i) NL_NOEXCEPT { return m_value[i]; } - constexpr const T & operator[](const std::size_t i) const NL_NOEXCEPT { return m_value[i]; } + state_array &operator=(const T &rhs) noexcept { m_value = rhs; return *this; } + T & operator[](const std::size_t i) noexcept { return m_value[i]; } + constexpr const T & operator[](const std::size_t i) const noexcept { return m_value[i]; } private: std::array m_value; }; @@ -390,190 +385,324 @@ namespace netlist /*! predefined state variable type for sig_t */ using state_var_sig = state_var; - // ----------------------------------------------------------------------------- - // object_t - // ----------------------------------------------------------------------------- + namespace detail { - /*! The base class for netlist devices, terminals and parameters. - * - * This class serves as the base class for all device, terminal and - * objects. It provides new and delete operators to support e.g. pooled - * memory allocation to enhance locality. Please refer to \ref USE_MEMPOOL as - * well. - */ - class detail::object_t - { - public: + // ----------------------------------------------------------------------------- + // object_t + // ----------------------------------------------------------------------------- - /*! Constructor. + /*! The base class for netlist devices, terminals and parameters. * - * Every class derived from the object_t class must have a name. + * This class serves as the base class for all device, terminal and + * objects. It provides new and delete operators to support e.g. pooled + * memory allocation to enhance locality. Please refer to \ref USE_MEMPOOL as + * well. */ - explicit object_t(const pstring &aname /*!< string containing name of the object */); + class object_t + { + public: - COPYASSIGNMOVE(object_t, delete) - /*! return name of the object - * - * \returns name of the object. - */ - pstring name() const; + /*! Constructor. + * + * Every class derived from the object_t class must have a name. + */ + explicit object_t(const pstring &aname /*!< string containing name of the object */); + + COPYASSIGNMOVE(object_t, delete) + /*! return name of the object + * + * \returns name of the object. + */ + pstring name() const; + + #if 0 + void * operator new (size_t size, void *ptr) { plib::unused_var(size); return ptr; } + void operator delete (void *ptr, void *) { plib::unused_var(ptr); } + void * operator new (size_t size) = delete; + void operator delete (void * mem) = delete; + #endif + protected: + ~object_t() noexcept = default; // only childs should be destructible -#if 0 - void * operator new (size_t size, void *ptr) { plib::unused_var(size); return ptr; } - void operator delete (void *ptr, void *) { plib::unused_var(ptr); } - void * operator new (size_t size) = delete; - void operator delete (void * mem) = delete; -#endif - protected: - ~object_t() noexcept = default; // only childs should be destructible + private: + //pstring m_name; + static std::unordered_map &name_hash() + { + static std::unordered_map lhash; + return lhash; + } + }; - private: - //pstring m_name; - static std::unordered_map &name_hash() + struct netlist_ref { - static std::unordered_map lhash; - return lhash; - } - }; + explicit netlist_ref(netlist_state_t &nl); - struct detail::netlist_ref - { - explicit netlist_ref(netlist_state_t &nl); + COPYASSIGNMOVE(netlist_ref, delete) - COPYASSIGNMOVE(netlist_ref, delete) + netlist_state_t & state() noexcept; + const netlist_state_t & state() const noexcept; - netlist_state_t & state() noexcept; - const netlist_state_t & state() const noexcept; + setup_t & setup() noexcept; + const setup_t & setup() const noexcept; - setup_t & setup() noexcept; - const setup_t & setup() const noexcept; + netlist_t & exec() noexcept { return m_netlist; } + const netlist_t & exec() const noexcept { return m_netlist; } - netlist_t & exec() noexcept { return m_netlist; } - const netlist_t & exec() const noexcept { return m_netlist; } + protected: + ~netlist_ref() noexcept = default; // prohibit polymorphic destruction - protected: - ~netlist_ref() noexcept = default; // prohibit polymorphic destruction - - private: - netlist_t & m_netlist; + private: + netlist_t & m_netlist; - }; + }; - // ----------------------------------------------------------------------------- - // device_object_t - // ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- + // device_object_t + // ----------------------------------------------------------------------------- - /*! Base class for all objects being owned by a device. - * - * Serves as the base class of all objects being owned by a device. - * - */ - class detail::device_object_t : public detail::object_t - { - public: - /*! Constructor. + /*! Base class for all objects being owned by a device. + * + * Serves as the base class of all objects being owned by a device. * - * \param dev device owning the object. - * \param name string holding the name of the device */ - device_object_t(core_device_t &dev, const pstring &name); + class device_object_t : public object_t + { + public: + /*! Constructor. + * + * \param dev device owning the object. + * \param name string holding the name of the device + */ + device_object_t(core_device_t &dev, const pstring &name); + + /*! returns reference to owning device. + * \returns reference to owning device. + */ + core_device_t &device() noexcept { return m_device; } + const core_device_t &device() const noexcept { return m_device; } + + /*! The netlist owning the owner of this object. + * \returns reference to netlist object. + */ + netlist_state_t &state() NL_NOEXCEPT; + const netlist_state_t &state() const NL_NOEXCEPT; + + netlist_t &exec() NL_NOEXCEPT; + const netlist_t &exec() const NL_NOEXCEPT; - /*! returns reference to owning device. - * \returns reference to owning device. - */ - core_device_t &device() noexcept { return m_device; } - const core_device_t &device() const noexcept { return m_device; } + private: + core_device_t & m_device; + }; + + // ----------------------------------------------------------------------------- + // core_terminal_t + // ----------------------------------------------------------------------------- - /*! The netlist owning the owner of this object. - * \returns reference to netlist object. + /*! Base class for all terminals. + * + * All terminals are derived from this class. + * */ - netlist_state_t &state() NL_NOEXCEPT; - const netlist_state_t &state() const NL_NOEXCEPT; - netlist_t &exec() NL_NOEXCEPT; - const netlist_t &exec() const NL_NOEXCEPT; + class net_t; - private: - core_device_t & m_device; -}; + class core_terminal_t : public device_object_t, + public plib::linkedlist_t::element_t + { + public: - // ----------------------------------------------------------------------------- - // core_terminal_t - // ----------------------------------------------------------------------------- + using list_t = std::vector; - /*! Base class for all terminals. - * - * All terminals are derived from this class. - * - */ - class detail::core_terminal_t : public device_object_t, - public plib::linkedlist_t::element_t - { - public: + static constexpr const auto INP_HL_SHIFT = 0; + static constexpr const auto INP_LH_SHIFT = 1; + static constexpr const auto INP_ACTIVE_SHIFT = 2; - using list_t = std::vector; + enum state_e { + STATE_INP_PASSIVE = 0, + STATE_INP_HL = (1 << INP_HL_SHIFT), + STATE_INP_LH = (1 << INP_LH_SHIFT), + STATE_INP_ACTIVE = (1 << INP_ACTIVE_SHIFT), + STATE_OUT = 128, + STATE_BIDIR = 256 + }; - static constexpr const auto INP_HL_SHIFT = 0; - static constexpr const auto INP_LH_SHIFT = 1; - static constexpr const auto INP_ACTIVE_SHIFT = 2; + core_terminal_t(core_device_t &dev, const pstring &aname, + const state_e state, nldelegate delegate = nldelegate()); + virtual ~core_terminal_t() noexcept = default; - enum state_e { - STATE_INP_PASSIVE = 0, - STATE_INP_HL = (1 << INP_HL_SHIFT), - STATE_INP_LH = (1 << INP_LH_SHIFT), - STATE_INP_ACTIVE = (1 << INP_ACTIVE_SHIFT), - STATE_OUT = 128, - STATE_BIDIR = 256 - }; + COPYASSIGNMOVE(core_terminal_t, delete) - core_terminal_t(core_device_t &dev, const pstring &aname, - const state_e state, nldelegate delegate = nldelegate()); - virtual ~core_terminal_t() noexcept = default; + /*! The object type. + * \returns type of the object + */ + terminal_type type() const; + /*! Checks if object is of specified type. + * \param atype type to check object against. + * \returns true if object is of specified type else false. + */ + bool is_type(const terminal_type atype) const noexcept { return (type() == atype); } - COPYASSIGNMOVE(core_terminal_t, delete) + void set_net(net_t *anet) noexcept { m_net = anet; } + void clear_net() noexcept { m_net = nullptr; } + bool has_net() const noexcept { return (m_net != nullptr); } - /*! The object type. - * \returns type of the object - */ - terminal_type type() const; - /*! Checks if object is of specified type. - * \param atype type to check object against. - * \returns true if object is of specified type else false. - */ - bool is_type(const terminal_type atype) const noexcept { return (type() == atype); } + const net_t & net() const noexcept { return *m_net;} + net_t & net() noexcept { return *m_net;} - void set_net(net_t *anet) noexcept { m_net = anet; } - void clear_net() noexcept { m_net = nullptr; } - bool has_net() const noexcept { return (m_net != nullptr); } + bool is_logic() const NL_NOEXCEPT; + bool is_analog() const NL_NOEXCEPT; - const net_t & net() const noexcept { return *m_net;} - net_t & net() noexcept { return *m_net;} + bool is_state(state_e astate) const noexcept { return (m_state == astate); } + state_e terminal_state() const noexcept { return m_state; } + void set_state(state_e astate) noexcept { m_state = astate; } - bool is_logic() const NL_NOEXCEPT; - bool is_analog() const NL_NOEXCEPT; + void reset() noexcept { set_state(is_type(OUTPUT) ? STATE_OUT : STATE_INP_ACTIVE); } - bool is_state(state_e astate) const noexcept { return (m_state == astate); } - state_e terminal_state() const noexcept { return m_state; } - void set_state(state_e astate) noexcept { m_state = astate; } + nldelegate m_delegate; + #if USE_COPY_INSTEAD_OF_REFERENCE + void set_copied_input(netlist_sig_t val) + { + m_Q = val; + } - void reset() noexcept { set_state(is_type(OUTPUT) ? STATE_OUT : STATE_INP_ACTIVE); } + state_var_sig m_Q; + #else + void set_copied_input(netlist_sig_t val) const { plib::unused_var(val); } + #endif - nldelegate m_delegate; -#if USE_COPY_INSTEAD_OF_REFERENCE - void set_copied_input(netlist_sig_t val) + private: + net_t * m_net; + state_var m_state; + }; + + // ----------------------------------------------------------------------------- + // net_t + // ----------------------------------------------------------------------------- + + class net_t : + public object_t, + public netlist_ref { - m_Q = val; - } + public: - state_var_sig m_Q; -#else - void set_copied_input(netlist_sig_t val) const { plib::unused_var(val); } -#endif + enum class queue_status + { + DELAYED_DUE_TO_INACTIVE = 0, + QUEUED, + DELIVERED + }; - private: - net_t * m_net; - state_var m_state; - }; + net_t(netlist_state_t &nl, const pstring &aname, core_terminal_t *mr = nullptr); + + COPYASSIGNMOVE(net_t, delete) + + virtual ~net_t() noexcept = default; + + void reset(); + + void toggle_new_Q() noexcept { m_new_Q = (m_cur_Q ^ 1); } + + void toggle_and_push_to_queue(netlist_time delay) NL_NOEXCEPT + { + toggle_new_Q(); + push_to_queue(delay); + } + + void push_to_queue(netlist_time delay) NL_NOEXCEPT; + bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } + + void update_devs() NL_NOEXCEPT; + + netlist_time next_scheduled_time() const noexcept { return m_next_scheduled_time; } + void set_next_scheduled_time(netlist_time ntime) noexcept { m_next_scheduled_time = ntime; } + + bool isRailNet() const noexcept { return !(m_railterminal == nullptr); } + core_terminal_t & railterminal() const noexcept { return *m_railterminal; } + + std::size_t num_cons() const noexcept { return m_core_terms.size(); } + + void add_to_active_list(core_terminal_t &term) NL_NOEXCEPT; + void remove_from_active_list(core_terminal_t &term) NL_NOEXCEPT; + + /* setup stuff */ + + void add_terminal(core_terminal_t &terminal); + void remove_terminal(core_terminal_t &terminal); + + bool is_logic() const NL_NOEXCEPT; + bool is_analog() const NL_NOEXCEPT; + + void rebuild_list(); /* rebuild m_list after a load */ + void move_connections(net_t &dest_net); + + std::vector &core_terms() { return m_core_terms; } + #if USE_COPY_INSTEAD_OF_REFERENCE + void update_inputs() + { + for (auto & term : m_core_terms) + term->m_Q = m_cur_Q; + } + #else + void update_inputs() const + { + /* nothing needs to be done */ + } + #endif + + protected: + + /* only used for logic nets */ + netlist_sig_t Q() const noexcept { return m_cur_Q; } + + /* only used for logic nets */ + void initial(const netlist_sig_t val) noexcept + { + m_cur_Q = m_new_Q = val; + update_inputs(); + } + + /* only used for logic nets */ + void set_Q_and_push(const netlist_sig_t newQ, const netlist_time delay) NL_NOEXCEPT + { + if (newQ != m_new_Q) + { + m_new_Q = newQ; + push_to_queue(delay); + } + } + + /* only used for logic nets */ + void set_Q_time(const netlist_sig_t newQ, const netlist_time at) NL_NOEXCEPT + { + if (newQ != m_new_Q) + { + m_in_queue = queue_status::DELAYED_DUE_TO_INACTIVE; + m_next_scheduled_time = at; + } + m_cur_Q = m_new_Q = newQ; + update_inputs(); + } + + /* internal state support + * FIXME: get rid of this and implement export/import in MAME + */ + /* only used for logic nets */ + netlist_sig_t *Q_state_ptr() { return m_cur_Q.ptr(); } + + private: + state_var m_new_Q; + state_var m_cur_Q; + state_var m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */ + state_var m_next_scheduled_time; + + core_terminal_t * m_railterminal; + plib::linkedlist_t m_list_active; + std::vector m_core_terms; // save post-start m_list ... + + template + void process(const T mask, netlist_sig_t sig); + }; + } // detail // ----------------------------------------------------------------------------- // analog_t @@ -713,133 +842,6 @@ namespace netlist }; - // ----------------------------------------------------------------------------- - // net_t - // ----------------------------------------------------------------------------- - - class detail::net_t : - public detail::object_t, - public detail::netlist_ref - { - public: - - enum class queue_status - { - DELAYED_DUE_TO_INACTIVE = 0, - QUEUED, - DELIVERED - }; - - net_t(netlist_state_t &nl, const pstring &aname, core_terminal_t *mr = nullptr); - - COPYASSIGNMOVE(net_t, delete) - - virtual ~net_t() noexcept = default; - - void reset(); - - void toggle_new_Q() noexcept { m_new_Q = (m_cur_Q ^ 1); } - - void toggle_and_push_to_queue(netlist_time delay) NL_NOEXCEPT - { - toggle_new_Q(); - push_to_queue(delay); - } - - void push_to_queue(netlist_time delay) NL_NOEXCEPT; - bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } - - void update_devs() NL_NOEXCEPT; - - netlist_time next_scheduled_time() const noexcept { return m_next_scheduled_time; } - void set_next_scheduled_time(netlist_time ntime) noexcept { m_next_scheduled_time = ntime; } - - bool isRailNet() const noexcept { return !(m_railterminal == nullptr); } - core_terminal_t & railterminal() const noexcept { return *m_railterminal; } - - std::size_t num_cons() const noexcept { return m_core_terms.size(); } - - void add_to_active_list(core_terminal_t &term) NL_NOEXCEPT; - void remove_from_active_list(core_terminal_t &term) NL_NOEXCEPT; - - /* setup stuff */ - - void add_terminal(core_terminal_t &terminal); - void remove_terminal(core_terminal_t &terminal); - - bool is_logic() const NL_NOEXCEPT; - bool is_analog() const NL_NOEXCEPT; - - void rebuild_list(); /* rebuild m_list after a load */ - void move_connections(net_t &dest_net); - - std::vector &core_terms() { return m_core_terms; } -#if USE_COPY_INSTEAD_OF_REFERENCE - void update_inputs() - { - for (auto & term : m_core_terms) - term->m_Q = m_cur_Q; - } -#else - void update_inputs() const - { - /* nothing needs to be done */ - } -#endif - - protected: - - /* only used for logic nets */ - netlist_sig_t Q() const noexcept { return m_cur_Q; } - - /* only used for logic nets */ - void initial(const netlist_sig_t val) noexcept - { - m_cur_Q = m_new_Q = val; - update_inputs(); - } - - /* only used for logic nets */ - void set_Q_and_push(const netlist_sig_t newQ, const netlist_time delay) NL_NOEXCEPT - { - if (newQ != m_new_Q) - { - m_new_Q = newQ; - push_to_queue(delay); - } - } - - /* only used for logic nets */ - void set_Q_time(const netlist_sig_t newQ, const netlist_time at) NL_NOEXCEPT - { - if (newQ != m_new_Q) - { - m_in_queue = queue_status::DELAYED_DUE_TO_INACTIVE; - m_next_scheduled_time = at; - } - m_cur_Q = m_new_Q = newQ; - update_inputs(); - } - - /* internal state support - * FIXME: get rid of this and implement export/import in MAME - */ - /* only used for logic nets */ - netlist_sig_t *Q_state_ptr() { return m_cur_Q.ptr(); } - - private: - state_var m_new_Q; - state_var m_cur_Q; - state_var m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */ - state_var m_next_scheduled_time; - - core_terminal_t * m_railterminal; - plib::linkedlist_t m_list_active; - std::vector m_core_terms; // save post-start m_list ... - - template - void process(const T mask, netlist_sig_t sig); - }; class logic_net_t : public detail::net_t { diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 4ca1e7507c8..325f8a67c72 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -198,7 +198,8 @@ namespace netlist mutex_type m_lock; PALIGNAS_CACHELINE() T * m_end; - std::vector m_list; + //std::vector m_list; + plib::aligned_vector m_list; public: // profiling diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index d3551897f69..2c357e97624 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -239,7 +239,7 @@ namespace plib ops.calc_rhs(Ax, x); - vec_sub(n, rhs, Ax, residual); + vec_sub(n, residual, rhs, Ax); ops.solve_LU_inplace(residual); @@ -258,7 +258,7 @@ namespace plib //for (std::size_t i = 0; i < mr + 1; i++) // vec_set_scalar(mr, m_ht[i], NL_FCONST(0.0)); - vec_mult_scalar(n, residual, constants::one() / rho, m_v[0]); + vec_mult_scalar(n, m_v[0], residual, constants::one() / rho); for (std::size_t k = 0; k < RESTART; k++) { @@ -270,7 +270,7 @@ namespace plib for (std::size_t j = 0; j <= k; j++) { m_ht[j][k] = vec_mult(n, m_v[kp1], m_v[j]); - vec_add_mult_scalar(n, m_v[j], -m_ht[j][k], m_v[kp1]); + vec_add_mult_scalar(n, m_v[kp1], m_v[j], -m_ht[j][k]); } m_ht[kp1][k] = std::sqrt(vec_mult2(n, m_v[kp1])); @@ -315,7 +315,7 @@ namespace plib } for (std::size_t i = 0; i <= last_k; i++) - vec_add_mult_scalar(n, m_v[i], m_y[i], x); + vec_add_mult_scalar(n, x, m_v[i], m_y[i]); if (rho <= rho_delta) break; diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 6616669f619..c5a83718395 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -38,7 +38,7 @@ */ #ifndef USE_ALIGNED_OPTIMIZATIONS -#define USE_ALIGNED_OPTIMIZATIONS (1) +#define USE_ALIGNED_OPTIMIZATIONS (0) #endif #define USE_ALIGNED_ALLOCATION (USE_ALIGNED_OPTIMIZATIONS) @@ -48,7 +48,7 @@ */ #define PALIGN_CACHELINE (64) -#define PALIGN_VECTOROPT (32) +#define PALIGN_VECTOROPT (64) #define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) #define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 2a0fd3a6c3c..c2fee9c2f8e 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -34,10 +34,10 @@ public: using iterator = C *; using const_iterator = const C *; - uninitialised_array_t() = default; + uninitialised_array_t() noexcept = default; COPYASSIGNMOVE(uninitialised_array_t, delete) - ~uninitialised_array_t() + ~uninitialised_array_t() noexcept { for (std::size_t i=0; i::type, N> m_buf; }; @@ -226,10 +226,10 @@ public: void push_front(LC *elem) noexcept { + if (m_head) + m_head->m_prev = elem; elem->m_next = m_head; elem->m_prev = nullptr; - if (elem->m_next) - elem->m_next->m_prev = elem; m_head = elem; } diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 5449595c86c..f55807c86dc 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -182,59 +182,6 @@ namespace plib { }; -#if 0 - class mempool_default - { - private: - - size_t m_min_alloc; - size_t m_min_align; - - public: - - static constexpr const bool is_stateless = true; - template - using allocator_type = arena_allocator; - - mempool_default(size_t min_alloc = 16, size_t min_align = (1 << 21)) - : m_min_alloc(min_alloc), m_min_align(min_align) - { - } - - COPYASSIGNMOVE(mempool_default, delete) - - ~mempool_default() = default; - - void *allocate(size_t alignment, size_t size) - { - plib::unused_var(m_min_alloc); // -Wunused-private-field fires without - plib::unused_var(m_min_align); - plib::unused_var(alignment); - - return ::operator new(size); - } - - static void deallocate(void *ptr) - { - ::operator delete(ptr); - } - - template - using poolptr = plib::owned_ptr>; - - template - poolptr make_poolptr(Args&&... args) - { - plib::unused_var(m_min_alloc); // -Wunused-private-field fires without - plib::unused_var(m_min_align); - - auto *obj = plib::pnew(std::forward(args)...); - poolptr a(obj, true); - return std::move(a); - } - }; -#endif - } // namespace plib #endif /* PMEMPOOL_H_ */ diff --git a/src/lib/netlist/plib/pstring.cpp b/src/lib/netlist/plib/pstring.cpp index 089244c8232..c304f11d1fd 100644 --- a/src/lib/netlist/plib/pstring.cpp +++ b/src/lib/netlist/plib/pstring.cpp @@ -13,15 +13,6 @@ #include #include -template -std::size_t strlen_mem(const T *s) -{ - std::size_t len(0); - while (*s++) - ++len; - return len; -} - template int pstring_t::compare(const pstring_t &right) const { diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 64cb0604b69..c4caeab8e8f 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -75,7 +75,7 @@ public: using string_type = typename traits_type::string_type; // FIXME: this is ugly - class ref_value_type final + struct ref_value_type final { public: ref_value_type() = delete; @@ -202,11 +202,9 @@ public: size_type mem_t_size() const { return m_str.size(); } - pstring_t rpad(const pstring_t &ws, const size_type cnt) const; - const string_type &cpp_string() const { return m_str; } - static const size_type npos = static_cast(-1); + static constexpr const size_type npos = static_cast(-1); private: string_type m_str; diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h index 880840e8707..8043c48f61c 100644 --- a/src/lib/netlist/plib/vector_ops.h +++ b/src/lib/netlist/plib/vector_ops.h @@ -26,7 +26,7 @@ namespace plib { template - void vec_set_scalar (const std::size_t n, VT &v, T && scalar) + void vec_set_scalar(const std::size_t n, VT &v, T && scalar) { const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) @@ -34,14 +34,14 @@ namespace plib } template - void vec_set (const std::size_t n, VT &v, const VS & source) + void vec_set(const std::size_t n, VT &v, const VS & source) { for ( std::size_t i = 0; i < n; i++ ) v[i] = source[i]; } template - T vec_mult (const std::size_t n, const V1 & v1, const V2 & v2 ) + T vec_mult(const std::size_t n, const V1 & v1, const V2 & v2 ) { using b8 = T[8]; PALIGNAS_VECTOROPT() b8 value = {0}; @@ -53,7 +53,7 @@ namespace plib } template - T vec_mult2 (const std::size_t n, const VT &v) + T vec_mult2(const std::size_t n, const VT &v) { using b8 = T[8]; PALIGNAS_VECTOROPT() b8 value = {0}; @@ -65,7 +65,7 @@ namespace plib } template - T vec_sum (const std::size_t n, const VT &v) + T vec_sum(const std::size_t n, const VT &v) { if (n<8) { @@ -87,15 +87,15 @@ namespace plib } template - void vec_mult_scalar (const std::size_t n, const VV & v, T && scalar, VR & result) + void vec_mult_scalar(const std::size_t n, VR & result, const VV & v, T && scalar) { const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) result[i] = s * v[i]; } - template - void vec_add_mult_scalar (const std::size_t n, const VV & v, T && scalar, VR & result) + template + void vec_add_mult_scalar(const std::size_t n, VR & result, const VV & v, T && scalar) { const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) @@ -103,21 +103,21 @@ namespace plib } template - void vec_add_mult_scalar_p(const std::size_t & n, const T * v, T scalar, T * result) + void vec_add_mult_scalar_p(const std::size_t n, T * result, const T * v, T scalar) { for ( std::size_t i = 0; i < n; i++ ) result[i] += scalar * v[i]; } - template - void vec_add_ip(const std::size_t n, const V & v, R & result) + template + void vec_add_ip(const std::size_t n, R & result, const V & v) { for ( std::size_t i = 0; i < n; i++ ) result[i] += v[i]; } - template - void vec_sub(const std::size_t n, const V1 &v1, const V2 & v2, VR & result) + template + void vec_sub(const std::size_t n, VR & result, const V1 &v1, const V2 & v2) { for ( std::size_t i = 0; i < n; i++ ) result[i] = v1[i] - v2[i]; diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h index 35858363a33..2501742218d 100644 --- a/src/lib/netlist/solver/nld_ms_direct.h +++ b/src/lib/netlist/solver/nld_ms_direct.h @@ -139,9 +139,9 @@ namespace devices const FT * pi = &A(i,i+1); FT * pj = &A(j,i+1); #if 1 - plib::vec_add_mult_scalar_p(kN-i,pi,f1,pj); + plib::vec_add_mult_scalar_p(kN-i,pj, pi,f1); #else - vec_add_mult_scalar_p(kN-i-1,pj,f1,pi); + vec_add_mult_scalar_p1(kN-i-1,pj,pi,f1); //for (unsigned k = i+1; k < kN; k++) // pj[k] = pj[k] + pi[k] * f1; //for (unsigned k = i+1; k < kN; k++) -- cgit v1.2.3-70-g09d2