summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/netlist/devices/nld_log.c
blob: f6061cc3aab0c2108bb3d900f8aee76788bff003 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
 * nld_log.c
 *
 */

#include <cstdio>

#include "nld_log.h"
//#include "sound/wavwrite.h"

NETLIB_NAMESPACE_DEVICES_START()

//FIXME: what to do with save states?

NETLIB_START(log)
{
	register_input("I", m_I);

	pstring filename = pstring::sprintf("%s.log", name().cstr());
	m_file = fopen(filename, "w");
}

NETLIB_RESET(log)
{
}

NETLIB_UPDATE(log)
{
	std::fprintf(static_cast<FILE *>(m_file), "%20.9e %e\n", netlist().time().as_double(), (nl_double) INPANALOG(m_I));
}

NETLIB_NAME(log)::~NETLIB_NAME(log)()
{
	std::fclose(static_cast<FILE *>(m_file));
}

NETLIB_START(logD)
{
	NETLIB_NAME(log)::start();
	register_input("I2", m_I2);
}

NETLIB_RESET(logD)
{
}

NETLIB_UPDATE(logD)
{
	std::fprintf(static_cast<FILE *>(m_file), "%e %e\n", netlist().time().as_double(), (nl_double) (INPANALOG(m_I) - INPANALOG(m_I2)));
}

// FIXME: Implement wav later, this must be clock triggered device where the input to be written
//        is on a subdevice ...
#if 0
NETLIB_START(wav)
{
	register_input("I", m_I);

	pstring filename = "netlist_" + name() + ".wav";
	m_file = wav_open(filename, sample_rate(), active_inputs()/2)
}

NETLIB_UPDATE(wav)
{
	fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I));
}

NETLIB_NAME(log)::~NETLIB_NAME(wav)()
{
	fclose(m_file);
}
#endif

NETLIB_NAMESPACE_DEVICES_END()