trunk/src/mame/drivers/gottlieb.c
| r20836 | r20837 | |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | |
| 586 | | static void laserdisc_audio_process(device_t *dummy, laserdisc_device &device, int samplerate, int samples, const INT16 *ch0, const INT16 *ch1) |
| 586 | void gottlieb_state::laserdisc_audio_process(laserdisc_device &device, int samplerate, int samples, const INT16 *ch0, const INT16 *ch1) |
| 587 | 587 | { |
| 588 | | gottlieb_state *state = device.machine().driver_data<gottlieb_state>(); |
| 589 | | int logit = LOG_AUDIO_DECODE && device.machine().input().code_pressed(KEYCODE_L); |
| 588 | int logit = LOG_AUDIO_DECODE && machine().input().code_pressed(KEYCODE_L); |
| 590 | 589 | attotime time_per_sample = attotime::from_hz(samplerate); |
| 591 | | attotime curtime = state->m_laserdisc_last_time; |
| 590 | attotime curtime = m_laserdisc_last_time; |
| 592 | 591 | int cursamp; |
| 593 | 592 | |
| 594 | 593 | if (logit) |
| r20836 | r20837 | |
| 597 | 596 | /* if no data, reset it all */ |
| 598 | 597 | if (ch1 == NULL) |
| 599 | 598 | { |
| 600 | | state->m_laserdisc_last_time = curtime + time_per_sample * samples; |
| 599 | m_laserdisc_last_time = curtime + time_per_sample * samples; |
| 601 | 600 | return; |
| 602 | 601 | } |
| 603 | 602 | |
| r20836 | r20837 | |
| 611 | 610 | logerror("%s: %d", (curtime + time_per_sample + time_per_sample).as_string(6), sample); |
| 612 | 611 | |
| 613 | 612 | /* if we are past the "break in transmission" time, reset everything */ |
| 614 | | if ((curtime - state->m_laserdisc_last_clock) > attotime::from_usec(400)) |
| 615 | | state->audio_end_state(); |
| 613 | if ((curtime - m_laserdisc_last_clock) > attotime::from_usec(400)) |
| 614 | audio_end_state(); |
| 616 | 615 | |
| 617 | 616 | /* if this sample reinforces that the previous one ended a zero crossing, count it */ |
| 618 | | if ((sample >= 256 && state->m_laserdisc_last_samples[1] >= 0 && state->m_laserdisc_last_samples[0] < 0) || |
| 619 | | (sample <= -256 && state->m_laserdisc_last_samples[1] <= 0 && state->m_laserdisc_last_samples[0] > 0)) |
| 617 | if ((sample >= 256 && m_laserdisc_last_samples[1] >= 0 && m_laserdisc_last_samples[0] < 0) || |
| 618 | (sample <= -256 && m_laserdisc_last_samples[1] <= 0 && m_laserdisc_last_samples[0] > 0)) |
| 620 | 619 | { |
| 621 | 620 | attotime zerotime; |
| 622 | 621 | int fractime; |
| 623 | 622 | |
| 624 | 623 | /* compute the fractional position of the 0-crossing, between the two samples involved */ |
| 625 | | fractime = (-state->m_laserdisc_last_samples[0] * 1000) / (state->m_laserdisc_last_samples[1] - state->m_laserdisc_last_samples[0]); |
| 624 | fractime = (-m_laserdisc_last_samples[0] * 1000) / (m_laserdisc_last_samples[1] - m_laserdisc_last_samples[0]); |
| 626 | 625 | |
| 627 | 626 | /* use this fraction to compute the approximate actual zero crossing time */ |
| 628 | 627 | zerotime = curtime + time_per_sample * fractime / 1000; |
| 629 | 628 | |
| 630 | 629 | /* determine if this is a clock; if it is, process */ |
| 631 | | state->audio_handle_zero_crossing(zerotime, logit); |
| 630 | audio_handle_zero_crossing(zerotime, logit); |
| 632 | 631 | } |
| 633 | 632 | if (logit) |
| 634 | 633 | logerror(" \n"); |
| 635 | 634 | |
| 636 | 635 | /* update our sample tracking and advance time */ |
| 637 | | state->m_laserdisc_last_samples[0] = state->m_laserdisc_last_samples[1]; |
| 638 | | state->m_laserdisc_last_samples[1] = sample; |
| 636 | m_laserdisc_last_samples[0] = m_laserdisc_last_samples[1]; |
| 637 | m_laserdisc_last_samples[1] = sample; |
| 639 | 638 | curtime += time_per_sample; |
| 640 | 639 | } |
| 641 | 640 | |
| 642 | 641 | /* remember the last time */ |
| 643 | | state->m_laserdisc_last_time = curtime; |
| 642 | m_laserdisc_last_time = curtime; |
| 644 | 643 | } |
| 645 | 644 | |
| 646 | 645 | |
| r20836 | r20837 | |
| 1745 | 1744 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 1746 | 1745 | |
| 1747 | 1746 | MCFG_LASERDISC_PR8210_ADD("laserdisc") |
| 1748 | | MCFG_LASERDISC_AUDIO(laserdisc_audio_delegate(FUNC(laserdisc_audio_process), device)) |
| 1747 | MCFG_LASERDISC_AUDIO(laserdisc_audio_delegate(FUNC(gottlieb_state::laserdisc_audio_process), (gottlieb_state*)owner)) |
| 1749 | 1748 | MCFG_LASERDISC_OVERLAY_DRIVER(GOTTLIEB_VIDEO_HCOUNT, GOTTLIEB_VIDEO_VCOUNT, gottlieb_state, screen_update_gottlieb) |
| 1750 | 1749 | MCFG_LASERDISC_OVERLAY_CLIP(0, GOTTLIEB_VIDEO_HBLANK-1, 0, GOTTLIEB_VIDEO_VBLANK-8) |
| 1751 | 1750 | MCFG_SOUND_ROUTE(0, "mono", 1.0) |
| r20836 | r20837 | |
| 1836 | 1835 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 1837 | 1836 | |
| 1838 | 1837 | MCFG_LASERDISC_PR8210_ADD("laserdisc") |
| 1839 | | MCFG_LASERDISC_AUDIO(laserdisc_audio_delegate(FUNC(laserdisc_audio_process), device)) |
| 1838 | MCFG_LASERDISC_AUDIO(laserdisc_audio_delegate(FUNC(gottlieb_state::laserdisc_audio_process), (gottlieb_state*)owner)) |
| 1840 | 1839 | MCFG_LASERDISC_OVERLAY_DRIVER(GOTTLIEB_VIDEO_HCOUNT, GOTTLIEB_VIDEO_VCOUNT, gottlieb_state, screen_update_gottlieb) |
| 1841 | 1840 | MCFG_LASERDISC_OVERLAY_CLIP(0, GOTTLIEB_VIDEO_HBLANK-1, 0, GOTTLIEB_VIDEO_VBLANK-8) |
| 1842 | 1841 | MCFG_SOUND_ROUTE(0, "mono", 1.0) |