comparison 3x666.c @ 37:38b7583302c3

Add commandline parsing and help.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 19 Mar 2013 02:55:25 +0200
parents dca4b72dc2e0
children da3a7c376a84
comparison
equal deleted inserted replaced
36:f5eca2e829ca 37:38b7583302c3
52 52
53 53
54 54
55 static void dmPrintVA(int level, const char *fmt, va_list ap) 55 static void dmPrintVA(int level, const char *fmt, va_list ap)
56 { 56 {
57 (void) level;
57 #ifdef __WIN32 58 #ifdef __WIN32
58 (void) fmt; 59 (void) fmt;
59 (void) ap; 60 (void) ap;
60 #else 61 #else
61 vfprintf(stderr, fmt, ap); 62 vfprintf(stderr, fmt, ap);
932 int main(int argc, char *argv[]) 933 int main(int argc, char *argv[])
933 { 934 {
934 BOOL initSDL = FALSE; 935 BOOL initSDL = FALSE;
935 const int U = SET_VID_BUFW / 40; 936 const int U = SET_VID_BUFW / 40;
936 const Uint16 *dez = dezign; 937 const Uint16 *dez = dezign;
937 int flagz = 0, flixtim = 0; 938 int flagz = 0, flixtim = 0, argn;
938 char *phiword = NULL, *dizainword = NULL; 939 char *phiword = NULL, *dizainword = NULL;
939 940
940 memset(&engine, 0, sizeof(engine)); 941 memset(&engine, 0, sizeof(engine));
941 942
942 dmPrint(0, 943 dmPrint(0,
943 SET_PROG_NAME " by Ocsa (PWP) (c) 1998\n" 944 SET_PROG_NAME " by Ocsa (PWP) (c) 1998\n"
944 "libSDL port by ccr/TNSP^PWP (c) 2013\n"); 945 "libSDL port by ccr/TNSP^PWP (c) 2013\n");
945 946
946 // Parse commandline options 947 // Parse commandline options
947 // engine.optVFlags |= SDL_FULLSCREEN; 948 for (argn = 1; argn < argc; argn++)
949 {
950 char *arg = argv[argn];
951 if (arg[0] == '-')
952 switch (arg[1])
953 {
954 case 'f':
955 engine.optVFlags |= SDL_FULLSCREEN;
956 break;
957
958 case '?':
959 case 'h':
960 dmPrint(0,
961 "Usage: %s [options]\n"
962 "\n"
963 " -f Start in full screen\n"
964 " -h/-? Show this help\n"
965 "\n", argv[0]);
966 goto error_exit;
967
968 default:
969 dmError("Invalid option '%s'.\n", arg);
970 goto error_exit;
971 }
972 else
973 {
974 dmError("Invalid argument '%s'.\n", arg);
975 goto error_exit;
976 }
977 }
948 978
949 979
950 // Initialize SDL components 980 // Initialize SDL components
951 dmPrint(0, "Engine initializing ..\n"); 981 dmPrint(0, "Engine initializing ..\n");
952 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0) 982 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0)