fix crashing bugs in yabause+software

This commit is contained in:
zeromus 2014-06-09 19:19:12 +00:00
parent 1edd4edb49
commit 92f417dade
2 changed files with 22 additions and 12 deletions

View File

@ -76,10 +76,6 @@ namespace BizHawk.Client.Common
{
//this is here for future use and tracking purposes.. however.. instead of relying on this, we should just make sure we always activate what we need before we use it
}
// ret.RequestGLContext = () => new BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK();
//ret.ActivateGLContext = (gl) => ((BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK)gl).MakeDefaultCurrent();
//ret.DeactivateGLContext = () => GlobalWin.DisplayManager..
public class ContextRef
{

View File

@ -69,18 +69,32 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
ResetCounters();
CoreComm.ActivateGLContext(glContext);
ActivateGL();
Init(bios);
InputCallbackH = new LibYabause.InputCallback(() => CoreComm.InputCallback.Call());
LibYabause.libyabause_setinputcallback(InputCallbackH);
CoreComm.UsesDriveLed = true;
CoreComm.DeactivateGLContext();
DeactivateGL();
}
static object glContext;
void ActivateGL()
{
//if (!SyncSettings.UseGL) return; //not safe
if (glContext == null) return;
CoreComm.ActivateGLContext(glContext);
}
void DeactivateGL()
{
//if (!SyncSettings.UseGL) return; //not safe
if (glContext == null) return;
CoreComm.DeactivateGLContext();
}
void Init(byte[] bios)
{
bool GL = SyncSettings.UseGL;
@ -197,7 +211,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
{
int w, h, nsamp;
CoreComm.ActivateGLContext(glContext);
ActivateGL();
LibYabause.Buttons1 p11 = (LibYabause.Buttons1)0xff;
LibYabause.Buttons2 p12 = (LibYabause.Buttons2)0xff;
@ -279,7 +293,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
//CheckStates();
CoreComm.DeactivateGLContext();
DeactivateGL();
}
public int Frame { get; private set; }
@ -373,11 +387,11 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
fp.Offer(data);
//loadstate can trigger GL work
CoreComm.ActivateGLContext(glContext);
ActivateGL();
bool succeed = LibYabause.libyabause_loadstate(fp.GetPipeNameNative());
CoreComm.DeactivateGLContext();
DeactivateGL();
fp.Finish();
if (!succeed)
@ -537,7 +551,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
{
if (!Disposed)
{
CoreComm.ActivateGLContext(glContext);
ActivateGL();
if (SaveRamModified)
DisposedSaveRam = ReadSaveRam();
LibYabause.libyabause_setvidbuff(IntPtr.Zero);
@ -546,7 +560,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
VideoHandle.Free();
SoundHandle.Free();
Disposed = true;
CoreComm.DeactivateGLContext();
DeactivateGL();
}
}