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"
|
2015-04-22 03:51:03 +00:00
|
|
|
#include "common/serializer.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-03-17 03:52:08 +00:00
|
|
|
|
|
|
|
namespace Sherlock {
|
|
|
|
|
|
|
|
#define PALETTE_SIZE 768
|
|
|
|
#define PALETTE_COUNT 256
|
2015-03-17 12:31:29 +00:00
|
|
|
#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
|
2015-03-24 00:34:34 +00:00
|
|
|
|
2015-03-27 01:40:24 +00:00
|
|
|
enum {
|
2015-05-19 18:07:24 +00:00
|
|
|
INFO_BLACK = 1,
|
|
|
|
INFO_FOREGROUND = 11,
|
|
|
|
INFO_BACKGROUND = 1,
|
|
|
|
BORDER_COLOR = 237,
|
|
|
|
INV_FOREGROUND = 14,
|
|
|
|
INV_BACKGROUND = 1,
|
|
|
|
COMMAND_HIGHLIGHTED = 10,
|
|
|
|
COMMAND_FOREGROUND = 15,
|
|
|
|
COMMAND_BACKGROUND = 4,
|
|
|
|
COMMAND_NULL = 248,
|
|
|
|
BUTTON_TOP = 233,
|
|
|
|
BUTTON_MIDDLE = 244,
|
|
|
|
BUTTON_BOTTOM = 248,
|
|
|
|
TALK_FOREGROUND = 12,
|
|
|
|
TALK_NULL = 16,
|
|
|
|
PEN_COLOR = 250
|
2015-03-27 01:40:24 +00:00
|
|
|
};
|
2015-03-17 03:52:08 +00:00
|
|
|
|
|
|
|
class SherlockEngine;
|
|
|
|
|
|
|
|
class Screen : public Surface {
|
|
|
|
private:
|
|
|
|
SherlockEngine *_vm;
|
|
|
|
int _fontNumber;
|
2015-03-17 04:01:12 +00:00
|
|
|
Common::List<Common::Rect> _dirtyRects;
|
2015-03-18 23:02:17 +00:00
|
|
|
uint32 _transitionSeed;
|
2015-03-24 12:35:08 +00:00
|
|
|
ImageFile *_font;
|
|
|
|
int _fontHeight;
|
2015-04-30 21:23:31 +00:00
|
|
|
Surface _sceneSurface;
|
2015-03-17 04:01:12 +00:00
|
|
|
|
2015-05-13 02:02:59 +00:00
|
|
|
// Rose Tattoo fields
|
|
|
|
int _fadeBytesRead, _fadeBytesToRead;
|
|
|
|
int _oldFadePercent;
|
|
|
|
byte _lookupTable[PALETTE_COUNT];
|
|
|
|
byte _lookupTable1[PALETTE_COUNT];
|
|
|
|
private:
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Merges together overlapping dirty areas of the screen
|
|
|
|
*/
|
2015-03-17 04:01:12 +00:00
|
|
|
void mergeDirtyRects();
|
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Returns the union of two dirty area rectangles
|
|
|
|
*/
|
2015-03-17 04:01:12 +00:00
|
|
|
bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2);
|
2015-03-24 12:35:08 +00:00
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Draws the given string into the back buffer using the images stored in _font
|
|
|
|
*/
|
2015-03-29 13:52:23 +00:00
|
|
|
void writeString(const Common::String &str, const Common::Point &pt, byte color);
|
2015-03-17 04:01:12 +00:00
|
|
|
protected:
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Adds a rectangle to the list of modified areas of the screen during the
|
|
|
|
* current frame
|
|
|
|
*/
|
2015-03-17 04:01:12 +00:00
|
|
|
virtual void addDirtyRect(const Common::Rect &r);
|
2015-03-18 03:09:04 +00:00
|
|
|
public:
|
2015-03-29 00:13:57 +00:00
|
|
|
Surface _backBuffer1, _backBuffer2;
|
|
|
|
Surface *_backBuffer;
|
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
|
|
|
int _currentScroll, _targetScroll;
|
|
|
|
int _scrollSize, _scrollSpeed;
|
|
|
|
bool _flushScreen;
|
2015-03-17 03:52:08 +00:00
|
|
|
public:
|
|
|
|
Screen(SherlockEngine *vm);
|
2015-05-08 05:15:40 +00:00
|
|
|
virtual ~Screen();
|
2015-03-17 03:52:08 +00:00
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Set the font to use for writing text on the screen
|
|
|
|
*/
|
2015-03-17 03:52:08 +00:00
|
|
|
void setFont(int fontNumber);
|
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Handles updating any dirty areas of the screen Surface object to the physical screen
|
|
|
|
*/
|
2015-03-17 03:52:08 +00:00
|
|
|
void update();
|
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Return the currently active palette
|
|
|
|
*/
|
2015-03-17 03:52:08 +00:00
|
|
|
void getPalette(byte palette[PALETTE_SIZE]);
|
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Set the palette
|
|
|
|
*/
|
2015-03-17 03:52:08 +00:00
|
|
|
void setPalette(const byte palette[PALETTE_SIZE]);
|
|
|
|
|
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-05-20 12:28:12 +00:00
|
|
|
void print(const Common::Point &pt, byte 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-05-20 12:28:12 +00:00
|
|
|
void gPrint(const Common::Point &pt, byte 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-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Returns the width of a string in pixels
|
|
|
|
*/
|
2015-03-24 12:35:08 +00:00
|
|
|
int stringWidth(const Common::String &str);
|
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Returns the width of a character in pixels
|
|
|
|
*/
|
2015-03-24 12:35:08 +00:00
|
|
|
int charWidth(char c);
|
2015-03-25 00:14:13 +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
|
|
|
/**
|
|
|
|
* Draws a button for use in the inventory, talk, and examine dialogs.
|
|
|
|
*/
|
2015-03-29 02:31:18 +00:00
|
|
|
void makeButton(const Common::Rect &bounds, int textX, const Common::String &str);
|
2015-03-29 13:52:23 +00:00
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Prints an interface command with the first letter highlighted to indicate
|
|
|
|
* what keyboard shortcut is associated with it
|
|
|
|
*/
|
2015-03-29 13:52:23 +00:00
|
|
|
void buttonPrint(const Common::Point &pt, byte color, bool slamIt, const Common::String &str);
|
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Draw a panel in the back buffer with a raised area effect around the edges
|
|
|
|
*/
|
2015-03-29 13:52:23 +00:00
|
|
|
void makePanel(const Common::Rect &r);
|
2015-03-31 01:07:01 +00:00
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Draw a field in the back buffer with a raised area effect around the edges,
|
|
|
|
* suitable for text input.
|
|
|
|
*/
|
2015-05-17 21:21:21 +00:00
|
|
|
void makeField(const Common::Rect &r);
|
2015-03-31 01:07:01 +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
|
|
|
|
|
|
|
int fontNumber() const { return _fontNumber; }
|
2015-04-22 03:51:03 +00:00
|
|
|
|
2015-05-19 11:37:55 +00:00
|
|
|
/**
|
|
|
|
* Synchronize the data for a savegame
|
|
|
|
*/
|
2015-04-22 03:51:03 +00:00
|
|
|
void synchronize(Common::Serializer &s);
|
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);
|
|
|
|
|
|
|
|
void setupBGArea(const byte cMap[PALETTE_SIZE]);
|
|
|
|
|
|
|
|
void initScrollVars();
|
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
|