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."); } if (NeedRtiRtsWarning) { warningMessages.Add("Warning: The code originally contained an RTI/RTS instruction and it no longer does - this will probably cause problems."); } } else { warningMessages.Add($"Warning: The contents currently mapped to CPU memory addresses ${_startAddress.ToString("X4")} to ${(_startAddress+ctrlHexBox.ByteProvider.Length).ToString("X4")} 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) { WaitUntilBreak(); byte lastByte = ctrlHexBox.ByteProvider.ReadByte(ctrlHexBox.ByteProvider.Length - 1); bool endsWithRtiRts = lastByte == 0x40 || lastByte == 0x60; int byteGap = (int)(_blockLength - ctrlHexBox.ByteProvider.Length); List <byte> bytes = new List <byte>(((StaticByteProvider)ctrlHexBox.ByteProvider).Bytes); if (byteGap > 0) { //Pad data with NOPs as needed int insertPoint = endsWithRtiRts ? bytes.Count - 1 : bytes.Count; for (int i = 0; i < byteGap; i++) { bytes.Insert(insertPoint, 0xEA); //0xEA = NOP } } InteropEmu.DebugSetMemoryValues(DebugMemoryType.CpuMemory, (UInt32)_startAddress, bytes.ToArray()); frmDebugger debugger = DebugWindowManager.GetDebugger(); if (debugger != null) { debugger.UpdateDebugger(false); } else { InteropEmu.DebugRun(); } this.DialogResult = DialogResult.OK; this.Close(); } }
private void MarkSelectionAs(int start, int end, CdlPrgFlags type) { if (_memoryType == DebugMemoryType.CpuMemory) { start = InteropEmu.DebugGetAbsoluteAddress((UInt32)start); end = InteropEmu.DebugGetAbsoluteAddress((UInt32)end); } if (start >= 0 && end >= 0 && start <= end) { InteropEmu.DebugMarkPrgBytesAs((UInt32)start, (UInt32)end, type); frmDebugger debugger = DebugWindowManager.GetDebugger(); if (debugger != null) { debugger.UpdateDebugger(false, false); } } }
private void MarkSelectionAs(CdlPrgFlags type) { int startAddress, endAddress; string range; GetSelectedAddressRange(out startAddress, out endAddress, out range); if (startAddress >= 0 && endAddress >= 0 && startAddress <= endAddress) { InteropEmu.DebugMarkPrgBytesAs((UInt32)startAddress, (UInt32)endAddress, type); frmDebugger debugger = DebugWindowManager.GetDebugger(); if (debugger != null) { debugger.UpdateDebugger(false); } } }