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
|
|
|
|
{
|
|
|
|
enum PatchType
|
|
|
|
{
|
2016-06-24 10:43:46 +02:00
|
|
|
PATCH_8BIT,
|
|
|
|
PATCH_16BIT,
|
|
|
|
PATCH_32BIT,
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
extern const char* PatchTypeStrings[];
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
struct PatchEntry
|
|
|
|
{
|
2016-06-24 10:43:46 +02: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 10:43:46 +02: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 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)
|
|
|
|
{
|
|
|
|
case PatchEngine::PATCH_8BIT:
|
|
|
|
size = 2;
|
|
|
|
break;
|
2011-07-09 21:00:30 +00:00
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
case PatchEngine::PATCH_16BIT:
|
|
|
|
size = 4;
|
|
|
|
break;
|
2011-07-09 21:00:30 +00:00
|
|
|
|
2016-06-24 10:43:46 +02:00
|
|
|
case PatchEngine::PATCH_32BIT:
|
|
|
|
size = 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return size;
|
2011-07-09 21:00:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-03 18:59:33 -05:00
|
|
|
} // namespace PatchEngine
|