scummvm/engines/saga2/display.cpp

291 lines
7.7 KiB
C++
Raw 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 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
* along 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-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"
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
* ===================================================================== */
void reDrawScreen(void);
void quickSavePalette(void);
void quickRestorePalette(void);
void localCursorOn(void);
void localCursorOff(void);
void setPaletteToBlack(void);
void lightsOut(void);
void loadingScreen(void);
void resetInputDevices(void);
APPFUNC(cmdWindowFunc); // main window event handler
static void switchOn(void);
static void switchOff(void);
// ------------------------------------------------------------------------
// end game (normally)
void endGame(void) {
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
* ===================================================================== */
void dayNightUpdate(void);
void fadeUp(void);
void displayUpdate(void);
void drawMainDisplay(void);
void niceScreenStartup(void) {
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(NULL);
g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
2021-05-17 20:47:39 +02:00
resetInputDevices();
}
// ------------------------------------------------------------------------
// backbuffer startup
void initBackPanel(void) {
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
}
bool displayOkay(void) {
return displayEnabled();
}
// ------------------------------------------------------------------------
// Main on/off swiotch for display
void mainEnable(void) {
displayEnable(GameNotInitialized);
}
// ------------------------------------------------------------------------
// This is a check to see if blitting is enabled
void mainDisable(void) {
displayDisable(GameNotInitialized);
}
// ------------------------------------------------------------------------
// On/Off hooks
static void switchOn(void) {
enableUserControls();
}
static void switchOff(void) {
disableUserControls();
}
/* ===================================================================== *
Palette disable hooks
* ===================================================================== */
void enablePaletteChanges(void) {
2021-06-13 16:56:52 +02:00
paletteSuspendFlag = false;
paletteMayHaveChanged = true;
2021-05-17 20:47:39 +02:00
}
void disablePaletteChanges(void) {
2021-06-13 16:56:52 +02:00
paletteSuspendFlag = true;
2021-05-17 20:47:39 +02:00
}
bool paletteChangesEnabled(void) {
return !paletteSuspendFlag;
}
/* ===================================================================== *
Refresh
* ===================================================================== */
// ------------------------------------------------------------------------
// notice that screen may be dirty
void delayedDisplayEnable(void) {
2021-06-13 16:56:52 +02:00
delayReDraw = false;
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// notice that palette may be dirty
void externalPaletteIntrusion(void) {
2021-06-13 16:56:52 +02:00
paletteMayHaveChanged = true;
2021-05-17 20:47:39 +02:00
}
// ------------------------------------------------------------------------
// force a full screen redraw
void reDrawScreen(void) {
//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-05-17 20:47:39 +02:00
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
* ===================================================================== */
void blackOut(void) {
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-05-17 20:47:39 +02:00
lightsOut();
}
/* ===================================================================== *
Loading screen
* ===================================================================== */
// ------------------------------------------------------------------------
// enable / disable blitting
void showLoadMessage(void) {
uint32 saved = displayStatus;
displayStatus = 0;
loadingScreen();
displayStatus = saved;
}
/* ===================================================================== *
Video mode save and restore for videos
* ===================================================================== */
void pushVidState(void) {
}
void popVidState(void) {
}
} // end of namespace Saga2