2021-03-14 13:50:30 +01:00
|
|
|
#include "specific/shell.h"
|
|
|
|
|
2021-03-21 21:17:46 +01:00
|
|
|
#include "args.h"
|
2021-03-09 18:53:27 +01:00
|
|
|
#include "game/demo.h"
|
|
|
|
#include "game/game.h"
|
2021-03-10 23:47:59 +01:00
|
|
|
#include "game/gameflow.h"
|
2021-03-09 18:53:27 +01:00
|
|
|
#include "game/inv.h"
|
|
|
|
#include "game/savegame.h"
|
2021-03-18 16:32:59 +01:00
|
|
|
#include "game/settings.h"
|
2021-03-09 18:53:27 +01:00
|
|
|
#include "game/setup.h"
|
2021-03-08 00:41:27 +01:00
|
|
|
#include "game/text.h"
|
2021-03-21 21:17:46 +01:00
|
|
|
#include "global/const.h"
|
|
|
|
#include "global/types.h"
|
|
|
|
#include "global/vars.h"
|
2021-10-31 18:29:50 +01:00
|
|
|
#include "log.h"
|
2021-03-08 00:41:27 +01:00
|
|
|
#include "specific/display.h"
|
|
|
|
#include "specific/frontend.h"
|
2021-03-27 23:18:27 +01:00
|
|
|
#include "specific/hwr.h"
|
2021-03-09 18:53:27 +01:00
|
|
|
#include "specific/init.h"
|
2021-03-23 16:49:12 +01:00
|
|
|
#include "specific/input.h"
|
2021-03-09 18:53:27 +01:00
|
|
|
#include "specific/output.h"
|
2021-03-23 16:35:52 +01:00
|
|
|
#include "specific/smain.h"
|
2021-03-09 18:53:27 +01:00
|
|
|
#include "specific/sndpc.h"
|
2021-03-14 13:50:30 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2021-03-08 00:41:27 +01:00
|
|
|
#include <stdio.h>
|
2021-03-11 14:47:35 +01:00
|
|
|
#include <stdlib.h>
|
2021-03-21 18:25:24 +01:00
|
|
|
#include <string.h>
|
2021-03-08 00:41:27 +01:00
|
|
|
|
2021-03-10 21:39:29 +01:00
|
|
|
void GameMain()
|
|
|
|
{
|
2021-11-03 22:08:41 +01:00
|
|
|
SoundIsActive = true;
|
2021-03-10 21:39:29 +01:00
|
|
|
|
2021-10-16 15:54:59 +02:00
|
|
|
const char *gameflow_path = T1MGameflowPath;
|
2021-03-21 18:25:24 +01:00
|
|
|
|
|
|
|
char **args;
|
|
|
|
int arg_count;
|
|
|
|
get_command_line(&args, &arg_count);
|
|
|
|
for (int i = 0; i < arg_count; i++) {
|
|
|
|
if (!strcmp(args[i], "-gold")) {
|
2021-10-16 15:54:59 +02:00
|
|
|
gameflow_path = T1MGameflowGoldPath;
|
2021-03-21 18:25:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < arg_count; i++) {
|
|
|
|
free(args[i]);
|
|
|
|
}
|
|
|
|
free(args);
|
|
|
|
|
2021-03-10 21:39:29 +01:00
|
|
|
S_InitialiseSystem();
|
|
|
|
|
2021-03-21 18:25:24 +01:00
|
|
|
if (!GF_LoadScriptFile(gameflow_path)) {
|
2021-03-10 23:47:59 +01:00
|
|
|
ShowFatalError("MAIN: unable to load script file");
|
|
|
|
return;
|
2021-03-10 21:39:29 +01:00
|
|
|
}
|
|
|
|
|
2021-03-12 17:02:41 +01:00
|
|
|
InitialiseStartInfo();
|
2021-03-10 21:39:29 +01:00
|
|
|
S_FrontEndCheck();
|
|
|
|
S_ReadUserSettings();
|
2021-03-08 00:41:27 +01:00
|
|
|
|
2021-10-31 19:52:21 +01:00
|
|
|
TempVideoAdjust(2);
|
2021-03-08 00:41:27 +01:00
|
|
|
S_DisplayPicture("data\\eidospc");
|
2021-03-28 01:39:01 +01:00
|
|
|
S_InitialisePolyList();
|
|
|
|
S_CopyBufferToScreen();
|
|
|
|
S_OutputPolyList();
|
|
|
|
S_DumpScreen();
|
2021-03-27 18:29:02 +01:00
|
|
|
S_Wait(TICKS_PER_SECOND);
|
2021-03-08 00:41:27 +01:00
|
|
|
|
2021-10-13 22:10:20 +02:00
|
|
|
HWR_PrepareFMV();
|
2021-03-17 00:24:00 +01:00
|
|
|
WinPlayFMV(FMV_CORE, 1);
|
|
|
|
WinPlayFMV(FMV_ESCAPE, 1);
|
|
|
|
WinPlayFMV(FMV_INTRO, 1);
|
2021-10-13 22:10:20 +02:00
|
|
|
HWR_FMVDone();
|
2021-03-08 00:41:27 +01:00
|
|
|
|
|
|
|
int32_t gf_option = GF_EXIT_TO_TITLE;
|
|
|
|
|
|
|
|
int8_t loop_continue = 1;
|
|
|
|
while (loop_continue) {
|
|
|
|
TempVideoRemove();
|
|
|
|
int32_t gf_direction = gf_option & ~((1 << 6) - 1);
|
|
|
|
int32_t gf_param = gf_option & ((1 << 6) - 1);
|
2021-03-25 18:18:18 +01:00
|
|
|
LOG_INFO("%d %d", gf_direction, gf_param);
|
2021-03-08 00:41:27 +01:00
|
|
|
|
|
|
|
switch (gf_direction) {
|
2021-03-11 23:21:18 +01:00
|
|
|
case GF_START_GAME:
|
2021-03-12 17:02:41 +01:00
|
|
|
gf_option = GF_InterpretSequence(gf_param, GFL_NORMAL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GF_START_SAVED_GAME:
|
2021-03-13 17:51:46 +01:00
|
|
|
S_LoadGame(&SaveGame, gf_param);
|
|
|
|
gf_option = GF_InterpretSequence(SaveGame.current_level, GFL_SAVED);
|
2021-03-08 00:41:27 +01:00
|
|
|
break;
|
|
|
|
|
2021-03-11 23:21:18 +01:00
|
|
|
case GF_START_CINE:
|
2021-03-14 15:38:11 +01:00
|
|
|
gf_option = GF_InterpretSequence(gf_param, GFL_CUTSCENE);
|
2021-03-08 00:41:27 +01:00
|
|
|
break;
|
|
|
|
|
2021-03-11 23:21:18 +01:00
|
|
|
case GF_START_DEMO:
|
2021-03-08 00:41:27 +01:00
|
|
|
gf_option = StartDemo();
|
|
|
|
break;
|
|
|
|
|
2021-03-11 23:21:18 +01:00
|
|
|
case GF_LEVEL_COMPLETE:
|
2021-03-08 00:41:27 +01:00
|
|
|
gf_option = LevelCompleteSequence(gf_param);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GF_EXIT_TO_TITLE:
|
|
|
|
T_InitPrint();
|
2021-10-31 19:52:21 +01:00
|
|
|
TempVideoAdjust(2);
|
2021-03-08 00:41:27 +01:00
|
|
|
S_DisplayPicture("data\\titleh");
|
|
|
|
NoInputCount = 0;
|
2021-03-12 17:02:41 +01:00
|
|
|
if (!InitialiseLevel(GF.title_level_num, GFL_TITLE)) {
|
|
|
|
gf_option = GF_EXIT_GAME;
|
|
|
|
break;
|
2021-03-08 00:41:27 +01:00
|
|
|
}
|
|
|
|
|
2021-03-29 16:54:12 +02:00
|
|
|
gf_option = Display_Inventory(INV_TITLE_MODE);
|
2021-03-08 00:41:27 +01:00
|
|
|
|
|
|
|
S_FadeToBlack();
|
2021-03-25 16:36:42 +01:00
|
|
|
S_MusicStop();
|
2021-03-08 00:41:27 +01:00
|
|
|
break;
|
|
|
|
|
2021-03-11 23:21:18 +01:00
|
|
|
case GF_EXIT_GAME:
|
2021-03-08 00:41:27 +01:00
|
|
|
loop_continue = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-11-03 23:43:02 +01:00
|
|
|
S_ExitSystemFmt(
|
|
|
|
"MAIN: Unknown request %x %d", gf_direction, gf_param);
|
2021-03-10 18:54:01 +01:00
|
|
|
return;
|
2021-03-08 00:41:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-10 21:39:29 +01:00
|
|
|
S_WriteUserSettings();
|
2021-03-08 00:41:27 +01:00
|
|
|
}
|