summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/electron/fbprint.cpp
blob: 00bb056db753575cd537bcbbc36021be9d21477f (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
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

    First Byte Printer Interface

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


#include "emu.h"
#include "fbprint.h"


//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(ELECTRON_FBPRINT, electron_fbprint_device, "electron_fbprint", "First Byte Printer Interface")


//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

void electron_fbprint_device::device_add_mconfig(machine_config &config)
{
	/* printer */
	CENTRONICS(config, m_centronics, centronics_devices, "printer");
	m_centronics->busy_handler().set([this](int state) { m_centronics_busy = state; });
	output_latch_device &latch(OUTPUT_LATCH(config, "cent_data_out"));
	m_centronics->set_output_latch(latch);
}

//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  electron_fbprint_device - constructor
//-------------------------------------------------

electron_fbprint_device::electron_fbprint_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, ELECTRON_FBPRINT, tag, owner, clock)
	, device_electron_expansion_interface(mconfig, *this)
	, m_centronics(*this, "centronics")
	, m_cent_data_out(*this, "cent_data_out")
	, m_centronics_busy(0)
{
}


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

void electron_fbprint_device::device_start()
{
}


//-------------------------------------------------
//  expbus_r - expansion data read
//-------------------------------------------------

uint8_t electron_fbprint_device::expbus_r(offs_t offset)
{
	uint8_t data = 0xff;

	if (offset == 0xfc72)
	{
		data = (m_centronics_busy << 7) | 0x7f;
	}

	return data;
}


//-------------------------------------------------
//  expbus_w - expansion data write
//-------------------------------------------------

void electron_fbprint_device::expbus_w(offs_t offset, uint8_t data)
{
	if (offset == 0xfc71)
	{
		m_cent_data_out->write(data);
		m_centronics->write_strobe(0);
		m_centronics->write_strobe(1);
	}
}