ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/main_sdl.cpp
Revision: 1.3
Committed: 2001-01-04T19:54:13Z (23 years, 3 months ago) by cebix
Branch: MAIN
Changes since 1.2: +17 -7 lines
Log Message:
- split prefs.cpp into prefs.cpp and prefs_items.cpp
- it's now possible to specify prefs items on the command line

File Contents

# Content
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
29
30 /*
31 * Main program
32 */
33
34 static void usage(const char *prg_name)
35 {
36 printf("\nUsage: %s [options] FILE [song_number]]\n", prg_name);
37 exit(0);
38 }
39
40 static void quit(void)
41 {
42 ExitAll();
43 SDL_Quit();
44 }
45
46 int main(int argc, char **argv)
47 {
48 // Print banner
49 printf(
50 PACKAGE " Version " VERSION "\n\n"
51 "Copyright (C) 1996-2000 Christian Bauer\n"
52 "E-mail: Christian.Bauer@uni-mainz.de\n"
53 "http://www.uni-mainz.de/~bauec002/\n\n"
54 "This is free software with ABSOLUTELY NO WARRANTY.\n"
55 "You are welcome to redistribute it under certain conditions.\n"
56 "For details, see the file COPYING.\n\n"
57 );
58
59 // Parse arguments
60 if (argc < 2)
61 usage(argv[0]);
62 char *file_name = argv[argc - 1];
63 int song = 0;
64 if (argc >= 3) {
65 bool only_numbers = true;
66 for (int i=0; i<strlen(file_name); i++)
67 if (!isdigit(file_name[i])) {
68 only_numbers = false;
69 break;
70 }
71 if (only_numbers) {
72 song = atoi(file_name);
73 file_name = argv[argc - 2];
74 }
75 }
76
77 // Initialize everything
78 if (SDL_Init(SDL_INIT_AUDIO) < 0) {
79 fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
80 exit(1);
81 }
82 atexit(quit);
83 InitAll(argc, argv);
84
85 // Load given PSID file
86 if (!LoadPSIDFile(file_name)) {
87 fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name);
88 exit(1);
89 }
90
91 // Select song
92 if (song > 0) {
93 if (song > number_of_songs)
94 song = number_of_songs;
95 SelectSong(song - 1);
96 }
97
98 // Print file information
99 printf("Module Name: %s\n", module_name);
100 printf("Author : %s\n", author_name);
101 printf("Copyright : %s\n\n", copyright_info);
102 printf("Playing song %d/%d\n", current_song + 1, number_of_songs);
103
104 // Start replay and enter main loop
105 SDL_PauseAudio(false);
106 while (true) {
107 SDL_Event e;
108 if (SDL_WaitEvent(&e)) {
109 if (e.type == SDL_QUIT)
110 break;
111 }
112 }
113
114 return 0;
115 }