2017-07-19 11:37:54 +00: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 17:47:58 +00: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.
|
2017-07-19 11:37:54 +00: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
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-07-19 11:37:54 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SLUDGE_GRAPHICS_H
|
|
|
|
#define SLUDGE_GRAPHICS_H
|
|
|
|
|
2017-07-21 12:00:24 +00:00
|
|
|
#include "sludge/sprbanks.h"
|
|
|
|
|
2021-05-06 22:52:05 +00:00
|
|
|
namespace Common {
|
|
|
|
class SeekableReadStream;
|
|
|
|
class WriteStream;
|
|
|
|
}
|
|
|
|
|
2017-07-19 11:37:54 +00:00
|
|
|
namespace Sludge {
|
|
|
|
|
|
|
|
class Parallax;
|
2017-07-19 22:41:13 +00:00
|
|
|
class SludgeEngine;
|
|
|
|
class SpritePalette;
|
|
|
|
|
2017-07-20 08:39:24 +00:00
|
|
|
struct StackHandler;
|
2017-07-19 22:41:13 +00:00
|
|
|
struct FrozenStuffStruct;
|
2017-07-21 12:00:24 +00:00
|
|
|
struct LoadedSpriteBank;
|
2017-07-20 08:39:24 +00:00
|
|
|
struct OnScreenPerson;
|
2017-07-19 22:41:13 +00:00
|
|
|
struct SpriteBank;
|
|
|
|
struct Sprite;
|
2021-05-16 23:41:48 +00:00
|
|
|
struct VariableStack;
|
2017-07-19 22:41:13 +00:00
|
|
|
struct ZBufferData;
|
|
|
|
|
|
|
|
enum ELightMapMode {
|
|
|
|
LIGHTMAPMODE_NONE = -1,
|
|
|
|
LIGHTMAPMODE_HOTSPOT,
|
|
|
|
LIGHTMAPMODE_PIXEL,
|
|
|
|
LIGHTMAPMODE_NUM
|
|
|
|
};
|
2017-07-19 11:37:54 +00:00
|
|
|
|
2021-05-13 21:48:25 +00:00
|
|
|
// Parallax
|
|
|
|
struct ParallaxLayer {
|
|
|
|
Graphics::Surface surface;
|
|
|
|
int speedX, speedY;
|
|
|
|
bool wrapS, wrapT;
|
|
|
|
uint16 fileNum, fractionX, fractionY;
|
|
|
|
int cameraX, cameraY;
|
|
|
|
};
|
|
|
|
typedef Common::List<ParallaxLayer *> ParallaxLayers;
|
|
|
|
|
2017-07-19 11:37:54 +00:00
|
|
|
class GraphicsManager {
|
|
|
|
public:
|
2017-07-19 22:41:13 +00:00
|
|
|
GraphicsManager(SludgeEngine *vm);
|
2017-07-19 11:37:54 +00:00
|
|
|
virtual ~GraphicsManager();
|
|
|
|
|
2017-08-22 12:12:54 +00:00
|
|
|
void init();
|
|
|
|
void kill();
|
|
|
|
|
2017-07-19 22:41:13 +00:00
|
|
|
// graphics
|
|
|
|
void setWindowSize(uint winWidth, uint winHeight) { _winWidth = winWidth; _winHeight = winHeight; }
|
2017-08-22 12:12:54 +00:00
|
|
|
bool initGfx();
|
2017-07-19 22:41:13 +00:00
|
|
|
void display();
|
2017-08-01 07:29:34 +00:00
|
|
|
void clear();
|
2017-07-19 22:41:13 +00:00
|
|
|
|
2017-07-19 11:37:54 +00:00
|
|
|
// Parallax
|
|
|
|
bool loadParallax(uint16 v, uint16 fracX, uint16 fracY);
|
|
|
|
void killParallax();
|
|
|
|
void saveParallax(Common::WriteStream *fp);
|
|
|
|
void drawParallax();
|
2017-07-19 22:41:13 +00:00
|
|
|
|
|
|
|
// Backdrop
|
|
|
|
void killAllBackDrop();
|
|
|
|
bool resizeBackdrop(int x, int y);
|
|
|
|
bool killResizeBackdrop(int x, int y);
|
|
|
|
void killBackDrop();
|
|
|
|
void loadBackDrop(int fileNum, int x, int y);
|
|
|
|
void mixBackDrop(int fileNum, int x, int y);
|
|
|
|
void drawBackDrop();
|
|
|
|
void blankScreen(int x1, int y1, int x2, int y2);
|
|
|
|
void blankAllScreen();
|
|
|
|
void darkScreen();
|
|
|
|
void saveHSI(Common::WriteStream *stream);
|
2021-05-06 13:00:12 +00:00
|
|
|
bool loadHSI(int num, Common::SeekableReadStream *stream, int, int, bool);
|
|
|
|
bool mixHSI(int num, Common::SeekableReadStream *stream, int x = 0, int y = 0);
|
2017-07-19 22:41:13 +00:00
|
|
|
void drawLine(uint, uint, uint, uint);
|
|
|
|
void drawHorizontalLine(uint, uint, uint);
|
|
|
|
void drawVerticalLine(uint, uint, uint);
|
|
|
|
void hardScroll(int distance);
|
2017-07-20 08:39:24 +00:00
|
|
|
bool getRGBIntoStack(uint x, uint y, StackHandler *sH);
|
2018-04-27 17:12:30 +00:00
|
|
|
void saveBackdrop(Common::WriteStream *stream); // To game save
|
|
|
|
void loadBackdrop(int ssgVersion, Common::SeekableReadStream *streamn); // From game save
|
2017-07-19 22:41:13 +00:00
|
|
|
|
|
|
|
// Lightmap
|
|
|
|
int _lightMapMode;
|
|
|
|
void killLightMap();
|
|
|
|
bool loadLightMap(int v);
|
|
|
|
void saveLightMap(Common::WriteStream *stream);
|
|
|
|
bool loadLightMap(int ssgVersion, Common::SeekableReadStream *stream);
|
|
|
|
|
|
|
|
// Snapshot
|
|
|
|
void nosnapshot();
|
|
|
|
bool snapshot();
|
|
|
|
void saveSnapshot(Common::WriteStream *stream);
|
|
|
|
bool restoreSnapshot(Common::SeekableReadStream *stream);
|
|
|
|
|
|
|
|
// Camera
|
|
|
|
int getCamX() { return _cameraX; }
|
|
|
|
int getCamY() { return _cameraY; }
|
|
|
|
float getCamZoom() { return _cameraZoom; }
|
|
|
|
void aimCamera(int cameraX, int cameraY);
|
|
|
|
void zoomCamera(int z);
|
|
|
|
|
|
|
|
// Screen
|
|
|
|
int getCenterX(int width) { return (_winWidth - width) >> 1; }
|
2017-07-19 23:55:21 +00:00
|
|
|
int checkSizeValide(int width, int height) { return ((width >= 0) && (height >= 0) && (width < (int)_winWidth) && (height < (int)_winHeight)); }
|
2017-07-19 22:41:13 +00:00
|
|
|
|
|
|
|
// Freeze
|
|
|
|
bool freeze();
|
|
|
|
void unfreeze(bool killImage = true);
|
|
|
|
int howFrozen();
|
|
|
|
bool isFrozen() { return (_frozenStuff != nullptr); }
|
|
|
|
|
|
|
|
// Sprites
|
2017-08-22 12:12:54 +00:00
|
|
|
static void forgetSpriteBank(SpriteBank &forgetme);
|
2017-07-19 22:41:13 +00:00
|
|
|
bool loadSpriteBank(char *filename, SpriteBank &loadhere);
|
|
|
|
bool loadSpriteBank(int fileNum, SpriteBank &loadhere, bool isFont);
|
|
|
|
|
|
|
|
void fontSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
|
|
|
|
void flipFontSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
|
|
|
|
|
2017-07-20 08:39:24 +00:00
|
|
|
bool scaleSprite(Sprite &single, const SpritePalette &fontPal, OnScreenPerson *thisPerson, bool mirror);
|
2017-08-08 16:15:36 +00:00
|
|
|
void fixScaleSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal, OnScreenPerson *thisPerson, const int camX, const int camY, bool);
|
|
|
|
|
2017-07-19 22:41:13 +00:00
|
|
|
void pasteSpriteToBackDrop(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
|
|
|
|
bool reserveSpritePal(SpritePalette &sP, int n);
|
|
|
|
void burnSpriteToBackDrop(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
|
|
|
|
|
2017-07-21 12:00:24 +00:00
|
|
|
// Sprite Bank
|
|
|
|
LoadedSpriteBank *loadBankForAnim(int ID);
|
|
|
|
|
2017-07-19 22:41:13 +00:00
|
|
|
// ZBuffer
|
|
|
|
bool setZBuffer(int y);
|
|
|
|
void killZBuffer();
|
|
|
|
void drawZBuffer(int x, int y, bool upsidedown);
|
|
|
|
void saveZBuffer(Common::WriteStream *stream);
|
|
|
|
bool loadZBuffer(Common::SeekableReadStream *stream);
|
|
|
|
|
2023-11-15 14:36:46 +00:00
|
|
|
void drawSpriteToZBuffer(int x, int y, uint8 depth, const Graphics::Surface &surface);
|
|
|
|
void fillZBuffer(uint8 d);
|
2023-11-03 11:38:03 +00:00
|
|
|
|
2017-07-19 22:41:13 +00:00
|
|
|
// Colors
|
|
|
|
void setBlankColor(int r, int g, int b) { _currentBlankColour = _renderSurface.format.RGBToColor(r & 255, g & 255, b & 255);};
|
|
|
|
void setBurnColor(int r, int g, int b) {
|
2023-01-17 03:02:55 +00:00
|
|
|
_currentBurnR = r;
|
2017-07-19 22:41:13 +00:00
|
|
|
_currentBurnG = g;
|
|
|
|
_currentBurnB = b;
|
|
|
|
}
|
|
|
|
void saveColors(Common::WriteStream *stream);
|
|
|
|
void loadColors(Common::SeekableReadStream *stream);
|
|
|
|
|
2018-04-27 12:15:09 +00:00
|
|
|
// Thumbnail
|
|
|
|
bool setThumbnailSize(int thumbWidth, int thumbHeight);
|
2017-08-08 11:36:30 +00:00
|
|
|
bool saveThumbnail(Common::WriteStream *stream);
|
|
|
|
bool skipThumbnail(Common::SeekableReadStream *stream);
|
|
|
|
void showThumbnail(const Common::String &filename, int x, int y);
|
|
|
|
|
2018-04-27 17:12:30 +00:00
|
|
|
// Transition
|
|
|
|
void setBrightnessLevel(int brightnessLevel);
|
2018-04-29 07:52:48 +00:00
|
|
|
void setFadeMode(int fadeMode) { _fadeMode = fadeMode; };
|
|
|
|
void fixBrightness();
|
|
|
|
void resetRandW();
|
2021-05-16 14:38:26 +00:00
|
|
|
void reserveTransitionTexture();
|
2018-04-27 17:12:30 +00:00
|
|
|
|
2021-05-14 21:58:32 +00:00
|
|
|
void transitionFader();
|
2021-05-16 14:38:26 +00:00
|
|
|
void transitionDisolve();
|
2021-05-16 14:43:31 +00:00
|
|
|
void transitionTV();
|
2021-05-16 15:07:56 +00:00
|
|
|
void transitionBlinds();
|
2021-05-16 15:27:00 +00:00
|
|
|
void transitionSnapshotBox();
|
2021-05-16 16:44:55 +00:00
|
|
|
void transitionCrossFader();
|
2021-05-14 21:58:32 +00:00
|
|
|
|
2021-05-16 23:41:48 +00:00
|
|
|
// BG effects
|
|
|
|
bool blurScreen();
|
|
|
|
void blur_saveSettings(Common::WriteStream *stream);
|
|
|
|
void blur_loadSettings(Common::SeekableReadStream *stream);
|
|
|
|
bool blur_createSettings(int numParams, VariableStack *&stack);
|
|
|
|
|
2022-10-14 16:57:03 +00:00
|
|
|
uint getWinWidth() { return _winWidth; }
|
|
|
|
uint getWinHeight() { return _winHeight; }
|
|
|
|
|
2017-07-19 22:41:13 +00:00
|
|
|
private:
|
|
|
|
SludgeEngine *_vm;
|
|
|
|
|
|
|
|
uint _winWidth, _winHeight, _sceneWidth, _sceneHeight;
|
|
|
|
|
|
|
|
// renderSurface
|
|
|
|
Graphics::Surface _renderSurface;
|
|
|
|
|
2023-11-03 11:38:03 +00:00
|
|
|
// Z Buffer Surface
|
2023-11-15 14:36:46 +00:00
|
|
|
uint8 *_zBufferSurface = nullptr;
|
2023-11-03 11:38:03 +00:00
|
|
|
|
2017-07-19 22:41:13 +00:00
|
|
|
// Snapshot
|
|
|
|
Graphics::Surface _snapshotSurface;
|
|
|
|
|
|
|
|
// LightMap
|
|
|
|
int _lightMapNumber;
|
|
|
|
Graphics::Surface _lightMap;
|
|
|
|
|
|
|
|
// Camera
|
|
|
|
float _cameraZoom;
|
|
|
|
int _cameraX, _cameraY;
|
|
|
|
|
|
|
|
// Freeze
|
|
|
|
FrozenStuffStruct *_frozenStuff;
|
|
|
|
Graphics::Surface _freezeSurface;
|
|
|
|
void freezeGraphics();
|
|
|
|
|
|
|
|
// Back drop
|
|
|
|
Graphics::Surface _backdropSurface;
|
|
|
|
Graphics::Surface _origBackdropSurface;
|
|
|
|
bool _backdropExists;
|
|
|
|
bool reserveBackdrop();
|
|
|
|
|
|
|
|
// Sprites
|
|
|
|
void fontSprite(bool flip, int x, int y, Sprite &single, const SpritePalette &fontPal);
|
2017-08-14 13:54:08 +00:00
|
|
|
Graphics::Surface *duplicateSurface(Graphics::Surface *surface);
|
|
|
|
void blendColor(Graphics::Surface * surface, uint32 color, Graphics::TSpriteBlendMode mode);
|
|
|
|
Graphics::Surface *applyLightmapToSprite(Graphics::Surface *&blitted, OnScreenPerson *thisPerson, bool mirror, int x, int y, int x1, int y1, int diffX, int diffY);
|
2017-07-19 22:41:13 +00:00
|
|
|
|
2017-07-21 12:00:24 +00:00
|
|
|
// Sprite banks
|
|
|
|
LoadedSpriteBanks _allLoadedBanks;
|
|
|
|
|
2017-07-19 22:41:13 +00:00
|
|
|
// ZBuffer
|
|
|
|
ZBufferData *_zBuffer;
|
|
|
|
void sortZPal(int *oldpal, int *newpal, int size);
|
|
|
|
|
|
|
|
// Colors
|
|
|
|
uint _currentBlankColour;
|
|
|
|
byte _currentBurnR, _currentBurnG, _currentBurnB;
|
2018-04-27 12:15:09 +00:00
|
|
|
|
|
|
|
// Thumbnail
|
|
|
|
int _thumbWidth;
|
|
|
|
int _thumbHeight;
|
2018-04-27 17:12:30 +00:00
|
|
|
|
|
|
|
// Transition
|
|
|
|
byte _brightnessLevel;
|
2018-04-29 07:52:48 +00:00
|
|
|
byte _fadeMode;
|
2021-05-13 21:48:25 +00:00
|
|
|
|
2021-05-16 14:38:26 +00:00
|
|
|
#define RANDKK 17
|
|
|
|
|
|
|
|
uint32 _randbuffer[RANDKK][2];
|
|
|
|
int _randp1, _randp2;
|
2023-10-22 05:52:02 +00:00
|
|
|
Graphics::ManagedSurface *_transitionTexture;
|
2021-05-16 14:38:26 +00:00
|
|
|
|
2021-05-13 21:48:25 +00:00
|
|
|
// Parallax
|
|
|
|
ParallaxLayers *_parallaxLayers;
|
|
|
|
|
|
|
|
inline int sortOutPCamera(int cX, int fX, int sceneMax, int boxMax) {
|
|
|
|
return (fX == 65535) ? (sceneMax ? ((cX * boxMax) / sceneMax) : 0) : ((cX * fX) / 100);
|
|
|
|
}
|
2017-07-19 11:37:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Sludge
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SLUDGE_GRAPHICS_H
|