Pong update:

- based on feedback from IRC hopefully fixed issues like "jumping"
- adjusted VR1 and VR2 to 50%
- disabled all printf output.
This commit is contained in:
Couriersud 2013-12-19 11:58:05 +00:00
parent 786ca09655
commit 614b76c0fe
19 changed files with 355 additions and 117 deletions

1
.gitattributes vendored
View File

@ -9140,6 +9140,7 @@ src/tools/chdman.c svneol=native#text/plain
src/tools/jedutil.c svneol=native#text/plain
src/tools/ldresample.c svneol=native#text/plain
src/tools/ldverify.c svneol=native#text/plain
src/tools/nltool.c svneol=native#text/plain
src/tools/pngcmp.c svneol=native#text/plain
src/tools/regrep.c svneol=native#text/plain
src/tools/romcmp.c svneol=native#text/plain

View File

@ -50,6 +50,8 @@
#include "netlist/nl_setup.h"
#include "netlist/devices/net_lib.h"
#define LOG_DEV_CALLS(x) do { } while (0);
// ----------------------------------------------------------------------------------------
// netlist_mame_device
// ----------------------------------------------------------------------------------------
@ -71,14 +73,18 @@ void netlist_mame_device::static_set_constructor(device_t &device, void (*setup_
{
netlist_mame_device &netlist = downcast<netlist_mame_device &>(device);
netlist.m_setup_func = setup_func;
LOG_DEV_CALLS(("static_set_constructor\n"));
}
void netlist_mame_device::device_config_complete()
{
LOG_DEV_CALLS(("device_config_complete\n"));
}
void netlist_mame_device::device_start()
{
LOG_DEV_CALLS(("device_start\n"));
m_netlist = global_alloc_clear(netlist_mame_t(*this));
m_netlist->set_clock_freq(this->clock());
@ -91,16 +97,15 @@ void netlist_mame_device::device_start()
m_setup_func(*m_setup);
m_setup->start_devices();
bool allok = true;
for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods))
allok &= ods->object()->OnDeviceStart();
if (!allok)
m_netlist->xfatalerror("required elements not found\n");
m_setup->resolve_inputs();
bool allok = true;
for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods))
allok &= ods->object()->OnDeviceStart();
if (!allok)
m_netlist->xfatalerror("required elements not found\n");
save_state();
/* TODO: we have to save the round robin queue as well */
@ -110,12 +115,13 @@ void netlist_mame_device::device_start()
void netlist_mame_device::device_reset()
{
LOG_DEV_CALLS(("device_reset\n"));
m_netlist->reset();
m_setup->step_devices_once();
}
void netlist_mame_device::device_stop()
{
LOG_DEV_CALLS(("device_stop\n"));
m_setup->print_stats();
global_free(m_setup);

View File

@ -8,7 +8,6 @@
ATTR_HOT inline void NETLIB_NAME(7474sub)::newstate(const UINT8 state)
{
static const netlist_time delay[2] = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(40) };
//printf("%s %d %d %d\n", "7474", state, Q.Q(), QQ.Q());
OUTLOGIC(m_Q, state, delay[state]);
OUTLOGIC(m_QQ, !state, delay[!state]);
}

View File

@ -44,7 +44,6 @@ NETLIB_UPDATE(7493)
if (r)
{
//printf("%s reset\n", name());
A.m_reset = B.m_reset = C.m_reset = D.m_reset = 1;
A.m_I.inactivate();
B.m_I.inactivate();
@ -58,6 +57,5 @@ NETLIB_UPDATE(7493)
A.m_reset = B.m_reset = C.m_reset = D.m_reset = 0;
A.m_I.activate_hl();
B.m_I.activate_hl();
//printf("%s enable\n", name());
}
}

View File

@ -10,6 +10,8 @@
// netlist_matrix_solver
// ----------------------------------------------------------------------------------------
#define SOLVER_VERBOSE_OUT(x) do {} while (0)
//#define SOLVER_VERBOSE_OUT(x) printf x
ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &aowner)
{
@ -264,7 +266,7 @@ NETLIB_FUNC_VOID(solver, post_start, ())
}
}
printf("Scanning net groups ...\n");
SOLVER_VERBOSE_OUT(("Scanning net groups ...\n"));
// determine net groups
for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn))
{
@ -276,7 +278,7 @@ NETLIB_FUNC_VOID(solver, post_start, ())
}
// setup the solvers
printf("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count());
SOLVER_VERBOSE_OUT(("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count()));
for (int i = 0; i <= cur_group; i++)
{
netlist_matrix_solver_t *ms = new netlist_matrix_solver_t();
@ -284,8 +286,8 @@ NETLIB_FUNC_VOID(solver, post_start, ())
ms->m_convergence_factor = m_convergence.Value();
ms->setup(groups[i], *this);
m_mat_solvers.add(ms);
printf("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr());
printf(" has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic");
SOLVER_VERBOSE_OUT(("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr()));
SOLVER_VERBOSE_OUT((" has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic"));
}
}

View File

@ -227,7 +227,7 @@ NETLIB_UPDATE_PARAM(QBJT_switch<_type>)
if (m_gB < NETLIST_GMIN)
m_gB = NETLIST_GMIN;
m_gC = BF * m_gB; // very rough estimate
printf("%f %f \n", m_V, m_gB);
//printf("%f %f \n", m_V, m_gB);
m_RB.set(NETLIST_GMIN, 0.0, 0.0);
m_RC.set(NETLIST_GMIN, 0.0, 0.0);
}

View File

@ -312,7 +312,6 @@ public:
double vE = INPANALOG(m_EV);
double vB = INPANALOG(m_BV);
//printf("diff %f %f = %f - %f\n", vB - vE, vB, vE, m_RB.m_N.m_g);
int new_state = (vB - vE > m_V ) ? 1 : 0;
if (m_state_on ^ new_state)
{

View File

@ -69,8 +69,19 @@ netlist_base_t::netlist_base_t()
{
}
template <class T>
static void tagmap_free_entries(T &tm)
{
for (typename T::entry_t *entry = tm.first(); entry != NULL; entry = tm.next(entry))
{
delete entry->object();
}
tm.reset();
}
netlist_base_t::~netlist_base_t()
{
tagmap_free_entries<tagmap_devices_t>(m_devices);
pstring::resetmem();
}
@ -92,8 +103,20 @@ ATTR_COLD void netlist_base_t::reset()
if (m_mainclock != NULL)
m_mainclock->m_Q.net().set_time(netlist_time::zero);
}
// FIXME: some const devices rely on this
/* make sure params are set now .. */
for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
{
entry->object()->update_param();
}
// Step all devices once !
for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
{
netlist_device_t *dev = entry->object();
dev->update_dev();
}
}
void netlist_base_t::set_clock_freq(UINT64 clockfreq)
{
@ -294,8 +317,6 @@ ATTR_COLD void netlist_device_t::register_subalias(const pstring &name, const ne
{
pstring alias = this->name() + "." + name;
//printf("alias: %s\n", alias.cstr());
setup().register_alias(alias, term.name());
if (term.isType(netlist_terminal_t::INPUT))

View File

@ -814,7 +814,7 @@ public:
ATTR_HOT virtual void inc_active() { }
ATTR_HOT virtual void dec_active() { /*printf("DeActivate %s\n", m_name);*/ }
ATTR_HOT virtual void dec_active() { }
ATTR_HOT virtual void step_time(const double st) { }
ATTR_HOT virtual void update_terminals() { }
@ -890,6 +890,8 @@ private:
// netlist_base_t
// ----------------------------------------------------------------------------------------
typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t;
class netlist_base_t
{
NETLIST_PREVENT_COPYING(netlist_base_t)
@ -914,21 +916,19 @@ public:
ATTR_HOT inline const netlist_time &time() const { return m_time_ps; }
ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev);
ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev);
ATTR_COLD void set_solver_dev(NETLIB_NAME(solver) *dev);
ATTR_COLD void set_setup(netlist_setup_t *asetup) { m_setup = asetup; }
ATTR_COLD void set_clock_freq(UINT64 clockfreq);
ATTR_COLD netlist_setup_t &setup() { return *m_setup; }
ATTR_COLD void set_setup(netlist_setup_t *asetup)
{
m_setup = asetup;
}
ATTR_COLD void reset();
ATTR_COLD void xfatalerror(const char *format, ...) const;
tagmap_devices_t m_devices;
protected:
// any derived netlist must override this ...

View File

@ -7,20 +7,18 @@
#include "nl_parser.h"
#undef NL_VERBOSE_OUT
#define NL_VERBOSE_OUT(x) printf x
//#undef NL_VERBOSE_OUT
//#define NL_VERBOSE_OUT(x) printf x
// ----------------------------------------------------------------------------------------
// A netlist parser
// ----------------------------------------------------------------------------------------
void netlist_parser::parse(char *buf)
void netlist_parser::parse(const char *buf)
{
char c;
m_px = buf;
c = getc();
while (c)
while (!eof())
{
pstring n;
skipws();
@ -45,7 +43,6 @@ void netlist_parser::parse(char *buf)
netdev_const(n);
else
netdev_device(n);
c = getc();
}
}
@ -83,7 +80,6 @@ void netlist_parser::netdev_param()
val = eval_param();
NL_VERBOSE_OUT(("Parser: Param: %s %f\n", param.cstr(), val));
m_setup.register_param(param, val);
//m_setup.find_param(param).initial(val);
check_char(')');
}
@ -103,7 +99,6 @@ void netlist_parser::netdev_const(const pstring &dev_name)
paramfq = name + ".CONST";
NL_VERBOSE_OUT(("Parser: Const: %s %f\n", name.cstr(), val));
check_char(')');
//m_setup.find_param(paramfq).initial(val);
m_setup.register_param(paramfq, val);
}
@ -273,31 +268,28 @@ double netlist_parser::eval_param()
static double facs[6] = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12};
int i;
int f=0;
char *e;
bool e;
double ret;
pstring s = getname2(')',',');
printf("Got %s\n", s.cstr());
for (i=1; i<6;i++)
if (strncmp(s.cstr(), macs[i], strlen(macs[i])) == 0)
f = i;
ret = strtod(s.substr(strlen(macs[f])).cstr(), &e);
if ((f>0) && (*e != 0))
ret = s.substr(strlen(macs[f])).as_double(&e);
if ((f>0) && e)
m_setup.netlist().xfatalerror("Parser: Error with parameter ...\n");
if (f>0)
check_char(')');
//if (f == 0)
// ungetc();
//if (f>0)
// e++;
//m_p = e;
return ret * facs[f];
}
unsigned char netlist_parser::getc()
{
return *(m_px++);
if (*m_px)
return *(m_px++);
else
return *m_px;
}
void netlist_parser::ungetc()

View File

@ -17,7 +17,7 @@ public:
netlist_parser(netlist_setup_t &setup)
: m_setup(setup) {}
void parse(char *buf);
void parse(const char *buf);
void net_alias();
void netdev_param();
void net_c();
@ -38,7 +38,7 @@ private:
void ungetc();
bool eof() { return *m_px == 0; }
char * m_px;
const char * m_px;
netlist_setup_t &m_setup;
};

View File

@ -37,21 +37,9 @@ netlist_setup_t::netlist_setup_t(netlist_base_t &netlist)
NETLIST_NAME(base)(*this);
}
template <class T>
static void tagmap_free_entries(T &tm)
{
for (typename T::entry_t *entry = tm.first(); entry != NULL; entry = tm.next(entry))
{
delete entry->object();
}
tm.reset();
}
netlist_setup_t::~netlist_setup_t()
{
tagmap_free_entries<tagmap_devices_t>(m_devices);
//tagmap_free_entries<tagmap_link_t>(m_links);
//tagmap_free_entries<tagmap_nstring_t>(m_alias);
m_links.reset();
m_alias.reset();
m_params.reset();
@ -63,9 +51,10 @@ netlist_setup_t::~netlist_setup_t()
pstring::resetmem();
}
// FIXME: Move to netlist ...
netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const pstring &name)
{
if (!(m_devices.add(name, dev, false)==TMERR_NONE))
if (!(netlist().m_devices.add(name, dev, false)==TMERR_NONE))
netlist().xfatalerror("Error adding %s to device list\n", name.cstr());
return dev;
}
@ -89,7 +78,7 @@ static void remove_start_with(T &hm, pstring &sw)
void netlist_setup_t::remove_dev(const pstring &name)
{
netlist_device_t *dev = m_devices.find(name);
netlist_device_t *dev = netlist().m_devices.find(name);
pstring temp = name + ".";
if (dev == NULL)
netlist().xfatalerror("Device %s does not exist\n", name.cstr());
@ -106,7 +95,7 @@ void netlist_setup_t::remove_dev(const pstring &name)
m_links.remove(p->object());
p = n;
}
m_devices.remove(name);
netlist().m_devices.remove(name);
}
void netlist_setup_t::register_model(const pstring &model)
@ -182,7 +171,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
{
case netlist_param_t::DOUBLE:
{
//printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()));
double vald = 0;
if (sscanf(val.cstr(), "%lf", &vald) != 1)
netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
@ -192,7 +181,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device
case netlist_param_t::INTEGER:
case netlist_param_t::LOGIC:
{
//printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()));
int vald = 0;
if (sscanf(val.cstr(), "%d", &vald) != 1)
netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr());
@ -273,7 +262,7 @@ const pstring netlist_setup_t::resolve_alias(const pstring &name) const
if (p > 0)
{
pstring dname = ret;
netlist_device_t *dev = m_devices.find(dname.substr(0,p));
netlist_device_t *dev = netlist().m_devices.find(dname.substr(0,p));
if (dev == NULL)
netlist().xfatalerror("Device for %s not found\n", name.cstr());
int c = atoi(ret.substr(p+2,ret.len()-p-3));
@ -285,7 +274,7 @@ const pstring netlist_setup_t::resolve_alias(const pstring &name) const
} while (temp != "");
}
//printf("%s==>%s\n", name.cstr(), ret.cstr());
NL_VERBOSE_OUT(("%s==>%s\n", name.cstr(), ret.cstr()));
return ret;
}
@ -367,7 +356,6 @@ void netlist_setup_t::connect_input_output(netlist_input_t &in, netlist_output_t
}
else if (out.isFamily(netlist_terminal_t::LOGIC) && in.isFamily(netlist_terminal_t::ANALOG))
{
//printf("here 1\n");
nld_d_to_a_proxy *proxy = new nld_d_to_a_proxy(out);
pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt);
m_proxy_cnt++;
@ -490,13 +478,13 @@ void netlist_setup_t::connect(netlist_core_terminal_t &t1, netlist_core_terminal
if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::INPUT))
{
if (t2.has_net())
mame_printf_warning("Input %s already connected\n", t2.name().cstr());
NL_VERBOSE_OUT(("Input %s already connected\n", t2.name().cstr()));
connect_input_output(dynamic_cast<netlist_input_t &>(t2), dynamic_cast<netlist_output_t &>(t1));
}
else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::OUTPUT))
{
if (t1.has_net())
mame_printf_warning("Input %s already connected\n", t1.name().cstr());
NL_VERBOSE_OUT(("Input %s already connected\n", t1.name().cstr()));
connect_input_output(dynamic_cast<netlist_input_t &>(t1), dynamic_cast<netlist_output_t &>(t2));
}
else if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::TERMINAL))
@ -523,7 +511,7 @@ void netlist_setup_t::connect(netlist_core_terminal_t &t1, netlist_core_terminal
netlist().xfatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr());
}
void netlist_setup_t::resolve_inputs(void)
void netlist_setup_t::resolve_inputs()
{
NL_VERBOSE_OUT(("Resolving ...\n"));
@ -551,7 +539,7 @@ void netlist_setup_t::resolve_inputs(void)
}
void netlist_setup_t::start_devices(void)
void netlist_setup_t::start_devices()
{
if (getenv("NL_LOGS"))
@ -560,9 +548,9 @@ void netlist_setup_t::start_devices(void)
nl_util::pstring_list ll = nl_util::split(getenv("NL_LOGS"), ":");
for (int i=0; i < ll.count(); i++)
{
printf("%d: <%s>\n",i, ll[i].cstr());
NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr()));
netlist_device_t *nc = factory().new_device_by_classname("nld_log", *this);
pstring name = "log" + ll[i];
pstring name = "log_" + ll[i];
register_dev(nc, name);
register_link(name + ".I", ll[i]);
}
@ -571,7 +559,7 @@ void netlist_setup_t::start_devices(void)
NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n"));
/* find the main clock ... */
for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry))
{
netlist_device_t *dev = entry->object();
if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL)
@ -585,30 +573,14 @@ void netlist_setup_t::start_devices(void)
}
NL_VERBOSE_OUT(("Initializing devices ...\n"));
for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry))
{
netlist_device_t *dev = entry->object();
dev->init(netlist(), entry->tag().cstr());
}
}
void netlist_setup_t::step_devices_once(void)
{
/* make sure params are set now .. */
for (tagmap_param_t::entry_t *entry = m_params.first(); entry != NULL; entry = m_params.next(entry))
{
entry->object()->netdev().update_param();
}
for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
{
netlist_device_t *dev = entry->object();
dev->update_dev();
}
}
void netlist_setup_t::parse(char *buf)
void netlist_setup_t::parse(const char *buf)
{
netlist_parser parser(*this);
parser.parse(buf);

View File

@ -94,7 +94,6 @@ public:
link_t &operator=(const link_t &rhs) { e1 = rhs.e1; e2 = rhs.e2; return *this; }
};
typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t;
typedef tagmap_t<pstring, 393> tagmap_nstring_t;
typedef tagmap_t<netlist_param_t *, 393> tagmap_param_t;
typedef tagmap_t<netlist_core_terminal_t *, 393> tagmap_terminal_t;
@ -124,11 +123,10 @@ public:
netlist_param_t *find_param(const pstring &param_in, bool required = true);
void parse(char *buf);
void parse(const char *buf);
void start_devices(void);
void resolve_inputs(void);
void step_devices_once(void);
void start_devices();
void resolve_inputs();
/* not ideal, but needed for save_state */
tagmap_terminal_t m_terminals;
@ -141,7 +139,6 @@ private:
netlist_base_t &m_netlist;
tagmap_devices_t m_devices;
tagmap_nstring_t m_alias;
tagmap_param_t m_params;
tagmap_link_t m_links;

View File

@ -108,6 +108,37 @@ int pstring::pcmpi(const char *lhs, const char *rhs, int count) const
return 1;
}
double pstring::as_double(bool *error) const
{
double ret;
char *e = NULL;
if (error != NULL)
*error = false;
ret = strtod(cstr(), &e);
if (*e != 0)
if (error != NULL)
*error = true;
return ret;
}
long pstring::as_long(bool *error) const
{
double ret;
char *e = NULL;
if (error != NULL)
*error = false;
if (startsWith("0x"))
ret = strtol(&(cstr()[2]), &e, 16);
else
ret = strtol(cstr(), &e, 10);
if (*e != 0)
if (error != NULL)
*error = true;
return ret;
}
pstring pstring::vprintf(va_list args) const
{
// sprintf into the temporary buffer

View File

@ -122,10 +122,10 @@ public:
inline bool equals(const pstring &string) { return (pcmp(string.cstr(), m_ptr->str()) == 0); }
inline bool iequals(const pstring &string) { return (pcmpi(string.cstr(), m_ptr->str()) == 0); }
int cmp(const pstring &string) const { return pcmp(string.cstr()); }
int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); }
inline int cmp(const pstring &string) const { return pcmp(string.cstr()); }
inline int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); }
int find(const char *search, int start = 0) const
inline int find(const char *search, int start = 0) const
{
int alen = len();
const char *result = strstr(cstr() + MIN(start, alen), search);
@ -134,19 +134,26 @@ public:
// various
bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); }
bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); }
inline bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); }
inline bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); }
// these return nstring ...
pstring cat(const pstring &s) const { return *this + s; }
pstring cat(const char *s) const { return *this + s; }
inline pstring cat(const pstring &s) const { return *this + s; }
inline pstring cat(const char *s) const { return *this + s; }
pstring substr(unsigned int start, int count = -1) const ;
pstring left(unsigned int count) const { return substr(0, count); }
pstring right(unsigned int count) const { return substr(len() - count, count); }
inline pstring left(unsigned int count) const { return substr(0, count); }
inline pstring right(unsigned int count) const { return substr(len() - count, count); }
pstring ucase() const;
// conversions
double as_double(bool *error = NULL) const;
long as_long(bool *error = NULL) const;
// printf using string as format ...
pstring vprintf(va_list args) const;

View File

@ -222,6 +222,7 @@ UINT32 fixedfreq_device::screen_update(screen_device &screen, bitmap_rgb32 &bitm
void fixedfreq_device::update_vid(double newval, attotime cur_time)
{
bitmap_rgb32 *bm = m_bitmap[m_cur_bm];
const int has_fields = (m_fieldcount > 1) ? 1: 0;
int pixels = round((cur_time - m_line_time).as_double() / m_clock_period.as_double());
attotime time = (cur_time - m_last_time);
@ -245,11 +246,11 @@ void fixedfreq_device::update_vid(double newval, attotime cur_time)
while (0 && pixels >= m_htotal)
{
bm->plot_box(m_last_x, m_last_y + m_sig_field, m_htotal - 1 - m_last_x, 1, col);
bm->plot_box(m_last_x, m_last_y + m_sig_field * has_fields, m_htotal - 1 - m_last_x, 1, col);
pixels -= m_htotal;
m_last_x = 0;
}
bm->plot_box(m_last_x, m_last_y + m_sig_field, pixels - m_last_x, 1, col);
bm->plot_box(m_last_x, m_last_y + m_sig_field * has_fields, pixels - m_last_x, 1, col);
m_last_x = pixels;
}
if (sync & 1)
@ -267,7 +268,7 @@ void fixedfreq_device::update_vid(double newval, attotime cur_time)
if (sync & 1)
{
m_last_y = 0;
m_last_y = m_vbackporch - m_vsync; // 6; // FIXME: needed for pong - need to be able to adjust screen parameters
// toggle bitmap
m_cur_bm ^= 1;
update_screen_parameters(cur_time - m_last_vsync_time);

View File

@ -58,8 +58,8 @@ TODO:
fixedfreq_interface fixedfreq_mode_pong = {
MASTER_CLOCK,
H_TOTAL-67,H_TOTAL-40,H_TOTAL-8,H_TOTAL,
V_TOTAL-22,V_TOTAL-19,V_TOTAL-16,V_TOTAL,
1, /* interlaced */
V_TOTAL-22,V_TOTAL-19,V_TOTAL-12,V_TOTAL,
1, /* non-interlaced */
0.32
};
@ -67,7 +67,7 @@ fixedfreq_interface fixedfreq_mode_pongX2 = {
MASTER_CLOCK * 2,
(H_TOTAL-67) * 2, (H_TOTAL-40) * 2, (H_TOTAL-8) * 2, (H_TOTAL) * 2,
V_TOTAL-22,V_TOTAL-19,V_TOTAL-16,V_TOTAL,
1, /* interlaced */
1, /* non-interlaced */
0.32
};
@ -933,9 +933,9 @@ static INPUT_PORTS_START( pong )
PORT_DIPSETTING( 0x06, "15" )
PORT_START("VR1")
PORT_ADJUSTER( 63, "VR1 - 50k, Paddle 1 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR1)
PORT_ADJUSTER( 50, "VR1 - 50k, Paddle 1 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR1)
PORT_START("VR2")
PORT_ADJUSTER( 63, "VR2 - 50k, Paddle 2 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR2)
PORT_ADJUSTER( 50, "VR2 - 50k, Paddle 2 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR2)
//PORT_START("GATESPEED")
//PORT_ADJUSTER( 100, "Logic Gate Delay" ) PORT_MINMAX(10, 200) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_GATEDELAY)

200
src/tools/nltool.c Normal file
View File

@ -0,0 +1,200 @@
/***************************************************************************
nltool.c
Simple tool to debug netlists outside MAME.
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "astring.h"
#include "corefile.h"
#include "corestr.h"
#include "sha1.h"
#include "netlist/nl_base.h"
#include "netlist/nl_setup.h"
#include "options.h"
/***************************************************************************
MAME COMPATIBILITY ...
***************************************************************************/
#if 0
void mame_printf_warning(const char *format, ...)
{
va_list argptr;
/* do the output */
va_start(argptr, format);
vprintf(format, argptr);
va_end(argptr);
}
#endif
void *malloc_file_line(size_t size, const char *file, int line)
{
// allocate the memory and fail if we can't
void *ret = osd_malloc(size);
memset(ret, 0, size);
return ret;
}
void *malloc_array_file_line(size_t size, const char *file, int line)
{
// allocate the memory and fail if we can't
void *ret = osd_malloc_array(size);
memset(ret, 0, size);
return ret;
}
void free_file_line( void *memory, const char *file, int line )
{
osd_free( memory );
}
struct options_entry oplist[] =
{
{ "time_to_run;ttr", "1.0", OPTION_FLOAT, "time to run the emulation (seconds)" },
{ "f", "-", OPTION_STRING, "file to process (default is stdin)" },
{ "help;h", "0", OPTION_BOOLEAN, "display help" },
{ NULL }
};
/***************************************************************************
CORE IMPLEMENTATION
***************************************************************************/
const char *filetobuf(pstring fname)
{
static pstring pbuf = "";
if (fname == "-")
{
char lbuf[1024];
while (!feof(stdin))
{
fgets(lbuf, 1024, stdin);
pbuf += lbuf;
}
printf("%d\n",*(pbuf.right(1).cstr()+1));
return pbuf.cstr();
}
else
{
FILE *f;
f = fopen(fname, "rb");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
char *buf = (char *) malloc(fsize);
fread(buf, fsize, 1, f);
buf[fsize] = 0;
fclose(f);
return buf;
}
}
class netlist_tool_t : public netlist_base_t
{
public:
netlist_tool_t()
: netlist_base_t(), m_setup(NULL)
{
}
virtual ~netlist_tool_t() { };
void read_netlist(const char *buffer)
{
m_setup = new netlist_setup_t(*this);
this->set_clock_freq(NETLIST_CLOCK);
// register additional devices
//m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback");
// read the netlist ...
//m_setup_func(*m_setup);
m_setup->parse(buffer);
// start devices
m_setup->start_devices();
m_setup->resolve_inputs();
// reset
this->reset();
}
protected:
void vfatalerror(const char *format, va_list ap) const
{
vprintf(format, ap);
throw;
}
private:
netlist_setup_t *m_setup;
};
void usage(core_options &opts)
{
astring buffer;
fprintf(stderr,
"Usage:\n"
" nltool -help\n"
" nltool [options]\n"
"\n"
"Where:\n"
);
fprintf(stderr, "%s\n", opts.output_help(buffer));
}
/*-------------------------------------------------
main - primary entry point
-------------------------------------------------*/
int main(int argc, char *argv[])
{
//int result;
netlist_tool_t nt;
core_options opts(oplist);
astring aerror("");
osd_ticks_t t = osd_ticks();
fprintf(stderr, "%s", "WARNING: This is Work In Progress! - It may fail anytime\n");
if (!opts.parse_command_line(argc, argv, OPTION_PRIORITY_DEFAULT, aerror))
{
fprintf(stderr, "%s\n", aerror.cstr());
usage(opts);
return 1;
}
if (opts.bool_value("h"))
{
usage(opts);
return 1;
}
nt.read_netlist(filetobuf(opts.value("f")));
double ttr = opts.float_value("ttr");
INT64 tt = ttr * NETLIST_CLOCK;
printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() );
printf("runnning ...\n");
t = osd_ticks();
while (tt>0)
{
INT32 tr = MIN(tt, NETLIST_CLOCK / 10);
tt -= tr;
nt.process_queue(tr);
}
double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second();
printf("%f seconds emulation took %f real time ==> %5.2f%%\n", ttr, emutime, ttr/emutime*100.0);
}

View File

@ -62,6 +62,7 @@ TOOLS += \
src2html$(EXE) \
split$(EXE) \
pngcmp$(EXE) \
nltool$(EXE) \
@ -207,3 +208,14 @@ pngcmp$(EXE): $(PNGCMPOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB)
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@
#-------------------------------------------------
# nltool
#-------------------------------------------------
NLTOOLOBJS = \
$(TOOLSOBJ)/nltool.o \
$(NETLISTOBJS) \
nltool$(EXE): $(NLTOOLOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB) $(EXPAT)
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@