mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-26 08:43:44 +02:00
Merge branch 'libretro-compat' into libretro
This commit is contained in:
commit
ebca366cc3
1 changed files with 18 additions and 17 deletions
35
src/core.cpp
35
src/core.cpp
|
@ -43,6 +43,17 @@
|
|||
using namespace mkxp_retro;
|
||||
using namespace mkxp_sandbox;
|
||||
|
||||
namespace mkxp_retro {
|
||||
retro_log_printf_t log_printf = NULL;
|
||||
retro_video_refresh_t video_refresh;
|
||||
retro_audio_sample_batch_t audio_sample_batch;
|
||||
retro_environment_t environment;
|
||||
retro_input_poll_t input_poll;
|
||||
retro_input_state_t input_state;
|
||||
struct retro_perf_callback perf;
|
||||
retro_hw_render_callback hw_render;
|
||||
}
|
||||
|
||||
static inline void *malloc_align(size_t alignment, size_t size) {
|
||||
#if defined(MKXPZ_HAVE_POSIX_MEMALIGN) || defined(MKXPZ_BUILD_XCODE)
|
||||
void *mem;
|
||||
|
@ -64,17 +75,6 @@ static inline void free_align(void *ptr) {
|
|||
#endif
|
||||
}
|
||||
|
||||
namespace mkxp_retro {
|
||||
retro_log_printf_t log_printf;
|
||||
retro_video_refresh_t video_refresh;
|
||||
retro_audio_sample_batch_t audio_sample_batch;
|
||||
retro_environment_t environment;
|
||||
retro_input_poll_t input_poll;
|
||||
retro_input_state_t input_state;
|
||||
struct retro_perf_callback perf;
|
||||
retro_hw_render_callback hw_render;
|
||||
}
|
||||
|
||||
extern const uint8_t mkxp_gmgsx_sf2[];
|
||||
extern const size_t mkxp_gmgsx_sf2_len;
|
||||
|
||||
|
@ -304,15 +304,15 @@ extern "C" RETRO_API void retro_set_environment(retro_environment_t cb) {
|
|||
environment = cb;
|
||||
|
||||
struct retro_log_callback log;
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log)) {
|
||||
log_printf = log.log;
|
||||
} else {
|
||||
#endif // __EMSCRIPTEN__
|
||||
log_printf = fallback_log;
|
||||
#ifndef __EMSCRIPTEN__
|
||||
}
|
||||
#endif // __EMSCRIPTEN__
|
||||
// Bug in RetroArch:
|
||||
// retro_set_environment is called multiple times and only the first time
|
||||
// callbacks will work and return true.
|
||||
else if (log_printf == NULL) {
|
||||
log_printf = fallback_log;
|
||||
}
|
||||
|
||||
perf = {
|
||||
.get_time_usec = nullptr,
|
||||
|
@ -516,6 +516,7 @@ extern "C" RETRO_API bool retro_load_game_special(unsigned int type, const struc
|
|||
|
||||
extern "C" RETRO_API void retro_unload_game() {
|
||||
deinit_sandbox();
|
||||
log_printf = NULL;
|
||||
}
|
||||
|
||||
extern "C" RETRO_API unsigned int retro_get_region() {
|
||||
|
|
Loading…
Add table
Reference in a new issue