Beispiel #1
0
        public SceneManager(
            IRenderer renderer,
            InputProcessor inputProcessor,
            EventProcessor eventProcessor,
            IEnumerable <IScene> scenes,
            Config config,
            StateManager stateManager,
            EventBus eventBus
            )
        {
            _buttons = (GameControllerButton[])Enum.GetValues(typeof(GameControllerButton));

            _renderer = renderer;
            _renderer.Initialize();
            _inputProcessor = inputProcessor;
            _eventProcessor = eventProcessor;

            _scenes = scenes.ToArray();
            Array.Sort(_scenes);

            _config = config;

            _nopTimer = new Stopwatch();
            _nopTimer.Start();

            // Audio Related Stuff
            _tmpAudioBuffer = new float[8192];
            _xtAudio        = new XtAudio(null, IntPtr.Zero, _traceCallback, _fatalCallback);
            var xtService = XtAudio.GetServiceBySystem(XtSystem.Wasapi);

//            Console.WriteLine("  Capabilities: " + XtPrint.CapabilitiesToString(xtService.GetCapabilities()));
//            for (int d = 0; d < xtService.GetDeviceCount(); d++)
//                using (XtDevice device = xtService.OpenDevice(d)) {
//
//                    Console.WriteLine("  Device " + device.GetName() + ":");
//                    Console.WriteLine("    System: " + device.GetSystem());
//                    Console.WriteLine("    Current mix: " + device.GetMix());
//                    Console.WriteLine("    Input channels: " + device.GetChannelCount(false));
//                    Console.WriteLine("    Output channels: " + device.GetChannelCount(true));
//                    Console.WriteLine("    Interleaved access: " + device.SupportsAccess(true));
//                    Console.WriteLine("    Non-interleaved access: " + device.SupportsAccess(false));
//                }
//            _xtDevice = xtService.OpenDevice(9);
            _xtDevice = xtService.OpenDefaultDevice(true);
            var audioFormat = new XtFormat(new XtMix(_config.SampleRate, XtSample.Int16), 0, 0, 2, 0);
            var xtBuffer    = _xtDevice.GetBuffer(audioFormat);

            _xtStream = _xtDevice.OpenStream(audioFormat, true, true, xtBuffer.current, RenderAudioCallback, XRunCallback, null);
            _xtStream.Start();

            stateManager.Initialize();
            stateManager.ScanForGames();
//            var game = stateManager.GetGameById("240pSuite");
            var game = stateManager.GetGameById("Megaman X6");

//            var game = stateManager.GetGameById("R.P.M. Racing (Japan)");
//            var game = stateManager.GetGameById("Super Mario World 2 - Yoshi's Island (USA) (Rev 1)");
            eventBus.Publish(new LoadGameEvent(game));
        }
Beispiel #2
0
 public static string FormatToString(XtFormat format)
 {
     XtNative.Format native = XtNative.Format.ToNative(format);
     return(XtNative.FreeStringFromUtf8(XtNative.XtPrintFormatToString(ref native)));
 }