X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fcfgopt.c;h=170e47fffac74a7c27e570a9bb90137e51d6ef06;hp=553a1457fcae6a25144a02c7fc26795e0adbefec;hb=67c749060592270c9cd8b4f7dafe7d7c7a61a614;hpb=493e590908a39324651cd2c81323e6969c0b4c4f diff --git a/src/cfgopt.c b/src/cfgopt.c index 553a145..170e47f 100644 --- a/src/cfgopt.c +++ b/src/cfgopt.c @@ -4,7 +4,27 @@ #include #include "cfgopt.h" -struct options opt; +#ifdef NDEBUG +/* release build default options */ +struct options opt = { + 0, /* start_scr */ + 1, /* music */ + 0, /* mouse */ + 0, /* sball */ + 0, /* vsync */ + 0 /* dbginfo */ +}; +#else +/* debug build default options */ +struct options opt = { + 0, /* start_scr */ + 0, /* music */ + 1, /* mouse */ + 0, /* sball */ + 0, /* vsync */ + 1 /* dbginfo */ +}; +#endif int parse_args(int argc, char **argv) { @@ -19,6 +39,26 @@ int parse_args(int argc, char **argv) opt.music = 0; } else if(strcmp(argv[i], "-scr") == 0 || strcmp(argv[i], "-screen") == 0) { scrname = argv[++i]; + } else if(strcmp(argv[i], "-mouse") == 0) { + opt.mouse = 1; + } else if(strcmp(argv[i], "-nomouse") == 0) { + opt.mouse = 0; + } else if(strcmp(argv[i], "-sball") == 0) { + opt.sball = !opt.sball; + } else if(strcmp(argv[i], "-vsync") == 0) { + opt.vsync = 1; + } else if(strcmp(argv[i], "-novsync") == 0) { + opt.vsync = 0; + } else if(strcmp(argv[i], "-dbg") == 0) { + opt.dbginfo = 1; + } else if(strcmp(argv[i], "-nodbg") == 0) { + opt.dbginfo = 0; +#ifndef MSDOS + } else if(strcmp(argv[i], "-fs") == 0) { + opt.fullscreen = 1; + } else if(strcmp(argv[i], "-win") == 0) { + opt.fullscreen = 0; +#endif } else { fprintf(stderr, "invalid option: %s\n", argv[i]); return -1; @@ -32,7 +72,9 @@ int parse_args(int argc, char **argv) } } - opt.start_scr = scrname; + if(scrname) { + opt.start_scr = scrname; + } return 0; } @@ -99,6 +141,18 @@ int load_config(const char *fname) opt.music = bool_value(value); } else if(strcmp(line, "screen") == 0) { opt.start_scr = strdup(value); + } else if(strcmp(line, "mouse") == 0) { + opt.mouse = bool_value(value); + } else if(strcmp(line, "sball") == 0) { + opt.sball = bool_value(value); + } else if(strcmp(line, "vsync") == 0) { + opt.vsync = bool_value(value); + } else if(strcmp(line, "debug") == 0) { + opt.dbginfo = bool_value(value); +#ifndef MSDOS + } else if(strcmp(line, "fullscreen") == 0) { + opt.fullscreen = bool_value(value); +#endif } else { fprintf(stderr, "%s:%d invalid option: %s\n", fname, nline, line); return -1;