33 |
|
|
34 |
|
static void usage(const char *prg_name) |
35 |
|
{ |
36 |
< |
printf("\nUsage: %s FILE [song_number]]\n", prg_name); |
36 |
> |
printf("\nUsage: %s [options] FILE [song_number]]\n", prg_name); |
37 |
|
exit(0); |
38 |
|
} |
39 |
|
|
59 |
|
// Parse arguments |
60 |
|
if (argc < 2) |
61 |
|
usage(argv[0]); |
62 |
< |
char *file_name = argv[1]; |
62 |
> |
char *file_name = argv[argc - 1]; |
63 |
|
int song = 0; |
64 |
< |
if (argc == 3) |
65 |
< |
song = atoi(argv[2]); |
64 |
> |
if (argc >= 3) { |
65 |
> |
bool only_numbers = true; |
66 |
> |
for (int i=0; i<strlen(file_name); i++) |
67 |
> |
if (!isdigit(file_name[i])) { |
68 |
> |
only_numbers = false; |
69 |
> |
break; |
70 |
> |
} |
71 |
> |
if (only_numbers) { |
72 |
> |
song = atoi(file_name); |
73 |
> |
file_name = argv[argc - 2]; |
74 |
> |
} |
75 |
> |
} |
76 |
|
|
77 |
|
// Initialize everything |
78 |
|
if (SDL_Init(SDL_INIT_AUDIO) < 0) { |
80 |
|
exit(1); |
81 |
|
} |
82 |
|
atexit(quit); |
83 |
< |
InitAll(); |
83 |
> |
InitAll(argc, argv); |
84 |
|
|
85 |
|
// Load given PSID file |
86 |
< |
if (!LoadPSIDFile(argv[1])) { |
87 |
< |
fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", argv[1]); |
86 |
> |
if (!LoadPSIDFile(file_name)) { |
87 |
> |
fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name); |
88 |
|
exit(1); |
89 |
|
} |
90 |
|
|