public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings) { string videoplugin; switch (settings.Plugin) { default: case PluginType.Rice: videoplugin = "mupen64plus-video-rice.dll"; break; case PluginType.Glide: videoplugin = "mupen64plus-video-glide64.dll"; break; case PluginType.GlideMk2: videoplugin = "mupen64plus-video-glide64mk2.dll"; break; case PluginType.GLideN64: videoplugin = "mupen64plus-video-GLideN64.dll"; break; } GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX, videoplugin); GFXReadScreen2 = mupen64plusApi.GetTypedDelegate <ReadScreen2>(GfxDll, "ReadScreen2"); GFXReadScreen2Res = mupen64plusApi.GetTypedDelegate <ReadScreen2Res>(GfxDll, "ReadScreen2"); var funcPtr = OSTailoredCode.LinkedLibManager.GetProcAddrOrZero(GfxDll, "GetScreenTextureID"); if (funcPtr != IntPtr.Zero) { GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(funcPtr, typeof(GetScreenTextureID)); } }
public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings) { string videoplugin; switch (settings.Plugin) { default: case PluginType.Rice: videoplugin = "mupen64plus-video-rice.dll"; break; case PluginType.Glide: videoplugin = "mupen64plus-video-glide64.dll"; break; case PluginType.GlideMk2: videoplugin = "mupen64plus-video-glide64mk2.dll"; break; case PluginType.Jabo: videoplugin = "mupen64plus-video-jabo.dll"; break; } GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX, videoplugin); GFXReadScreen2 = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2)); GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res)); if(GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero) GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID)); }
public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings) { string videoplugin; switch (settings.Plugin) { default: case PluginType.Rice: videoplugin = "mupen64plus-video-rice.dll"; break; case PluginType.Glide: videoplugin = "mupen64plus-video-glide64.dll"; break; case PluginType.GlideMk2: videoplugin = "mupen64plus-video-glide64mk2.dll"; break; case PluginType.Jabo: videoplugin = "mupen64plus-video-jabo.dll"; break; } GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX, videoplugin); GFXReadScreen2 = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2)); GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res)); if (GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero) { GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID)); } }
/// <summary> /// Puts plugin settings of EmuHawk into mupen64plus /// </summary> /// <param name="video_settings">Settings to put into mupen64plus</param> public void set_video_parameters(VideoPluginSettings video_settings) { IntPtr video_plugin_section = IntPtr.Zero; if (video_settings.Plugin == PluginType.Rice) { m64pConfigOpenSection("Video-Rice", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.Glide) { m64pConfigOpenSection("Video-Glide64", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.GlideMk2) { m64pConfigOpenSection("Video-Glide64mk2", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.GLideN64) { m64pConfigOpenSection("Video-GLideN64", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.Angrylion) { m64pConfigOpenSection("Video-Angrylion", ref video_plugin_section); } else { return; } foreach (string Parameter in video_settings.Parameters.Keys) { if (video_settings.Parameters[Parameter].GetType() == typeof(string)) { string value = ((string)video_settings.Parameters[Parameter]); StringBuilder sb = new StringBuilder(value); m64pConfigSetParameterStr(video_plugin_section, Parameter, m64p_type.M64TYPE_STRING, sb); } else { int value = 0; if (video_settings.Parameters[Parameter].GetType() == typeof(int)) { value = (int)video_settings.Parameters[Parameter]; } else if (video_settings.Parameters[Parameter].GetType() == typeof(bool)) { value = (bool)video_settings.Parameters[Parameter] ? 1 : 0; } else if (video_settings.Parameters[Parameter] is Enum) { value = (int)video_settings.Parameters[Parameter]; } m64pConfigSetParameter(video_plugin_section, Parameter, m64p_type.M64TYPE_INT, ref value); } } }
/// <summary> /// Creates N64 Video system with mupen64plus backend /// </summary> /// <param name="api">mupen64plus DLL that is used</param> 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 > videosettings.Width ? width : videosettings.Width, height > videosettings.Height ? height : videosettings.Height ); core.BeforeRender += DoVideoFrame; core.BeforeRender += () => { IsVIFrame = true; }; }
public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings) { string videoplugin; //bool jaboReady = false; switch (settings.Plugin) { default: case PluginType.Rice: videoplugin = "mupen64plus-video-rice.dll"; break; case PluginType.Glide: videoplugin = "mupen64plus-video-glide64.dll"; break; case PluginType.GlideMk2: videoplugin = "mupen64plus-video-glide64mk2.dll"; break; case PluginType.Jabo: videoplugin = "mupen64plus-video-jabo.dll"; N64JaboManager manager = new N64JaboManager(); manager.Scan(); if (manager.Status == N64JaboManager.JaboStatus.ReadyToPatch) { manager.Patch(); } if (manager.Status != N64JaboManager.JaboStatus.Ready) { throw new FileNotFoundException(string.Format("Error: Jabo dll was not found. please copy Jabo_Direct3D8.dll from a Project64 v1.6.1 installation into Bizhawk's dll directory.")); } break; } GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX, videoplugin); GFXReadScreen2 = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2)); GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res)); if (GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero) { GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID)); } }
// get mupenapi internal object public VideoPluginSettings GetVPS(GameInfo game, int videoSizeX, int videoSizeY) { var ret = new VideoPluginSettings(VideoPlugin, videoSizeX, videoSizeY); IPluginSettings ips = null; switch (VideoPlugin) { // clone so per game hacks don't overwrite our settings object case PluginType.Glide: ips = GlidePlugin.Clone(); break; case PluginType.GlideMk2: ips = Glide64mk2Plugin.Clone(); break; case PluginType.Rice: ips = RicePlugin.Clone(); break; case PluginType.Jabo: ips = JaboPlugin.Clone(); break; } ips.FillPerGameHacks(game); ret.Parameters = ips.GetPluginSettings(); return ret; }
/// <summary> /// Puts plugin settings of EmuHawk into mupen64plus /// </summary> /// <param name="video_settings">Settings to put into mupen64plus</param> public void set_video_parameters(VideoPluginSettings video_settings) { IntPtr video_plugin_section = IntPtr.Zero; if (video_settings.Plugin == PluginType.Rice) { m64pConfigOpenSection("Video-Rice", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.Glide) { m64pConfigOpenSection("Video-Glide64", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.GlideMk2) { m64pConfigOpenSection("Video-Glide64mk2", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.Jabo) { m64pConfigOpenSection("Video-Jabo", ref video_plugin_section); } else { return; } foreach (string Parameter in video_settings.Parameters.Keys) { int value = 0; if (video_settings.Parameters[Parameter].GetType() == typeof(int)) { value = (int)video_settings.Parameters[Parameter]; } else if (video_settings.Parameters[Parameter].GetType() == typeof(bool)) { value = (bool)video_settings.Parameters[Parameter] ? 1 : 0; } else if (video_settings.Parameters[Parameter] is Enum) { value = (int)video_settings.Parameters[Parameter]; } m64pConfigSetParameter(video_plugin_section, Parameter, m64p_type.M64TYPE_INT, ref value); } }
public mupen64plusVideoApi(mupen64plusApi core, VideoPluginSettings settings) { string videoplugin; //bool jaboReady = false; switch (settings.Plugin) { default: case PluginType.Rice: videoplugin = "mupen64plus-video-rice.dll"; break; case PluginType.Glide: videoplugin = "mupen64plus-video-glide64.dll"; break; case PluginType.GlideMk2: videoplugin = "mupen64plus-video-glide64mk2.dll"; break; case PluginType.Jabo: videoplugin = "mupen64plus-video-jabo.dll"; N64JaboManager manager = new N64JaboManager(); manager.Scan(); if (manager.Status == N64JaboManager.JaboStatus.ReadyToPatch) manager.Patch(); if(manager.Status != N64JaboManager.JaboStatus.Ready) throw new FileNotFoundException(string.Format("Error: Jabo dll was not found. please copy Jabo_Direct3D8.dll from a Project64 v1.6.1 installation into Bizhawk's dll directory.")); break; } GfxDll = core.AttachPlugin(mupen64plusApi.m64p_plugin_type.M64PLUGIN_GFX, videoplugin); GFXReadScreen2 = (ReadScreen2)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2)); GFXReadScreen2Res = (ReadScreen2Res)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "ReadScreen2"), typeof(ReadScreen2Res)); if(GetProcAddress(GfxDll, "GetScreenTextureID") != IntPtr.Zero) GFXGetScreenTextureID = (GetScreenTextureID)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GfxDll, "GetScreenTextureID"), typeof(GetScreenTextureID)); }
public mupen64plusApi(N64 bizhawkCore, byte[] rom, VideoPluginSettings video_settings, int SaveType, int CoreType, bool DisableExpansionSlot) { // There can only be one core (otherwise breaks mupen64plus) if (AttachedCore != null) { AttachedCore.Dispose(); AttachedCore = null; } this.bizhawkCore = bizhawkCore; CoreDll = LoadLibrary("mupen64plus.dll"); if (CoreDll == IntPtr.Zero) { throw new InvalidOperationException(string.Format("Failed to load mupen64plus.dll")); } connectFunctionPointers(); // Start up the core m64p_error result = m64pCoreStartup(0x20001, "", "", "Core", null, "", IntPtr.Zero); // Open the core settings section in the config system IntPtr core_section = IntPtr.Zero; m64pConfigOpenSection("Core", ref core_section); // Set the savetype if needed if (DisableExpansionSlot) { int disable = 1; m64pConfigSetParameter(core_section, "DisableExtraMem", m64p_type.M64TYPE_INT, ref disable); } // Set the savetype if needed if (SaveType != 0) { m64pConfigSetParameter(core_section, "SaveType", m64p_type.M64TYPE_INT, ref SaveType); } m64pConfigSetParameter(core_section, "R4300Emulator", m64p_type.M64TYPE_INT, ref CoreType); // Pass the rom to the core result = m64pCoreDoCommandByteArray(m64p_command.M64CMD_ROM_OPEN, rom.Length, rom); // Open the general video settings section in the config system IntPtr video_section = IntPtr.Zero; m64pConfigOpenSection("Video-General", ref video_section); // Set the desired width and height for mupen64plus result = m64pConfigSetParameter(video_section, "ScreenWidth", m64p_type.M64TYPE_INT, ref video_settings.Width); result = m64pConfigSetParameter(video_section, "ScreenHeight", m64p_type.M64TYPE_INT, ref video_settings.Height); set_video_parameters(video_settings); InitSaveram(); // Initialize event invoker m64pFrameCallback = new FrameCallback(FireFrameFinishedEvent); result = m64pCoreDoCommandFrameCallback(m64p_command.M64CMD_SET_FRAME_CALLBACK, 0, m64pFrameCallback); m64pVICallback = new VICallback(FireVIEvent); result = m64pCoreDoCommandVICallback(m64p_command.M64CMD_SET_VI_CALLBACK, 0, m64pVICallback); m64pRenderCallback = new RenderCallback(FireRenderEvent); result = m64pCoreDoCommandRenderCallback(m64p_command.M64CMD_SET_RENDER_CALLBACK, 0, m64pRenderCallback); // Prepare to start the emulator in a different thread m64pEmulator = new Thread(ExecuteEmulator); AttachedCore = this; }
/// <summary> /// Puts plugin settings of EmuHawk into mupen64plus /// </summary> /// <param name="video_settings">Settings to put into mupen64plus</param> public void set_video_parameters(VideoPluginSettings video_settings) { IntPtr video_plugin_section = IntPtr.Zero; if (video_settings.Plugin == PluginType.Rice) { m64pConfigOpenSection("Video-Rice", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.Glide) { m64pConfigOpenSection("Video-Glide64", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.GlideMk2) { m64pConfigOpenSection("Video-Glide64mk2", ref video_plugin_section); } else if (video_settings.Plugin == PluginType.Jabo) { m64pConfigOpenSection("Video-Jabo", ref video_plugin_section); } else { return; } foreach (string Parameter in video_settings.Parameters.Keys) { int value = 0; if (video_settings.Parameters[Parameter].GetType() == typeof(int)) { value = (int)video_settings.Parameters[Parameter]; } else if (video_settings.Parameters[Parameter].GetType() == typeof(bool)) { value = (bool)video_settings.Parameters[Parameter] ? 1 : 0; } else if (video_settings.Parameters[Parameter] is Enum) { value = (int)video_settings.Parameters[Parameter]; } m64pConfigSetParameter(video_plugin_section, Parameter, m64p_type.M64TYPE_INT, ref value); } }
public mupen64plusApi(N64 bizhawkCore, byte[] rom, VideoPluginSettings video_settings, int SaveType, int CoreType, bool DisableExpansionSlot) { // There can only be one core (otherwise breaks mupen64plus) if (AttachedCore != null) { AttachedCore.Dispose(); AttachedCore = null; } this.bizhawkCore = bizhawkCore; CoreDll = LoadLibrary("mupen64plus.dll"); if (CoreDll == IntPtr.Zero) throw new InvalidOperationException(string.Format("Failed to load mupen64plus.dll")); connectFunctionPointers(); // Start up the core m64p_error result = m64pCoreStartup(0x20001, "", "", "Core", null, "", IntPtr.Zero); // Set the savetype if needed if (DisableExpansionSlot) { IntPtr core_section = IntPtr.Zero; int disable = 1; m64pConfigOpenSection("Core", ref core_section); m64pConfigSetParameter(core_section, "DisableExtraMem", m64p_type.M64TYPE_INT, ref disable); } // Set the savetype if needed if (SaveType != 0) { IntPtr core_section = IntPtr.Zero; m64pConfigOpenSection("Core", ref core_section); m64pConfigSetParameter(core_section, "SaveType", m64p_type.M64TYPE_INT, ref SaveType); } IntPtr coreSection = IntPtr.Zero; m64pConfigOpenSection("Core", ref coreSection); m64pConfigSetParameter(coreSection, "R4300Emulator", m64p_type.M64TYPE_INT, ref CoreType); // Pass the rom to the core result = m64pCoreDoCommandByteArray(m64p_command.M64CMD_ROM_OPEN, rom.Length, rom); // Open the general video settings section in the config system IntPtr video_section = IntPtr.Zero; m64pConfigOpenSection("Video-General", ref video_section); // Set the desired width and height for mupen64plus result = m64pConfigSetParameter(video_section, "ScreenWidth", m64p_type.M64TYPE_INT, ref video_settings.Width); result = m64pConfigSetParameter(video_section, "ScreenHeight", m64p_type.M64TYPE_INT, ref video_settings.Height); set_video_parameters(video_settings); InitSaveram(); // Initialize event invoker m64pFrameCallback = new FrameCallback(FireFrameFinishedEvent); result = m64pCoreDoCommandFrameCallback(m64p_command.M64CMD_SET_FRAME_CALLBACK, 0, m64pFrameCallback); m64pVICallback = new VICallback(FireVIEvent); result = m64pCoreDoCommandVICallback(m64p_command.M64CMD_SET_VI_CALLBACK, 0, m64pVICallback); m64pRenderCallback = new RenderCallback(FireRenderEvent); result = m64pCoreDoCommandRenderCallback(m64p_command.M64CMD_SET_RENDER_CALLBACK, 0, m64pRenderCallback); // Prepare to start the emulator in a different thread m64pEmulator = new Thread(ExecuteEmulator); AttachedCore = this; }