diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/module.mk | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control.cpp | 9 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control.h | 9 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub12.h | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub16.cpp | 74 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub16.h | 57 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.cpp (renamed from engines/titanic/star_control/star_control_sub11.cpp) | 26 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.h (renamed from engines/titanic/star_control/star_control_sub11.h) | 18 |
8 files changed, 184 insertions, 17 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 7138f57464..71df87d9cf 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -427,11 +427,13 @@ MODULE_OBJS := \ star_control/star_control_sub8.o \ star_control/star_control_sub9.o \ star_control/star_control_sub10.o \ - star_control/star_control_sub11.o \ + star_control/star_view.o \ star_control/star_control_sub12.o \ star_control/star_control_sub13.o \ star_control/star_control_sub14.o \ star_control/star_control_sub15.o \ + star_control/star_control_sub16.o \ + star_control/surface_obj.o \ support/direct_draw.o \ support/direct_draw_surface.o \ support/exe_resources.o \ diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index d8b7d1206c..aa65781e93 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -31,6 +31,8 @@ CStarControl::CStarControl() : _fieldBC(0), _field80B0(0), void CStarControl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); + _sub1.save(file, indent); + _view.save(file, indent); CGameObject::save(file, indent); } @@ -42,7 +44,7 @@ void CStarControl::load(SimpleFile *file) { if (!_sub1.initDocument()) error("Couldn't initialise the StarField document"); - _sub11.load(file, 0); + _view.load(file, 0); CScreenManager *screenManager = CScreenManager::setCurrent(); if (!screenManager) error("There's no screen manager during loading"); @@ -53,6 +55,11 @@ void CStarControl::load(SimpleFile *file) { CGameObject::load(file); } +void CStarControl::draw(CScreenManager *screenManager) { + if (_visible) + _view.draw(screenManager); +} + void CStarControl::fn3() { warning("CStarControl::fn3"); } diff --git a/engines/titanic/star_control/star_control.h b/engines/titanic/star_control/star_control.h index be8ee752cf..c653e8ef7b 100644 --- a/engines/titanic/star_control/star_control.h +++ b/engines/titanic/star_control/star_control.h @@ -25,7 +25,7 @@ #include "titanic/core/game_object.h" #include "titanic/star_control/star_control_sub1.h" -#include "titanic/star_control/star_control_sub11.h" +#include "titanic/star_control/star_view.h" namespace Titanic { @@ -33,7 +33,7 @@ class CStarControl : public CGameObject { private: int _fieldBC; CStarControlSub1 _sub1; - CStarControlSub11 _sub11; + CStarView _view; Rect _starRect; int _field80B0; public: @@ -50,6 +50,11 @@ public: */ virtual void load(SimpleFile *file); + /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager); + void fn1(int v); void fn3(); void fn4(); diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h index bce668f863..e053aefb84 100644 --- a/engines/titanic/star_control/star_control_sub12.h +++ b/engines/titanic/star_control/star_control_sub12.h @@ -50,12 +50,12 @@ public: /** * Load the data for the class from file */ - void load(SimpleFile *file, int param); + virtual void load(SimpleFile *file, int param); /** * Save the data for the class to file */ - void save(SimpleFile *file, int indent); + virtual void save(SimpleFile *file, int indent); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub16.cpp b/engines/titanic/star_control/star_control_sub16.cpp new file mode 100644 index 0000000000..1465ac6a3e --- /dev/null +++ b/engines/titanic/star_control/star_control_sub16.cpp @@ -0,0 +1,74 @@ +/* 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/star_control/star_control_sub16.h" + +namespace Titanic { + +CStarControlSub16::CStarControlSub16() : _field4(-1), _field8(32), + _videoSurface(nullptr) { +} + +void CStarControlSub16::reset() { + _field4 = 0; +} + +bool CStarControlSub16::setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface) { + int width = srcSurface->getWidth(); + int height = srcSurface->getHeight(); + + if (_videoSurface) { + if (width == _videoSurface->getWidth() && _videoSurface->getHeight()) + // Allocated surface already matches new size + return true; + + // Different sizes, so delete old surface + delete _videoSurface; + } + + _videoSurface = screenManager->createSurface(width, height); + return true; +} + +CVideoSurface *CStarControlSub16::loadSurface(CScreenManager *screenManager, CVideoSurface *srcSurface) { + if (_field4 < 0 || _field4 >= _field8) + return srcSurface; + + if (!_field8 && !setupSurface(screenManager, srcSurface)) + return nullptr; + + srcSurface->lock(); + _videoSurface->lock(); + CSurfaceObj srcSurfaceObj(srcSurface); + CSurfaceObj destSurfaceObj(_videoSurface); + + proc4(srcSurfaceObj, destSurfaceObj); + + srcSurface->unlock(); + _videoSurface->unlock(); + + ++_field4; + return _videoSurface; +} + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub16.h b/engines/titanic/star_control/star_control_sub16.h new file mode 100644 index 0000000000..64e463ca5b --- /dev/null +++ b/engines/titanic/star_control/star_control_sub16.h @@ -0,0 +1,57 @@ +/* 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_STAR_CONTROL_SUB16_H +#define TITANIC_STAR_CONTROL_SUB16_H + +#include "titanic/support/video_surface.h" +#include "titanic/support/screen_manager.h" +#include "titanic/star_control/surface_obj.h" + +namespace Titanic { + +class CStarControlSub16 { +private: + /** + * Sets up an internal surface to match the size of the specified one + */ + bool setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface); +protected: + int _field4; + int _field8; + CVideoSurface *_videoSurface; +protected: + virtual void proc4(CSurfaceObj &srcSurface, CSurfaceObj &destSurface) = 0; +public: + CStarControlSub16(); + + virtual void reset(); + + /** + * Loads from a given source surface + */ + virtual CVideoSurface *loadSurface(CScreenManager *screenManager, CVideoSurface *srcSurface); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB16_H */ diff --git a/engines/titanic/star_control/star_control_sub11.cpp b/engines/titanic/star_control/star_view.cpp index 05f2733e21..8af94c6b08 100644 --- a/engines/titanic/star_control/star_control_sub11.cpp +++ b/engines/titanic/star_control/star_view.cpp @@ -21,18 +21,18 @@ */ #include "titanic/support/screen_manager.h" -#include "titanic/star_control/star_control_sub11.h" +#include "titanic/star_control/star_view.h" namespace Titanic { -CStarControlSub11::CStarControlSub11() : +CStarView::CStarView() : _sub12(nullptr, nullptr), _sub13(nullptr), - _field4(0), _field8(0), _field118(0), _field20C(0), + _field4(0), _videoSurface(nullptr), _field118(0), _field20C(0), _field210(0), _field214(0), _field218(0), _field21C(0) { _sub12.proc3(); } -void CStarControlSub11::load(SimpleFile *file, int param) { +void CStarView::load(SimpleFile *file, int param) { if (!param) { _sub12.load(file, param); @@ -45,7 +45,23 @@ void CStarControlSub11::load(SimpleFile *file, int param) { } } -void CStarControlSub11::save(SimpleFile *file, int indent) { +void CStarView::save(SimpleFile *file, int indent) { + _sub12.save(file, indent); + + file->writeNumberLine(_field118, indent); + if (_field118) + _sub13.save(file, indent); + + file->writeNumberLine(_field218, indent); + file->writeNumberLine(_field21C, indent); +} + +void CStarView::draw(CScreenManager *screenManager) { + if (!screenManager) + return; + + + // TODO } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub11.h b/engines/titanic/star_control/star_view.h index a322e1e43a..47d138a0dc 100644 --- a/engines/titanic/star_control/star_control_sub11.h +++ b/engines/titanic/star_control/star_view.h @@ -20,21 +20,22 @@ * */ -#ifndef TITANIC_STAR_CONTROL_SUB11_H -#define TITANIC_STAR_CONTROL_SUB11_H +#ifndef TITANIC_STAR_VIEW_H +#define TITANIC_STAR_VIEW_H #include "titanic/support/simple_file.h" +#include "titanic/support/video_surface.h" #include "titanic/star_control/star_control_sub12.h" #include "titanic/star_control/star_control_sub13.h" #include "titanic/star_control/star_control_sub15.h" namespace Titanic { -class CStarControlSub11 { +class CStarView { private: int _field0; int _field4; - int _field8; + CVideoSurface *_videoSurface; CStarControlSub12 _sub12; int _field118; CStarControlSub13 _sub13; @@ -45,7 +46,7 @@ private: int _field218; int _field21C; public: - CStarControlSub11(); + CStarView(); /** * Load the data for the class from file @@ -56,8 +57,13 @@ public: * Save the data for the class to file */ void save(SimpleFile *file, int indent); + + /** + * Allows the item to draw itself + */ + void draw(CScreenManager *screenManager); }; } // End of namespace Titanic -#endif /* TITANIC_STAR_CONTROL_SUB11_H */ +#endif /* TITANIC_STAR_RENDERER_H */ |