ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/main_sdl.cpp
(Generate patch)

Comparing SIDPlayer/src/main_sdl.cpp (file contents):
Revision 1.4 by cebix, 2001-01-16T14:12:54Z vs.
Revision 1.8 by cebix, 2001-04-01T12:13:49Z

# Line 1 | Line 1
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
# Line 35 | Line 35
35  
36   static void usage(const char *prg_name)
37   {
38 <        printf("\nUsage: %s [options] FILE [song_number]]\n", prg_name);
38 >        printf("Usage: %s [OPTION...] FILE [song_number]\n", prg_name);
39 >        PrefsPrintUsage();
40          exit(0);
41   }
42  
# Line 50 | Line 51 | int main(int argc, char **argv)
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"
# Line 58 | Line 59 | int main(int argc, char **argv)
59                  "For details, see the file COPYING.\n\n"
60          );
61  
61        // Parse arguments
62        if (argc < 2)
63                usage(argv[0]);
64        char *file_name = argv[argc - 1];
65        int song = 0;
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
62          // Initialize everything
63          if (SDL_Init(SDL_INIT_AUDIO) < 0) {
64                  fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
# Line 83 | Line 66 | int main(int argc, char **argv)
66          }
67          atexit(quit);
68          InitAll(argc, argv);
69 +        int32 selected_speed = PrefsFindInt32("speed");
70 +
71 +        // Parse non-option arguments
72 +        const char *file_name = NULL;
73 +        int song = 0;
74 +        for (int i=1; i<argc; i++) {
75 +                if (strcmp(argv[i], "--help") == 0)
76 +                        usage(argv[0]);
77 +                else if (argv[i][0] == '-') {
78 +                        fprintf(stderr, "Unrecognized option '%s'\n", argv[i]);
79 +                        usage(argv[0]);
80 +                } else {
81 +                        if (file_name == NULL)
82 +                                file_name = argv[i];  // First non-option argument is file name
83 +                        else
84 +                                song = atoi(argv[i]); // Second non-option argument is song number
85 +                }
86 +        }
87 +        if (file_name == NULL)
88 +                usage(argv[0]);
89  
90          // Load given PSID file
91          if (!LoadPSIDFile(file_name)) {
# Line 104 | Line 107 | int main(int argc, char **argv)
107          printf("Playing song %d/%d\n", current_song + 1, number_of_songs);
108  
109          // Start replay and enter main loop
110 <        SIDAdjustSpeed(PrefsFindInt32("speed"));
110 >        SIDAdjustSpeed(selected_speed); // SelectSong resets this to 100%
111          SDL_PauseAudio(false);
112          while (true) {
113                  SDL_Event e;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines