254
163
mame_printf_debug("Votrax played '%s'\n", phonemes);
255
play_sample(samples, phonemes);
257
popmessage("%s", phonemes);
165
if (strcmp(phonemes, "[0] HEH3LOOW AH1EH3I3YMTERI2NDAHN") == 0) /* Q-Bert & Tylz - Hello, I am turned on */
166
m_samples->start(0, 42);
167
else if (strcmp(phonemes, "[0]BAH1EH1Y") == 0) /* Q-Bert - Bye, bye */
168
m_samples->start(0, 43);
169
else if (strcmp(phonemes, "[0]A2YHT LEH2FTTH") == 0) /* Reactor - Eight left */
170
m_samples->start(0, 0);
171
else if (strcmp(phonemes, "[0]SI3KS DTYN LEH2FTTH") == 0) /* Reactor - Sixteen left */
172
m_samples->start(0, 1);
173
else if (strcmp(phonemes, "[0]WO2RNYNG KO2R UH1NSDTABUH1L") == 0) /* Reactor - Warning core unstable */
174
m_samples->start(0, 5);
175
else if (strcmp(phonemes, "[0]CHAMBERR AE1EH2KTI1VA1I3DTEH1DT ") == 0) /* Reactor - Chamber activated */
176
m_samples->start(0, 7);
261
state->m_votrax_queuepos = 0;
179
m_votrax_queuepos = 0;
264
182
/* generate a NMI after a while to make the CPU continue to send data */
265
space->machine().scheduler().timer_set(attotime::from_usec(50), FUNC(gottlieb_nmi_generate));
268
static WRITE8_HANDLER( speech_clock_dac_w )
270
gottlieb_state *state = space->machine().driver_data<gottlieb_state>();
271
if (data != state->m_last)
272
mame_printf_debug("clock = %02X\n", data);
273
state->m_last = data;
277
/*************************************
279
* Rev 1. initialization
281
*************************************/
283
static SOUND_START( gottlieb1 )
285
gottlieb_state *state = machine.driver_data<gottlieb_state>();
286
state->m_score_sample = 7;
287
state->m_random_offset = 0;
289
state_save_register_global_array(machine, state->m_votrax_queue);
290
state_save_register_global(machine, state->m_votrax_queuepos);
295
/*************************************
299
*************************************/
301
static ADDRESS_MAP_START( gottlieb_sound1_map, AS_PROGRAM, 8 )
302
/* A15 not decoded except in expansion socket */
183
timer_set(attotime::from_usec(50));
186
static const char *const reactor_sample_names[] =
189
"fx_53", /* "8 left" */
190
"fx_54", /* "16 left" */
191
"fx_55", /* "24 left" */
192
"fx_56", /* "32 left" */
193
"fx_57", /* "40 left" */
194
"fx_58", /* "warning, core unstable" */
195
"fx_59", /* "bonus" */
196
"fx_31", /* "chamber activated" */
197
"fx_39a", /* "2000" */
198
"fx_39b", /* "5000" */
199
"fx_39c", /* "10000" */
200
"fx_39d", /* "15000" */
201
"fx_39e", /* "20000" */
202
"fx_39f", /* "25000" */
203
"fx_39g", /* "30000" */
204
"fx_39h", /* "35000" */
205
"fx_39i", /* "40000" */
206
"fx_39j", /* "45000" */
207
"fx_39k", /* "50000" */
208
"fx_39l", /* "55000" */
212
static const char *const qbert_sample_names[] =
215
"fx_17a", /* random speech, voice clock 255 */
216
"fx_17b", /* random speech, voice clock 255 */
217
"fx_17c", /* random speech, voice clock 255 */
218
"fx_17d", /* random speech, voice clock 255 */
219
"fx_17e", /* random speech, voice clock 255 */
220
"fx_17f", /* random speech, voice clock 255 */
221
"fx_17g", /* random speech, voice clock 255 */
222
"fx_17h", /* random speech, voice clock 255 */
223
"fx_18a", /* random speech, voice clock 176 */
224
"fx_18b", /* random speech, voice clock 176 */
225
"fx_18c", /* random speech, voice clock 176 */
226
"fx_18d", /* random speech, voice clock 176 */
227
"fx_18e", /* random speech, voice clock 176 */
228
"fx_18f", /* random speech, voice clock 176 */
229
"fx_18g", /* random speech, voice clock 176 */
230
"fx_18h", /* random speech, voice clock 176 */
231
"fx_19a", /* random speech, voice clock 128 */
232
"fx_19b", /* random speech, voice clock 128 */
233
"fx_19c", /* random speech, voice clock 128 */
234
"fx_19d", /* random speech, voice clock 128 */
235
"fx_19e", /* random speech, voice clock 128 */
236
"fx_19f", /* random speech, voice clock 128 */
237
"fx_19g", /* random speech, voice clock 128 */
238
"fx_19h", /* random speech, voice clock 128 */
239
"fx_20a", /* random speech, voice clock 96 */
240
"fx_20b", /* random speech, voice clock 96 */
241
"fx_20c", /* random speech, voice clock 96 */
242
"fx_20d", /* random speech, voice clock 96 */
243
"fx_20e", /* random speech, voice clock 96 */
244
"fx_20f", /* random speech, voice clock 96 */
245
"fx_20g", /* random speech, voice clock 96 */
246
"fx_20h", /* random speech, voice clock 96 */
247
"fx_21a", /* random speech, voice clock 62 */
248
"fx_21b", /* random speech, voice clock 62 */
249
"fx_21c", /* random speech, voice clock 62 */
250
"fx_21d", /* random speech, voice clock 62 */
251
"fx_21e", /* random speech, voice clock 62 */
252
"fx_21f", /* random speech, voice clock 62 */
253
"fx_21g", /* random speech, voice clock 62 */
254
"fx_21h", /* random speech, voice clock 62 */
255
"fx_22", /* EH2 with decreasing voice clock */
256
"fx_23", /* O1 with varying voice clock */
263
static const samples_interface reactor_samples_interface =
269
static const samples_interface qbert_samples_interface =
275
MACHINE_CONFIG_FRAGMENT( reactor_samples )
276
MCFG_SAMPLES_ADD("samples", reactor_samples_interface)
277
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
280
MACHINE_CONFIG_FRAGMENT( qbert_samples )
281
MCFG_SAMPLES_ADD("samples", qbert_samples_interface)
282
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
289
//**************************************************************************
290
// REV 1 SOUND BOARD: 6502 + DAC
291
//**************************************************************************
293
//-------------------------------------------------
294
// gottlieb_sound_r1_device - constructors
295
//-------------------------------------------------
297
gottlieb_sound_r1_device::gottlieb_sound_r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
298
: device_t(mconfig, GOTTLIEB_SOUND_REV1, "Gottlieb Sound rev. 1", "gotsndr1", tag, owner, clock),
299
device_mixer_interface(mconfig, *this),
300
m_audiocpu(*this, "audiocpu"),
301
m_riot(*this, "riot"),
303
m_votrax(*this, "votrax"),
304
m_populate_votrax(false),
305
m_last_speech_clock(0)
307
, m_samples(*this, ":samples"),
315
gottlieb_sound_r1_device::gottlieb_sound_r1_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, bool populate_votrax)
316
: device_t(mconfig, GOTTLIEB_SOUND_REV1, "Gottlieb Sound rev. 1", "gotsndr1", tag, owner, clock),
317
device_mixer_interface(mconfig, *this),
318
m_audiocpu(*this, "audiocpu"),
319
m_riot(*this, "riot"),
321
m_votrax(*this, "votrax"),
322
m_populate_votrax(populate_votrax),
323
m_last_speech_clock(0)
325
, m_samples(*this, ":samples"),
334
//-------------------------------------------------
335
// write - handle an external command write
336
//-------------------------------------------------
338
WRITE8_MEMBER( gottlieb_sound_r1_device::write )
340
// write the command data to the low 6 bits, and the trigger to the upper bit
341
UINT8 pa7 = (data & 0x0f) != 0xf;
342
UINT8 pa0_5 = ~data & 0x3f;
343
m_riot->porta_in_set(pa0_5 | (pa7 << 7), 0xbf);
346
if (pa7 && m_samples != NULL)
347
trigger_sample(pa0_5);
352
//-------------------------------------------------
353
// snd_interrupt - signal a sound interrupt
354
//-------------------------------------------------
356
WRITE_LINE_MEMBER( gottlieb_sound_r1_device::snd_interrupt )
358
m_audiocpu->set_input_line(M6502_IRQ_LINE, state);
362
//-------------------------------------------------
363
// r6532_portb_w - handle writes to the RIOT's
365
//-------------------------------------------------
367
WRITE8_MEMBER( gottlieb_sound_r1_device::r6532_portb_w )
369
// unsure if this is ever used, but the NMI is connected to the RIOT's PB7
370
m_audiocpu->set_input_line(INPUT_LINE_NMI, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
374
//-------------------------------------------------
375
// votrax_data_w - write data to the Votrax SC-01
377
//-------------------------------------------------
379
WRITE8_MEMBER( gottlieb_sound_r1_device::votrax_data_w )
381
if (m_votrax != NULL)
383
m_votrax->inflection_w(space, offset, data >> 6);
384
m_votrax->write(space, offset, ~data & 0x3f);
388
fake_votrax_data_w(data);
393
//-------------------------------------------------
394
// speech_clock_dac_w - modify the clock driving
395
// the Votrax SC-01 speech chip
396
//-------------------------------------------------
398
WRITE8_MEMBER( gottlieb_sound_r1_device::speech_clock_dac_w )
400
if (m_votrax != NULL)
402
// nominal clock is 0xa0
403
if (data != m_last_speech_clock)
405
mame_printf_debug("clock = %02X\n", data);
407
// totally random guesswork; would like to get real measurements on a board
408
if (m_votrax != NULL)
409
m_votrax->set_unscaled_clock(600000 + (data - 0xa0) * 10000);
410
m_last_speech_clock = data;
416
//-------------------------------------------------
417
// votrax_request - map the VOTRAX SC-01 request
418
// line to the NMI pin on the sound chip
419
//-------------------------------------------------
421
WRITE_LINE_MEMBER( gottlieb_sound_r1_device::votrax_request )
423
m_audiocpu->set_input_line(INPUT_LINE_NMI, state);
427
//-------------------------------------------------
429
//-------------------------------------------------
431
static const riot6532_interface gottlieb_riot6532_intf =
434
DEVCB_INPUT_PORT("SB1"),
436
DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, gottlieb_sound_r1_device, r6532_portb_w),
437
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, gottlieb_sound_r1_device, snd_interrupt)
441
//-------------------------------------------------
443
//-------------------------------------------------
445
static const votrax_sc01_interface gottlieb_votrax_interface =
447
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, gottlieb_sound_r1_device, votrax_request)
451
//-------------------------------------------------
453
//-------------------------------------------------
455
static ADDRESS_MAP_START( gottlieb_sound_r1_map, AS_PROGRAM, 8, gottlieb_sound_r1_device )
456
// A15 not decoded except in expansion socket
303
457
ADDRESS_MAP_GLOBAL_MASK(0x7fff)
304
458
AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0d80) AM_RAM
305
AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0de0) AM_DEVREADWRITE("riot", riot6532_r, riot6532_w)
306
AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x0fff) AM_DEVWRITE("dac", dac_w)
307
AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x0fff) AM_WRITE(vortrax_data_w)
459
AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0de0) AM_DEVREADWRITE("riot", riot6532_device, read, write)
460
AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x0fff) AM_DEVWRITE_LEGACY("dac", dac_w)
461
AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x0fff) AM_WRITE(votrax_data_w)
308
462
AM_RANGE(0x3000, 0x3000) AM_MIRROR(0x0fff) AM_WRITE(speech_clock_dac_w)
309
463
AM_RANGE(0x6000, 0x7fff) AM_ROM
314
/*************************************
316
* Rev. 1 machine driver
318
*************************************/
320
MACHINE_CONFIG_FRAGMENT( gottlieb_soundrev1 )
321
MCFG_SOUND_START(gottlieb1)
467
//-------------------------------------------------
468
// machine configuration
469
//-------------------------------------------------
471
MACHINE_CONFIG_FRAGMENT( gottlieb_sound_r1 )
473
MCFG_CPU_ADD("audiocpu", M6502, SOUND1_CLOCK/4) // the board can be set to /2 as well
474
MCFG_CPU_PROGRAM_MAP(gottlieb_sound_r1_map)
323
477
MCFG_RIOT6532_ADD("riot", SOUND1_CLOCK/4, gottlieb_riot6532_intf)
325
MCFG_CPU_ADD("audiocpu", M6502, SOUND1_CLOCK/4) /* the board can be set to /2 as well */
326
MCFG_CPU_PROGRAM_MAP(gottlieb_sound1_map)
329
480
MCFG_SOUND_ADD("dac", DAC, 0)
330
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
335
/*************************************
339
*************************************/
341
INPUT_PORTS_START( gottlieb1_sound )
481
MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.50)
484
MACHINE_CONFIG_FRAGMENT( gottlieb_sound_r1_with_votrax )
485
MCFG_FRAGMENT_ADD(gottlieb_sound_r1)
488
MCFG_VOTRAX_SC01_ADD("votrax", 720000, gottlieb_votrax_interface)
489
MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.50)
493
//-------------------------------------------------
495
//-------------------------------------------------
497
INPUT_PORTS_START( gottlieb_sound_r1 )
342
498
PORT_START("SB1")
343
499
PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" )
344
500
PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" )
349
505
PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) PORT_DIPLOCATION("SB1:2")
350
506
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
351
507
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
352
PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */
357
/*************************************
359
* Rev. 2 communication handlers
361
*************************************/
363
static void gottlieb2_sh_w(address_space *space, UINT8 data)
365
gottlieb_state *state = space->machine().driver_data<gottlieb_state>();
366
/* when data is not 0xff, the transparent latch at A3 allows it to pass through unmolested */
508
PORT_BIT( 0x80, 0x80, IPT_SPECIAL )
511
INPUT_PORTS_START( gottlieb_sound_r1_with_votrax )
512
PORT_INCLUDE(gottlieb_sound_r1)
514
PORT_BIT( 0x80, 0x80, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("votrax", votrax_sc01_device, request)
518
//-------------------------------------------------
519
// device_mconfig_additions - return a pointer to
520
// the device's machine fragment
521
//-------------------------------------------------
523
machine_config_constructor gottlieb_sound_r1_device::device_mconfig_additions() const
525
return MACHINE_CONFIG_NAME( gottlieb_sound_r1 );
529
//-------------------------------------------------
530
// device_input_ports - return a pointer to
531
// the device's I/O ports
532
//-------------------------------------------------
534
ioport_constructor gottlieb_sound_r1_device::device_input_ports() const
536
return INPUT_PORTS_NAME( gottlieb_sound_r1 );
540
//-------------------------------------------------
541
// device_start - device-specific startup
542
//-------------------------------------------------
544
void gottlieb_sound_r1_device::device_start()
550
//**************************************************************************
551
// REV 1 SOUND BOARD WITH VOTRAX
552
//**************************************************************************
554
//-------------------------------------------------
555
// gottlieb_sound_r1_with_votrax_device -
557
//-------------------------------------------------
559
gottlieb_sound_r1_with_votrax_device::gottlieb_sound_r1_with_votrax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
560
: gottlieb_sound_r1_device(mconfig, tag, owner, clock, true)
565
//-------------------------------------------------
566
// device_mconfig_additions - return a pointer to
567
// the device's machine fragment
568
//-------------------------------------------------
570
machine_config_constructor gottlieb_sound_r1_with_votrax_device::device_mconfig_additions() const
572
return MACHINE_CONFIG_NAME( gottlieb_sound_r1_with_votrax );
576
//-------------------------------------------------
577
// device_input_ports - return a pointer to
578
// the device's I/O ports
579
//-------------------------------------------------
581
ioport_constructor gottlieb_sound_r1_with_votrax_device::device_input_ports() const
583
return INPUT_PORTS_NAME( gottlieb_sound_r1_with_votrax );
588
//**************************************************************************
589
// REV 2 SOUND BOARD: 6502 + 2 x DAC + 2 x AY-8913
590
//**************************************************************************
592
//-------------------------------------------------
593
// gottlieb_sound_r2_device - constructor
594
//-------------------------------------------------
596
gottlieb_sound_r2_device::gottlieb_sound_r2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
597
: device_t(mconfig, GOTTLIEB_SOUND_REV2, "Gottlieb Sound rev. 2", "gotsndr2", tag, owner, clock),
598
device_mixer_interface(mconfig, *this),
599
m_audiocpu(*this, "audiocpu"),
600
m_speechcpu(*this, "speechcpu"),
604
m_sp0250(*this, "spsnd"),
605
m_cobram3_mod(false),
609
m_speechcpu_latch(0),
619
//-------------------------------------------------
620
// static_enable_cobram3_mods - enable changes
622
//-------------------------------------------------
624
void gottlieb_sound_r2_device::static_enable_cobram3_mods(device_t &device)
626
downcast<gottlieb_sound_r2_device &>(device).m_cobram3_mod = true;
630
//-------------------------------------------------
631
// write - handle an external command write
632
//-------------------------------------------------
634
WRITE8_MEMBER( gottlieb_sound_r2_device::write )
636
// when data is not 0xff, the transparent latch at A3 allows it to pass through unmolested
367
637
if (data != 0xff)
369
/* each CPU has its own latch */
370
soundlatch_w(space, 0, data);
371
soundlatch2_w(space, 0, data);
373
/* if the previous data was 0xff, clock an IRQ on each */
374
if (state->m_last_command == 0xff)
376
cputag_set_input_line(space->machine(), "audiocpu", M6502_IRQ_LINE, ASSERT_LINE);
377
cputag_set_input_line(space->machine(), "speech", M6502_IRQ_LINE, ASSERT_LINE);
380
state->m_last_command = data;
384
static READ8_HANDLER( speech_data_r )
386
cputag_set_input_line(space->machine(), "speech", M6502_IRQ_LINE, CLEAR_LINE);
387
return soundlatch_r(space, offset);
391
static READ8_HANDLER( audio_data_r )
393
cputag_set_input_line(space->machine(), "audiocpu", M6502_IRQ_LINE, CLEAR_LINE);
394
return soundlatch2_r(space, offset);
398
static WRITE8_HANDLER( signal_audio_nmi_w )
400
cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_NMI, ASSERT_LINE);
401
cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_NMI, CLEAR_LINE);
406
/*************************************
410
*************************************/
412
INLINE void nmi_timer_adjust(running_machine &machine)
414
gottlieb_state *state = machine.driver_data<gottlieb_state>();
415
/* adjust timer to go off in the future based on the current rate */
416
state->m_nmi_timer->adjust(attotime::from_hz(SOUND2_CLOCK/16) * (256 * (256 - state->m_nmi_rate)));
420
INLINE void nmi_state_update(running_machine &machine)
422
gottlieb_state *state = machine.driver_data<gottlieb_state>();
423
/* update the NMI line state based on the enable and state */
424
cputag_set_input_line(machine, "speech", INPUT_LINE_NMI, (state->m_nmi_state && (state->m_speech_control & 1)) ? ASSERT_LINE : CLEAR_LINE);
428
static TIMER_CALLBACK( nmi_clear )
430
gottlieb_state *state = machine.driver_data<gottlieb_state>();
431
/* clear the NMI state and update it */
432
state->m_nmi_state = 0;
433
nmi_state_update(machine);
437
static TIMER_CALLBACK( nmi_callback )
439
gottlieb_state *state = machine.driver_data<gottlieb_state>();
440
/* assert the NMI if it is not disabled */
441
state->m_nmi_state = 1;
442
nmi_state_update(machine);
444
/* set a timer to turn it off again on hte next SOUND_CLOCK/16 */
445
machine.scheduler().timer_set(attotime::from_hz(SOUND2_CLOCK/16), FUNC(nmi_clear));
447
/* adjust the NMI timer for the next time */
448
nmi_timer_adjust(machine);
452
static WRITE8_HANDLER( nmi_rate_w )
454
gottlieb_state *state = space->machine().driver_data<gottlieb_state>();
455
/* the new rate is picked up when the previous timer expires */
456
state->m_nmi_rate = data;
461
/*************************************
463
* Rev. 2 sound chip access
465
*************************************/
467
static CUSTOM_INPUT( speech_drq_custom_r )
469
return sp0250_drq_r(field.machine().device("spsnd"));
473
static WRITE8_DEVICE_HANDLER( gottlieb_dac_w )
475
gottlieb_state *state = device->machine().driver_data<gottlieb_state>();
476
/* dual DAC; the first DAC serves as the reference voltage for the
477
second, effectively scaling the output */
478
state->m_dac_data[offset] = data;
479
dac_data_16_w(device, state->m_dac_data[0] * state->m_dac_data[1]);
483
static WRITE8_HANDLER( speech_control_w )
485
gottlieb_state *state = space->machine().driver_data<gottlieb_state>();
486
UINT8 previous = state->m_speech_control;
487
state->m_speech_control = data;
489
/* bit 0 enables/disables the NMI line */
490
nmi_state_update(space->machine());
492
/* bit 1 controls a LED on the sound board */
494
/* bit 2 goes to 8913 BDIR pin */
495
if ((previous & 0x04) != 0 && (data & 0x04) == 0)
497
/* bit 3 selects which of the two 8913 to enable */
498
/* bit 4 goes to the 8913 BC1 pin */
499
device_t *ay = space->machine().device((data & 0x08) ? "ay1" : "ay2");
500
ay8910_data_address_w(ay, data >> 4, *state->m_psg_latch);
503
/* bit 5 goes to the speech chip DIRECT DATA TEST pin */
505
/* bit 6 = speech chip DATA PRESENT pin; high then low to make the chip read data */
506
if ((previous & 0x40) == 0 && (data & 0x40) != 0)
508
device_t *sp = space->machine().device("spsnd");
509
sp0250_w(sp, 0, *state->m_sp0250_latch);
512
/* bit 7 goes to the speech chip RESET pin */
513
if ((previous ^ data) & 0x80)
514
space->machine().device("spsnd")->reset();
517
static WRITE8_HANDLER( cobram3_speech_control_w )
519
gottlieb_state *state = space->machine().driver_data<gottlieb_state>();
520
UINT8 previous = state->m_speech_control;
521
state->m_speech_control = data;
523
/* bit 0 enables/disables the NMI line */
524
nmi_state_update(space->machine());
526
/* bit 1 controls a LED on the sound board */
530
state->m_psg_data_latch = *state->m_psg_latch;
639
// latch data on a timer
640
synchronize(TID_SOUND_LATCH_WRITE, data);
642
// if the previous data was 0xff, clock an IRQ on each
643
if (m_last_command == 0xff)
645
m_audiocpu->set_input_line(M6502_IRQ_LINE, ASSERT_LINE);
646
m_speechcpu->set_input_line(M6502_IRQ_LINE, ASSERT_LINE);
649
m_last_command = data;
653
//-------------------------------------------------
654
// nmi_timer_adjust - adjust the NMI timer to
655
// fire based on its configured rate
656
//-------------------------------------------------
658
inline void gottlieb_sound_r2_device::nmi_timer_adjust()
660
// adjust timer to go off in the future based on the current rate
661
m_nmi_timer->adjust(attotime::from_hz(SOUND2_CLOCK/16) * (256 * (256 - m_nmi_rate)));
665
//-------------------------------------------------
666
// nmi_state_update - update the NMI state based
667
// on the timer firing and the enable control
668
//-------------------------------------------------
670
inline void gottlieb_sound_r2_device::nmi_state_update()
672
// update the NMI line state based on the enable and state
673
m_speechcpu->set_input_line(INPUT_LINE_NMI, (m_nmi_state && (m_speech_control & 1)) ? ASSERT_LINE : CLEAR_LINE);
677
//-------------------------------------------------
678
// speech_data_r - read the input command latch
679
// from the audio CPU
680
//-------------------------------------------------
682
READ8_MEMBER( gottlieb_sound_r2_device::audio_data_r )
684
m_audiocpu->set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
685
return m_audiocpu_latch;
689
//-------------------------------------------------
690
// speech_data_r - read the input command latch
691
// from the speech CPU
692
//-------------------------------------------------
694
READ8_MEMBER( gottlieb_sound_r2_device::speech_data_r )
696
m_speechcpu->set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
697
return m_speechcpu_latch;
701
//-------------------------------------------------
702
// signal_audio_nmi_w - signal an NMI from the
703
// speech CPU to the audio CPU
704
//-------------------------------------------------
706
WRITE8_MEMBER( gottlieb_sound_r2_device::signal_audio_nmi_w )
708
m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
709
m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
713
//-------------------------------------------------
714
// nmi_rate_w - adjust the NMI rate on the speech
716
//-------------------------------------------------
718
WRITE8_MEMBER( gottlieb_sound_r2_device::nmi_rate_w )
720
// the new rate is picked up when the previous timer expires
725
//-------------------------------------------------
726
// speech_drq_custom_r - return the SP0250
727
// request line as an input port bit
728
//-------------------------------------------------
730
CUSTOM_INPUT_MEMBER( gottlieb_sound_r2_device::speech_drq_custom_r )
732
return sp0250_drq_r(m_sp0250);
736
//-------------------------------------------------
737
// dac_w - write to one of the two DACs on the
739
//-------------------------------------------------
741
WRITE8_MEMBER( gottlieb_sound_r2_device::dac_w )
743
// dual DAC; the first DAC serves as the reference voltage for the
744
// second, effectively scaling the output
745
m_dac_data[offset] = data;
746
dac_data_16_w(m_dac, m_dac_data[0] * m_dac_data[1]);
750
//-------------------------------------------------
751
// speech_control_w - primary audio control
752
// register on the speech board
753
//-------------------------------------------------
755
WRITE8_MEMBER( gottlieb_sound_r2_device::speech_control_w )
757
UINT8 previous = m_speech_control;
758
m_speech_control = data;
760
// bit 0 enables/disables the NMI line
763
// bit 1 controls a LED on the sound board
765
// bits 2-4 control the AY-8913, but act differently between the
766
// standard sound board and the modified Cobra Command board
769
// bit 2 goes to 8913 BDIR pin
770
if ((previous & 0x04) != 0 && (data & 0x04) == 0)
772
// bit 3 selects which of the two 8913 to enable
773
// bit 4 goes to the 8913 BC1 pin
774
if ((data & 0x08) != 0)
775
ay8910_data_address_w(m_ay1, data >> 4, m_psg_latch);
777
ay8910_data_address_w(m_ay2, data >> 4, m_psg_latch);
534
device_t *ay = space->machine().device((data & 0x08) ? "ay1" : "ay2");
535
ay8910_address_w(ay, 0, *state->m_psg_latch);
536
ay8910_data_w(ay, 0, state->m_psg_data_latch);
784
m_psg_data_latch = m_psg_latch;
788
ay8913_device *ay = (data & 0x08) ? m_ay1 : m_ay2;
789
ay8910_address_w(ay, 0, m_psg_latch);
790
ay8910_data_w(ay, 0, m_psg_data_latch);
538
/* bit 5 goes to the speech chip DIRECT DATA TEST pin */
540
/* bit 6 = speech chip DATA PRESENT pin; high then low to make the chip read data */
794
// bit 5 goes to the speech chip DIRECT DATA TEST pin
796
// bit 6 = speech chip DATA PRESENT pin; high then low to make the chip read data
541
797
if ((previous & 0x40) == 0 && (data & 0x40) != 0)
543
device_t *sp = space->machine().device("spsnd");
544
sp0250_w(sp, 0, *state->m_sp0250_latch);
798
sp0250_w(m_sp0250, 0, m_sp0250_latch);
547
/* bit 7 goes to the speech chip RESET pin */
800
// bit 7 goes to the speech chip RESET pin
548
801
if ((previous ^ data) & 0x80)
549
space->machine().device("spsnd")->reset();
553
/*************************************
555
* Rev. 2 initialization
557
*************************************/
559
static SOUND_START( gottlieb2 )
561
gottlieb_state *state = machine.driver_data<gottlieb_state>();
562
/* set up the NMI timer */
563
state->m_nmi_timer = machine.scheduler().timer_alloc(FUNC(nmi_callback));
564
state->m_nmi_rate = 0;
565
nmi_timer_adjust(machine);
567
state->m_dac_data[0] = state->m_dac_data[1] = 0xff;
569
/* register for save states */
570
state_save_register_global(machine, state->m_nmi_rate);
571
state_save_register_global(machine, state->m_nmi_state);
572
state_save_register_global(machine, state->m_speech_control);
573
state_save_register_global(machine, state->m_last_command);
578
/*************************************
582
*************************************/
584
static ADDRESS_MAP_START( gottlieb_speech2_map, AS_PROGRAM, 8 )
585
AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM
586
AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x1fff) AM_WRITEONLY AM_BASE_MEMBER(gottlieb_state, m_sp0250_latch)
587
AM_RANGE(0x4000, 0x4000) AM_MIRROR(0x1fff) AM_WRITE(speech_control_w)
588
AM_RANGE(0x6000, 0x6000) AM_MIRROR(0x1fff) AM_READ_PORT("SB2")
589
AM_RANGE(0x8000, 0x8000) AM_MIRROR(0x1fff) AM_WRITEONLY AM_BASE_MEMBER(gottlieb_state, m_psg_latch)
590
AM_RANGE(0xa000, 0xa000) AM_MIRROR(0x07ff) AM_WRITE(nmi_rate_w)
591
AM_RANGE(0xa800, 0xa800) AM_MIRROR(0x07ff) AM_READ(speech_data_r)
592
AM_RANGE(0xb000, 0xb000) AM_MIRROR(0x07ff) AM_WRITE(signal_audio_nmi_w)
593
AM_RANGE(0xc000, 0xffff) AM_ROM
597
static ADDRESS_MAP_START( gottlieb_cobram3_speech2_map, AS_PROGRAM, 8 )
598
AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM
599
AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x1fff) AM_WRITEONLY AM_BASE_MEMBER(gottlieb_state, m_sp0250_latch)
600
AM_RANGE(0x4000, 0x4000) AM_MIRROR(0x1fff) AM_WRITE(cobram3_speech_control_w)
601
AM_RANGE(0x6000, 0x6000) AM_MIRROR(0x1fff) AM_READ_PORT("SB2")
602
AM_RANGE(0x8000, 0x8000) AM_MIRROR(0x1fff) AM_WRITEONLY AM_BASE_MEMBER(gottlieb_state, m_psg_latch)
603
AM_RANGE(0xa000, 0xa000) AM_MIRROR(0x07ff) AM_WRITE(nmi_rate_w)
604
AM_RANGE(0xa800, 0xa800) AM_MIRROR(0x07ff) AM_READ(speech_data_r)
605
AM_RANGE(0xb000, 0xb000) AM_MIRROR(0x07ff) AM_WRITE(signal_audio_nmi_w)
606
AM_RANGE(0xc000, 0xffff) AM_ROM
609
static ADDRESS_MAP_START( gottlieb_audio2_map, AS_PROGRAM, 8 )
806
//-------------------------------------------------
807
// psg_latch_w - store an 8-bit value in the PSG
809
//-------------------------------------------------
811
WRITE8_MEMBER( gottlieb_sound_r2_device::psg_latch_w )
817
//-------------------------------------------------
818
// psg_latch_w - store an 8-bit value in the
819
// SP0250 latch register
820
//-------------------------------------------------
822
WRITE8_MEMBER( gottlieb_sound_r2_device::sp0250_latch_w )
824
m_sp0250_latch = data;
828
//-------------------------------------------------
829
// sound CPU address map
830
//-------------------------------------------------
832
static ADDRESS_MAP_START( gottlieb_sound_r2_map, AS_PROGRAM, 8, gottlieb_sound_r2_device )
610
833
AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x3c00) AM_RAM
611
AM_RANGE(0x4000, 0x4001) AM_MIRROR(0x3ffe) AM_DEVWRITE("dac1", gottlieb_dac_w) AM_BASE_MEMBER(gottlieb_state, m_dac_data)
834
AM_RANGE(0x4000, 0x4001) AM_MIRROR(0x3ffe) AM_WRITE(dac_w)
612
835
AM_RANGE(0x8000, 0x8000) AM_MIRROR(0x3fff) AM_READ(audio_data_r)
613
836
AM_RANGE(0xe000, 0xffff) AM_MIRROR(0x2000) AM_ROM
618
/*************************************
620
* Rev. 2 machine driver
622
*************************************/
624
MACHINE_CONFIG_FRAGMENT( gottlieb_soundrev2 )
626
MCFG_CPU_ADD("audiocpu", M6502, SOUND2_CLOCK/4)
627
MCFG_CPU_PROGRAM_MAP(gottlieb_audio2_map)
629
MCFG_CPU_ADD("speech", M6502, SOUND2_CLOCK/4)
630
MCFG_CPU_PROGRAM_MAP(gottlieb_speech2_map)
633
MCFG_SOUND_START( gottlieb2 )
635
MCFG_SOUND_ADD("dac1", DAC, 0)
636
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
638
MCFG_SOUND_ADD("dac2", DAC, 0)
639
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
641
MCFG_SOUND_ADD("ay1", AY8913, SOUND2_CLOCK/2)
642
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
644
MCFG_SOUND_ADD("ay2", AY8913, SOUND2_CLOCK/2)
645
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
647
MCFG_SOUND_ADD("spsnd", SP0250, SOUND2_SPEECH_CLOCK)
648
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
651
MACHINE_CONFIG_FRAGMENT( gottlieb_cobram3_soundrev2 )
653
MCFG_CPU_ADD("audiocpu", M6502, SOUND2_CLOCK/4)
654
MCFG_DEVICE_DISABLE()
655
MCFG_CPU_PROGRAM_MAP(gottlieb_audio2_map)
657
MCFG_CPU_ADD("speech", M6502, SOUND2_CLOCK/4)
658
MCFG_CPU_PROGRAM_MAP(gottlieb_cobram3_speech2_map)
661
MCFG_SOUND_START( gottlieb2 )
663
MCFG_SOUND_ADD("dac1", DAC, 0)
664
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
666
MCFG_SOUND_ADD("dac2", DAC, 0)
667
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
669
MCFG_SOUND_ADD("ay1", AY8913, SOUND2_CLOCK/2)
670
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
672
MCFG_SOUND_ADD("ay2", AY8913, SOUND2_CLOCK/2)
673
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
675
MCFG_SOUND_ADD("spsnd", SP0250, SOUND2_SPEECH_CLOCK)
676
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
680
/*************************************
684
*************************************/
686
INPUT_PORTS_START( gottlieb2_sound )
840
//-------------------------------------------------
841
// sppech CPU address map
842
//-------------------------------------------------
844
static ADDRESS_MAP_START( gottlieb_speech_r2_map, AS_PROGRAM, 8, gottlieb_sound_r2_device )
845
AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM
846
AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x1fff) AM_WRITE(sp0250_latch_w)
847
AM_RANGE(0x4000, 0x4000) AM_MIRROR(0x1fff) AM_WRITE(speech_control_w)
848
AM_RANGE(0x6000, 0x6000) AM_MIRROR(0x1fff) AM_READ_PORT("SB2")
849
AM_RANGE(0x8000, 0x8000) AM_MIRROR(0x1fff) AM_WRITE(psg_latch_w)
850
AM_RANGE(0xa000, 0xa000) AM_MIRROR(0x07ff) AM_WRITE(nmi_rate_w)
851
AM_RANGE(0xa800, 0xa800) AM_MIRROR(0x07ff) AM_READ(speech_data_r)
852
AM_RANGE(0xb000, 0xb000) AM_MIRROR(0x07ff) AM_WRITE(signal_audio_nmi_w)
853
AM_RANGE(0xc000, 0xffff) AM_ROM
857
//-------------------------------------------------
858
// machine configuration
859
//-------------------------------------------------
861
MACHINE_CONFIG_FRAGMENT( gottlieb_sound_r2 )
863
MCFG_CPU_ADD("audiocpu", M6502, SOUND2_CLOCK/4)
864
MCFG_CPU_PROGRAM_MAP(gottlieb_sound_r2_map)
866
MCFG_CPU_ADD("speechcpu", M6502, SOUND2_CLOCK/4)
867
MCFG_CPU_PROGRAM_MAP(gottlieb_speech_r2_map)
870
MCFG_SOUND_ADD("dac", DAC, 0)
871
MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.15)
873
MCFG_SOUND_ADD("ay1", AY8913, SOUND2_CLOCK/2)
874
MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.15)
876
MCFG_SOUND_ADD("ay2", AY8913, SOUND2_CLOCK/2)
877
MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 0.15)
879
MCFG_SOUND_ADD("spsnd", SP0250, SOUND2_SPEECH_CLOCK)
880
MCFG_SOUND_ROUTE(ALL_OUTPUTS, DEVICE_SELF_OWNER, 1.0)
884
//-------------------------------------------------
886
//-------------------------------------------------
888
INPUT_PORTS_START( gottlieb_sound_r2 )
687
889
PORT_START("SB2")
688
890
PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB2:1")
689
891
PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB2:2")