2
* OpenTyrian: A modern cross-platform port of Tyrian
3
* Copyright (C) 2007-2009 The OpenTyrian Development Team
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
#include "hg_revision.h"
47
#include "video_scale.h"
56
const char *opentyrian_str = "OpenTyrian",
57
*opentyrian_version = HG_REV;
59
/* zero-terminated strncpy */
60
char *strnztcpy( char *to, const char *from, size_t count )
63
return strncpy(to, from, count);
66
void opentyrian_menu( void )
79
static const char *menu_items[] =
86
"Return to Main Menu",
88
bool menu_items_disabled[] =
91
!can_init_any_scaler(false) || !can_init_any_scaler(true),
98
assert(COUNTOF(menu_items) == MenuOptions_MAX);
99
assert(COUNTOF(menu_items_disabled) == MenuOptions_MAX);
102
JE_loadPic(VGAScreen, 13, false);
104
draw_font_hv(VGAScreen, VGAScreen->w / 2, 5, opentyrian_str, large_font, centered, 15, -3);
106
memcpy(VGAScreen2->pixels, VGAScreen->pixels, VGAScreen2->pitch * VGAScreen2->h);
110
play_song(36); // A Field for Mag
114
uint temp_scaler = scaler;
116
bool fade_in = true, quit = false;
119
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
121
for (MenuOptions i = 0; i < MenuOptions_MAX; i++)
123
const char *text = menu_items[i];
126
if (i == MENU_SCALER)
128
snprintf(buffer, sizeof(buffer), "Scaler: %s", scalers[temp_scaler].name);
132
int y = i != MENU_RETURN ? i * 16 + 32 : 118;
133
draw_font_hv(VGAScreen, VGAScreen->w / 2, y, text, normal_font, centered, 15, menu_items_disabled[i] ? -8 : i != sel ? -4 : -2);
141
fade_palette(colors, 20, 0, 255);
142
wait_noinput(true, false, false);
146
JE_textMenuWait(&tempW, false);
156
sel = MenuOptions_MAX - 1;
158
while (menu_items_disabled[sel]);
160
JE_playSampleNum(S_CURSOR);
165
if (++sel >= MenuOptions_MAX)
168
while (menu_items_disabled[sel]);
170
JE_playSampleNum(S_CURSOR);
174
if (sel == MENU_SCALER)
178
if (temp_scaler == 0)
179
temp_scaler = scalers_count;
182
while (!can_init_scaler(temp_scaler, fullscreen_enabled));
184
JE_playSampleNum(S_CURSOR);
188
if (sel == MENU_SCALER)
193
if (temp_scaler == scalers_count)
196
while (!can_init_scaler(temp_scaler, fullscreen_enabled));
198
JE_playSampleNum(S_CURSOR);
206
JE_playSampleNum(S_SELECT);
208
scroller_sine(about_text);
210
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
215
case MENU_FULLSCREEN:
216
JE_playSampleNum(S_SELECT);
218
if (!init_scaler(scaler, !fullscreen_enabled) && // try new fullscreen state
219
!init_any_scaler(!fullscreen_enabled) && // try any scaler in new fullscreen state
220
!init_scaler(scaler, fullscreen_enabled)) // revert on fail
224
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
228
JE_playSampleNum(S_SELECT);
230
if (scaler != temp_scaler)
232
if (!init_scaler(temp_scaler, fullscreen_enabled) && // try new scaler
233
!init_scaler(temp_scaler, !fullscreen_enabled) && // try other fullscreen state
234
!init_scaler(scaler, fullscreen_enabled)) // revert on fail
238
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
243
JE_playSampleNum(S_SELECT);
248
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
255
JE_playSampleNum(S_SPRING);
258
case MenuOptions_MAX:
266
JE_playSampleNum(S_SPRING);
276
int main( int argc, char *argv[] )
278
mt_srand(time(NULL));
280
printf("\nWelcome to... >> %s %s <<\n\n", opentyrian_str, opentyrian_version);
282
printf("Copyright (C) 2007-2013 The OpenTyrian Development Team\n\n");
284
printf("This program comes with ABSOLUTELY NO WARRANTY.\n");
285
printf("This is free software, and you are welcome to redistribute it\n");
286
printf("under certain conditions. See the file GPL.txt for details.\n\n");
290
printf("Failed to initialize SDL: %s\n", SDL_GetError());
294
JE_loadConfiguration();
296
xmas = xmas_time(); // arg handler may override
298
JE_paramCheck(argc, argv);
300
JE_scanForEpisodes();
305
printf("assuming mouse detected\n"); // SDL can't tell us if there isn't one
307
if (xmas && (!dir_file_exists(data_dir(), "tyrianc.shp") || !dir_file_exists(data_dir(), "voicesc.snd")))
311
fprintf(stderr, "warning: Christmas is missing.\n");
315
JE_loadMainShapeTables(xmas ? "tyrianc.shp" : "tyrian.shp");
317
if (xmas && !xmas_prompt())
321
free_main_shape_tables();
322
JE_loadMainShapeTables("tyrian.shp");
326
/* Default Options */
327
youAreCheating = false;
329
loadDestruct = false;
333
printf("initializing SDL audio...\n");
339
JE_loadSndFile("tyrian.snd", xmas ? "voicesc.snd" : "voices.snd");
343
printf("audio disabled\n");
347
printf("demo recording enabled (input limited to keyboard)\n");
349
JE_loadExtraShapes(); /*Editship*/
352
/*debuginfo("Help text complete");*/
359
network_tyrian_halt(3, false);
362
fprintf(stderr, "OpenTyrian was compiled without networking support.");
377
if (JE_titleScreen(true))
378
break; // user quit from title screen
383
loadDestruct = false;