public frmEmulationConfig() { InitializeComponent(); tpgOverclocking.Enabled = !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording(); tpgAdvanced.Enabled = !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording(); ConfigManager.Config.EmulationInfo.EmulationSpeed = InteropEmu.GetEmulationSpeed(); Entity = ConfigManager.Config.EmulationInfo; AddBinding("EmulationSpeed", nudEmulationSpeed); AddBinding("TurboSpeed", nudTurboSpeed); AddBinding("RewindSpeed", nudRewindSpeed); AddBinding("UseAlternativeMmc3Irq", chkUseAlternativeMmc3Irq); AddBinding("AllowInvalidInput", chkAllowInvalidInput); AddBinding("RemoveSpriteLimit", chkRemoveSpriteLimit); AddBinding("AdaptiveSpriteLimit", chkAdaptiveSpriteLimit); AddBinding("DisablePpu2004Reads", chkDisablePpu2004Reads); AddBinding("DisablePaletteRead", chkDisablePaletteRead); AddBinding("DisableOamAddrBug", chkDisableOamAddrBug); AddBinding("DisablePpuReset", chkDisablePpuReset); AddBinding("EnableOamDecay", chkEnableOamDecay); AddBinding("UseNes101Hvc101Behavior", chkUseNes101Hvc101Behavior); AddBinding("EnableMapperRandomPowerOnState", chkMapperRandomPowerOnState); AddBinding("OverclockRate", nudOverclockRate); AddBinding("OverclockAdjustApu", chkOverclockAdjustApu); AddBinding("PpuExtraScanlinesBeforeNmi", nudExtraScanlinesBeforeNmi); AddBinding("PpuExtraScanlinesAfterNmi", nudExtraScanlinesAfterNmi); AddBinding("ShowLagCounter", chkShowLagCounter); AddBinding("RamPowerOnState", cboRamPowerOnState); }
private void SelectAndClose() { if (_resultCount > 0) { SearchResultInfo searchResult = _results[_selectedResult].Tag as SearchResultInfo; if (!searchResult.Disabled) { AddressTypeInfo addressInfo = new AddressTypeInfo() { Address = searchResult.AbsoluteAddress, Type = searchResult.MemoryType }; Destination = new GoToDestination() { AddressInfo = addressInfo, CpuAddress = addressInfo.Address >= 0 ? InteropEmu.DebugGetRelativeAddress((UInt32)addressInfo.Address, addressInfo.Type) : -1, Label = searchResult.CodeLabel, File = searchResult.Filename, Line = searchResult.FileLineNumber }; DialogResult = DialogResult.OK; Close(); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if(!this.DesignMode) { this._notifListener = new InteropEmu.NotificationListener(); this._notifListener.OnNotification += this._notifListener_OnNotification; this.nudScanline.Value = ConfigManager.Config.DebugInfo.PpuDisplayScanline; this.nudCycle.Value = ConfigManager.Config.DebugInfo.PpuDisplayCycle; InteropEmu.DebugSetPpuViewerScanlineCycle(_ppuViewerId, (int)this.nudScanline.Value, (int)this.nudCycle.Value); this.ctrlNametableViewer.GetData(); this.ctrlChrViewer.GetData(); this.ctrlSpriteViewer.GetData(); this.ctrlPaletteViewer.GetData(); this.ctrlNametableViewer.RefreshViewer(); this.ctrlChrViewer.RefreshViewer(); this.ctrlSpriteViewer.RefreshViewer(); this.ctrlPaletteViewer.RefreshViewer(); } }
private void lstCounters_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { AddressCounters counts = _counts[e.ItemIndex]; ListViewItem item = new ListViewItem("$" + counts.Address.ToString("X4")); item.Selected = false; item.Focused = false; item.SubItems.Add("$" + InteropEmu.DebugGetMemoryValue(_memoryType, counts.Address).ToString("X2")); item.SubItems.Add(FormatNumber(counts.ReadCount)); item.SubItems.Add(counts.ReadStamp > 0 ? FormatNumber(_cycleCount - counts.ReadStamp) : "n/a"); item.SubItems.Add(FormatNumber(counts.WriteCount)); item.SubItems.Add(counts.WriteStamp > 0 ? FormatNumber(_cycleCount - counts.WriteStamp) : "n/a"); item.SubItems.Add(FormatNumber(counts.ExecCount)); item.SubItems.Add(counts.ExecStamp > 0 ? FormatNumber(_cycleCount - counts.ExecStamp) : "n/a"); item.SubItems.Add(counts.UninitRead != 0 ? "☑" : "☐"); if (counts.ReadCount == 0 && counts.WriteCount == 0 && counts.ExecCount == 0) { item.ForeColor = Color.Gray; } e.Item = item; }
public static bool SetLabel(UInt32 address, AddressType type, string label, string comment, bool raiseEvent = true) { if (_labels.ContainsKey(GetKey(address, type))) { _reverseLookup.Remove(_labels[GetKey(address, type)].Label); } _labels[GetKey(address, type)] = new CodeLabel() { Address = address, AddressType = type, Label = label, Comment = comment }; if (label.Length > 0) { _reverseLookup[label] = _labels[GetKey(address, type)]; } InteropEmu.DebugSetLabel(address, type, label, comment.Replace(Environment.NewLine, "\n")); if (raiseEvent) { OnLabelUpdated?.Invoke(null, null); } return(true); }
public static void UpdateEmuLanguage() { InteropEmu.SetDisplayLanguage(_language); }
private void RefreshLog(bool scrollToBottom, bool forceUpdate) { if (_refreshRunning) { return; } //Make sure labels are up to date DebugWorkspaceManager.GetWorkspace(); _refreshRunning = true; SetOptions(); Task.Run(() => { //Update trace log in another thread for performance DebugState state = new DebugState(); InteropEmu.DebugGetState(ref state); if (_previousCycleCount != state.CPU.CycleCount || forceUpdate) { string newTrace = InteropEmu.DebugGetExecutionTrace((UInt32)_lineCount); _previousCycleCount = state.CPU.CycleCount; _previousTrace = newTrace; int index = 0; string line = null; Func <bool> readLine = () => { if (index < newTrace.Length) { int endOfLineIndex = newTrace.IndexOf('\n', index); line = newTrace.Substring(index, endOfLineIndex - index); index = endOfLineIndex + 1; return(true); } else { return(false); } }; List <int> programCounter = new List <int>(30000); List <string> byteCode = new List <string>(30000); List <string> lineContent = new List <string>(30000); List <int> indent = new List <int>(30000); bool showByteCode = false; while (readLine()) { string[] parts = line.Split('\x1'); programCounter.Add(Int32.Parse(parts[0], System.Globalization.NumberStyles.HexNumber)); byteCode.Add(parts[1]); string content = parts[2]; while (true) { string str = content.TrimStart(); if (str.StartsWith(parts[0])) { content = str.Substring(4); } else if (str.StartsWith(parts[1])) { content = str.Substring(11); showByteCode = true; } else if (str.StartsWith(parts[1].Replace("$", ""))) { content = str.Substring(8); showByteCode = true; } else { break; } } lineContent.Add(content); indent.Add(0); } this.BeginInvoke((Action)(() => { txtTraceLog.ShowContentNotes = showByteCode; txtTraceLog.ShowSingleContentLineNotes = showByteCode; txtTraceLog.LineIndentations = indent.ToArray(); txtTraceLog.LineNumbers = programCounter.ToArray(); txtTraceLog.TextLineNotes = byteCode.ToArray(); txtTraceLog.TextLines = lineContent.ToArray(); if (scrollToBottom) { txtTraceLog.ScrollToLineIndex(txtTraceLog.LineCount - 1); } })); } _refreshRunning = false; }); }
private void mnuGoToResetHandler_Click(object sender, EventArgs e) { int address = (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFD) << 8) | InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFC); this.OnGotoLocation?.Invoke(address, null); }
private void tmrButton_Tick(object sender, EventArgs e) { btnUndo.Enabled = this._dirty && InteropEmu.DebugIsExecutionStopped(); }
public void ProcessMouseMove(Point location) { if (_previousLocation != location) { bool closeExistingPopup = true; _previousLocation = location; string word = _codeViewer.GetWordUnderLocation(location); if (word.StartsWith("$")) { try { UInt32 address = UInt32.Parse(word.Substring(1), NumberStyles.AllowHexSpecifier); AddressTypeInfo info = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType(address, info); if (info.Address >= 0) { CodeLabel label = LabelManager.GetLabel((UInt32)info.Address, info.Type); if (label == null) { DisplayAddressTooltip(word, address); closeExistingPopup = false; } else { DisplayLabelTooltip(word, label); closeExistingPopup = false; } } else { DisplayAddressTooltip(word, address); closeExistingPopup = false; } } catch { } } else { int address = _codeViewer.GetLineNumberAtPosition(location.Y); if (SymbolProvider != null) { int rangeStart, rangeEnd; if (_codeViewer.GetNoteRangeAtLocation(location.Y, out rangeStart, out rangeEnd)) { Ld65DbgImporter.SymbolInfo symbol = SymbolProvider.GetSymbol(word, rangeStart, rangeEnd); if (symbol != null) { DisplaySymbolTooltip(symbol); return; } } } else { CodeLabel label = LabelManager.GetLabel(word); if (label != null) { DisplayLabelTooltip(word, label); return; } } if (ConfigManager.Config.DebugInfo.ShowOpCodeTooltips && frmOpCodeTooltip.IsOpCode(word)) { ShowTooltip(word, null, address, new AddressTypeInfo() { Address = address, Type = AddressType.Register }); closeExistingPopup = false; } } if (closeExistingPopup) { this.Close(); } } }
public void Import(string path, bool silent = false) { string[] fileRows = File.ReadAllLines(path); string basePath = Path.GetDirectoryName(path); foreach (string row in fileRows) { try { if (LoadLines(row) || LoadSpans(row) || LoadSymbols(row) || LoadCSymbols(row) || LoadFiles(row, basePath) || LoadSegments(row)) { continue; } } catch { _errorCount++; } } LoadFileData(basePath); int prgSize = InteropEmu.DebugGetMemorySize(DebugMemoryType.PrgRom); if (prgSize > 0) { byte[] cdlFile = new byte[prgSize]; foreach (KeyValuePair <int, SpanInfo> kvp in _spans) { SegmentInfo segment; if (_segments.TryGetValue(kvp.Value.SegmentID, out segment)) { if (!segment.IsRam && kvp.Value.Size != segment.Size) { int prgAddress = kvp.Value.Offset + segment.FileOffset - iNesHeaderSize; if (prgAddress >= 0 && prgAddress < prgSize) { for (int i = 0; i < kvp.Value.Size; i++) { if (cdlFile[prgAddress + i] == 0 && !kvp.Value.IsData && kvp.Value.Size <= 3) { cdlFile[prgAddress + i] = (byte)0x01; } else if (kvp.Value.IsData) { cdlFile[prgAddress + i] = (byte)0x02; } } } } } } InteropEmu.DebugSetCdlData(cdlFile); } foreach (LineInfo line in _lines.Values) { if (line.SpanID == null) { continue; } FileInfo file = _files[line.FileID]; SpanInfo span = _spans[line.SpanID.Value]; SegmentInfo segment = _segments[span.SegmentID]; if (!segment.IsRam) { for (int i = 0; i < span.Size; i++) { int prgAddress = segment.FileOffset - iNesHeaderSize + span.Offset + i; LineInfo existingLine; if (_linesByPrgAddress.TryGetValue(prgAddress, out existingLine) && existingLine.Type == LineType.External) { //Give priority to lines that come from C files continue; } _linesByPrgAddress[prgAddress] = line; if (i == 0) { _prgAddressByLine[file.ID.ToString() + "_" + line.LineNumber.ToString()] = prgAddress; } } } } LoadLabels(); int labelCount = 0; DebugImportConfig config = ConfigManager.Config.DebugInfo.ImportConfig; if (config.DbgImportComments) { LoadComments(); } if (config.DbgImportPrgRomLabels) { LabelManager.SetLabels(_romLabels.Values); labelCount += _romLabels.Count; } if (config.DbgImportRamLabels) { LabelManager.SetLabels(_ramLabels.Values); labelCount += _ramLabels.Count; } if (!silent) { if (_errorCount > 0) { _errorCount -= _filesNotFound.Count; string message = $"Import completed with {labelCount} labels imported"; if (_errorCount > 0) { message += $"and {_errorCount} errors - please file a bug report and attach the DBG file you tried to import."; } if (_filesNotFound.Count > 0) { message += Environment.NewLine + Environment.NewLine + "The following files could not be found:"; foreach (string file in _filesNotFound) { message += Environment.NewLine + file; } } MessageBox.Show(message, "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show($"Import completed with {labelCount} labels imported.", "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public void Prepare(long firstByteIndex, long lastByteIndex) { int visibleByteCount = (int)(lastByteIndex - firstByteIndex + 1); if (_highlightBreakpoints) { Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray(); _breakpointTypes = new BreakpointType[visibleByteCount]; for (int i = 0; i < visibleByteCount; i++) { int byteIndex = i + (int)firstByteIndex; foreach (Breakpoint bp in breakpoints) { if (bp.Enabled && bp.IsCpuBreakpoint && bp.Matches(byteIndex, _memoryType)) { _breakpointTypes[i] = bp.BreakOnExec ? BreakpointType.Execute : (bp.BreakOnWrite ? BreakpointType.WriteRam : BreakpointType.ReadRam); break; } } } } else { _breakpointTypes = null; } _readStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); _execStamps = InteropEmu.DebugGetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Exec); if (_memoryType == DebugMemoryType.CpuMemory) { _freezeState = InteropEmu.DebugGetFreezeState((UInt16)firstByteIndex, (UInt16)visibleByteCount); } _readCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); _execCounts = InteropEmu.DebugGetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Exec); _cdlData = null; if (_highlightDmcDataBytes || _highlightDataBytes || _highlightCodeBytes) { switch (_memoryType) { case DebugMemoryType.ChrRom: case DebugMemoryType.PpuMemory: case DebugMemoryType.CpuMemory: case DebugMemoryType.PrgRom: _cdlData = InteropEmu.DebugGetCdlData((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType); break; } } _hasLabel = new bool[visibleByteCount]; if (_highlightLabelledBytes) { if (_memoryType == DebugMemoryType.CpuMemory) { for (long i = 0; i < _hasLabel.Length; i++) { _hasLabel[i] = ( !string.IsNullOrWhiteSpace(LabelManager.GetLabel((UInt16)(i + firstByteIndex))?.Label) || !string.IsNullOrWhiteSpace(LabelManager.GetLabel((uint)(i + firstByteIndex), AddressType.Register)?.Label) ); } } else if (_memoryType == DebugMemoryType.PrgRom || _memoryType == DebugMemoryType.WorkRam || _memoryType == DebugMemoryType.SaveRam) { for (long i = 0; i < _hasLabel.Length; i++) { _hasLabel[i] = !string.IsNullOrWhiteSpace(LabelManager.GetLabel((uint)(firstByteIndex + i), _memoryType.ToAddressType())?.Label); } } } InteropEmu.DebugGetState(ref _state); }
protected override void OnClosing(CancelEventArgs e) { tmrUpdatePosition.Stop(); InteropEmu.HistoryViewerRelease(); base.OnClosing(e); }
private void trkVolume_ValueChanged(object sender, EventArgs e) { InteropEmu.SetMasterVolume(trkVolume.Value / 10d, 0, InteropEmu.ConsoleId.HistoryViewer); }
private void mnuResumeGameplay_Click(object sender, EventArgs e) { InteropEmu.HistoryViewerResumeGameplay(InteropEmu.HistoryViewerGetPosition()); }
public KeyPresets() { _wasdLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("K"), B = InteropEmu.GetKeyCode("J"), TurboA = InteropEmu.GetKeyCode(","), TurboB = InteropEmu.GetKeyCode("M"), Select = InteropEmu.GetKeyCode("U"), Start = InteropEmu.GetKeyCode("I"), Up = InteropEmu.GetKeyCode("W"), Down = InteropEmu.GetKeyCode("S"), Left = InteropEmu.GetKeyCode("A"), Right = InteropEmu.GetKeyCode("D") }; _arrowLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("S"), B = InteropEmu.GetKeyCode("A"), TurboA = InteropEmu.GetKeyCode("Z"), TurboB = InteropEmu.GetKeyCode("X"), Select = InteropEmu.GetKeyCode("Q"), Start = InteropEmu.GetKeyCode("W"), Up = InteropEmu.GetKeyCode("Up Arrow"), Down = InteropEmu.GetKeyCode("Down Arrow"), Left = InteropEmu.GetKeyCode("Left Arrow"), Right = InteropEmu.GetKeyCode("Right Arrow") }; _nestopiaLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("."), B = InteropEmu.GetKeyCode(","), TurboA = InteropEmu.GetKeyCode("L"), TurboB = InteropEmu.GetKeyCode("K"), Select = InteropEmu.GetKeyCode("Shift"), Start = InteropEmu.GetKeyCode("Enter"), Up = InteropEmu.GetKeyCode("Up Arrow"), Down = InteropEmu.GetKeyCode("Down Arrow"), Left = InteropEmu.GetKeyCode("Left Arrow"), Right = InteropEmu.GetKeyCode("Right Arrow") }; _fceuxLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("F"), B = InteropEmu.GetKeyCode("D"), TurboA = 0, TurboB = 0, Select = InteropEmu.GetKeyCode("S"), Start = InteropEmu.GetKeyCode("Enter"), Up = InteropEmu.GetKeyCode("Up Arrow"), Down = InteropEmu.GetKeyCode("Down Arrow"), Left = InteropEmu.GetKeyCode("Left Arrow"), Right = InteropEmu.GetKeyCode("Right Arrow") }; for (int i = 0; i < 2; i++) { string prefix = "Pad" + (i + 1).ToString() + " "; _xboxLayouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "A"), B = InteropEmu.GetKeyCode(prefix + "X"), TurboA = InteropEmu.GetKeyCode(prefix + "B"), TurboB = InteropEmu.GetKeyCode(prefix + "Y"), Select = InteropEmu.GetKeyCode(prefix + "Back"), Start = InteropEmu.GetKeyCode(prefix + "Start"), Up = InteropEmu.GetKeyCode(prefix + "Up"), Down = InteropEmu.GetKeyCode(prefix + "Down"), Left = InteropEmu.GetKeyCode(prefix + "Left"), Right = InteropEmu.GetKeyCode(prefix + "Right") }; prefix = "Joy" + (i + 1).ToString() + " "; _ps4Layouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "But2"), B = InteropEmu.GetKeyCode(prefix + "But1"), TurboA = InteropEmu.GetKeyCode(prefix + "But3"), TurboB = InteropEmu.GetKeyCode(prefix + "But4"), Select = InteropEmu.GetKeyCode(prefix + "But9"), Start = InteropEmu.GetKeyCode(prefix + "But10"), Up = InteropEmu.GetKeyCode(prefix + "DPad Up"), Down = InteropEmu.GetKeyCode(prefix + "DPad Down"), Left = InteropEmu.GetKeyCode(prefix + "DPad Left"), Right = InteropEmu.GetKeyCode(prefix + "DPad Right") }; _snes30Layouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "But2"), B = InteropEmu.GetKeyCode(prefix + "But5"), TurboA = InteropEmu.GetKeyCode(prefix + "But1"), TurboB = InteropEmu.GetKeyCode(prefix + "But4"), Select = InteropEmu.GetKeyCode(prefix + "But11"), Start = InteropEmu.GetKeyCode(prefix + "But12"), Up = InteropEmu.GetKeyCode(prefix + "Y+"), Down = InteropEmu.GetKeyCode(prefix + "Y-"), Left = InteropEmu.GetKeyCode(prefix + "X-"), Right = InteropEmu.GetKeyCode(prefix + "X+") }; } }
public List <string> GetCode(out int byteLength, ref int startAddress, int endAddress = -1) { _code.InitAssemblerValues(); List <string> result = new List <string>(); byteLength = 0; if (endAddress == -1) { //When no end address is specified, find the start of the function based on startAddress int address = InteropEmu.DebugFindSubEntryPoint((UInt16)startAddress); if (address != -1) { startAddress = address; } } for (int i = startAddress; (i <= endAddress || endAddress == -1) && endAddress < 65536;) { string code; if (_code.CodeContent.TryGetValue(i, out code)) { code = code.Split('\x2')[0].Trim(); if (code.StartsWith("--") || code.StartsWith("__")) { //Stop adding code when we find a new section (new function, data blocks, etc.) break; } AddressTypeInfo info = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((UInt32)i, info); CodeLabel codeLabel = info.Address >= 0 ? LabelManager.GetLabel((UInt32)info.Address, AddressType.PrgRom) : null; string comment = codeLabel?.Comment; string label = codeLabel?.Label; bool addPadding = true; if (code.StartsWith("STP*") || code.StartsWith("NOP*")) { //Transform unofficial opcodes that can't be reassembled properly into .byte statements if (comment != null) { comment.Insert(0, code + " - "); } else { comment = code; } code = ".byte " + string.Join(",", _code.CodeByteCode[i].Split(' ')); addPadding = false; } if (!string.IsNullOrWhiteSpace(comment) && comment.Contains("\n")) { result.AddRange(comment.Replace("\r", "").Split('\n').Select(cmt => ";" + cmt)); comment = null; } if (!string.IsNullOrWhiteSpace(label)) { result.Add(label + ":"); } result.Add((addPadding ? " " : "") + code + (!string.IsNullOrWhiteSpace(comment) ? (" ;" + comment) : "")); int length = _code.CodeByteCode[i].Count(c => c == ' ') + 1; byteLength += length; i += length; if (endAddress == -1 && (string.Compare(code, "RTI", true) == 0 || string.Compare(code, "RTS", true) == 0)) { break; } } else { break; } } result.Add(""); return(result); }
public static void ClearCheats() { InteropEmu.SetCheats(new InteropCheatInfo[] { }, 0); }
private void DisplaySymbolTooltip(Ld65DbgImporter.SymbolInfo symbol) { AddressTypeInfo addressInfo = SymbolProvider.GetSymbolAddressInfo(symbol); if (addressInfo != null && addressInfo.Address >= 0) { int relativeAddress = InteropEmu.DebugGetRelativeAddress((uint)addressInfo.Address, addressInfo.Type); byte byteValue = relativeAddress >= 0 ? InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, (UInt32)relativeAddress) : (byte)0; UInt16 wordValue = relativeAddress >= 0 ? (UInt16)(byteValue | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, (UInt32)relativeAddress + 1) << 8)) : (UInt16)0; var values = new Dictionary <string, string>() { { "Symbol", symbol.Name } }; if (relativeAddress >= 0) { values["CPU Address"] = "$" + relativeAddress.ToString("X4"); } else { values["CPU Address"] = "<out of scope>"; } if (addressInfo.Type == AddressType.PrgRom) { values["PRG Offset"] = "$" + addressInfo.Address.ToString("X4"); } values["Value"] = (relativeAddress >= 0 ? $"${byteValue.ToString("X2")} (byte){Environment.NewLine}${wordValue.ToString("X4")} (word)" : "n/a"); ShowTooltip(symbol.Name, values, -1, addressInfo); } else { var values = new Dictionary <string, string>() { { "Symbol", symbol.Name }, { "Constant", symbol.Address.HasValue ? ("$" + symbol.Address.Value.ToString("X2")) : "<unknown>" } }; ShowTooltip(symbol.Name, values, -1, addressInfo); } }
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); } } } }
private bool UpdateContextMenu(Point mouseLocation) { _lastLocation = mouseLocation; UpdateContextMenuItemVisibility(true); mnuSwitchView.Text = SourceView ? "Switch to Disassembly View" : "Switch to Source View"; string word = Viewer.CodeViewer.GetWordUnderLocation(mouseLocation); Ld65DbgImporter.SymbolInfo symbol = null; CodeLabel codeLabel = null; if (!word.StartsWith("$")) { codeLabel = LabelManager.GetLabel(word); if (Viewer.SymbolProvider != null) { int rangeStart, rangeEnd; if (Viewer.CodeViewer.GetNoteRangeAtLocation(mouseLocation.Y, out rangeStart, out rangeEnd)) { symbol = Viewer.SymbolProvider.GetSymbol(word, rangeStart, rangeEnd); if (symbol?.SegmentID == null) { symbol = null; } } } } if (word.StartsWith("$") || codeLabel != null || symbol != null) { //Cursor is on a numeric value or label _lastWord = word; if (word.StartsWith("$")) { //CPU Address _lastClickedAddress = Int32.Parse(word.Substring(1), NumberStyles.AllowHexSpecifier); _newWatchValue = "[$" + _lastClickedAddress.ToString("X") + "]"; } else if (symbol != null) { //Symbol AddressTypeInfo addressInfo = (AddressTypeInfo)Viewer.SymbolProvider.GetSymbolAddressInfo(symbol); _lastClickedAddress = (Int32)InteropEmu.DebugGetRelativeAddress((uint)addressInfo.Address, addressInfo.Type); bool matchingLabelExists = codeLabel != null && codeLabel.Label == symbol.Name; _newWatchValue = matchingLabelExists ? $"[{word}]" : $"[${_lastClickedAddress.ToString("X2")}]"; } else if (codeLabel != null) { //Label _lastClickedAddress = (Int32)InteropEmu.DebugGetRelativeAddress(codeLabel.Address, codeLabel.AddressType); _newWatchValue = "[" + word + "]"; } mnuGoToLocation.Enabled = true; mnuGoToLocation.Text = $"Go to Location ({word})"; mnuShowInSplitView.Enabled = true; mnuShowInSplitView.Text = $"Show in Split View ({word})"; mnuAddToWatch.Enabled = true; mnuAddToWatch.Text = $"Add to Watch ({word})"; mnuFindOccurrences.Enabled = true; mnuFindOccurrences.Text = $"Find Occurrences ({word})"; mnuEditLabel.Enabled = true; mnuEditLabel.Text = $"Edit Label ({word})"; mnuEditInMemoryViewer.Enabled = true; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer ({word})"; return(true); } else { mnuGoToLocation.Enabled = false; mnuGoToLocation.Text = "Go to Location"; mnuShowInSplitView.Enabled = false; mnuShowInSplitView.Text = "Show in Split View"; mnuAddToWatch.Enabled = false; mnuAddToWatch.Text = "Add to Watch"; mnuFindOccurrences.Enabled = false; mnuFindOccurrences.Text = "Find Occurrences"; mnuEditLabel.Enabled = false; mnuEditLabel.Text = "Edit Label"; mnuEditInMemoryViewer.Enabled = false; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer"; if (mouseLocation.X < Viewer.CodeViewer.CodeMargin) { _lastClickedAddress = Viewer.CodeViewer.GetLineNumberAtPosition(mouseLocation.Y); } else { _lastClickedAddress = Viewer.CodeViewer.LastSelectedLine; } if (_lastClickedAddress >= 0) { //Cursor is in the margin, over an address label string address = $"${_lastClickedAddress.ToString("X4")}"; _newWatchValue = $"[{address}]"; _lastWord = address; mnuShowInSplitView.Enabled = true; mnuShowInSplitView.Text = $"Show in Split View ({address})"; mnuAddToWatch.Enabled = true; mnuAddToWatch.Text = $"Add to Watch ({address})"; mnuFindOccurrences.Enabled = true; mnuFindOccurrences.Text = $"Find Occurrences ({address})"; mnuEditLabel.Enabled = true; mnuEditLabel.Text = $"Edit Label ({address})"; mnuEditInMemoryViewer.Enabled = true; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer ({address})"; return(true); } return(false); } }
private void mnuDebug_DropDownOpening(object sender, EventArgs e) { mnuEditHeader.Enabled = _emuThread != null && InteropEmu.GetRomInfo().Format == RomFormat.iNes; }
private void UpdateVectorAddresses() { bool isNsf = InteropEmu.GetRomInfo().Format == RomFormat.Nsf; if (isNsf) { NsfHeader header = InteropEmu.NsfGetHeader(); mnuGoToInitHandler.Text = "Init Handler ($" + header.InitAddress.ToString("X4") + ")"; mnuGoToPlayHandler.Text = "Play Handler ($" + header.PlayAddress.ToString("X4") + ")"; } else { int nmiHandler = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFA) | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFB) << 8); int resetHandler = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFC) | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFD) << 8); int irqHandler = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFE) | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFF) << 8); mnuGoToNmiHandler.Text = "NMI Handler ($" + nmiHandler.ToString("X4") + ")"; mnuGoToResetHandler.Text = "Reset Handler ($" + resetHandler.ToString("X4") + ")"; mnuGoToIrqHandler.Text = "IRQ Handler ($" + irqHandler.ToString("X4") + ")"; } mnuGoToInitHandler.Visible = isNsf; mnuGoToPlayHandler.Visible = isNsf; mnuGoToIrqHandler.Visible = !isNsf; mnuGoToNmiHandler.Visible = !isNsf; mnuGoToResetHandler.Visible = !isNsf; }
private void mnuNetPlayPlayer5_Click(object sender, EventArgs e) { InteropEmu.NetPlaySelectController(4); }
private void mnuGoToPlayHandler_Click(object sender, EventArgs e) { this.OnGotoLocation?.Invoke((int)InteropEmu.NsfGetHeader().PlayAddress, null); }
private void mnuNetPlaySpectator_Click(object sender, EventArgs e) { InteropEmu.NetPlaySelectController(0xFF); }
private void btnClearLog_Click(object sender, EventArgs e) { InteropEmu.DebugClearTraceLog(); RefreshLog(true, true); }
private void mnuStopMovie_Click(object sender, EventArgs e) { InteropEmu.MovieStop(); }
public KeyPresets() { _wasdLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("K"), B = InteropEmu.GetKeyCode("J"), TurboA = InteropEmu.GetKeyCode(","), TurboB = InteropEmu.GetKeyCode("M"), Select = InteropEmu.GetKeyCode("U"), Start = InteropEmu.GetKeyCode("I"), Up = InteropEmu.GetKeyCode("W"), Down = InteropEmu.GetKeyCode("S"), Left = InteropEmu.GetKeyCode("A"), Right = InteropEmu.GetKeyCode("D") }; _arrowLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("S"), B = InteropEmu.GetKeyCode("A"), TurboA = InteropEmu.GetKeyCode("X"), TurboB = InteropEmu.GetKeyCode("Z"), Select = InteropEmu.GetKeyCode("Q"), Start = InteropEmu.GetKeyCode("W"), Up = InteropEmu.GetKeyCode("Up Arrow"), Down = InteropEmu.GetKeyCode("Down Arrow"), Left = InteropEmu.GetKeyCode("Left Arrow"), Right = InteropEmu.GetKeyCode("Right Arrow") }; _nestopiaLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("."), B = InteropEmu.GetKeyCode(","), TurboA = InteropEmu.GetKeyCode("L"), TurboB = InteropEmu.GetKeyCode("K"), Select = InteropEmu.GetKeyCode("Shift"), Start = InteropEmu.GetKeyCode("Enter"), Up = InteropEmu.GetKeyCode("Up Arrow"), Down = InteropEmu.GetKeyCode("Down Arrow"), Left = InteropEmu.GetKeyCode("Left Arrow"), Right = InteropEmu.GetKeyCode("Right Arrow") }; _fceuxLayout = new KeyMappings() { A = InteropEmu.GetKeyCode("F"), B = InteropEmu.GetKeyCode("D"), TurboA = 0, TurboB = 0, Select = InteropEmu.GetKeyCode("S"), Start = InteropEmu.GetKeyCode("Enter"), Up = InteropEmu.GetKeyCode("Up Arrow"), Down = InteropEmu.GetKeyCode("Down Arrow"), Left = InteropEmu.GetKeyCode("Left Arrow"), Right = InteropEmu.GetKeyCode("Right Arrow") }; _player2KeyboardLayout = new KeyMappings() { A = InteropEmu.GetKeyCode(";"), B = InteropEmu.GetKeyCode("L"), TurboA = InteropEmu.GetKeyCode("/"), TurboB = InteropEmu.GetKeyCode("."), Select = InteropEmu.GetKeyCode("O"), Start = InteropEmu.GetKeyCode("P"), Up = InteropEmu.GetKeyCode("Y"), Down = InteropEmu.GetKeyCode("H"), Left = InteropEmu.GetKeyCode("G"), Right = InteropEmu.GetKeyCode("J") }; if (Program.IsMono) { for (int i = 0; i < 2; i++) { string prefix = "Pad" + (i + 1).ToString() + " "; _xboxLayouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "A"), B = InteropEmu.GetKeyCode(prefix + "X"), TurboA = InteropEmu.GetKeyCode(prefix + "B"), TurboB = InteropEmu.GetKeyCode(prefix + "Y"), Select = InteropEmu.GetKeyCode(prefix + "Select"), Start = InteropEmu.GetKeyCode(prefix + "Start"), Up = InteropEmu.GetKeyCode(prefix + "Up"), Down = InteropEmu.GetKeyCode(prefix + "Down"), Left = InteropEmu.GetKeyCode(prefix + "Left"), Right = InteropEmu.GetKeyCode(prefix + "Right") }; _ps4Layouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "B"), B = InteropEmu.GetKeyCode(prefix + "A"), TurboA = InteropEmu.GetKeyCode(prefix + "C"), TurboB = InteropEmu.GetKeyCode(prefix + "X"), Select = InteropEmu.GetKeyCode(prefix + "L2"), Start = InteropEmu.GetKeyCode(prefix + "R2"), Up = InteropEmu.GetKeyCode(prefix + "Up"), Down = InteropEmu.GetKeyCode(prefix + "Down"), Left = InteropEmu.GetKeyCode(prefix + "Left"), Right = InteropEmu.GetKeyCode(prefix + "Right") }; _snes30Layouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "Thumb"), B = InteropEmu.GetKeyCode(prefix + "Top2"), TurboA = InteropEmu.GetKeyCode(prefix + "Trigger"), TurboB = InteropEmu.GetKeyCode(prefix + "Top"), Select = InteropEmu.GetKeyCode(prefix + "Base5"), Start = InteropEmu.GetKeyCode(prefix + "Base6"), Up = InteropEmu.GetKeyCode(prefix + "Y-"), Down = InteropEmu.GetKeyCode(prefix + "Y+"), Left = InteropEmu.GetKeyCode(prefix + "X-"), Right = InteropEmu.GetKeyCode(prefix + "X+") }; } } else { for (int i = 0; i < 2; i++) { string prefix = "Pad" + (i + 1).ToString() + " "; _xboxLayouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "A"), B = InteropEmu.GetKeyCode(prefix + "X"), TurboA = InteropEmu.GetKeyCode(prefix + "B"), TurboB = InteropEmu.GetKeyCode(prefix + "Y"), Select = InteropEmu.GetKeyCode(prefix + "Back"), Start = InteropEmu.GetKeyCode(prefix + "Start"), Up = InteropEmu.GetKeyCode(prefix + "Up"), Down = InteropEmu.GetKeyCode(prefix + "Down"), Left = InteropEmu.GetKeyCode(prefix + "Left"), Right = InteropEmu.GetKeyCode(prefix + "Right") }; prefix = "Joy" + (i + 1).ToString() + " "; _ps4Layouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "But2"), B = InteropEmu.GetKeyCode(prefix + "But1"), TurboA = InteropEmu.GetKeyCode(prefix + "But3"), TurboB = InteropEmu.GetKeyCode(prefix + "But4"), Select = InteropEmu.GetKeyCode(prefix + "But9"), Start = InteropEmu.GetKeyCode(prefix + "But10"), Up = InteropEmu.GetKeyCode(prefix + "DPad Up"), Down = InteropEmu.GetKeyCode(prefix + "DPad Down"), Left = InteropEmu.GetKeyCode(prefix + "DPad Left"), Right = InteropEmu.GetKeyCode(prefix + "DPad Right") }; _snes30Layouts[i] = new KeyMappings() { A = InteropEmu.GetKeyCode(prefix + "But2"), B = InteropEmu.GetKeyCode(prefix + "But5"), TurboA = InteropEmu.GetKeyCode(prefix + "But1"), TurboB = InteropEmu.GetKeyCode(prefix + "But4"), Select = InteropEmu.GetKeyCode(prefix + "But11"), Start = InteropEmu.GetKeyCode(prefix + "But12"), Up = InteropEmu.GetKeyCode(prefix + "Y+"), Down = InteropEmu.GetKeyCode(prefix + "Y-"), Left = InteropEmu.GetKeyCode(prefix + "X-"), Right = InteropEmu.GetKeyCode(prefix + "X+") }; } } }
private void mnuAviStop_Click(object sender, EventArgs e) { InteropEmu.AviStop(); }