diff --git a/README.md b/README.md index 09139308..05eba070 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Run `./extract-assets.py --clean && make clean` or `make distclean` to remove RO * Analog camera control and mouse look. (Activate with `make BETTERCAMERA=1`.) * An option to disable drawing distances. (Activate with `make NODRAWINGDISTANCE=1`.) * In-game control binding, currently available on the `testing` branch. - * Skip introductory Peach & Lakitu cutscenes with a `--skip-intro` CLI option, currently available on `testing` and `skip-intro` branches. + * Skip introductory Peach & Lakitu cutscenes with the `--skip-intro` CLI option ## Building For building instructions, please refer to the [wiki](https://github.com/sm64pc/sm64pc/wiki). diff --git a/src/game/level_update.c b/src/game/level_update.c index b2450c0b..13246ad5 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -32,6 +32,8 @@ #include "../pc/configfile.h" #define CONFIG_FILE "sm64config.txt" +#include "pc/cliopts.h" + #define PLAY_MODE_NORMAL 0 #define PLAY_MODE_PAUSED 2 #define PLAY_MODE_CHANGE_AREA 3 @@ -176,7 +178,8 @@ s8 D_8032C9E0 = 0; u8 unused3[4]; u8 unused4[2]; - +// For configfile intro skipping +extern unsigned int configSkipIntro; void basic_update(s16 *arg); @@ -1214,7 +1217,7 @@ s32 init_level(void) { if (gMarioState->action != ACT_UNINITIALIZED) { if (save_file_exists(gCurrSaveFileNum - 1)) { set_mario_action(gMarioState, ACT_IDLE, 0); - } else { + } else if (gCLIOpts.SkipIntro == 0 && configSkipIntro == 0) { set_mario_action(gMarioState, ACT_INTRO_CUTSCENE, 0); val4 = 1; } diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c new file mode 100644 index 00000000..cd77ef12 --- /dev/null +++ b/src/pc/cliopts.c @@ -0,0 +1,21 @@ +#include "cliopts.h" +#include + +struct PCCLIOptions gCLIOpts; + +void parse_cli_opts(int argc, char* argv[]) +{ + // Initialize options with false values. + gCLIOpts.SkipIntro = 0; + + // Scan arguments for options + if (argc > 1) + { + int i; + for (i = 1; i < argc; i++) + { + if (strcmp(argv[i], "--skip-intro") == 0) // Skip Peach Intro + gCLIOpts.SkipIntro = 1; + } + } +} \ No newline at end of file diff --git a/src/pc/cliopts.h b/src/pc/cliopts.h new file mode 100644 index 00000000..2f08cc4e --- /dev/null +++ b/src/pc/cliopts.h @@ -0,0 +1,10 @@ +#include "sm64.h" + +struct PCCLIOptions +{ + u8 SkipIntro; +}; + +extern struct PCCLIOptions gCLIOpts; + +void parse_cli_opts(int argc, char* argv[]); \ No newline at end of file diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 4d38aaaf..6b1e83b0 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -69,6 +69,7 @@ bool configCameraInvertY = false; bool configEnableCamera = false; bool configCameraMouse = false; #endif +unsigned int configSkipIntro = 0; static const struct ConfigOption options[] = { {.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configFullscreen}, @@ -107,6 +108,7 @@ static const struct ConfigOption options[] = { {.name = "bettercam_aggression", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraAggr}, {.name = "bettercam_pan_level", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraPan}, #endif + {.name = "skip_intro", .type = CONFIG_TYPE_UINT, .uintValue = &configSkipIntro}, }; // Reads an entire line from a file (excluding the newline character) and returns an allocated string diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 5b4bcd23..ca7adf51 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -18,6 +18,7 @@ #include "audio/audio_sdl.h" #include "audio/audio_null.h" +#include "cliopts.h" #include "configfile.h" OSMesg D_80339BEC; @@ -155,6 +156,7 @@ void main_func(void) { } int main(int argc, char *argv[]) { + parse_cli_opts(argc, argv); main_func(); return 0; }