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 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
#include "saga2/calender.h"
|
|
|
|
#include "saga2/modal.h"
|
|
|
|
#include "saga2/display.h"
|
|
|
|
|
|
|
|
namespace Saga2 {
|
|
|
|
|
|
|
|
/* ===================================================================== *
|
|
|
|
Prototypes
|
|
|
|
* ===================================================================== */
|
|
|
|
|
|
|
|
bool isModalMode(void) {
|
|
|
|
uint16 i;
|
2021-06-13 16:56:52 +02:00
|
|
|
bool modalFlag = false;
|
2021-05-17 20:47:39 +02:00
|
|
|
|
|
|
|
for (i = 0; i < GameMode::modeStackCtr; i++) {
|
|
|
|
// go through each stacked mode
|
|
|
|
// and if modal mode is one of them,
|
|
|
|
// then set the modal flag
|
2021-06-07 18:19:10 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dayNightUpdate(void) {
|
|
|
|
// do nothing while in modal mode
|
|
|
|
if (isModalMode()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
audioEnvironmentSetDaytime(isDayTime());
|
|
|
|
|
2021-08-26 04:43:14 +09:00
|
|
|
uint32 lightLevel = g_vm->_calender->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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemEventLoop(void);
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
// Fade to black
|
|
|
|
|
|
|
|
void clearTileAreaPort(void);
|
|
|
|
void reDrawScreen(void) ;
|
|
|
|
void updateMainDisplay(void);
|
|
|
|
void updateActiveRegions();
|
|
|
|
void drawMainDisplay(void);
|
|
|
|
void fadeUp();
|
|
|
|
void fadeDown();
|
|
|
|
void clearTileAreaPort(void);
|
|
|
|
void displayUpdate(void);
|
|
|
|
void disableUserControls(void);
|
|
|
|
void enableUserControls(void);
|
|
|
|
|
|
|
|
void fadeDown(void) {
|
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
|
|
|
|
|
|
|
|
void fadeUp(void) {
|
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
|