update Cheat files

This commit is contained in:
Nayla Hanegan 2023-04-20 20:32:13 -04:00
commit cbfd634a4b
No known key found for this signature in database
GPG key ID: BAFE9001DA16CFA2
217 changed files with 2263 additions and 1880 deletions

View file

@ -3092,7 +3092,7 @@ void ARM64FloatEmitter::FMOV(ARM64Reg Rd, uint8_t imm8)
// Vector
void ARM64FloatEmitter::ADD(u8 size, ARM64Reg Rd, ARM64Reg Rn, ARM64Reg Rm)
{
EmitThreeSame(0, IntLog2(size) - 3, 0b10000, Rd, Rn, Rm);
EmitThreeSame(0, MathUtil::IntLog2(size) - 3, 0b10000, Rd, Rn, Rm);
}
void ARM64FloatEmitter::AND(ARM64Reg Rd, ARM64Reg Rn, ARM64Reg Rm)
{

View file

@ -41,8 +41,8 @@ add_library(common
DebugInterface.h
DynamicLibrary.cpp
DynamicLibrary.h
ENetUtil.cpp
ENetUtil.h
ENet.cpp
ENet.h
EnumFormatter.h
EnumMap.h
Event.h
@ -80,7 +80,6 @@ add_library(common
Logging/Log.h
Logging/LogManager.cpp
Logging/LogManager.h
MathUtil.cpp
MathUtil.h
Matrix.cpp
Matrix.h
@ -299,7 +298,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(common PUBLIC dl rt)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(WIN32)
target_sources(common PRIVATE HRWrap.h HRWrap.cpp)
endif()

View file

@ -13,6 +13,8 @@
#define strerror_r(err, buf, len) strerror_s(buf, len, err)
#endif
namespace Common
{
constexpr size_t BUFFER_SIZE = 256;
// Wrapper function to get last strerror(errno) string.
@ -73,3 +75,4 @@ std::optional<std::wstring> GetModuleName(void* hInstance)
return name;
}
#endif
} // namespace Common

View file

@ -39,6 +39,8 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
}
#endif // WIN32 ndef
namespace Common
{
// Wrapper function to get last strerror(errno) string.
// This function might change the error code.
std::string LastStrerrorString();
@ -51,3 +53,4 @@ std::string GetLastErrorString();
// Obtains a full path to the specified module.
std::optional<std::wstring> GetModuleName(void* hInstance);
#endif
} // namespace Common

View file

@ -170,7 +170,7 @@ static std::optional<std::wstring> GetModulePath(const wchar_t* name)
if (module == nullptr)
return std::nullopt;
return GetModuleName(module);
return Common::GetModuleName(module);
}
static bool GetModuleVersion(const wchar_t* name, Version* version)

View file

@ -3,42 +3,45 @@
#include "Common/Crypto/bn.h"
#include <cstddef>
#include <cstdio>
#include <cstring>
#include "Common/CommonTypes.h"
static void bn_zero(u8* d, int n)
static void bn_zero(u8* d, const size_t n)
{
std::memset(d, 0, n);
}
static void bn_copy(u8* d, const u8* a, int n)
static void bn_copy(u8* d, const u8* a, const size_t n)
{
std::memcpy(d, a, n);
}
int bn_compare(const u8* a, const u8* b, int n)
int bn_compare(const u8* a, const u8* b, const size_t n)
{
return std::memcmp(a, b, n);
}
void bn_sub_modulus(u8* a, const u8* N, int n)
void bn_sub_modulus(u8* a, const u8* N, const size_t n)
{
u8 c = 0;
for (int i = n - 1; i >= 0; --i)
for (size_t i = n; i > 0;)
{
--i;
u32 dig = N[i] + c;
c = (a[i] < dig);
a[i] -= dig;
}
}
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n)
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, const size_t n)
{
u8 c = 0;
for (int i = n - 1; i >= 0; --i)
for (size_t i = n; i > 0;)
{
--i;
u32 dig = a[i] + b[i] + c;
c = (dig >= 0x100);
d[i] = dig;
@ -51,11 +54,11 @@ void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n)
bn_sub_modulus(d, N, n);
}
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n)
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, const size_t n)
{
bn_zero(d, n);
for (int i = 0; i < n; i++)
for (size_t i = 0; i < n; i++)
{
for (u8 mask = 0x80; mask != 0; mask >>= 1)
{
@ -66,13 +69,13 @@ void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n)
}
}
void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en)
void bn_exp(u8* d, const u8* a, const u8* N, const size_t n, const u8* e, const size_t en)
{
u8 t[512];
bn_zero(d, n);
d[n - 1] = 1;
for (int i = 0; i < en; i++)
for (size_t i = 0; i < en; i++)
{
for (u8 mask = 0x80; mask != 0; mask >>= 1)
{
@ -86,7 +89,7 @@ void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en)
}
// only for prime N -- stupid but lazy, see if I care
void bn_inv(u8* d, const u8* a, const u8* N, int n)
void bn_inv(u8* d, const u8* a, const u8* N, const size_t n)
{
u8 t[512], s[512];

View file

@ -3,13 +3,15 @@
#pragma once
#include <cstddef>
#include "Common/CommonTypes.h"
// bignum arithmetic
int bn_compare(const u8* a, const u8* b, int n);
void bn_sub_modulus(u8* a, const u8* N, int n);
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, int n);
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, int n);
void bn_inv(u8* d, const u8* a, const u8* N, int n); // only for prime N
void bn_exp(u8* d, const u8* a, const u8* N, int n, const u8* e, int en);
int bn_compare(const u8* a, const u8* b, size_t n);
void bn_sub_modulus(u8* a, const u8* N, size_t n);
void bn_add(u8* d, const u8* a, const u8* b, const u8* N, size_t n);
void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, size_t n);
void bn_inv(u8* d, const u8* a, const u8* N, size_t n); // only for prime N
void bn_exp(u8* d, const u8* a, const u8* N, size_t n, const u8* e, size_t en);

View file

@ -126,16 +126,18 @@ InstructionAttributes CodeTrace::GetInstructionAttributes(const TraceOutput& ins
TraceOutput CodeTrace::SaveCurrentInstruction(const Core::CPUThreadGuard& guard) const
{
auto& system = guard.GetSystem();
auto& ppc_state = system.GetPPCState();
auto& power_pc = system.GetPowerPC();
auto& ppc_state = power_pc.GetPPCState();
auto& debug_interface = power_pc.GetDebugInterface();
// Quickly save instruction and memory target for fast logging.
TraceOutput output;
const std::string instr = PowerPC::debug_interface.Disassemble(&guard, ppc_state.pc);
const std::string instr = debug_interface.Disassemble(&guard, ppc_state.pc);
output.instruction = instr;
output.address = ppc_state.pc;
if (IsInstructionLoadStore(output.instruction))
output.memory_target = PowerPC::debug_interface.GetMemoryAddressFromInstruction(instr);
output.memory_target = debug_interface.GetMemoryAddressFromInstruction(instr);
return output;
}
@ -189,16 +191,17 @@ AutoStepResults CodeTrace::AutoStepping(const Core::CPUThreadGuard& guard, bool
else if (stop_on == AutoStop::Changed)
stop_condition = HitType::ACTIVE;
PowerPC::breakpoints.ClearAllTemporary();
auto& power_pc = guard.GetSystem().GetPowerPC();
power_pc.GetBreakPoints().ClearAllTemporary();
using clock = std::chrono::steady_clock;
clock::time_point timeout = clock::now() + std::chrono::seconds(4);
PowerPC::CoreMode old_mode = PowerPC::GetMode();
PowerPC::SetMode(PowerPC::CoreMode::Interpreter);
PowerPC::CoreMode old_mode = power_pc.GetMode();
power_pc.SetMode(PowerPC::CoreMode::Interpreter);
do
{
PowerPC::SingleStep();
power_pc.SingleStep();
pc_instr = SaveCurrentInstruction(guard);
hit = TraceLogic(pc_instr);
@ -210,7 +213,7 @@ AutoStepResults CodeTrace::AutoStepping(const Core::CPUThreadGuard& guard, bool
if (clock::now() >= timeout)
results.timed_out = true;
PowerPC::SetMode(old_mode);
power_pc.SetMode(old_mode);
m_recording = false;
results.reg_tracked = m_reg_autotrack;

View file

@ -1,12 +1,12 @@
// Copyright 2015 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "Common/ENetUtil.h"
#include "Common/ENet.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
namespace ENetUtil
namespace Common::ENet
{
void WakeupThread(ENetHost* host)
{
@ -62,4 +62,4 @@ bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id)
return true;
}
} // namespace ENetUtil
} // namespace Common::ENet

View file

@ -3,15 +3,22 @@
//
#pragma once
#include <enet/enet.h>
#include <memory>
#include <SFML/Network/Packet.hpp>
#include <enet/enet.h>
#include "Common/CommonTypes.h"
namespace ENetUtil
namespace Common::ENet
{
struct ENetHostDeleter
{
void operator()(ENetHost* host) const noexcept { enet_host_destroy(host); }
};
using ENetHostPtr = std::unique_ptr<ENetHost, ENetHostDeleter>;
void WakeupThread(ENetHost* host);
int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event);
bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id);
} // namespace ENetUtil
} // namespace Common::ENet

View file

@ -358,14 +358,14 @@ u64 GetSize(FILE* f)
const u64 pos = ftello(f);
if (fseeko(f, 0, SEEK_END) != 0)
{
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), LastStrerrorString());
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), Common::LastStrerrorString());
return 0;
}
const u64 size = ftello(f);
if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0))
{
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), LastStrerrorString());
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), Common::LastStrerrorString());
return 0;
}
@ -379,7 +379,7 @@ bool CreateEmptyFile(const std::string& filename)
if (!File::IOFile(filename, "wb"))
{
ERROR_LOG_FMT(COMMON, "CreateEmptyFile: failed {}: {}", filename, LastStrerrorString());
ERROR_LOG_FMT(COMMON, "CreateEmptyFile: failed {}: {}", filename, Common::LastStrerrorString());
return false;
}
@ -486,7 +486,7 @@ FSTEntry ScanDirectoryTree(std::string directory, bool recursive)
}
else if (cur_depth < prev_depth)
{
while (dir_fsts.size() - 1 != cur_depth)
while (dir_fsts.size() != static_cast<size_t>(cur_depth) + 1u)
{
calc_dir_size(dir_fsts.top());
dir_fsts.pop();
@ -726,7 +726,7 @@ std::string GetBundleDirectory()
std::string GetExePath()
{
#ifdef _WIN32
auto exe_path = GetModuleName(nullptr);
auto exe_path = Common::GetModuleName(nullptr);
if (!exe_path)
return {};
std::error_code error;

View file

@ -155,7 +155,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, None}};
s_glxError = false;
m_context = glXCreateContextAttribs(m_display, m_fbconfig, 0, True, &context_attribs[0]);
m_context =
glXCreateContextAttribs(m_display, m_fbconfig, nullptr, True, &context_attribs[0]);
XSync(m_display, False);
if (!m_context || s_glxError)
continue;
@ -174,7 +175,8 @@ bool GLContextGLX::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
std::array<int, 5> context_attribs_legacy = {
{GLX_CONTEXT_MAJOR_VERSION_ARB, 1, GLX_CONTEXT_MINOR_VERSION_ARB, 0, None}};
s_glxError = false;
m_context = glXCreateContextAttribs(m_display, m_fbconfig, 0, True, &context_attribs_legacy[0]);
m_context =
glXCreateContextAttribs(m_display, m_fbconfig, nullptr, True, &context_attribs_legacy[0]);
XSync(m_display, False);
m_attribs.clear();
m_attribs.insert(m_attribs.end(), context_attribs_legacy.begin(), context_attribs_legacy.end());

View file

@ -69,7 +69,7 @@ private:
struct Storage
{
std::mutex m_mutex;
std::recursive_mutex m_mutex;
std::vector<HookImpl*> m_listeners;
};

View file

@ -33,8 +33,8 @@ public:
Response Fetch(const std::string& url, Method method, const Headers& headers, const u8* payload,
size_t size, AllowedReturnCodes codes = AllowedReturnCodes::Ok_Only);
static int CurlProgressCallback(Impl* impl, double dlnow, double dltotal, double ulnow,
double ultotal);
static int CurlProgressCallback(Impl* impl, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow);
std::string EscapeComponent(const std::string& string);
private:
@ -95,11 +95,12 @@ HttpRequest::Response HttpRequest::Post(const std::string& url, const std::strin
reinterpret_cast<const u8*>(payload.data()), payload.size(), codes);
}
int HttpRequest::Impl::CurlProgressCallback(Impl* impl, double dlnow, double dltotal, double ulnow,
double ultotal)
int HttpRequest::Impl::CurlProgressCallback(Impl* impl, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow)
{
// Abort if callback isn't true
return !impl->m_callback(dlnow, dltotal, ulnow, ultotal);
return !impl->m_callback(static_cast<s64>(dltotal), static_cast<s64>(dlnow),
static_cast<s64>(ultotal), static_cast<s64>(ulnow));
}
HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback callback)
@ -116,7 +117,7 @@ HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms, ProgressCallback c
if (m_callback)
{
curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSDATA, this);
curl_easy_setopt(m_curl.get(), CURLOPT_PROGRESSFUNCTION, CurlProgressCallback);
curl_easy_setopt(m_curl.get(), CURLOPT_XFERINFOFUNCTION, CurlProgressCallback);
}
// Set up error buffer

View file

@ -25,8 +25,7 @@ public:
};
// Return false to abort the request
using ProgressCallback =
std::function<bool(double dlnow, double dltotal, double ulnow, double ultotal)>;
using ProgressCallback = std::function<bool(s64 dltotal, s64 dlnow, s64 ultotal, s64 ulnow)>;
explicit HttpRequest(std::chrono::milliseconds timeout_ms = std::chrono::milliseconds{3000},
ProgressCallback callback = nullptr);

View file

@ -15,6 +15,8 @@
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
namespace Common
{
void IniFile::ParseLine(std::string_view line, std::string* keyOut, std::string* valueOut)
{
if (line.empty() || line.front() == '#')
@ -369,3 +371,4 @@ bool IniFile::Save(const std::string& filename)
return 0;
}
*/
} // namespace Common

View file

@ -13,6 +13,8 @@
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
namespace Common
{
struct CaseInsensitiveStringCompare
{
// Allow heterogenous lookup.
@ -166,3 +168,4 @@ private:
static const std::string& NULL_STRING;
};
} // namespace Common

View file

@ -27,6 +27,8 @@
// value_type[value_size] value;
//}
namespace Common
{
template <typename K, typename V>
class LinearDiskCacheReader
{
@ -163,3 +165,4 @@ private:
File::IOFile m_file;
u32 m_num_entries = 0;
};
} // namespace Common

View file

@ -1,12 +0,0 @@
// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "Common/MathUtil.h"
#include <numeric>
// Calculate sum of a float list
float MathFloatVectorSum(const std::vector<float>& Vec)
{
return std::accumulate(Vec.begin(), Vec.end(), 0.0f);
}

View file

@ -8,7 +8,6 @@
#include <cmath>
#include <limits>
#include <type_traits>
#include <vector>
#include "Common/CommonTypes.h"
@ -186,12 +185,9 @@ private:
T m_variance{};
};
} // namespace MathUtil
float MathFloatVectorSum(const std::vector<float>&);
// Rounds down. 0 -> undefined
constexpr int IntLog2(u64 val)
{
return 63 - std::countl_zero(val);
}
} // namespace MathUtil

View file

@ -250,7 +250,7 @@ size_t MemPhysical()
mib[1] = HW_PHYSMEM64;
#endif
size_t length = sizeof(size_t);
sysctl(mib, 2, &physical_memory, &length, NULL, 0);
sysctl(mib, 2, &physical_memory, &length, nullptr, 0);
return physical_memory;
#elif defined __HAIKU__
system_info sysinfo;

View file

@ -70,12 +70,10 @@ std::string SettingsHandler::GetValue(std::string_view key) const
void SettingsHandler::Decrypt()
{
const u8* str = m_buffer.data();
while (m_position < m_buffer.size())
{
decoded.push_back((u8)(m_buffer[m_position] ^ m_key));
m_position++;
str++;
m_key = (m_key >> 31) | (m_key << 1);
}

View file

@ -304,7 +304,7 @@ int ENET_CALLBACK TraversalClient::InterceptCallback(ENetHost* host, ENetEvent*
}
std::unique_ptr<TraversalClient> g_TraversalClient;
std::unique_ptr<ENetHost> g_MainNetHost;
Common::ENet::ENetHostPtr g_MainNetHost;
// The settings at the previous TraversalClient reset - notably, we
// need to know not just what port it's on, but whether it was
@ -323,18 +323,18 @@ bool EnsureTraversalClient(const std::string& server, u16 server_port, u16 liste
g_OldListenPort = listen_port;
ENetAddress addr = {ENET_HOST_ANY, listen_port};
ENetHost* host = enet_host_create(&addr, // address
50, // peerCount
NetPlay::CHANNEL_COUNT, // channelLimit
0, // incomingBandwidth
0); // outgoingBandwidth
auto host = Common::ENet::ENetHostPtr{enet_host_create(&addr, // address
50, // peerCount
NetPlay::CHANNEL_COUNT, // channelLimit
0, // incomingBandwidth
0)}; // outgoingBandwidth
if (!host)
{
g_MainNetHost.reset();
return false;
}
host->mtu = std::min(host->mtu, NetPlay::MAX_ENET_MTU);
g_MainNetHost.reset(host);
g_MainNetHost = std::move(host);
g_TraversalClient.reset(new TraversalClient(g_MainNetHost.get(), server, server_port));
}
return true;

View file

@ -11,6 +11,7 @@
#include <enet/enet.h>
#include "Common/CommonTypes.h"
#include "Common/ENet.h"
#include "Common/Thread.h"
#include "Common/TraversalProto.h"
@ -91,7 +92,7 @@ private:
};
extern std::unique_ptr<TraversalClient> g_TraversalClient;
// the NetHost connected to the TraversalClient.
extern std::unique_ptr<ENetHost> g_MainNetHost;
extern Common::ENet::ENetHostPtr g_MainNetHost;
// Create g_TraversalClient and g_MainNetHost if necessary.
bool EnsureTraversalClient(const std::string& server, u16 server_port, u16 listen_port = 0);
void ReleaseTraversalClient();

View file

@ -1,5 +1,4 @@
// Copyright 2021 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: CC0-1.0
#pragma once

View file

@ -164,14 +164,14 @@ static void UnmapPortThread()
UnmapPort(s_mapped);
}
void UPnP::TryPortmapping(u16 port)
void Common::UPnP::TryPortmapping(u16 port)
{
if (s_thread.joinable())
s_thread.join();
s_thread = std::thread(&MapPortThread, port);
}
void UPnP::StopPortmapping()
void Common::UPnP::StopPortmapping()
{
if (s_thread.joinable())
s_thread.join();

View file

@ -7,10 +7,10 @@
#include "Common/CommonTypes.h"
namespace UPnP
namespace Common::UPnP
{
void TryPortmapping(u16 port);
void StopPortmapping();
} // namespace UPnP
} // namespace Common::UPnP
#endif

View file

@ -1106,7 +1106,8 @@ public:
template <typename FunctionPointer>
void ABI_CallFunctionPR(FunctionPointer func, const void* ptr, X64Reg reg1)
{
MOV(64, R(ABI_PARAM2), R(reg1));
if (reg1 != ABI_PARAM2)
MOV(64, R(ABI_PARAM2), R(reg1));
MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast<u64>(ptr)));
ABI_CallFunction(func);
}