From 43811ae7acec0f46035b62db82c0e864ca9844ae Mon Sep 17 00:00:00 2001 From: Sour Date: Sun, 17 Nov 2019 18:44:36 -0500 Subject: [PATCH] UI: Added "reload rom" option and changed power cycle to not reload from disk --- Core/BaseMapper.cpp | 35 ++++++------------- Core/BaseMapper.h | 7 ++-- Core/CheatManager.cpp | 29 ++++++++------- Core/CheatManager.h | 4 +-- Core/Console.cpp | 29 ++++++++++----- Core/Console.h | 3 +- Core/EmulationSettings.h | 1 + Core/MemoryManager.cpp | 4 +-- Docs/content/configuration/Preferences.md | 5 +-- GUI.NET/Dependencies/resources.ca.xml | 2 ++ GUI.NET/Dependencies/resources.en.xml | 2 ++ GUI.NET/Dependencies/resources.es.xml | 2 ++ GUI.NET/Dependencies/resources.fr.xml | 2 ++ GUI.NET/Dependencies/resources.it.xml | 2 ++ GUI.NET/Dependencies/resources.ja.xml | 2 ++ GUI.NET/Dependencies/resources.pt.xml | 2 ++ GUI.NET/Dependencies/resources.ru.xml | 2 ++ GUI.NET/Dependencies/resources.uk.xml | 2 ++ GUI.NET/Dependencies/resources.zh.xml | 2 ++ GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs | 1 + GUI.NET/Forms/frmMain.Designer.cs | 27 +++++++++----- GUI.NET/Forms/frmMain.cs | 10 +++--- GUI.NET/InteropEmu.cs | 2 ++ InteropDLL/ConsoleWrapper.cpp | 1 + 24 files changed, 108 insertions(+), 70 deletions(-) diff --git a/Core/BaseMapper.cpp b/Core/BaseMapper.cpp index 25f997f6..8149ae1f 100644 --- a/Core/BaseMapper.cpp +++ b/Core/BaseMapper.cpp @@ -433,11 +433,6 @@ string BaseMapper::GetBatteryFilename() { return FolderUtilities::CombinePath(FolderUtilities::GetSaveFolder(), FolderUtilities::GetFilename(_romInfo.RomName, false) + ".sav"); } - -void BaseMapper::RestoreOriginalPrgRam() -{ - memcpy(_prgRom, _originalPrgRom.data(), _originalPrgRom.size()); -} void BaseMapper::InitializeChrRam(int32_t chrRamSize) { @@ -637,8 +632,6 @@ void BaseMapper::Initialize(RomData &romData) //Load battery data if present LoadBattery(); - ApplyCheats(); - _romInfo.HasChrRam = HasChrRam(); } @@ -652,24 +645,6 @@ BaseMapper::~BaseMapper() delete[] _nametableRam; } -void BaseMapper::ProcessNotification(ConsoleNotificationType type, void* parameter) -{ - switch(type) { - case ConsoleNotificationType::CheatAdded: - case ConsoleNotificationType::CheatRemoved: - ApplyCheats(); - break; - default: - break; - } -} - -void BaseMapper::ApplyCheats() -{ - RestoreOriginalPrgRam(); - _console->GetCheatManager()->ApplyPrgCodes(_prgRom, _prgSize); -} - void BaseMapper::GetMemoryRanges(MemoryRanges &ranges) { if(_romInfo.System == GameSystem::VsSystem) { @@ -1267,4 +1242,14 @@ bool BaseMapper::HasPrgChrChanges() } } return false; +} + +void BaseMapper::CopyPrgChrRom(shared_ptr mapper) +{ + if(_prgSize == mapper->_prgSize && _chrRomSize == mapper->_chrRomSize) { + memcpy(_prgRom, mapper->_prgRom, _prgSize); + if(!_onlyChrRam) { + memcpy(_chrRom, mapper->_chrRom, _chrRomSize); + } + } } \ No newline at end of file diff --git a/Core/BaseMapper.h b/Core/BaseMapper.h index f32b4e3c..6c3d5cd4 100644 --- a/Core/BaseMapper.h +++ b/Core/BaseMapper.h @@ -12,7 +12,7 @@ class BaseControlDevice; -class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificationListener, public IBattery +class BaseMapper : public IMemoryHandler, public Snapshotable, public IBattery { private: MirroringType _mirroringType; @@ -135,7 +135,6 @@ protected: void SetupDefaultWorkRam(); - void RestoreOriginalPrgRam(); void InitializeChrRam(int32_t chrRamSize = -1); void AddRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation = MemoryOperation::Any); @@ -167,11 +166,8 @@ public: virtual void SetNesModel(NesModel model) { } virtual void ProcessCpuClock() { } virtual void NotifyVRAMAddressChange(uint16_t addr); - void ProcessNotification(ConsoleNotificationType type, void* parameter) override; virtual void GetMemoryRanges(MemoryRanges &ranges) override; - void ApplyCheats(); - virtual void SaveBattery() override; void SetConsole(shared_ptr console); @@ -240,4 +236,5 @@ public: void RestorePrgChrBackup(vector& backupData); void RevertPrgChrChanges(); bool HasPrgChrChanges(); + void CopyPrgChrRom(shared_ptr mapper); }; \ No newline at end of file diff --git a/Core/CheatManager.cpp b/Core/CheatManager.cpp index 5a6d6a92..fe0a316d 100644 --- a/Core/CheatManager.cpp +++ b/Core/CheatManager.cpp @@ -2,6 +2,7 @@ #include "CheatManager.h" #include "Console.h" +#include "BaseMapper.h" #include "MessageManager.h" #include "NotificationManager.h" @@ -98,6 +99,7 @@ void CheatManager::AddCode(CodeInfo &code) } else { _absoluteCheatCodes.push_back(code); } + _hasCode = true; _console->GetNotificationManager()->SendNotification(ConsoleNotificationType::CheatAdded); } @@ -137,14 +139,19 @@ void CheatManager::ClearCodes() cheatRemoved |= _absoluteCheatCodes.size() > 0; _absoluteCheatCodes.clear(); - + _hasCode = false; + if(cheatRemoved) { _console->GetNotificationManager()->SendNotification(ConsoleNotificationType::CheatRemoved); } } -void CheatManager::ApplyRamCodes(uint16_t addr, uint8_t &value) +void CheatManager::ApplyCodes(uint16_t addr, uint8_t &value) { + if(!_hasCode) { + return; + } + if(_relativeCheatCodes[addr] != nullptr) { for(uint32_t i = 0, len = i < _relativeCheatCodes[addr]->size(); i < len; i++) { CodeInfo code = _relativeCheatCodes[addr]->at(i); @@ -153,16 +160,14 @@ void CheatManager::ApplyRamCodes(uint16_t addr, uint8_t &value) return; } } - } -} - -void CheatManager::ApplyPrgCodes(uint8_t *prgRam, uint32_t prgSize) -{ - for(uint32_t i = 0, len = i < _absoluteCheatCodes.size(); i < len; i++) { - CodeInfo code = _absoluteCheatCodes[i]; - if(code.Address < prgSize) { - if(code.CompareValue == -1 || code.CompareValue == prgRam[code.Address]) { - prgRam[code.Address] = code.Value; + } else if(!_absoluteCheatCodes.empty()) { + int32_t absAddr = _console->GetMapper()->ToAbsoluteAddress(addr); + if(absAddr >= 0) { + for(CodeInfo &code : _absoluteCheatCodes) { + if(code.Address == (uint32_t)absAddr && (code.CompareValue == -1 || code.CompareValue == value)) { + value = code.Value; + return; + } } } } diff --git a/Core/CheatManager.h b/Core/CheatManager.h index 7ac8cdd0..3bc3fe11 100644 --- a/Core/CheatManager.h +++ b/Core/CheatManager.h @@ -36,6 +36,7 @@ class CheatManager private: shared_ptr _console; + bool _hasCode = false; vector>> _relativeCheatCodes; vector _absoluteCheatCodes; @@ -56,6 +57,5 @@ public: void SetCheats(vector &cheats); void SetCheats(CheatInfo cheats[], uint32_t length); - void ApplyRamCodes(uint16_t addr, uint8_t &value); - void ApplyPrgCodes(uint8_t *prgRam, uint32_t prgSize); + void ApplyCodes(uint16_t addr, uint8_t &value); }; \ No newline at end of file diff --git a/Core/Console.cpp b/Core/Console.cpp index 61338e3b..94c2e053 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -255,7 +255,7 @@ bool Console::Initialize(VirtualFile &romFile) return Initialize(romFile, patchFile); } -bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) +bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile, bool forPowerCycle) { if(romFile.IsValid()) { Pause(); @@ -306,6 +306,7 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) StopRecordingHdPack(); } + shared_ptr previousMapper = _mapper; _mapper = mapper; _memoryManager.reset(new MemoryManager(shared_from_this())); _cpu.reset(new CPU(shared_from_this())); @@ -313,7 +314,9 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) _mapper->SetConsole(shared_from_this()); _mapper->Initialize(romData); - GetNotificationManager()->RegisterNotificationListener(_mapper); + if(!isDifferentGame && forPowerCycle) { + _mapper->CopyPrgChrRom(previousMapper); + } if(_slave) { _slave->Release(false); @@ -400,8 +403,10 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) ResetComponents(false); //Reset components before creating rewindmanager, otherwise the first save state it takes will be invalid - _rewindManager.reset(new RewindManager(shared_from_this())); - _notificationManager->RegisterNotificationListener(_rewindManager); + if(!forPowerCycle) { + _rewindManager.reset(new RewindManager(shared_from_this())); + _notificationManager->RegisterNotificationListener(_rewindManager); + } //Poll controller input after creating rewind manager, to make sure it catches the first frame's input _controlManager->UpdateInputState(); @@ -418,9 +423,12 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) FolderUtilities::AddKnownGameFolder(romFile.GetFolderPath()); if(IsMaster()) { - string modelName = _model == NesModel::PAL ? "PAL" : (_model == NesModel::Dendy ? "Dendy" : "NTSC"); - string messageTitle = MessageManager::Localize("GameLoaded") + " (" + modelName + ")"; - MessageManager::DisplayMessage(messageTitle, FolderUtilities::GetFilename(GetRomInfo().RomName, false)); + if(!forPowerCycle) { + string modelName = _model == NesModel::PAL ? "PAL" : (_model == NesModel::Dendy ? "Dendy" : "NTSC"); + string messageTitle = MessageManager::Localize("GameLoaded") + " (" + modelName + ")"; + MessageManager::DisplayMessage(messageTitle, FolderUtilities::GetFilename(GetRomInfo().RomName, false)); + } + _settings->ClearFlags(EmulationFlags::ForceMaxSpeed); if(_slave) { @@ -565,11 +573,16 @@ shared_ptr Console::GetSystemActionManager() } void Console::PowerCycle() +{ + ReloadRom(true); +} + +void Console::ReloadRom(bool forPowerCycle) { if(_initialized && !_romFilepath.empty()) { VirtualFile romFile = _romFilepath; VirtualFile patchFile = _patchFilename; - Initialize(romFile, patchFile); + Initialize(romFile, patchFile, forPowerCycle); } } diff --git a/Core/Console.h b/Core/Console.h index 53f6c2c8..6196fc29 100644 --- a/Core/Console.h +++ b/Core/Console.h @@ -143,7 +143,7 @@ public: bool Initialize(string romFile, string patchFile = ""); bool Initialize(VirtualFile &romFile); - bool Initialize(VirtualFile &romFile, VirtualFile &patchFile); + bool Initialize(VirtualFile &romFile, VirtualFile &patchFile, bool forPowerCycle = false); void SaveBatteries(); @@ -179,6 +179,7 @@ public: void Reset(bool softReset = true); void PowerCycle(); + void ReloadRom(bool forPowerCycle = false); void ResetComponents(bool softReset); //Used to pause the emu loop to perform thread-safe operations diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index 07c11e38..59bb13c0 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -431,6 +431,7 @@ enum class EmulatorShortcut Pause, Reset, PowerCycle, + ReloadRom, PowerOff, Exit, diff --git a/Core/MemoryManager.cpp b/Core/MemoryManager.cpp index dfe956cc..1c55b4e3 100644 --- a/Core/MemoryManager.cpp +++ b/Core/MemoryManager.cpp @@ -101,7 +101,7 @@ uint8_t MemoryManager::DebugRead(uint16_t addr, bool disableSideEffects) } } - _console->GetCheatManager()->ApplyRamCodes(addr, value); + _console->GetCheatManager()->ApplyCodes(addr, value); return value; } @@ -114,7 +114,7 @@ uint16_t MemoryManager::DebugReadWord(uint16_t addr) uint8_t MemoryManager::Read(uint16_t addr, MemoryOperationType operationType) { uint8_t value = _ramReadHandlers[addr]->ReadRAM(addr); - _console->GetCheatManager()->ApplyRamCodes(addr, value); + _console->GetCheatManager()->ApplyCodes(addr, value); _console->DebugProcessRamOperation(operationType, addr, value); _openBusHandler.SetOpenBus(value); diff --git a/Docs/content/configuration/Preferences.md b/Docs/content/configuration/Preferences.md index e9075154..c123a66e 100644 --- a/Docs/content/configuration/Preferences.md +++ b/Docs/content/configuration/Preferences.md @@ -66,8 +66,9 @@ Available shortcuts: * **Rewind 10 seconds**: Instantly rewinds 10 seconds of gameplay. * **Rewind 1 minute**: Instantly rewinds 1 minute of gameplay. * **Pause**: Pauses or unpauses the game. -* **Reset**: Resets the game. -* **Power Cycle**: Power cycles the game and reloads the file from disk. +* **Reset**: Resets the game (equivalent to pressing the reset button on the NES.) +* **Power Cycle**: Power cycles the game (equivalent to turning the power off and then back on.) +* **Reload ROM**: Reloads the ROM from the disk and power cycles the console. * **Power Off**: Powers off the game, returning to the game selection screen. * **Exit**: Exits the emulator. * **FDS - Insert Next Disk**: Inserts face A of the next disk. diff --git a/GUI.NET/Dependencies/resources.ca.xml b/GUI.NET/Dependencies/resources.ca.xml index 8f9d74ea..82e780f3 100644 --- a/GUI.NET/Dependencies/resources.ca.xml +++ b/GUI.NET/Dependencies/resources.ca.xml @@ -13,6 +13,7 @@ Pausa Reinicia el joc Atura i reinicia el joc + Reload ROM Atura el joc Canvia la cara del disc Escull el disc @@ -856,6 +857,7 @@ Pausa Reinicia el joc Atura i reinicia el joc + Reload ROM Atura el joc Surt Captura de pantalla diff --git a/GUI.NET/Dependencies/resources.en.xml b/GUI.NET/Dependencies/resources.en.xml index b33980b5..f8d1d89e 100644 --- a/GUI.NET/Dependencies/resources.en.xml +++ b/GUI.NET/Dependencies/resources.en.xml @@ -13,6 +13,7 @@ Pause Reset Power Cycle + Reload ROM Power Off Switch Disk Side Select Disk @@ -888,6 +889,7 @@ Pause Reset Power Cycle + Reload ROM Power Off Exit Take Screenshot diff --git a/GUI.NET/Dependencies/resources.es.xml b/GUI.NET/Dependencies/resources.es.xml index 800d167c..786b27e7 100644 --- a/GUI.NET/Dependencies/resources.es.xml +++ b/GUI.NET/Dependencies/resources.es.xml @@ -13,6 +13,7 @@ Pausa Reiniciar Detener y reiniciar + Reload ROM Detener el juego Cambiar la cara del disco Elegir el disco @@ -873,6 +874,7 @@ Pausa Reiniciar Detener y reiniciar + Reload ROM Detener el juego Salir Captura de pantalla diff --git a/GUI.NET/Dependencies/resources.fr.xml b/GUI.NET/Dependencies/resources.fr.xml index 542dd6e0..c0f78696 100644 --- a/GUI.NET/Dependencies/resources.fr.xml +++ b/GUI.NET/Dependencies/resources.fr.xml @@ -13,6 +13,7 @@ Pause Reset Arrêt && redémarrage + Recharger le ROM à partir du disque Arrêter le jeu Changer le disque de côté Choisir le disque @@ -887,6 +888,7 @@ Pause Reset Arrêt & redémarrage + Recharger le ROM à partir du disque Arrêter le jeu Quitter Capture d'écran diff --git a/GUI.NET/Dependencies/resources.it.xml b/GUI.NET/Dependencies/resources.it.xml index 8fdddf15..12f5e3be 100644 --- a/GUI.NET/Dependencies/resources.it.xml +++ b/GUI.NET/Dependencies/resources.it.xml @@ -13,6 +13,7 @@ Pausa Reset Spegni/Riaccendi + Reload ROM Spegni Cambia Lato Disco Seleziona Disco @@ -888,6 +889,7 @@ Pausa Reset Spegni e Riaccendi + Reload ROM Spegni Esci Fai uno Screenshot diff --git a/GUI.NET/Dependencies/resources.ja.xml b/GUI.NET/Dependencies/resources.ja.xml index 79691922..c82d9c0b 100644 --- a/GUI.NET/Dependencies/resources.ja.xml +++ b/GUI.NET/Dependencies/resources.ja.xml @@ -13,6 +13,7 @@ ポーズ リセット 停止と再起動 + ディスクからROMをリロードする ゲームを停止する A面B面切り替え ディスク選択 @@ -875,6 +876,7 @@ ポーズ リセット 停止と再起動 + ディスクからROMをリロードする ゲームを停止する 終了 スクリーンショットを撮る diff --git a/GUI.NET/Dependencies/resources.pt.xml b/GUI.NET/Dependencies/resources.pt.xml index 1546e54f..02cb0bb2 100644 --- a/GUI.NET/Dependencies/resources.pt.xml +++ b/GUI.NET/Dependencies/resources.pt.xml @@ -13,6 +13,7 @@ Pausar Reiniciar Parar e reiniciar + Reload ROM Desligar Trocar o lado do disco Selecionar o disco @@ -888,6 +889,7 @@ Pausar Reiniciar Parar e ligar + Reload ROM Desligar Sair Fazer uma captura de tela diff --git a/GUI.NET/Dependencies/resources.ru.xml b/GUI.NET/Dependencies/resources.ru.xml index cdce0e44..f2340520 100644 --- a/GUI.NET/Dependencies/resources.ru.xml +++ b/GUI.NET/Dependencies/resources.ru.xml @@ -13,6 +13,7 @@ Пауза Сброс Power Cycle + Reload ROM Power Off Сменить сторону диска Выбрать диск @@ -875,6 +876,7 @@ Пауза Сброс Power Cycle + Reload ROM Power Off Exit Сделать сриншот diff --git a/GUI.NET/Dependencies/resources.uk.xml b/GUI.NET/Dependencies/resources.uk.xml index 329c0aa1..0718a058 100644 --- a/GUI.NET/Dependencies/resources.uk.xml +++ b/GUI.NET/Dependencies/resources.uk.xml @@ -13,6 +13,7 @@ Пауза Скидання Цикл включення + Reload ROM Power Off Змінити сторону диска Вибрати диск @@ -875,6 +876,7 @@ Пауза Скидання Цикл включення + Reload ROM Вимкнення Вихід Скріншот diff --git a/GUI.NET/Dependencies/resources.zh.xml b/GUI.NET/Dependencies/resources.zh.xml index a073180f..9ef34e3d 100644 --- a/GUI.NET/Dependencies/resources.zh.xml +++ b/GUI.NET/Dependencies/resources.zh.xml @@ -13,6 +13,7 @@ 暂停 重设 电源 + Reload ROM 关机 磁盘换面 选择磁盘 @@ -893,6 +894,7 @@ 暂停 重设 电源 + Reload ROM 关机 退出 截图 diff --git a/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs b/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs index eab6f7b4..d8640f3d 100644 --- a/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs +++ b/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs @@ -40,6 +40,7 @@ namespace Mesen.GUI.Forms.Config EmulatorShortcut.Pause, EmulatorShortcut.Reset, EmulatorShortcut.PowerCycle, + EmulatorShortcut.ReloadRom, EmulatorShortcut.PowerOff, EmulatorShortcut.Exit, diff --git a/GUI.NET/Forms/frmMain.Designer.cs b/GUI.NET/Forms/frmMain.Designer.cs index 5c1acb38..a9ccfb3e 100644 --- a/GUI.NET/Forms/frmMain.Designer.cs +++ b/GUI.NET/Forms/frmMain.Designer.cs @@ -45,6 +45,7 @@ namespace Mesen.GUI.Forms this.menuStrip = new Mesen.GUI.Controls.ctrlMesenMenuStrip(); this.mnuFile = new System.Windows.Forms.ToolStripMenuItem(); this.mnuOpen = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuReloadRom = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); this.mnuSaveState = new System.Windows.Forms.ToolStripMenuItem(); this.mnuLoadState = new System.Windows.Forms.ToolStripMenuItem(); @@ -203,6 +204,7 @@ namespace Mesen.GUI.Forms this.mnuScriptWindow = new System.Windows.Forms.ToolStripMenuItem(); this.mnuTextHooker = new System.Windows.Forms.ToolStripMenuItem(); this.mnuTraceLogger = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuWatchWindow = new System.Windows.Forms.ToolStripMenuItem(); this.sepDebugDualSystemSecondaryCpu = new System.Windows.Forms.ToolStripSeparator(); this.mnuDebugDualSystemSecondaryCpu = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem25 = new System.Windows.Forms.ToolStripSeparator(); @@ -222,7 +224,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.mnuWatchWindow = new System.Windows.Forms.ToolStripMenuItem(); this.panelRenderer.SuspendLayout(); this.panelInfo.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -378,6 +379,7 @@ namespace Mesen.GUI.Forms // this.mnuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mnuOpen, + this.mnuReloadRom, this.toolStripMenuItem4, this.mnuSaveState, this.mnuLoadState, @@ -401,6 +403,12 @@ namespace Mesen.GUI.Forms this.mnuOpen.Size = new System.Drawing.Size(166, 22); this.mnuOpen.Text = "Open"; // + // mnuReloadRom + // + this.mnuReloadRom.Name = "mnuReloadRom"; + this.mnuReloadRom.Size = new System.Drawing.Size(166, 22); + this.mnuReloadRom.Text = "Reload ROM"; + // // toolStripMenuItem4 // this.toolStripMenuItem4.Name = "toolStripMenuItem4"; @@ -1662,6 +1670,14 @@ namespace Mesen.GUI.Forms this.mnuTraceLogger.Text = "Trace Logger"; this.mnuTraceLogger.Click += new System.EventHandler(this.mnuTraceLogger_Click); // + // mnuWatchWindow + // + this.mnuWatchWindow.Image = global::Mesen.GUI.Properties.Resources.Find; + this.mnuWatchWindow.Name = "mnuWatchWindow"; + this.mnuWatchWindow.Size = new System.Drawing.Size(258, 22); + this.mnuWatchWindow.Text = "Watch Window"; + this.mnuWatchWindow.Click += new System.EventHandler(this.mnuWatchWindow_Click); + // // sepDebugDualSystemSecondaryCpu // this.sepDebugDualSystemSecondaryCpu.Name = "sepDebugDualSystemSecondaryCpu"; @@ -1804,14 +1820,6 @@ namespace Mesen.GUI.Forms this.mnuAbout.Text = "About"; this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click); // - // mnuWatchWindow - // - this.mnuWatchWindow.Image = global::Mesen.GUI.Properties.Resources.Find; - this.mnuWatchWindow.Name = "mnuWatchWindow"; - this.mnuWatchWindow.Size = new System.Drawing.Size(258, 22); - this.mnuWatchWindow.Text = "Watch Window"; - this.mnuWatchWindow.Click += new System.EventHandler(this.mnuWatchWindow_Click); - // // frmMain // this.AllowDrop = true; @@ -2034,6 +2042,7 @@ namespace Mesen.GUI.Forms private System.Windows.Forms.ToolStripMenuItem mnuProfiler; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.ToolStripMenuItem mnuWatchWindow; + private System.Windows.Forms.ToolStripMenuItem mnuReloadRom; } } diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs index c5580aa2..327170b3 100644 --- a/GUI.NET/Forms/frmMain.cs +++ b/GUI.NET/Forms/frmMain.cs @@ -690,15 +690,15 @@ namespace Mesen.GUI.Forms case InteropEmu.ConsoleNotificationType.GameStopped: this._currentGame = null; - CheatInfo.ClearCheats(); this.BeginInvoke((MethodInvoker)(() => { if(_hdPackEditorWindow != null) { _hdPackEditorWindow.Close(); } - if(!ConfigManager.Config.PreferenceInfo.DisableGameSelectionScreen) { - ctrlRecentGames.Initialize(); - } if(e.Parameter == IntPtr.Zero) { + if(!ConfigManager.Config.PreferenceInfo.DisableGameSelectionScreen) { + ctrlRecentGames.Initialize(); + } + //We are completely stopping the emulation, close fullscreen mode StopExclusiveFullscreenMode(); } @@ -806,6 +806,7 @@ namespace Mesen.GUI.Forms BindShortcut(mnuPause, EmulatorShortcut.Pause, runningNotClient); BindShortcut(mnuReset, EmulatorShortcut.Reset, runningNotClientNotMovie); BindShortcut(mnuPowerCycle, EmulatorShortcut.PowerCycle, runningNotClientNotMovie); + BindShortcut(mnuReloadRom, EmulatorShortcut.ReloadRom, runningNotClientNotMovie); BindShortcut(mnuPowerOff, EmulatorShortcut.PowerOff, runningNotClient); BindShortcut(mnuSwitchDiskSide, EmulatorShortcut.SwitchDiskSide, runningFdsMultipleDisks); @@ -903,6 +904,7 @@ namespace Mesen.GUI.Forms case EmulatorShortcut.Pause: PauseEmu(); break; case EmulatorShortcut.Reset: this.ResetEmu(); break; case EmulatorShortcut.PowerCycle: this.PowerCycleEmu(); break; + case EmulatorShortcut.ReloadRom: InteropEmu.ReloadRom(); break; case EmulatorShortcut.PowerOff: Task.Run(() => InteropEmu.Stop()); break; case EmulatorShortcut.Exit: this.Close(); break; diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index 08da34af..eb6e0353 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -93,6 +93,7 @@ namespace Mesen.GUI [DllImport(DLLPath, EntryPoint = "GetRomInfo")] private static extern UInt32 GetRomInfoWrapper(ref InteropRomInfo romInfo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string filename = ""); + [DllImport(DLLPath)] public static extern void ReloadRom(); [DllImport(DLLPath)] public static extern void PowerCycle(); [DllImport(DLLPath)] public static extern void Reset(); [DllImport(DLLPath)] public static extern void ResetLagCounter(); @@ -1925,6 +1926,7 @@ namespace Mesen.GUI Pause, Reset, PowerCycle, + ReloadRom, PowerOff, Exit, diff --git a/InteropDLL/ConsoleWrapper.cpp b/InteropDLL/ConsoleWrapper.cpp index 9632ea6e..1adf6290 100644 --- a/InteropDLL/ConsoleWrapper.cpp +++ b/InteropDLL/ConsoleWrapper.cpp @@ -441,6 +441,7 @@ namespace InteropEmu { DllExport void __stdcall Reset() { _console->Reset(true); } DllExport void __stdcall PowerCycle() { _console->Reset(false); } + DllExport void __stdcall ReloadRom() { _console->ReloadRom(); } DllExport void __stdcall ResetLagCounter() { _console->ResetLagCounter(); } DllExport void __stdcall StartServer(uint16_t port, char* password, char* hostPlayerName) { GameServer::StartServer(_console, port, password, hostPlayerName); }