Beispiel #1
0
        // Clock speed changes due to loading a new song
        private c64.c64.model_t c64model(sidplayfp.SidConfig.c64_model_t defaultModel, bool forced)
        {
            sidplayfp.SidTuneInfo tuneInfo = m_tune.getInfo();

            sidplayfp.SidTuneInfo.clock_t clockSpeed = tuneInfo.clockSpeed();

            c64.c64.model_t model = c64.c64.model_t.PAL_B;

            // Use preferred speed if forced or if song speed is unknown
            if (forced || clockSpeed == sidplayfp.SidTuneInfo.clock_t.CLOCK_UNKNOWN || clockSpeed == sidplayfp.SidTuneInfo.clock_t.CLOCK_ANY)
            {
                switch (defaultModel)
                {
                case sidplayfp.SidConfig.c64_model_t.PAL:
                    clockSpeed  = sidplayfp.SidTuneInfo.clock_t.CLOCK_PAL;
                    model       = c64.c64.model_t.PAL_B;
                    videoSwitch = 1;
                    break;

                case sidplayfp.SidConfig.c64_model_t.DREAN:
                    clockSpeed  = sidplayfp.SidTuneInfo.clock_t.CLOCK_PAL;
                    model       = c64.c64.model_t.PAL_N;
                    videoSwitch = 1;     // TODO verify
                    break;

                case sidplayfp.SidConfig.c64_model_t.NTSC:
                    clockSpeed  = sidplayfp.SidTuneInfo.clock_t.CLOCK_NTSC;
                    model       = c64.c64.model_t.NTSC_M;
                    videoSwitch = 0;
                    break;

                case sidplayfp.SidConfig.c64_model_t.OLD_NTSC:
                    clockSpeed  = sidplayfp.SidTuneInfo.clock_t.CLOCK_NTSC;
                    model       = c64.c64.model_t.OLD_NTSC_M;
                    videoSwitch = 0;
                    break;
                }
            }
            else
            {
                switch (clockSpeed)
                {
                default:
                case sidplayfp.SidTuneInfo.clock_t.CLOCK_PAL:
                    model       = c64.c64.model_t.PAL_B;
                    videoSwitch = 1;
                    break;

                case sidplayfp.SidTuneInfo.clock_t.CLOCK_NTSC:
                    model       = c64.c64.model_t.NTSC_M;
                    videoSwitch = 0;
                    break;
                }
            }

            switch (clockSpeed)
            {
            case sidplayfp.SidTuneInfo.clock_t.CLOCK_PAL:
                if (tuneInfo.songSpeed() == sidplayfp.SidTuneInfo.SPEED_CIA_1A)
                {
                    m_info.m_speedString = TXT_PAL_CIA;
                }
                else if (tuneInfo.clockSpeed() == sidplayfp.SidTuneInfo.clock_t.CLOCK_NTSC)
                {
                    m_info.m_speedString = TXT_PAL_VBI_FIXED;
                }
                else
                {
                    m_info.m_speedString = TXT_PAL_VBI;
                }
                break;

            case sidplayfp.SidTuneInfo.clock_t.CLOCK_NTSC:
                if (tuneInfo.songSpeed() == sidplayfp.SidTuneInfo.SPEED_CIA_1A)
                {
                    m_info.m_speedString = TXT_NTSC_CIA;
                }
                else if (tuneInfo.clockSpeed() == sidplayfp.SidTuneInfo.clock_t.CLOCK_PAL)
                {
                    m_info.m_speedString = TXT_NTSC_VBI_FIXED;
                }
                else
                {
                    m_info.m_speedString = TXT_NTSC_VBI;
                }
                break;

            default:
                break;
            }

            return(model);
        }
Beispiel #2
0
        public bool config(ref sidplayfp.SidConfig cfg, bool force = false)
        {
            // Check if configuration have been changed or forced
            if (!force && !m_cfg.compare(ref cfg))
            {
                return(true);
            }

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

            // Only do these if we have a loaded tune
            if (m_tune != null)
            {
                sidplayfp.SidTuneInfo tuneInfo = m_tune.getInfo();

                try
                {
                    sidRelease();

                    List <UInt32> addresses        = new List <uint>();
                    UInt16        secondSidAddress = tuneInfo.sidChipBase(1) != 0 ?
                                                     tuneInfo.sidChipBase(1) :
                                                     cfg.secondSidAddress;
                    if (secondSidAddress != 0)
                    {
                        addresses.Add(secondSidAddress);
                    }

                    UInt16 thirdSidAddress = tuneInfo.sidChipBase(2) != 0 ?
                                             tuneInfo.sidChipBase(2) :
                                             cfg.thirdSidAddress;
                    if (thirdSidAddress != 0)
                    {
                        addresses.Add(thirdSidAddress);
                    }

                    // SID emulation setup (must be performed before the
                    // environment setup call)
                    sidCreate(cfg.sidEmulation, cfg.defaultSidModel, cfg.forceSidModel, ref addresses);

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

                    m_c64.setModel(model);

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

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

            bool isStereo = cfg.playback == sidplayfp.SidConfig.playback_t.STEREO;

            m_info.m_channels = (UInt32)(isStereo ? 2 : 1);

            m_mixer.setStereo(isStereo);
            m_mixer.setVolume((Int32)cfg.leftVolume, (Int32)cfg.rightVolume);

            // Update Configuration
            m_cfg = cfg;

            return(true);
        }