diff --git a/README.md b/README.md
index dc2f419..2395502 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# OpenGP
+
+
OpenGP is a **native PC port of Mario Kart Arcade GP and Mario Kart Arcade GP 2**
(Namco, 2005 and 2007, Triforce arcade hardware). It is built by **static recompilation**, the
same approach as [Zelda64Recomp](https://github.com/Zelda64Recomp/Zelda64Recomp) and
@@ -63,6 +65,10 @@ unpack it and open `OpenGP`, the launcher. Add your disc image of each game: Ope
on your machine from your images, then plays them (see [docs/packaging.md](docs/packaging.md) and
[docs/playing.md](docs/playing.md)). On the command line, `opengp-cli` builds them the same way.
+[RecompLauncher](https://recomplauncher.com/game/opengp) can also install and update OpenGP,
+build GP 2 from your disc image and start it, with OpenGP's settings on the game's page. GP 1 is
+built and played from OpenGP's own launcher in the same folder.
+
## Building
You need CMake 3.25+, Ninja, Python 3.9+, and GCC 12+ or Clang 16+. On Windows, use clang-cl: the
diff --git a/cmake/package.cmake b/cmake/package.cmake
index 96acf99..115deb3 100644
--- a/cmake/package.cmake
+++ b/cmake/package.cmake
@@ -156,3 +156,10 @@ install(FILES ${PROJECT_SOURCE_DIR}/thirdparty/qt/third-party.txt DESTINATION li
# All of them: the player's pages link to the others.
install(DIRECTORY ${PROJECT_SOURCE_DIR}/docs/ DESTINATION docs FILES_MATCHING PATTERN "*.md")
install(FILES ${PROJECT_SOURCE_DIR}/tools/installer/ISO-README.txt DESTINATION ISO RENAME README.txt)
+
+# How RecompLauncher (recomplauncher.com) sets the package up, next to the
+# launcher. Its setup step is versioned with the package: each version builds
+# the game again.
+configure_file(${PROJECT_SOURCE_DIR}/tools/installer/recomplauncher.json.in
+ ${CMAKE_BINARY_DIR}/package/recomplauncher.json @ONLY)
+install(FILES ${CMAKE_BINARY_DIR}/package/recomplauncher.json DESTINATION .)
diff --git a/docs/packaging.md b/docs/packaging.md
index 16c1a86..861b1c8 100644
--- a/docs/packaging.md
+++ b/docs/packaging.md
@@ -95,6 +95,17 @@ opengp-cli [IMAGE...] [--force] [--jobs N] [--cxx COMPILER] [--keep-build]
- `--cxx COMPILER` uses this C++ compiler instead of the package's.
- `--keep-build` keeps the generated C++ and the object files in `build//`. The installer
deletes them once the game is built otherwise.
+- `--only ID` builds only that game (`GGPE02` or `GGPE01`). An image of the other game is an error.
+- `--prepare` is for other launchers: it prints its progress as `progress <0 to 1> ` lines
+ and never waits for a key at the end.
+
+### RecompLauncher
+
+The package carries a `recomplauncher.json`, which tells [RecompLauncher](https://recomplauncher.com)
+how to set OpenGP up: the player picks their GP 2 disc image, RecompLauncher runs
+`opengp-cli --prepare --only GGPE02 ` to build the game, and Play starts `opengp-mkgp2`
+with `--iso `. OpenGP's settings show on the game's page there, and RecompLauncher edits
+`user/settings.toml` before each start. Each new version of OpenGP builds the game again.
## The compiler
diff --git a/tools/installer/main.cpp b/tools/installer/main.cpp
index 141035c..9d6ae04 100644
--- a/tools/installer/main.cpp
+++ b/tools/installer/main.cpp
@@ -4,13 +4,19 @@
// from the player's disc images, as the launcher (the package's OpenGP) does.
//
// opengp-cli [IMAGE...] [--force] [--jobs N] [--cxx COMPILER] [--keep-build]
+// [--only ID] [--prepare]
//
// Without images it uses the images each game was built from before, then
// those in ISO/ and private/ next to it. Each game is built on its own: a
// missing image only skips that game. Games already built by this version
// are skipped unless --force is given. On Windows an image can be dropped on
// opengp-cli.exe.
+//
+// For other launchers (RecompLauncher's recomplauncher.json): --only ID builds
+// that game alone, and an image of another game is an error; --prepare prints
+// the progress as "progress <0..1> " lines and never waits for a key.
+#include
#include
#include
#include
@@ -32,11 +38,16 @@ namespace {
constexpr const char* kUsage =
"usage: opengp-cli [IMAGE...] [--force] [--jobs N] [--cxx COMPILER]\n"
- " [--keep-build]\n"
+ " [--keep-build] [--only ID] [--prepare]\n"
"\n"
"Builds the games from your disc images (.iso / .gcm). Without images, it uses\n"
"the ones the games were built from before, then those in ISO/ and private/.\n"
- "OpenGP, the launcher next to it, does the same in a window.\n";
+ "OpenGP, the launcher next to it, does the same in a window.\n"
+ "\n"
+ " --only ID build only this game (GGPE02 or GGPE01); an image of another\n"
+ " game is an error\n"
+ " --prepare for other launchers: the progress as \"progress <0..1> \"\n"
+ " lines, and no waiting for a key at the end\n";
// When opengp-cli.exe was started from Explorer (a double click, or an
// image dropped on it), its console closes when it exits: wait for a key first.
@@ -51,9 +62,9 @@ void pause_if_own_console() {
#endif
}
-int run(const std::vector& args) {
+int run(const std::vector& args, bool* prepare) {
std::vector images;
- std::string cxx;
+ std::string cxx, only;
bool force = false;
installer::BuildOptions options;
const std::size_t argc = args.size();
@@ -70,6 +81,8 @@ int run(const std::vector& args) {
}
options.jobs = static_cast(n);
} else if (a == "--cxx" && i + 1 < argc) cxx = args[++i];
+ else if (a == "--only" && i + 1 < argc) only = args[++i];
+ else if (a == "--prepare") *prepare = true;
else if (a == "-h" || a == "--help") {
std::printf("%s", kUsage);
return 0;
@@ -87,6 +100,25 @@ int run(const std::vector& args) {
std::fprintf(stderr, "%s\n", installer::not_a_package_message(error).c_str());
return 1;
}
+ if (!only.empty()) {
+ // This game alone: the package's others are left out of this run.
+ const auto it = std::find_if(package.games.begin(), package.games.end(),
+ [&](const installer::GameInfo& g) { return g.id == only; });
+ if (it == package.games.end()) {
+ std::fprintf(stderr, "--only %s: not one of this package's games\n", only.c_str());
+ return 2;
+ }
+ for (const std::string& image : images) {
+ const installer::GameInfo* g = installer::identify_image(package, image);
+ if (g && g->id != only) {
+ std::fprintf(stderr, "%s is %s (%s), not %s (%s). Pick your disc image of %s.\n", image.c_str(),
+ g->title.c_str(), g->id.c_str(), it->title.c_str(), it->id.c_str(), it->title.c_str());
+ return 1;
+ }
+ }
+ installer::GameInfo game = *it;
+ package.games = {std::move(game)};
+ }
std::printf("OpenGP %s installer\n\n", package.version.c_str());
// Everything it makes goes in the package folder: say so at once if it
// cannot write there.
@@ -96,14 +128,37 @@ int run(const std::vector& args) {
}
installer::Reporter report;
- report.line = [](const std::string& s) {
- std::printf("\r%s\n", s.c_str());
- std::fflush(stdout);
- };
- report.progress = [](double f) {
- std::printf("\r %3d%%", static_cast(f * 100 + 0.5));
- std::fflush(stdout);
- };
+ // --prepare: the whole run as one fraction. Each game's share is mostly its
+ // compile step, the only one that reports its own progress.
+ std::size_t game_index = 0, game_count = 1;
+ double game_done = 0;
+ std::string last_line;
+ int last_percent = -1;
+ auto overall = [&] { return (static_cast(game_index) + game_done) / static_cast(game_count); };
+ if (*prepare) {
+ report.line = [&](const std::string& s) {
+ last_line = s;
+ std::printf("progress %.3f %s\n", overall(), s.c_str());
+ std::fflush(stdout);
+ };
+ report.progress = [&](double f) {
+ game_done = 0.1 + 0.85 * f;
+ const int percent = static_cast(overall() * 100);
+ if (percent == last_percent) return;
+ last_percent = percent;
+ std::printf("progress %.3f %s\n", overall(), last_line.c_str());
+ std::fflush(stdout);
+ };
+ } else {
+ report.line = [](const std::string& s) {
+ std::printf("\r%s\n", s.c_str());
+ std::fflush(stdout);
+ };
+ report.progress = [](double f) {
+ std::printf("\r %3d%%", static_cast(f * 100 + 0.5));
+ std::fflush(stdout);
+ };
+ }
const auto found = installer::find_images(package, images, report);
for (const installer::GameInfo& g : package.games) {
@@ -112,15 +167,21 @@ int run(const std::vector& args) {
if (!have) std::printf("%s: no disc image found; skipped.\n", g.title.c_str());
}
if (found.empty()) {
- std::printf(
- "\nPut your disc images in the ISO folder next to opengp-cli, or drop one on it (see ISO/README.txt).\n");
+ if (*prepare)
+ std::fprintf(stderr, "No disc image of %s found.\n", package.games.front().title.c_str());
+ else
+ std::printf(
+ "\nPut your disc images in the ISO folder next to opengp-cli, or drop one on it (see ISO/README.txt).\n");
return 1;
}
int failures = 0;
std::string compiler;
+ game_count = found.size();
for (const auto& [game, image] : found) {
- std::printf("\n%s (%s)\n", game->title.c_str(), game->id.c_str());
+ game_done = 0;
+ if (*prepare) report.line(game->title + " (" + game->id + ")");
+ else std::printf("\n%s (%s)\n", game->title.c_str(), game->id.c_str());
if (!force && installer::is_installed(package, *game)) {
std::printf("Already built by this version (--force rebuilds it).\n");
// The image may have moved: the game uses this one from now on.
@@ -130,6 +191,7 @@ int run(const std::vector& args) {
else
std::fprintf(stderr, "%s\n", error.c_str());
}
+ ++game_index;
continue;
}
if (compiler.empty() && !installer::find_compiler(package, cxx, report, &compiler, &error)) {
@@ -140,15 +202,24 @@ int run(const std::vector& args) {
std::fprintf(stderr, "\n%s\n", error.c_str());
++failures;
}
+ ++game_index;
+ }
+ if (*prepare) {
+ if (failures == 0) {
+ game_done = 0;
+ report.line("Ready to play");
+ }
+ } else if (failures == 0) {
+ std::printf("\nDone. Start a game with OpenGP, or with opengp-mkgp2 or opengp-mkgp1.\n");
}
- if (failures == 0) std::printf("\nDone. Start a game with OpenGP, or with opengp-mkgp2 or opengp-mkgp1.\n");
return failures ? 1 : 0;
}
} // namespace
int main(int argc, char** argv) {
- const int code = run(os::utf8_args(argc, argv));
- pause_if_own_console();
+ bool prepare = false;
+ const int code = run(os::utf8_args(argc, argv), &prepare);
+ if (!prepare) pause_if_own_console();
return code;
}
diff --git a/tools/installer/recomplauncher.json.in b/tools/installer/recomplauncher.json.in
new file mode 100644
index 0000000..56d279b
--- /dev/null
+++ b/tools/installer/recomplauncher.json.in
@@ -0,0 +1,198 @@
+{
+ "$schema": "https://recomplauncher.com/schema/recomplauncher.json",
+ "format": 1,
+ "name": "OpenGP",
+ "repo": "OpenGP-dev/OpenGP",
+ "game": {
+ "kind": "iso",
+ "label": "Your disc image (.iso or .gcm) of Mario Kart Arcade GP 2, the USA release (GGPE02). A compressed image (.rvz, .gcz, .ciso) must be converted to .iso in Dolphin first.",
+ "check": { "ids": ["GGPE02", "RELSAB"] }
+ },
+ "prepare": {
+ "program": ["opengp-cli.exe", "opengp-cli"],
+ "args": ["--prepare", "--only", "GGPE02", "{game}"],
+ "label": "Building the game from your disc (once per OpenGP version). On Windows the first build downloads the compiler, about 190 MB.",
+ "timeout": 3600,
+ "version": "@PROJECT_VERSION@"
+ },
+ "start": {
+ "program": ["opengp-mkgp2.exe", "opengp-mkgp2"],
+ "args": ["--iso", "{game}"]
+ },
+ "config": [
+ {
+ "id": "main",
+ "format": "toml",
+ "file": [{ "path": "{install}/user/settings.toml" }]
+ }
+ ],
+ "saves": [
+ "{install}/user/tribackup_*.bin",
+ "{install}/user/cards",
+ "{install}/user/settings.toml",
+ "{install}/user/controls.toml"
+ ],
+ "folders": {
+ "saves": [{ "path": "{install}/user" }],
+ "screenshots": [{ "path": "{install}/user/screenshots" }]
+ },
+ "settings": [
+ {
+ "id": "window", "label": "Window", "group": "Video",
+ "help": "Fullscreen fills your screen. F11 or Alt+Enter switches in the game.",
+ "choices": [
+ { "label": "Windowed", "set": { "video/fullscreen": "false" } },
+ { "label": "Fullscreen", "set": { "video/fullscreen": "true" } }
+ ],
+ "defaults": { "video/fullscreen": "false" }
+ },
+ {
+ "id": "window_size", "label": "Window size", "group": "Video",
+ "help": "The window's size when not fullscreen, at 100% display scale.",
+ "choices": [
+ { "label": "1280 x 720", "set": { "video/window_width": "1280", "video/window_height": "720" } },
+ { "label": "1600 x 900", "set": { "video/window_width": "1600", "video/window_height": "900" } },
+ { "label": "1920 x 1080", "set": { "video/window_width": "1920", "video/window_height": "1080" } },
+ { "label": "960 x 720 (4:3)", "set": { "video/window_width": "960", "video/window_height": "720" } }
+ ],
+ "defaults": { "video/window_width": "1280", "video/window_height": "720", "video/fullscreen": "false" },
+ "when": { "video/fullscreen": "false" }
+ },
+ {
+ "id": "aspect", "label": "Aspect ratio", "group": "Video",
+ "help": "Wider than 4:3 shows more of the course at the sides. Automatic follows the window's shape.",
+ "choices": [
+ { "label": "Automatic", "set": { "video/aspect_ratio": "\"auto\"" } },
+ { "label": "4:3 (the cabinet's)", "set": { "video/aspect_ratio": "\"4:3\"" } },
+ { "label": "16:9", "set": { "video/aspect_ratio": "\"16:9\"" } },
+ { "label": "16:10", "set": { "video/aspect_ratio": "\"16:10\"" } },
+ { "label": "21:9", "set": { "video/aspect_ratio": "\"21:9\"" } }
+ ],
+ "defaults": { "video/aspect_ratio": "\"auto\"" }
+ },
+ {
+ "id": "resolution", "label": "Resolution", "group": "Video",
+ "help": "What the game draws at, in times the cabinet's own picture. Match the window picks the size for your screen; higher needs a faster graphics card.",
+ "choices": [
+ { "label": "Match the window", "set": { "video/internal_resolution": "0" } },
+ { "label": "1x (the cabinet's)", "set": { "video/internal_resolution": "1" } },
+ { "label": "2x", "set": { "video/internal_resolution": "2" } },
+ { "label": "3x", "set": { "video/internal_resolution": "3" } },
+ { "label": "4x", "set": { "video/internal_resolution": "4" } },
+ { "label": "6x", "set": { "video/internal_resolution": "6" } },
+ { "label": "8x", "set": { "video/internal_resolution": "8" } }
+ ],
+ "defaults": { "video/internal_resolution": "0" }
+ },
+ {
+ "id": "vsync", "label": "V-Sync", "group": "Video",
+ "help": "Waits for your screen's refresh, so the picture never tears. The game always runs at 60 FPS, as on the cabinet.",
+ "choices": [
+ { "label": "On", "set": { "video/vsync": "true" } },
+ { "label": "Off", "set": { "video/vsync": "false" } }
+ ],
+ "defaults": { "video/vsync": "true" }
+ },
+ {
+ "id": "even_pacing", "label": "Even frame pacing", "group": "Video",
+ "help": "Shows each frame on the game's own 60 Hz tick, as the cabinet's screen does: smoother on FreeSync and G-Sync screens, about half a frame later.",
+ "choices": [
+ { "label": "Off", "set": { "video/even_pacing": "false" } },
+ { "label": "On", "set": { "video/even_pacing": "true" } }
+ ],
+ "defaults": { "video/even_pacing": "false" }
+ },
+ {
+ "id": "volume", "label": "Volume", "group": "Sound",
+ "help": "The game's volume, in percent.",
+ "slider": { "key": "audio/volume", "min": 0, "max": 100, "step": 5, "format": "%d" },
+ "defaults": { "audio/volume": "100" }
+ },
+ {
+ "id": "free_play", "label": "Free play", "group": "Game",
+ "help": "Play without inserting coins.",
+ "choices": [
+ { "label": "Off", "set": { "game/free_play": "false" } },
+ { "label": "On", "set": { "game/free_play": "true" } }
+ ],
+ "defaults": { "game/free_play": "false" }
+ },
+ {
+ "id": "brake_goes_back", "label": "Brake goes back", "group": "Game",
+ "help": "The brake goes back a screen in the game's menus, to change your character, kart or cup. Off in linked games.",
+ "choices": [
+ { "label": "On", "set": { "game/brake_goes_back": "true" } },
+ { "label": "Off", "set": { "game/brake_goes_back": "false" } }
+ ],
+ "defaults": { "game/brake_goes_back": "true" }
+ },
+ {
+ "id": "pause_in_menu", "label": "Pause in the menu", "group": "Game",
+ "help": "The game pauses while OpenGP's menu (Esc) is open. Never in linked games.",
+ "choices": [
+ { "label": "On", "set": { "game/pause_in_menu": "true" } },
+ { "label": "Off", "set": { "game/pause_in_menu": "false" } }
+ ],
+ "defaults": { "game/pause_in_menu": "true" }
+ },
+ {
+ "id": "pause_in_background", "label": "Pause in the background", "group": "Game",
+ "help": "The game pauses while its window isn't the one in front. Never in linked games.",
+ "choices": [
+ { "label": "Off", "set": { "game/pause_in_background": "false" } },
+ { "label": "On", "set": { "game/pause_in_background": "true" } }
+ ],
+ "defaults": { "game/pause_in_background": "false" }
+ },
+ {
+ "id": "camera", "label": "Camera", "group": "Game",
+ "help": "The cabinet's camera takes the players' photos. Webcam uses yours; Test shows colour bars.",
+ "choices": [
+ { "label": "Off", "set": { "camera/source": "\"off\"" } },
+ { "label": "Webcam", "set": { "camera/source": "\"webcam\"" } },
+ { "label": "Test pattern", "set": { "camera/source": "\"test\"" } }
+ ],
+ "defaults": { "camera/source": "\"off\"" }
+ },
+ {
+ "id": "rich_presence", "label": "Discord status", "group": "Game",
+ "help": "Shows your character, cup, course and place on your Discord profile while Discord runs.",
+ "choices": [
+ { "label": "On", "set": { "discord/rich_presence": "true" } },
+ { "label": "Off", "set": { "discord/rich_presence": "false" } }
+ ],
+ "defaults": { "discord/rich_presence": "true" }
+ },
+ {
+ "id": "cabinet", "label": "Cabinet number", "group": "Linked cabinets",
+ "help": "For linked races, give each OpenGP its own number. Game's own uses the number set in the game's test menu.",
+ "choices": [
+ { "label": "Game's own", "set": { "link/cabinet": "0" } },
+ { "label": "1", "set": { "link/cabinet": "1" } },
+ { "label": "2", "set": { "link/cabinet": "2" } },
+ { "label": "3", "set": { "link/cabinet": "3" } },
+ { "label": "4", "set": { "link/cabinet": "4" } }
+ ],
+ "defaults": { "link/cabinet": "0" }
+ },
+ {
+ "id": "lan", "label": "Link over the network", "group": "Linked cabinets",
+ "help": "Also links with OpenGP on other computers on your local network, not only on this one.",
+ "choices": [
+ { "label": "Off", "set": { "link/lan": "false" } },
+ { "label": "On", "set": { "link/lan": "true" } }
+ ],
+ "defaults": { "link/lan": "false" }
+ }
+ ],
+ "groups": [
+ { "id": "Video" },
+ { "id": "Sound" },
+ { "id": "Game" },
+ { "id": "Linked cabinets", "advanced": true }
+ ],
+ "actions": [
+ { "id": "saves", "label": "Saves and settings", "help": "Your Mario Cards, the game's records, settings and controls.", "open": "saves" },
+ { "id": "screenshots", "label": "Screenshots", "help": "The screenshots you've taken in the game.", "open": "screenshots" }
+ ]
+}