From 4cbe3af070ee8415217e7fe502874fda93eb2be1 Mon Sep 17 00:00:00 2001 From: IvanDSM Date: Mon, 11 May 2020 02:42:22 -0300 Subject: [PATCH 1/5] Added CLI functionality with --skip-intro option. --- src/game/level_update.c | 4 +++- src/pc/cliopts.c | 20 ++++++++++++++++++++ src/pc/cliopts.h | 10 ++++++++++ src/pc/pc_main.c | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/pc/cliopts.c create mode 100644 src/pc/cliopts.h diff --git a/src/game/level_update.c b/src/game/level_update.c index f278811e..8e1c0a99 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -28,6 +28,8 @@ #include "course_table.h" #include "thread6.h" +#include "pc/cliopts.h" + #define PLAY_MODE_NORMAL 0 #define PLAY_MODE_PAUSED 2 #define PLAY_MODE_CHANGE_AREA 3 @@ -1197,7 +1199,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) { 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..162b3e1a --- /dev/null +++ b/src/pc/cliopts.c @@ -0,0 +1,20 @@ +#include "cliopts.h" + +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/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; } From bd93878c5605703797697963d5ab4e48fc6b93f5 Mon Sep 17 00:00:00 2001 From: IvanDSM Date: Mon, 11 May 2020 05:13:51 -0300 Subject: [PATCH 2/5] Add option in the configfile for skipping the intro Now it's possible to either provide the --skip-intro command line argument or have skip_intro set to 1 on the config file. --- src/game/level_update.c | 5 +++-- src/pc/configfile.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 8e1c0a99..698e8c7a 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -174,7 +174,8 @@ s8 D_8032C9E0 = 0; u8 unused3[4]; u8 unused4[2]; - +// For configfile intro skipping +extern unsigned int configSkipIntro; void basic_update(s16 *arg); @@ -1199,7 +1200,7 @@ s32 init_level(void) { if (gMarioState->action != ACT_UNINITIALIZED) { if (save_file_exists(gCurrSaveFileNum - 1)) { set_mario_action(gMarioState, ACT_IDLE, 0); - } else if (gCLIOpts.SkipIntro == 0) { + } else if (gCLIOpts.SkipIntro == 0 && configSkipIntro == 0) { set_mario_action(gMarioState, ACT_INTRO_CUTSCENE, 0); val4 = 1; } 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 From cdcea5c0f8a726ec5a9f6f3ac4cb58a19c18f83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20R=2E=20Miguel?= <36349314+vrmiguel@users.noreply.github.com> Date: Mon, 11 May 2020 18:31:59 -0300 Subject: [PATCH 3/5] Add what's skipintro is about --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fc8e1320..775b891f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# sm64pc +# sm64pc - skipintro branch + +This is a testing branch featuring a new CLI interface and support to skip the introductory Peach & Lakitu cutscenes, useful for development tests. + OpenGL adaptation of [n64decomp/sm64](https://github.com/n64decomp/sm64). Feel free to report bugs and contribute, but remember, there must be **no upload of any copyrighted asset**. From 59d0cc16c194270427bfb42b83ca9feb498008dd Mon Sep 17 00:00:00 2001 From: IvanDSM Date: Thu, 14 May 2020 23:02:04 -0300 Subject: [PATCH 4/5] Add include Oops! --- src/pc/cliopts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index 162b3e1a..cd77ef12 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -1,4 +1,5 @@ #include "cliopts.h" +#include struct PCCLIOptions gCLIOpts; From a43ac2ebafe3650bb857731bda575c5c19976cfd Mon Sep 17 00:00:00 2001 From: IvanDSM Date: Thu, 14 May 2020 23:04:07 -0300 Subject: [PATCH 5/5] Update README for merging --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 775b891f..1815517e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ -# sm64pc - skipintro branch - -This is a testing branch featuring a new CLI interface and support to skip the introductory Peach & Lakitu cutscenes, useful for development tests. - +# sm64pc OpenGL adaptation of [n64decomp/sm64](https://github.com/n64decomp/sm64). Feel free to report bugs and contribute, but remember, there must be **no upload of any copyrighted asset**. @@ -13,6 +10,7 @@ Run `./extract-assets.py --clean && make clean` or `make distclean` to remove RO * Variable aspect ratio and resolution. The game can now correctly render at basically any window size. * Native xinput controller support. On Linux, DualShock 4 has been confirmed to work plug-and-play. * Analog camera control and mouse look. (Activate with `make BETTERCAMERA=1`.) + * Option to skip the Peach/Lakitu new file intro. ## Building For building instructions, please refer to the [wiki](https://github.com/sm64pc/sm64pc/wiki).