[gnome-games/wip/exalm/mame: 12/18] Introduce Nintendo 64 plugin



commit 2e380bcaa45005c259bdcf56973d2a80d6050bbc
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Feb 2 04:06:34 2020 +0500

    Introduce Nintendo 64 plugin
    
    Replace simple type with a plugin. This will be needed to support switching
    expansion paks in the following commits.

 meson_options.txt                               |  1 +
 plugins/meson.build                             |  1 +
 plugins/nintendo-64/data/meson.build            |  1 +
 plugins/nintendo-64/data/nintendo-64.plugin     |  6 +++
 plugins/nintendo-64/meson.build                 |  2 +
 plugins/nintendo-64/src/meson.build             | 16 ++++++
 plugins/nintendo-64/src/nintendo-64-plugin.vala | 68 +++++++++++++++++++++++++
 src/retro/retro-simple-types.vala               |  1 -
 8 files changed, 95 insertions(+), 1 deletion(-)
---
diff --git a/meson_options.txt b/meson_options.txt
index 998ffb44..f94d0a07 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -17,6 +17,7 @@ option ('libretro-plugin',      description: 'Support for Libretro games',
 option ('love-plugin',          description: 'Support for LÖVE games',          type: 'boolean')
 option ('mame-plugin',          description: 'Support for MAME games',          type: 'boolean', value: 
false)
 option ('ms-dos-plugin',        description: 'Support for MS-DOS games',        type: 'boolean')
+option ('nintendo-64-plugin',   description: 'Support for Nintendo 64 games',   type: 'boolean')
 option ('nintendo-ds-plugin',   description: 'Support for Nintendo DS games',   type: 'boolean')
 option ('playstation-plugin',   description: 'Support for PlayStation games',   type: 'boolean')
 option ('sega-cd-plugin',       description: 'Support for Sega CD games',       type: 'boolean')
diff --git a/plugins/meson.build b/plugins/meson.build
index 3fe8b172..f15025bb 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -6,6 +6,7 @@ plugins = [
   'love',
   'mame',
   'ms-dos',
+  'nintendo-64',
   'nintendo-ds',
   'playstation',
   'sega-cd',
diff --git a/plugins/nintendo-64/data/meson.build b/plugins/nintendo-64/data/meson.build
new file mode 100644
index 00000000..0d4b6c49
--- /dev/null
+++ b/plugins/nintendo-64/data/meson.build
@@ -0,0 +1 @@
+install_data (plugin_name + '.plugin', install_dir: plugins_dir)
diff --git a/plugins/nintendo-64/data/nintendo-64.plugin b/plugins/nintendo-64/data/nintendo-64.plugin
new file mode 100644
index 00000000..54fdeea0
--- /dev/null
+++ b/plugins/nintendo-64/data/nintendo-64.plugin
@@ -0,0 +1,6 @@
+[Plugin]
+Module=libgames-nintendo-64-plugin
+Name=Nintendo 64 Plugin
+Description=Provides support for Nintendo 64 games.
+Authors=Alexander Mikhaylenko <alexm gnome org>
+Copyright=Copyright © 2020 Alexander Mikhaylenko
diff --git a/plugins/nintendo-64/meson.build b/plugins/nintendo-64/meson.build
new file mode 100644
index 00000000..d7e84900
--- /dev/null
+++ b/plugins/nintendo-64/meson.build
@@ -0,0 +1,2 @@
+subdir ('data')
+subdir ('src')
diff --git a/plugins/nintendo-64/src/meson.build b/plugins/nintendo-64/src/meson.build
new file mode 100644
index 00000000..39b5bd24
--- /dev/null
+++ b/plugins/nintendo-64/src/meson.build
@@ -0,0 +1,16 @@
+vala_sources = [
+  'nintendo-64-plugin.vala',
+]
+
+c_args = [
+  '-DG_LOG_DOMAIN="GamesNintendo64"'
+]
+
+shared_module (
+  'games-' + plugin_name + '-plugin',
+  vala_sources,
+  dependencies: gnome_games_dep,
+  c_args: c_args,
+  install: true,
+  install_dir: plugins_dir
+)
diff --git a/plugins/nintendo-64/src/nintendo-64-plugin.vala b/plugins/nintendo-64/src/nintendo-64-plugin.vala
new file mode 100644
index 00000000..a06551c7
--- /dev/null
+++ b/plugins/nintendo-64/src/nintendo-64-plugin.vala
@@ -0,0 +1,68 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private class Games.Nintendo64Plugin : Object, Plugin {
+       private const string MIME_TYPE = "application/x-n64-rom";
+       private const string PLATFORM_ID = "Nintendo64";
+       private const string PLATFORM_NAME = _("Nintendo 64");
+       private const string PLATFORM_UID_PREFIX = "nintendo-64";
+
+       private static RetroPlatform platform;
+
+       static construct {
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
+       }
+
+       public string[] get_mime_types () {
+               return { MIME_TYPE };
+       }
+
+       public UriGameFactory[] get_uri_game_factories () {
+               var game_uri_adapter = new GenericGameUriAdapter (game_for_uri);
+               var factory = new GenericUriGameFactory (game_uri_adapter);
+               factory.add_mime_type (MIME_TYPE);
+
+               return { factory };
+       }
+
+       public RunnerFactory[] get_runner_factories () {
+               var factory = new GenericRunnerFactory (create_runner);
+               factory.add_platform (platform);
+
+               return { factory };
+       }
+
+       private static Game game_for_uri (Uri uri) throws Error {
+
+               var uid = new FingerprintUid (uri, PLATFORM_UID_PREFIX);
+               var title = new FilenameTitle (uri);
+               var media = new GriloMedia (title, MIME_TYPE);
+               var cover = new CompositeCover ({
+                       new LocalCover (uri),
+                       new GriloCover (media, uid)});
+
+               var game = new GenericGame (uid, uri, title, platform);
+               game.set_cover (cover);
+
+               return game;
+       }
+
+       private static Runner? create_runner (Game game) throws Error {
+               var core_source = new RetroCoreSource (platform);
+
+               var builder = new RetroRunnerBuilder ();
+               builder.core_source = core_source;
+               builder.uri = game.get_uri ();
+               builder.uid = game.get_uid ();
+               builder.title = game.name;
+               return builder.to_runner ();
+       }
+}
+
+[ModuleInit]
+public Type register_games_plugin (TypeModule module) {
+       return typeof (Games.Nintendo64Plugin);
+}
diff --git a/src/retro/retro-simple-types.vala b/src/retro/retro-simple-types.vala
index 0910f394..6fc3b0f7 100644
--- a/src/retro/retro-simple-types.vala
+++ b/src/retro/retro-simple-types.vala
@@ -15,7 +15,6 @@ namespace Games {
                { "application/x-gba-rom", true, "GameBoyAdvance", "game-boy-advance" },
                { "application/x-genesis-32x-rom", true, "Sega32X", "mega-drive-32x" },
                { "application/x-genesis-rom", true, "SegaGenesis", "mega-drive" },
-               { "application/x-n64-rom", true, "Nintendo64", "nintendo-64" },
                { "application/x-neo-geo-pocket-color-rom", true, "NeoGeoPocketColor", "neo-geo-pocket" }, // 
The prefix is the same as the Neo Geo Pocket type for backward compatibility.
                { "application/x-neo-geo-pocket-rom", true, "NeoGeoPocket", "neo-geo-pocket" },
                { "application/x-nes-rom", true, "NintendoEntertainmentSystem", "nes" },


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