public void SetupCallbacks( RetroEnvironment retroEnvironment, RetroVideoRefresh retroVideoRefresh, RetroAudioSample retroAudioSample, RetroAudioSampleBatch retroAudioSampleBatch, RetroInputPoll retroInputPoll, RetroInputState retroInputState, RetroLogCallbackWrapper retroLogCallbackWrapper ) { _wrappedRetroEnvironment = retroEnvironment; _retroLogCallbackWrapper = retroLogCallbackWrapper; unsafe { _retroEnvironment = _internalRetroEnvironment; _internalRetroLogPrintf = _retroLogCallback; } _delegateHandles.Add(GCHandle.Alloc(_retroEnvironment)); _delegateHandles.Add(GCHandle.Alloc(_internalRetroLogPrintf)); _delegateHandles.Add(GCHandle.Alloc(retroVideoRefresh)); _delegateHandles.Add(GCHandle.Alloc(retroAudioSample)); _delegateHandles.Add(GCHandle.Alloc(retroAudioSampleBatch)); _delegateHandles.Add(GCHandle.Alloc(retroInputPoll)); _delegateHandles.Add(GCHandle.Alloc(retroInputState)); _retroSetEnvironment(_retroEnvironment); _retroSetVideoRefresh(retroVideoRefresh); _retroSetAudioSample(retroAudioSample); _retroSetAudioSampleBatch(retroAudioSampleBatch); _retroSetInputPoll(retroInputPoll); _retroSetInputState(retroInputState); }
public RetroCore(string dllPath, Config config, InputProcessor inputProcessor, IRenderer renderer) { _systemDirectory = Path.Combine( Environment.CurrentDirectory, "system" ); _delegateDictionary = new Dictionary <Delegate, GCHandle>(); _inputDescriptors = new List <InputDescriptor>(); _coreVariables = new Dictionary <string, CoreVariable>(); RetroLogCallbackWrapper logCallback = _retroLogCallback; _delegateDictionary.Add(logCallback, GCHandle.Alloc(logCallback)); _core = new Core(dllPath); _core.RetroGetSystemInfo(out var systemInfo); _coreName = Marshal.PtrToStringAnsi(systemInfo.LibraryName); unsafe { _core.SetupCallbacks( _environment, _videoRefresh, _audioSample, _audioSampleBatch, _inputPoll, _inputState, _retroLogCallback ); } GameLoaded = false; // Audio Buffers _temporaryInputAudioBuffer = new short[8192]; _temporaryPreconversionAudioBuffer = new short[8192]; _temporaryConversionBuffer = new float[8192]; _temporaryStretcherBuffer = new float[2][]; _temporaryStretcherBuffer[0] = new float[8192]; _temporaryStretcherBuffer[1] = new float[8192]; _temporaryResampleBuffer = new float[8192]; _temporaryOutputBuffer = new float[8192]; _audioBuffer = new CircularBuffer <float>(8192); _temporaryBuffer = new CircularBuffer <short>(8192); _config = config; _inputProcessor = inputProcessor; _renderer = renderer; _core.RetroInit(); }