MCPcopy Create free account
hub / github.com/cemu-project/Cemu / UpdateIntegerRegister

Method UpdateIntegerRegister

src/gui/debugger/RegisterWindow.cpp:137–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void RegisterWindow::UpdateIntegerRegister(wxTextCtrl* label, wxTextCtrl* value, uint32 registerValue, bool hasChanged)
138{
139 //const auto value = dynamic_cast<wxTextCtrl*>(GetWindowChild(kRegisterValueR0 + i));
140 //wxASSERT(value);
141
142 //const bool has_changed = register_value != m_prev_snapshot.gpr[i];
143 if (hasChanged)
144 value->SetForegroundColour(COLOR_RED);
145 else if (value->GetForegroundColour() != COLOR_BLACK)
146 value->SetForegroundColour(COLOR_BLACK);
147
148 value->ChangeValue(wxString::Format("%08x", registerValue));
149
150 //const auto label = dynamic_cast<wxTextCtrl*>(GetWindowChild(kRegisterLabelR0 + i));
151 //wxASSERT(label);
152 label->SetForegroundColour(hasChanged ? COLOR_RED : COLOR_BLACK);
153
154 // check if address is a string
155 if (registerValue >= MEMORY_DATA_AREA_ADDR && registerValue < (MEMORY_DATA_AREA_ADDR + MEMORY_DATA_AREA_SIZE))
156 {
157 bool is_valid_string = true;
158 std::stringstream buffer;
159
160 uint32 string_offset = registerValue;
161 while (string_offset < (MEMORY_DATA_AREA_ADDR + MEMORY_DATA_AREA_SIZE))
162 {
163 const uint8 c = memory_readU8(string_offset++);
164 if (isprint(c))
165 buffer << c;
166 else if (c == '\0')
167 {
168 buffer << c;
169 break;
170 }
171 else
172 {
173 is_valid_string = false;
174 break;
175 }
176 }
177
178 if (is_valid_string && buffer.tellp() > 1)
179 {
180 label->ChangeValue(wxString::Format("\"%s\"", buffer.str().c_str()));
181 return;
182 }
183
184 // check for widestring
185 is_valid_string = true;
186 string_offset = registerValue;
187 std::wstringstream wbuffer;
188 while (string_offset < (MEMORY_DATA_AREA_ADDR + MEMORY_DATA_AREA_SIZE - 1))
189 {
190 const uint16 c = memory_readU16(string_offset);
191 string_offset += 2;
192
193 if (iswprint(c))
194 wbuffer << c;

Callers

nothing calls this directly

Calls 5

memory_readU8Function · 0.85
memory_readU16Function · 0.85
c_strMethod · 0.45
GetMPTRMethod · 0.45

Tested by

no test coverage detected