diff --git a/README.md b/README.md index 83fd5e4d9..3ce316ca3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +Get it on RecompLauncher + [comment]: <> (Todo: Make Light Mode Image) [comment]: <> (Todo: Make Dark Mode Image) diff --git a/recomplauncher.json b/recomplauncher.json new file mode 100644 index 000000000..22e519c3a --- /dev/null +++ b/recomplauncher.json @@ -0,0 +1,219 @@ +{ + "$schema": "https://recomplauncher.com/schema/recomplauncher.json", + "format": 1, + "name": "Starship", + "game": { + "kind": "iso", + "label": "Your Star Fox 64 US ROM (.z64), version 1.0 or 1.1.", + "check": { + "ids": [ + "NFXE" + ] + } + }, + "start": { + "program": [ + "Starship.exe", + "starship.appimage" + ], + "args": [ + "--game", + "{game}" + ] + }, + "prepare": { + "program": [ + "Starship.exe", + "starship.appimage" + ], + "args": [ + "--prepare", + "--game", + "{game}" + ], + "label": "Extracting the game's assets from your ROM", + "timeout": 600 + }, + "config": [ + { + "id": "main", + "format": "json", + "file": [ + { + "path": "{install}/starship.cfg.json" + } + ] + } + ], + "mods": { + "loader": "otr" + }, + "settings": [ + { + "id": "window", + "label": "Full screen", + "choices": [ + { + "label": "Off", + "set": { + "Window/Fullscreen/Enabled": "false" + } + }, + { + "label": "On", + "set": { + "Window/Fullscreen/Enabled": "true" + } + } + ], + "defaults": { + "Window/Fullscreen/Enabled": "false" + } + }, + { + "id": "resolution", + "label": "Resolution", + "help": "Draws above the window size for a sharper picture.", + "choices": [ + { + "label": "100% (window size)", + "set": { + "CVars/gInternalResolution": "1.0" + } + }, + { + "label": "150%", + "set": { + "CVars/gInternalResolution": "1.5" + } + }, + { + "label": "200%", + "set": { + "CVars/gInternalResolution": "2.0" + } + } + ], + "defaults": { + "CVars/gInternalResolution": "1.0" + } + }, + { + "id": "msaa", + "label": "Anti-aliasing", + "help": "Smoother edges.", + "choices": [ + { + "label": "Off", + "set": { + "CVars/gMSAAValue": "1" + } + }, + { + "label": "2x", + "set": { + "CVars/gMSAAValue": "2" + } + }, + { + "label": "4x", + "set": { + "CVars/gMSAAValue": "4" + } + }, + { + "label": "8x", + "set": { + "CVars/gMSAAValue": "8" + } + } + ], + "defaults": { + "CVars/gMSAAValue": "1" + } + }, + { + "id": "vsync", + "label": "V-Sync", + "help": "Stops tearing, but caps the frame rate at your screen's refresh rate.", + "choices": [ + { + "label": "On", + "set": { + "CVars/gVsyncEnabled": "1" + } + }, + { + "label": "Off", + "set": { + "CVars/gVsyncEnabled": "0" + } + } + ], + "defaults": { + "CVars/gVsyncEnabled": "1" + } + }, + { + "id": "fps", + "label": "Frame rate", + "help": "Higher rates add in-between frames for smoother motion.", + "choices": [ + { + "label": "30 fps (original)", + "set": { + "CVars/gInterpolationFPS": "30" + } + }, + { + "label": "60 fps", + "set": { + "CVars/gInterpolationFPS": "60" + } + }, + { + "label": "120 fps", + "set": { + "CVars/gInterpolationFPS": "120" + } + } + ], + "defaults": { + "CVars/gInterpolationFPS": "60" + } + }, + { + "id": "texfilter", + "label": "Texture filtering", + "help": "How textures are smoothed.", + "choices": [ + { + "label": "Three-point (original)", + "set": { + "CVars/gTextureFilter": "0" + } + }, + { + "label": "Linear", + "set": { + "CVars/gTextureFilter": "1" + } + }, + { + "label": "None", + "set": { + "CVars/gTextureFilter": "2" + } + } + ], + "defaults": { + "CVars/gTextureFilter": "0" + } + } + ], + "requires": [ + "start", + "settings.json", + "settings.choices" + ] +} diff --git a/src/port/Game.cpp b/src/port/Game.cpp index ef7894bed..9b24df055 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -2,6 +2,10 @@ #include #include "Engine.h" +#include "extractor/GameExtractor.h" +#include +#include +#include extern "C" { #include @@ -29,6 +33,47 @@ void push_frame() { GameEngine::EndAudioFrame(); } +extern std::string gGameArgPath; + +// --prepare: make sf64.o2r from the ROM given with --game, without opening a window. +// Same steps as GameEngine::GenAssetFile: read ROM, check hash, GenerateOTR. +static int Starship_Prepare() { + if (gGameArgPath.empty()) { + fprintf(stderr, "--prepare needs --game \n"); + return 1; + } + printf("progress 0.0 Reading your ROM\n"); + fflush(stdout); + + // Same context the engine creates first, so the output goes to the same folder. + auto context = Ship::Context::CreateUninitializedInstance("Starship", "ship", "starship.cfg.json"); + + GameExtractor extractor; + if (!extractor.SelectGameFromUI()) { + fprintf(stderr, "Could not read the ROM at the path given with --game.\n"); + return 1; + } + + printf("progress 0.1 Checking your ROM\n"); + fflush(stdout); + auto game = extractor.ValidateChecksum(); + if (!game.has_value()) { + fprintf(stderr, "This ROM is not supported. Use a US 1.0 or US 1.1 Star Fox 64 ROM in .z64 format.\n"); + return 1; + } + + printf("progress 0.2 Extracting assets from %s\n", game.value().c_str()); + fflush(stdout); + if (!extractor.GenerateOTR()) { + fprintf(stderr, "Asset extraction failed, no O2R file was generated.\n"); + return 1; + } + + printf("progress 1.0 Done\n"); + fflush(stdout); + return 0; +} + #ifdef _WIN32 int SDL_main(int argc, char **argv) { #else @@ -37,6 +82,17 @@ extern "C" #endif int main(int argc, char *argv[]) { #endif + bool prepareOnly = false; + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--game") == 0 && i + 1 < argc) { + gGameArgPath = argv[++i]; + } else if (strcmp(argv[i], "--prepare") == 0) { + prepareOnly = true; + } + } + if (prepareOnly) { + return Starship_Prepare(); + } GameEngine::Create(); Main_SetVIMode(); Lib_FillScreen(1); diff --git a/src/port/extractor/GameExtractor.cpp b/src/port/extractor/GameExtractor.cpp index 9be7f4b7d..c1d021477 100644 --- a/src/port/extractor/GameExtractor.cpp +++ b/src/port/extractor/GameExtractor.cpp @@ -9,6 +9,9 @@ #include "portable-file-dialogs.h" #endif +// Set by --game : the player's ROM, used instead of the file picker. +std::string gGameArgPath; + std::unordered_map mGameList = { { "d8b1088520f7c5f81433292a9258c1184afa1457", "Star Fox 64 (U) (V1.0)" }, { "63b69f0ef36306257481afc250f9bc304c7162b2", "Star Fox 64 (U) (V1.0) (Uncompressed)" }, @@ -24,6 +27,14 @@ std::unordered_map mGameList = { }; bool GameExtractor::SelectGameFromUI() { + if (!gGameArgPath.empty()) { + this->mGamePath = gGameArgPath; + std::ifstream argFile(this->mGamePath, std::ios::binary); + this->mGameData = std::vector(std::istreambuf_iterator(argFile), {}); + argFile.close(); + return !this->mGameData.empty(); + } + #if !defined(__IOS__) && !defined(__ANDROID__) && !defined(__SWITCH__) auto selection = pfd::open_file("Select a file", ".", { "N64 Roms", "*.z64" }).result();