aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics/frameout.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/graphics/frameout.h')
-rw-r--r--engines/sci/graphics/frameout.h359
1 files changed, 169 insertions, 190 deletions
diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
index a7b529fe90..78bf2e068a 100644
--- a/engines/sci/graphics/frameout.h
+++ b/engines/sci/graphics/frameout.h
@@ -37,21 +37,11 @@ class GfxTransitions32;
struct PlaneShowStyle;
/**
- * Frameout class, kFrameout and relevant functions for SCI32 games.
- * Roughly equivalent to GraphicsMgr in the actual SCI engine.
+ * Frameout class, kFrameOut and relevant functions for SCI32 games.
+ * Roughly equivalent to GraphicsMgr in SSCI.
*/
class GfxFrameout {
friend class GfxTransitions32;
-private:
- GfxCursor32 *_cursor;
- GfxPalette32 *_palette;
- SegManager *_segMan;
-
- /**
- * Determines whether the current game should be rendered in
- * high resolution.
- */
- bool gameIsHiRes() const;
public:
GfxFrameout(SegManager *segMan, GfxPalette32 *palette, GfxTransitions32 *transitions, GfxCursor32 *cursor);
@@ -62,12 +52,20 @@ public:
void clear();
void run();
-#pragma mark -
-#pragma mark Screen items
private:
- void remapMarkRedraw();
- bool getNowSeenRect(const reg_t screenItemObject, Common::Rect &result) const;
+ GfxCursor32 *_cursor;
+ GfxPalette32 *_palette;
+ GfxTransitions32 *_transitions;
+ SegManager *_segMan;
+
+ /**
+ * Determines whether the current game should be rendered in high
+ * resolution.
+ */
+ bool gameIsHiRes() const;
+#pragma mark -
+#pragma mark Screen items
public:
/**
* Adds a screen item.
@@ -100,39 +98,27 @@ public:
bool kernelSetNowSeen(const reg_t screenItemObject) const;
int16 kernelObjectIntersect(const reg_t object1, const reg_t object2) const;
-#pragma mark -
-#pragma mark Planes
private:
- /**
- * The list of planes (i.e. layers) that have been added
- * to the screen.
- *
- * @note This field is on `GraphicsMgr.screen` in SCI
- * engine.
- */
- PlaneList _planes;
-
- /**
- * Updates an existing plane with properties from the
- * given VM object.
- */
- void updatePlane(Plane &plane);
+ void remapMarkRedraw();
+ bool getNowSeenRect(const reg_t screenItemObject, Common::Rect &result) const;
+#pragma mark -
+#pragma mark Planes
public:
/**
* Creates and adds a new plane to the plane list. Ownership of the passed
* object is transferred to GfxFrameout.
*
- * @note This method is on Screen in SCI engine, but it
- * is only ever called on `GraphicsMgr.screen`.
+ * @note This method is on Screen in SSCI, but it is only ever called on
+ * `GraphicsMgr.screen`.
*/
void addPlane(Plane *plane);
/**
* Deletes a plane within the current plane list.
*
- * @note This method is on Screen in SCI engine, but it
- * is only ever called on `GraphicsMgr.screen`.
+ * @note This method is on Screen in SSCI, but it is only ever called on
+ * `GraphicsMgr.screen`.
*/
void deletePlane(Plane &plane);
@@ -148,6 +134,20 @@ public:
void kernelMovePlaneItems(const reg_t object, const int16 deltaX, const int16 deltaY, const bool scrollPics);
int16 kernelGetHighPlanePri();
+private:
+ /**
+ * The list of planes (i.e. layers) that will be rendered to the screen on
+ * the next call to `frameOut`.
+ *
+ * @note This field is on `GraphicsMgr.screen` in SSCI.
+ */
+ PlaneList _planes;
+
+ /**
+ * Updates an existing plane with properties from the given VM object.
+ */
+ void updatePlane(Plane &plane);
+
#pragma mark -
#pragma mark Pics
public:
@@ -155,121 +155,193 @@ public:
#pragma mark -
#pragma mark Rendering
+public:
+ /**
+ * Updates the hardware screen, no more than once per tick.
+ *
+ * @param delta An additional number of ticks that should elapse
+ * since the last time the screen was updated before it gets updated now.
+ * This is used for updating the screen within run_vm, where we normally
+ * expect that a call to kFrameOut will occur later during the current
+ * frame, but if it does not, then update the screen on the second frame
+ * anyway since the game is doing something bad.
+ */
+ void updateScreen(const int delta = 0);
+
+ /**
+ * Resets the pixel format of the hardware surface to the given format.
+ */
+ void setPixelFormat(const Graphics::PixelFormat &format) const {
+ initGraphics(_currentBuffer.screenWidth, _currentBuffer.screenHeight, _isHiRes, &format);
+ }
+
+ /**
+ * Whether or not to throttle kFrameOut calls.
+ */
+ bool _throttleKernelFrameOut;
+
+ /**
+ * Whether `palMorphFrameOut` should be used instead of `frameOut` for
+ * rendering. Used by `kMorphOn` to explicitly enable `palMorphFrameOut` for
+ * one frame.
+ */
+ bool _palMorphIsOn;
+
+ inline const Buffer &getCurrentBuffer() const {
+ return _currentBuffer;
+ }
+
+ void kernelFrameOut(const bool showBits);
+
+ /**
+ * Throttles the engine as necessary to maintain 60fps output.
+ */
+ void throttle();
+
+ /**
+ * Updates the internal screen buffer for the next frame. If
+ * `shouldShowBits` is true, also sends the buffer to hardware. If
+ * `eraseRect` is non-empty, it is added to the erase list for this frame.
+ */
+ void frameOut(const bool shouldShowBits, const Common::Rect &eraseRect = Common::Rect());
+
+ /**
+ * TODO: Documentation
+ */
+ void palMorphFrameOut(const int8 *styleRanges, PlaneShowStyle *showStyle);
+
+ /**
+ * Draws the given rect from the internal screen buffer to hardware without
+ * processing any other graphics updates except for cursor changes.
+ */
+ void directFrameOut(const Common::Rect &showRect);
+
+#ifdef USE_RGB_COLOR
+ /**
+ * Sends the entire internal screen buffer and palette to hardware.
+ */
+ void resetHardware();
+#endif
+
+ /**
+ * Modifies the raw pixel data for the next frame with new palette indexes
+ * based on matched style ranges.
+ */
+ void alterVmap(const Palette &palette1, const Palette &palette2, const int8 style, const int8 *const styleRanges);
+
+ // This function is used within ScreenItem subsystem and assigned to various
+ // booleanish fields that seem to represent the state of the screen item
+ // (created, updated, deleted). In GK1/DOS, Phant1/m68k, SQ6/DOS, SQ6/Win,
+ // and Phant2/Win, this function simply returns 1. If you know of any
+ // game/environment where this function returns some value other than 1, or
+ // if you used to work at Sierra and can explain why this is a thing (and if
+ // anyone needs to care about it), please open a ticket!!
+ inline int getScreenCount() const {
+ return 1;
+ };
+
+ /**
+ * Shakes the screen.
+ */
+ void shakeScreen(const int16 numShakes, const ShakeDirection direction);
+
private:
/**
* The last time the hardware screen was updated.
*/
uint32 _lastScreenUpdateTick;
- GfxTransitions32 *_transitions;
-
/**
- * State tracker to provide more accurate 60fps
- * video throttling.
+ * State tracker to provide more accurate 60fps video throttling.
*/
uint8 _throttleState;
/**
- * The internal display pixel buffer. During frameOut,
- * this buffer is drawn into according to the draw and
- * erase rects calculated by `calcLists`, then drawn out
- * to the hardware surface according to the `_showList`
- * rects (which are also calculated by `calcLists`).
+ * The internal display pixel buffer. During `frameOut`, this buffer is
+ * drawn into according to the draw and erase rects calculated by
+ * `calcLists`, then drawn out to the hardware surface according to the
+ * `_showList` rects (which are also calculated by `calcLists`).
*/
Buffer _currentBuffer;
/**
- * When true, a change to the remap zone in the palette
- * has occurred and screen items with remap data need to
- * be redrawn.
+ * When true, a change to the remap zone in the palette has occurred and
+ * screen items with remap data need to be redrawn.
*/
bool _remapOccurred;
/**
- * TODO: Document
- * TODO: Depending upon if the engine ever modifies this
- * rect, it may be stupid to store it separately instead
- * of just getting width/height from GfxScreen.
+ * The dimensions of the output buffer, in display coordinates.
*
- * @note This field is on `GraphicsMgr.screen` in SCI
- * engine.
+ * @note This field is on `GraphicsMgr.screen` in SSCI.
*/
Common::Rect _screenRect;
/**
- * A list of rectangles, in display coordinates, that
- * represent portions of the internal screen buffer that
- * should be drawn to the hardware display surface.
+ * A list of rectangles, in screen coordinates, that represent portions of
+ * the internal screen buffer that are dirty and should be drawn to the
+ * hardware display surface.
*
- * @note This field is on `GraphicsMgr.screen` in SCI
- * engine.
+ * @note This field is on `GraphicsMgr.screen` in SSCI.
*/
RectList _showList;
/**
- * The amount of extra overdraw that is acceptable when
- * merging two show list rectangles together into a
- * single larger rectangle.
+ * The amount of extra overdraw that is acceptable when merging two show
+ * list rectangles together into a single larger rectangle.
*
- * @note This field is on `GraphicsMgr.screen` in SCI
- * engine.
+ * @note This field is on `GraphicsMgr.screen` in SSCI.
*/
int _overdrawThreshold;
/**
- * A list of planes that are currently drawn to the
- * hardware display surface. Used to calculate
- * differences in plane properties between the last
- * frame and current frame.
+ * The list of planes that are currently drawn to the hardware display
+ * surface. Used to calculate differences in plane properties between the
+ * last frame and current frame.
*
- * @note This field is on `GraphicsMgr.visibleScreen` in
- * SCI engine.
+ * @note This field is on `GraphicsMgr.visibleScreen` in SSCI.
*/
PlaneList _visiblePlanes;
/**
- * Calculates the location and dimensions of dirty rects
- * over the entire screen for rendering the next frame.
- * The draw and erase lists in `drawLists` and
- * `eraseLists` each represent one plane on the screen.
- * The optional `eraseRect` argument allows a specific
- * area of the screen to be erased.
+ * Calculates the location and dimensions of dirty rects over the entire
+ * screen for rendering the next frame. The draw and erase lists in
+ * `drawLists` and `eraseLists` each represent one plane on the screen.
+ * The optional `eraseRect` argument allows a specific area of the screen to
+ * be explicitly erased.
*/
void calcLists(ScreenItemListList &drawLists, EraseListList &eraseLists, const Common::Rect &eraseRect = Common::Rect());
/**
- * Erases the areas in the given erase list from the
- * visible screen buffer by filling them with the color
- * from the corresponding plane. This is an optimisation
- * for colored-type planes only; other plane types have
- * to be redrawn from pixel data.
+ * Erases the areas in the given erase list from the visible screen buffer
+ * by filling them with the color from the corresponding plane. This is an
+ * optimisation for colored-type planes only; other plane types have to be
+ * redrawn from pixel data.
*/
void drawEraseList(const RectList &eraseList, const Plane &plane);
/**
- * Draws all screen items from the given draw list to
- * the visible screen buffer.
+ * Draws all screen items from the given draw list to the visible screen
+ * buffer.
*/
void drawScreenItemList(const DrawList &screenItemList);
/**
- * Adds a new rectangle to the list of regions to write
- * out to the hardware. The provided rect may be merged
- * into an existing rectangle to reduce the number of
- * blit operations.
+ * Adds a new rectangle to the list of regions to write out to the hardware.
+ * The provided rect may be merged into an existing rectangle to reduce the
+ * number of blit operations.
*/
void mergeToShowList(const Common::Rect &drawRect, RectList &showList, const int overdrawThreshold);
/**
- * Sends all dirty rects from the internal frame buffer to the backend,
- * then updates the hardware screen.
+ * Sends all dirty rects from the internal frame buffer to the backend, then
+ * updates the hardware screen.
*/
void showBits();
/**
- * Validates whether the given palette index in the
- * style range should copy a color from the next
- * palette to the source palette during a palette
+ * Validates whether the given palette index in the style range should copy
+ * a color from the next palette to the source palette during a palette
* morph operation.
*/
inline bool validZeroStyle(const uint8 style, const int i) const {
@@ -290,101 +362,11 @@ private:
}
}
-public:
- /**
- * Updates the hardware screen, no more than once per tick.
- *
- * @param delta An additional number of ticks that should elapse
- * since the last time the screen was updated before it gets updated now.
- * This is used for updating the screen within run_vm, where we normally
- * expect that a call to kFrameOut will occur later during the current
- * frame, but if it does not, then update the screen on the second frame
- * anyway since the game is doing something bad.
- */
- void updateScreen(const int delta = 0);
-
- /**
- * Resets the pixel format of the hardware surface to the given format.
- */
- void setPixelFormat(const Graphics::PixelFormat &format) const {
- initGraphics(_currentBuffer.screenWidth, _currentBuffer.screenHeight, _isHiRes, &format);
- }
-
- /**
- * Whether or not to throttle kFrameOut calls.
- */
- bool _throttleKernelFrameOut;
-
- /**
- * Whether palMorphFrameOut should be used instead of
- * frameOut for rendering. Used by kMorphOn to
- * explicitly enable palMorphFrameOut for one frame.
- */
- bool _palMorphIsOn;
-
- inline const Buffer &getCurrentBuffer() const {
- return _currentBuffer;
- }
-
- void kernelFrameOut(const bool showBits);
-
- /**
- * Throttles the engine as necessary to maintain
- * 60fps output.
- */
- void throttle();
-
- /**
- * Updates the internal screen buffer for the next
- * frame. If `shouldShowBits` is true, also sends the
- * buffer to hardware. If `eraseRect` is non-empty,
- * it is added to the erase list for this frame.
- */
- void frameOut(const bool shouldShowBits, const Common::Rect &eraseRect = Common::Rect());
-
- /**
- * TODO: Documentation
- */
- void palMorphFrameOut(const int8 *styleRanges, PlaneShowStyle *showStyle);
-
- /**
- * Draws the given rect from the internal screen buffer to hardware without
- * processing any other graphics updates except for cursor changes.
- */
- void directFrameOut(const Common::Rect &showRect);
-
-#ifdef USE_RGB_COLOR
- /**
- * Sends the entire internal screen buffer and palette to hardware.
- */
- void resetHardware();
-#endif
-
- /**
- * Modifies the raw pixel data for the next frame with
- * new palette indexes based on matched style ranges.
- */
- void alterVmap(const Palette &palette1, const Palette &palette2, const int8 style, const int8 *const styleRanges);
-
- // NOTE: This function is used within ScreenItem subsystem and assigned
- // to various booleanish fields that seem to represent the state of the
- // screen item (created, updated, deleted). In GK1/DOS, Phant1/m68k,
- // SQ6/DOS, SQ6/Win, and Phant2/Win, this function simply returns 1. If
- // you know of any game/environment where this function returns some
- // value other than 1, or if you used to work at Sierra and can explain
- // why this is a thing (and if anyone needs to care about it), please
- // open a ticket!!
- inline int getScreenCount() const {
- return 1;
- };
-
- /**
- * Shakes the screen.
- */
- void shakeScreen(const int16 numShakes, const ShakeDirection direction);
-
#pragma mark -
#pragma mark Mouse cursor
+public:
+ reg_t kernelIsOnMe(const reg_t object, const Common::Point &position, const bool checkPixel) const;
+
private:
void updateMousePositionForRendering() const {
// In SSCI, mouse events were received via hardware interrupt, so the
@@ -398,14 +380,11 @@ private:
}
/**
- * Determines whether or not the point given by
- * `position` is inside of the given screen item.
+ * Determines whether or not the point given by `position` is inside of the
+ * given screen item.
*/
bool isOnMe(const ScreenItem &screenItem, const Plane &plane, const Common::Point &position, const bool checkPixel) const;
-public:
- reg_t kernelIsOnMe(const reg_t object, const Common::Point &position, const bool checkPixel) const;
-
#pragma mark -
#pragma mark Debugging
public: