[gnome-games/wip/exalm/sharp-x68000: 548/548] Add Sharp X68000 platform
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/sharp-x68000: 548/548] Add Sharp X68000 platform
- Date: Wed, 15 Jan 2020 21:44:53 +0000 (UTC)
commit 62b6eb45e5abf1a58b75d5699d1c24f151f6f3e7
Author: Exalm <exalm7659 gmail com>
Date: Tue Apr 3 02:42:37 2018 +0500
Add Sharp X68000 platform
data/options/meson.build | 3 +-
data/options/px68k.options | 2 +
data/org.gnome.Games.desktop.in.in | 2 +-
flatpak/libretro-cores/px68k.libretro | 9 +-
meson_options.txt | 1 +
plugins/meson.build | 1 +
plugins/sharp-x68000/data/meson.build | 1 +
plugins/sharp-x68000/data/sharp-x68000.plugin | 6 +
plugins/sharp-x68000/meson.build | 2 +
plugins/sharp-x68000/src/meson.build | 19 +++
.../src/sharp-x68000-game-factory.vala | 181 +++++++++++++++++++++
.../src/sharp-x68000-gameinfo-cache.vala | 21 +++
.../src/sharp-x68000-input-capabilities.vala | 13 ++
plugins/sharp-x68000/src/sharp-x68000-plugin.vala | 68 ++++++++
src/retro/retro-core-source.vala | 3 +-
15 files changed, 326 insertions(+), 6 deletions(-)
---
diff --git a/data/options/meson.build b/data/options/meson.build
index fbc6c081..a2386177 100644
--- a/data/options/meson.build
+++ b/data/options/meson.build
@@ -1,6 +1,7 @@
options_files = [
'desmume.options',
- 'desmume2015.options'
+ 'desmume2015.options',
+ 'px68k.options',
]
install_data (options_files, install_dir: options_dir)
diff --git a/data/options/px68k.options b/data/options/px68k.options
new file mode 100644
index 00000000..9ad7b9c7
--- /dev/null
+++ b/data/options/px68k.options
@@ -0,0 +1,2 @@
+[Options]
+px68k_disk_path=disabled
diff --git a/data/org.gnome.Games.desktop.in.in b/data/org.gnome.Games.desktop.in.in
index d5da88b2..438ea38b 100644
--- a/data/org.gnome.Games.desktop.in.in
+++ b/data/org.gnome.Games.desktop.in.in
@@ -12,4 +12,4 @@ X-GNOME-SingleWindow=true
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Player;Game;
-MimeType=application/vnd.nintendo.snes.rom;application/x-amiga-disk-format;application/x-atari-2600-rom;application/x-atari-7800-rom;application/x-atari-lynx-rom;application/x-cue;application/x-dc-rom;application/x-desktop;application/x-doom-wad;application/x-fds-disk;application/x-gameboy-color-rom;application/x-gameboy-rom;application/x-gamecube-rom;application/x-gamegear-rom;application/x-gba-rom;application/x-genesis-32x-rom;application/x-genesis-rom;application/x-love-game;application/x-mame-rom;application/x-ms-dos-executable;application/x-n64-rom;application/x-neo-geo-pocket-color-rom;application/x-neo-geo-pocket-rom;application/x-nes-rom;application/x-nintendo-ds-rom;application/x-pc-engine-rom;application/x-playstation-rom;application/x-saturn-rom;application/x-sega-cd-rom;application/x-sega-pico-rom;application/x-sg1000-rom;application/x-sms-rom;application/x-virtual-boy-rom;application/x-wii-rom;application/x-wii-wad;application/x-wonderswan-color-rom;application/
x-wonder
swan-rom;application/zip;
+MimeType=application/vnd.nintendo.snes.rom;application/x-amiga-disk-format;application/x-atari-2600-rom;application/x-atari-7800-rom;application/x-atari-lynx-rom;application/x-cue;application/x-dc-rom;application/x-desktop;application/x-doom-wad;application/x-fds-disk;application/x-gameboy-color-rom;application/x-gameboy-rom;application/x-gamecube-rom;application/x-gamegear-rom;application/x-gba-rom;application/x-genesis-32x-rom;application/x-genesis-rom;application/x-love-game;application/x-mame-rom;application/x-ms-dos-executable;application/x-n64-rom;application/x-neo-geo-pocket-color-rom;application/x-neo-geo-pocket-rom;application/x-nes-rom;application/x-nintendo-ds-rom;application/x-pc-engine-rom;application/x-playstation-rom;application/x-saturn-rom;application/x-sega-cd-rom;application/x-sega-pico-rom;application/x-sg1000-rom;application/x-sms-rom;application/x-virtual-boy-rom;application/x-wii-rom;application/x-wii-wad;application/x-wonderswan-color-rom;application/
x-wonder
swan-rom;application/zip;application/x-x68k-rom;
diff --git a/flatpak/libretro-cores/px68k.libretro b/flatpak/libretro-cores/px68k.libretro
index ec356c5e..06bc3190 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;application/x-x68k-hdf-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/meson_options.txt b/meson_options.txt
index 998ffb44..23435673 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -21,6 +21,7 @@ option ('nintendo-ds-plugin', description: 'Support for Nintendo DS games',
option ('playstation-plugin', description: 'Support for PlayStation games', type: 'boolean')
option ('sega-cd-plugin', description: 'Support for Sega CD games', type: 'boolean')
option ('sega-saturn-plugin', description: 'Support for Sega Saturn games', type: 'boolean')
+option ('sharp-x68000-plugin', description: 'Support for Sharp X68000 games', type: 'boolean')
option ('steam-plugin', description: 'Support for Steam games', type: 'boolean')
option ('turbografx-cd-plugin', description: 'Support for TurboGrafx-CD games', type: 'boolean')
option ('virtual-boy-plugin', description: 'Support for Virtual Boy games', type: 'boolean')
diff --git a/plugins/meson.build b/plugins/meson.build
index 3fe8b172..5261dc75 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -10,6 +10,7 @@ plugins = [
'playstation',
'sega-cd',
'sega-saturn',
+ 'sharp-x68000',
'steam',
'turbografx-cd',
'virtual-boy',
diff --git a/plugins/sharp-x68000/data/meson.build b/plugins/sharp-x68000/data/meson.build
new file mode 100644
index 00000000..0d4b6c49
--- /dev/null
+++ b/plugins/sharp-x68000/data/meson.build
@@ -0,0 +1 @@
+install_data (plugin_name + '.plugin', install_dir: plugins_dir)
diff --git a/plugins/sharp-x68000/data/sharp-x68000.plugin b/plugins/sharp-x68000/data/sharp-x68000.plugin
new file mode 100644
index 00000000..8070e816
--- /dev/null
+++ b/plugins/sharp-x68000/data/sharp-x68000.plugin
@@ -0,0 +1,6 @@
+[Plugin]
+Module=libgames-sharp-x68000-plugin
+Name=Sharp X68000 Plugin
+Description=Provides support for Sharp X68000 games.
+Authors=Alexander Mikhaylenko <exalm7659 gmail com>
+Copyright=Copyright © 2018 Alexander Mikhaylenko
diff --git a/plugins/sharp-x68000/meson.build b/plugins/sharp-x68000/meson.build
new file mode 100644
index 00000000..d7e84900
--- /dev/null
+++ b/plugins/sharp-x68000/meson.build
@@ -0,0 +1,2 @@
+subdir ('data')
+subdir ('src')
diff --git a/plugins/sharp-x68000/src/meson.build b/plugins/sharp-x68000/src/meson.build
new file mode 100644
index 00000000..18a60702
--- /dev/null
+++ b/plugins/sharp-x68000/src/meson.build
@@ -0,0 +1,19 @@
+vala_sources = [
+ 'sharp-x68000-game-factory.vala',
+ 'sharp-x68000-gameinfo-cache.vala',
+ 'sharp-x68000-input-capabilities.vala',
+ 'sharp-x68000-plugin.vala',
+]
+
+c_args = [
+ '-DG_LOG_DOMAIN="GamesSharpX68000"'
+]
+
+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/sharp-x68000/src/sharp-x68000-game-factory.vala
b/plugins/sharp-x68000/src/sharp-x68000-game-factory.vala
new file mode 100644
index 00000000..431519df
--- /dev/null
+++ b/plugins/sharp-x68000/src/sharp-x68000-game-factory.vala
@@ -0,0 +1,181 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.SharpX68000GameFactory : Object, UriGameFactory {
+ private const string FINGERPRINT_PREFIX = "sharp-x68000";
+ private const string MIME_TYPE_DIM = "application/x-x68k-rom";
+ private const string MIME_TYPE_XDF = "application/x-x68k-xdf-rom";
+ private const string MIME_TYPE_HDF = "application/x-x68k-hdf-rom";
+ private const string MIME_TYPE_TGDB = "application/x-sharp-x68000-rom";
+ private const string PLATFORM = "SharpX68000";
+ private const string ICON_NAME = "media-floppy-symbolic";
+
+ private HashTable<string, PartialGameData?> uris_for_game;
+ private HashTable<Uri, Game> game_for_uri;
+ private GenericSet<Game> games;
+ private RetroPlatform platform;
+ private SharpX68000GameinfoCache gameinfo_cache;
+ private unowned GameCallback game_added_callback;
+
+ private struct PartialGameData {
+ Uri?[] uris;
+ string?[] titles;
+ }
+
+ public SharpX68000GameFactory (RetroPlatform platform, SharpX68000GameinfoCache gameinfo_cache) {
+ uris_for_game = new HashTable<string, PartialGameData?> (str_hash, str_equal);
+ game_for_uri = new HashTable<Uri, Game> (Uri.hash, Uri.equal);
+ games = new GenericSet<Game> (direct_hash, direct_equal);
+ this.platform = platform;
+ this.gameinfo_cache = gameinfo_cache;
+ }
+
+ public string[] get_mime_types () {
+ return { MIME_TYPE_DIM, MIME_TYPE_XDF, MIME_TYPE_HDF };
+ }
+
+ public Game? query_game_for_uri (Uri uri) {
+ if (game_for_uri.contains (uri))
+ return game_for_uri[uri];
+
+ return null;
+ }
+
+ public void add_uri (Uri uri) {
+ try {
+ add_uri_with_error (uri);
+ }
+ catch (Error e) {
+ debug (e.message);
+ }
+ }
+
+ private void add_uri_with_error (Uri uri) throws Error {
+ if (game_for_uri.contains (uri))
+ return;
+
+ var file = uri.to_file ();
+ 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_DIM && mime_type != MIME_TYPE_XDF && mime_type != MIME_TYPE_HDF)
+ return;
+
+ var path = file.get_path ();
+ print ("%s\n", path);
+
+ var regex = /\((Dis[ck] (\d+)) of (\d+)\)/i;
+ MatchInfo match_info;
+ if (regex.match (path, 0, out match_info)) {
+ // The game has multiple disks
+ var title = match_info.fetch (1);
+ var index = int.parse (match_info.fetch (2));
+ var total = int.parse (match_info.fetch (3));
+ print ("%d %d\n", index, total);
+
+ if (index > 0 && total > 0) {
+ var game_id = regex.replace (path, path.length, 0, "");
+ print ("%s\n", game_id);
+ if (!uris_for_game.contains (game_id))
+ uris_for_game.insert(game_id, { new Uri?[total], new string?[total]
});
+ uris_for_game.lookup(game_id).uris[index - 1] = uri;
+ uris_for_game.lookup(game_id).titles[index - 1] = title;
+
+ var data = uris_for_game.lookup(game_id);
+ bool complete = true;
+ foreach (var u in data.uris)
+ 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 ();
+ for (var i = 0; i < total; i++) {
+ var media = new Media (new GenericTitle (data.titles[i]));
+ media.add_uri (data.uris[i]);
+ media_set.add_media (media);
+ }
+ media_set.icon = GLib.Icon.new_for_string (ICON_NAME);
+
+ var game = create_game (data.uris[0], mime_type);
+ gameinfo_cache.store_info (data.uris[0], media_set);
+
+ foreach (var u in data.uris)
+ game_for_uri[u] = game;
+
+ games.add (game);
+ if (game_added_callback != null)
+ game_added_callback (game);
+ }
+
+ return;
+ }
+ }
+
+ print ("The game is single-disk\n");
+
+ var game = create_game (uri, mime_type);
+
+ game_for_uri[uri] = game;
+ games.add (game);
+
+ if (game_added_callback != null)
+ game_added_callback (game);
+/*
+// File bin_file;
+// var disc_id = uri.to_string
+
+ // Check whether we already have a media and by extension a media set
+ // and a game for this disc ID. If such a case, simply add the new URI.
+ if (media_for_disc_id.contains (disc_id)) {
+ var media = media_for_disc_id.lookup (disc_id);
+ media.add_uri (uri);
+ game_for_uri[uri] = game_for_disc_set_id[disc_set_id];
+
+ return;
+ }
+/*
+ var media_set = new MediaSet ();
+ foreach (var game_media in new_medias_array)
+ media_set.add_media (game_media);
+ media_set.icon = GLib.Icon.new_for_string (ICON_NAME);
+ var game = create_game (media_set, disc_set_id, uri);
+
+ // Creating the Medias, MediaSet and Game worked, we can save them.
+
+ foreach (var new_disc_id in new_medias.get_keys ())
+ media_for_disc_id[new_disc_id] = new_medias[new_disc_id];
+*/
+
+// var game = create_game (uri);
+
+// game_for_uri[uri] = game;
+// games.add (game);
+
+// game_added (game);
+ }
+
+ public void foreach_game (GameCallback game_callback) {
+ games.foreach ((game) => game_callback (game));
+ }
+
+ private Game create_game (Uri uri, string mime_type) throws Error {
+ var uid = new FingerprintUid (uri, FINGERPRINT_PREFIX);
+ var title = new FilenameTitle (uri);
+ var media = new GriloMedia (title, MIME_TYPE_TGDB);
+ 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;
+ }
+
+ public void set_game_added_callback (GameCallback game_callback) {
+ game_added_callback = game_callback;
+ }
+}
diff --git a/plugins/sharp-x68000/src/sharp-x68000-gameinfo-cache.vala
b/plugins/sharp-x68000/src/sharp-x68000-gameinfo-cache.vala
new file mode 100644
index 00000000..0e6da21c
--- /dev/null
+++ b/plugins/sharp-x68000/src/sharp-x68000-gameinfo-cache.vala
@@ -0,0 +1,21 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.SharpX68000GameinfoCache : Object {
+ private HashTable<Uri, MediaSet> media_set_for_uri;
+
+ construct {
+ media_set_for_uri = new HashTable<Uri, MediaSet> (Uri.hash, Uri.equal);
+ }
+
+ public void store_info (Uri uri, MediaSet media_set) {
+ media_set_for_uri[uri] = media_set;
+ }
+
+ public bool media_set_exists (Uri uri) {
+ return uri in media_set_for_uri;
+ }
+
+ public MediaSet get_media_set (Uri uri) {
+ return media_set_for_uri[uri];
+ }
+}
diff --git a/plugins/sharp-x68000/src/sharp-x68000-input-capabilities.vala
b/plugins/sharp-x68000/src/sharp-x68000-input-capabilities.vala
new file mode 100644
index 00000000..8f6989a1
--- /dev/null
+++ b/plugins/sharp-x68000/src/sharp-x68000-input-capabilities.vala
@@ -0,0 +1,13 @@
+public class Games.SharpX68000InputCapabilities : Object, InputCapabilities {
+ public bool get_allow_classic_gamepads () throws Error {
+ return true;
+ }
+
+ public bool get_allow_analog_gamepads () throws Error {
+ return true;
+ }
+
+ public bool get_allow_keyboard_mode () {
+ return true;
+ }
+}
diff --git a/plugins/sharp-x68000/src/sharp-x68000-plugin.vala
b/plugins/sharp-x68000/src/sharp-x68000-plugin.vala
new file mode 100644
index 00000000..7f401162
--- /dev/null
+++ b/plugins/sharp-x68000/src/sharp-x68000-plugin.vala
@@ -0,0 +1,68 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private class Games.SharpX68000Plugin : Object, Plugin {
+ private const string MIME_TYPE_DIM = "application/x-x68k-rom";
+ private const string MIME_TYPE_XDF = "application/x-x68k-xdf-rom";
+ private const string MIME_TYPE_HDF = "application/x-x68k-hdf-rom";
+ private const string PLATFORM_ID = "SharpX68000";
+ private const string PLATFORM_NAME = _("Sharp X68000");
+ private const string PLATFORM_UID_PREFIX = "sharp-x68000";
+
+ private static RetroPlatform platform;
+ private static SharpX68000GameinfoCache gameinfo_cache;
+
+ static construct {
+ string[] mime_types = { MIME_TYPE_DIM, MIME_TYPE_XDF, MIME_TYPE_HDF };
+ platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types, PLATFORM_UID_PREFIX);
+ gameinfo_cache = new SharpX68000GameinfoCache ();
+ }
+
+ public Platform[] get_platforms () {
+ return { platform };
+ }
+
+ public string[] get_mime_types () {
+ return { MIME_TYPE_DIM, MIME_TYPE_XDF, MIME_TYPE_HDF };
+ }
+
+ public UriGameFactory[] get_uri_game_factories () {
+ var factory = new SharpX68000GameFactory (platform, gameinfo_cache);
+
+ return { factory };
+ }
+
+ public RunnerFactory[] get_runner_factories () {
+ var factory = new GenericRunnerFactory (create_runner);
+ factory.add_platform (platform);
+
+ return { factory };
+ }
+
+ public static Runner? create_runner (Game game) throws Error {
+ var uri = game.get_uri ();
+ var input_capabilities = new SharpX68000InputCapabilities ();
+
+ var core_source = new RetroCoreSource (platform);
+
+ var builder = new RetroRunnerBuilder ();
+ builder.core_source = core_source;
+
+ if (gameinfo_cache.media_set_exists (uri)) {
+ var media_set = gameinfo_cache.get_media_set (uri);
+ builder.media_set = media_set;
+ }
+ else
+ builder.uri = uri;
+
+ builder.uid = game.get_uid ();
+ builder.title = game.name;
+ builder.input_capabilities = input_capabilities;
+
+ return builder.to_runner ();
+ }
+}
+
+[ModuleInit]
+public Type register_games_plugin (TypeModule module) {
+ return typeof(Games.SharpX68000Plugin);
+}
diff --git a/src/retro/retro-core-source.vala b/src/retro/retro-core-source.vala
index cc0ad491..0bf7743e 100644
--- a/src/retro/retro-core-source.vala
+++ b/src/retro/retro-core-source.vala
@@ -63,9 +63,8 @@ public class Games.RetroCoreSource : Object {
var platforms_dir = Application.get_platforms_dir ();
var platform_id = platform.get_id ();
- var firmware_dir = File.new_for_path (@"$platforms_dir/$platform_id/system");
var firmware_path = core_descriptor.get_firmware_path (firmware);
- var firmware_file = firmware_dir.get_child (firmware_path);
+ var firmware_file = File.new_for_path(@"$platforms_dir/$platform_id/system/" + firmware_path);
if (!firmware_file.query_exists ())
throw new RetroError.FIRMWARE_NOT_FOUND (_("This game requires the %s firmware file
to run."), firmware_file.get_path ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]