using System; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.N64.NativeApi; namespace BizHawk.Emulation.Cores.Nintendo.N64 { class N64VideoProvider : IVideoProvider, IDisposable { private int[] frameBuffer; private mupen64plusVideoApi api; /// /// Creates N64 Video system with mupen64plus backend /// /// mupen64plus DLL that is used public N64VideoProvider(mupen64plusApi core, VideoPluginSettings videosettings) { this.api = new mupen64plusVideoApi(core, videosettings); int width = 0; int height = 0; api.GetScreenDimensions(ref width, ref height); SetBufferSize(width, height); core.FrameFinished += DoVideoFrame; } public int[] GetVideoBuffer() { return frameBuffer; } public int VirtualWidth { get { return BufferWidth; } } public int BufferWidth { get; private set; } public int BufferHeight { get; private set; } public int BackgroundColor { get { return 0; } } /// /// Fetches current frame buffer from mupen64 /// public void DoVideoFrame() { int width = 0; int height = 0; api.GetScreenDimensions(ref width, ref height); if (width != BufferWidth || height != BufferHeight) { SetBufferSize(width, height); } api.Getm64pFrameBuffer(frameBuffer, ref width, ref height); } /// /// Sets a new width and height for frame buffer /// /// New width in pixels /// New height in pixels private void SetBufferSize(int width, int height) { BufferHeight = height; BufferWidth = width; frameBuffer = new int[width * height]; } public void Dispose() { // api is disposed by N64 api = null; } } }