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