private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { //write the pokemon red ROM to the disk. var romPath = Path.Combine(Environment.CurrentDirectory, "PokemonCrystal.gba"); if (!File.Exists(romPath)) { File.WriteAllBytes(romPath, FileResources.PokemonCrystal); } //start the emulator with 20X normal speed. await _gameboy.Start(romPath, GameboyArea, SpeedMultiplier); _startTime = File.GetLastWriteTime(Path.Combine(_gameboy.EmulatorDirectory, "bgb.exe")); await Task.Delay(5000); //enable turbo. _gameboy.StartSpeedMode(); await Task.Delay(1000); //now load the game. _gameboy.TapStart(); await Task.Delay(1000); _gameboy.LoadState(); await Task.Delay(1000); //now that the game is running, start simulating random keypresses. StartKeyPressLoop(); StartSlowMotionLoop(); StartBackupLoop(); }
async void MainWindow_Loaded(object sender, RoutedEventArgs e) { //launch camera stuff. var cameraPicker = new CameraDevicePickerWindow(); cameraPicker.ShowDialog(); var camera = cameraPicker.ChosenCamera; if (camera == null) { throw new InvalidOperationException("Can't run this sample application without a camera attached to your computer. Restart the program and try again."); } var captureDevice = new VideoCaptureDevice(camera.MonikerString); captureDevice.NewFrame += captureDevice_NewFrame; captureDevice.Start(); //write the pokemon red ROM to the disk. var romPath = Path.Combine(Environment.CurrentDirectory, "PokemonRed.gb"); if (!File.Exists(romPath)) { File.WriteAllBytes(romPath, FileResources.PokemonRed); } await _engine.Start(romPath, GameboyArea); //now load the game. _engine.TapStart(); _engine.LoadState(); //start randomize loop. StartRandomizeLoop(); }