diff --git a/core/rend/gl4/abuffer.cpp b/core/rend/gl4/abuffer.cpp index 3462725f5..d1e3b4fb7 100644 --- a/core/rend/gl4/abuffer.cpp +++ b/core/rend/gl4/abuffer.cpp @@ -393,7 +393,7 @@ void termABuffer() glDeleteVertexArrays(1, &g_quadVertexArray); g_quadVertexArray = 0; } - g_quadIndexBuffer.reset(); + g_quadBuffer.reset(); g_quadIndexBuffer.reset(); glcache.DeleteProgram(g_abuffer_final_shader.program); g_abuffer_final_shader.program = 0; diff --git a/shell/libretro/libretro.cpp b/shell/libretro/libretro.cpp index a5dec7b44..5bee06671 100644 --- a/shell/libretro/libretro.cpp +++ b/shell/libretro/libretro.cpp @@ -289,6 +289,8 @@ static void retro_keyboard_event(bool down, unsigned keycode, uint32_t character // Now comes the interesting stuff void retro_init() { + static bool emuInited; + // Logging struct retro_log_callback log; if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log)) @@ -322,6 +324,12 @@ void retro_init() os_InstallFaultHandler(); MapleConfigMap::UpdateVibration = updateVibration; + +#if defined(__GNUC__) && !defined(_WIN32) + if (!emuInited) +#endif + emu.init(); + emuInited = true; } void retro_deinit() @@ -335,6 +343,12 @@ void retro_deinit() std::lock_guard lock(mtx_serialization); } os_UninstallFaultHandler(); + +#if defined(__GNUC__) && !defined(_WIN32) + _vmem_release(); +#else + emu.term(); +#endif libretro_supports_bitmasks = false; categoriesSupported = false; platformIsDreamcast = true; @@ -1913,13 +1927,11 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info *i void retro_unload_game() { INFO_LOG(COMMON, "Flycast unloading game"); - emu.stop(); + emu.unloadGame(); game_data.clear(); disk_paths.clear(); disk_labels.clear(); blankVmus(); - - emu.term(); }