2013-04-17 22:43:11 -04:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// 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-02-17 05:18:15 -05:00
|
|
|
#include "Common/IniFile.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
namespace PatchEngine
|
|
|
|
{
|
|
|
|
|
|
|
|
enum PatchType
|
|
|
|
{
|
|
|
|
PATCH_8BIT,
|
|
|
|
PATCH_16BIT,
|
|
|
|
PATCH_32BIT,
|
|
|
|
};
|
|
|
|
|
2008-12-10 22:36:26 +00:00
|
|
|
extern const char *PatchTypeStrings[];
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
struct PatchEntry
|
|
|
|
{
|
|
|
|
PatchEntry() {}
|
|
|
|
PatchEntry(PatchType _t, u32 _addr, u32 _value) : type(_t), address(_addr), value(_value) {}
|
|
|
|
PatchType type;
|
|
|
|
u32 address;
|
|
|
|
u32 value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Patch
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
std::vector<PatchEntry> entries;
|
|
|
|
bool active;
|
2013-09-07 23:02:49 +02:00
|
|
|
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);
|
2013-09-07 23:02:49 +02:00
|
|
|
void LoadPatchSection(const char *section, std::vector<Patch> &patches,
|
|
|
|
IniFile &globalIni, IniFile &localIni);
|
2013-09-23 02:39:14 -04:00
|
|
|
void LoadPatches();
|
2008-12-08 04:46:09 +00:00
|
|
|
void ApplyFramePatches();
|
|
|
|
void ApplyARPatches();
|
2013-07-25 16:43:00 -04:00
|
|
|
void Shutdown();
|
2011-07-09 21:00:30 +00:00
|
|
|
|
|
|
|
inline int GetPatchTypeCharLength(PatchType type)
|
|
|
|
{
|
|
|
|
int size = 8;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case PatchEngine::PATCH_8BIT:
|
|
|
|
size = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PatchEngine::PATCH_16BIT:
|
|
|
|
size = 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PatchEngine::PATCH_32BIT:
|
|
|
|
size = 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
} // namespace
|