aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/render_manager.cpp12
-rw-r--r--engines/zvision/render_manager.h4
-rw-r--r--engines/zvision/render_table.cpp17
-rw-r--r--engines/zvision/render_table.h3
4 files changed, 35 insertions, 1 deletions
diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp
index 132c597140..2d45ad835d 100644
--- a/engines/zvision/render_manager.cpp
+++ b/engines/zvision/render_manager.cpp
@@ -80,6 +80,8 @@ void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uin
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());
} else {
@@ -139,7 +141,17 @@ void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint
tga.destroy();
}
+}
+
+const Common::Point RenderManager::convertToImageCoords(const Common::Point &point) {
+ Common::Point newPoint(point);
+
+ if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) {
+ newPoint = _renderTable.convertWarpedPointToFlatCoords(newPoint);
+ }
+ newPoint -= _backgroundOffset;
+ return newPoint;
}
RenderTable *RenderManager::getRenderTable() {
diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h
index 6e267eb395..aea24505a9 100644
--- a/engines/zvision/render_manager.h
+++ b/engines/zvision/render_manager.h
@@ -53,6 +53,7 @@ private:
RenderTable _renderTable;
Common::SeekableReadStream *_currentBackground;
+ Common::Point _backgroundOffset;
Video::VideoDecoder *_currentVideo;
byte *_scaledVideoFrameBuffer;
@@ -90,8 +91,9 @@ public:
*/
void setBackgroundImage(const Common::String &fileName);
- RenderTable *getRenderTable();
+ const Common::Point convertToImageCoords(const Common::Point &point);
+ RenderTable *getRenderTable();
private:
void renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle, bool autoCenter);
diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp
index b6598c12b2..2a111ce659 100644
--- a/engines/zvision/render_table.cpp
+++ b/engines/zvision/render_table.cpp
@@ -60,6 +60,16 @@ void RenderTable::setRenderState(RenderState newState) {
}
}
+const Common::Point RenderTable::convertWarpedPointToFlatCoords(const Common::Point &point) {
+ uint32 index = point.y * _numColumns + point.x;
+
+ Common::Point newPoint(point);
+ newPoint.x += _internalBuffer[index].x;
+ newPoint.y += _internalBuffer[index].y;
+
+ return newPoint;
+}
+
uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) {
assert(percentColorOne < 1.0f);
@@ -157,7 +167,14 @@ void RenderTable::generatePanoramaLookupTable() {
}
void RenderTable::generateTiltLookupTable() {
+ for (uint x = 0; x < _numColumns; x++) {
+ for (uint y = 0; y < _numRows; y++) {
+ uint32 index = y * _numColumns + x;
+ _internalBuffer[index].x = 0;
+ _internalBuffer[index].y = 0;
+ }
+ }
}
void RenderTable::setPanoramaFoV(float fov) {
diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h
index 82bea62769..5cef062045 100644
--- a/engines/zvision/render_table.h
+++ b/engines/zvision/render_table.h
@@ -63,6 +63,9 @@ private:
public:
RenderState getRenderState() { return _renderState; }
void setRenderState(RenderState newState);
+
+ const Common::Point convertWarpedPointToFlatCoords(const Common::Point &point);
+
void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 imageWidth, uint32 imageHeight, Common::Rect subRectangle, Common::Rect destRectangle);
void generateRenderTable();