dolphin/Source/Core/Core/GeckoCode.h
Lioncash e8cd5a3979 GeckoCode: Provide operator== and operator!= overloads
Same thing but allows both GeckoCode and Code to be utilized directly
without predicates for equality/inequality in stardard algorithms

The size check for std::vectors is unnecessary, as this is built into std::vector's operator==
2016-10-03 02:32:43 -04:00

67 lines
2.0 KiB
C++

// Copyright 2010 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
class PointerWrap;
namespace Gecko
{
class GeckoCode
{
public:
GeckoCode() : enabled(false) {}
struct Code
{
u32 address = 0;
u32 data = 0;
std::string original_line;
};
std::vector<Code> codes;
std::string name, creator;
std::vector<std::string> notes;
bool enabled;
bool user_defined;
bool Exist(u32 address, u32 data) const;
};
bool operator==(const GeckoCode& lhs, const GeckoCode& rhs);
bool operator!=(const GeckoCode& lhs, const GeckoCode& rhs);
bool operator==(const GeckoCode::Code& lhs, const GeckoCode::Code& rhs);
bool operator!=(const GeckoCode::Code& lhs, const GeckoCode::Code& rhs);
// Installation address for codehandler.bin in the Game's RAM
constexpr u32 INSTALLER_BASE_ADDRESS = 0x80001800;
constexpr u32 INSTALLER_END_ADDRESS = 0x80003000;
constexpr u32 ENTRY_POINT = INSTALLER_BASE_ADDRESS + 0xA8;
// If the GCT is max-length then this is the second word of the End code (0xF0000000 0x00000000)
// If the table is shorter than the max-length then this address is unused / contains trash.
constexpr u32 HLE_TRAMPOLINE_ADDRESS = INSTALLER_END_ADDRESS - 4;
// This forms part of a communication protocol with HLE_Misc::GeckoCodeHandlerICacheFlush.
// Basically, codehandleronly.s doesn't use ICBI like it's supposed to when patching the
// game's code. This results in the JIT happily ignoring all code patches for blocks that
// are already compiled. The hack for getting around that is that the first 5 frames after
// the handler is installed (0xD01F1BAD -> +5 -> 0xD01F1BB2) cause full ICache resets.
//
// GeckoCodeHandlerICacheFlush will increment this value 5 times then cease flushing the ICache to
// preserve the emulation performance.
constexpr u32 MAGIC_GAMEID = 0xD01F1BAD;
void SetActiveCodes(const std::vector<GeckoCode>& gcodes);
void RunCodeHandler();
void Shutdown();
void DoState(PointerWrap&);
} // namespace Gecko