aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-14 23:09:57 -0400
committerPaul Gilbert2016-03-14 23:09:57 -0400
commit3c29a101309b2d74cedf345c2d7314ef82fd9367 (patch)
tree5d7cbe5989fb633459e4b65bdb42a8c9f9f8e7c1 /engines
parent041c6475d6dd86f563dae2e19ae732b16ec34ce6 (diff)
downloadscummvm-rg350-3c29a101309b2d74cedf345c2d7314ef82fd9367.tar.gz
scummvm-rg350-3c29a101309b2d74cedf345c2d7314ef82fd9367.tar.bz2
scummvm-rg350-3c29a101309b2d74cedf345c2d7314ef82fd9367.zip
TITANIC: Further graphics setup, beginnings of files manager
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/direct_draw.cpp29
-rw-r--r--engines/titanic/direct_draw.h13
-rw-r--r--engines/titanic/files_manager.cpp56
-rw-r--r--engines/titanic/files_manager.h61
-rw-r--r--engines/titanic/game_manager.cpp7
-rw-r--r--engines/titanic/game_manager.h4
-rw-r--r--engines/titanic/main_game_window.cpp2
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/screen_manager.cpp2
-rw-r--r--engines/titanic/string.cpp5
-rw-r--r--engines/titanic/string.h5
-rw-r--r--engines/titanic/titanic.cpp3
-rw-r--r--engines/titanic/titanic.h4
-rw-r--r--engines/titanic/video_surface.cpp10
-rw-r--r--engines/titanic/video_surface.h4
15 files changed, 177 insertions, 29 deletions
diff --git a/engines/titanic/direct_draw.cpp b/engines/titanic/direct_draw.cpp
index 9691ea91f4..71f0d35630 100644
--- a/engines/titanic/direct_draw.cpp
+++ b/engines/titanic/direct_draw.cpp
@@ -28,21 +28,18 @@
namespace Titanic {
-DirectDraw::DirectDraw(TitanicEngine *vm) : _vm(vm) {
- _field8 = 0;
- _fieldC = 0;
- _width = 0;
- _height = 0;
- _bpp = 0;
- _numBackSurfaces = 0;
- _field24 = 0;
+DirectDraw::DirectDraw(TitanicEngine *vm) : _vm(vm),
+ _windowed(false), _fieldC(0), _width(0), _height(0),
+ _bpp(0), _numBackSurfaces(0), _field24(0) {
}
void DirectDraw::setDisplayMode(int width, int height, int bpp, int refreshRate) {
debugC(ERROR_BASIC, kDebugGraphics, "DirectDraw::SetDisplayMode (%d x %d), %d bpp",
width, height, bpp);
- assert(bpp == 8);
- initGraphics(width, height, true);
+ assert(bpp == 16);
+
+ Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+ initGraphics(width, height, true, &pixelFormat);
}
void DirectDraw::diagnostics() {
@@ -58,10 +55,10 @@ DirectDrawSurface *DirectDraw::createSurfaceFromDesc(const DDSurfaceDesc &desc)
/*------------------------------------------------------------------------*/
-DirectDrawManager::DirectDrawManager(TitanicEngine *vm, int v) : _directDraw(vm) {
+DirectDrawManager::DirectDrawManager(TitanicEngine *vm, bool windowed) : _directDraw(vm) {
_mainSurface = nullptr;
_backSurfaces[0] = _backSurfaces[1] = nullptr;
- _directDraw._field8 = v;
+ _directDraw._windowed = windowed;
}
void DirectDrawManager::initVideo(int width, int height, int bpp, int numBackSurfaces) {
@@ -71,10 +68,10 @@ void DirectDrawManager::initVideo(int width, int height, int bpp, int numBackSur
_directDraw._height = height;
_directDraw._bpp = bpp;
- if (numBackSurfaces) {
- setResolution();
+ if (_directDraw._windowed) {
+ initWindowed();
} else {
- initSurface();
+ initFullScreen();
}
}
@@ -90,7 +87,7 @@ void DirectDrawManager::proc3() {
}
-void DirectDrawManager::initSurface() {
+void DirectDrawManager::initFullScreen() {
debugC(ERROR_BASIC, kDebugGraphics, "Creating surfaces");
_directDraw.setDisplayMode(_directDraw._width, _directDraw._height,
_directDraw._bpp, 0);
diff --git a/engines/titanic/direct_draw.h b/engines/titanic/direct_draw.h
index 728094e7f7..6dedcd0e52 100644
--- a/engines/titanic/direct_draw.h
+++ b/engines/titanic/direct_draw.h
@@ -47,7 +47,7 @@ class DirectDraw {
private:
TitanicEngine *_vm;
public:
- int _field8;
+ bool _windowed;
int _fieldC;
int _width;
int _height;
@@ -79,7 +79,7 @@ public:
DirectDrawSurface *_mainSurface;
DirectDrawSurface *_backSurfaces[2];
public:
- DirectDrawManager(TitanicEngine *vm, int v);
+ DirectDrawManager(TitanicEngine *vm, bool windowed);
/**
* Initializes video surfaces
@@ -97,9 +97,14 @@ public:
void proc3();
/**
- * Initializes the surface for the screen
+ * Initializes the surfaces in windowed mode
*/
- void initSurface();
+ void initWindowed() { initFullScreen(); }
+
+ /**
+ * Initializes the surfaces for the screen
+ */
+ void initFullScreen();
/**
* Create a surface
diff --git a/engines/titanic/files_manager.cpp b/engines/titanic/files_manager.cpp
new file mode 100644
index 0000000000..4dcee2e062
--- /dev/null
+++ b/engines/titanic/files_manager.cpp
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/files_manager.h"
+#include "titanic/game_manager.h"
+
+namespace Titanic {
+
+CFilesManager::CFilesManager() : _gameManager(nullptr),
+ _field0(0), _field14(0), _field18(0), _field1C(0), _field3C(0) {
+}
+
+int CFilesManager::fn1(const CString &name) {
+ if (name.empty())
+ return 0;
+
+ CString str = name;
+ str.toLowercase();
+
+ if (str[0] == 'z' || str[0] == 'y') {
+ return 1;
+ } else if (str[0] < 'a' || str[0] > 'c') {
+ return 0;
+ }
+
+ CString tempStr = str;
+ int idx = tempStr.indexOf('#');
+ if (idx >= 0) {
+ tempStr = tempStr.left(idx);
+ str = str.c_str() + idx + 1;
+ str += ".st";
+ }
+
+ return 0;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/files_manager.h b/engines/titanic/files_manager.h
new file mode 100644
index 0000000000..29a67e6605
--- /dev/null
+++ b/engines/titanic/files_manager.h
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_FILES_MANAGER_H
+#define TITANIC_FILES_MANAGER_H
+
+#include "titanic/core/list.h"
+
+namespace Titanic {
+
+class CGameManager;
+
+class CFilesManagerList : public List<ListItem> {
+};
+
+class CFilesManager {
+private:
+ CGameManager *_gameManager;
+ CFilesManagerList _list;
+ CString _string1;
+ CString _string2;
+ int _field0;
+ int _field14;
+ int _field18;
+ int _field1C;
+ int _field3C;
+public:
+ CFilesManager();
+
+ /**
+ * Sets the game manager
+ */
+ void setGameManager(CGameManager *gameManager) {
+ _gameManager = gameManager;
+ }
+
+ int fn1(const CString &name);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_FILES_MANAGER_H */
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index 0495d08dbd..2f718626e9 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -47,10 +47,13 @@ CGameManager::CGameManager(CProjectItem *project, CGameView *gameView):
_project(project), _gameView(gameView), _trueTalkManager(this),
_inputHandler(this), _inputTranslator(&_inputHandler),
_gameState(this), _sound(this), _musicRoom(this),
- _field30(0), _field34(0), _field48(0), _field4C(0),
+ _field30(0), _field34(0), _field4C(0),
_field50(0), _field54(0), _tickCount1(0), _tickCount2(0) {
- _videoSurface = CScreenManager::_screenManagerPtr->createSurface(600, 340);
+
+ _videoSurface1 = nullptr;
+ _videoSurface2 = CScreenManager::_screenManagerPtr->createSurface(600, 340);
_project->setGameManager(this);
+ g_vm->_filesManager.setGameManager(this);
}
void CGameManager::load(SimpleFile *file) {
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index a9bdaaa71f..82ab6d1e3b 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -62,11 +62,11 @@ private:
CGameManagerList _list;
int _field30;
int _field34;
- int _field48;
+ CVideoSurface *_videoSurface1;
int _field4C;
int _field50;
int _field54;
- CVideoSurface *_videoSurface;
+ CVideoSurface *_videoSurface2;
uint _tickCount1;
uint _tickCount2;
public:
diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp
index 01996e6b13..e9fb423bd1 100644
--- a/engines/titanic/main_game_window.cpp
+++ b/engines/titanic/main_game_window.cpp
@@ -54,7 +54,7 @@ void CMainGameWindow::applicationStarting() {
// Set the video mode
CScreenManager *screenManager = CScreenManager::setCurrent();
- screenManager->setMode(640, 480, 1, 1, false);
+ screenManager->setMode(640, 480, 16, 1, true);
// TODO: Clear surfaces
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 48f6ce640b..664dc0a3e5 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/titanic
MODULE_OBJS := \
detection.o \
direct_draw.o \
+ files_manager.o \
font.o \
game_location.o \
game_manager.o \
diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp
index ebde0e0a6c..e2d62bec54 100644
--- a/engines/titanic/screen_manager.cpp
+++ b/engines/titanic/screen_manager.cpp
@@ -74,7 +74,7 @@ CScreenManager *CScreenManager::setCurrent() {
/*------------------------------------------------------------------------*/
OSScreenManager::OSScreenManager(TitanicEngine *vm): CScreenManager(vm),
- _directDrawManager(vm, 0) {
+ _directDrawManager(vm, false) {
_field48 = 0;
_field4C = 0;
_field50 = 0;
diff --git a/engines/titanic/string.cpp b/engines/titanic/string.cpp
index 128a9a38eb..f726f78c21 100644
--- a/engines/titanic/string.cpp
+++ b/engines/titanic/string.cpp
@@ -40,4 +40,9 @@ CString CString::mid(uint start, uint count) const {
return CString(c_str() + start, MIN(count, size() - start));
}
+int CString::indexOf(char c) {
+ const char *charP = strchr(c_str(), c);
+ return charP ? charP - c_str() : -1;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/string.h b/engines/titanic/string.h
index 076cce05a2..de442647ca 100644
--- a/engines/titanic/string.h
+++ b/engines/titanic/string.h
@@ -51,6 +51,11 @@ public:
* Returns a substring from within the string
*/
CString mid(uint start, uint count) const;
+
+ /**
+ * Returns the index of the first occurance of a given character
+ */
+ int indexOf(char c);
};
} // End of namespace Titanic
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index b00e1c3088..d1d8386228 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -40,8 +40,11 @@
namespace Titanic {
+TitanicEngine *g_vm;
+
TitanicEngine::TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDesc)
: _gameDescription(gameDesc), Engine(syst) {
+ g_vm = this;
_window = nullptr;
_screenManager = nullptr;
}
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index ad0ed75165..9513f8d759 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -28,6 +28,7 @@
#include "common/serializer.h"
#include "engines/advancedDetector.h"
#include "engines/engine.h"
+#include "titanic/files_manager.h"
#include "titanic/screen_manager.h"
#include "titanic/main_game_window.h"
@@ -93,6 +94,7 @@ protected:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
public:
+ CFilesManager _filesManager;
OSScreenManager *_screenManager;
CMainGameWindow *_window;
public:
@@ -104,6 +106,8 @@ public:
Common::Language getLanguage() const;
};
+extern TitanicEngine *g_vm;
+
} // End of namespace Titanic
#endif /* TITANIC_TITANIC_H */
diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp
index 780ea2bc9e..c7643cf656 100644
--- a/engines/titanic/video_surface.cpp
+++ b/engines/titanic/video_surface.cpp
@@ -59,7 +59,15 @@ OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, const CResourceKey
}
void OSVideoSurface::proc8(const CResourceKey &key) {
- warning("TODO");
+ _resourceKey = key;
+ _field38 = 1;
+
+ if (hasSurface())
+ proc43();
+}
+
+bool OSVideoSurface::hasSurface() {
+ return _surface != nullptr;
}
void OSVideoSurface::proc43() {
diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h
index 04d9fa8c58..71a2fd668c 100644
--- a/engines/titanic/video_surface.h
+++ b/engines/titanic/video_surface.h
@@ -57,7 +57,7 @@ public:
void setSurface(CScreenManager *screenManager, DirectDrawSurface *surface);
virtual void proc8(const CResourceKey &key) = 0;
-
+ virtual bool hasSurface() = 0;
virtual void proc43() = 0;
};
@@ -67,7 +67,7 @@ public:
OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool flag = false);
virtual void proc8(const CResourceKey &key);
-
+ virtual bool hasSurface();
virtual void proc43();
};