ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/main_sdl.cpp
Revision: 1.5
Committed: 2001-01-16T16:53:26Z (23 years, 9 months ago) by cebix
Branch: MAIN
Changes since 1.4: +14 -12 lines
Log Message:
added options help screen for command line version

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * main_sdl.cpp - SIDPlayer SDL main program
3     *
4     * SIDPlayer (C) Copyright 1996-2000 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
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #include "sys.h"
22    
23     #include <SDL.h>
24     #include <stdio.h>
25     #include <stdlib.h>
26    
27     #include "main.h"
28 cebix 1.4 #include "prefs.h"
29     #include "sid.h"
30 cebix 1.1
31    
32     /*
33     * Main program
34     */
35    
36     static void usage(const char *prg_name)
37     {
38 cebix 1.5 printf("Usage: %s [OPTION...] FILE [song_number]]\n", prg_name);
39     PrefsPrintUsage();
40 cebix 1.1 exit(0);
41     }
42    
43     static void quit(void)
44     {
45     ExitAll();
46     SDL_Quit();
47     }
48    
49     int main(int argc, char **argv)
50     {
51     // Print banner
52     printf(
53     PACKAGE " Version " VERSION "\n\n"
54 cebix 1.5 "Copyright (C) 1996-2001 Christian Bauer\n"
55 cebix 1.1 "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"
58     "You are welcome to redistribute it under certain conditions.\n"
59     "For details, see the file COPYING.\n\n"
60     );
61    
62 cebix 1.5 // 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(argc, argv);
69     int32 selected_speed = PrefsFindInt32("speed");
70    
71     // Parse non-option arguments
72 cebix 1.1 if (argc < 2)
73     usage(argv[0]);
74 cebix 1.3 char *file_name = argv[argc - 1];
75 cebix 1.1 int song = 0;
76 cebix 1.3 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 cebix 1.1
89     // Load given PSID file
90 cebix 1.3 if (!LoadPSIDFile(file_name)) {
91     fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name);
92 cebix 1.1 exit(1);
93     }
94    
95     // Select song
96     if (song > 0) {
97     if (song > number_of_songs)
98     song = number_of_songs;
99     SelectSong(song - 1);
100     }
101    
102     // Print file information
103     printf("Module Name: %s\n", module_name);
104     printf("Author : %s\n", author_name);
105     printf("Copyright : %s\n\n", copyright_info);
106     printf("Playing song %d/%d\n", current_song + 1, number_of_songs);
107    
108     // Start replay and enter main loop
109 cebix 1.5 SIDAdjustSpeed(selected_speed); // SelectSong resets this to 100%
110 cebix 1.1 SDL_PauseAudio(false);
111     while (true) {
112     SDL_Event e;
113     if (SDL_WaitEvent(&e)) {
114     if (e.type == SDL_QUIT)
115     break;
116     }
117     }
118    
119     return 0;
120     }