summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/e05a03.cpp
blob: 7e887714884bb1893989d5e1fff6026b7637e871 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// license:GPL-2.0+
// copyright-holders:Dirk Best
/***************************************************************************

    E05A03 Gate Array (used in the Epson LX-800)

***************************************************************************/

#include "emu.h"
#include "e05a03.h"


/*****************************************************************************
    DEVICE INTERFACE
*****************************************************************************/

const device_type E05A03 = &device_creator<e05a03_device>;

e05a03_device::e05a03_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: device_t(mconfig, E05A03, "E05A03", tag, owner, clock, "e05a03", __FILE__),
	m_write_nlq_lp(*this),
	m_write_pe_lp(*this),
	m_write_reso(*this),
	m_write_pe(*this),
	m_read_data(*this),
	m_shift(0),
	m_busy_leading(0),
	m_busy_software(0),
	m_nlqlp(0),
	m_cndlp(0),
	#if 0
	m_pe(0),
	m_pelp(0),
	#endif
	m_printhead(0),
	m_pf_motor(0),
	m_cr_motor(0)
{
}

//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void e05a03_device::device_start()
{
	/* resolve callbacks */
	m_write_nlq_lp.resolve_safe();
	m_write_pe_lp.resolve_safe();
	m_write_reso.resolve_safe();
	m_write_pe.resolve_safe();
	m_read_data.resolve_safe(0);

	/* register for state saving */
	save_item(NAME(m_shift));
	save_item(NAME(m_busy_leading));
	save_item(NAME(m_busy_software));
	save_item(NAME(m_nlqlp));
	save_item(NAME(m_cndlp));
	#if 0
	save_item(NAME(m_pe));
	save_item(NAME(m_pelp));
	#endif
	save_item(NAME(m_printhead));
	save_item(NAME(m_pf_motor));
	save_item(NAME(m_cr_motor));
}

//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void e05a03_device::device_reset()
{
	m_printhead = 0x00;
	m_pf_motor = 0x00;
	m_cr_motor = 0x0f;

	m_write_pe(0);
	m_write_pe_lp(1);

	m_busy_software = 1;
	m_nlqlp = 1;
	m_cndlp = 1;
}



/***************************************************************************
    IMPLEMENTATION
***************************************************************************/

WRITE8_MEMBER( e05a03_device::write )
{
	logerror("%s: e05a03_w(%02x): %02x\n", space.machine().describe_context(), offset, data);

	switch (offset)
	{
	/* shift register */
	case 0x00: m_shift = (m_shift & 0x00ffff) | (data << 16); break;
	case 0x01: m_shift = (m_shift & 0xff00ff) | (data << 8); break;
	case 0x02: m_shift = (m_shift & 0xffff00) | (data << 0); break;

	case 0x03:
		m_busy_leading = BIT(data, 7);
		m_busy_software = BIT(data, 6);
		m_nlqlp = BIT(data, 4);
		m_cndlp = BIT(data, 3);

		m_write_pe(BIT(data, 2));
		m_write_pe_lp(!BIT(data, 2));

#if 0
		m_pe = BIT(data, 2);
		m_pelp = !BIT(data, 2);
#endif

		break;

	/* printhead */
    case 0x04: m_printhead = (m_printhead & 0x100) | (data == 0 ? 0xff : 0); break;
    case 0x05: m_printhead = (m_printhead & 0x0ff) | (BIT(data, 7) ? (1 << 8) : 0); break;

	/* paper feed and carriage motor phase data*/
	case 0x06: m_pf_motor = (data & 0xf0) >> 4; break;
	case 0x07: m_cr_motor = (data & 0x0f) >> 0; break;
	}
}

READ8_MEMBER( e05a03_device::read )
{
	UINT8 result = 0;

	logerror("%s: e05a03_r(%02x)\n", space.machine().describe_context(), offset);

	switch (offset)
	{
	case 0x00:
		break;

	case 0x01:
		break;

	case 0x02:
		result = m_read_data(0);
		break;

	case 0x03:
		result |= BIT(m_shift, 23) << 7;
		m_shift <<= 1;
		break;
	}

	return result;
}

/* home position signal */
WRITE_LINE_MEMBER( e05a03_device::home_w )
{
}

/* printhead solenoids trigger */
WRITE_LINE_MEMBER( e05a03_device::fire_w )
{
}

WRITE_LINE_MEMBER( e05a03_device::strobe_w )
{
}

READ_LINE_MEMBER( e05a03_device::busy_r )
{
	return 1;
}

WRITE_LINE_MEMBER( e05a03_device::resi_w )
{
	if (!state)
	{
		device_reset();
		m_write_reso(1);
	}
}

WRITE_LINE_MEMBER( e05a03_device::init_w )
{
	resi_w(state);
}