#include "common/assert.h" #include "common/log.h" #include "libretro_host_interface.h" #include "scmversion/scmversion.h" Log_SetChannel(Main); RETRO_API unsigned retro_api_version(void) { return RETRO_API_VERSION; } RETRO_API void retro_init(void) { Log::SetConsoleOutputParams(true); Log::SetDebugOutputParams(true); Log_InfoPrintf("retro_init()"); if (!g_libretro_host_interface.Initialize()) Panic("Host interface initialization failed"); } RETRO_API void retro_deinit(void) { Log_InfoPrintf("retro_deinit()"); g_libretro_host_interface.Shutdown(); } RETRO_API void retro_get_system_info(struct retro_system_info* info) { std::memset(info, 0, sizeof(*info)); #if defined(_DEBUGFAST) info->library_name = "DuckStation DebugFast"; #elif defined(_DEBUG) info->library_name = "DuckStation Debug"; #else info->library_name = "DuckStation"; #endif info->library_version = g_scm_tag_str; info->valid_extensions = "exe|cue|bin|chd|psf"; info->need_fullpath = true; info->block_extract = false; } RETRO_API void retro_get_system_av_info(struct retro_system_av_info* info) { g_libretro_host_interface.retro_get_system_av_info(info); } RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device) { Log_ErrorPrintf("retro_set_controller_port_device(%u, %u)", port, device); } RETRO_API void retro_reset(void) { Log_InfoPrint("retro_reset()"); g_libretro_host_interface.ResetSystem(); } RETRO_API void retro_run(void) { g_libretro_host_interface.retro_run_frame(); } RETRO_API size_t retro_serialize_size(void) { Log_ErrorPrintf("retro_serialize_size()"); return 0; } RETRO_API bool retro_serialize(void* data, size_t size) { Log_ErrorPrintf("retro_serialize()"); return false; } RETRO_API bool retro_unserialize(const void* data, size_t size) { Log_ErrorPrintf("retro_unserialize()"); return false; } RETRO_API void retro_cheat_reset(void) { Log_ErrorPrintf("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); } RETRO_API bool retro_load_game(const struct retro_game_info* game) { Log_InfoPrintf("retro_load_game(%s)", game->path); return g_libretro_host_interface.retro_load_game(game); } RETRO_API bool retro_load_game_special(unsigned game_type, const struct retro_game_info* info, size_t num_info) { Log_ErrorPrintf("retro_load_game_special()"); return false; } RETRO_API void retro_unload_game(void) { Log_ErrorPrintf("retro_unload_game()"); g_libretro_host_interface.DestroySystem(); } RETRO_API unsigned retro_get_region(void) { return g_libretro_host_interface.retro_get_region(); } RETRO_API void* retro_get_memory_data(unsigned id) { return nullptr; } RETRO_API size_t retro_get_memory_size(unsigned id) { return 0; } RETRO_API void retro_set_environment(retro_environment_t f) { static bool core_options_set = false; g_retro_environment_callback = f; if (!core_options_set) { core_options_set = true; if (!g_libretro_host_interface.SetCoreOptions()) Log_WarningPrintf("Failed to set core options, settings will not be changeable."); } } RETRO_API void retro_set_video_refresh(retro_video_refresh_t f) { g_retro_video_refresh_callback = f; } RETRO_API void retro_set_audio_sample(retro_audio_sample_t f) { g_retro_audio_sample_callback = f; } RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t f) { g_retro_audio_sample_batch_callback = f; } RETRO_API void retro_set_input_poll(retro_input_poll_t f) { g_retro_input_poll_callback = f; } RETRO_API void retro_set_input_state(retro_input_state_t f) { g_retro_input_state_callback = f; }