aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-14 20:03:32 -0400
committerPaul Gilbert2016-03-14 20:03:32 -0400
commit041c6475d6dd86f563dae2e19ae732b16ec34ce6 (patch)
tree46185ff36aabbc817e7be3b7b76e00d6ecc4edfd
parentbc1585ccee0fe156a4f6d2e6e721c606ac6dd8a9 (diff)
downloadscummvm-rg350-041c6475d6dd86f563dae2e19ae732b16ec34ce6.tar.gz
scummvm-rg350-041c6475d6dd86f563dae2e19ae732b16ec34ce6.tar.bz2
scummvm-rg350-041c6475d6dd86f563dae2e19ae732b16ec34ce6.zip
TITANIC: Fleshed out DirectDrawSurface creation
-rw-r--r--engines/titanic/core/game_object.cpp4
-rw-r--r--engines/titanic/core/game_object.h2
-rw-r--r--engines/titanic/direct_draw.cpp20
-rw-r--r--engines/titanic/direct_draw.h26
-rw-r--r--engines/titanic/game_location.cpp21
-rw-r--r--engines/titanic/game_location.h5
-rw-r--r--engines/titanic/screen_manager.cpp8
-rw-r--r--engines/titanic/screen_manager.h24
-rw-r--r--engines/titanic/true_talk/tt_named_script.cpp1
-rw-r--r--engines/titanic/video_surface.cpp37
-rw-r--r--engines/titanic/video_surface.h36
11 files changed, 166 insertions, 18 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 3238258a61..f5e9806365 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -118,4 +118,8 @@ void CGameObject::load(SimpleFile *file) {
CNamedItem::load(file);
}
+void CGameObject::fn2() {
+ error("TODO");
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 3809ae38d0..c284fb4ebe 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -71,6 +71,8 @@ public:
* Load the data for the class from file
*/
virtual void load(SimpleFile *file);
+
+ void fn2();
};
} // End of namespace Titanic
diff --git a/engines/titanic/direct_draw.cpp b/engines/titanic/direct_draw.cpp
index d503938fe4..9691ea91f4 100644
--- a/engines/titanic/direct_draw.cpp
+++ b/engines/titanic/direct_draw.cpp
@@ -22,6 +22,7 @@
#include "common/debug.h"
#include "engines/util.h"
+#include "graphics/pixelformat.h"
#include "titanic/titanic.h"
#include "titanic/direct_draw.h"
@@ -48,6 +49,13 @@ void DirectDraw::diagnostics() {
debugC(ERROR_BASIC, kDebugGraphics, "Running DirectDraw Diagnostic...");
}
+DirectDrawSurface *DirectDraw::createSurfaceFromDesc(const DDSurfaceDesc &desc) {
+ DirectDrawSurface *surface = new DirectDrawSurface();
+ surface->create(desc._w, desc._h, Graphics::PixelFormat::createFormatCLUT8());
+
+ return surface;
+}
+
/*------------------------------------------------------------------------*/
DirectDrawManager::DirectDrawManager(TitanicEngine *vm, int v) : _directDraw(vm) {
@@ -87,12 +95,20 @@ void DirectDrawManager::initSurface() {
_directDraw.setDisplayMode(_directDraw._width, _directDraw._height,
_directDraw._bpp, 0);
- _mainSurface = new Graphics::Surface();
+ _mainSurface = new DirectDrawSurface();
_mainSurface->create(_directDraw._width, _directDraw._height,
Graphics::PixelFormat::createFormatCLUT8());
- _backSurfaces[0] = new Graphics::Surface();
+ _backSurfaces[0] = new DirectDrawSurface();
_backSurfaces[0]->create(_directDraw._width, _directDraw._height,
Graphics::PixelFormat::createFormatCLUT8());
}
+DirectDrawSurface *DirectDrawManager::createSurface(int w, int h, int surfaceNum) {
+ if (surfaceNum)
+ return nullptr;
+
+ assert(_mainSurface);
+ return _directDraw.createSurfaceFromDesc(DDSurfaceDesc(w, h));
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/direct_draw.h b/engines/titanic/direct_draw.h
index cb49efa513..728094e7f7 100644
--- a/engines/titanic/direct_draw.h
+++ b/engines/titanic/direct_draw.h
@@ -31,6 +31,18 @@ namespace Titanic {
class TitanicEngine;
+struct DDSurfaceDesc {
+ int _w;
+ int _h;
+ int _flags;
+ int _caps;
+
+ DDSurfaceDesc(int w, int h) : _w(w), _h(h), _flags(0x1006), _caps(64) {}
+};
+
+class DirectDrawSurface : public Graphics::Surface {
+};
+
class DirectDraw {
private:
TitanicEngine *_vm;
@@ -54,13 +66,18 @@ public:
* Logs diagnostic information
*/
void diagnostics();
+
+ /**
+ * Create a surface from a passed description record
+ */
+ DirectDrawSurface *createSurfaceFromDesc(const DDSurfaceDesc &desc);
};
class DirectDrawManager {
public:
DirectDraw _directDraw;
- Graphics::Surface *_mainSurface;
- Graphics::Surface *_backSurfaces[2];
+ DirectDrawSurface *_mainSurface;
+ DirectDrawSurface *_backSurfaces[2];
public:
DirectDrawManager(TitanicEngine *vm, int v);
@@ -83,6 +100,11 @@ public:
* Initializes the surface for the screen
*/
void initSurface();
+
+ /**
+ * Create a surface
+ */
+ DirectDrawSurface *createSurface(int w, int h, int surfaceNum);
};
} // End of namespace Titanic
diff --git a/engines/titanic/game_location.cpp b/engines/titanic/game_location.cpp
index 5f87d3bc67..2a01bbf248 100644
--- a/engines/titanic/game_location.cpp
+++ b/engines/titanic/game_location.cpp
@@ -23,6 +23,7 @@
#include "titanic/game_location.h"
#include "titanic/game_manager.h"
#include "titanic/game_state.h"
+#include "titanic/core/game_object.h"
#include "titanic/core/project_item.h"
namespace Titanic {
@@ -49,6 +50,26 @@ void CGameLocation::load(SimpleFile *file) {
_viewNumber = file->readNumber();
}
+void CGameLocation::setView(CViewItem *view) {
+ if (_view) {
+ for (CTreeItem *treeItem = view; treeItem;
+ treeItem = treeItem->scan(_view)) {
+ CGameObject *obj = dynamic_cast<CGameObject *>(treeItem);
+ if (obj)
+ obj->fn2();
+ }
+ }
+
+ _view = view;
+ if (_view) {
+ _viewNumber = _view->_viewNumber;
+ _nodeNumber = _view->findNode()->_nodeNumber;
+ _roomNumber = _view->findRoom()->_roomNumber;
+ } else {
+ _viewNumber = _nodeNumber = _roomNumber = -1;
+ }
+}
+
CViewItem *CGameLocation::getView() {
if (!_view) {
CGameManager *gm = _gameState->_gameManager;
diff --git a/engines/titanic/game_location.h b/engines/titanic/game_location.h
index 94cea799e8..a64a82403b 100644
--- a/engines/titanic/game_location.h
+++ b/engines/titanic/game_location.h
@@ -54,6 +54,11 @@ public:
void load(SimpleFile *file);
/**
+ * Set the current view
+ */
+ void setView(CViewItem *view);
+
+ /**
* Get the current view
*/
CViewItem *getView();
diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp
index 47e5d3d49a..ebde0e0a6c 100644
--- a/engines/titanic/screen_manager.cpp
+++ b/engines/titanic/screen_manager.cpp
@@ -126,8 +126,12 @@ void OSScreenManager::proc20() {}
void OSScreenManager::proc21() {}
CVideoSurface *OSScreenManager::createSurface(int w, int h) {
- warning("TODO");
- return nullptr;
+ DirectDrawSurface *ddSurface = _directDrawManager.createSurface(w, h, 0);
+ return new OSVideoSurface(this, ddSurface);
+}
+
+CVideoSurface *OSScreenManager::createSurface(const CResourceKey &key) {
+ return new OSVideoSurface(this, key);
}
void OSScreenManager::proc23() {}
diff --git a/engines/titanic/screen_manager.h b/engines/titanic/screen_manager.h
index d0bcc5dbd8..0fd6bfad8b 100644
--- a/engines/titanic/screen_manager.h
+++ b/engines/titanic/screen_manager.h
@@ -29,6 +29,7 @@
#include "titanic/font.h"
#include "titanic/input_handler.h"
#include "titanic/video_surface.h"
+#include "titanic/core/resource_key.h"
namespace Titanic {
@@ -78,6 +79,8 @@ public:
void fn1() {}
void fn2() {}
+
+
virtual void setWindowHandle(int v);
virtual bool resetWindowHandle(int v);
virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2) = 0;
@@ -98,8 +101,17 @@ public:
virtual void proc19() = 0;
virtual void proc20() = 0;
virtual void proc21() = 0;
+
+ /**
+ * Creates a surface of a given size
+ */
virtual CVideoSurface *createSurface(int w, int h) = 0;
- virtual void proc23() = 0;
+
+ /**
+ * Creates a surface from a specified resource
+ */
+ virtual CVideoSurface *createSurface(const CResourceKey &key) = 0;
+
virtual void proc24() = 0;
virtual void proc25() = 0;
virtual void showCursor() = 0;
@@ -147,7 +159,17 @@ public:
virtual void proc19();
virtual void proc20();
virtual void proc21();
+
+ /**
+ * Creates a surface of a given size
+ */
virtual CVideoSurface *createSurface(int w, int h);
+
+ /**
+ * Creates a surface from a specified resource
+ */
+ virtual CVideoSurface *createSurface(const CResourceKey &key);
+
virtual void proc23();
virtual void proc24();
virtual void proc25();
diff --git a/engines/titanic/true_talk/tt_named_script.cpp b/engines/titanic/true_talk/tt_named_script.cpp
index 89adb16702..7f4bb5b201 100644
--- a/engines/titanic/true_talk/tt_named_script.cpp
+++ b/engines/titanic/true_talk/tt_named_script.cpp
@@ -93,6 +93,7 @@ int TTNamedScript::proc12() const {
bool TTNamedScript::proc13() const {
warning("TODO");
+ return true;
}
void TTNamedScript::proc14(int v) {
diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp
index d03e2f4525..780ea2bc9e 100644
--- a/engines/titanic/video_surface.cpp
+++ b/engines/titanic/video_surface.cpp
@@ -24,19 +24,46 @@
namespace Titanic {
-CVideoSurface::CVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface):
- _screenManager(screenManager), _surface(surface) {
+int CVideoSurface::_videoSurfaceCounter = 0;
+
+CVideoSurface::CVideoSurface(CScreenManager *screenManager) :
+ _screenManager(screenManager), _field2C(0),
+ _field34(0), _field38(0), _field3C(0), _field40(0),
+ _field44(4), _field48(0), _field50(1) {
+ _videoSurfaceNum = _videoSurfaceCounter++;
}
-void CVideoSurface::setSurface(CScreenManager *screenManager, Graphics::Surface *surface) {
+void CVideoSurface::setSurface(CScreenManager *screenManager, DirectDrawSurface *surface) {
_screenManager = screenManager;
_surface = surface;
}
/*------------------------------------------------------------------------*/
-OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface):
- CVideoSurface(screenManager, surface) {
+OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface) :
+ CVideoSurface(screenManager) {
+ _surface = surface;
+}
+
+OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool flag) :
+ CVideoSurface(screenManager) {
+ _surface = nullptr;
+ _field38 = flag;
+
+ if (_field38) {
+ proc8(key);
+ } else {
+ _resourceKey = key;
+ proc43();
+ }
+}
+
+void OSVideoSurface::proc8(const CResourceKey &key) {
+ warning("TODO");
+}
+
+void OSVideoSurface::proc43() {
+ warning("TODO");
}
} // End of namespace Titanic
diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h
index 978eacfbbe..04d9fa8c58 100644
--- a/engines/titanic/video_surface.h
+++ b/engines/titanic/video_surface.h
@@ -25,26 +25,50 @@
#include "common/scummsys.h"
#include "common/array.h"
-#include "graphics/surface.h"
#include "titanic/font.h"
+#include "titanic/direct_draw.h"
+#include "titanic/core/list.h"
+#include "titanic/core/resource_key.h"
namespace Titanic {
class CScreenManager;
-class CVideoSurface {
+class CVideoSurface : public ListItem {
private:
+ static int _videoSurfaceCounter;
+protected:
CScreenManager *_screenManager;
- Graphics::Surface *_surface;
+ CResourceKey _resourceKey;
+ DirectDrawSurface *_surface;
+ int _field2C;
+ int _field34;
+ bool _field38;
+ int _field3C;
+ int _field40;
+ int _field44;
+ int _field48;
+ int _videoSurfaceNum;
+ int _field50;
+ int _accessCtr;
public:
- CVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface);
+ CVideoSurface(CScreenManager *screenManager);
- void setSurface(CScreenManager *screenManager, Graphics::Surface *surface);
+ void setSurface(CScreenManager *screenManager, DirectDrawSurface *surface);
+
+ virtual void proc8(const CResourceKey &key) = 0;
+
+ virtual void proc43() = 0;
};
class OSVideoSurface : public CVideoSurface {
public:
- OSVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface);
+ OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface);
+ OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool flag = false);
+
+ virtual void proc8(const CResourceKey &key);
+
+ virtual void proc43();
};
} // End of namespace Titanic