Exemple #1
0
        public unsafe bool Start(Wrapper wrapper, string coreName)
        {
            bool result = false;

            try
            {
                string extension;
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
                extension = ".dll";
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                extension = ".dylib";
#elif UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
                extension = ".so";
#else
#endif

                string corePath = FileSystem.GetAbsolutePath($"{CoresDirectory}/{coreName}_libretro{extension}");
                if (FileSystem.FileExists(corePath))
                {
                    string tempDirectory = FileSystem.GetAbsolutePath(TempDirectory);
                    if (!Directory.Exists(tempDirectory))
                    {
                        _ = Directory.CreateDirectory(tempDirectory);
                    }

                    string instancePath = Path.Combine(tempDirectory, $"{coreName}_{Guid.NewGuid()}{extension}");
                    File.Copy(corePath, instancePath);

                    _dll.Load(instancePath);

                    GetCoreFunctions();

                    ApiVersion = retro_api_version();

                    SetCallbacks(wrapper);

                    retro_system_info systemInfo = new retro_system_info();
                    retro_get_system_info(ref systemInfo);

                    CoreName    = CharsToString(systemInfo.library_name);
                    CoreVersion = CharsToString(systemInfo.library_version);
                    if (systemInfo.valid_extensions != null)
                    {
                        ValidExtensions = CharsToString(systemInfo.valid_extensions).Split('|');
                    }
                    NeedFullPath = systemInfo.need_fullpath;
                    BlockExtract = systemInfo.block_extract;

                    retro_set_environment(_environmentCallback);
                    retro_init();
                    retro_set_video_refresh(_videoRefreshCallback);
                    retro_set_audio_sample(_audioSampleCallback);
                    retro_set_audio_sample_batch(_audioSampleBatchCallback);
                    retro_set_input_poll(_inputPollCallback);
                    retro_set_input_state(_inputStateCallback);

                    Initialized = true;
                    result      = true;
                }
                else
                {
                    Log.Error($"Core '{coreName}' at path '{corePath}' not found.", "Libretro.LibretroCore.Start");
                }
            }
            catch (Exception e)
            {
                Log.Exception(e, "Libretro.LibretroCore.Start");
            }

            return(result);
        }
Exemple #2
0
 public static extern void retro_get_system_info(out retro_system_info info);
Exemple #3
0
 public void GetSystemInfo(ref retro_system_info info)
 {
     _getSystemInfo(ref info);
 }