ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/main_sdl.cpp
Revision: 1.4
Committed: 2001-01-16T14:12:54Z (23 years, 2 months ago) by cebix
Branch: MAIN
Changes since 1.3: +3 -0 lines
Log Message:
- updated autogen.sh script
- added "--speed" option to 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.3 printf("\nUsage: %s [options] FILE [song_number]]\n", prg_name);
39 cebix 1.1 exit(0);
40     }
41    
42     static void quit(void)
43     {
44     ExitAll();
45     SDL_Quit();
46     }
47    
48     int main(int argc, char **argv)
49     {
50     // Print banner
51     printf(
52     PACKAGE " Version " VERSION "\n\n"
53     "Copyright (C) 1996-2000 Christian Bauer\n"
54     "E-mail: Christian.Bauer@uni-mainz.de\n"
55     "http://www.uni-mainz.de/~bauec002/\n\n"
56     "This is free software with ABSOLUTELY NO WARRANTY.\n"
57     "You are welcome to redistribute it under certain conditions.\n"
58     "For details, see the file COPYING.\n\n"
59     );
60    
61     // Parse arguments
62     if (argc < 2)
63     usage(argv[0]);
64 cebix 1.3 char *file_name = argv[argc - 1];
65 cebix 1.1 int song = 0;
66 cebix 1.3 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 cebix 1.1
79     // Initialize everything
80     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
81     fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
82     exit(1);
83     }
84     atexit(quit);
85 cebix 1.3 InitAll(argc, argv);
86 cebix 1.1
87     // Load given PSID file
88 cebix 1.3 if (!LoadPSIDFile(file_name)) {
89     fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name);
90 cebix 1.1 exit(1);
91     }
92    
93     // Select song
94     if (song > 0) {
95     if (song > number_of_songs)
96     song = number_of_songs;
97     SelectSong(song - 1);
98     }
99    
100     // Print file information
101     printf("Module Name: %s\n", module_name);
102     printf("Author : %s\n", author_name);
103     printf("Copyright : %s\n\n", copyright_info);
104     printf("Playing song %d/%d\n", current_song + 1, number_of_songs);
105    
106     // Start replay and enter main loop
107 cebix 1.4 SIDAdjustSpeed(PrefsFindInt32("speed"));
108 cebix 1.1 SDL_PauseAudio(false);
109     while (true) {
110     SDL_Event e;
111     if (SDL_WaitEvent(&e)) {
112     if (e.type == SDL_QUIT)
113     break;
114     }
115     }
116    
117     return 0;
118     }