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
203
204
205
206
207
208
209
210
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
RCA VIP Super Sound System VP550 emulation
TODO: Implement VP551 variant
**********************************************************************/
#include "emu.h"
#include "vp550.h"
#include "speaker.h"
#define VERBOSE (0)
#include "logmacro.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(VP550, vp550_device, "vp550", "VP-550 Super Sound")
//-------------------------------------------------
// device_add_mconfig
//-------------------------------------------------
void vp550_device::device_add_mconfig(machine_config &config)
{
SPEAKER(config, "mono").front_center();
CDP1863(config, m_pfg[0]);
m_pfg[0]->set_clock2(0);
m_pfg[0]->add_route(ALL_OUTPUTS, "mono", 1.0);
CDP1863(config, m_pfg[1]);
m_pfg[1]->set_clock2(0);
m_pfg[1]->add_route(ALL_OUTPUTS, "mono", 1.0);
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// vp550_device - constructor
//-------------------------------------------------
vp550_device::vp550_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
device_t(mconfig, VP550, tag, owner, clock),
device_vip_expansion_card_interface(mconfig, *this),
m_pfg(*this, "u%u", 1U),
m_sync_timer(nullptr)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void vp550_device::device_start()
{
// allocate timers
m_sync_timer = timer_alloc(FUNC(vp550_device::sync_tick), this);
m_sync_timer->adjust(attotime::from_hz(50), 0, attotime::from_hz(50));
m_sync_timer->enable(0);
}
//-------------------------------------------------
// sync_timer - fire an interrupt on host
//-------------------------------------------------
TIMER_CALLBACK_MEMBER(vp550_device::sync_tick)
{
LOG("VP550 '%s' Interrupt\n", tag());
m_slot->interrupt_w(ASSERT_LINE);
}
//-------------------------------------------------
// vip_program_w - program write
//-------------------------------------------------
void vp550_device::vip_program_w(offs_t offset, uint8_t data, int cdef, int *minh)
{
if (BIT(offset, 15))
{
*minh = 1;
switch (offset & 0x03)
{
case 1: m_pfg[0]->str_w(data); break;
case 2: m_pfg[1]->str_w(data); break;
case 3: octave_w(data); break;
}
switch ((offset >> 4) & 0x03)
{
case 1: vlmna_w(data); break;
case 2: vlmnb_w(data); break;
case 3: sync_w(data); break;
}
}
}
//-------------------------------------------------
// vip_sc_w - status code write
//-------------------------------------------------
void vp550_device::vip_sc_w(int n, int sc)
{
if (BIT(sc, 1))
{
LOG("VP550 '%s' Clear Interrupt\n", tag());
m_slot->interrupt_w(CLEAR_LINE);
}
}
//-------------------------------------------------
// vip_q_w - Q write
//-------------------------------------------------
void vp550_device::vip_q_w(int state)
{
m_pfg[0]->oe_w(state);
m_pfg[1]->oe_w(state);
}
//-------------------------------------------------
// vip_run_w - RUN write
//-------------------------------------------------
void vp550_device::vip_run_w(int state)
{
if (!state)
{
m_pfg[0]->reset();
m_pfg[1]->reset();
}
}
//-------------------------------------------------
// octave_w - octave select write
//-------------------------------------------------
void vp550_device::octave_w(uint8_t data)
{
int channel = (data >> 2) & 0x03;
int clock2 = 0;
if (BIT(data, 4))
{
clock2 = m_slot->clock() >> (3 - (data & 0x03));
}
m_pfg[BIT(data, 2)]->set_clk2(clock2);
LOG("VP550 '%s' Clock %c: %u Hz\n", tag(), 'A' + channel, clock2);
}
//-------------------------------------------------
// vlmna_w - channel A amplitude write
//-------------------------------------------------
void vp550_device::vlmna_w(uint8_t data)
{
LOG("VP550 '%s' A Volume: %u\n", tag(), data & 0x0f);
float gain = (data & 0x0f) / 15.0f;
m_pfg[0]->set_output_gain(0, gain);
}
//-------------------------------------------------
// vlmnb_w - channel B amplitude write
//-------------------------------------------------
void vp550_device::vlmnb_w(uint8_t data)
{
LOG("VP550 '%s' B Volume: %u\n", tag(), data & 0x0f);
float gain = (data & 0x0f) / 15.0f;
m_pfg[1]->set_output_gain(0, gain);
}
//-------------------------------------------------
// sync_w - interrupt enable write
//-------------------------------------------------
void vp550_device::sync_w(uint8_t data)
{
LOG("VP550 '%s' Interrupt Enable: %u\n", tag(), BIT(data, 0));
m_sync_timer->enable(BIT(data, 0));
}
|