private void btnOk_Click(object sender, EventArgs e) { List <string> warningMessages = new List <string>(); if (_hasParsingErrors) { warningMessages.Add("Warning: The code contains parsing errors - lines with errors will be ignored."); } if (_isEditMode) { if (SizeExceeded) { warningMessages.Add("Warning: The new code exceeds the original code's length." + Environment.NewLine + "Applying this modification will overwrite other portions of the code and potentially cause problems."); } } else { warningMessages.Add($"Warning: The contents currently mapped to CPU memory addresses ${_startAddress.ToString("X6")} to ${(_startAddress+ctrlHexBox.ByteProvider.Length).ToString("X6")} will be overridden."); } if (warningMessages.Count == 0 || MessageBox.Show(string.Join(Environment.NewLine + Environment.NewLine, warningMessages.ToArray()) + Environment.NewLine + Environment.NewLine + "OK?", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK) { List <byte> bytes = new List <byte>(((StaticByteProvider)ctrlHexBox.ByteProvider).Bytes); int byteGap = (int)(_blockLength - ctrlHexBox.ByteProvider.Length); for (int i = 0; i < byteGap; i++) { //Pad data with NOPs as needed bytes.Add(0xEA); } DebugApi.SetMemoryValues(SnesMemoryType.CpuMemory, (UInt32)_startAddress, bytes.ToArray(), bytes.Count); AddressInfo absStart = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = _startAddress, Type = SnesMemoryType.CpuMemory }); AddressInfo absEnd = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = _startAddress + bytes.Count, Type = SnesMemoryType.CpuMemory }); if (absStart.Type == SnesMemoryType.PrgRom && absEnd.Type == SnesMemoryType.PrgRom && (absEnd.Address - absStart.Address) == bytes.Count) { DebugApi.MarkBytesAs((uint)absStart.Address, (uint)absEnd.Address, CdlFlags.Code); } frmDebugger debugger = DebugWindowManager.OpenDebugger(CpuType.Cpu); if (debugger != null) { debugger.RefreshDisassembly(); } this.DialogResult = DialogResult.OK; this.Close(); } }
private void mnuViewInDisassembly_Click(object sender, EventArgs e) { if (lstWatch.SelectedItems.Count != 1) { return; } if (_selectedAddress >= 0) { DebugWindowManager.OpenDebugger(_cpuType).GoToAddress(_selectedAddress); } else if (_selectedLabel != null) { AddressInfo relAddress = _selectedLabel.GetRelativeAddress(_cpuType); if (relAddress.Address >= 0) { DebugWindowManager.OpenDebugger(_cpuType).GoToAddress(relAddress.Address); } } }