public void Dispose() { if (!Disposed) { ActivateGL(); if (SaveRamModified) { DisposedSaveRam = ReadSaveRam(); } LibYabause.libyabause_setvidbuff(IntPtr.Zero); LibYabause.libyabause_setsndbuff(IntPtr.Zero); LibYabause.libyabause_deinit(); VideoHandle.Free(); SoundHandle.Free(); Disposed = true; DeactivateGL(); } }
public void Dispose() { if (!Disposed) { ActivateGL(); if (SaveRamModified) { DisposedSaveRam = CloneSaveRam(); } LibYabause.libyabause_setvidbuff(IntPtr.Zero); LibYabause.libyabause_setsndbuff(IntPtr.Zero); LibYabause.libyabause_deinit(); VideoHandle.Free(); SoundHandle.Free(); CD.Dispose(); Disposed = true; DeactivateGL(); CoreComm.ReleaseGLContext(glContext); } }
public void SetGLRes(int factor, int width, int height) { if (!GLMode) { return; } if (factor < 0) { factor = 0; } if (factor > 4) { factor = 4; } int maxwidth, maxheight; if (factor == 0) { maxwidth = width; maxheight = height; } else { maxwidth = 704 * factor; maxheight = 512 * factor; } if (maxwidth * maxheight > VideoBuffer.Length) { VideoHandle.Free(); VideoBuffer = new int[maxwidth * maxheight]; VideoHandle = GCHandle.Alloc(VideoBuffer, GCHandleType.Pinned); LibYabause.libyabause_setvidbuff(VideoHandle.AddrOfPinnedObject()); } LibYabause.libyabause_glsetnativefactor(factor); if (factor == 0) { LibYabause.libyabause_glresize(width, height); } }
void Init(byte[] bios) { bool GL = SyncSettings.UseGL; if (AttachedCore != null) { AttachedCore.Dispose(); AttachedCore = null; } VideoHandle = GCHandle.Alloc(VideoBuffer, GCHandleType.Pinned); SoundHandle = GCHandle.Alloc(SoundBuffer, GCHandleType.Pinned); LibYabause.CDInterface CDInt = new LibYabause.CDInterface(); CDInt.InitFunc = InitH = new LibYabause.CDInterface.Init(CD_Init); CDInt.DeInitFunc = DeInitH = new LibYabause.CDInterface.DeInit(CD_DeInit); CDInt.GetStatusFunc = GetStatusH = new LibYabause.CDInterface.GetStatus(CD_GetStatus); CDInt.ReadTOCFunc = ReadTOCH = new LibYabause.CDInterface.ReadTOC(CD_ReadTOC); CDInt.ReadSectorFADFunc = ReadSectorFADH = new LibYabause.CDInterface.ReadSectorFAD(CD_ReadSectorFAD); CDInt.ReadAheadFADFunc = ReadAheadFADH = new LibYabause.CDInterface.ReadAheadFAD(CD_ReadAheadFAD); var fp = new FilePiping(); string BiosPipe = fp.GetPipeNameNative(); fp.Offer(bios); int basetime; if (SyncSettings.RealTimeRTC) { basetime = 0; } else { basetime = (int)((SyncSettings.RTCInitialTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds); } if (!LibYabause.libyabause_init ( ref CDInt, BiosPipe, GL, SyncSettings.CartType, SyncSettings.SkipBios, !SyncSettings.RealTimeRTC, basetime )) { throw new Exception("libyabause_init() failed!"); } fp.Finish(); LibYabause.libyabause_setvidbuff(VideoHandle.AddrOfPinnedObject()); LibYabause.libyabause_setsndbuff(SoundHandle.AddrOfPinnedObject()); AttachedCore = this; // with or without GL, this is the guaranteed frame -1 size; (unless you do a gl resize) BufferWidth = 320; BufferHeight = 224; InitMemoryDomains(); GLMode = GL; // if in GL mode, this will trigger the initial GL resize PutSyncSettings(this.SyncSettings); }