1 /*
2 This file is part of "Avanor, the Land of Mystery" roguelike game
3 Home page: http://www.avanor.com/
4 Copyright (C) 2000-2003 Vadim Gaidukevich
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 
21 #include <stdlib.h>
22 #include <ctype.h>
23 #include "global.h"
24 #include "game.h"
25 #include "xdebug.h"
26 #include "manual.h"
27 #include "hiscore.h"
28 
29 char * logo_text[] =
30 {
31 	MSG_CYAN
32 	"  .oooooo  oo      oo    .oooooo  oo     oo    .oooo.    ooooooo. ",
33 	" dP'   88  88      88   dP'   88  88b    88   dP'  `Yb   88    `Yb",
34 	"d8     88  88      88  d8     88  88Yb   88  88      88  88     88",
35 	"88     88  Y8      8Y  88     88  88 Yb  88  88      88  88     88",
36 	"88ooooo88   Yb    dY   88ooooo88  88  Yb 88  88      88  88oooodP ",
37 	"88     88    Yb  dY    88     88  88   Yb88  88      88  88   Yb  ",
38 	"88     88     YbdY     88     88  88    Y88  `8b    d8'  88    Yb ",
39 	"88     88      YY      88     88  88     88   `Y8bd8P    88     Yb",
40 	MSG_WHITE,
41 	"                T h e  L a n d  o f  M y s t e r y",
42 	"",
43 	MSG_GREEN
44 	"                      version " GAME_VERSION "\n",
45 	MSG_YELLOW,
46 	"              (c) 2000 - 2003 by Vadim Gaidukevich",
47 	"",
48 	MSG_YELLOW
49 	"                      http://www.avanor.com",
50 	"",
51 	"",
52 	" "
53 	MSG_LIGHTGRAY "[" MSG_WHITE "R" MSG_LIGHTGRAY "] - Restore game "
54 	MSG_LIGHTGRAY "[" MSG_WHITE "N" MSG_LIGHTGRAY "] - New game "
55 	MSG_LIGHTGRAY "[" MSG_WHITE "?" MSG_LIGHTGRAY "] - read Manual "
56 	MSG_LIGHTGRAY "[" MSG_WHITE "Esc" MSG_LIGHTGRAY "] - Exit",
57 };
58 
ShowLogo()59 void ShowLogo()
60 {
61 	int logo_height = sizeof(logo_text) / sizeof(char *), logo_width = 0, i;
62 
63 	for (i = 0; i < logo_height; i++)
64 		if (x_strlen(logo_text[i]) > logo_width)
65 			logo_width = x_strlen(logo_text[i]);
66 
67 	int shift_x = (size_x - logo_width) / 2;
68 	int shift_y = (size_y - logo_height) / 2;
69 
70 	vClrScr();
71 	for (i = 0; i < logo_height; i++)
72 	{
73 		vGotoXY(shift_x, i + shift_y);
74 		vPutS(logo_text[i]);
75 	}
76 
77 	vRefresh();
78 }
79 
80 XGame Game;
81 
main(int argc,char * argv[])82 int main(int argc, char * argv[])
83 {
84 #ifdef NOT_SET_RND_SEED
85 	vRandSeed(0);
86 #else
87 	vRandSeed((unsigned long)time(NULL));
88 #endif
89 	vInit();
90 	vClrScr();
91 	vHideCursor();
92 
93 	ShowLogo();
94 
95 	if (argc > 1 && strcmp(argv[1], "-test") == 0)
96 	{
97 		if (argc > 2) vRandSeed(atoi(argv[2]));
98 		Game.Create('T');
99 		Game.RunWithoutHero();
100 	} else
101 	if (argc > 1 && strcmp(argv[1], "-demo") == 0)
102 	{
103 		Game.Create('D');
104 		Game.RunDemo();
105 	} else
106 	{
107 		if (argc > 1 && strcmp(argv[1], "-god") == 0)
108 		{
109 			Game.isGodMode = true;
110 		} else
111 			Game.isGodMode = false;
112 
113   		char ch;
114 		while (true)
115 		{
116 			ch = toupper(vGetch());
117 			if (ch == '?')
118 			{
119 				XManual man;
120 				man.Run();
121 				ShowLogo();
122 			}
123 			if (ch == KEY_ESC || ch == 'Z')
124 			{
125 				vFinit();
126 				return 0;
127 			}
128 			if (ch == 'R' || ch == 'N') break;
129 		}
130 		Game.Create(ch);
131 		Game.Run();
132 	}
133 	vFinit();
134 	return 0;
135 }
136