Shortcuts: Added increase/decrease speed shortcuts

This commit is contained in:
Souryo 2016-09-11 08:29:34 -04:00
parent 732187a0ab
commit 477f663cd5
14 changed files with 89 additions and 52 deletions

View File

@ -222,6 +222,8 @@ struct EmulatorKeyMappings
uint32_t VsServiceButton;
uint32_t TakeScreenshot;
uint32_t IncreaseSpeed;
uint32_t DecreaseSpeed;
};
struct EmulatorKeyMappingSet
@ -477,9 +479,32 @@ public:
}
//0: No limit, Number: % of default speed (50/60fps)
static void SetEmulationSpeed(uint32_t emulationSpeed)
static void SetEmulationSpeed(uint32_t emulationSpeed, bool displaySpeed = false)
{
_emulationSpeed = emulationSpeed;
if(_emulationSpeed != emulationSpeed) {
_emulationSpeed = emulationSpeed;
if(displaySpeed) {
MessageManager::DisplayMessage("EmulationSpeed", _emulationSpeed == 0 ? "EmulationMaximumSpeed" : "EmulationSpeedPercent", std::to_string(_emulationSpeed));
}
}
}
static void IncreaseEmulationSpeed()
{
if(_emulationSpeed > 0 && _emulationSpeed < 450) {
EmulationSettings::SetEmulationSpeed(_emulationSpeed + (_emulationSpeed < 100 ? 25 : 50), true);
} else {
EmulationSettings::SetEmulationSpeed(0, true);
}
}
static void DecreaseEmulationSpeed()
{
if(_emulationSpeed == 0) {
EmulationSettings::SetEmulationSpeed(450, true);
} else if(_emulationSpeed > 25) {
EmulationSettings::SetEmulationSpeed(_emulationSpeed - (_emulationSpeed <= 100 ? 25 : 50), true);
}
}
static void SetTurboSpeed(uint32_t turboSpeed)

View File

@ -54,6 +54,14 @@ void ShortcutKeyHandler::CheckMappedKeys(EmulatorKeyMappings mappings)
EmulationSettings::ClearFlags(EmulationFlags::Turbo);
}
if(DetectKeyPress(mappings.IncreaseSpeed)) {
EmulationSettings::IncreaseEmulationSpeed();
}
if(DetectKeyPress(mappings.DecreaseSpeed)) {
EmulationSettings::DecreaseEmulationSpeed();
}
if(DetectKeyPress(mappings.TakeScreenshot)) {
VideoDecoder::GetInstance()->TakeScreenshot();
}

View File

@ -54,8 +54,10 @@
<Message ID="NoMatchingCheats">The selected cheat file ({0}) contains no cheats that match the selected game.</Message>
<Message ID="EmulatorShortcutMappings_FastForward">Fast Forward</Message>
<Message ID="EmulatorShortcutMappings_IncreaseSpeed">Increase Speed</Message>
<Message ID="EmulatorShortcutMappings_DecreaseSpeed">Decrease Speed</Message>
<Message ID="EmulatorShortcutMappings_Pause">Pause</Message>
<Message ID="EmulatorShortcutMappings_Reset">Reset</Message>
<Message ID="EmulatorShortcutMappings_Reset">Reset</Message>
<Message ID="EmulatorShortcutMappings_TakeScreenshot">Take Screenshot</Message>
<Message ID="EmulatorShortcutMappings_SwitchDiskSide">FDS - Switch Side</Message>
<Message ID="EmulatorShortcutMappings_InsertNextDisk">FDS - Insert Next Disk</Message>

View File

@ -496,6 +496,8 @@
<Message ID="InvalidCheatFile">El archivo seleccionado ({0}) no es un archivo de trucos válido.</Message>
<Message ID="InvalidXmlFile">El archivo seleccionado ({0}) no es un archivo XML válido.</Message>
<Message ID="EmulatorShortcutMappings_FastForward">Avance rápido</Message>
<Message ID="EmulatorShortcutMappings_IncreaseSpeed">Increase Speed</Message>
<Message ID="EmulatorShortcutMappings_DecreaseSpeed">Decrease Speed</Message>
<Message ID="EmulatorShortcutMappings_Pause">Pausa</Message>
<Message ID="EmulatorShortcutMappings_Reset">Reiniciar</Message>
<Message ID="EmulatorShortcutMappings_TakeScreenshot">Captura de pantalla</Message>

View File

@ -514,6 +514,8 @@
<Message ID="NoMatchingCheats">Le fichier sélectionné ({0}) ne contient aucun code correspondant au jeu sélectionné.</Message>
<Message ID="EmulatorShortcutMappings_FastForward">Avance rapide</Message>
<Message ID="EmulatorShortcutMappings_IncreaseSpeed">Augmenter la vitesse</Message>
<Message ID="EmulatorShortcutMappings_DecreaseSpeed">Réduire la vitesse</Message>
<Message ID="EmulatorShortcutMappings_Pause">Pause</Message>
<Message ID="EmulatorShortcutMappings_Reset">Reset</Message>
<Message ID="EmulatorShortcutMappings_TakeScreenshot">Capture d'écran</Message>

View File

@ -496,6 +496,8 @@
<Message ID="NoMatchingCheats">このファイル({0})に選択されたゲームに該当するチートコードを見つかりませんでした。</Message>
<Message ID="EmulatorShortcutMappings_FastForward">早送り</Message>
<Message ID="EmulatorShortcutMappings_IncreaseSpeed">速度を上げる</Message>
<Message ID="EmulatorShortcutMappings_DecreaseSpeed">速度を下げる</Message>
<Message ID="EmulatorShortcutMappings_Pause">ポーズ</Message>
<Message ID="EmulatorShortcutMappings_Reset">リセット</Message>
<Message ID="EmulatorShortcutMappings_TakeScreenshot">スクリーンショットを撮る</Message>

View File

@ -505,6 +505,8 @@
<Message ID="NoMatchingCheats">Выбранный Cheat файл ({0}) не содержит читов для данной игры.</Message>
<Message ID="EmulatorShortcutMappings_FastForward">Перемотка</Message>
<Message ID="EmulatorShortcutMappings_IncreaseSpeed">Increase Speed</Message>
<Message ID="EmulatorShortcutMappings_DecreaseSpeed">Decrease Speed</Message>
<Message ID="EmulatorShortcutMappings_Pause">Пауза</Message>
<Message ID="EmulatorShortcutMappings_Reset">Сброс</Message>
<Message ID="EmulatorShortcutMappings_TakeScreenshot">Сделать сриншот</Message>

View File

@ -504,6 +504,8 @@
<Message ID="NoMatchingCheats">Обраний Cheat файл ({0}) не містить читов для даної гри.</Message>
<Message ID="EmulatorShortcutMappings_FastForward">Перемотка</Message>
<Message ID="EmulatorShortcutMappings_IncreaseSpeed">Increase Speed</Message>
<Message ID="EmulatorShortcutMappings_DecreaseSpeed">Decrease Speed</Message>
<Message ID="EmulatorShortcutMappings_Pause">Пауза</Message>
<Message ID="EmulatorShortcutMappings_Reset">Скидання</Message>
<Message ID="EmulatorShortcutMappings_TakeScreenshot">Зробити скріншот</Message>

View File

@ -51,7 +51,7 @@
this.gridShortcuts.MultiSelect = false;
this.gridShortcuts.Name = "gridShortcuts";
this.gridShortcuts.RowHeadersVisible = false;
this.gridShortcuts.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.gridShortcuts.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.gridShortcuts.Size = new System.Drawing.Size(448, 248);
this.gridShortcuts.TabIndex = 2;
this.gridShortcuts.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridShortcuts_CellContentClick);
@ -63,7 +63,7 @@
this.colAction.ReadOnly = true;
this.colAction.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.colAction.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.colAction.Width = 250;
this.colAction.Width = 233;
//
// colBinding1
//

View File

@ -18,6 +18,7 @@ namespace Mesen.GUI.Forms.Config
{
InitializeComponent();
ConfigManager.Config.EmulationInfo.EmulationSpeed = InteropEmu.GetEmulationSpeed();
Entity = ConfigManager.Config.EmulationInfo;
AddBinding("EmulationSpeed", nudEmulationSpeed);

View File

@ -155,6 +155,7 @@ namespace Mesen.GUI.Forms
this.mnuTestRecordTest = new System.Windows.Forms.ToolStripMenuItem();
this.mnuTestStopRecording = new System.Windows.Forms.ToolStripMenuItem();
this.mnuRunAllTests = new System.Windows.Forms.ToolStripMenuItem();
this.mnuRunAllGameTests = new System.Windows.Forms.ToolStripMenuItem();
this.mnuDebugger = new System.Windows.Forms.ToolStripMenuItem();
this.mnuLogWindow = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
@ -165,7 +166,6 @@ namespace Mesen.GUI.Forms
this.mnuReportBug = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator();
this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem();
this.mnuRunAllGameTests = new System.Windows.Forms.ToolStripMenuItem();
this.panelRenderer.SuspendLayout();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
@ -448,8 +448,9 @@ namespace Mesen.GUI.Forms
this.mnuShowFPS});
this.mnuEmulationSpeed.Image = global::Mesen.GUI.Properties.Resources.Speed;
this.mnuEmulationSpeed.Name = "mnuEmulationSpeed";
this.mnuEmulationSpeed.Size = new System.Drawing.Size(135, 22);
this.mnuEmulationSpeed.Size = new System.Drawing.Size(152, 22);
this.mnuEmulationSpeed.Text = "Speed";
this.mnuEmulationSpeed.DropDownOpening += new System.EventHandler(this.mnuEmulationSpeed_DropDownOpening);
//
// mnuEmuSpeedNormal
//
@ -549,7 +550,7 @@ namespace Mesen.GUI.Forms
this.mnuFullscreen});
this.mnuVideoScale.Image = global::Mesen.GUI.Properties.Resources.Fullscreen;
this.mnuVideoScale.Name = "mnuVideoScale";
this.mnuVideoScale.Size = new System.Drawing.Size(135, 22);
this.mnuVideoScale.Size = new System.Drawing.Size(152, 22);
this.mnuVideoScale.Text = "Video Size";
//
// mnuScale1x
@ -657,7 +658,7 @@ namespace Mesen.GUI.Forms
this.toolStripMenuItem19,
this.mnuBilinearInterpolation});
this.mnuVideoFilter.Name = "mnuVideoFilter";
this.mnuVideoFilter.Size = new System.Drawing.Size(135, 22);
this.mnuVideoFilter.Size = new System.Drawing.Size(152, 22);
this.mnuVideoFilter.Text = "Video Filter";
//
// mnuNoneFilter
@ -840,7 +841,7 @@ namespace Mesen.GUI.Forms
this.mnuRegionDendy});
this.mnuRegion.Image = global::Mesen.GUI.Properties.Resources.Globe;
this.mnuRegion.Name = "mnuRegion";
this.mnuRegion.Size = new System.Drawing.Size(135, 22);
this.mnuRegion.Size = new System.Drawing.Size(152, 22);
this.mnuRegion.Text = "Region";
//
// mnuRegionAuto
@ -874,13 +875,13 @@ namespace Mesen.GUI.Forms
// toolStripMenuItem10
//
this.toolStripMenuItem10.Name = "toolStripMenuItem10";
this.toolStripMenuItem10.Size = new System.Drawing.Size(132, 6);
this.toolStripMenuItem10.Size = new System.Drawing.Size(149, 6);
//
// mnuAudioConfig
//
this.mnuAudioConfig.Image = global::Mesen.GUI.Properties.Resources.Audio;
this.mnuAudioConfig.Name = "mnuAudioConfig";
this.mnuAudioConfig.Size = new System.Drawing.Size(135, 22);
this.mnuAudioConfig.Size = new System.Drawing.Size(152, 22);
this.mnuAudioConfig.Text = "Audio";
this.mnuAudioConfig.Click += new System.EventHandler(this.mnuAudioConfig_Click);
//
@ -888,7 +889,7 @@ namespace Mesen.GUI.Forms
//
this.mnuInput.Image = global::Mesen.GUI.Properties.Resources.Controller;
this.mnuInput.Name = "mnuInput";
this.mnuInput.Size = new System.Drawing.Size(135, 22);
this.mnuInput.Size = new System.Drawing.Size(152, 22);
this.mnuInput.Text = "Input";
this.mnuInput.Click += new System.EventHandler(this.mnuInput_Click);
//
@ -896,7 +897,7 @@ namespace Mesen.GUI.Forms
//
this.mnuVideoConfig.Image = global::Mesen.GUI.Properties.Resources.Video;
this.mnuVideoConfig.Name = "mnuVideoConfig";
this.mnuVideoConfig.Size = new System.Drawing.Size(135, 22);
this.mnuVideoConfig.Size = new System.Drawing.Size(152, 22);
this.mnuVideoConfig.Text = "Video";
this.mnuVideoConfig.Click += new System.EventHandler(this.mnuVideoConfig_Click);
//
@ -904,20 +905,20 @@ namespace Mesen.GUI.Forms
//
this.mnuEmulationConfig.Image = global::Mesen.GUI.Properties.Resources.DipSwitches;
this.mnuEmulationConfig.Name = "mnuEmulationConfig";
this.mnuEmulationConfig.Size = new System.Drawing.Size(135, 22);
this.mnuEmulationConfig.Size = new System.Drawing.Size(152, 22);
this.mnuEmulationConfig.Text = "Emulation";
this.mnuEmulationConfig.Click += new System.EventHandler(this.mnuEmulationConfig_Click);
//
// toolStripMenuItem11
//
this.toolStripMenuItem11.Name = "toolStripMenuItem11";
this.toolStripMenuItem11.Size = new System.Drawing.Size(132, 6);
this.toolStripMenuItem11.Size = new System.Drawing.Size(149, 6);
//
// mnuPreferences
//
this.mnuPreferences.Image = global::Mesen.GUI.Properties.Resources.Cog;
this.mnuPreferences.Name = "mnuPreferences";
this.mnuPreferences.Size = new System.Drawing.Size(135, 22);
this.mnuPreferences.Size = new System.Drawing.Size(152, 22);
this.mnuPreferences.Text = "Preferences";
this.mnuPreferences.Click += new System.EventHandler(this.mnuPreferences_Click);
//
@ -1203,6 +1204,13 @@ namespace Mesen.GUI.Forms
this.mnuRunAllTests.Text = "Run all tests";
this.mnuRunAllTests.Click += new System.EventHandler(this.mnuRunAllTests_Click);
//
// mnuRunAllGameTests
//
this.mnuRunAllGameTests.Name = "mnuRunAllGameTests";
this.mnuRunAllGameTests.Size = new System.Drawing.Size(192, 22);
this.mnuRunAllGameTests.Text = "Run all game tests";
this.mnuRunAllGameTests.Click += new System.EventHandler(this.mnuRunAllGameTests_Click);
//
// mnuDebugger
//
this.mnuDebugger.Name = "mnuDebugger";
@ -1277,13 +1285,6 @@ namespace Mesen.GUI.Forms
this.mnuAbout.Text = "About";
this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
//
// mnuRunAllGameTests
//
this.mnuRunAllGameTests.Name = "mnuRunAllGameTests";
this.mnuRunAllGameTests.Size = new System.Drawing.Size(192, 22);
this.mnuRunAllGameTests.Text = "Run all game tests";
this.mnuRunAllGameTests.Click += new System.EventHandler(this.mnuRunAllGameTests_Click);
//
// frmMain
//
this.AllowDrop = true;

View File

@ -147,6 +147,7 @@ namespace Mesen.GUI.Forms
_debugger.Close();
}
ConfigManager.Config.EmulationInfo.EmulationSpeed = InteropEmu.GetEmulationSpeed();
ConfigManager.Config.VideoInfo.VideoScale = _regularScale;
ConfigManager.ApplyChanges();
@ -216,12 +217,11 @@ namespace Mesen.GUI.Forms
mnuEmuSpeedHalf.Tag = 50;
mnuEmuSpeedQuarter.Tag = 25;
mnuEmuSpeedMaximumSpeed.Tag = 0;
UpdateEmulationSpeedMenu();
}
private void UpdateEmulationSpeedMenu()
{
ConfigManager.Config.EmulationInfo.EmulationSpeed = InteropEmu.GetEmulationSpeed();
foreach(ToolStripMenuItem item in new ToolStripMenuItem[] { mnuEmuSpeedDouble, mnuEmuSpeedHalf, mnuEmuSpeedNormal, mnuEmuSpeedQuarter, mnuEmuSpeedTriple, mnuEmuSpeedMaximumSpeed }) {
item.Checked = ((int)item.Tag == ConfigManager.Config.EmulationInfo.EmulationSpeed);
}
@ -229,41 +229,24 @@ namespace Mesen.GUI.Forms
private void SetEmulationSpeed(uint emulationSpeed)
{
if(emulationSpeed == 0) {
InteropEmu.DisplayMessage("EmulationSpeed", "EmulationMaximumSpeed");
} else {
InteropEmu.DisplayMessage("EmulationSpeed", "EmulationSpeedPercent", emulationSpeed.ToString());
}
ConfigManager.Config.EmulationInfo.EmulationSpeed = emulationSpeed;
ConfigManager.ApplyChanges();
UpdateEmulationSpeedMenu();
EmulationInfo.ApplyConfig();
}
private void mnuEmulationSpeed_DropDownOpening(object sender, EventArgs e)
{
UpdateEmulationSpeedMenu();
}
private void mnuIncreaseSpeed_Click(object sender, EventArgs e)
{
if(ConfigManager.Config.EmulationInfo.EmulationSpeed > 0) {
if(ConfigManager.Config.EmulationInfo.EmulationSpeed < 100) {
SetEmulationSpeed(ConfigManager.Config.EmulationInfo.EmulationSpeed + 25);
} else if(ConfigManager.Config.EmulationInfo.EmulationSpeed < 450) {
SetEmulationSpeed(ConfigManager.Config.EmulationInfo.EmulationSpeed + 50);
} else {
SetEmulationSpeed(0);
}
}
InteropEmu.IncreaseEmulationSpeed();
}
private void mnuDecreaseSpeed_Click(object sender, EventArgs e)
{
if(ConfigManager.Config.EmulationInfo.EmulationSpeed == 0) {
SetEmulationSpeed(450);
} else if(ConfigManager.Config.EmulationInfo.EmulationSpeed <= 100) {
if(ConfigManager.Config.EmulationInfo.EmulationSpeed > 25) {
SetEmulationSpeed(ConfigManager.Config.EmulationInfo.EmulationSpeed - 25);
}
} else {
SetEmulationSpeed(ConfigManager.Config.EmulationInfo.EmulationSpeed - 50);
}
InteropEmu.DecreaseEmulationSpeed();
}
private void mnuEmuSpeedMaximumSpeed_Click(object sender, EventArgs e)
@ -1538,7 +1521,6 @@ namespace Mesen.GUI.Forms
private void mnuEmulationConfig_Click(object sender, EventArgs e)
{
new frmEmulationConfig().ShowDialog(sender);
UpdateEmulationSpeedMenu();
}
private void InitializeNsfMode(bool updateTextOnly = false, bool gameLoaded = false)

View File

@ -136,6 +136,9 @@ namespace Mesen.GUI
[DllImport(DLLPath)] public static extern void SetReverbParameters(double strength, double delay);
[DllImport(DLLPath)] public static extern void SetNesModel(NesModel model);
[DllImport(DLLPath)] public static extern void SetEmulationSpeed(UInt32 emulationSpeed);
[DllImport(DLLPath)] public static extern void IncreaseEmulationSpeed();
[DllImport(DLLPath)] public static extern void DecreaseEmulationSpeed();
[DllImport(DLLPath)] public static extern UInt32 GetEmulationSpeed();
[DllImport(DLLPath)] public static extern void SetTurboSpeed(UInt32 turboSpeed);
[DllImport(DLLPath)] public static extern void SetOverclockRate(UInt32 overclockRate, [MarshalAs(UnmanagedType.I1)]bool adjustApu);
[DllImport(DLLPath)] public static extern void SetPpuNmiConfig(UInt32 extraScanlinesBeforeNmi, UInt32 extraScanlineAfterNmi);
@ -773,6 +776,8 @@ namespace Mesen.GUI
public UInt32 VsServiceButton;
public UInt32 TakeScreenshot;
public UInt32 IncreaseSpeed;
public UInt32 DecreaseSpeed;
}
public struct InteropCheatInfo

View File

@ -333,7 +333,10 @@ namespace InteropEmu {
DllExport void __stdcall SetNesModel(uint32_t model) { EmulationSettings::SetNesModel((NesModel)model); }
DllExport void __stdcall SetOverscanDimensions(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom) { EmulationSettings::SetOverscanDimensions(left, right, top, bottom); }
DllExport void __stdcall SetEmulationSpeed(uint32_t emulationSpeed) { EmulationSettings::SetEmulationSpeed(emulationSpeed); }
DllExport void __stdcall SetEmulationSpeed(uint32_t emulationSpeed) { EmulationSettings::SetEmulationSpeed(emulationSpeed, true); }
DllExport void __stdcall IncreaseEmulationSpeed() { EmulationSettings::IncreaseEmulationSpeed(); }
DllExport void __stdcall DecreaseEmulationSpeed() { EmulationSettings::DecreaseEmulationSpeed(); }
DllExport uint32_t __stdcall GetEmulationSpeed() { return EmulationSettings::GetEmulationSpeed(true); }
DllExport void __stdcall SetTurboSpeed(uint32_t turboSpeed) { EmulationSettings::SetTurboSpeed(turboSpeed); }
DllExport void __stdcall SetOverclockRate(uint32_t overclockRate, bool adjustApu) { EmulationSettings::SetOverclockRate(overclockRate, adjustApu); }
DllExport void __stdcall SetPpuNmiConfig(uint32_t extraScanlinesBeforeNmi, uint32_t extraScanlinesAfterNmi) { EmulationSettings::SetPpuNmiConfig(extraScanlinesBeforeNmi, extraScanlinesAfterNmi); }