Пример #1
0
        private void logCallback(LogLevel level, string fmt, IntPtr arg0, IntPtr arg1, IntPtr arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5, IntPtr arg6, IntPtr arg7, IntPtr arg8, IntPtr arg9)
        {
            if (LogHandler != null)
            {
                StringBuilder logMessage = new StringBuilder(256);

                do
                {
                    int length;
                    if (_os == OS.OSX)
                    {
                        length = OSXAPI.snprintf(logMessage, (uint)logMessage.Capacity, fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
                    }
                    else
                    {
                        length = WindowsAPI._snprintf(logMessage, (uint)logMessage.Capacity, fmt, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
                    }

                    if ((length <= 0) || (length >= logMessage.Capacity))
                    {
                        logMessage.Capacity *= 2;
                        continue;
                    }

                    logMessage.Length = length;
                    break;
                } while (logMessage.Length >= logMessage.Capacity);

                LogHandler(level, logMessage.ToString());
            }
        }
Пример #2
0
 public T GetDelegate <T>(string libretroFunctionName)
 {
     if (_os == OS.OSX)
     {
         return((T)Convert.ChangeType(Marshal.GetDelegateForFunctionPointer(OSXAPI.dlsym(_libretroDLL, libretroFunctionName), typeof(T)), typeof(T)));
     }
     else
     {
         return((T)Convert.ChangeType(Marshal.GetDelegateForFunctionPointer(WindowsAPI.GetProcAddress(_libretroDLL, libretroFunctionName), typeof(T)), typeof(T)));
     }
 }
Пример #3
0
        public Core(OS os, string libretroDLLPath, string systemDirectoryPath)
        {
            _os = os;
            _systemDirectoryPath = systemDirectoryPath;

            _frameTimer = new Stopwatch();

            _variablesDirty = true;

            Variables = new List <Variable>();
            Inputs    = new List <Input>();

            if (_os == OS.OSX)
            {
                _libretroDLL = OSXAPI.dlopen(libretroDLLPath, 2);
            }
            else
            {
                _libretroDLL = WindowsAPI.LoadLibrary(libretroDLLPath);
            }

            _apiVersion              = GetDelegate <APIVersionSignature>("retro_api_version");
            _deinit                  = GetDelegate <DeinitSignature>("retro_deinit");
            _getMemoryData           = GetDelegate <GetMemoryDataSignature>("retro_get_memory_data");
            _getMemorySize           = GetDelegate <GetMemorySizeSignature>("retro_get_memory_size");
            _getSystemAVInfo         = GetDelegate <GetSystemAVInfoSignature>("retro_get_system_av_info");
            _getSystemInfo           = GetDelegate <GetSystemInfoSignature>("retro_get_system_info");
            _init                    = GetDelegate <InitSignature>("retro_init");
            _loadGame                = GetDelegate <LoadGameSignature>("retro_load_game");
            _reset                   = GetDelegate <ResetSignature>("retro_reset");
            _run                     = GetDelegate <RunSignature>("retro_run");
            _serialize               = GetDelegate <SerializeSignature>("retro_serialize");
            _serializeSize           = GetDelegate <SerializeSizeSignature>("retro_serialize_size");
            _setAudioSample          = GetDelegate <SetAudioSampleSignature>("retro_set_audio_sample");
            _setAudioSampleBatch     = GetDelegate <SetAudioSampleBatchSignature>("retro_set_audio_sample_batch");
            _setControllerPortDevice = GetDelegate <SetControllerPortDeviceSignature>("retro_set_controller_port_device");
            _setEnvironment          = GetDelegate <SetEnvironmentSignature>("retro_set_environment");
            _setInputPoll            = GetDelegate <SetInputPollSignature>("retro_set_input_poll");
            _setInputState           = GetDelegate <SetInputStateSignature>("retro_set_input_state");
            _setVideoRefresh         = GetDelegate <SetVideoRefreshSignature>("retro_set_video_refresh");
            _unloadGame              = GetDelegate <UnloadGameSignature>("retro_unload_game");
            _unserialize             = GetDelegate <UnserializeSignature>("retro_unserialize");
        }