mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Kill AsciiToHex
Now superseded by Common::FromChars
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/GekkoDisassembler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Core.h"
|
||||
@ -451,22 +452,23 @@ PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instructio
|
||||
if (!std::regex_search(instruction, match, re))
|
||||
return std::nullopt;
|
||||
|
||||
// Output: match.str(1): negative sign for offset or no match. match.str(2): 0xNNNN, 0, or
|
||||
// rNN. Check next for 'r' to see if a gpr needs to be loaded. match.str(3): will either be p,
|
||||
// toc, or NN. Always a gpr.
|
||||
const std::string offset_match = match.str(2);
|
||||
const std::string register_match = match.str(3);
|
||||
// match[1]: negative sign for offset or no match.
|
||||
// match[2]: 0xNNNN, 0, or rNN. Check next for 'r' to see if a gpr needs to be loaded.
|
||||
// match[3]: will either be p, toc, or NN. Always a gpr.
|
||||
const std::string_view offset_match{&*match[2].first, size_t(match[2].length())};
|
||||
const std::string_view register_match{&*match[3].first, size_t(match[3].length())};
|
||||
constexpr char is_reg = 'r';
|
||||
u32 offset = 0;
|
||||
|
||||
if (is_reg == offset_match[0])
|
||||
{
|
||||
const int register_index = std::stoi(offset_match.substr(1), nullptr, 10);
|
||||
unsigned register_index;
|
||||
Common::FromChars(offset_match.substr(1), register_index, 10);
|
||||
offset = (register_index == 0 ? 0 : m_system.GetPPCState().gpr[register_index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = static_cast<u32>(std::stoi(offset_match, nullptr, 16));
|
||||
Common::FromChars(offset_match, offset, 16);
|
||||
}
|
||||
|
||||
// sp and rtoc need to be converted to 1 and 2.
|
||||
@ -479,11 +481,11 @@ PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instructio
|
||||
else if (is_rtoc == register_match[0])
|
||||
i = 2;
|
||||
else
|
||||
i = std::stoi(register_match, nullptr, 10);
|
||||
Common::FromChars(register_match, i, 10);
|
||||
|
||||
const u32 base_address = m_system.GetPPCState().gpr[i];
|
||||
|
||||
if (!match.str(1).empty())
|
||||
if (std::string_view sign{&*match[1].first, size_t(match[1].length())}; !sign.empty())
|
||||
return base_address - offset;
|
||||
|
||||
return base_address + offset;
|
||||
|
Reference in New Issue
Block a user