M64p: String parameters can now be passed to the core.

This commit is contained in:
pjgat09 2016-09-22 14:21:51 -04:00
parent 85376d854f
commit 7f24960ed8
1 changed files with 34 additions and 10 deletions

View File

@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
using System.Threading;
using BizHawk.Emulation.Common;
using System.Text;
namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
{
@ -192,6 +193,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
delegate m64p_error ConfigSetParameter(IntPtr ConfigSectionHandle, string ParamName, m64p_type ParamType, ref int ParamValue);
ConfigSetParameter m64pConfigSetParameter;
/// <summary>
/// Sets a parameter in the global config system
/// </summary>
/// <param name="ConfigSectionHandle">The handle of the section to access</param>
/// <param name="ParamName">The name of the parameter to set</param>
/// <param name="ParamType">The type of the parameter</param>
/// <param name="ParamValue">A pointer to the value to use for the parameter (must be a string)</param>
/// <returns></returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate m64p_error ConfigSetParameterStr(IntPtr ConfigSectionHandle, string ParamName, m64p_type ParamType, StringBuilder ParamValue);
ConfigSetParameterStr m64pConfigSetParameterStr;
/// <summary>
/// Saves the mupen64plus state to the provided buffer
/// </summary>
@ -513,6 +526,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
m64pCoreDetachPlugin = (CoreDetachPlugin)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDetachPlugin"), typeof(CoreDetachPlugin));
m64pConfigOpenSection = (ConfigOpenSection)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "ConfigOpenSection"), typeof(ConfigOpenSection));
m64pConfigSetParameter = (ConfigSetParameter)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "ConfigSetParameter"), typeof(ConfigSetParameter));
m64pConfigSetParameterStr = (ConfigSetParameterStr)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "ConfigSetParameter"), typeof(ConfigSetParameterStr));
m64pCoreSaveState = (savestates_save_bkm)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "savestates_save_bkm"), typeof(savestates_save_bkm));
m64pCoreLoadState = (savestates_load_bkm)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "savestates_load_bkm"), typeof(savestates_load_bkm));
m64pDebugMemGetPointer = (DebugMemGetPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugMemGetPointer"), typeof(DebugMemGetPointer));
@ -567,8 +581,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
}
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];
@ -584,6 +607,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
m64pConfigSetParameter(video_plugin_section, Parameter, m64p_type.M64TYPE_INT, ref value);
}
}
}
public int get_memory_size(N64_MEMORY id)
{