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