[Scummvm-git-logs] scummvm master -> 74b91f3bf3c970ef193960636e510cffc950d892

spleen1981 noreply at scummvm.org
Fri Apr 21 16:10:28 UTC 2023


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
598cc489e9 LIBRETRO: reset EMU_EXITED flag on emu thread deinit
ba2abf6d92 LIBRETRO: add scummvm_main parameters init function
9176a80269 LIBRETRO: add log_scummvm_exit_code function
ab15b39465 LIBRETRO: simplyfy core unloading
74b91f3bf3 LIBRETRO: fix core reset feature


Commit: 598cc489e9a169f0bf0103f114cd36a90e7ededf
    https://github.com/scummvm/scummvm/commit/598cc489e9a169f0bf0103f114cd36a90e7ededf
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-21T18:07:34+02:00

Commit Message:
LIBRETRO: reset EMU_EXITED flag on emu thread deinit

Changed paths:
    backends/platform/libretro/src/libretro-threads.cpp


diff --git a/backends/platform/libretro/src/libretro-threads.cpp b/backends/platform/libretro/src/libretro-threads.cpp
index 117ba7c7427..3f9d56b91d0 100644
--- a/backends/platform/libretro/src/libretro-threads.cpp
+++ b/backends/platform/libretro/src/libretro-threads.cpp
@@ -165,6 +165,8 @@ bool retro_init_emu_thread(void) {
 
 	if (!success)
 		retro_free_emu_thread();
+	else
+		status &= ~EMU_EXITED;
 
 	return success;
 }


Commit: ba2abf6d92bb053c4c3ee96e84c900e2d875cc61
    https://github.com/scummvm/scummvm/commit/ba2abf6d92bb053c4c3ee96e84c900e2d875cc61
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-21T18:07:53+02:00

Commit Message:
LIBRETRO: add scummvm_main parameters init function

Changed paths:
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index abbf94d72c8..6b45cfc0cfa 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -309,6 +309,12 @@ bool consecutive_screen_updates_is_enabled(){
 		return consecutive_screen_updates;
 }
 
+void init_command_params(void) {
+	memset(cmd_params, 0, sizeof(cmd_params));
+	cmd_params_num = 1;
+	strcpy(cmd_params[0], "scummvm\0");
+}
+
 void parse_command_params(char *cmdline) {
 	int j = 0;
 	int cmdlen = strlen(cmdline);
@@ -470,8 +476,7 @@ void retro_init(void) {
 	audio_buffer_init(SAMPLE_RATE, (uint16) frame_rate);
 	update_variables();
 
-	cmd_params_num = 1;
-	strcpy(cmd_params[0], "scummvm\0");
+	init_command_params();
 
 	struct retro_input_descriptor desc[] = {
 		{0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Mouse Cursor Left"},
@@ -707,9 +712,8 @@ void retro_run(void) {
 			/* Determine frameskip need based on settings */
 			if ((frameskip_type == 2) || (performance_switch & PERF_SWITCH_ON))
 				skip_frame = (audio_status & AUDIO_STATUS_BUFFER_UNDERRUN);
-			else if (frameskip_type == 1){
+			else if (frameskip_type == 1)
 				skip_frame = !(current_frame % frameskip_no == 0);
-}
 			else if (frameskip_type == 3)
 				skip_frame = (retro_audio_buff_occupancy < frameskip_threshold);
 


Commit: 9176a80269d754412c5e37b1a2c16d21f91c2e4e
    https://github.com/scummvm/scummvm/commit/9176a80269d754412c5e37b1a2c16d21f91c2e4e
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-21T18:08:16+02:00

Commit Message:
LIBRETRO: add log_scummvm_exit_code function

Changed paths:
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 6b45cfc0cfa..127fa89ad10 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -74,6 +74,7 @@ static float mouse_speed = 1.0f;
 static float gamepad_acceleration_time = 0.2f;
 
 static bool timing_inaccuracies_enabled = false;
+static bool consecutive_screen_updates = false;
 
 char cmd_params[20][200];
 char cmd_params_num;
@@ -88,7 +89,6 @@ static uint8 frameskip_threshold;
 static uint32 frameskip_counter = 0;
 static uint8 frameskip_events = 0;
 
-static bool consecutive_screen_updates = false;
 
 static uint8 audio_status = AUDIO_STATUS_MUTE;
 
@@ -104,6 +104,15 @@ static size_t samples_per_frame_buffer_size = 0;
 
 static int16_t *sound_buffer = NULL;       // pointer to output buffer
 
+static void log_scummvm_exit_code(void) {
+	if (retro_get_scummvm_res() == Common::kNoError)
+		log_cb(RETRO_LOG_INFO, "ScummVM exited successfully.\n");
+	else if (retro_get_scummvm_res() < Common::kNoError)
+		log_cb(RETRO_LOG_WARN, "Unknown ScummVM exit code.\n");
+	else
+		log_cb(RETRO_LOG_ERROR, "ScummVM exited with error %d.\n", retro_get_scummvm_res());
+}
+
 static void audio_buffer_init(uint16 sample_rate, uint16 frame_rate) {
 	samples_per_frame = sample_rate / frame_rate;
 
@@ -810,13 +819,7 @@ void retro_unload_game(void) {
 		}
 		retro_deinit_emu_thread();
 	}
-
-	if (retro_get_scummvm_res() == Common::kNoError)
-		log_cb(RETRO_LOG_INFO, "ScummVM exited successfully.\n");
-	else if (retro_get_scummvm_res() < Common::kNoError)
-		log_cb(RETRO_LOG_WARN, "ScummVM not initialized correctly.\n", frameskip_counter, current_frame);
-	else
-		log_cb(RETRO_LOG_ERROR, "ScummVM exited with error %d.\n", retro_get_scummvm_res());
+	log_scummvm_exit_code();
 }
 
 void retro_reset(void) {


Commit: ab15b3946528248396ff1b0793052282ca5b1242
    https://github.com/scummvm/scummvm/commit/ab15b3946528248396ff1b0793052282ca5b1242
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-21T18:08:33+02:00

Commit Message:
LIBRETRO: simplyfy core unloading

Changed paths:
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 127fa89ad10..970c698ce42 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -768,11 +768,10 @@ void retro_run(void) {
 			if (!skip_frame)
 				retro_switch_to_emu_thread();
 
-			if (retro_emu_thread_exited())
+			if (retro_emu_thread_exited()) {
 				retro_deinit_emu_thread();
-
-			if (!retro_emu_thread_initialized()) {
 				environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, NULL);
+				log_scummvm_exit_code();
 				return;
 			}
 
@@ -812,14 +811,7 @@ void retro_run(void) {
 }
 
 void retro_unload_game(void) {
-	if (retro_emu_thread_initialized()) {
-		while (!retro_emu_thread_exited()) {
-			retroQuit();
-			retro_switch_to_emu_thread();
-		}
-		retro_deinit_emu_thread();
-	}
-	log_scummvm_exit_code();
+	retroQuit();
 }
 
 void retro_reset(void) {


Commit: 74b91f3bf3c970ef193960636e510cffc950d892
    https://github.com/scummvm/scummvm/commit/74b91f3bf3c970ef193960636e510cffc950d892
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-04-21T18:08:54+02:00

Commit Message:
LIBRETRO: fix core reset feature

Changed paths:
    backends/platform/libretro/src/libretro-os.cpp
    backends/platform/libretro/src/libretro.cpp


diff --git a/backends/platform/libretro/src/libretro-os.cpp b/backends/platform/libretro/src/libretro-os.cpp
index 4aea3b35fc0..677662e410f 100644
--- a/backends/platform/libretro/src/libretro-os.cpp
+++ b/backends/platform/libretro/src/libretro-os.cpp
@@ -1284,9 +1284,7 @@ public:
 	}
 
 	void Reset() {
-		Common::Event ev;
-		ev.type = Common::EVENT_RETURN_TO_LAUNCHER;
-		dynamic_cast<OSystem_RETRO *>(g_system)->getEventManager()->pushEvent(ev);
+		dynamic_cast<OSystem_RETRO *>(g_system)->getEventManager()->resetQuit();
 	}
 
 };
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro.cpp
index 970c698ce42..265b92a7a22 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro.cpp
@@ -54,6 +54,9 @@
 #include "backends/platform/libretro/include/libretro-core-options.h"
 #include "backends/platform/libretro/include/os.h"
 
+static struct retro_game_info game_buf;
+static struct retro_game_info * game_buf_ptr;
+
 retro_log_printf_t log_cb = NULL;
 static retro_video_refresh_t video_cb = NULL;
 static retro_audio_sample_batch_t audio_batch_cb = NULL;
@@ -89,6 +92,7 @@ static uint8 frameskip_threshold;
 static uint32 frameskip_counter = 0;
 static uint8 frameskip_events = 0;
 
+static bool restart_pending = false;
 
 static uint8 audio_status = AUDIO_STATUS_MUTE;
 
@@ -585,6 +589,8 @@ bool retro_load_game(const struct retro_game_info *game) {
 	}
 
 	if (game) {
+		game_buf_ptr = &game_buf;
+		memcpy(game_buf_ptr, game, sizeof(retro_game_info));
 		// Retrieve the game path.
 		Common::FSNode detect_target = Common::FSNode(game->path);
 		Common::FSNode parent_dir = detect_target.getParent();
@@ -671,6 +677,8 @@ bool retro_load_game(const struct retro_game_info *game) {
 		} else {
 			parse_command_params(buffer);
 		}
+	} else {
+		game_buf_ptr = NULL;
 	}
 
 	if (!retro_init_emu_thread()) {
@@ -770,8 +778,15 @@ void retro_run(void) {
 
 			if (retro_emu_thread_exited()) {
 				retro_deinit_emu_thread();
-				environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, NULL);
-				log_scummvm_exit_code();
+				if (!restart_pending) {
+					environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, NULL);
+					log_scummvm_exit_code();
+				} else {
+					init_command_params();
+					retro_load_game(game_buf_ptr);
+					retroReset();
+					restart_pending = false;
+				}
 				return;
 			}
 
@@ -815,7 +830,8 @@ void retro_unload_game(void) {
 }
 
 void retro_reset(void) {
-	retroReset();
+	restart_pending = true;
+	retroQuit();
 }
 
 // Stubs




More information about the Scummvm-git-logs mailing list