void CreateNewContextAndRemoveOldOne() { ContextInitializedFlag = false; ContextInitialized.Reset(); { // Stops the current context if it has one already. if (PspRunner != null) { PspRunner.StopSynchronized(); PspEmulatorContext.GetInstance<PspMemory>().Dispose(); PspEmulatorContext.GetInstance<GpuImpl>().StopSynchronized(); PspEmulatorContext.GetInstance<PspAudioImpl>().StopSynchronized(); PspRunner = null; PspEmulatorContext = null; GC.Collect(); } foreach (var FileName in new [] { Path.GetDirectoryName(typeof(Program).Assembly.Location) + @"\CSPspEmu.Hle.Modules.dll", Application.ExecutablePath, }) { if (File.Exists(FileName)) { PspConfig.HleModulesDll = Assembly.LoadFile(FileName); break; } } // PspEmulatorContext = new PspEmulatorContext(PspConfig); { PspEmulatorContext.SetInstanceType<GpuImpl, OpenglGpuImpl>(); PspEmulatorContext.SetInstanceType<PspAudioImpl, PspAudioOpenalImpl>(); #if RELEASE PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); #else PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); #endif /* if (PspConfig.UseFastAndUnsaferMemory) { PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); } else { PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); } */ } PspRunner = PspEmulatorContext.GetInstance<PspRunner>(); PspRunner.StartSynchronized(); var GpuImpl = PspEmulatorContext.GetInstance<GpuImpl>(); GpuImpl.InitSynchronizedOnce(); } ContextInitializedFlag = true; ContextInitialized.Set(); }
void CreateNewContextAndRemoveOldOne() { ContextInitializedFlag = false; ContextInitialized.Reset(); { // Stops the current context if it has one already. if (PspRunner != null) { PspRunner.StopSynchronized(); PspEmulatorContext.GetInstance<PspMemory>().Dispose(); PspEmulatorContext.GetInstance<GpuImpl>().StopSynchronized(); PspEmulatorContext.GetInstance<PspAudioImpl>().StopSynchronized(); PspRunner = null; PspEmulatorContext = null; GC.Collect(); } PspConfig.HleModulesDll = typeof(HleModulesRoot).Assembly; /* foreach (var FileName in new [] { Path.GetDirectoryName(typeof(Program).Assembly.Location) + @"\CSPspEmu.Hle.Modules.dll", Application.ExecutablePath, }) { if (File.Exists(FileName)) { PspConfig.HleModulesDll = Assembly.LoadFile(FileName); break; } } */ // PspEmulatorContext = new PspEmulatorContext(PspConfig); { // GPU PspPluginImpl.SelectWorkingPlugin<GpuImpl>(PspEmulatorContext, typeof(OpenglGpuImpl), typeof(GpuImplSoft), typeof(GpuImplNull) ); // AUDIO PspPluginImpl.SelectWorkingPlugin<PspAudioImpl>(PspEmulatorContext, typeof(PspAudioOpenalImpl), typeof(PspAudioWaveOutImpl), typeof(AudioAlsaImpl), typeof(AudioImplNull) ); // Memory if (PspConfig.StoredConfig.UseFastMemory) { PspEmulatorContext.SetInstanceType<PspMemory, FastPspMemory>(); } else { PspEmulatorContext.SetInstanceType<PspMemory, NormalPspMemory>(); } } PspEmulatorContext.GetInstance<PspDisplay>().VBlankEventCall += new Action(PspEmulator_VBlankEventCall); PspRunner = PspEmulatorContext.GetInstance<PspRunner>(); PspRunner.StartSynchronized(); var GpuImpl = PspEmulatorContext.GetInstance<GpuImpl>(); GpuImpl.InitSynchronizedOnce(); } ContextInitializedFlag = true; ContextInitialized.Set(); }
void CreateNewContextAndRemoveOldOne() { Console.WriteLine("----------------------------------------------"); // Stops the current context if it has one already. if (PspRunner != null) { PspRunner.StopSynchronized(); InjectContext.GetInstance<PspMemory>().Dispose(); InjectContext.GetInstance<GpuImpl>().StopSynchronized(); InjectContext.GetInstance<PspAudioImpl>().StopSynchronized(); PspRunner = null; _InjectContext.Dispose(); _InjectContext = null; GC.Collect(); } lock (this) { _InjectContext = PspInjectContext.CreateInjectContext(StoredConfig, Test: false); _InjectContext.SetInstanceType<IGuiExternalInterface, PspEmulator>(); _InjectContext.InjectDependencesTo(this); PspRunner.StartSynchronized(); } //GpuImpl.InitSynchronizedOnce(); }