MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / contextPasteInstructionText

Method contextPasteInstructionText

pcsx2-qt/Debugger/DisassemblyView.cpp:109–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void DisassemblyView::contextPasteInstructionText()
110{
111 if (!cpu().isCpuPaused())
112 {
113 AsyncDialogs::warning(this, tr("Assemble Error"), tr("Unable to change assembly while core is running"));
114 return;
115 }
116
117 // split text in clipboard by new lines
118 QString clipboardText = QApplication::clipboard()->text();
119 std::vector<std::string> newInstructions = StringUtil::splitOnNewLine(clipboardText.toLocal8Bit().constData());
120 u32 newInstructionsSize = static_cast<u32>(newInstructions.size());
121
122 // validate new instructions before pasting them
123 std::vector<u32> encodedInstructions;
124 for (u32 instructionIdx = 0; instructionIdx < newInstructionsSize; instructionIdx++)
125 {
126 u32 replaceAddress = m_selectedAddressStart + instructionIdx * 4;
127 u32 encodedInstruction;
128 std::string errorText;
129 bool valid = MipsAssembleOpcode(newInstructions[instructionIdx].c_str(), &cpu(), replaceAddress, encodedInstruction, errorText);
130 if (!valid)
131 {
132 AsyncDialogs::warning(this, tr("Assemble Error"), QString("%1 %2").arg(errorText.c_str()).arg(newInstructions[instructionIdx].c_str()));
133 return;
134 }
135 encodedInstructions.push_back(encodedInstruction);
136 }
137
138 // paste validated instructions
139 for (u32 instructionIdx = 0; instructionIdx < newInstructionsSize; instructionIdx++)
140 {
141 u32 replaceAddress = m_selectedAddressStart + instructionIdx * 4;
142 setInstructions(replaceAddress, replaceAddress, encodedInstructions[instructionIdx]);
143 }
144}
145
146void DisassemblyView::contextAssembleInstruction()
147{

Callers

nothing calls this directly

Calls 7

splitOnNewLineFunction · 0.85
MipsAssembleOpcodeFunction · 0.85
isCpuPausedMethod · 0.80
argMethod · 0.80
sizeMethod · 0.45
c_strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected