/* ** core.cpp ** ** This file is part of mkxp. ** ** Copyright (C) 2013 - 2021 Amaryllis Kulla ** ** mkxp is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 2 of the License, or ** (at your option) any later version. ** ** mkxp is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with mkxp. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include "../binding-sandbox/sandbox.h" #include "../binding-sandbox/binding-sandbox.h" #include "../binding-sandbox/core.h" #include "filesystem.h" using namespace mkxp_retro; using namespace mkxp_sandbox; #if defined(__unix__) || defined(__APPLE__) static inline void *malloc_align(size_t alignment, size_t size) { void *mem; return posix_memalign(&mem, alignment, size) ? NULL : mem; } #elif defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) static inline void *malloc_align(size_t alignment, size_t size) { return _aligned_malloc(size, alignment); } #else static inline void *malloc_align(size_t alignment, size_t size) { return aligned_alloc(alignment, size); } #endif extern unsigned char GMGSx_sf2[]; extern unsigned int GMGSx_sf2_len; static size_t frame_number = 0; static ALCdevice *al_device = NULL; static ALCcontext *al_context = NULL; static LPALCRENDERSAMPLESSOFT alcRenderSamplesSOFT = NULL; static int16_t *sound_buf; static void fallback_log(enum retro_log_level level, const char *fmt, ...) { std::va_list va; va_start(va, fmt); std::vfprintf(stderr, fmt, va); va_end(va); } static void fluid_log(int level, char *message, void *data) { switch (level) { case FLUID_PANIC: log_printf(RETRO_LOG_ERROR, "fluidsynth: panic: %s\n", message); case FLUID_ERR: log_printf(RETRO_LOG_ERROR, "fluidsynth: error: %s\n", message); case FLUID_WARN: log_printf(RETRO_LOG_WARN, "fluidsynth: warning: %s\n", message); case FLUID_INFO: log_printf(RETRO_LOG_INFO, "fluidsynth: %s\n", message); case FLUID_DBG: log_printf(RETRO_LOG_DEBUG, "fluidsynth: debug: %s\n", message); } } static uint32_t *frame_buf; boost::optional mkxp_retro::sandbox; boost::optional