diff options
author | richiesams | 2013-08-14 10:25:50 -0500 |
---|---|---|
committer | richiesams | 2013-08-14 11:20:04 -0500 |
commit | 54f16f2539d619b7cdb4e43d7de03e1f538a1c1f (patch) | |
tree | 037a5397b09c2c67098faea0457490a9b964a050 /engines | |
parent | 003b30c77b34c9447bab3927d206101d5f341b4f (diff) | |
download | scummvm-rg350-54f16f2539d619b7cdb4e43d7de03e1f538a1c1f.tar.gz scummvm-rg350-54f16f2539d619b7cdb4e43d7de03e1f538a1c1f.tar.bz2 scummvm-rg350-54f16f2539d619b7cdb4e43d7de03e1f538a1c1f.zip |
ZVISION: Create the concept of a working window
The working window is a Rect centered inside the actual window edges. All in-game
coordinates are in the working window coordinate system. Also, all images in-game
are clipped to the edges of the working window.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/render_manager.cpp | 30 | ||||
-rw-r--r-- | engines/zvision/render_manager.h | 25 | ||||
-rw-r--r-- | engines/zvision/video.cpp | 8 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 7 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 13 |
5 files changed, 49 insertions, 34 deletions
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index e705a7f8b4..7855dc3903 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -34,12 +34,13 @@ namespace ZVision { -RenderManager::RenderManager(OSystem *system, const int width, const int height) +RenderManager::RenderManager(OSystem *system, const Common::Rect workingWindow) : _system(system), - _width(width), - _height(height), + _workingWidth(workingWindow.width()), + _workingHeight(workingWindow.height()), + _workingWindow(workingWindow), _currentBackground(0), - _renderTable(width, height) { + _renderTable(workingWindow.width(), workingWindow.height()) { } RenderManager::~RenderManager() { @@ -75,20 +76,19 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin if (!subRectangle.isValidRect() || subRectangle.isEmpty() || !destRect.isValidRect() || destRect.isEmpty()) return; - // Center the image on the screen if asked - if (autoCenter) { - destRect.moveTo((_width - subRectangle.width()) / 2, (_height - subRectangle.height()) / 2); } _backgroundOffset = Common::Point(destRect.left, destRect.top); if (_renderTable.getRenderState() == RenderTable::FLAT) { - _system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left, destRect.top, destRect.width(), destRect.height()); + // Convert destRect to screen space by adding _workingWindowOffset + _system->copyRectToScreen(buffer + subRectangle.top * horizontalPitch + subRectangle.left, horizontalPitch, destRect.left + _workingWindow.left, destRect.top + _workingWindow.top, destRect.width(), destRect.height()); } else { uint16 *destBuffer = new uint16[destRect.width() * destRect.height()]; _renderTable.mutateImage((uint16 *)buffer, destBuffer, imageWidth, imageHeight, subRectangle, destRect); - _system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left, destRect.top, destRect.width(), destRect.height()); + // Convert destRect to screen space by adding _workingWindow offest + _system->copyRectToScreen(destBuffer, subRectangle.width() * sizeof(uint16), destRect.left + _workingWindow.left, destRect.top + _workingWindow.top, destRect.width(), destRect.height()); delete[] destBuffer; } } @@ -143,14 +143,20 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint } } -const Common::Point RenderManager::convertToImageCoords(const Common::Point &point) { - Common::Point newPoint(point); +const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) { + // Convert from screen space to working window space + Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top)); if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) { - newPoint = _renderTable.convertWarpedPointToFlatCoords(newPoint); + newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint); } newPoint -= _backgroundOffset; + if (newPoint.x < 0) + newPoint.x += _backgroundWidth; + if (newPoint.y < 0) + newPoint.y += _backgroundHeight; + return newPoint; } diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index aea24505a9..8731675ef6 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -43,13 +43,14 @@ namespace ZVision { class RenderManager { public: - RenderManager(OSystem *system, const int width, const int height); + RenderManager(OSystem *system, const Common::Rect workingWindow); ~RenderManager(); private: OSystem *_system; - const int _width; - const int _height; + const int _workingWidth; + const int _workingHeight; + const Common::Rect _workingWindow; RenderTable _renderTable; Common::SeekableReadStream *_currentBackground; @@ -63,23 +64,23 @@ public: /** * Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame. - * The image will be clipped to fit inside the window. + * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space! * * @param fileName Name of the image file - * @param destinationX X position where the image should be put - * @param destinationY Y position where the image should be put - * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. + * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! + * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! + * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space! */ void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false); /** * Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame. - * The image will be clipped to fit inside the window. + * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space! * * @param stream Stream to read the image data from - * @param destinationX X position where the image should be put - * @param destinationY Y position where the image should be put - * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. + * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! + * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! + * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. Coords are in working window space, not screen space! */ void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0), bool autoCenter = false); @@ -91,7 +92,7 @@ public: */ void setBackgroundImage(const Common::String &fileName); - const Common::Point convertToImageCoords(const Common::Point &point); + const Common::Point screenSpaceToImageSpace(const Common::Point &point); RenderTable *getRenderTable(); diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp index f9637d36a4..5497d0af0c 100644 --- a/engines/zvision/video.cpp +++ b/engines/zvision/video.cpp @@ -80,7 +80,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d // Videos use a different pixel format Common::List<Graphics::PixelFormat> formats; formats.push_back(videoDecoder.getPixelFormat()); - initGraphics(_width, _height, true, formats); + initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, formats); byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel; @@ -113,8 +113,8 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel]; } - uint16 x = ((_width - finalWidth) / 2) + destRect.left; - uint16 y = ((_height - finalHeight) / 2) + destRect.top; + uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left; + uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top; _clock.stop(); videoDecoder.start(); @@ -168,7 +168,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d } // Reset the pixel format to the original state - initGraphics(_width, _height, true, &_pixelFormat); + initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat); } } // End of namespace ZVision diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 7f925e9828..0f6ec14120 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -49,8 +49,7 @@ namespace ZVision { ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), - _width(640), - _height(480), + _workingWindow((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT), _pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /*RGB 555*/ _desiredFrameTime(33), /* ~30 fps */ _clock(_system) { @@ -69,7 +68,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) // Create managers _scriptManager = new ScriptManager(this); - _renderManager = new RenderManager(_system, _width, _height); + _renderManager = new RenderManager(_system, _workingWindow); _cursorManager = new CursorManager(this, &_pixelFormat); debug("ZVision::ZVision"); @@ -115,7 +114,7 @@ void ZVision::initialize() { SearchMan.add(name, archive); } - initGraphics(_width, _height, true, &_pixelFormat); + initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat); _scriptManager->initialize(); // Has to be done after graphics has been initialized diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index bf42bf2621..ca710804b0 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -64,10 +64,19 @@ public: ~ZVision(); private: + enum { + WINDOW_WIDTH = 640, + WINDOW_HEIGHT = 480, + WORKING_WINDOW_WIDTH = 512, + WORKING_WINDOW_HEIGHT = 320, + + ROTATION_SCREEN_EDGE_OFFSET = 60, + MAX_ROTATION_SPEED = 150 // Pixels per second + }; + Console *_console; const ZVisionGameDescription *_gameDescription; - const int _width; - const int _height; + const Common::Rect _workingWindow; const Graphics::PixelFormat _pixelFormat; const int _desiredFrameTime; |