public static void AutoImportSymbols() { if (ConfigManager.Config.Debug.DbgIntegration.AutoImport) { RomInfo romInfo = EmuApi.GetRomInfo(); string romName = romInfo.GetRomName(); string romFolder = ((ResourcePath)romInfo.RomPath).Folder; string dbgPath = Path.Combine(romFolder, romName + ".dbg"); string mslPath = Path.Combine(romFolder, romName + ".msl"); string symPath = Path.Combine(romFolder, romName + ".sym"); string tassPath = Path.Combine(romFolder, romName + ".tass"); if (File.Exists(dbgPath)) { ImportDbgFile(dbgPath, true); } else if (File.Exists(mslPath)) { ImportMslFile(mslPath, true); } else if (File.Exists(symPath)) { ImportSymFile(symPath, true); } else if (File.Exists(tassPath)) { ImportSymFile(tassPath, true); } } }
public static void SetGameSpecificOverscan(bool overrideOverscan, UInt32 top, UInt32 bottom, UInt32 left, UInt32 right) { RomInfo romInfo = InteropEmu.GetRomInfo(); if (romInfo.PrgCrc32 == 0) { return; } GameSpecificInfo existingConfig = ConfigManager.Config.GameSpecificSettings.Find(gameConfig => gameConfig.GamePrgCrc32 == romInfo.GetPrgCrcString()); if (overrideOverscan || existingConfig != null) { //Only add if the config already exists, or if override setting is turned on GameSpecificInfo info = existingConfig ?? new GameSpecificInfo(); info.GameName = romInfo.GetRomName(); info.GamePrgCrc32 = romInfo.GetPrgCrcString(); info.OverrideOverscan = overrideOverscan; info.OverscanTop = top; info.OverscanBottom = bottom; info.OverscanLeft = left; info.OverscanRight = right; if (existingConfig == null) { ConfigManager.Config.GameSpecificSettings.Add(info); } } }
private void InitializeGameSpecificOverscanTab() { RomInfo romInfo = InteropEmu.GetRomInfo(); if (romInfo.PrgCrc32 == 0) { chkEnableGameSpecificOverscan.Enabled = false; } else { chkEnableGameSpecificOverscan.Text += " (" + romInfo.GetRomName() + ")"; GameSpecificInfo info = GameSpecificInfo.GetGameSpecificInfo(); if (info != null) { chkEnableGameSpecificOverscan.Checked = info.OverrideOverscan; if (chkEnableGameSpecificOverscan.Checked) { tabOverscan.SelectedTab = tpgOverscanGameSpecific; } nudGameSpecificOverscanTop.Value = info.OverscanTop; nudGameSpecificOverscanBottom.Value = info.OverscanBottom; nudGameSpecificOverscanLeft.Value = info.OverscanLeft; nudGameSpecificOverscanRight.Value = info.OverscanRight; } } //Change name to share resources with global overscan tab lblGameSpecificOverscanBottom.Name = "lblBottom"; lblGameSpecificOverscanLeft.Name = "lblLeft"; lblGameSpecificOverscanRight.Name = "lblRight"; lblGameSpecificOverscanTop.Name = "lblTop"; }
public static GameSpecificInfo CreateGameSpecificConfig() { RomInfo romInfo = InteropEmu.GetRomInfo(); GameSpecificInfo info = new GameSpecificInfo(); info.GameName = romInfo.GetRomName(); info.GamePrgCrc32 = romInfo.GetPrgCrcString(); return(info); }
public static void AutoLoadDbgFiles(bool silent) { Ld65DbgImporter oldSymbolProvider = SymbolProvider; if (ConfigManager.Config.DebugInfo.AutoLoadDbgFiles) { RomInfo info = InteropEmu.GetRomInfo(); string dbgPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".dbg"); if (File.Exists(dbgPath)) { DateTime lastDbgUpdate = File.GetLastWriteTime(dbgPath); if (lastDbgUpdate != oldSymbolProvider?.DbgFileStamp) { ImportDbgFile(dbgPath, silent); } else { //Currently loaded symbol provider is still valid return; } } else { string mlbPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".mlb"); if (File.Exists(mlbPath)) { ImportMlbFile(mlbPath, silent); } else { string fnsPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".fns"); if (File.Exists(fnsPath)) { ImportNesasmFnsFile(fnsPath, silent); } } } } if (oldSymbolProvider == SymbolProvider) { SymbolProvider = null; } }
private void OnNotificationReceived(NotificationEventArgs e) { switch (e.NotificationType) { case ConsoleNotificationType.GameLoaded: this.BeginInvoke((Action)(() => { UpdateDebuggerMenu(); ctrlRecentGames.Visible = false; SaveStateManager.UpdateStateMenu(mnuLoadState, false); SaveStateManager.UpdateStateMenu(mnuSaveState, true); RomInfo romInfo = EmuApi.GetRomInfo(); this.Text = "Mesen-S - " + romInfo.GetRomName(); if (DebugWindowManager.HasOpenedWindow) { DebugWorkspaceManager.GetWorkspace(); } })); break; case ConsoleNotificationType.BeforeEmulationStop: this.Invoke((Action)(() => { DebugWindowManager.CloseAll(); })); break; case ConsoleNotificationType.EmulationStopped: this.BeginInvoke((Action)(() => { this.Text = "Mesen-S"; UpdateDebuggerMenu(); ctrlRecentGames.Initialize(); ctrlRecentGames.Visible = true; ResizeRecentGames(); if (_displayManager.ExclusiveFullscreen) { _displayManager.SetFullscreenState(false); } })); break; case ConsoleNotificationType.ResolutionChanged: this.BeginInvoke((Action)(() => { _displayManager.UpdateViewerSize(); })); break; case ConsoleNotificationType.ExecuteShortcut: this.BeginInvoke((Action)(() => { _shortcuts.ExecuteShortcut((EmulatorShortcut)e.Parameter); })); break; } }
private void AutoLoadDbgFiles(bool silent) { if (ConfigManager.Config.DebugInfo.AutoLoadDbgFiles) { RomInfo info = InteropEmu.GetRomInfo(); string dbgPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".dbg"); if (File.Exists(dbgPath)) { Ld65DbgImporter dbgImporter = new Ld65DbgImporter(); dbgImporter.Import(dbgPath, silent); } else { string mlbPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".mlb"); if (File.Exists(mlbPath)) { MesenLabelFile.Import(mlbPath, silent); } } } }
public frmCheatImport() { InitializeComponent(); UpdateImportButton(); RomInfo romInfo = InteropEmu.GetRomInfo(); _gameCrc = romInfo.GetPrgCrcString(); _gameName = romInfo.GetRomName(); txtGameName.Text = _gameName; }
private void LoadGame(string romPath) { int archiveFileIndex = -1; if (frmSelectRom.SelectRom(romPath, ref archiveFileIndex)) { RomInfo romInfo = InteropEmu.GetRomInfo(romPath, archiveFileIndex); _gameCrc = romInfo.GetPrgCrcString(); _gameName = romInfo.GetRomName(); txtGameName.Text = _gameName; UpdateImportButton(); } }
private void LoadGame(string romPath) { ResourcePath resource = romPath; if (frmSelectRom.SelectRom(ref resource)) { RomInfo romInfo = InteropEmu.GetRomInfo(resource); _gameCrc = romInfo.GetPrgCrcString(); _gameName = romInfo.GetRomName(); txtGameName.Text = _gameName; UpdateImportButton(); } }
private void LoadGame(string romPath) { ResourcePath resource = romPath; if (frmSelectRom.SelectRom(ref resource)) { RomInfo romInfo = InteropEmu.GetRomInfo(resource); _gameCrc = romInfo.GetPrgCrcString(); if (_gameCrc != null) { ((CheatInfo)Entity).GameName = romInfo.GetRomName(); txtGameName.Text = ((CheatInfo)Entity).GameName; } } }
private void AutoLoadCdlFiles() { if (ConfigManager.Config.DebugInfo.AutoLoadCdlFiles) { //This loads CDL files that are next to the rom - useful when developing with a compiler that can produce a CDL file RomInfo info = InteropEmu.GetRomInfo(); string cdlPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".cdl"); if (File.Exists(cdlPath)) { if (InteropEmu.DebugLoadCdlFile(cdlPath)) { UpdateDebugger(false, false); } } } }
private void btnCreateCheat_Click(object sender, EventArgs e) { RomInfo romInfo = InteropEmu.GetRomInfo(); CheatInfo newCheat = new CheatInfo { GameCrc = romInfo.GetPrgCrcString(), GameName = romInfo.GetRomName(), Address = (uint)lstAddresses.CurrentAddress, CheatType = CheatType.Custom }; frmCheat frm = new frmCheat(newCheat); if (frm.ShowDialog() == DialogResult.OK) { OnAddCheat?.Invoke(newCheat, new EventArgs()); } }
protected override void OnShown(EventArgs e) { base.OnShown(e); _cheats = NestopiaCheatLoader.Load(ResourceManager.GetZippedResource("MesenCheatDb.xml"), "", ""); _gamesByCrc = new Dictionary <string, GameInfo>(); foreach (CheatInfo cheat in _cheats) { if (_gamesByCrc.ContainsKey(cheat.GameName)) { _gamesByCrc[cheat.GameCrc].CheatCount++; } else { _gamesByCrc[cheat.GameCrc] = new GameInfo() { Name = cheat.GameName, Crc = cheat.GameCrc, CheatCount = 1 }; } } lblCheatCount.Text = ResourceHelper.GetMessage("CheatsFound", _gamesByCrc.Count.ToString(), _cheats.Count.ToString()); lstGames.Sorted = true; txtSearch.Focus(); UpdateList(); RomInfo info = InteropEmu.GetRomInfo(); if (!string.IsNullOrWhiteSpace(info.GetRomName())) { string loadedGameCrc = info.GetPrgCrcString(); for (int i = 0, len = lstGames.Items.Count; i < len; i++) { if (((GameInfo)lstGames.Items[i]).Crc == loadedGameCrc) { lstGames.TopIndex = Math.Max(0, i - 10); lstGames.SelectedIndex = i; break; } } } }
public static DebugWorkspace GetWorkspace() { RomInfo info = InteropEmu.GetRomInfo(); return(Deserialize(Path.Combine(ConfigManager.DebuggerFolder, info.GetRomName() + ".Workspace.xml"))); }
private void mnuInstallHdPack_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.SetFilter(ResourceHelper.GetMessage("FilterZipFiles")); if (ofd.ShowDialog(this) == DialogResult.OK) { try { using (FileStream stream = File.Open(ofd.FileName, FileMode.Open)) { ZipArchive zip = new ZipArchive(stream); //Find the hires.txt file ZipArchiveEntry hiresEntry = null; foreach (ZipArchiveEntry entry in zip.Entries) { if (entry.Name == "hires.txt") { hiresEntry = entry; break; } } if (hiresEntry != null) { using (Stream entryStream = hiresEntry.Open()) { using (StreamReader reader = new StreamReader(entryStream)) { string hiresData = reader.ReadToEnd(); RomInfo romInfo = InteropEmu.GetRomInfo(); //If there's a "supportedRom" tag, check if it matches the current ROM Regex supportedRomRegex = new Regex("<supportedRom>([^\\n]*)"); Match match = supportedRomRegex.Match(hiresData); if (match.Success) { if (!match.Groups[1].Value.ToUpper().Contains(InteropEmu.GetRomInfo().Sha1.ToUpper())) { MesenMsgBox.Show("InstallHdPackWrongRom", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } //Extract HD pack try { string targetFolder = Path.Combine(ConfigManager.HdPackFolder, Path.GetFileNameWithoutExtension(romInfo.GetRomName())); if (Directory.Exists(targetFolder)) { //Warn if the folder already exists if (MesenMsgBox.Show("InstallHdPackConfirmOverwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, targetFolder) != DialogResult.OK) { return; } } else { Directory.CreateDirectory(targetFolder); } string hiresFileFolder = hiresEntry.FullName.Substring(0, hiresEntry.FullName.Length - "hires.txt".Length); foreach (ZipArchiveEntry entry in zip.Entries) { //Extract only the files in the same subfolder as the hires.txt file (and only if they have a name & size > 0) if (!string.IsNullOrWhiteSpace(entry.Name) && entry.Length > 0 && entry.FullName.StartsWith(hiresFileFolder)) { entry.ExtractToFile(Path.Combine(targetFolder, entry.Name), true); } } } catch (Exception ex) { MesenMsgBox.Show("InstallHdPackError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString()); return; } } //Turn on HD Pack support automatically after installation succeeds ConfigManager.Config.VideoInfo.UseHdPacks = true; ConfigManager.ApplyChanges(); ConfigManager.Config.ApplyConfig(); if (MesenMsgBox.Show("InstallHdPackConfirmReset", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { //Power cycle game if the user agrees InteropEmu.PowerCycle(); } } } else { MesenMsgBox.Show("InstallHdPackInvalidPack", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { //Invalid file (file missing, not a zip file, etc.) MesenMsgBox.Show("InstallHdPackInvalidZipFile", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public static void ImportDbgFile() { _symbolProvider = null; if (ConfigManager.Config.Debug.DbgIntegration.AutoImport) { RomInfo romInfo = EmuApi.GetRomInfo(); string dbgPath = Path.Combine(((ResourcePath)romInfo.RomPath).Folder, romInfo.GetRomName() + ".dbg"); if (File.Exists(dbgPath)) { _symbolProvider = new DbgImporter(); _symbolProvider.Import(dbgPath, true); SymbolProviderChanged?.Invoke(_symbolProvider); LabelManager.RefreshLabels(); } } SymbolProviderChanged?.Invoke(_symbolProvider); }
private void OnNotificationReceived(NotificationEventArgs e) { switch (e.NotificationType) { case ConsoleNotificationType.GameLoaded: CheatCodes.ApplyCheats(); this.BeginInvoke((Action)(() => { UpdateDebuggerMenu(); ctrlRecentGames.Visible = false; SaveStateManager.UpdateStateMenu(mnuLoadState, false); SaveStateManager.UpdateStateMenu(mnuSaveState, true); RomInfo romInfo = EmuApi.GetRomInfo(); this.Text = "Mesen-S - " + romInfo.GetRomName(); if (DebugWindowManager.HasOpenedWindow) { DebugWorkspaceManager.GetWorkspace(); } })); break; case ConsoleNotificationType.BeforeEmulationStop: this.Invoke((Action)(() => { DebugWindowManager.CloseAll(); })); break; case ConsoleNotificationType.GameResumed: this.BeginInvoke((Action)(() => { //Ensure mouse is hidden when game is resumed CursorManager.OnMouseMove(ctrlRenderer); })); break; case ConsoleNotificationType.EmulationStopped: this.BeginInvoke((Action)(() => { this.Text = "Mesen-S"; UpdateDebuggerMenu(); ShowGameScreen(GameScreenMode.RecentGames); ResizeRecentGames(); if (_displayManager.ExclusiveFullscreen) { _displayManager.SetFullscreenState(false); } })); break; case ConsoleNotificationType.ResolutionChanged: this.BeginInvoke((Action)(() => { _displayManager.UpdateViewerSize(); })); break; case ConsoleNotificationType.ExecuteShortcut: this.BeginInvoke((Action)(() => { _shortcuts.ExecuteShortcut((EmulatorShortcut)e.Parameter); })); break; case ConsoleNotificationType.MissingFirmware: this.Invoke((Action)(() => { MissingFirmwareMessage msg = (MissingFirmwareMessage)Marshal.PtrToStructure(e.Parameter, typeof(MissingFirmwareMessage)); FirmwareHelper.RequestFirmwareFile(msg); })); break; } }
private void UpdateGameList(string gameCrc = null) { RomInfo romInfo = InteropEmu.GetRomInfo(); Dictionary <string, string> nameByCrc = new Dictionary <string, string>(); if (!string.IsNullOrWhiteSpace(romInfo.GetRomName())) { nameByCrc[romInfo.GetPrgCrcString()] = romInfo.GetRomName(); } foreach (CheatInfo cheat in _cheats) { if (!nameByCrc.ContainsKey(cheat.GameCrc)) { nameByCrc[cheat.GameCrc] = cheat.GameName; } } lstGameList.Items.Clear(); List <GameInfo> gameList = new List <GameInfo>(); foreach (KeyValuePair <string, string> kvp in nameByCrc) { gameList.Add(new GameInfo { Text = kvp.Value, Crc = kvp.Key }); } lstGameList.Items.AddRange(gameList.ToArray()); if (lstGameList.Items.Count > 0) { if (gameCrc == null) { if (_selectedItem == null && !string.IsNullOrWhiteSpace(romInfo.GetRomName())) { gameCrc = romInfo.GetPrgCrcString(); } else { gameCrc = _selectedItem?.Crc; } } _selectedItem = null; if (gameCrc != null) { foreach (GameInfo info in lstGameList.Items) { if (info.Crc == gameCrc) { _selectedItem = info; info.Selected = true; break; } } } if (_selectedItem == null && lstGameList.Items.Count > 0) { _selectedItem = (GameInfo)lstGameList.Items[0]; lstGameList.Items[0].Selected = true; } } else { _selectedItem = null; } if (_selectedItem != null) { _selectedItem.EnsureVisible(); } btnDeleteGameCheats.Enabled = mnuDeleteGameCheats.Enabled = btnExportGame.Enabled = mnuExportGame.Enabled = _selectedItem != null; UpdateCheatList(); }