diff --git a/src/emu/netlist/nl_util.h b/src/emu/netlist/nl_util.h index 3ec22f72f1e..09c1c673709 100644 --- a/src/emu/netlist/nl_util.h +++ b/src/emu/netlist/nl_util.h @@ -21,7 +21,7 @@ private: public: typedef plinearlist_t pstring_list; - static pstring_list split(const pstring &str, const pstring &onstr) + static pstring_list split(const pstring &str, const pstring &onstr, bool ignore_empty = false) { pstring_list temp; @@ -31,12 +31,18 @@ public: pn = str.find(onstr, p); while (pn>=0) { - temp.add(str.substr(p, pn - p)); + pstring t = str.substr(p, pn - p); + if (!ignore_empty || t.len() != 0) + temp.add(t); p = pn + onstr.len(); pn = str.find(onstr, p); } if (p nets; + +static void add_term(pstring netname, pstring termname) +{ + sp_net_t * net = nets.find(netname); + if (net == NULL) + { + net = new sp_net_t; + net->m_name = netname; + nets.add(net, false); + } + net->m_terminals.add(termname); +} + +static void convert(core_options &opts) +{ + pstring spnlf = filetobuf(opts.value("f")); + nl_util::pstring_list spnl = nl_util::split(spnlf, "\n"); + + for (int i=0; i < spnl.count(); i++) + { + pstring line = spnl[i].trim(); + if (line != "" && line.left(1) != "*") + { + nl_util::pstring_list tt = nl_util::split(line, " ", true); + switch (tt[0].cstr()[0]) + { + case '.': + // e.g. SUBCKT - ignored for now + break; + case 'Q': + printf("QBJT(%s, \"%s\")\n", tt[0].cstr(), tt[4].cstr()); + add_term(tt[1], tt[0] + ".C"); + add_term(tt[2], tt[0] + ".B"); + add_term(tt[3], tt[0] + ".E"); + break; + case 'R': + // FIXME: Rewrite resistor value + printf("RES(%s, %s)\n", tt[0].cstr(), tt[3].cstr()); + add_term(tt[1], tt[0] + ".1"); + add_term(tt[2], tt[0] + ".2"); + break; + default: + printf("%s: %s\n", tt[0].cstr(), line.cstr()); + } + } + } + // print nets + for (int i=0; iname().cstr()); + printf("NET_C(%s", net->m_terminals[0].cstr() ); + for (int j=1; jm_terminals.count(); j++) + { + printf(", %s", net->m_terminals[j].cstr() ); + } + printf(")\n"); + } + +} + + /*------------------------------------------------- main - primary entry point -------------------------------------------------*/ @@ -315,13 +393,18 @@ int main(int argc, char *argv[]) return 1; } - if (opts.bool_value("ld")) - { + pstring cmd = opts.value("c"); + if (cmd == "listdevices") listdevices(); - } + else if (cmd == "run") + run(opts); + else if (cmd == "convert") + convert(opts); else { - run(opts); + fprintf(stderr, "Unknown command %s\n", cmd.cstr()); + usage(opts); + return 1; } return 0;