aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-02 08:52:07 -0400
committerPaul Gilbert2016-04-02 08:52:07 -0400
commit5795ec0c9712c48912842570ef4c2bf70f793c91 (patch)
treed6651735b363a5ac6df087de1c42bc573774f49a
parent1b8ffff10e164d1fe7c03ef9a35aeb8f7ca3c5e5 (diff)
downloadscummvm-rg350-5795ec0c9712c48912842570ef4c2bf70f793c91.tar.gz
scummvm-rg350-5795ec0c9712c48912842570ef4c2bf70f793c91.tar.bz2
scummvm-rg350-5795ec0c9712c48912842570ef4c2bf70f793c91.zip
TITANIC: Implemented ScreenManager fillRect
-rw-r--r--engines/titanic/direct_draw_surface.cpp7
-rw-r--r--engines/titanic/direct_draw_surface.h5
-rw-r--r--engines/titanic/pet_control/pet_control_sub12.cpp6
-rw-r--r--engines/titanic/screen_manager.cpp34
-rw-r--r--engines/titanic/screen_manager.h17
5 files changed, 64 insertions, 5 deletions
diff --git a/engines/titanic/direct_draw_surface.cpp b/engines/titanic/direct_draw_surface.cpp
index b432245333..05fe68a347 100644
--- a/engines/titanic/direct_draw_surface.cpp
+++ b/engines/titanic/direct_draw_surface.cpp
@@ -78,6 +78,13 @@ void DirectDrawSurface::fill(const Rect *bounds, uint32 color) {
_surface->fillRect(tempBounds, color);
}
+void DirectDrawSurface::fillRect(Rect *rect, byte r, byte g, byte b) {
+ uint color = _surface->format.RGBToColor(r, g, b);
+ Rect tempRect = rect ? *rect : Rect(0, 0, getWidth(), getHeight());
+
+ _surface->fillRect(tempRect, color);
+}
+
void DirectDrawSurface::blit(const Rect &destRect, DirectDrawSurface *srcSurface, Rect &srcRect) {
assert(srcSurface);
if (!destRect.isEmpty())
diff --git a/engines/titanic/direct_draw_surface.h b/engines/titanic/direct_draw_surface.h
index dfcdccb48c..28ff6a8ae6 100644
--- a/engines/titanic/direct_draw_surface.h
+++ b/engines/titanic/direct_draw_surface.h
@@ -101,6 +101,11 @@ public:
void fill(const Rect *bounds, uint32 color);
/**
+ * Fill an area with a specific color
+ */
+ void fillRect(Rect *rect, byte r, byte g, byte b);
+
+ /**
* Copy data from a source surfcae into this one
*/
void blit(const Rect &destRect, DirectDrawSurface *srcSurface, Rect &srcRect);
diff --git a/engines/titanic/pet_control/pet_control_sub12.cpp b/engines/titanic/pet_control/pet_control_sub12.cpp
index 44335f3b5a..79a53ecb8d 100644
--- a/engines/titanic/pet_control/pet_control_sub12.cpp
+++ b/engines/titanic/pet_control/pet_control_sub12.cpp
@@ -106,6 +106,12 @@ void CPetControlSub12::load(SimpleFile *file, int param) {
}
void CPetControlSub12::draw(CScreenManager *screenManager) {
+ Rect tempRect = _bounds;
+
+ if (_field70) {
+
+ }
+
warning("TODO: CPetControlSub12::draw");
}
diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp
index 5e38eca2d8..f74c97bafb 100644
--- a/engines/titanic/screen_manager.cpp
+++ b/engines/titanic/screen_manager.cpp
@@ -113,11 +113,20 @@ void OSScreenManager::drawCursors() {
warning("OSScreenManager::drawCursors");
}
+DirectDrawSurface *OSScreenManager::getDDSurface(SurfaceNum surfaceNum) {
+ if (surfaceNum == SURFACE_PRIMARY)
+ return _directDrawManager._mainSurface;
+ else if (surfaceNum < (int)_backSurfaces.size())
+ return _directDrawManager._backSurfaces[surfaceNum];
+ else
+ return nullptr;
+}
+
void OSScreenManager::proc6() {}
void OSScreenManager::proc7() {}
CVideoSurface *OSScreenManager::getSurface(SurfaceNum surfaceNum) const {
- if (surfaceNum == -1)
+ if (surfaceNum == SURFACE_PRIMARY)
return _frontRenderSurface;
else if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size())
return _backSurfaces[surfaceNum]._surface;
@@ -126,7 +135,26 @@ CVideoSurface *OSScreenManager::getSurface(SurfaceNum surfaceNum) const {
}
void OSScreenManager::proc9() {}
-void OSScreenManager::proc10() {}
+
+void OSScreenManager::fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) {
+ DirectDrawSurface *surface = getDDSurface(surfaceNum);
+ if (!surface)
+ return;
+
+ // If bounds are provided, clip and use them. Otherwise, use entire surface area
+ Rect surfaceRect(0, 0, surface->getWidth(), surface->getHeight());
+ Rect tempRect;
+
+ if (rect) {
+ tempRect = *rect;
+ tempRect.clip(surfaceRect);
+ } else {
+ tempRect = surfaceRect;
+ }
+
+ if (tempRect.isValidRect())
+ surface->fillRect(&tempRect, r, g, b);
+}
void OSScreenManager::blitFrom(SurfaceNum surfaceNum, CVideoSurface *src,
const Point *destPos, const Rect *srcRect) {
@@ -176,7 +204,7 @@ void OSScreenManager::proc18() {}
void OSScreenManager::proc19() {}
void OSScreenManager::clearSurface(SurfaceNum surfaceNum, Rect *bounds) {
- if (surfaceNum == -1)
+ if (surfaceNum == SURFACE_PRIMARY)
_directDrawManager._mainSurface->fill(bounds, 0);
else if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size())
_directDrawManager._backSurfaces[surfaceNum]->fill(bounds, 0);
diff --git a/engines/titanic/screen_manager.h b/engines/titanic/screen_manager.h
index 1b926fc3c6..8ca17525a1 100644
--- a/engines/titanic/screen_manager.h
+++ b/engines/titanic/screen_manager.h
@@ -93,7 +93,11 @@ public:
virtual void proc7() = 0;
virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const = 0;
virtual void proc9() = 0;
- virtual void proc10() = 0;
+
+ /**
+ * Fill an area with a specific color
+ */
+ virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) = 0;
/**
* Blits a surface onto one of the screen surfaces
@@ -151,6 +155,11 @@ private:
* Load game cursors
*/
void loadCursors();
+
+ /**
+ * Gets an underlying surface
+ */
+ DirectDrawSurface *getDDSurface(SurfaceNum surfaceNum);
public:
int _field48;
int _field4C;
@@ -175,7 +184,11 @@ public:
virtual void proc7();
virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const;
virtual void proc9();
- virtual void proc10();
+
+ /**
+ * Fill an area with a specific color
+ */
+ virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b);
/**
* Blits a surface onto one of the screen surfaces