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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
// license:BSD-3-Clause
// copyright-holders:Devin Acker
/*
Casio LD-50 electronic drums
Unlike most Casio instruments, this is either rebranded or outsourced.
It's unclear who developed it, or if it was ever sold under other brands,
but the data ROM mentions "SharpWin".
Main board:
bottom left: "DIGITAL DRUM [LD-50] DATE: 2001/07/20"
bottom right: "LD50 Main PCB Rev.1"
IC1: Burr-Brown PCM1717E DAC
IC2: unknown SOIC8 ("2429 170")
IC4: Philips P87C52UBAA MCU
IC5: AMD AM29F040 ROM
IC7/8/9/10: 4x 74HC374
IC11: unknown COB (letter "B" handwritten on epoxy)
IC12: Dream SAM9793
XTAL1: 9.6MHz (for SAM9793)
XTAL2: 12MHz (for MCU)
A 10-pin header at the upper left connects to the input matrix and
a small plastic LCD assembly on the other side of the board.
Most of the sound is provided by the SAM9793, which is just a MIDI
synth on a chip that takes in serial MIDI input and outputs I2S.
The four sound effect pads also trigger PCM samples separately,
possibly via the black blob at IC11.
The external ROM contains the demo and rhythms, which are all stored
as standard type 0 MIDI files.
To activate the test mode, hold "Rhythm" and "Assign" when powering on.
From here, hitting the drum pads will display time/velocity measurements.
TODO:
- drum LEDs
- LCD artwork
- clickable layout?
- possibly connect a MIDI out port in lieu of the SAM9793
(MCS51 core needs proper serial output first)
- dump/emulate the other PCM device somehow
*/
#include "emu.h"
#include "bus/midi/midioutport.h"
#include "cpu/mcs51/mcs51.h"
#include "video/hd44780.h"
#include "emupal.h"
#include "screen.h"
namespace {
class ld50_state : public driver_device
{
public:
ld50_state(machine_config const &mconfig, device_type type, char const *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_lcdc(*this, "lcdc")
, m_datarom(*this, "datarom")
, m_inputs(*this, "IN%u", 0)
, m_pads(*this, "PADS")
, m_dial(*this, "DIAL")
{
}
void ld50(machine_config &config);
DECLARE_CUSTOM_INPUT_MEMBER(dial_r);
private:
u8 port0_r();
void port0_w(u8 data);
u8 port1_r();
void port2_w(u8 data);
void port3_w(u8 data);
virtual void driver_start() override;
virtual void driver_reset() override;
HD44780_PIXEL_UPDATE(lcd_update);
void palette_init(palette_device &palette);
required_device<mcs51_cpu_device> m_maincpu;
required_device<hd44780_device> m_lcdc;
required_memory_region m_datarom;
required_ioport_array<5> m_inputs;
required_ioport m_pads;
required_ioport m_dial;
u8 m_port[4];
u32 m_rom_addr;
u16 m_shift_data;
};
HD44780_PIXEL_UPDATE(ld50_state::lcd_update)
{
if (x < 6 && y < 8 && line < 2 && pos < 8)
bitmap.pix(y, line * 48 + pos * 6 + x) = state;
}
void ld50_state::palette_init(palette_device &palette)
{
palette.set_pen_color(0, rgb_t(255, 255, 255));
palette.set_pen_color(1, rgb_t(0, 0, 0));
}
u8 ld50_state::port0_r()
{
u8 data = 0xf0 | (m_lcdc->db_r() >> 4);
if (!BIT(m_port[2], 3))
data &= m_datarom->base()[m_rom_addr & 0x7ffff];
return data;
}
void ld50_state::port0_w(u8 data)
{
m_lcdc->db_w(data << 4);
m_port[0] = data;
}
u8 ld50_state::port1_r()
{
/*
bits 0-3: drum pads (active high)
bits 4-7: multiplexed inputs (active low)
The drum pads are read during the timer 0 interrupt.
Note velocity is based on the number of timer intervals that the pad remains pressed.
*/
return (m_port[1] & 0xf0) | m_pads->read();
}
void ld50_state::port2_w(u8 data)
{
/*
bit 0: ?
bit 1: ?
bit 2: ?
bit 3: ROM output enable
bit 4: ROM address low byte latch
bit 5: ROM address mid byte latch
bit 6: ROM address hi byte & input latch
bit 7: LCD control latch
*/
const u8 set = data & ~m_port[2];
m_port[2] = data;
if (BIT(set, 4))
{
m_rom_addr = (m_rom_addr & 0x7ff00) | m_port[0];
}
if (BIT(set, 5))
{
m_rom_addr = (m_rom_addr & 0x700ff) | (m_port[0] << 8);
}
if (BIT(set, 6))
{
m_rom_addr = (m_rom_addr & 0x0ffff) | ((m_port[0] & 0xe0) << 11);
m_port[1] |= 0xf0;
for (int i = 0; i < 5; i++)
{
if (!BIT(m_port[0], i))
m_port[1] &= (m_inputs[i]->read() << 4);
}
}
if (BIT(set, 7))
{
m_lcdc->rw_w(BIT(m_port[0], 6));
m_lcdc->rs_w(BIT(m_port[0], 7));
}
}
void ld50_state::port3_w(u8 data)
{
/*
bit 0: LCD enable
bit 1: MIDI Tx (TODO)
bit 2: ?
bit 3: trigger sound effect
bit 4: ?
bit 5: shift register data
bit 6: shift register clock
bit 7: ?
The LD-50 transmits MIDI both through the UART registers and manually via port 3.
Demo/rhythm playback uses the UART, while drum pads, effect values, etc. are
bit-banged through the port instead (why?)
*/
const u8 set = data & ~m_port[3];
m_port[3] = data;
m_lcdc->e_w(BIT(data, 0));
if (BIT(set, 3))
{
logerror("play sound effect %u\n", m_shift_data & 0x1f);
}
if (BIT(set, 6))
{
m_shift_data <<= 1;
m_shift_data |= BIT(data, 5);
}
if (BIT(set, 7))
{
logerror("unknown serial cmd (data = 0x%4x)\n", m_shift_data);
}
}
CUSTOM_INPUT_MEMBER(ld50_state::dial_r)
{
// return the dial position as a 2-bit gray code
const u8 val = m_dial->read();
return (val >> 6) ^ (val >> 7);
}
void ld50_state::driver_start()
{
save_item(NAME(m_port));
save_item(NAME(m_rom_addr));
save_item(NAME(m_shift_data));
}
void ld50_state::driver_reset()
{
memset(m_port, 0xff, sizeof m_port);
m_rom_addr = 0;
m_shift_data = 0;
}
void ld50_state::ld50(machine_config &config)
{
// CPU
I87C52(config, m_maincpu, 12_MHz_XTAL);
m_maincpu->port_in_cb<0>().set(FUNC(ld50_state::port0_r));
m_maincpu->port_out_cb<0>().set(FUNC(ld50_state::port0_w));
m_maincpu->port_in_cb<1>().set(FUNC(ld50_state::port1_r));
m_maincpu->port_out_cb<2>().set(FUNC(ld50_state::port2_w));
m_maincpu->port_out_cb<3>().set(FUNC(ld50_state::port3_w));
// LCD
HD44780(config, m_lcdc, 0);
m_lcdc->set_lcd_size(2, 8);
m_lcdc->set_pixel_update_cb(FUNC(ld50_state::lcd_update));
// screen (for testing only)
// TODO: the actual LCD with custom segments
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
screen.set_screen_update("lcdc", FUNC(hd44780_device::screen_update));
screen.set_size(6 * 16, 8);
screen.set_visarea_full();
screen.set_palette("palette");
PALETTE(config, "palette", FUNC(ld50_state::palette_init), 2);
}
INPUT_PORTS_START(ld50)
PORT_START("PADS")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Drum Pad 4")
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Drum Pad 3")
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Drum Pad 2")
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Drum Pad 1")
PORT_START("DIAL")
PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(50) PORT_KEYDELTA(50) PORT_REVERSE
PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("SE Pad 4")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("SE Pad 3")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("SE Pad 2")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("SE Pad 1")
PORT_START("IN1")
PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(ld50_state, dial_r)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("Effect")
PORT_START("IN2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_EQUALS) PORT_NAME("Assign")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_MINUS) PORT_NAME("Drum Set")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_0) PORT_NAME("SE Set")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_9) PORT_NAME("Rhythm")
PORT_START("IN3")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_8) PORT_NAME("Play Level")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_7) PORT_NAME("Light")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_6) PORT_NAME("Tempo")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_5) PORT_NAME("Start/Stop")
PORT_START("IN4")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_4) PORT_NAME("Synchro Start")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_3) PORT_NAME("Demo")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_2) PORT_NAME("Rhythm Vol.")
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_1) PORT_NAME("Main Vol.")
INPUT_PORTS_END
ROM_START(ld50)
ROM_REGION(0x2000, "maincpu", 0)
ROM_LOAD("87c52.ic4", 0x0000, 0x2000, CRC(126108cc) SHA1(cb8d7359628f8e519862cec73e38078275c3bd48))
ROM_REGION(0x80000, "datarom", 0)
ROM_LOAD("ld50.ic5", 0x00000, 0x80000, CRC(acaee847) SHA1(7235aefd72260b6d9d1f652c643022515a880781))
ROM_END
} // anonymous namespace
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
SYST( 2002, ld50, 0, 0, ld50, ld50, ld50_state, empty_init, "Casio", "LD-50", MACHINE_NO_SOUND | MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE )
|