Initial work on implementing support for cheats

This commit is contained in:
Gericom
2026-02-22 20:28:35 +01:00
parent f73c8b0547
commit dddee0bb94
28 changed files with 966 additions and 17 deletions

View File

@@ -0,0 +1,25 @@
#pragma once
#include <memory>
#include "fat/File.h"
#include "ICheatRepository.h"
#include "UsrCheatDat.h"
class UsrCheatRepository : public ICheatRepository
{
public:
UsrCheatRepository(std::unique_ptr<File> usrCheatDatFile,
std::unique_ptr<usr_cheat_index_entry_t[]> sortedIndices, u32 numberOfIndices)
: _usrCheatFile(std::move(usrCheatDatFile))
, _sortedIndices(std::move(sortedIndices)), _numberOfIndices(numberOfIndices) { }
std::unique_ptr<GameCheats> GetCheatsForGame(u32 gameCode, u32 headerCrc32) const override;
private:
std::unique_ptr<File> _usrCheatFile;
std::unique_ptr<usr_cheat_index_entry_t[]> _sortedIndices;
u32 _numberOfIndices;
const usr_cheat_index_entry_t* FindIndex(u32 gameCode, u32 headerCrc32) const;
void ParseCategory(CheatCategory& category, u8*& ptr) const;
void ParseCheat(Cheat& cheat, u8*& ptr) const;
};