1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef SHERLOCK_SCREEN_H 24 #define SHERLOCK_SCREEN_H 25 26 #include "common/list.h" 27 #include "common/rect.h" 28 #include "sherlock/image_file.h" 29 #include "sherlock/surface.h" 30 #include "sherlock/resources.h" 31 #include "sherlock/saveload.h" 32 33 namespace Sherlock { 34 35 #define VGA_COLOR_TRANS(x) ((x) * 255 / 63) 36 #define BG_GREYSCALE_RANGE_END 229 37 #define BLACK 0 38 39 class SherlockEngine; 40 41 class Screen : public BaseSurface { 42 private: 43 uint32 _transitionSeed; 44 45 // Rose Tattoo fields 46 int _fadeBytesRead, _fadeBytesToRead; 47 int _oldFadePercent; 48 protected: 49 SherlockEngine *_vm; 50 Surface _backBuffer; 51 52 public: 53 Surface _backBuffer1, _backBuffer2; 54 bool _fadeStyle; 55 byte _cMap[PALETTE_SIZE]; 56 byte _sMap[PALETTE_SIZE]; 57 byte _tMap[PALETTE_SIZE]; 58 bool _flushScreen; 59 Common::Point _currentScroll; 60 public: 61 static Screen *init(SherlockEngine *vm); 62 Screen(SherlockEngine *vm); 63 ~Screen() override; 64 65 /** 66 * Obtain the currently active back buffer. 67 */ getBackBuffer()68 Surface *getBackBuffer() { return &_backBuffer; } 69 70 /** 71 * Makes first back buffer active. 72 */ 73 void activateBackBuffer1(); 74 75 /** 76 * Makes second back buffer active. 77 */ 78 void activateBackBuffer2(); 79 80 /** 81 * Fades from the currently active palette to the passed palette 82 */ 83 int equalizePalette(const byte palette[PALETTE_SIZE]); 84 85 /** 86 * Fade out the palette to black 87 */ 88 void fadeToBlack(int speed = 2); 89 90 /** 91 * Fade in a given palette 92 */ 93 void fadeIn(const byte palette[PALETTE_SIZE], int speed = 2); 94 95 /** 96 * Do a random pixel transition in from _backBuffer surface to the screen 97 */ 98 void randomTransition(); 99 100 /** 101 * Transition to the surface from _backBuffer using a vertical transition 102 */ 103 void verticalTransition(); 104 105 /** 106 * Prints the text passed onto the back buffer at the given position and color. 107 * The string is then blitted to the screen 108 */ 109 void print(const Common::Point &pt, uint color, const char *formatStr, ...) GCC_PRINTF(4, 5); 110 111 /** 112 * Print a strings onto the back buffer without blitting it to the screen 113 */ 114 void gPrint(const Common::Point &pt, uint color, const char *formatStr, ...) GCC_PRINTF(4, 5); 115 116 /** 117 * Copies a section of the second back buffer into the main back buffer 118 */ 119 void restoreBackground(const Common::Rect &r); 120 121 /** 122 * Copies a given area to the screen 123 */ 124 void slamArea(int16 xp, int16 yp, int16 width, int16 height); 125 126 /** 127 * Copies a given area to the screen 128 */ 129 void slamRect(const Common::Rect &r); 130 131 /** 132 * Copy an image from the back buffer to the screen, taking care of both the 133 * new area covered by the shape as well as the old area, which must be restored 134 */ 135 void flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp, 136 int16 *width, int16 *height); 137 138 /** 139 * Similar to flushImage, this method takes in an extra parameter for the scale proporation, 140 * which affects the calculated bounds accordingly 141 */ 142 void flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp, 143 int16 *width, int16 *height, int scaleVal); 144 145 /** 146 * Variation of flushImage/flushScaleImage that takes in and updates a rect 147 */ 148 void flushImage(ImageFrame *frame, const Common::Point &pt, Common::Rect &newBounds, int scaleVal); 149 150 /** 151 * Copies data from the back buffer to the screen 152 */ 153 void blockMove(const Common::Rect &r); 154 155 /** 156 * Copies the entire screen from the back buffer 157 */ 158 void blockMove(); 159 160 /** 161 * Fills an area on the back buffer, and then copies it to the screen 162 */ 163 void vgaBar(const Common::Rect &r, int color); 164 165 /** 166 * Sets the active back buffer pointer to a restricted sub-area of the first back buffer 167 */ 168 void setDisplayBounds(const Common::Rect &r); 169 170 /** 171 * Resets the active buffer pointer to point back to the full first back buffer 172 */ 173 void resetDisplayBounds(); 174 175 /** 176 * Return the size of the current display window 177 */ 178 Common::Rect getDisplayBounds(); 179 180 /** 181 * Synchronize the data for a savegame 182 */ 183 void synchronize(Serializer &s); 184 185 /** 186 * Draws the given string into the back buffer using the images stored in _font 187 */ 188 virtual void writeString(const Common::String &str, const Common::Point &pt, uint overrideColor); 189 190 191 // Rose Tattoo specific methods 192 void initPaletteFade(int bytesToRead); 193 194 int fadeRead(Common::SeekableReadStream &stream, byte *buf, int totalSize); 195 196 /** 197 * Translate a palette from 6-bit RGB values to full 8-bit values suitable for passing 198 * to the underlying palette manager 199 */ 200 static void translatePalette(byte palette[PALETTE_SIZE]); 201 }; 202 203 } // End of namespace Sherlock 204 205 #endif 206