Beispiel #1
0
        public bool LoadSIDFromStream(Stream mem)
        {
            Stop();

            if (mem == null)
            {
                return(false);
            }

            _CurrentTune = new SidTune(mem);

            return(_CurrentTune.StatusOk);
        }
Beispiel #2
0
        /// <summary>
        /// Inject regular program and set start address
        /// </summary>
        /// <param name="HexData"></param>
        /// <param name="DataStartAddress"></param>
        /// <param name="InitialAddress"></param>
        /// <returns></returns>
        public bool PlayFromBinary(string HexData, int DataStartAddress, int InitialAddress)
        {
            Stop();

            var byteData = StringToByteArrayFastest(HexData);

            _CurrentTune = new SidTune();

            _CurrentTune.info.loadAddr      = DataStartAddress;
            _CurrentTune.info.c64dataLen    = byteData.Length;
            _CurrentTune.info.initAddr      = InitialAddress;
            _CurrentTune.info.playAddr      = InitialAddress;
            _CurrentTune.info.compatibility = SidTune.SIDTUNE_COMPATIBILITY_R64;
            _CurrentTune.InjectProgramInMemory(byteData, DataStartAddress);
            _CurrentTune.status = true;

            _WavePlayer = new WaveOut();

            WaveFormat fmt = new WaveFormat(_Frequency, 16, 2);

            _BufferedWaveProvider = new BufferedWaveProvider(fmt);
            _BufferedWaveProvider.BufferDuration = TimeSpan.FromSeconds(2); // allow us to get well ahead of ourselves

            _WavePlayer.Init(_BufferedWaveProvider);

            _InternalPlayer = new InternalPlayer();

            sid2_config_t config = _InternalPlayer.config();

            config.frequency     = _Frequency;
            config.playback      = SID2Types.sid2_playback_t.sid2_mono;
            config.optimisation  = SID2Types.SID2_DEFAULT_OPTIMISATION;
            config.sidModel      = (SID2Types.sid2_model_t)_CurrentTune.Info.sidModel;
            config.clockDefault  = SID2Types.sid2_clock_t.SID2_CLOCK_CORRECT;
            config.clockSpeed    = SID2Types.sid2_clock_t.SID2_CLOCK_CORRECT;
            config.clockForced   = false;
            config.environment   = SID2Types.sid2_env_t.sid2_envR;
            config.forceDualSids = false;
            config.volume        = 255;
            config.sampleFormat  = SID2Types.sid2_sample_t.SID2_LITTLE_SIGNED;
            config.sidDefault    = SID2Types.sid2_model_t.SID2_MODEL_CORRECT;
            config.sidSamples    = true;
            config.precision     = SID2Types.SID2_DEFAULT_PRECISION;
            config.environment   = SID2Types.sid2_env_t.sid2_envR;

            _InternalPlayer.load(_CurrentTune);
            _InternalPlayer.config(config);

            // inject code
            for (int i = 0; i < byteData.Length; ++i)
            {
                _InternalPlayer.mem_writeMemByte(DataStartAddress + i, byteData[i]);
            }

            _InternalPlayer.SetCPUPos(InitialAddress);
            _IsStereo = _CurrentTune.isStereo;

            _InternalPlayer.start();

            _Thread = new Thread(new ThreadStart(ThreadProc));
            _Thread.Start();

            return(true);
        }
Beispiel #3
0
 public PSid(SidTune sidtune)
 {
     this.sidtune = sidtune;
     this.info    = sidtune.info;
 }