summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/c64/bn1541.cpp
blob: bd3fc5a270bd67e3a434b02317ab94b743c1d9e8 (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
// license:BSD-3-Clause
// copyright-holders:Curt Coder, smf
/**********************************************************************

    SpeedDOS / Burst Nibbler 1541/1571 Parallel Cable emulation

    http://sta.c64.org/cbmparc2.html

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

#include "emu.h"
#include "bn1541.h"



//**************************************************************************
//  MACROS / CONSTANTS
//**************************************************************************

#define LOG 0



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

const device_type C64_BN1541 = device_creator<c64_bn1541_device>;



//**************************************************************************
//  FLOPPY DRIVE INTERFACE
//**************************************************************************

//-------------------------------------------------
//  device_c64_floppy_parallel_interface - constructor
//-------------------------------------------------

device_c64_floppy_parallel_interface::device_c64_floppy_parallel_interface(const machine_config &mconfig, device_t &device) :
	m_other(nullptr), m_parallel_data(0)
{
}


//-------------------------------------------------
//  ~device_c64_floppy_parallel_interface - destructor
//-------------------------------------------------

device_c64_floppy_parallel_interface::~device_c64_floppy_parallel_interface()
{
}



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

//-------------------------------------------------
//  c64_bn1541_device - constructor
//-------------------------------------------------

c64_bn1541_device::c64_bn1541_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, C64_BN1541, "C64 Burst Nibbler 1541/1571 Parallel Cable", tag, owner, clock, "c64_bn1541", __FILE__),
	device_pet_user_port_interface(mconfig, *this),
	device_c64_floppy_parallel_interface(mconfig, *this), m_parallel_output(0)
{
}


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

void c64_bn1541_device::device_start()
{
	for (device_t &device : device_iterator(machine().root_device()))
	{
		for (device_t &subdevice : device_iterator(device))
		{
			if (subdevice.interface(m_other) && &subdevice != this)
			{
				if (LOG) logerror("Parallel device %s\n", subdevice.tag());

				// grab the first 1541/1571 and run to the hills
				m_other->m_other = this;
				return;
			}
		}
	}
}


//-------------------------------------------------
//  parallel_data_w -
//-------------------------------------------------

void c64_bn1541_device::parallel_data_w(uint8_t data)
{
	if (LOG) logerror("1541 parallel data %02x\n", data);

	output_c((data>>0)&1);
	output_d((data>>1)&1);
	output_e((data>>2)&1);
	output_f((data>>3)&1);
	output_h((data>>4)&1);
	output_j((data>>5)&1);
	output_k((data>>6)&1);
	output_l((data>>7)&1);
}


//-------------------------------------------------
//  parallel_strobe_w -
//-------------------------------------------------

void c64_bn1541_device::parallel_strobe_w(int state)
{
	if (LOG) logerror("1541 parallel strobe %u\n", state);

	output_b(state);
}


//-------------------------------------------------
//  update_output
//-------------------------------------------------

void c64_bn1541_device::update_output()
{
	if (m_other != nullptr)
	{
		m_other->parallel_data_w(m_parallel_output);
	}
}


//-------------------------------------------------
//  input_8 - CIA2 PC write
//-------------------------------------------------

WRITE_LINE_MEMBER(c64_bn1541_device::input_8)
{
	if (LOG) logerror("C64 parallel strobe %u\n", state);

	if (m_other != nullptr)
	{
		m_other->parallel_strobe_w(state);
	}
}