mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 02:15:47 -04:00
libretro: Cheat support
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include "common/string_util.h"
|
||||
#include "core/analog_controller.h"
|
||||
#include "core/bus.h"
|
||||
#include "core/cheats.h"
|
||||
#include "core/digital_controller.h"
|
||||
#include "core/gpu.h"
|
||||
#include "core/system.h"
|
||||
@ -369,6 +370,29 @@ size_t LibretroHostInterface::retro_get_memory_size(unsigned id)
|
||||
}
|
||||
}
|
||||
|
||||
void LibretroHostInterface::retro_cheat_reset()
|
||||
{
|
||||
System::SetCheatList(nullptr);
|
||||
}
|
||||
|
||||
void LibretroHostInterface::retro_cheat_set(unsigned index, bool enabled, const char* code)
|
||||
{
|
||||
CheatList* cl = System::GetCheatList();
|
||||
if (!cl)
|
||||
{
|
||||
System::SetCheatList(std::make_unique<CheatList>());
|
||||
cl = System::GetCheatList();
|
||||
}
|
||||
|
||||
CheatCode cc;
|
||||
cc.description = StringUtil::StdStringFromFormat("Cheat%u", index);
|
||||
cc.enabled = true;
|
||||
if (!CheatList::ParseLibretroCheat(&cc, code))
|
||||
Log_ErrorPrintf("Failed to parse cheat %u '%s'", index, code);
|
||||
|
||||
cl->SetCode(index, std::move(cc));
|
||||
}
|
||||
|
||||
bool LibretroHostInterface::AcquireHostDisplay()
|
||||
{
|
||||
// start in software mode, switch to hardware later
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
bool retro_unserialize(const void* data, size_t size);
|
||||
void* retro_get_memory_data(unsigned id);
|
||||
size_t retro_get_memory_size(unsigned id);
|
||||
void retro_cheat_reset();
|
||||
void retro_cheat_set(unsigned index, bool enabled, const char* code);
|
||||
|
||||
protected:
|
||||
bool AcquireHostDisplay() override;
|
||||
|
@ -79,12 +79,14 @@ RETRO_API bool retro_unserialize(const void* data, size_t size)
|
||||
|
||||
RETRO_API void retro_cheat_reset(void)
|
||||
{
|
||||
Log_ErrorPrintf("retro_cheat_reset()");
|
||||
Log_InfoPrint("retro_cheat_reset()");
|
||||
g_libretro_host_interface.retro_cheat_reset();
|
||||
}
|
||||
|
||||
RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char* code)
|
||||
{
|
||||
Log_ErrorPrintf("retro_cheat_set(%u, %u, %s)", index, enabled, code);
|
||||
Log_InfoPrintf("retro_cheat_set(%u, %u, %s)", index, enabled, code);
|
||||
g_libretro_host_interface.retro_cheat_set(index, enabled, code);
|
||||
}
|
||||
|
||||
RETRO_API bool retro_load_game(const struct retro_game_info* game)
|
||||
|
Reference in New Issue
Block a user