public void AdvanceMachineCycle(JoypadState joypadState) { _joypad.SetJoypadState(joypadState); _audioProcessingUnit.AdvanceMachineCycle(); _dmaController.AdvanceMachineCycle(); _cpuCore.AdvanceMachineCycle(); _timer.AdvanceMachineCycle(); _serialController.AdvanceMachineCycle(); _pixelProcessingUnit.AdvanceMachineCycle(); }
private JoypadState GetJoypadState() { JoypadState joypadState = 0; if (KeyboardState.IsKeyDown(Key.Enter)) { joypadState |= JoypadState.Start; } if (KeyboardState.IsKeyDown(Key.ShiftLeft)) { joypadState |= JoypadState.Select; } if (KeyboardState.IsKeyDown(Key.A)) { joypadState |= JoypadState.A; } if (KeyboardState.IsKeyDown(Key.S)) { joypadState |= JoypadState.B; } if (KeyboardState.IsKeyDown(Key.Left) && KeyboardState.IsKeyUp(Key.Right)) { joypadState |= JoypadState.Left; } if (KeyboardState.IsKeyDown(Key.Right) && KeyboardState.IsKeyUp(Key.Left)) { joypadState |= JoypadState.Right; } if (KeyboardState.IsKeyDown(Key.Up) && KeyboardState.IsKeyUp(Key.Down)) { joypadState |= JoypadState.Up; } if (KeyboardState.IsKeyDown(Key.Down) && KeyboardState.IsKeyUp(Key.Up)) { joypadState |= JoypadState.Down; } return(joypadState); }
protected override void OnUpdateFrame(FrameEventArgs e) { var timespan = _stopwatch.Elapsed; if (timespan.TotalMilliseconds >= (16 + _stopwatchOvershoot) || _fastForward == true) { _stopwatchOvershoot = 16 - timespan.TotalMilliseconds; if (_stopwatchOvershoot > 0) { _stopwatchOvershoot = 0; } _stopwatch.Restart(); _joypadState = GetJoypadState(); for (int i = 0; i < 17000; i++) { _soundPlayer.QueueAudioSample(Channels.Channel1, _gameBoy.GetAudioSample(Channels.Channel1)); _soundPlayer.QueueAudioSample(Channels.Channel2, _gameBoy.GetAudioSample(Channels.Channel2)); _soundPlayer.QueueAudioSample(Channels.Channel3, _gameBoy.GetAudioSample(Channels.Channel3)); _soundPlayer.QueueAudioSample(Channels.Channel4, _gameBoy.GetAudioSample(Channels.Channel4)); _gameBoy.AdvanceMachineCycle(_joypadState); } } if (KeyboardState.IsKeyDown(Key.Escape)) { Close(); } if (KeyboardState.IsKeyDown(Key.Tab)) { _fastForward = true; } else { _fastForward = false; } if (KeyboardState.IsKeyDown(Key.P) && LastKeyboardState.IsKeyUp(Key.P)) { if (Size.X < 640) { Size = new OpenToolkit.Mathematics.Vector2i(ClientSize.X + 160, ClientSize.Y + 144); } } if (KeyboardState.IsKeyDown(Key.M) && LastKeyboardState.IsKeyUp(Key.M)) { if (Size.X > 160) { Size = new OpenToolkit.Mathematics.Vector2i(ClientSize.X - 160, ClientSize.Y - 144); } } if (KeyboardState.IsKeyDown(Key.L) && LastKeyboardState.IsKeyUp(Key.L)) { _gameBoy.EnableLogging(); } base.OnUpdateFrame(e); }
public void SetJoypadState(JoypadState joypadState) { _joypadState = joypadState; }