mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-30 11:03:31 +00:00
Yellow squiggly lines begone! Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes. If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed. The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports. Not everything is removed, but the cleanup should be substantial enough. Because this done on Linux, code that isn't used on it is mostly untouched. (Hopefully no open PR is depending on these imports...)
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
// Copyright 2018 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
namespace Core
|
|
{
|
|
class CPUThreadGuard;
|
|
}
|
|
|
|
namespace Common::Debug
|
|
{
|
|
struct MemoryPatch
|
|
{
|
|
enum class State
|
|
{
|
|
Enabled,
|
|
Disabled
|
|
};
|
|
|
|
enum class ApplyType
|
|
{
|
|
Once,
|
|
EachFrame
|
|
};
|
|
|
|
MemoryPatch(u32 address_, std::vector<u8> value_);
|
|
MemoryPatch(u32 address_, u32 value_);
|
|
|
|
u32 address;
|
|
std::vector<u8> value;
|
|
State is_enabled = State::Enabled;
|
|
ApplyType type = ApplyType::Once;
|
|
};
|
|
|
|
class MemoryPatches
|
|
{
|
|
public:
|
|
MemoryPatches();
|
|
virtual ~MemoryPatches();
|
|
|
|
void SetPatch(const Core::CPUThreadGuard& guard, u32 address, u32 value);
|
|
void SetPatch(const Core::CPUThreadGuard& guard, u32 address, std::vector<u8> value);
|
|
void SetFramePatch(const Core::CPUThreadGuard& guard, u32 address, u32 value);
|
|
void SetFramePatch(const Core::CPUThreadGuard& guard, u32 address, std::vector<u8> value);
|
|
const std::vector<MemoryPatch>& GetPatches() const;
|
|
void UnsetPatch(const Core::CPUThreadGuard& guard, u32 address);
|
|
void EnablePatch(const Core::CPUThreadGuard& guard, std::size_t index);
|
|
void DisablePatch(const Core::CPUThreadGuard& guard, std::size_t index);
|
|
bool HasEnabledPatch(u32 address) const;
|
|
void RemovePatch(const Core::CPUThreadGuard& guard, std::size_t index);
|
|
void ClearPatches(const Core::CPUThreadGuard& guard);
|
|
virtual void ApplyExistingPatch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
|
|
|
protected:
|
|
virtual void Patch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
|
virtual void UnPatch(std::size_t index) = 0;
|
|
|
|
std::vector<MemoryPatch> m_patches;
|
|
};
|
|
} // namespace Common::Debug
|