1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder, smf
3 /**********************************************************************
4
5 SpeedDOS / Burst Nibbler 1541/1571 Parallel Cable emulation
6
7 http://sta.c64.org/cbmparc2.html
8
9 **********************************************************************/
10
11 #include "emu.h"
12 #include "bn1541.h"
13
14
15
16 //**************************************************************************
17 // MACROS / CONSTANTS
18 //**************************************************************************
19
20 #define LOG 0
21
22
23
24 //**************************************************************************
25 // DEVICE DEFINITIONS
26 //**************************************************************************
27
28 DEFINE_DEVICE_TYPE(C64_BN1541, c64_bn1541_device, "c64_bn1541", "C64 Burst Nibbler 1541/1571 Parallel Cable")
29
30
31
32 //**************************************************************************
33 // FLOPPY DRIVE INTERFACE
34 //**************************************************************************
35
36 //-------------------------------------------------
37 // device_c64_floppy_parallel_interface - constructor
38 //-------------------------------------------------
39
device_c64_floppy_parallel_interface(const machine_config & mconfig,device_t & device)40 device_c64_floppy_parallel_interface::device_c64_floppy_parallel_interface(const machine_config &mconfig, device_t &device) :
41 m_other(nullptr), m_parallel_data(0)
42 {
43 }
44
45
46 //-------------------------------------------------
47 // ~device_c64_floppy_parallel_interface - destructor
48 //-------------------------------------------------
49
~device_c64_floppy_parallel_interface()50 device_c64_floppy_parallel_interface::~device_c64_floppy_parallel_interface()
51 {
52 }
53
54
55
56 //**************************************************************************
57 // LIVE DEVICE
58 //**************************************************************************
59
60 //-------------------------------------------------
61 // c64_bn1541_device - constructor
62 //-------------------------------------------------
63
c64_bn1541_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)64 c64_bn1541_device::c64_bn1541_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
65 device_t(mconfig, C64_BN1541, tag, owner, clock),
66 device_pet_user_port_interface(mconfig, *this),
67 device_c64_floppy_parallel_interface(mconfig, *this), m_parallel_output(0)
68 {
69 }
70
71
72 //-------------------------------------------------
73 // device_start - device-specific startup
74 //-------------------------------------------------
75
device_start()76 void c64_bn1541_device::device_start()
77 {
78 for (device_t &device : device_iterator(machine().root_device()))
79 {
80 for (device_t &subdevice : device_iterator(device))
81 {
82 if (subdevice.interface(m_other) && &subdevice != this)
83 {
84 if (LOG) logerror("Parallel device %s\n", subdevice.tag());
85
86 // grab the first 1541/1571 and run to the hills
87 m_other->m_other = this;
88 return;
89 }
90 }
91 }
92 }
93
94
95 //-------------------------------------------------
96 // parallel_data_w -
97 //-------------------------------------------------
98
parallel_data_w(uint8_t data)99 void c64_bn1541_device::parallel_data_w(uint8_t data)
100 {
101 if (LOG) logerror("1541 parallel data %02x\n", data);
102
103 output_c((data>>0)&1);
104 output_d((data>>1)&1);
105 output_e((data>>2)&1);
106 output_f((data>>3)&1);
107 output_h((data>>4)&1);
108 output_j((data>>5)&1);
109 output_k((data>>6)&1);
110 output_l((data>>7)&1);
111 }
112
113
114 //-------------------------------------------------
115 // parallel_strobe_w -
116 //-------------------------------------------------
117
parallel_strobe_w(int state)118 void c64_bn1541_device::parallel_strobe_w(int state)
119 {
120 if (LOG) logerror("1541 parallel strobe %u\n", state);
121
122 output_b(state);
123 }
124
125
126 //-------------------------------------------------
127 // update_output
128 //-------------------------------------------------
129
update_output()130 void c64_bn1541_device::update_output()
131 {
132 if (m_other != nullptr)
133 {
134 m_other->parallel_data_w(m_parallel_output);
135 }
136 }
137
138
139 //-------------------------------------------------
140 // input_8 - CIA2 PC write
141 //-------------------------------------------------
142
WRITE_LINE_MEMBER(c64_bn1541_device::input_8)143 WRITE_LINE_MEMBER(c64_bn1541_device::input_8)
144 {
145 if (LOG) logerror("C64 parallel strobe %u\n", state);
146
147 if (m_other != nullptr)
148 {
149 m_other->parallel_strobe_w(state);
150 }
151 }
152