ScummVM API documentation
frameout.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SCI_GRAPHICS_FRAMEOUT_H
23#define SCI_GRAPHICS_FRAMEOUT_H
24
25#include "common/system.h" // for g_system
26#include "engines/util.h" // for initGraphics
27#include "sci/event.h"
28#include "sci/graphics/plane32.h"
29#include "sci/graphics/screen_item32.h"
30
31namespace Sci {
32typedef Common::Array<DrawList> ScreenItemListList;
33typedef Common::Array<RectList> EraseListList;
34
35class GfxCursor32;
36class GfxTransitions32;
37struct PlaneShowStyle;
38
44 friend class GfxTransitions32;
45
46public:
47 GfxFrameout(SegManager *segMan, GfxPalette32 *palette, GfxTransitions32 *transitions, GfxCursor32 *cursor);
49
50 void clear();
51 void run();
52
57 inline bool isHiRes() const { return _isHiRes; }
58
62 inline int16 getScriptWidth() const { return _scriptWidth; }
63
67 inline int16 getScriptHeight() const { return _scriptHeight; }
68
72 inline int16 getScreenWidth() const { return _currentBuffer.w; }
73
77 inline int16 getScreenHeight() const { return _currentBuffer.h; }
78
79private:
80 GfxCursor32 *_cursor;
81 GfxPalette32 *_palette;
82 GfxTransitions32 *_transitions;
83 SegManager *_segMan;
84
88 bool _isHiRes;
89
94 int16 _scriptWidth, _scriptHeight;
95
100 bool detectHiRes() const;
101
102#pragma mark -
103#pragma mark Screen items
104public:
108 void addScreenItem(ScreenItem &screenItem) const;
109
113 void updateScreenItem(ScreenItem &screenItem) const;
114
118 void deleteScreenItem(ScreenItem &screenItem);
119
123 void deleteScreenItem(ScreenItem &screenItem, Plane &plane);
124
128 void deleteScreenItem(ScreenItem &screenItem, const reg_t plane);
129
130 void kernelAddScreenItem(const reg_t object);
131 void kernelUpdateScreenItem(const reg_t object);
132 void kernelDeleteScreenItem(const reg_t object);
133 bool kernelSetNowSeen(const reg_t screenItemObject) const;
134 int16 kernelObjectIntersect(const reg_t object1, const reg_t object2) const;
135
136private:
137 void remapMarkRedraw();
138 bool getNowSeenRect(const reg_t screenItemObject, Common::Rect &result) const;
139
140#pragma mark -
141#pragma mark Planes
142public:
150 void addPlane(Plane *plane);
151
158 void deletePlane(Plane &plane);
159
164
165 const PlaneList &getPlanes() const {
166 return _planes;
167 }
168 const PlaneList &getVisiblePlanes() const {
169 return _visiblePlanes;
170 }
171 void kernelAddPlane(const reg_t object);
172 void kernelUpdatePlane(const reg_t object);
173 void kernelDeletePlane(const reg_t object);
174 void kernelMovePlaneItems(const reg_t object, const int16 deltaX, const int16 deltaY, const bool scrollPics);
175 int16 kernelGetHighPlanePri();
176
177private:
184 PlaneList _planes;
185
189 void updatePlane(Plane &plane);
190
191#pragma mark -
192#pragma mark Pics
193public:
194 void kernelAddPicAt(const reg_t planeObject, const GuiResourceId pictureId, const int16 pictureX, const int16 pictureY, const bool mirrorX, const bool deleteDuplicate);
195
196#pragma mark -
197#pragma mark Rendering
198public:
209 void updateScreen(const int delta = 0);
210
214 bool setPixelFormat(const Graphics::PixelFormat *format) const {
215 if (!format) {
216 initGraphics(_currentBuffer.w, _currentBuffer.h, format);
217 return !g_system->getScreenFormat().isCLUT8();
218 } else {
219 // Also try CLUT8 as a fallback to prevent error dialogs
221 formatList.push_back(*format);
222 if (!format->isCLUT8())
224 initGraphics(_currentBuffer.w, _currentBuffer.h, formatList);
225 return g_system->getScreenFormat() == *format;
226 }
227 }
228
233
240
241 inline const Buffer &getCurrentBuffer() const {
242 return _currentBuffer;
243 }
244
245 void kernelFrameOut(const bool showBits);
246
250 void throttle();
251
257 void frameOut(const bool shouldShowBits, const Common::Rect &eraseRect = Common::Rect());
258
262 void palMorphFrameOut(const int8 *styleRanges, PlaneShowStyle *showStyle);
263
268 void directFrameOut(const Common::Rect &showRect);
269
276 void redrawGameScreen(const Common::Rect &skipRect) const;
277
282
287 void alterVmap(const Palette &palette1, const Palette &palette2, const int8 style, const int8 *const styleRanges);
288
289 // This function is used within ScreenItem subsystem and assigned to various
290 // booleanish fields that seem to represent the state of the screen item
291 // (created, updated, deleted). In GK1/DOS, Phant1/m68k, SQ6/DOS, SQ6/Win,
292 // and Phant2/Win, this function simply returns 1. If you know of any
293 // game/environment where this function returns some value other than 1, or
294 // if you used to work at Sierra and can explain why this is a thing (and if
295 // anyone needs to care about it), please open a ticket!!
296 inline int getScreenCount() const {
297 return 1;
298 };
299
303 void shakeScreen(const int16 numShakes, const ShakeDirection direction);
304
305 Plane *getTopVisiblePlane();
306
307private:
311 uint32 _lastScreenUpdateTick;
312
316 uint8 _throttleState;
317
324 Buffer _currentBuffer;
325
330 bool _remapOccurred;
331
339 RectList _showList;
340
345 ScreenItemListList _screenItemLists;
346
353 int _overdrawThreshold;
354
362 PlaneList _visiblePlanes;
363
371 void calcLists(ScreenItemListList &drawLists, EraseListList &eraseLists, const Common::Rect &eraseRect = Common::Rect());
372
379 void drawEraseList(const RectList &eraseList, const Plane &plane);
380
385 void drawScreenItemList(const DrawList &screenItemList);
386
392 void mergeToShowList(const Common::Rect &drawRect, RectList &showList, const int overdrawThreshold);
393
398 void showBits();
399
405 inline bool validZeroStyle(const uint8 style, const int i) const {
406 if (style != 0) {
407 return false;
408 }
409
410 // TODO: Cannot check Shivers or MGDX until those executables can be
411 // unwrapped
412 switch (g_sci->getGameId()) {
413 case GID_KQ7:
414 case GID_PHANTASMAGORIA:
415 case GID_SQ6:
416 return (i > 71 && i < 104);
417 break;
418 default:
419 return true;
420 }
421 }
422
423#pragma mark -
424#pragma mark Mouse cursor
425public:
426 reg_t kernelIsOnMe(const reg_t object, const Common::Point &position, const bool checkPixel) const;
427
428private:
429 void updateMousePositionForRendering() const {
430 // In SSCI, mouse events were received via hardware interrupt, so the
431 // mouse cursor would always get updated immediately when the user moved
432 // the mouse. ScummVM must poll for mouse events from the backend
433 // instead, so we poll just before rendering so that the latest mouse
434 // position is rendered instead of whatever position it was at the last
435 // time kGetEvent was called. Without this, the mouse appears stuck
436 // during loops that do not make calls to kGetEvent, like transitions.
437 g_sci->getEventManager()->getSciEvent(kSciEventPeek);
438 }
439
444 bool isOnMe(const ScreenItem &screenItem, const Plane &plane, const Common::Point &position, const bool checkPixel) const;
445
446#pragma mark -
447#pragma mark Debugging
448public:
449 void printPlaneList(Console *con) const;
450 void printVisiblePlaneList(Console *con) const;
451 void printPlaneListInternal(Console *con, const PlaneList &planeList) const;
452 void printPlaneItemList(Console *con, const reg_t planeObject) const;
453 void printVisiblePlaneItemList(Console *con, const reg_t planeObject) const;
454 void printPlaneItemListInternal(Console *con, const ScreenItemList &screenItemList) const;
455};
456
457} // End of namespace Sci
458
459#endif // SCI_GRAPHICS_FRAMEOUT_H
Definition: display_client.h:113
Definition: list.h:44
void push_back(const t_T &element)
Definition: list.h:174
Definition: plane32.h:82
Definition: cursor32.h:34
Definition: frameout.h:43
bool setPixelFormat(const Graphics::PixelFormat *format) const
Definition: frameout.h:214
void addScreenItem(ScreenItem &screenItem) const
void deletePlanesForMacRestore()
void frameOut(const bool shouldShowBits, const Common::Rect &eraseRect=Common::Rect())
void palMorphFrameOut(const int8 *styleRanges, PlaneShowStyle *showStyle)
void alterVmap(const Palette &palette1, const Palette &palette2, const int8 style, const int8 *const styleRanges)
bool _throttleKernelFrameOut
Definition: frameout.h:232
int16 getScriptWidth() const
Definition: frameout.h:62
bool _palMorphIsOn
Definition: frameout.h:239
void deleteScreenItem(ScreenItem &screenItem, Plane &plane)
void deleteScreenItem(ScreenItem &screenItem, const reg_t plane)
void redrawGameScreen(const Common::Rect &skipRect) const
int16 getScriptHeight() const
Definition: frameout.h:67
void directFrameOut(const Common::Rect &showRect)
int16 getScreenWidth() const
Definition: frameout.h:72
void updateScreenItem(ScreenItem &screenItem) const
bool isHiRes() const
Definition: frameout.h:57
void shakeScreen(const int16 numShakes, const ShakeDirection direction)
int16 getScreenHeight() const
Definition: frameout.h:77
void deletePlane(Plane &plane)
void deleteScreenItem(ScreenItem &screenItem)
void addPlane(Plane *plane)
void updateScreen(const int delta=0)
Definition: palette32.h:234
Definition: transitions32.h:215
Definition: plane32.h:103
Definition: plane32.h:479
Definition: plane32.h:55
Definition: screen_item32.h:53
Definition: seg_manager.h:48
OSystem * g_system
void initGraphics(int width, int height)
Definition: console.h:28
SciEngine * g_sci
Definition: rect.h:144
Definition: rect.h:536
Definition: pixelformat.h:138
bool isCLUT8() const
Definition: pixelformat.h:430
static constexpr PixelFormat createFormatCLUT8()
Definition: pixelformat.h:184
Definition: helpers.h:247
Definition: transitions32.h:53
Definition: vm_types.h:39