# HG changeset patch # User Matti Hamalainen # Date 1363654525 -7200 # Node ID 38b7583302c3b1265f5bff474f6d60f2ab547f87 # Parent f5eca2e829ca97544f2fcfca27f3baa8bd6b5baa Add commandline parsing and help. diff -r f5eca2e829ca -r 38b7583302c3 3x666.c --- a/3x666.c Tue Mar 19 02:48:31 2013 +0200 +++ b/3x666.c Tue Mar 19 02:55:25 2013 +0200 @@ -54,6 +54,7 @@ static void dmPrintVA(int level, const char *fmt, va_list ap) { + (void) level; #ifdef __WIN32 (void) fmt; (void) ap; @@ -934,7 +935,7 @@ BOOL initSDL = FALSE; const int U = SET_VID_BUFW / 40; const Uint16 *dez = dezign; - int flagz = 0, flixtim = 0; + int flagz = 0, flixtim = 0, argn; char *phiword = NULL, *dizainword = NULL; memset(&engine, 0, sizeof(engine)); @@ -944,7 +945,36 @@ "libSDL port by ccr/TNSP^PWP (c) 2013\n"); // Parse commandline options -// engine.optVFlags |= SDL_FULLSCREEN; + for (argn = 1; argn < argc; argn++) + { + char *arg = argv[argn]; + if (arg[0] == '-') + switch (arg[1]) + { + case 'f': + engine.optVFlags |= SDL_FULLSCREEN; + break; + + case '?': + case 'h': + dmPrint(0, + "Usage: %s [options]\n" + "\n" + " -f Start in full screen\n" + " -h/-? Show this help\n" + "\n", argv[0]); + goto error_exit; + + default: + dmError("Invalid option '%s'.\n", arg); + goto error_exit; + } + else + { + dmError("Invalid argument '%s'.\n", arg); + goto error_exit; + } + } // Initialize SDL components