[gnome-games/wip/exalm/sharp-x68000: 197/203] Support xdf



commit 95a1f6571c64df8e2f5123bb0f66395898cbfbe5
Author: Exalm <exalm7659 gmail com>
Date:   Wed Apr 11 18:07:27 2018 +0500

    Support xdf

 flatpak/libretro-cores/px68k.libretro              |  9 ++++-
 .../src/sharp-x68000-game-factory.vala             | 46 +++++++++++++++-------
 plugins/sharp-x68000/src/sharp-x68000-plugin.vala  |  5 ++-
 3 files changed, 41 insertions(+), 19 deletions(-)
---
diff --git a/flatpak/libretro-cores/px68k.libretro b/flatpak/libretro-cores/px68k.libretro
index ec356c5e..72438648 100644
--- a/flatpak/libretro-cores/px68k.libretro
+++ b/flatpak/libretro-cores/px68k.libretro
@@ -8,8 +8,8 @@ Authors=hissorii;
 License=???;
 
 [Platform:SharpX68000]
-MimeType=application/x-x68k-rom;
-Firmwares=CGROM;IPLROM;
+MimeType=application/x-x68k-rom;application/x-x68k-xdf-rom;
+Firmwares=CGROM;IPLROM;IPL30ROM;
 
 [Firmware:CGROM]
 Path=keropi/cgrom.dat
@@ -20,3 +20,8 @@ Mandatory=true
 Path=keropi/iplrom.dat
 MD5=7fd4caabac1d9169e289f0f7bbf71d8e
 Mandatory=true
+
+[Firmware:IPL30ROM]
+Path=keropi/iplrom30.dat
+MD5=f373003710ab4322642f527f567e020a
+Mandatory=false
diff --git a/plugins/sharp-x68000/src/sharp-x68000-game-factory.vala 
b/plugins/sharp-x68000/src/sharp-x68000-game-factory.vala
index 6b4751be..ccbbfca4 100644
--- a/plugins/sharp-x68000/src/sharp-x68000-game-factory.vala
+++ b/plugins/sharp-x68000/src/sharp-x68000-game-factory.vala
@@ -2,7 +2,8 @@
 
 public class Games.SharpX68000GameFactory : Object, UriGameFactory {
        private const string FINGERPRINT_PREFIX = "sharp-x68000";
-       private const string MIME_TYPE = "application/x-x68k-rom";
+       private const string MIME_TYPE_DIM = "application/x-x68k-rom";
+       private const string MIME_TYPE_XDF = "application/x-x68k-xdf-rom";
        private const string PLATFORM = "SharpX68000";
        private const string ICON_NAME = "media-floppy-symbolic";
 
@@ -22,7 +23,7 @@ public class Games.SharpX68000GameFactory : Object, UriGameFactory {
        }
 
        public string[] get_mime_types () {
-               return { MIME_TYPE };
+               return { MIME_TYPE_DIM, MIME_TYPE_XDF };
        }
 
        public async Game? query_game_for_uri (Uri uri) {
@@ -52,13 +53,13 @@ public class Games.SharpX68000GameFactory : Object, UriGameFactory {
                var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 
FileQueryInfoFlags.NONE);
                var mime_type = file_info.get_content_type ();
 
-               if (mime_type != MIME_TYPE)
+               if (mime_type != MIME_TYPE_DIM && mime_type != MIME_TYPE_XDF)
                        return;
 
                var path = file.get_path ();
                print ("%s\n", path);
 
-               var regex = /\((Dis[ck] (\d+)) of (\d+)\)/;
+               var regex = /\((Dis[ck] (\d+)) of (\d+)\)/i;
                MatchInfo match_info;
                if (regex.match (path, 0, out match_info)) {
                        // The game has multiple disks
@@ -78,8 +79,12 @@ public class Games.SharpX68000GameFactory : Object, UriGameFactory {
                                var data = uris_for_game.lookup(game_id);
                                bool complete = true;
                                foreach (var u in data.uris)
-                                       if (u == null)
+                                       if (u == null) {
                                                complete = false;
+                                               print ("null\n");
+                                       } else
+                                               print ("%s\n", u.to_string());
+                               print ("%d\n", complete ? 1 : 0);
 
                                if (complete) {
                                        var media_set = new MediaSet ();
@@ -90,7 +95,7 @@ public class Games.SharpX68000GameFactory : Object, UriGameFactory {
                                        }
                                        media_set.icon = GLib.Icon.new_for_string (ICON_NAME);
 
-                                       var game = create_game (uri, media_set);
+                                       var game = create_multi_disk_game (data.uris[0], media_set, 
mime_type);
 
                                        foreach (var u in data.uris)
                                                game_for_uri[u] = game;
@@ -105,7 +110,7 @@ public class Games.SharpX68000GameFactory : Object, UriGameFactory {
 
                print ("The game is single-disk\n");
 
-               var game = create_game (uri);
+               var game = create_game (uri, mime_type);
 
                game_for_uri[uri] = game;
                games.add (game);
@@ -149,20 +154,31 @@ public class Games.SharpX68000GameFactory : Object, UriGameFactory {
                games.foreach ((game) => game_callback (game));
        }
 
-       private Game create_game (Uri uri, MediaSet? media_set = null) throws Error {
+       private Game create_multi_disk_game (Uri uri, MediaSet media_set, string mime_type) throws Error {
                var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
                var title = new FilenameTitle (uri);
                var icon = new DummyIcon ();
-               var media = new GriloMedia (title, MIME_TYPE);
+               var media = new GriloMedia (title, mime_type);
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
-               var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
-               RetroRunner runner;
-               if (media_set != null)
-                       runner = new RetroRunner.for_media_set (core_source, media_set, uid, title);
-               else
-                       runner = new RetroRunner (core_source, uri, uid, title);
+               var core_source = new RetroCoreSource (PLATFORM, get_mime_types ());
+               RetroRunner runner = new RetroRunner.for_media_set (core_source, media_set, uid, title);
+
+               print (uri.to_string ());
+               return new GenericGame (title, icon, cover, runner);
+       }
+
+       private Game create_game (Uri uri, string mime_type) throws Error {
+               var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+               var title = new FilenameTitle (uri);
+               var icon = new DummyIcon ();
+               var media = new GriloMedia (title, mime_type);
+               var cover = new CompositeCover ({
+                       new LocalCover (uri),
+                       new GriloCover (media, uid)});
+               var core_source = new RetroCoreSource (PLATFORM, get_mime_types ());
+               RetroRunner runner = new RetroRunner (core_source, uri, uid, title);
 
                return new GenericGame (title, icon, cover, runner);
        }
diff --git a/plugins/sharp-x68000/src/sharp-x68000-plugin.vala 
b/plugins/sharp-x68000/src/sharp-x68000-plugin.vala
index 681f751c..a13beb9d 100644
--- a/plugins/sharp-x68000/src/sharp-x68000-plugin.vala
+++ b/plugins/sharp-x68000/src/sharp-x68000-plugin.vala
@@ -1,10 +1,11 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private class Games.SharpX68000Plugin : Object, Plugin {
-       private const string MIME_TYPE = "application/x-x68k-rom";
+       private const string MIME_TYPE_DIM = "application/x-x68k-rom";
+       private const string MIME_TYPE_XDF = "application/x-x68k-xdf-rom";
 
        public string[] get_mime_types () {
-               return { MIME_TYPE };
+               return { MIME_TYPE_DIM, MIME_TYPE_XDF };
        }
 
        public UriGameFactory[] get_uri_game_factories () {


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