Ejemplo n.º 1
0
            public bool LoadGame(string gamePath)
            {
                GameInfo gameInfo = LoadGameInfo(gamePath);
                bool     ret      = Libretro.RetroLoadGame(ref gameInfo);

                Console.WriteLine("\nSystem information:");

                _av = new SystemAVInfo();
                Libretro.RetroGetSystemAVInfo(ref _av);

                var audioConfig = AudioSettings.GetConfiguration();

                audioConfig.sampleRate = (int)_av.timing.sample_rate;
                AudioSettings.Reset(audioConfig);

                Debug.Log("Geometry:");
                Debug.Log("Base width: " + _av.geometry.base_width);
                Debug.Log("Base height: " + _av.geometry.base_height);
                Debug.Log("Max width: " + _av.geometry.max_width);
                Debug.Log("Max height: " + _av.geometry.max_height);
                Debug.Log("Aspect ratio: " + _av.geometry.aspect_ratio);
                Debug.Log("Geometry:");
                Debug.Log("Target fps: " + _av.timing.fps);
                Debug.Log("Sample rate " + _av.timing.sample_rate);
                return(ret);
            }
Ejemplo n.º 2
0
Archivo: game.cs Proyecto: Alcaro/R.net
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            
            _libretro = new Wrapper(_core);
            _libretro.Init();
            _libretro.LoadGame("smw.sfc");
            _avinfo = _libretro.GetAVInfo();
            _frameBuffer = new Texture2D(GraphicsDevice, (int)_avinfo.geometry.base_width, (int)_avinfo.geometry.base_height);

            _sampleRate = (int)_libretro.GetAVInfo().timing.sample_rate;
            _audioBuffer = new byte[_channels * _bufferSize * bytesPerSample];
            _workingBuffer = new float[_channels, _bufferSize];

            sound = new SoundEffect(_audioBuffer, _sampleRate, AudioChannels.Stereo);
        }
Ejemplo n.º 3
0
        public void Load(string romPath)
        {
            if (AudioSampleBatchPassthroughHandler == null)
            {
                _audioSampleBatchHandler = new AudioSampleBatchHandler(audioSampleBatchCallback);
            }
            else
            {
                _audioSampleBatchHandler = AudioSampleBatchPassthroughHandler;
            }

            if (InputStatePassthroughHandler == null)
            {
                _inputStateHandler = new InputStateHandler(inputStateCallback);
            }
            else
            {
                _inputStateHandler = InputStatePassthroughHandler;
            }

            if (VideoFramePassthroughHandler == null)
            {
                _videoRefreshHandler = new VideoRefreshHandler(videoRefreshCallback);
            }
            else
            {
                _videoRefreshHandler = VideoFramePassthroughHandler;
            }

            _audioSampleHandler = new AudioSampleHandler(audioSampleCallback);
            _environmentHandler = new EnvironmentHandler(environmentCallback); // options for passing through some commands need to be done here
            _inputPollHandler   = new InputPollHandler(inputPollCallback);

            _setEnvironment(_environmentHandler);
            _setVideoRefresh(_videoRefreshHandler);
            _setInputPoll(_inputPollHandler);
            _setInputState(_inputStateHandler);
            _setAudioSample(_audioSampleHandler);
            _setAudioSampleBatch(_audioSampleBatchHandler);

            _init();

            byte[] romBytes        = File.ReadAllBytes(romPath);
            IntPtr romBytesPointer = Marshal.AllocHGlobal(romBytes.Length);

            Marshal.Copy(romBytes, 0, romBytesPointer, romBytes.Length);
            GameInfo gameInfo = new GameInfo()
            {
                Path = romPath, Data = romBytesPointer, Size = (uint)romBytes.Length, Meta = null
            };

            _loadGame(ref gameInfo);
            Marshal.FreeHGlobal(romBytesPointer);

            _systemInfo = new SystemInfo();
            _getSystemInfo(out _systemInfo);
            _systemInfo.LibraryName     = Marshal.PtrToStringAnsi(_systemInfo.LibraryNameAddress);
            _systemInfo.LibraryVersion  = Marshal.PtrToStringAnsi(_systemInfo.LibraryVersionAddress);
            _systemInfo.ValidExtensions = Marshal.PtrToStringAnsi(_systemInfo.ValidExtensionsAddress);

            _systemAVInfo = new SystemAVInfo();
            _getSystemAVInfo(out _systemAVInfo);

            _framePeriodNanoseconds = (long)(1000000000 / _systemAVInfo.Timing.FPS);

            StateSize   = (int)_serializeSize();
            _ramAddress = _getMemoryData(MemoryType.RAM);
            _ramSize    = (int)_getMemorySize(MemoryType.RAM);
        }
Ejemplo n.º 4
0
            public bool LoadGame(string gamePath)
            {
                GameInfo gameInfo = LoadGameInfo(gamePath);
                bool ret = Libretro.RetroLoadGame(ref gameInfo);

                Console.WriteLine("\nSystem information:");

                _av = new SystemAVInfo();
                Libretro.RetroGetSystemAVInfo(ref _av);

                Debug.Log("Geometry:");
                Debug.Log("Base width: " + _av.geometry.base_width);
                Debug.Log("Base height: " + _av.geometry.base_height);
                Debug.Log("Max width: " + _av.geometry.max_width);
                Debug.Log("Max height: " + _av.geometry.max_height);
                Debug.Log("Aspect ratio: " + _av.geometry.aspect_ratio);
                Debug.Log("Geometry:");
                Debug.Log("Target fps: " + _av.timing.fps);
                Debug.Log("Sample rate " + _av.timing.sample_rate);
                return ret;
            }