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();
}