1 /*
2 Copyright (C) 2004 Parallel Realities
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 
21 #include "main.h"
22 
showHelp()23 void showHelp()
24 {
25 	printf("\n");
26 	printf("Virus Killer (Version %.1f, Release %d)\n", VERSION, RELEASE);
27 	printf("Copyright (C) 2004, 2010 Parallel Realities\n");
28 	printf("Licensed under the GPL\n\n");
29 
30 	printf("The Virus Killer gameplay manual can be found in,\n");
31 	printf("\t%s\n\n", GAMEPLAYMANUAL);
32 
33 	printf("Additional Commands\n");
34 	printf("\t-fullscreen         Start the game in Full Screen mode\n");
35 	printf("\t-mono               Use mono sound output instead of stereo\n");
36 	printf("\t-noaudio            Disables audio\n");
37 	printf("\t-version            Display version number\n");
38 	printf("\t--help              This help\n");
39 	printf("\t--safemode          Build file information from safe directory (%s)\n\n", SAFEDIR);
40 
41 	exit(0);
42 }
43 
showVersion()44 void showVersion()
45 {
46 	printf("\n");
47 	printf("Virus Killer (Version %.1f, Release %d)\n", VERSION, RELEASE);
48 	printf("Copyright (C) 2004, 2010 Parallel Realities\n");
49 	printf("Licensed under the GPL\n\n");
50 	exit(0);
51 }
52 
main(int argc,char * argv[])53 int main(int argc, char *argv[])
54 {
55 	atexit(cleanup);
56 
57 	bool useSafeMode = false;
58 
59 	for (int i = 1 ; i < argc ; i++)
60 	{
61 		if (strcmp(argv[i], "-fullscreen") == 0) engine.fullScreen = true;
62 		else if (strcmp(argv[i], "-noaudio") == 0) engine.useAudio = 0;
63 		else if (strcmp(argv[i], "-mono") == 0) engine.useAudio = 1;
64 		else if (strcmp(argv[i], "-version") == 0) showVersion();
65 		else if (strcmp(argv[i], "--help") == 0) showHelp();
66 		else if (strcmp(argv[i], "-safemode") == 0) useSafeMode = true;
67 	}
68 
69 	initSystem();
70 
71 	if (useSafeMode)
72 	{
73 		strcpy(gameData.directorySearchPath, SAFEDIR);
74 	}
75 
76 	loadResources();
77 
78 	engine.loadDefines();
79 	buildFileList(gameData.directorySearchPath, 0);
80 	gameData.removeEmptyDirectories();
81 	engine.defineList.clear();
82 
83 	int requiredSection = SECTION_TITLE;
84 
85 	while (true)
86 	{
87 		switch (requiredSection)
88 		{
89 			case SECTION_TITLE:
90 				requiredSection = doTitle();
91 				break;
92 			case SECTION_GAME:
93 				requiredSection = doGame();
94 				break;
95 			case SECTION_HIGHSCORE:
96 				requiredSection = addHighScore();
97 				break;
98 		}
99 	}
100 
101 	return 0;
102 }
103