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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* 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-06-23 14:41:01 +02:00
|
|
|
#include "saga2/saga2.h"
|
2021-06-02 00:40:57 +02:00
|
|
|
#include "saga2/idtypes.h"
|
2021-05-17 20:47:39 +02:00
|
|
|
#include "saga2/tile.h"
|
2021-06-02 00:40:57 +02:00
|
|
|
#include "saga2/vpal.h"
|
2021-05-17 20:47:39 +02:00
|
|
|
#include "saga2/palette.h"
|
2022-10-28 21:37:57 +02:00
|
|
|
#include "saga2/calendar.h"
|
2021-05-17 20:47:39 +02:00
|
|
|
#include "saga2/modal.h"
|
|
|
|
#include "saga2/display.h"
|
|
|
|
|
|
|
|
namespace Saga2 {
|
|
|
|
|
|
|
|
/* ===================================================================== *
|
|
|
|
Prototypes
|
|
|
|
* ===================================================================== */
|
|
|
|
|
2021-09-11 12:13:35 +03:00
|
|
|
bool isModalMode() {
|
2021-05-17 20:47:39 +02:00
|
|
|
uint16 i;
|
2021-06-13 16:56:52 +02:00
|
|
|
bool modalFlag = false;
|
2021-05-17 20:47:39 +02:00
|
|
|
|
2022-09-25 21:37:09 +02:00
|
|
|
for (i = 0; i < GameMode::_modeStackCtr; i++) {
|
2021-05-17 20:47:39 +02:00
|
|
|
// go through each stacked mode
|
|
|
|
// and if modal mode is one of them,
|
|
|
|
// then set the modal flag
|
2022-09-25 21:37:09 +02:00
|
|
|
if (GameMode::_modeStackPtr[i] == &ModalMode) {
|
2021-06-13 16:56:52 +02:00
|
|
|
modalFlag = true;
|
2021-05-17 20:47:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return modalFlag;
|
|
|
|
}
|
|
|
|
|
2021-09-11 12:13:35 +03:00
|
|
|
void dayNightUpdate() {
|
2021-05-17 20:47:39 +02:00
|
|
|
// do nothing while in modal mode
|
|
|
|
if (isModalMode()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
audioEnvironmentSetDaytime(isDayTime());
|
|
|
|
|
2022-10-28 21:37:57 +02:00
|
|
|
uint32 lightLevel = g_vm->_calendar->lightLevel(MAX_LIGHT);
|
2021-05-17 20:47:39 +02:00
|
|
|
|
|
|
|
// Code to avoid unneccessary fades.
|
2021-08-23 06:16:13 +09:00
|
|
|
if (lightLevel != g_vm->_pal->_prevLightLevel) {
|
|
|
|
g_vm->_pal->_prevLightLevel = lightLevel;
|
2021-05-17 20:47:39 +02:00
|
|
|
|
2021-08-22 07:26:24 +09:00
|
|
|
g_vm->_pal->createPalette(
|
2021-08-23 06:16:13 +09:00
|
|
|
&g_vm->_pal->_newPalette,
|
2021-08-22 07:26:24 +09:00
|
|
|
g_vm->_pal->_midnightPalette,
|
|
|
|
g_vm->_pal->_noonPalette,
|
2021-05-17 20:47:39 +02:00
|
|
|
lightLevel,
|
|
|
|
MAX_LIGHT);
|
|
|
|
|
2021-08-23 16:42:21 +09:00
|
|
|
if (g_vm->_currentMapNum == 0)
|
2021-08-23 06:16:13 +09:00
|
|
|
g_vm->_pal->beginFade(&g_vm->_pal->_newPalette, 100);
|
2021-05-17 20:47:39 +02:00
|
|
|
}
|
|
|
|
|
2021-08-22 07:26:24 +09:00
|
|
|
if (!g_vm->_pal->updatePalette()) {
|
2021-05-17 20:47:39 +02:00
|
|
|
gPalettePtr neededPalette;
|
|
|
|
gPalette currentPalette;
|
|
|
|
|
2021-08-23 16:42:21 +09:00
|
|
|
neededPalette = g_vm->_currentMapNum == 0 ? &g_vm->_pal->_newPalette : g_vm->_pal->_noonPalette;
|
2021-08-22 07:26:24 +09:00
|
|
|
g_vm->_pal->getCurrentPalette(¤tPalette);
|
2021-05-17 20:47:39 +02:00
|
|
|
if (memcmp(¤tPalette, neededPalette, sizeof(gPalette)) != 0)
|
2021-08-22 07:26:24 +09:00
|
|
|
g_vm->_pal->setCurrentPalette(neededPalette);
|
2021-05-17 20:47:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-11 12:13:35 +03:00
|
|
|
void SystemEventLoop();
|
2021-05-17 20:47:39 +02:00
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
// Fade to black
|
|
|
|
|
2021-09-11 12:13:35 +03:00
|
|
|
void clearTileAreaPort();
|
|
|
|
void updateMainDisplay();
|
2021-05-17 20:47:39 +02:00
|
|
|
void updateActiveRegions();
|
|
|
|
void fadeUp();
|
|
|
|
void fadeDown();
|
2021-09-11 12:13:35 +03:00
|
|
|
void displayUpdate();
|
|
|
|
void disableUserControls();
|
|
|
|
void enableUserControls();
|
2021-05-17 20:47:39 +02:00
|
|
|
|
2021-09-11 12:13:35 +03:00
|
|
|
void fadeDown() {
|
2021-08-22 06:12:34 +09:00
|
|
|
if (g_vm->_fadeDepth++ == 0) {
|
2021-08-22 07:26:24 +09:00
|
|
|
g_vm->_pal->beginFade(g_vm->_pal->_darkPalette, 20);
|
|
|
|
while (g_vm->_pal->updatePalette());
|
2021-05-17 20:47:39 +02:00
|
|
|
clearTileAreaPort();
|
|
|
|
blackOut();
|
|
|
|
disablePaletteChanges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
// Fade to many colors
|
|
|
|
|
2021-09-11 12:13:35 +03:00
|
|
|
void fadeUp() {
|
2021-08-22 06:12:34 +09:00
|
|
|
if (--g_vm->_fadeDepth == 0) {
|
2021-05-17 20:47:39 +02:00
|
|
|
enableUserControls();
|
|
|
|
updateMainDisplay();
|
|
|
|
drawMainDisplay();
|
|
|
|
reDrawScreen();
|
|
|
|
enablePaletteChanges();
|
2021-08-23 16:42:21 +09:00
|
|
|
g_vm->_pal->beginFade(g_vm->_currentMapNum != 0 ? g_vm->_pal->_noonPalette : &g_vm->_pal->_newPalette, 20);
|
2021-08-22 07:26:24 +09:00
|
|
|
while (g_vm->_pal->updatePalette()) ;
|
2021-05-17 20:47:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end of namespace Saga2
|