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 TWINE_RENDERER_SCREENS_H 24 #define TWINE_RENDERER_SCREENS_H 25 26 #include "common/scummsys.h" 27 #include "graphics/managed_surface.h" 28 #include "graphics/surface.h" 29 #include "twine/twine.h" 30 31 namespace TwinE { 32 33 class TwinEEngine; 34 class Screens { 35 private: 36 TwinEEngine *_engine; 37 38 /** 39 * Adjust palette intensity 40 * @param r red component of color 41 * @param g green component of color 42 * @param b blue component of color 43 * @param palette palette to adjust 44 * @param intensity intensity value to adjust 45 */ 46 void adjustPalette(uint8 r, uint8 g, uint8 b, const uint32 *palette, int32 intensity); 47 48 public: Screens(TwinEEngine * engine)49 Screens(TwinEEngine *engine) : _engine(engine) {} 50 51 /** In-game palette (should not be used, except in special case. otherwise use other images functions instead) */ 52 uint8 _palette[NUMOFCOLORS * 3]{0}; 53 54 /** converted in-game palette */ 55 uint32 _paletteRGBA[NUMOFCOLORS]{0}; 56 57 /** converted custom palette */ 58 uint32 _paletteRGBACustom[NUMOFCOLORS]{0}; 59 60 /** flag to check in the game palette was changed */ 61 bool _palResetted = false; 62 63 /** flag to check if the main flag is locked */ 64 bool _lockPalette = false; 65 66 /** flag to check if we are using a different palette than the main one */ 67 bool _useAlternatePalette = false; 68 69 /** converted in-game palette */ 70 uint32 _mainPaletteRGBA[NUMOFCOLORS]{0}; 71 72 /** Load and display Adeline Logo */ 73 bool adelineLogo(); 74 75 void convertPalToRGBA(const uint8 *in, uint32 *out); 76 77 /** 78 * Load a custom palette 79 * @param index \a RESS.HQR entry index (starting from 0) 80 */ 81 void loadCustomPalette(const TwineResource &resource); 82 83 /** Load and display Main Menu image */ 84 void loadMenuImage(bool fadeIn = true); 85 86 /** 87 * Load and display a particulary image on \a RESS.HQR file with cross fade effect 88 * @param index \a RESS.HQR entry index (starting from 0) 89 * @param paletteIndex \a RESS.HQR entry index of the palette for the given image. This is often the @c index + 1 90 * @param fadeIn if we fade in before using the palette 91 */ 92 void loadImage(TwineImage image, bool fadeIn = true); 93 94 /** 95 * Load and display a particulary image on \a RESS.HQR file with cross fade effect and delay 96 * @param index \a RESS.HQR entry index (starting from 0) 97 * @param paletteIndex \a RESS.HQR entry index of the palette for the given image. This is often the @c index + 1 98 * @param seconds number of seconds to delay 99 * @return @c true if aborted 100 */ 101 bool loadImageDelay(TwineImage image, int32 seconds); 102 103 /** 104 * Fade image in 105 * @param palette current palette to fade in 106 */ 107 void fadeIn(const uint32 *palette); 108 109 /** 110 * Fade image out 111 * @param palette current palette to fade out 112 */ 113 void fadeOut(const uint32 *palette); 114 115 /** 116 * Linear interpolation of the given value between start and end 117 * @param value color component 118 * @param start lower range 119 * @param end upper range 120 * @param t the location in given range 121 * @return the lerped value 122 * @note Doesn't clamp 123 */ 124 int32 lerp(int32 value, int32 start, int32 end, int32 t); 125 126 /** 127 * Adjust between two palettes 128 * @param pal1 palette from adjust 129 * @param pal2 palette to adjust 130 */ 131 void adjustCrossPalette(const uint32 *pal1, const uint32 *pal2); 132 133 /** 134 * Fade image to black 135 * @param palette current palette to fade 136 */ 137 void fadeToBlack(const uint32 *palette); 138 139 /** 140 * Fade image with another palette source 141 * @param palette current palette to fade 142 */ 143 void fadeToPal(const uint32 *palette); 144 145 /** Fade black palette to white palette */ 146 void blackToWhite(); 147 148 /** Resets both in-game and sdl palettes */ 149 void setBackPal(); 150 151 /** 152 * Fade palette to red palette 153 * @param palette current palette to fade 154 */ 155 void fadePalRed(const uint32 *palette); 156 157 /** 158 * Fade red to palette 159 * @param palette current palette to fade 160 */ 161 void fadeRedPal(const uint32 *palette); 162 163 /** 164 * Copy a determinate screen buffer to another 165 * @param source screen buffer 166 * @param destination screen buffer 167 */ 168 void copyScreen(const Graphics::ManagedSurface &source, Graphics::ManagedSurface &destination); 169 170 /** Clear front buffer screen */ 171 void clearScreen(); 172 173 /** Init palettes */ 174 void initPalettes(); 175 }; 176 177 } // namespace TwinE 178 179 #endif 180