1 |
|
/* |
2 |
|
* main_sdl.cpp - SIDPlayer SDL main program |
3 |
|
* |
4 |
< |
* SIDPlayer (C) Copyright 1996-2000 Christian Bauer |
4 |
> |
* SIDPlayer (C) Copyright 1996-2001 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
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_number]]\n", prg_name); |
38 |
> |
printf("Usage: %s [OPTION...] FILE [song_number]]\n", prg_name); |
39 |
> |
PrefsPrintUsage(); |
40 |
|
exit(0); |
41 |
|
} |
42 |
|
|
51 |
|
// Print banner |
52 |
|
printf( |
53 |
|
PACKAGE " Version " VERSION "\n\n" |
54 |
< |
"Copyright (C) 1996-2000 Christian Bauer\n" |
54 |
> |
"Copyright (C) 1996-2001 Christian Bauer\n" |
55 |
|
"E-mail: Christian.Bauer@uni-mainz.de\n" |
56 |
|
"http://www.uni-mainz.de/~bauec002/\n\n" |
57 |
|
"This is free software with ABSOLUTELY NO WARRANTY.\n" |
59 |
|
"For details, see the file COPYING.\n\n" |
60 |
|
); |
61 |
|
|
59 |
– |
// Parse arguments |
60 |
– |
if (argc < 2) |
61 |
– |
usage(argv[0]); |
62 |
– |
char *file_name = argv[1]; |
63 |
– |
int song = 0; |
64 |
– |
if (argc == 3) |
65 |
– |
song = atoi(argv[2]); |
66 |
– |
|
62 |
|
// Initialize everything |
63 |
|
if (SDL_Init(SDL_INIT_AUDIO) < 0) { |
64 |
|
fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError()); |
65 |
|
exit(1); |
66 |
|
} |
67 |
|
atexit(quit); |
68 |
< |
InitAll(); |
68 |
> |
InitAll(argc, argv); |
69 |
> |
int32 selected_speed = PrefsFindInt32("speed"); |
70 |
> |
|
71 |
> |
// Parse non-option arguments |
72 |
> |
if (argc < 2) |
73 |
> |
usage(argv[0]); |
74 |
> |
char *file_name = argv[argc - 1]; |
75 |
> |
int song = 0; |
76 |
> |
if (argc >= 3) { |
77 |
> |
bool only_numbers = true; |
78 |
> |
for (int i=0; i<strlen(file_name); i++) |
79 |
> |
if (!isdigit(file_name[i])) { |
80 |
> |
only_numbers = false; |
81 |
> |
break; |
82 |
> |
} |
83 |
> |
if (only_numbers) { |
84 |
> |
song = atoi(file_name); |
85 |
> |
file_name = argv[argc - 2]; |
86 |
> |
} |
87 |
> |
} |
88 |
|
|
89 |
|
// Load given PSID file |
90 |
< |
if (!LoadPSIDFile(argv[1])) { |
91 |
< |
fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", argv[1]); |
90 |
> |
if (!LoadPSIDFile(file_name)) { |
91 |
> |
fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name); |
92 |
|
exit(1); |
93 |
|
} |
94 |
|
|
106 |
|
printf("Playing song %d/%d\n", current_song + 1, number_of_songs); |
107 |
|
|
108 |
|
// Start replay and enter main loop |
109 |
+ |
SIDAdjustSpeed(selected_speed); // SelectSong resets this to 100% |
110 |
|
SDL_PauseAudio(false); |
111 |
|
while (true) { |
112 |
|
SDL_Event e; |