2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 22:43:11 -04:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-03-12 15:33:41 -04:00
|
|
|
#include <string>
|
2014-07-08 15:58:25 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2014-07-27 13:37:09 -04:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
|
|
|
class IniFile;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
namespace PatchEngine
|
|
|
|
{
|
2018-05-13 14:10:58 -04:00
|
|
|
enum class PatchType
|
2008-12-08 04:46:09 +00:00
|
|
|
{
|
2018-05-13 14:10:58 -04:00
|
|
|
Patch8Bit,
|
|
|
|
Patch16Bit,
|
|
|
|
Patch32Bit,
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PatchEntry
|
|
|
|
{
|
2018-05-13 13:53:49 -04:00
|
|
|
PatchEntry() = default;
|
|
|
|
PatchEntry(PatchType t, u32 addr, u32 value_) : type(t), address(addr), value(value_) {}
|
2018-05-13 14:10:58 -04:00
|
|
|
PatchType type = PatchType::Patch8Bit;
|
2018-05-13 13:53:49 -04:00
|
|
|
u32 address = 0;
|
|
|
|
u32 value = 0;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Patch
|
|
|
|
{
|
2016-06-24 10:43:46 +02:00
|
|
|
std::string name;
|
|
|
|
std::vector<PatchEntry> entries;
|
2018-05-13 13:53:49 -04:00
|
|
|
bool active = false;
|
|
|
|
bool user_defined = false; // False if this code is shipped with Dolphin.
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2018-05-13 14:10:58 -04:00
|
|
|
const char* PatchTypeAsString(PatchType type);
|
|
|
|
|
2010-10-02 02:04:44 +00:00
|
|
|
int GetSpeedhackCycles(const u32 addr);
|
2016-06-24 10:43:46 +02:00
|
|
|
void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, IniFile& globalIni,
|
|
|
|
IniFile& localIni);
|
2013-09-23 02:39:14 -04:00
|
|
|
void LoadPatches();
|
2016-09-24 15:14:51 +00:00
|
|
|
bool ApplyFramePatches();
|
2013-07-25 16:43:00 -04:00
|
|
|
void Shutdown();
|
2017-04-06 15:34:40 +01:00
|
|
|
void Reload();
|
2011-07-09 21:00:30 +00:00
|
|
|
|
|
|
|
inline int GetPatchTypeCharLength(PatchType type)
|
|
|
|
{
|
2016-06-24 10:43:46 +02:00
|
|
|
int size = 8;
|
|
|
|
switch (type)
|
|
|
|
{
|
2018-05-13 14:10:58 -04:00
|
|
|
case PatchType::Patch8Bit:
|
2016-06-24 10:43:46 +02:00
|
|
|
size = 2;
|
|
|
|
break;
|
2011-07-09 21:00:30 +00:00
|
|
|
|
2018-05-13 14:10:58 -04:00
|
|
|
case PatchType::Patch16Bit:
|
2016-06-24 10:43:46 +02:00
|
|
|
size = 4;
|
|
|
|
break;
|
2011-07-09 21:00:30 +00:00
|
|
|
|
2018-05-13 14:10:58 -04:00
|
|
|
case PatchType::Patch32Bit:
|
2016-06-24 10:43:46 +02:00
|
|
|
size = 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return size;
|
2011-07-09 21:00:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-03 18:59:33 -05:00
|
|
|
} // namespace PatchEngine
|