コード例 #1
0
ファイル: config.cpp プロジェクト: Kinglions/modizer
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) {
コード例 #2
0
ファイル: config.cpp プロジェクト: QaDeS/droidsound
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;
    }