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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Commodore VIC-1112 IEEE-488 Interface Cartridge emulation
**********************************************************************/
#include "emu.h"
#include "vic1112.h"
//**************************************************************************
// MACROS / CONSTANTS
//**************************************************************************
#define M6522_0_TAG "u4"
#define M6522_1_TAG "u5"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(VIC1112, vic1112_device, "vic1112", "VIC-1112 IEEE-488 Interface")
WRITE_LINE_MEMBER( vic1112_device::via0_irq_w )
{
m_via0_irq = state;
m_slot->irq_w(m_via0_irq | m_via1_irq);
}
READ8_MEMBER( vic1112_device::via0_pb_r )
{
/*
bit description
PB0
PB1
PB2
PB3 _EOI
PB4 _DAV IN
PB5 _NRFD IN
PB6 _NDAC IN
PB7 _ATN IN
*/
uint8_t data = 0;
data |= m_bus->eoi_r() << 3;
data |= m_bus->dav_r() << 4;
data |= m_bus->nrfd_r() << 5;
data |= m_bus->ndac_r() << 6;
data |= m_bus->atn_r() << 7;
return data;
}
WRITE8_MEMBER( vic1112_device::via0_pb_w )
{
/*
bit description
PB0 _DAV OUT
PB1 _NRFD OUT
PB2 _NDAC OUT
PB3
PB4
PB5
PB6
PB7
*/
m_bus->dav_w(BIT(data, 0));
m_bus->nrfd_w(BIT(data, 1));
m_bus->ndac_w(BIT(data, 2));
}
WRITE_LINE_MEMBER( vic1112_device::via1_irq_w )
{
m_via1_irq = state;
m_slot->irq_w(m_via0_irq | m_via1_irq);
}
//-------------------------------------------------
// MACHINE_DRIVER( vic1112 )
//-------------------------------------------------
static MACHINE_CONFIG_START( vic1112 )
MCFG_DEVICE_ADD(M6522_0_TAG, VIA6522, 0)
MCFG_VIA6522_READPB_HANDLER(READ8(vic1112_device, via0_pb_r))
MCFG_VIA6522_WRITEPB_HANDLER(WRITE8(vic1112_device, via0_pb_w))
MCFG_VIA6522_IRQ_HANDLER(WRITELINE(vic1112_device, via0_irq_w))
MCFG_DEVICE_ADD(M6522_1_TAG, VIA6522, 0)
MCFG_VIA6522_READPB_HANDLER(DEVREAD8(IEEE488_TAG, ieee488_device, dio_r))
MCFG_VIA6522_WRITEPA_HANDLER(DEVWRITE8(IEEE488_TAG, ieee488_device, dio_w))
MCFG_VIA6522_CA2_HANDLER(DEVWRITELINE(IEEE488_TAG, ieee488_device, atn_w))
MCFG_VIA6522_CB2_HANDLER(DEVWRITELINE(IEEE488_TAG, ieee488_device, eoi_w))
MCFG_VIA6522_IRQ_HANDLER(WRITELINE(vic1112_device, via1_irq_w))
MCFG_CBM_IEEE488_ADD(nullptr)
MCFG_IEEE488_SRQ_CALLBACK(DEVWRITELINE(M6522_1_TAG, via6522_device, write_cb1))
MACHINE_CONFIG_END
//-------------------------------------------------
// machine_config_additions - device-specific
// machine configurations
//-------------------------------------------------
machine_config_constructor vic1112_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( vic1112 );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// vic1112_device - constructor
//-------------------------------------------------
vic1112_device::vic1112_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, VIC1112, tag, owner, clock)
, device_vic20_expansion_card_interface(mconfig, *this)
, m_via0(*this, M6522_0_TAG)
, m_via1(*this, M6522_1_TAG)
, m_bus(*this, IEEE488_TAG)
, m_via0_irq(0), m_via1_irq(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void vic1112_device::device_start()
{
// state saving
save_item(NAME(m_via0_irq));
save_item(NAME(m_via1_irq));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void vic1112_device::device_reset()
{
m_bus->ifc_w(0);
m_bus->ifc_w(1);
}
//-------------------------------------------------
// vic20_cd_r - cartridge data read
//-------------------------------------------------
uint8_t vic1112_device::vic20_cd_r(address_space &space, offs_t offset, uint8_t data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3)
{
if (!io2)
{
data = (BIT(offset, 4) ? m_via1 : m_via0)->read(space, offset & 0x0f);
}
else if (!blk5)
{
if (offset & 0x1000)
data = m_blk5[offset & 0x17ff];
}
return data;
}
//-------------------------------------------------
// vic20_cd_w - cartridge data write
//-------------------------------------------------
void vic1112_device::vic20_cd_w(address_space &space, offs_t offset, uint8_t data, int ram1, int ram2, int ram3, int blk1, int blk2, int blk3, int blk5, int io2, int io3)
{
if (!io2)
{
(BIT(offset, 4) ? m_via1 : m_via0)->write(space, offset & 0x0f, data);
}
}
|