Merge pull request #102 from sm64pc/skipintro

Add command line parsing and --skip-intro option
This commit is contained in:
Vinícius R. Miguel 2020-05-15 12:36:15 -03:00 committed by GitHub
commit f39d9ad096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 3 deletions

View file

@ -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).

View file

@ -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;
}

21
src/pc/cliopts.c Normal file
View file

@ -0,0 +1,21 @@
#include "cliopts.h"
#include <strings.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;
}
}
}

10
src/pc/cliopts.h Normal file
View file

@ -0,0 +1,10 @@
#include "sm64.h"
struct PCCLIOptions
{
u8 SkipIntro;
};
extern struct PCCLIOptions gCLIOpts;
void parse_cli_opts(int argc, char* argv[]);

View file

@ -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

View file

@ -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;
}