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
|
/**********************************************************************
SpeedDOS / Burst Nibbler 1541/1571 Parallel Cable emulation
http://sta.c64.org/cbmparc2.html
Copyright MESS Team.
Visit http://mamedev.org for licensing and usage restrictions.
**********************************************************************/
#include "c64_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(NULL)
{
}
//-------------------------------------------------
// ~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 clock) :
device_t(mconfig, C64_BN1541, "C64 Burst Nibbler 1541/1571 Parallel Cable", tag, owner, clock),
device_c64_user_port_interface(mconfig, *this),
device_c64_floppy_parallel_interface(mconfig, *this)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void c64_bn1541_device::device_start()
{
device_iterator iter(machine().root_device());
for (device_t *device = iter.first(); device != NULL; device = iter.next())
{
device_iterator subiter(*device);
for (device_t *subdevice = subiter.first(); subdevice != NULL; subdevice = iter.next())
{
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 data)
{
if (LOG) logerror("1541 parallel data %02x\n", data);
m_parallel_data = data;
}
//-------------------------------------------------
// parallel_strobe_w -
//-------------------------------------------------
void c64_bn1541_device::parallel_strobe_w(int state)
{
if (LOG) logerror("1541 parallel strobe %u\n", state);
m_slot->cia_flag2_w(state);
}
//-------------------------------------------------
// c64_pb_r - port B read
//-------------------------------------------------
UINT8 c64_bn1541_device::c64_pb_r(address_space &space, offs_t offset)
{
return m_parallel_data;
}
//-------------------------------------------------
// c64_pb_w - port B write
//-------------------------------------------------
void c64_bn1541_device::c64_pb_w(address_space &space, offs_t offset, UINT8 data)
{
if (LOG) logerror("C64 parallel data %02x\n", data);
if (m_other != NULL)
{
m_other->parallel_data_w(data);
}
}
//-------------------------------------------------
// c64_pc2_w - CIA2 PC write
//-------------------------------------------------
void c64_bn1541_device::c64_pc2_w(int state)
{
if (LOG) logerror("C64 parallel strobe %u\n", state);
if (m_other != NULL)
{
m_other->parallel_strobe_w(state);
}
}
|