project64/Source/Project64-core/N64System/CheatClass.h

73 lines
2.3 KiB
C
Raw Normal View History

2012-12-19 09:30:18 +00:00
/****************************************************************************
* *
2015-11-10 05:21:49 +00:00
* Project64 - A Nintendo 64 emulator. *
2012-12-19 09:30:18 +00:00
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
2015-12-06 09:59:58 +00:00
#include "N64RomClass.h"
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
2015-12-06 09:59:58 +00:00
#include <Project64-core/Plugins/PluginClass.h>
2012-12-19 09:30:18 +00:00
class CCheats
{
public:
CCheats(CMipsMemoryVM & MMU);
~CCheats(void);
enum
{
MaxCheats = 50000,
MaxGSEntries = 100,
};
void ApplyCheats();
void ApplyGSButton();
void LoadCheats(bool DisableSelected, CPlugins * Plugins);
static bool IsValid16BitCode(const char * CheatString);
private:
struct GAMESHARK_CODE
{
uint32_t Command;
uint16_t Value;
};
struct MEM_VALUE16
{
uint16_t Original;
uint16_t Changed;
};
struct MEM_VALUE8
{
uint8_t Original;
uint8_t Changed;
};
typedef std::vector<GAMESHARK_CODE> CODES;
typedef std::vector<CODES> CODES_ARRAY;
typedef std::map<uint32_t, MEM_VALUE16> ORIGINAL_VALUES16;
typedef std::map<uint32_t, MEM_VALUE8> ORIGINAL_VALUES8;
void LoadPermCheats(CPlugins * Plugins);
void LoadEnhancements(void);
int32_t EntrySize(const CODES & CodeEntry, int32_t CurrentEntry);
CMipsMemoryVM & m_MMU;
CODES_ARRAY m_Codes;
ORIGINAL_VALUES16 m_OriginalValues16;
ORIGINAL_VALUES8 m_OriginalValues8;
bool LoadCode(const stdstr & CheatEntry, SettingID ExtensionSetting, int ExtensionIndex);
void ApplyCheatEntry(CODES & CodeEntry, int32_t CurrentEntry);
void ModifyMemory8(uint32_t Address, uint8_t Value);
void ModifyMemory16(uint32_t Address, uint16_t Value);
void ResetCodes(void);
2015-01-31 19:27:27 +00:00
};