2015-03-16 23:52:08 -04: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.
|
2015-05-09 18:04:13 +02:00
|
|
|
*
|
2015-03-16 23:52:08 -04: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.
|
2015-05-09 18:04:13 +02:00
|
|
|
*
|
2015-03-16 23:52:08 -04:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SHERLOCK_SCREEN_H
|
|
|
|
#define SHERLOCK_SCREEN_H
|
|
|
|
|
2015-03-17 00:01:12 -04:00
|
|
|
#include "common/list.h"
|
2015-03-16 23:52:08 -04:00
|
|
|
#include "common/rect.h"
|
2016-03-10 21:51:47 -05:00
|
|
|
#include "sherlock/image_file.h"
|
2015-05-13 20:05:19 -04:00
|
|
|
#include "sherlock/surface.h"
|
2015-03-22 00:52:02 -04:00
|
|
|
#include "sherlock/resources.h"
|
2015-06-07 19:18:14 -04:00
|
|
|
#include "sherlock/saveload.h"
|
2015-03-16 23:52:08 -04:00
|
|
|
|
|
|
|
namespace Sherlock {
|
|
|
|
|
2015-03-17 08:31:29 -04:00
|
|
|
#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
|
2015-06-06 11:37:00 -04:00
|
|
|
#define BG_GREYSCALE_RANGE_END 229
|
2015-09-06 20:52:15 -04:00
|
|
|
#define BLACK 0
|
2015-03-16 23:52:08 -04:00
|
|
|
|
|
|
|
class SherlockEngine;
|
|
|
|
|
2016-05-26 21:48:40 -04:00
|
|
|
class Screen : public BaseSurface {
|
2015-03-16 23:52:08 -04:00
|
|
|
private:
|
2015-03-18 19:02:17 -04:00
|
|
|
uint32 _transitionSeed;
|
2015-03-17 00:01:12 -04:00
|
|
|
|
2015-05-12 22:02:59 -04:00
|
|
|
// Rose Tattoo fields
|
|
|
|
int _fadeBytesRead, _fadeBytesToRead;
|
|
|
|
int _oldFadePercent;
|
2015-03-17 00:01:12 -04:00
|
|
|
protected:
|
2015-09-06 20:52:15 -04:00
|
|
|
SherlockEngine *_vm;
|
2016-03-21 03:10:35 +01:00
|
|
|
Surface _backBuffer;
|
2016-03-21 02:50:15 +01:00
|
|
|
|
2015-03-17 23:09:04 -04:00
|
|
|
public:
|
2015-03-28 20:13:57 -04:00
|
|
|
Surface _backBuffer1, _backBuffer2;
|
2015-03-18 22:32:41 -04:00
|
|
|
bool _fadeStyle;
|
2015-03-20 19:44:32 -04:00
|
|
|
byte _cMap[PALETTE_SIZE];
|
|
|
|
byte _sMap[PALETTE_SIZE];
|
2015-05-12 22:02:59 -04:00
|
|
|
byte _tMap[PALETTE_SIZE];
|
2015-05-27 22:36:51 -04:00
|
|
|
bool _flushScreen;
|
2015-07-04 11:28:55 -04:00
|
|
|
Common::Point _currentScroll;
|
2015-03-16 23:52:08 -04:00
|
|
|
public:
|
2015-06-25 20:42:02 -04:00
|
|
|
static Screen *init(SherlockEngine *vm);
|
2015-03-16 23:52:08 -04:00
|
|
|
Screen(SherlockEngine *vm);
|
2015-05-08 07:15:40 +02:00
|
|
|
virtual ~Screen();
|
2015-03-16 23:52:08 -04:00
|
|
|
|
2016-03-21 02:50:15 +01:00
|
|
|
/**
|
|
|
|
* Obtain the currently active back buffer.
|
|
|
|
*/
|
2016-03-21 03:10:35 +01:00
|
|
|
Surface *getBackBuffer() { return &_backBuffer; }
|
2016-03-21 02:50:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes first back buffer active.
|
|
|
|
*/
|
2016-03-21 03:10:35 +01:00
|
|
|
void activateBackBuffer1();
|
2016-03-21 02:50:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes second back buffer active.
|
|
|
|
*/
|
2016-03-21 03:10:35 +01:00
|
|
|
void activateBackBuffer2();
|
2016-03-21 02:50:15 +01:00
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Fades from the currently active palette to the passed palette
|
|
|
|
*/
|
2015-03-16 23:52:08 -04:00
|
|
|
int equalizePalette(const byte palette[PALETTE_SIZE]);
|
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Fade out the palette to black
|
|
|
|
*/
|
2015-03-17 23:09:04 -04:00
|
|
|
void fadeToBlack(int speed = 2);
|
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Fade in a given palette
|
|
|
|
*/
|
2015-03-17 23:09:04 -04:00
|
|
|
void fadeIn(const byte palette[PALETTE_SIZE], int speed = 2);
|
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Do a random pixel transition in from _backBuffer surface to the screen
|
|
|
|
*/
|
2015-03-17 23:09:04 -04:00
|
|
|
void randomTransition();
|
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Transition to the surface from _backBuffer using a vertical transition
|
|
|
|
*/
|
2015-03-17 23:09:04 -04:00
|
|
|
void verticalTransition();
|
2015-03-22 00:52:02 -04:00
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Prints the text passed onto the back buffer at the given position and color.
|
|
|
|
* The string is then blitted to the screen
|
|
|
|
*/
|
2015-09-06 20:52:15 -04:00
|
|
|
void print(const Common::Point &pt, uint color, const char *formatStr, ...) GCC_PRINTF(4, 5);
|
2015-03-22 00:52:02 -04:00
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Print a strings onto the back buffer without blitting it to the screen
|
|
|
|
*/
|
2015-09-06 20:52:15 -04:00
|
|
|
void gPrint(const Common::Point &pt, uint color, const char *formatStr, ...) GCC_PRINTF(4, 5);
|
2015-03-22 00:52:02 -04:00
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Copies a section of the second back buffer into the main back buffer
|
|
|
|
*/
|
2015-03-22 00:52:02 -04:00
|
|
|
void restoreBackground(const Common::Rect &r);
|
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Copies a given area to the screen
|
|
|
|
*/
|
2015-05-08 18:01:51 +02:00
|
|
|
void slamArea(int16 xp, int16 yp, int16 width, int16 height);
|
2015-05-19 07:37:55 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies a given area to the screen
|
|
|
|
*/
|
2015-03-22 00:52:02 -04:00
|
|
|
void slamRect(const Common::Rect &r);
|
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Copy an image from the back buffer to the screen, taking care of both the
|
|
|
|
* new area covered by the shape as well as the old area, which must be restored
|
|
|
|
*/
|
2016-10-09 14:59:58 +02:00
|
|
|
void flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
|
2015-05-28 21:47:52 -04:00
|
|
|
int16 *width, int16 *height);
|
2015-03-24 08:35:08 -04:00
|
|
|
|
2015-05-28 21:47:52 -04:00
|
|
|
/**
|
|
|
|
* Similar to flushImage, this method takes in an extra parameter for the scale proporation,
|
|
|
|
* which affects the calculated bounds accordingly
|
|
|
|
*/
|
2016-10-09 14:59:58 +02:00
|
|
|
void flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
|
2015-05-28 21:47:52 -04:00
|
|
|
int16 *width, int16 *height, int scaleVal);
|
2015-05-28 19:59:03 -04:00
|
|
|
|
2015-05-31 17:55:56 -04:00
|
|
|
/**
|
|
|
|
* Variation of flushImage/flushScaleImage that takes in and updates a rect
|
|
|
|
*/
|
|
|
|
void flushImage(ImageFrame *frame, const Common::Point &pt, Common::Rect &newBounds, int scaleVal);
|
|
|
|
|
2015-05-31 16:28:41 -04:00
|
|
|
/**
|
2015-07-04 11:28:55 -04:00
|
|
|
* Copies data from the back buffer to the screen
|
2015-05-31 16:28:41 -04:00
|
|
|
*/
|
2015-07-04 11:28:55 -04:00
|
|
|
void blockMove(const Common::Rect &r);
|
2015-05-31 16:28:41 -04:00
|
|
|
|
|
|
|
/**
|
2015-07-04 11:28:55 -04:00
|
|
|
* Copies the entire screen from the back buffer
|
2015-05-31 16:28:41 -04:00
|
|
|
*/
|
2015-07-04 11:28:55 -04:00
|
|
|
void blockMove();
|
2015-05-31 16:28:41 -04:00
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Fills an area on the back buffer, and then copies it to the screen
|
|
|
|
*/
|
2015-03-27 22:12:37 -04:00
|
|
|
void vgaBar(const Common::Rect &r, int color);
|
2015-03-28 22:31:18 -04:00
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Sets the active back buffer pointer to a restricted sub-area of the first back buffer
|
|
|
|
*/
|
2015-03-30 21:07:01 -04:00
|
|
|
void setDisplayBounds(const Common::Rect &r);
|
2015-05-19 07:37:55 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the active buffer pointer to point back to the full first back buffer
|
|
|
|
*/
|
2015-03-30 21:07:01 -04:00
|
|
|
void resetDisplayBounds();
|
2015-05-19 07:37:55 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the size of the current display window
|
|
|
|
*/
|
2015-03-30 21:07:01 -04:00
|
|
|
Common::Rect getDisplayBounds();
|
2015-04-12 23:20:22 -05:00
|
|
|
|
2015-05-19 07:37:55 -04:00
|
|
|
/**
|
|
|
|
* Synchronize the data for a savegame
|
|
|
|
*/
|
2015-06-07 19:18:14 -04:00
|
|
|
void synchronize(Serializer &s);
|
2015-05-12 22:02:59 -04:00
|
|
|
|
2015-06-10 20:54:05 -04:00
|
|
|
/**
|
|
|
|
* Draws the given string into the back buffer using the images stored in _font
|
|
|
|
*/
|
2015-09-06 20:52:15 -04:00
|
|
|
virtual void writeString(const Common::String &str, const Common::Point &pt, uint overrideColor);
|
2015-06-10 20:54:05 -04:00
|
|
|
|
|
|
|
|
2015-05-12 22:02:59 -04:00
|
|
|
// Rose Tattoo specific methods
|
|
|
|
void initPaletteFade(int bytesToRead);
|
|
|
|
|
|
|
|
int fadeRead(Common::SeekableReadStream &stream, byte *buf, int totalSize);
|
|
|
|
|
2015-05-24 07:46:25 -04:00
|
|
|
/**
|
|
|
|
* Translate a palette from 6-bit RGB values to full 8-bit values suitable for passing
|
|
|
|
* to the underlying palette manager
|
|
|
|
*/
|
|
|
|
static void translatePalette(byte palette[PALETTE_SIZE]);
|
2015-03-16 23:52:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Sherlock
|
|
|
|
|
|
|
|
#endif
|