Previous 199869 Revisions Next

r26660 Thursday 19th December, 2013 at 11:58:05 UTC by Couriersud
Pong update:
- based on feedback from IRC hopefully fixed issues like "jumping"
- adjusted VR1 and VR2 to 50%
- disabled all printf output.
[src/emu/machine]netlist.c
[src/emu/netlist]nl_base.c nl_base.h nl_parser.c nl_parser.h nl_setup.c nl_setup.h pstring.c pstring.h
[src/emu/netlist/devices]nld_7474.c nld_7493.c nld_solver.c nld_twoterm.c nld_twoterm.h
[src/emu/video]fixfreq.c
[src/mame/drivers]pong.c
[src/tools]nltool.c* tools.mak

trunk/src/mame/drivers/pong.c
r26659r26660
5858fixedfreq_interface fixedfreq_mode_pong = {
5959   MASTER_CLOCK,
6060   H_TOTAL-67,H_TOTAL-40,H_TOTAL-8,H_TOTAL,
61   V_TOTAL-22,V_TOTAL-19,V_TOTAL-16,V_TOTAL,
62   1,  /* interlaced */
61   V_TOTAL-22,V_TOTAL-19,V_TOTAL-12,V_TOTAL,
62   1,  /* non-interlaced */
6363   0.32
6464};
6565
r26659r26660
6767   MASTER_CLOCK * 2,
6868   (H_TOTAL-67) * 2, (H_TOTAL-40) * 2, (H_TOTAL-8) * 2, (H_TOTAL) * 2,
6969   V_TOTAL-22,V_TOTAL-19,V_TOTAL-16,V_TOTAL,
70   1,  /* interlaced */
70   1,  /* non-interlaced */
7171   0.32
7272};
7373
r26659r26660
933933   PORT_DIPSETTING(    0x06, "15" )
934934
935935   PORT_START("VR1")
936   PORT_ADJUSTER( 63, "VR1 - 50k, Paddle 1 adjustment" )   PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR1)
936   PORT_ADJUSTER( 50, "VR1 - 50k, Paddle 1 adjustment" )   PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR1)
937937   PORT_START("VR2")
938   PORT_ADJUSTER( 63, "VR2 - 50k, Paddle 2 adjustment" )   PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR2)
938   PORT_ADJUSTER( 50, "VR2 - 50k, Paddle 2 adjustment" )   PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR2)
939939   //PORT_START("GATESPEED")
940940   //PORT_ADJUSTER( 100, "Logic Gate Delay" ) PORT_MINMAX(10, 200) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_GATEDELAY)
941941
trunk/src/tools/tools.mak
r26659r26660
6262   src2html$(EXE) \
6363   split$(EXE) \
6464   pngcmp$(EXE) \
65   nltool$(EXE) \
6566
6667
6768
r26659r26660
207208   @echo Linking $@...
208209   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
209210
211#-------------------------------------------------
212# nltool
213#-------------------------------------------------
214
215NLTOOLOBJS = \
216   $(TOOLSOBJ)/nltool.o \
217   $(NETLISTOBJS) \
218
219nltool$(EXE): $(NLTOOLOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB) $(EXPAT)
220   @echo Linking $@...
221   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
trunk/src/tools/nltool.c
r0r26660
1/***************************************************************************
2
3    nltool.c
4
5    Simple tool to debug netlists outside MAME.
6
7****************************************************************************/
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <ctype.h>
13#include "astring.h"
14#include "corefile.h"
15#include "corestr.h"
16#include "sha1.h"
17#include "netlist/nl_base.h"
18#include "netlist/nl_setup.h"
19#include "options.h"
20
21/***************************************************************************
22    MAME COMPATIBILITY ...
23***************************************************************************/
24
25#if 0
26void mame_printf_warning(const char *format, ...)
27{
28    va_list argptr;
29
30    /* do the output */
31    va_start(argptr, format);
32    vprintf(format, argptr);
33    va_end(argptr);
34}
35#endif
36
37void *malloc_file_line(size_t size, const char *file, int line)
38{
39    // allocate the memory and fail if we can't
40    void *ret = osd_malloc(size);
41    memset(ret, 0, size);
42    return ret;
43}
44
45void *malloc_array_file_line(size_t size, const char *file, int line)
46{
47    // allocate the memory and fail if we can't
48    void *ret = osd_malloc_array(size);
49    memset(ret, 0, size);
50    return ret;
51}
52
53void free_file_line( void *memory, const char *file, int line )
54{
55    osd_free( memory );
56}
57
58
59struct options_entry oplist[] =
60{
61    { "time_to_run;ttr", "1.0", OPTION_FLOAT,   "time to run the emulation (seconds)" },
62    { "f",               "-",   OPTION_STRING,  "file to process (default is stdin)" },
63    { "help;h",          "0",   OPTION_BOOLEAN, "display help" },
64    { NULL }
65};
66
67/***************************************************************************
68    CORE IMPLEMENTATION
69***************************************************************************/
70
71const char *filetobuf(pstring fname)
72{
73    static pstring pbuf = "";
74
75    if (fname == "-")
76    {
77        char lbuf[1024];
78        while (!feof(stdin))
79        {
80            fgets(lbuf, 1024, stdin);
81            pbuf += lbuf;
82        }
83        printf("%d\n",*(pbuf.right(1).cstr()+1));
84        return pbuf.cstr();
85    }
86    else
87    {
88        FILE *f;
89        f = fopen(fname, "rb");
90        fseek(f, 0, SEEK_END);
91        long fsize = ftell(f);
92        fseek(f, 0, SEEK_SET);
93
94        char *buf = (char *) malloc(fsize);
95        fread(buf, fsize, 1, f);
96        buf[fsize] = 0;
97        fclose(f);
98        return buf;
99    }
100}
101
102class netlist_tool_t : public netlist_base_t
103{
104public:
105
106    netlist_tool_t()
107    : netlist_base_t(), m_setup(NULL)
108    {
109
110    }
111
112    virtual ~netlist_tool_t() { };
113
114    void read_netlist(const char *buffer)
115    {
116        m_setup = new netlist_setup_t(*this);
117        this->set_clock_freq(NETLIST_CLOCK);
118
119        // register additional devices
120        //m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback");
121
122        // read the netlist ...
123        //m_setup_func(*m_setup);
124
125        m_setup->parse(buffer);
126
127        // start devices
128        m_setup->start_devices();
129        m_setup->resolve_inputs();
130        // reset
131        this->reset();
132    }
133
134protected:
135
136    void vfatalerror(const char *format, va_list ap) const
137    {
138        vprintf(format, ap);
139        throw;
140    }
141
142private:
143    netlist_setup_t *m_setup;
144};
145
146void usage(core_options &opts)
147{
148    astring buffer;
149    fprintf(stderr,
150        "Usage:\n"
151        "  nltool -help\n"
152        "  nltool [options]\n"
153        "\n"
154        "Where:\n"
155    );
156    fprintf(stderr, "%s\n", opts.output_help(buffer));
157}
158
159/*-------------------------------------------------
160    main - primary entry point
161-------------------------------------------------*/
162
163int main(int argc, char *argv[])
164{
165   //int result;
166   netlist_tool_t nt;
167   core_options opts(oplist);
168   astring aerror("");
169    osd_ticks_t t = osd_ticks();
170
171    fprintf(stderr, "%s", "WARNING: This is Work In Progress! - It may fail anytime\n");
172   if (!opts.parse_command_line(argc, argv, OPTION_PRIORITY_DEFAULT, aerror))
173   {
174        fprintf(stderr, "%s\n", aerror.cstr());
175        usage(opts);
176        return 1;
177   }
178   if (opts.bool_value("h"))
179   {
180        usage(opts);
181        return 1;
182   }
183
184    nt.read_netlist(filetobuf(opts.value("f")));
185    double ttr = opts.float_value("ttr");
186
187    INT64 tt = ttr * NETLIST_CLOCK;
188
189    printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() );
190    printf("runnning ...\n");
191    t = osd_ticks();
192    while (tt>0)
193    {
194        INT32 tr = MIN(tt, NETLIST_CLOCK / 10);
195        tt -= tr;
196        nt.process_queue(tr);
197    }
198    double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second();
199    printf("%f seconds emulation took %f real time ==> %5.2f%%\n", ttr, emutime, ttr/emutime*100.0);
200}
Property changes on: trunk/src/tools/nltool.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/emu/machine/netlist.c
r26659r26660
5050#include "netlist/nl_setup.h"
5151#include "netlist/devices/net_lib.h"
5252
53#define LOG_DEV_CALLS(x)   do { } while (0);
54
5355// ----------------------------------------------------------------------------------------
5456// netlist_mame_device
5557// ----------------------------------------------------------------------------------------
r26659r26660
7173{
7274   netlist_mame_device &netlist = downcast<netlist_mame_device &>(device);
7375   netlist.m_setup_func = setup_func;
76   LOG_DEV_CALLS(("static_set_constructor\n"));
7477}
7578
7679void netlist_mame_device::device_config_complete()
7780{
81    LOG_DEV_CALLS(("device_config_complete\n"));
7882}
7983
8084void netlist_mame_device::device_start()
8185{
86    LOG_DEV_CALLS(("device_start\n"));
87
8288   m_netlist = global_alloc_clear(netlist_mame_t(*this));
8389   m_netlist->set_clock_freq(this->clock());
8490
r26659r26660
9197   m_setup_func(*m_setup);
9298
9399   m_setup->start_devices();
100   m_setup->resolve_inputs();
94101
95   bool allok = true;
96   for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods))
97      allok &= ods->object()->OnDeviceStart();
102    bool allok = true;
103    for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods))
104        allok &= ods->object()->OnDeviceStart();
98105
99   if (!allok)
100       m_netlist->xfatalerror("required elements not found\n");
106    if (!allok)
107        m_netlist->xfatalerror("required elements not found\n");
101108
102   m_setup->resolve_inputs();
103
104109   save_state();
105110   /* TODO: we have to save the round robin queue as well */
106111
r26659r26660
110115
111116void netlist_mame_device::device_reset()
112117{
118    LOG_DEV_CALLS(("device_reset\n"));
113119   m_netlist->reset();
114   m_setup->step_devices_once();
115120}
116121
117122void netlist_mame_device::device_stop()
118123{
124    LOG_DEV_CALLS(("device_stop\n"));
119125   m_setup->print_stats();
120126
121127   global_free(m_setup);
trunk/src/emu/netlist/nl_setup.h
r26659r26660
9494        link_t &operator=(const link_t &rhs) { e1 = rhs.e1; e2 = rhs.e2; return *this; }
9595    };
9696
97   typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t;
9897   typedef tagmap_t<pstring, 393> tagmap_nstring_t;
9998   typedef tagmap_t<netlist_param_t *, 393> tagmap_param_t;
10099   typedef tagmap_t<netlist_core_terminal_t *, 393> tagmap_terminal_t;
r26659r26660
124123
125124    netlist_param_t *find_param(const pstring &param_in, bool required = true);
126125
127    void parse(char *buf);
126    void parse(const char *buf);
128127
129    void start_devices(void);
130   void resolve_inputs(void);
131   void step_devices_once(void);
128    void start_devices();
129   void resolve_inputs();
132130
133131   /* not ideal, but needed for save_state */
134132   tagmap_terminal_t  m_terminals;
r26659r26660
141139
142140   netlist_base_t &m_netlist;
143141
144   tagmap_devices_t m_devices;
145142   tagmap_nstring_t m_alias;
146143   tagmap_param_t  m_params;
147144   tagmap_link_t   m_links;
trunk/src/emu/netlist/devices/nld_twoterm.c
r26659r26660
227227    if (m_gB < NETLIST_GMIN)
228228        m_gB = NETLIST_GMIN;
229229    m_gC = BF * m_gB; // very rough estimate
230    printf("%f %f \n", m_V, m_gB);
230    //printf("%f %f \n", m_V, m_gB);
231231    m_RB.set(NETLIST_GMIN, 0.0, 0.0);
232232    m_RC.set(NETLIST_GMIN, 0.0, 0.0);
233233}
trunk/src/emu/netlist/devices/nld_7474.c
r26659r26660
88ATTR_HOT inline void NETLIB_NAME(7474sub)::newstate(const UINT8 state)
99{
1010    static const netlist_time delay[2] = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(40) };
11    //printf("%s %d %d %d\n", "7474", state, Q.Q(), QQ.Q());
1211    OUTLOGIC(m_Q, state, delay[state]);
1312    OUTLOGIC(m_QQ, !state, delay[!state]);
1413}
trunk/src/emu/netlist/devices/nld_7493.c
r26659r26660
4444
4545    if (r)
4646    {
47        //printf("%s reset\n", name());
4847        A.m_reset = B.m_reset = C.m_reset = D.m_reset = 1;
4948        A.m_I.inactivate();
5049        B.m_I.inactivate();
r26659r26660
5857        A.m_reset = B.m_reset = C.m_reset = D.m_reset = 0;
5958        A.m_I.activate_hl();
6059        B.m_I.activate_hl();
61        //printf("%s enable\n", name());
6260    }
6361}
trunk/src/emu/netlist/devices/nld_twoterm.h
r26659r26660
312312        double vE = INPANALOG(m_EV);
313313        double vB = INPANALOG(m_BV);
314314
315        //printf("diff %f %f = %f - %f\n", vB - vE, vB, vE, m_RB.m_N.m_g);
316315        int new_state = (vB - vE > m_V ) ? 1 : 0;
317316        if (m_state_on ^ new_state)
318317        {
trunk/src/emu/netlist/devices/nld_solver.c
r26659r26660
1010// netlist_matrix_solver
1111// ----------------------------------------------------------------------------------------
1212
13#define SOLVER_VERBOSE_OUT(x) do {} while (0)
14//#define SOLVER_VERBOSE_OUT(x) printf x
1315
1416ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &aowner)
1517{
r26659r26660
264266        }
265267    }
266268
267    printf("Scanning net groups ...\n");
269    SOLVER_VERBOSE_OUT(("Scanning net groups ...\n"));
268270    // determine net groups
269271    for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn))
270272    {
r26659r26660
276278    }
277279
278280    // setup the solvers
279    printf("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count());
281    SOLVER_VERBOSE_OUT(("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count()));
280282    for (int i = 0; i <= cur_group; i++)
281283    {
282284        netlist_matrix_solver_t *ms = new netlist_matrix_solver_t();
r26659r26660
284286        ms->m_convergence_factor = m_convergence.Value();
285287        ms->setup(groups[i], *this);
286288        m_mat_solvers.add(ms);
287        printf("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr());
288        printf("  has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic");
289        SOLVER_VERBOSE_OUT(("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr()));
290        SOLVER_VERBOSE_OUT(("  has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic"));
289291    }
290292
291293}
trunk/src/emu/netlist/nl_base.c
r26659r26660
6969{
7070}
7171
72template <class T>
73static void tagmap_free_entries(T &tm)
74{
75    for (typename T::entry_t *entry = tm.first(); entry != NULL; entry = tm.next(entry))
76    {
77        delete entry->object();
78    }
79    tm.reset();
80}
81
7282netlist_base_t::~netlist_base_t()
7383{
84    tagmap_free_entries<tagmap_devices_t>(m_devices);
7485    pstring::resetmem();
7586}
7687
r26659r26660
92103    if (m_mainclock != NULL)
93104        m_mainclock->m_Q.net().set_time(netlist_time::zero);
94105
106    // FIXME: some const devices rely on this
107    /* make sure params are set now .. */
108    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
109    {
110        entry->object()->update_param();
111    }
112
113    // Step all devices once !
114    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
115    {
116        netlist_device_t *dev = entry->object();
117        dev->update_dev();
118    }
95119}
96120
97
98121void netlist_base_t::set_clock_freq(UINT64 clockfreq)
99122{
100123    m_div = netlist_time::from_hz(clockfreq).as_raw();
r26659r26660
294317{
295318    pstring alias = this->name() + "." + name;
296319
297    //printf("alias: %s\n", alias.cstr());
298
299320    setup().register_alias(alias, term.name());
300321
301322    if (term.isType(netlist_terminal_t::INPUT))
trunk/src/emu/netlist/nl_parser.c
r26659r26660
77
88#include "nl_parser.h"
99
10#undef NL_VERBOSE_OUT
11#define NL_VERBOSE_OUT(x) printf x
10//#undef NL_VERBOSE_OUT
11//#define NL_VERBOSE_OUT(x) printf x
1212
1313// ----------------------------------------------------------------------------------------
1414// A netlist parser
1515// ----------------------------------------------------------------------------------------
1616
17void netlist_parser::parse(char *buf)
17void netlist_parser::parse(const char *buf)
1818{
19    char c;
2019   m_px = buf;
21   c = getc();
2220
23   while (c)
21   while (!eof())
2422   {
2523      pstring n;
2624      skipws();
r26659r26660
4543         netdev_const(n);
4644      else
4745         netdev_device(n);
48      c = getc();
4946   }
5047}
5148
r26659r26660
8380   val = eval_param();
8481   NL_VERBOSE_OUT(("Parser: Param: %s %f\n", param.cstr(), val));
8582   m_setup.register_param(param, val);
86   //m_setup.find_param(param).initial(val);
8783   check_char(')');
8884}
8985
r26659r26660
10399   paramfq = name + ".CONST";
104100   NL_VERBOSE_OUT(("Parser: Const: %s %f\n", name.cstr(), val));
105101    check_char(')');
106   //m_setup.find_param(paramfq).initial(val);
107102   m_setup.register_param(paramfq, val);
108103}
109104
r26659r26660
273268   static double facs[6] = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12};
274269   int i;
275270   int f=0;
276   char *e;
271   bool e;
277272   double ret;
278273
279274   pstring s = getname2(')',',');
280275
281   printf("Got %s\n", s.cstr());
282276   for (i=1; i<6;i++)
283277      if (strncmp(s.cstr(), macs[i], strlen(macs[i])) == 0)
284278         f = i;
285   ret = strtod(s.substr(strlen(macs[f])).cstr(), &e);
286   if ((f>0) && (*e != 0))
279   ret = s.substr(strlen(macs[f])).as_double(&e);
280   if ((f>0) && e)
287281       m_setup.netlist().xfatalerror("Parser: Error with parameter ...\n");
288282    if (f>0)
289283        check_char(')');
290   //if (f == 0)
291   //    ungetc();
292   //if (f>0)
293   //   e++;
294   //m_p = e;
295284   return ret * facs[f];
296285}
297286
298287unsigned char netlist_parser::getc()
299288{
300    return *(m_px++);
289    if (*m_px)
290        return *(m_px++);
291    else
292        return *m_px;
301293}
302294
303295void netlist_parser::ungetc()
trunk/src/emu/netlist/pstring.c
r26659r26660
108108    return 1;
109109}
110110
111double pstring::as_double(bool *error) const
112{
113    double ret;
114    char *e = NULL;
115
116    if (error != NULL)
117        *error = false;
118    ret = strtod(cstr(), &e);
119    if (*e != 0)
120        if (error != NULL)
121            *error = true;
122    return ret;
123}
124
125long pstring::as_long(bool *error) const
126{
127    double ret;
128    char *e = NULL;
129
130    if (error != NULL)
131        *error = false;
132    if (startsWith("0x"))
133        ret = strtol(&(cstr()[2]), &e, 16);
134    else
135        ret = strtol(cstr(), &e, 10);
136    if (*e != 0)
137        if (error != NULL)
138            *error = true;
139    return ret;
140}
141
111142pstring pstring::vprintf(va_list args) const
112143{
113144    // sprintf into the temporary buffer
trunk/src/emu/netlist/nl_base.h
r26659r26660
814814
815815   ATTR_HOT virtual void inc_active() {  }
816816
817   ATTR_HOT virtual void dec_active() { /*printf("DeActivate %s\n", m_name);*/ }
817   ATTR_HOT virtual void dec_active() {  }
818818
819819   ATTR_HOT virtual void step_time(const double st) { }
820820    ATTR_HOT virtual void update_terminals() { }
r26659r26660
890890// netlist_base_t
891891// ----------------------------------------------------------------------------------------
892892
893typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t;
894
893895class netlist_base_t
894896{
895897    NETLIST_PREVENT_COPYING(netlist_base_t)
r26659r26660
914916
915917   ATTR_HOT inline const netlist_time &time() const { return m_time_ps; }
916918
917   ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev);
919    ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev);
918920    ATTR_COLD void set_solver_dev(NETLIB_NAME(solver) *dev);
921    ATTR_COLD void set_setup(netlist_setup_t *asetup) { m_setup = asetup;  }
919922
920923    ATTR_COLD void set_clock_freq(UINT64 clockfreq);
921924
922925    ATTR_COLD netlist_setup_t &setup() { return *m_setup; }
923    ATTR_COLD void set_setup(netlist_setup_t *asetup)
924    {
925        m_setup = asetup;
926    }
927
928926   ATTR_COLD void reset();
929927
930928   ATTR_COLD void xfatalerror(const char *format, ...) const;
931929
930    tagmap_devices_t m_devices;
931
932932protected:
933933
934934   // any derived netlist must override this ...
trunk/src/emu/netlist/nl_setup.c
r26659r26660
3737    NETLIST_NAME(base)(*this);
3838}
3939
40template <class T>
41static void tagmap_free_entries(T &tm)
42{
43   for (typename T::entry_t *entry = tm.first(); entry != NULL; entry = tm.next(entry))
44   {
45      delete entry->object();
46   }
47   tm.reset();
48}
4940
5041netlist_setup_t::~netlist_setup_t()
5142{
52   tagmap_free_entries<tagmap_devices_t>(m_devices);
53   //tagmap_free_entries<tagmap_link_t>(m_links);
54   //tagmap_free_entries<tagmap_nstring_t>(m_alias);
5543   m_links.reset();
5644   m_alias.reset();
5745   m_params.reset();
r26659r26660
6351   pstring::resetmem();
6452}
6553
54// FIXME: Move to netlist ...
6655netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const pstring &name)
6756{
68   if (!(m_devices.add(name, dev, false)==TMERR_NONE))
57   if (!(netlist().m_devices.add(name, dev, false)==TMERR_NONE))
6958       netlist().xfatalerror("Error adding %s to device list\n", name.cstr());
7059   return dev;
7160}
r26659r26660
8978
9079void netlist_setup_t::remove_dev(const pstring &name)
9180{
92   netlist_device_t *dev = m_devices.find(name);
81   netlist_device_t *dev = netlist().m_devices.find(name);
9382   pstring temp = name + ".";
9483   if (dev == NULL)
9584       netlist().xfatalerror("Device %s does not exist\n", name.cstr());
r26659r26660
10695           m_links.remove(p->object());
10796       p = n;
10897   }
109   m_devices.remove(name);
98   netlist().m_devices.remove(name);
11099}
111100
112101void netlist_setup_t::register_model(const pstring &model)
r26659r26660
182171                    {
183172                        case netlist_param_t::DOUBLE:
184173                        {
185                            //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
174                            NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()));
186175                            double vald = 0;
187176                            if (sscanf(val.cstr(), "%lf", &vald) != 1)
188177                                netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
r26659r26660
192181                        case netlist_param_t::INTEGER:
193182                        case netlist_param_t::LOGIC:
194183                        {
195                            //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
184                            NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()));
196185                            int vald = 0;
197186                            if (sscanf(val.cstr(), "%d", &vald) != 1)
198187                                netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
r26659r26660
273262   if (p > 0)
274263   {
275264       pstring dname = ret;
276       netlist_device_t *dev = m_devices.find(dname.substr(0,p));
265       netlist_device_t *dev = netlist().m_devices.find(dname.substr(0,p));
277266       if (dev == NULL)
278267           netlist().xfatalerror("Device for %s not found\n", name.cstr());
279268       int c = atoi(ret.substr(p+2,ret.len()-p-3));
r26659r26660
285274       } while (temp != "");
286275   }
287276
288    //printf("%s==>%s\n", name.cstr(), ret.cstr());
277   NL_VERBOSE_OUT(("%s==>%s\n", name.cstr(), ret.cstr()));
289278   return ret;
290279}
291280
r26659r26660
367356    }
368357    else if (out.isFamily(netlist_terminal_t::LOGIC) && in.isFamily(netlist_terminal_t::ANALOG))
369358    {
370        //printf("here 1\n");
371359        nld_d_to_a_proxy *proxy = new nld_d_to_a_proxy(out);
372360        pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt);
373361        m_proxy_cnt++;
r26659r26660
490478    if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::INPUT))
491479    {
492480        if (t2.has_net())
493            mame_printf_warning("Input %s already connected\n", t2.name().cstr());
481            NL_VERBOSE_OUT(("Input %s already connected\n", t2.name().cstr()));
494482        connect_input_output(dynamic_cast<netlist_input_t &>(t2), dynamic_cast<netlist_output_t &>(t1));
495483    }
496484    else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::OUTPUT))
497485    {
498486        if (t1.has_net())
499            mame_printf_warning("Input %s already connected\n", t1.name().cstr());
487            NL_VERBOSE_OUT(("Input %s already connected\n", t1.name().cstr()));
500488        connect_input_output(dynamic_cast<netlist_input_t &>(t1), dynamic_cast<netlist_output_t &>(t2));
501489    }
502490    else if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::TERMINAL))
r26659r26660
523511        netlist().xfatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr());
524512}
525513
526void netlist_setup_t::resolve_inputs(void)
514void netlist_setup_t::resolve_inputs()
527515{
528516
529517    NL_VERBOSE_OUT(("Resolving ...\n"));
r26659r26660
551539
552540}
553541
554void netlist_setup_t::start_devices(void)
542void netlist_setup_t::start_devices()
555543{
556544
557545    if (getenv("NL_LOGS"))
r26659r26660
560548        nl_util::pstring_list ll = nl_util::split(getenv("NL_LOGS"), ":");
561549        for (int i=0; i < ll.count(); i++)
562550        {
563            printf("%d: <%s>\n",i, ll[i].cstr());
551            NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr()));
564552            netlist_device_t *nc = factory().new_device_by_classname("nld_log", *this);
565            pstring name = "log" + ll[i];
553            pstring name = "log_" + ll[i];
566554            register_dev(nc, name);
567555            register_link(name + ".I", ll[i]);
568556        }
r26659r26660
571559
572560    NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n"));
573561    /* find the main clock ... */
574    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
562    for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry))
575563    {
576564        netlist_device_t *dev = entry->object();
577565        if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL)
r26659r26660
585573    }
586574
587575    NL_VERBOSE_OUT(("Initializing devices ...\n"));
588    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
576    for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry))
589577    {
590578        netlist_device_t *dev = entry->object();
591579        dev->init(netlist(), entry->tag().cstr());
592580    }
593581}
594582
595void netlist_setup_t::step_devices_once(void)
583void netlist_setup_t::parse(const char *buf)
596584{
597   /* make sure params are set now .. */
598   for (tagmap_param_t::entry_t *entry = m_params.first(); entry != NULL; entry = m_params.next(entry))
599   {
600      entry->object()->netdev().update_param();
601   }
602
603   for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
604   {
605      netlist_device_t *dev = entry->object();
606      dev->update_dev();
607   }
608}
609
610
611void netlist_setup_t::parse(char *buf)
612{
613585   netlist_parser parser(*this);
614586   parser.parse(buf);
615587}
trunk/src/emu/netlist/nl_parser.h
r26659r26660
1717   netlist_parser(netlist_setup_t &setup)
1818   : m_setup(setup) {}
1919
20   void parse(char *buf);
20   void parse(const char *buf);
2121   void net_alias();
2222   void netdev_param();
2323    void net_c();
r26659r26660
3838   void ungetc();
3939   bool eof() { return *m_px == 0; }
4040
41   char * m_px;
41   const char * m_px;
4242   netlist_setup_t &m_setup;
4343};
4444
trunk/src/emu/netlist/pstring.h
r26659r26660
122122    inline bool equals(const pstring &string) { return (pcmp(string.cstr(), m_ptr->str()) == 0); }
123123    inline bool iequals(const pstring &string) { return (pcmpi(string.cstr(), m_ptr->str()) == 0); }
124124
125    int cmp(const pstring &string) const { return pcmp(string.cstr()); }
126    int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); }
125    inline int cmp(const pstring &string) const { return pcmp(string.cstr()); }
126    inline int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); }
127127
128    int find(const char *search, int start = 0) const
128    inline int find(const char *search, int start = 0) const
129129    {
130130        int alen = len();
131131        const char *result = strstr(cstr() + MIN(start, alen), search);
r26659r26660
134134
135135    // various
136136
137    bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); }
138    bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); }
137    inline bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); }
138    inline bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); }
139139
140140    // these return nstring ...
141    pstring cat(const pstring &s) const { return *this + s; }
142    pstring cat(const char *s) const { return *this + s; }
141    inline pstring cat(const pstring &s) const { return *this + s; }
142    inline pstring cat(const char *s) const { return *this + s; }
143143
144144    pstring substr(unsigned int start, int count = -1) const ;
145145
146    pstring left(unsigned int count) const { return substr(0, count); }
147    pstring right(unsigned int count) const  { return substr(len() - count, count); }
146    inline pstring left(unsigned int count) const { return substr(0, count); }
147    inline pstring right(unsigned int count) const  { return substr(len() - count, count); }
148
148149    pstring ucase() const;
149150
151    // conversions
152
153    double as_double(bool *error = NULL) const;
154
155    long as_long(bool *error = NULL) const;
156
150157    // printf using string as format ...
151158
152159    pstring vprintf(va_list args) const;
trunk/src/emu/video/fixfreq.c
r26659r26660
222222void fixedfreq_device::update_vid(double newval, attotime cur_time)
223223{
224224   bitmap_rgb32 *bm = m_bitmap[m_cur_bm];
225   const int has_fields = (m_fieldcount > 1) ? 1: 0;
225226
226227   int pixels = round((cur_time - m_line_time).as_double() / m_clock_period.as_double());
227228   attotime time = (cur_time - m_last_time);
r26659r26660
245246
246247      while (0 && pixels >= m_htotal)
247248      {
248         bm->plot_box(m_last_x, m_last_y + m_sig_field, m_htotal - 1 - m_last_x, 1, col);
249         bm->plot_box(m_last_x, m_last_y + m_sig_field * has_fields, m_htotal - 1 - m_last_x, 1, col);
249250         pixels -= m_htotal;
250251         m_last_x = 0;
251252      }
252      bm->plot_box(m_last_x, m_last_y + m_sig_field, pixels - m_last_x, 1, col);
253      bm->plot_box(m_last_x, m_last_y + m_sig_field * has_fields, pixels - m_last_x, 1, col);
253254      m_last_x = pixels;
254255   }
255256   if (sync & 1)
r26659r26660
267268
268269   if (sync & 1)
269270   {
270      m_last_y = 0;
271      m_last_y = m_vbackporch - m_vsync; // 6; // FIXME: needed for pong - need to be able to adjust screen parameters
271272      // toggle bitmap
272273      m_cur_bm ^= 1;
273274      update_screen_parameters(cur_time - m_last_vsync_time);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team