25 |
|
#include <stdlib.h> |
26 |
|
|
27 |
|
#include "main.h" |
28 |
+ |
#include "prefs.h" |
29 |
+ |
#include "sid.h" |
30 |
|
|
31 |
|
|
32 |
|
/* |
35 |
|
|
36 |
|
static void usage(const char *prg_name) |
37 |
|
{ |
38 |
< |
printf("\nUsage: %s [file [song]]\n", prg_name); |
38 |
> |
printf("\nUsage: %s [options] FILE [song_number]]\n", prg_name); |
39 |
|
exit(0); |
40 |
|
} |
41 |
|
|
61 |
|
// Parse arguments |
62 |
|
if (argc < 2) |
63 |
|
usage(argv[0]); |
64 |
< |
char *file_name = argv[1]; |
64 |
> |
char *file_name = argv[argc - 1]; |
65 |
|
int song = 0; |
66 |
< |
if (argc == 3) |
67 |
< |
song = atoi(argv[2]); |
66 |
> |
if (argc >= 3) { |
67 |
> |
bool only_numbers = true; |
68 |
> |
for (int i=0; i<strlen(file_name); i++) |
69 |
> |
if (!isdigit(file_name[i])) { |
70 |
> |
only_numbers = false; |
71 |
> |
break; |
72 |
> |
} |
73 |
> |
if (only_numbers) { |
74 |
> |
song = atoi(file_name); |
75 |
> |
file_name = argv[argc - 2]; |
76 |
> |
} |
77 |
> |
} |
78 |
|
|
79 |
|
// Initialize everything |
80 |
|
if (SDL_Init(SDL_INIT_AUDIO) < 0) { |
82 |
|
exit(1); |
83 |
|
} |
84 |
|
atexit(quit); |
85 |
< |
InitAll(); |
85 |
> |
InitAll(argc, argv); |
86 |
|
|
87 |
|
// Load given PSID file |
88 |
< |
if (!LoadPSIDFile(argv[1])) { |
89 |
< |
fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", argv[1]); |
88 |
> |
if (!LoadPSIDFile(file_name)) { |
89 |
> |
fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name); |
90 |
|
exit(1); |
91 |
|
} |
92 |
|
|
104 |
|
printf("Playing song %d/%d\n", current_song + 1, number_of_songs); |
105 |
|
|
106 |
|
// Start replay and enter main loop |
107 |
+ |
SIDAdjustSpeed(PrefsFindInt32("speed")); |
108 |
|
SDL_PauseAudio(false); |
109 |
|
while (true) { |
110 |
|
SDL_Event e; |