[retro-gtk/to-c: 9/15] core: Move Core.load_game() to C



commit 647efea5c5b3fb001405d2f54d33444c869a6b2f
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jul 6 11:39:54 2017 +0200

    core: Move Core.load_game() to C
    
    This help porting the library to C.

 retro-gtk/core.vala    |   17 +----------------
 retro-gtk/retro-core.c |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 16 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index 65f8dce..366ef91 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -310,22 +310,7 @@ public class Core : Object {
         * @param game information to load the game
         * @return false if the loading failed, true otherwise
         */
-       public bool load_game (GameInfo game) {
-               if (game_loaded) {
-                       push_cb_data ();
-                       module.unload_game ();
-                       pop_cb_data ();
-               }
-
-               push_cb_data ();
-               game_loaded = module.load_game (game);
-               SystemAvInfo info;
-               module.get_system_av_info (out info);
-               set_system_av_info (info);
-               pop_cb_data ();
-
-               return game_loaded;
-       }
+       public extern bool load_game (GameInfo game);
 
        /**
         * Prepare the standalone core.
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index aad0e82..2dc6a32 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -243,6 +243,38 @@ retro_core_deserialize_state (RetroCore  *self,
 }
 
 gboolean
+retro_core_load_game (RetroCore     *self,
+                      RetroGameInfo *game)
+{
+  RetroUnloadGame unload_game;
+  RetroLoadGame load_game;
+  RetroGetSystemAvInfo get_system_av_info;
+  gboolean game_loaded;
+  RetroSystemAvInfo info = {{ 0 }};
+
+  g_return_val_if_fail (self != NULL, FALSE);
+  g_return_val_if_fail (game != NULL, FALSE);
+
+  if (retro_core_get_game_loaded (self)) {
+    retro_core_push_cb_data (self);
+    unload_game = retro_module_get_unload_game (self->module);
+    unload_game ();
+    retro_core_pop_cb_data ();
+  }
+
+  retro_core_push_cb_data (self);
+  load_game = retro_module_get_load_game (self->module);
+  game_loaded = load_game (game);
+  retro_core_set_game_loaded (self, game_loaded);
+  get_system_av_info = retro_module_get_get_system_av_info (self->module);
+  get_system_av_info (&info);
+  retro_core_set_system_av_info (self, &info);
+  retro_core_pop_cb_data ();
+
+  return game_loaded;
+}
+
+gboolean
 retro_core_prepare (RetroCore* self) {
   RetroLoadGame load_game;
   RetroGetSystemAvInfo get_system_av_info;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]