scummvm/engines/saga2/display.cpp

285 lines
7.4 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2021-05-17 20:47:39 +02:00
*
*
* Based on the original sources
* Faery Tale II -- The Halls of the Dead
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
2021-07-22 00:21:50 +09:00
#include "common/config-manager.h"
2021-06-23 14:41:01 +02:00
#include "saga2/saga2.h"
2021-05-17 20:47:39 +02:00
#include "saga2/display.h"
#include "saga2/intrface.h"
#include "saga2/loadmsg.h"
#include "saga2/grabinfo.h"
2021-08-22 07:26:24 +09:00
#include "saga2/vpal.h"
2021-05-17 20:47:39 +02:00
namespace Saga2 {
extern bool delayReDraw;
extern BackWindow *mainWindow; // main window...
/* ===================================================================== *
Globals
* ===================================================================== */
2021-06-13 16:56:52 +02:00
bool paletteMayHaveChanged = false;
2021-05-17 20:47:39 +02:00
/* ===================================================================== *
Locals
* ===================================================================== */
static uint32 displayStatus = GraphicsInit;
2021-06-13 16:56:52 +02:00
static bool paletteSuspendFlag = false;
2021-05-17 20:47:39 +02:00
/* ===================================================================== *
Prototypes
* ===================================================================== */
2021-09-11 12:13:35 +03:00
void localCursorOn();
void localCursorOff();
void resetInputDevices();
2021-05-17 20:47:39 +02:00
APPFUNC(cmdWindowFunc); // main window event handler
2021-09-11 12:13:35 +03:00
static void switchOn();
static void switchOff();
2021-05-17 20:47:39 +02:00
// ------------------------------------------------------------------------
// end game (normally)
2021-09-11 12:13:35 +03:00
void endGame() {
2021-05-17 20:47:39 +02:00
blackOut();
displayDisable(GameEnded);
2021-08-21 02:19:25 +09:00
g_vm->_gameRunning = false;
2021-05-17 20:47:39 +02:00
}
/* ===================================================================== *
Display initialization
* ===================================================================== */
2021-09-11 12:13:35 +03:00
void dayNightUpdate();
void fadeUp();
void displayUpdate();
void drawMainDisplay();
2021-05-17 20:47:39 +02:00
2021-09-11 12:13:35 +03:00
void niceScreenStartup() {
2021-07-22 00:21:50 +09:00
if (ConfMan.hasKey("save_slot")) {
cleanupGameState();
loadSavedGameState(ConfMan.getInt("save_slot"));
if (GameMode::newmodeFlag)
GameMode::update();
updateActiveRegions();
}
2021-05-17 20:47:39 +02:00
blackOut();
disablePaletteChanges();
mainEnable();
closeLoadMode();
2021-07-17 05:19:47 +09:00
g_vm->_pointer->move(Point16(320, 240));
//g_vm->_pointer->hide();
2021-05-17 20:47:39 +02:00
enablePaletteChanges();
displayUpdate();
dayNightUpdate();
fadeUp();
2021-07-17 05:19:47 +09:00
g_vm->_pointer->manditoryShow(); // hide mouse pointer
2021-05-17 20:47:39 +02:00
reDrawScreen();
2021-07-17 05:19:47 +09:00
//g_vm->_pointer->show();
2021-05-17 20:47:39 +02:00
updateAllUserControls();
reDrawScreen();
2021-07-01 05:05:03 +09:00
g_vm->_mouseInfo->replaceObject();
g_vm->_mouseInfo->clearGauge();
g_vm->_mouseInfo->setText(nullptr);
2021-07-01 05:05:03 +09:00
g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
2021-05-17 20:47:39 +02:00
resetInputDevices();
}
// ------------------------------------------------------------------------
// backbuffer startup
2021-09-11 12:13:35 +03:00
void initBackPanel() {
if (mainWindow)
return;
mainWindow = new BackWindow(
2021-05-17 20:47:39 +02:00
Rect16(0, 0, screenWidth, screenHeight),
0,
cmdWindowFunc);
if (mainWindow == nullptr)
error("Error initializing the back panel");
2021-05-17 20:47:39 +02:00
}
/* ===================================================================== *
Display disable flags
* ===================================================================== */
// ------------------------------------------------------------------------
// enable / disable blitting
void displayEnable(DisplayDisabledBecause reason, bool onOff) {
bool prev = displayEnabled();
if (!onOff)
displayStatus |= reason;
else
displayStatus &= (~reason);
if (prev != displayEnabled()) {
if (displayEnabled())
switchOn();
else
switchOff();
}
}
// ------------------------------------------------------------------------
// This is a check to see if blitting is enabled
bool displayEnabled(uint32 mask) {
2021-06-09 21:51:44 +09:00
return true;
2021-05-17 20:47:39 +02:00
}
2021-09-11 12:13:35 +03:00
bool displayOkay() {
2021-05-17 20:47:39 +02:00
return displayEnabled();
}
// ------------------------------------------------------------------------
// Main on/off swiotch for display
2021-09-11 12:13:35 +03:00
void mainEnable() {
2021-05-17 20:47:39 +02:00
displayEnable(GameNotInitialized);
}
// ------------------------------------------------------------------------
// This is a check to see if blitting is enabled
2021-09-11 12:13:35 +03:00
void mainDisable() {
2021-05-17 20:47:39 +02:00
displayDisable(GameNotInitialized);
}
// ------------------------------------------------------------------------
// On/Off hooks
2021-09-11 12:13:35 +03:00
static void switchOn() {
2021-05-17 20:47:39 +02:00
enableUserControls();
}
2021-09-11 12:13:35 +03:00
static void switchOff() {
2021-05-17 20:47:39 +02:00
disableUserControls();
}
/* ===================================================================== *
Palette disable hooks
* ===================================================================== */
2021-09-11 12:13:35 +03:00
void enablePaletteChanges() {
2021-06-13 16:56:52 +02:00
paletteSuspendFlag = false;
paletteMayHaveChanged = true;
2021-05-17 20:47:39 +02:00
}
2021-09-11 12:13:35 +03:00
void disablePaletteChanges() {
2021-06-13 16:56:52 +02:00
paletteSuspendFlag = true;
2021-05-17 20:47:39 +02:00
}
2021-09-11 12:13:35 +03:00
bool paletteChangesEnabled() {
2021-05-17 20:47:39 +02:00
return !paletteSuspendFlag;
}
/* ===================================================================== *
Refresh
* ===================================================================== */
// ------------------------------------------------------------------------
// notice that screen may be dirty
2021-09-11 12:13:35 +03:00
void delayedDisplayEnable() {
2021-06-13 16:56:52 +02:00
delayReDraw = false;
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// notice that palette may be dirty
2021-09-11 12:13:35 +03:00
void externalPaletteIntrusion() {
2021-06-13 16:56:52 +02:00
paletteMayHaveChanged = true;
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// force a full screen redraw
2021-09-11 12:13:35 +03:00
void reDrawScreen() {
2021-05-17 20:47:39 +02:00
//dispMM("refresh");
Rect16 r = Rect16(0, 0, 640, 480);
if (mainWindow && displayEnabled()) {
//updateAllUserControls();
drawMainDisplay();
2021-06-18 19:53:14 +02:00
mainWindow->invalidate(&r);
2021-06-13 16:56:52 +02:00
delayReDraw = false;
2021-05-17 20:47:39 +02:00
if (paletteMayHaveChanged) {
2021-06-13 16:56:52 +02:00
paletteMayHaveChanged = false;
2021-08-22 07:26:24 +09:00
g_vm->_pal->assertCurrentPalette();
2021-06-13 16:56:52 +02:00
paletteMayHaveChanged = false;
2021-05-17 20:47:39 +02:00
}
} else
2021-06-13 16:56:52 +02:00
delayReDraw = true;
2021-05-17 20:47:39 +02:00
//mainWindow->invalidate(r);
}
/* ===================================================================== *
Clear screen
* ===================================================================== */
2021-09-11 12:13:35 +03:00
void blackOut() {
2021-07-01 03:26:57 +09:00
g_vm->_mainPort.drawMode = drawModeReplace;
g_vm->_mainPort.setColor(0); // fill screen with color
g_vm->_mainPort.fillRect(Rect16(0, 0, 640, 480));
2021-08-22 07:26:24 +09:00
g_vm->_pal->lightsOut();
2021-05-17 20:47:39 +02:00
}
/* ===================================================================== *
Loading screen
* ===================================================================== */
// ------------------------------------------------------------------------
// enable / disable blitting
2021-09-11 12:13:35 +03:00
void showLoadMessage() {
2021-05-17 20:47:39 +02:00
uint32 saved = displayStatus;
displayStatus = 0;
loadingScreen();
displayStatus = saved;
}
/* ===================================================================== *
Video mode save and restore for videos
* ===================================================================== */
2021-09-11 12:13:35 +03:00
void pushVidState() {
2021-05-17 20:47:39 +02:00
}
2021-09-11 12:13:35 +03:00
void popVidState() {
2021-05-17 20:47:39 +02:00
}
} // end of namespace Saga2