Beispiel #1
0
SIDPLAY2_NAMESPACE_START

// An instance of this structure is used to transport emulator settings
// to and from the interface class.

int Player::config (const sid2_config_t &cfg)
{
    if (m_running)
    {
        m_errorString = ERR_CONF_WHILST_ACTIVE;
        goto Player_configure_error;
    }

    // Check for base sampling frequency
    if (cfg.frequency < 4000)
    {   // Rev 1.6 (saw) - Added descriptive error
        m_errorString = ERR_UNSUPPORTED_FREQ;
        goto Player_configure_error;
    }

    // Only do these if we have a loaded tune
    if (m_tune)
    {
        if (m_playerState != sid2_paused)
            m_tune->getInfo(m_tuneInfo);

        // SID emulation setup (must be performed before the
        // environment setup call)
        if (sidCreate (cfg.sidEmulation, cfg.sidModel, cfg.sidDefault) < 0)
        {
            m_errorString      = cfg.sidEmulation->error ();
            m_cfg.sidEmulation = NULL;
            goto Player_configure_restore;
        }

        if (m_playerState != sid2_paused)
        {
            float64_t cpuFreq;
            // Must be this order:
            // Determine clock speed
            cpuFreq = clockSpeed (cfg.clockSpeed, cfg.clockDefault,
                                  cfg.clockForced);
            // Setup fake cia
            sid6526.clock ((uint_least16_t)(cpuFreq / VIC_FREQ_PAL + 0.5));
            if (m_tuneInfo.songSpeed  == SIDTUNE_SPEED_CIA_1A ||
                m_tuneInfo.clockSpeed == SIDTUNE_CLOCK_NTSC)
            {
                sid6526.clock ((uint_least16_t)(cpuFreq / VIC_FREQ_NTSC + 0.5));
            }

            // @FIXME@ see mos6526.h for details. Setup TOD clock
            if (m_tuneInfo.clockSpeed == SIDTUNE_CLOCK_PAL)
            {
                cia.clock  (cpuFreq / VIC_FREQ_PAL);
                cia2.clock (cpuFreq / VIC_FREQ_PAL);
            }
            else
            {
                cia.clock  (cpuFreq / VIC_FREQ_NTSC);
                cia2.clock (cpuFreq / VIC_FREQ_NTSC);
            }

            /* inform ReSID of the desired sampling rate */
            for (int i = 0; i < SID2_MAX_SIDS; i += 1)
                sid[i]->sampling(cpuFreq, cfg.frequency, cfg.samplingMethod, cfg.fastSampling);

            // Start the real time clock event
            rtc.clock(cpuFreq);

            // Configure, setup and install C64 environment/events
            if (environment (cfg.environment) < 0)
                goto Player_configure_restore;
        }
    }
    sidSamples (cfg.sidSamples);

    // Setup sid mapping table
    // Note this should be based on m_tuneInfo.sidChipBase1
    // but this is only temporary code anyway
    {
        for (int i = 0; i < SID2_MAPPER_SIZE; i++)
            m_sidmapper[i] = 0;
    }

    m_info.channels = 1;
    if (m_tune && m_tuneInfo.sidChipBase2) {
        // Assumed to be in d4xx-d7xx range
        m_sidmapper[(m_tuneInfo.sidChipBase2 >> 5) &
                    (SID2_MAPPER_SIZE - 1)] = 1;
        m_info.channels = 2;
    } else if (cfg.forceDualSids) {
Beispiel #2
0
bool Player::config(const SidConfig &cfg)
{
    const SidTuneInfo* tuneInfo = 0;

    // Check for base sampling frequency
    if (cfg.frequency < 8000)
    {
        m_errorString = ERR_UNSUPPORTED_FREQ;
        return false;
    }

    uint_least16_t secondSidAddress = cfg.secondSidAddress;

    // Only do these if we have a loaded tune
    if (m_tune)
    {
        tuneInfo = m_tune->getInfo();

        if (tuneInfo->sidChipBase(1) != 0)
            secondSidAddress = tuneInfo->sidChipBase(1);

        try
        {
            // SID emulation setup (must be performed before the
            // environment setup call)
            sidRelease();
            const int channels = (secondSidAddress != 0) ? 2 : 1;
            sidCreate(cfg.sidEmulation, cfg.defaultSidModel, cfg.forceSidModel, channels);

            // Determine clock speed
            const c64::model_t model = c64model(cfg.defaultC64Model, cfg.forceC64Model);

            m_c64.setModel(model);

            sidParams(m_c64.getMainCpuSpeed(), cfg.frequency, cfg.samplingMethod, cfg.fastSampling);

            // Configure, setup and install C64 environment/events
            initialise();
        }
        catch (configError const &e)
        {
            m_errorString = e.message();
            m_cfg.sidEmulation = 0;
            if (&m_cfg != &cfg)
            {
                config(m_cfg);
            }
            return false;
        }
    }

    if (secondSidAddress)
    {
        // Assumed to be in d420-d7ff or de00-dfff range
        m_c64.setSecondSIDAddress(secondSidAddress);
        m_info.m_channels = 2;
    }
    else
    {
        m_c64.setSecondSIDAddress(0);
        m_info.m_channels = 1;
    }

    m_mixer.setStereo(cfg.playback == SidConfig::STEREO);
    m_mixer.setVolume(cfg.leftVolume, cfg.rightVolume);

    // Update Configuration
    m_cfg = cfg;

    return true;
}
Beispiel #3
0
SIDPLAY2_NAMESPACE_START

// An instance of this structure is used to transport emulator settings
// to and from the interface class.

int Player::config (const sid2_config_t &cfg)
{
    bool monosid = true;

    if (m_running)
    {
        m_errorString = ERR_CONF_WHILST_ACTIVE;
        goto Player_configure_error;
    }

    // Check for base sampling frequency
    if (cfg.frequency < 4000)
    {   // Rev 1.6 (saw) - Added descriptive error
        m_errorString = ERR_UNSUPPORTED_FREQ;
        goto Player_configure_error;
    }

    // Check for legal precision
    switch (cfg.precision)
    {
    case 8:
    case 16:
    case 24:
        if (cfg.precision > SID2_MAX_PRECISION)
        {   // Rev 1.6 (saw) - Added descriptive error
            m_errorString = ERR_UNSUPPORTED_PRECISION;
            goto Player_configure_error;
        }
    break;

    default:
        // Rev 1.6 (saw) - Added descriptive error
        m_errorString = ERR_UNSUPPORTED_PRECISION;
        goto Player_configure_error;
    }
   
    // Initialise sid mapping table
    {for (int i = 0; i < SID2_MAPPER_SIZE; i++)
        m_sidmapper[i] = 0;
    }

    // Only do these if we have a loaded tune
    if (m_tune)
    {
        if (m_playerState != sid2_paused)
            m_tune->getInfo(m_tuneInfo);

        // SID emulation setup (must be performed before the
        // environment setup call)
        if (sidCreate (cfg.sidEmulation, cfg.sidModel, cfg.sidDefault) < 0)
        {
            m_errorString      = cfg.sidEmulation->error ();
            m_cfg.sidEmulation = NULL;
            goto Player_configure_restore;
        }

        if (m_playerState != sid2_paused)
        {
            float64_t cpuFreq;
            // Must be this order:
            // Determine clock speed
            cpuFreq = clockSpeed (cfg.clockSpeed, cfg.clockDefault,
                                  cfg.clockForced);
            // Fixed point conversion 16.16
            m_samplePeriod = (event_clock_t) (cpuFreq /
                             (float64_t) cfg.frequency *
                             (1 << 16) * m_fastForwardFactor);
            // Setup fake cia
            sid6526.clock ((uint_least16_t)(cpuFreq / VIC_FREQ_PAL + 0.5));
            if (m_tuneInfo.songSpeed  == SIDTUNE_SPEED_CIA_1A ||
                m_tuneInfo.clockSpeed == SIDTUNE_CLOCK_NTSC)
            {
                sid6526.clock ((uint_least16_t)(cpuFreq / VIC_FREQ_NTSC + 0.5));
            }

            // @FIXME@ see mos6526.h for details. Setup TOD clock 
            if (m_tuneInfo.clockSpeed == SIDTUNE_CLOCK_PAL)
            {
                cia.clock  (cpuFreq / VIC_FREQ_PAL);
                cia2.clock (cpuFreq / VIC_FREQ_PAL);
            }
            else
            {
                cia.clock  (cpuFreq / VIC_FREQ_NTSC);
                cia2.clock (cpuFreq / VIC_FREQ_NTSC);
            }

            // Start the real time clock event
            rtc.clock  (cpuFreq);

            // Configure, setup and install C64 environment/events
            if (environment (cfg.environment) < 0)
                goto Player_configure_restore;
        }

        // Setup sid mapping table
        // Note this should be based on m_tuneInfo.sidChipBase1
        // but this is only temporary code anyway
        if (m_tuneInfo.sidChipBase2)
        {
            // Assumed to be in d4xx-d7xx range
            m_sidmapper[(m_tuneInfo.sidChipBase2 >> 5) &
                        (SID2_MAPPER_SIZE - 1)] = 1;
        }
        monosid = !m_tuneInfo.sidChipBase2;
    }