ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/main_sdl.cpp
Revision: 1.2
Committed: 2000-10-10T21:47:47Z (24 years, 1 month ago) by cebix
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
updated docs

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 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[1];
63 int song = 0;
64 if (argc == 3)
65 song = atoi(argv[2]);
66
67 // Initialize everything
68 if (SDL_Init(SDL_INIT_AUDIO) < 0) {
69 fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
70 exit(1);
71 }
72 atexit(quit);
73 InitAll();
74
75 // Load given PSID file
76 if (!LoadPSIDFile(argv[1])) {
77 fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", argv[1]);
78 exit(1);
79 }
80
81 // Select song
82 if (song > 0) {
83 if (song > number_of_songs)
84 song = number_of_songs;
85 SelectSong(song - 1);
86 }
87
88 // Print file information
89 printf("Module Name: %s\n", module_name);
90 printf("Author : %s\n", author_name);
91 printf("Copyright : %s\n\n", copyright_info);
92 printf("Playing song %d/%d\n", current_song + 1, number_of_songs);
93
94 // Start replay and enter main loop
95 SDL_PauseAudio(false);
96 while (true) {
97 SDL_Event e;
98 if (SDL_WaitEvent(&e)) {
99 if (e.type == SDL_QUIT)
100 break;
101 }
102 }
103
104 return 0;
105 }