Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<a href="https://recomplauncher.com/game/starship"><picture><source media="(prefers-color-scheme: dark)" srcset="https://recomplauncher.com/assets/press/launcher/badge-light.svg"><img alt="Get it on RecompLauncher" src="https://recomplauncher.com/assets/press/launcher/badge-dark.svg" height="48"></picture></a>

[comment]: <> (Todo: Make Light Mode Image)
[comment]: <> (Todo: Make Dark Mode Image)

Expand Down
219 changes: 219 additions & 0 deletions recomplauncher.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
56 changes: 56 additions & 0 deletions src/port/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include <Fast3D/interpreter.h>
#include "Engine.h"
#include "extractor/GameExtractor.h"
#include <cstdio>
#include <cstring>
#include <string>

extern "C" {
#include <sf64mesg.h>
Expand Down Expand Up @@ -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 <path to your Star Fox 64 US .z64 ROM>\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
Expand All @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/port/extractor/GameExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "portable-file-dialogs.h"
#endif

// Set by --game <path>: the player's ROM, used instead of the file picker.
std::string gGameArgPath;

std::unordered_map<std::string, std::string> mGameList = {
{ "d8b1088520f7c5f81433292a9258c1184afa1457", "Star Fox 64 (U) (V1.0)" },
{ "63b69f0ef36306257481afc250f9bc304c7162b2", "Star Fox 64 (U) (V1.0) (Uncompressed)" },
Expand All @@ -24,6 +27,14 @@ std::unordered_map<std::string, std::string> mGameList = {
};

bool GameExtractor::SelectGameFromUI() {
if (!gGameArgPath.empty()) {
this->mGamePath = gGameArgPath;
std::ifstream argFile(this->mGamePath, std::ios::binary);
this->mGameData = std::vector<uint8_t>(std::istreambuf_iterator<char>(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();

Expand Down