project64/Source/Project64-core/N64System/Enhancement/Enhancements.h

106 lines
3.5 KiB
C
Raw Normal View History

#pragma once
2021-02-28 21:32:50 +00:00
#include <Project64-core/N64System/Enhancement/EnhancementFile.h>
#include <Project64-core/N64System/Enhancement/EnhancementList.h>
#include <Common/Thread.h>
#include <Common/CriticalSection.h>
#include <map>
#include <string>
class CMipsMemoryVM;
2021-02-16 23:54:17 +00:00
class CPlugins;
class CEnhancements
{
enum
{
MaxGSEntries = 100,
};
public:
CEnhancements();
~CEnhancements();
2021-02-16 23:54:17 +00:00
void ApplyActive(CMipsMemoryVM & MMU, CPlugins * Plugins, bool UpdateChanges);
void ApplyGSButton(CMipsMemoryVM & MMU, bool UpdateChanges);
2021-01-17 03:17:58 +00:00
void UpdateCheats(const CEnhancementList & Cheats);
void UpdateCheats(void);
2021-01-17 03:17:58 +00:00
void UpdateEnhancements(const CEnhancementList & Enhancements);
2021-02-16 23:54:17 +00:00
void ResetActive(CPlugins * Plugins);
2021-03-23 02:11:18 +00:00
void Load(void);
void LoadActive(CMipsMemoryVM * MMU, CPlugins * Plugins);
2021-02-16 23:54:17 +00:00
CEnhancementList Cheats(void);
CEnhancementList Enhancements(void);
private:
2021-03-06 00:26:24 +00:00
class GAMESHARK_CODE
{
2021-03-06 00:26:24 +00:00
public:
GAMESHARK_CODE(const GAMESHARK_CODE&);
GAMESHARK_CODE(uint32_t Command, uint16_t Value, bool HasDisableValue, uint16_t DisableValue);
uint32_t Command(void) const { return m_Command; }
uint16_t Value(void) const { return m_Value; }
bool HasDisableValue(void) const { return m_HasDisableValue; }
uint16_t DisableValue(void) const { return m_DisableValue; }
private:
GAMESHARK_CODE();
GAMESHARK_CODE& operator=(const GAMESHARK_CODE&);
uint32_t m_Command;
uint16_t m_Value;
bool m_HasDisableValue;
uint16_t m_DisableValue;
};
struct MEM_VALUE16
{
uint16_t Original;
uint16_t Changed;
};
struct MEM_VALUE8
{
uint8_t Original;
uint8_t Changed;
};
typedef std::map<std::string, std::string> SectionFiles;
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 ResetCodes(CMipsMemoryVM * MMU);
2021-02-16 23:54:17 +00:00
void LoadActive(CEnhancementList & List, CPlugins * Plugins);
2021-01-17 03:17:58 +00:00
void LoadEnhancements(const char * Ident, SectionFiles & Files, std::unique_ptr<CEnhancmentFile> & File, CEnhancementList & EnhancementList);
void ApplyGameSharkCodes(CMipsMemoryVM & MMU, CODES & CodeEntry, uint32_t CurrentEntry);
uint32_t EntrySize(const CODES & CodeEntry, uint32_t CurrentEntry);
2021-03-06 00:26:24 +00:00
void ModifyMemory8(CMipsMemoryVM & MMU, uint32_t Address, uint8_t Value, bool HasDisableValue, uint8_t DisableValue);
void ModifyMemory16(CMipsMemoryVM & MMU, uint32_t Address, uint16_t Value, bool HasDisableValue, uint16_t DisableValue);
void ScanFileThread(void);
void WaitScanDone(void);
void GameChanged(void);
static uint32_t ConvertXP64Address(uint32_t Address);
static uint16_t ConvertXP64Value(uint16_t Value);
static uint32_t stScanFileThread(void * lpThreadParameter) { ((CEnhancements *)lpThreadParameter)->ScanFileThread(); return 0; }
CriticalSection m_CS;
2021-01-17 03:17:58 +00:00
SectionFiles m_CheatFiles, m_EnhancementFiles;
std::unique_ptr<CEnhancmentFile> m_CheatFile, m_EnhancementFile;
CEnhancementList m_Cheats;
2021-01-17 03:17:58 +00:00
CEnhancementList m_Enhancements;
CODES_ARRAY m_ActiveCodes;
CODES_ARRAY m_GSButtonCodes;
ORIGINAL_VALUES16 m_OriginalValues16;
ORIGINAL_VALUES8 m_OriginalValues8;
CThread m_ScanFileThread;
bool m_Scan;
bool m_Scanned;
bool m_UpdateCheats;
2021-03-10 07:39:01 +00:00
bool m_OverClock;
uint32_t m_OverClockModifier;
};