scummvm/engines/saga2/tromode.cpp

265 lines
6.3 KiB
C++
Raw Permalink Normal View History

2021-05-17 20:47:39 +02:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2021-05-17 20:47:39 +02:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* aint32 with this program; if not, write to the Free Software
*
*
* Based on the original sources
* Faery Tale II -- The Halls of the Dead
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
2021-05-27 14:01:29 +02:00
#include "common/config-manager.h"
2021-06-23 14:41:01 +02:00
#include "saga2/saga2.h"
#include "saga2/annoy.h"
2021-10-17 23:13:36 +03:00
#include "saga2/detection.h"
2021-05-17 20:47:39 +02:00
#include "saga2/fta.h"
#include "saga2/player.h"
#include "saga2/display.h"
#include "saga2/panel.h"
2021-08-22 07:26:24 +09:00
#include "saga2/vpal.h"
2021-05-17 20:47:39 +02:00
namespace Saga2 {
2021-05-31 21:56:02 +02:00
#define VIDEO_EXTENSION ".SMK"
#define INTRO_VID1 "TRIMARK" VIDEO_EXTENSION
#define INTRO_VID2 "INTRO" VIDEO_EXTENSION
2021-10-17 23:13:36 +03:00
#define INTRO_VID_DINO "TESTVID" VIDEO_EXTENSION
2021-05-31 21:56:02 +02:00
#define WIN_VID_1 "END_1" VIDEO_EXTENSION
#define WIN_VID_2 "END_2" VIDEO_EXTENSION
#define WIN_VID_3 "END_3A" VIDEO_EXTENSION
#define WIN_VID_4 "END_3B" VIDEO_EXTENSION
#define LOSE_VID "END_4" VIDEO_EXTENSION
2021-06-13 16:56:52 +02:00
#define ERASE_BETWEEN true
2021-05-17 20:47:39 +02:00
#define VIDEO_X 0
#define VIDEO_Y 0
extern bool allPlayerActorsDead;
2021-06-13 16:56:52 +02:00
int16 OptionsDialog(bool disableSaveResume = false);
2021-09-11 12:13:35 +03:00
void SystemEventLoop();
void freeAllTileBanks();
void resetInputDevices();
2021-05-17 20:47:39 +02:00
void cursorFullHide(bool onOff);
2021-09-11 12:13:35 +03:00
static void doIntro();
2021-05-17 20:47:39 +02:00
static void doWintro(int16 whichOne);
2021-09-11 12:13:35 +03:00
static void doLostro();
2021-05-17 20:47:39 +02:00
2021-09-11 12:13:35 +03:00
static void waitForVideo();
void waitForInput();
2021-05-17 20:47:39 +02:00
2021-09-11 12:13:35 +03:00
static void TroModeSetup();
static void TroModeCleanup();
2021-05-17 20:47:39 +02:00
2021-06-13 16:56:52 +02:00
static bool abortFlag = false;
2021-05-17 20:47:39 +02:00
//DO_OUTRO_IN_CLEANUP
static int whichOutro = -1;
// ------------------------------------------------------------------------
// Play intro video
2021-09-11 12:13:35 +03:00
void setIntroMode() {
2021-05-17 20:47:39 +02:00
blackOut();
if (!abortFlag) {
TroModeSetup();
doIntro();
TroModeCleanup();
}
showLoadMessage();
resetInputDevices();
}
// ------------------------------------------------------------------------
// Play outro video
2021-09-11 12:13:35 +03:00
void setOutroMode() {
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// Winning videos
extern GameWorld *currentWorld; // pointer to the current world
void setWintroMode(int16 whichOne) {
whichOutro = whichOne;
2021-06-13 16:56:52 +02:00
allPlayerActorsDead = true;
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// Losing video
void fadeDown();
void fadeUp();
void dumpGBASE(char *msg);
2021-09-11 12:13:35 +03:00
void setLostroMode() {
2021-07-26 01:13:34 +09:00
abortFlag = false;
2021-06-13 16:56:52 +02:00
allPlayerActorsDead = false;
2021-05-17 20:47:39 +02:00
if (GameMode::newmodeFlag)
GameMode::update();
if (!abortFlag) {
freeAllTileBanks();
TroModeSetup();
if (whichOutro >= 0)
doWintro(whichOutro);
else
doLostro();
whichOutro = -1;
TroModeCleanup();
}
2021-06-13 16:56:52 +02:00
OptionsDialog(true);
2021-05-17 20:47:39 +02:00
reDrawScreen();
}
/* ===================================================================== *
Entry & termination
* ===================================================================== */
2021-09-11 12:13:35 +03:00
void TroModeExternEvent() {
2021-06-13 16:56:52 +02:00
abortFlag = true;
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// Entry code
2021-09-11 12:13:35 +03:00
static void TroModeSetup() {
2021-05-17 20:47:39 +02:00
suspendAudio();
2021-07-17 05:19:47 +09:00
g_vm->_pointer->hide();
2021-08-22 07:26:24 +09:00
g_vm->_pal->quickSavePalette();
2021-05-17 20:47:39 +02:00
blackOut();
displayDisable(PlayingVideo);
pushVidState();
resetInputDevices();
2021-06-13 16:56:52 +02:00
abortFlag = false;
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// Exit
2021-09-11 12:13:35 +03:00
static void TroModeCleanup() {
g_vm->endVideo();
2021-05-17 20:47:39 +02:00
popVidState();
displayEnable(PlayingVideo);
blackOut();
2021-08-22 07:26:24 +09:00
g_vm->_pal->quickRestorePalette();
2021-05-17 20:47:39 +02:00
resumeAudio();
2021-07-17 05:19:47 +09:00
g_vm->_pointer->show();
// g_vm->_pointer->manditoryShow(); // hide mouse pointer
2021-05-17 20:47:39 +02:00
resetInputDevices();
}
/* ===================================================================== *
Wait for Event type routines
* ===================================================================== */
// ------------------------------------------------------------------------
// Wait till a video completes
2021-09-11 12:13:35 +03:00
static void waitForVideo() {
while (g_vm->checkVideo()) {
2021-05-17 20:47:39 +02:00
SystemEventLoop();
if (abortFlag)
return;
2021-05-31 21:56:02 +02:00
g_system->delayMillis(10);
2021-05-17 20:47:39 +02:00
}
}
// ------------------------------------------------------------------------
// Wait till the user hits a key or clicks or screams or whatever
2021-09-11 12:13:35 +03:00
void waitForInput() {
2021-06-13 16:56:52 +02:00
abortFlag = false;
2021-05-17 20:47:39 +02:00
while (!abortFlag) {
SystemEventLoop();
if (abortFlag)
return;
2021-05-31 21:56:02 +02:00
g_system->updateScreen();
g_system->delayMillis(10);
2021-05-17 20:47:39 +02:00
}
}
/* ===================================================================== *
Video playback
* ===================================================================== */
2021-05-31 21:56:02 +02:00
static void playAVideo(const char *fileName, int x, int y) { //, int16 from, int16 to )
g_vm->startVideo(fileName, x, y);
if (!g_vm->checkVideo()) {
g_vm->endVideo();
2021-06-13 16:56:52 +02:00
abortFlag = true;
2021-05-17 20:47:39 +02:00
return;
}
waitForVideo();
}
/* ===================================================================== *
These are the actual video routines
* ===================================================================== */
// ------------------------------------------------------------------------
// intro video(s)
2021-09-11 12:13:35 +03:00
static void doIntro() {
2021-10-17 23:13:36 +03:00
if (g_vm->getGameId() == GID_FTA2) {
playAVideo(INTRO_VID1, 0, 0);
abortFlag = false;
playAVideo(INTRO_VID2, 0, 0);
} else {
playAVideo(INTRO_VID_DINO, 0, 0);
}
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// one of several endings
static void doWintro(int16 whichOne) {
switch (whichOne) {
case 0:
playAVideo(WIN_VID_1, 0, 0);
return;
case 1:
playAVideo(WIN_VID_2, 0, 0);
return;
case 2:
playAVideo(WIN_VID_3, 0, 0);
return;
case 3:
playAVideo(WIN_VID_4, 0, 0);
return;
}
}
// ------------------------------------------------------------------------
// lost
2021-09-11 12:13:35 +03:00
static void doLostro() {
2021-05-17 20:47:39 +02:00
playAVideo(LOSE_VID, 0, 0);
}
} // end of namespace Saga2