aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2014-05-12 22:24:21 +0200
committeruruk2014-05-12 22:24:21 +0200
commit49d78527922f65c400056f0b4f98c26ee9d3a9c5 (patch)
tree892284c1a293a7d4ca89a41655bd3c10aec7ba59 /engines
parent89bece4b420f90c1fd3adc6b63fe05a9815f5957 (diff)
downloadscummvm-rg350-49d78527922f65c400056f0b4f98c26ee9d3a9c5.tar.gz
scummvm-rg350-49d78527922f65c400056f0b4f98c26ee9d3a9c5.tar.bz2
scummvm-rg350-49d78527922f65c400056f0b4f98c26ee9d3a9c5.zip
CGE2: Add Spare.
Diffstat (limited to 'engines')
-rw-r--r--engines/cge2/cge2.cpp4
-rw-r--r--engines/cge2/cge2.h2
-rw-r--r--engines/cge2/module.mk3
-rw-r--r--engines/cge2/spare.cpp87
-rw-r--r--engines/cge2/spare.h53
5 files changed, 148 insertions, 1 deletions
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp
index 986c616b65..c9fb590400 100644
--- a/engines/cge2/cge2.cpp
+++ b/engines/cge2/cge2.cpp
@@ -34,6 +34,7 @@
#include "cge2/text.h"
#include "cge2/hero.h"
#include "cge2/general.h"
+#include "cge2/spare.h"
namespace CGE2 {
@@ -49,6 +50,7 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
for (int i = 0; i < 2; i++)
_heroTab[i] = nullptr;
_eye = nullptr;
+ _spare = nullptr;
_quitFlag = false;
_bitmapPalette = nullptr;
@@ -69,6 +71,7 @@ void CGE2Engine::init() {
for (int i = 0; i < 2; i++)
_heroTab[i] = new HeroTab(this);
_eye = new V3D();
+ _spare = new Spare(this);
}
void CGE2Engine::deinit() {
@@ -82,6 +85,7 @@ void CGE2Engine::deinit() {
for (int i = 0; i < 2; i++)
delete _heroTab[i];
delete _eye;
+ delete _spare;
}
bool CGE2Engine::hasFeature(EngineFeature f) const {
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index f3cf574faf..bca5d1a62a 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -45,6 +45,7 @@ struct HeroTab;
class V3D;
class V2D;
class Dac;
+class Spare;
#define kScrWidth 320
#define kScrHeight 240
@@ -96,6 +97,7 @@ public:
Text *_text;
HeroTab *_heroTab[2];
V3D *_eye;
+ Spare *_spare;
private:
void init();
void deinit();
diff --git a/engines/cge2/module.mk b/engines/cge2/module.mk
index 4a7a412152..60b7db519c 100644
--- a/engines/cge2/module.mk
+++ b/engines/cge2/module.mk
@@ -10,7 +10,8 @@ MODULE_OBJS = \
cge2_main.o \
text.o \
hero.o \
- snail.o
+ snail.o \
+ spare.o
# This module can be built as a plugin
ifeq ($(ENABLE_CGE2), DYNAMIC_PLUGIN)
diff --git a/engines/cge2/spare.cpp b/engines/cge2/spare.cpp
new file mode 100644
index 0000000000..c1e536ac01
--- /dev/null
+++ b/engines/cge2/spare.cpp
@@ -0,0 +1,87 @@
+/* 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.
+ *
+ */
+
+/*
+ * This code is based on original Sfinx source code
+ * Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon
+ */
+
+#include "cge2/spare.h"
+
+namespace CGE2 {
+
+void Spare::synchronize() {
+ warning("STUB: Spare::Load");
+}
+
+void Spare::clear() {
+ _container.clear();
+}
+
+Spare::Spare(CGE2Engine *vm) : _vm(vm) {}
+
+Sprite *Spare::take(int ref) {
+ for (int i = 0; i < _container.size(); i++) {
+ if (_container[i]._ref == ref) {
+ return &_container[i];
+ }
+ }
+ return nullptr;
+}
+
+void Spare::takeCave(int cav) {
+ int ref = cav << 8;
+ Sprite *spr = take(ref);
+ _vm->_vga->_showQ->insert(spr);
+}
+
+void Spare::make(Sprite *spr) {
+ _container.insert_at(_container.size(), *spr);
+}
+
+void Spare::dispose(Sprite *spr) {
+ warning("STUB: Spare::Dispose()");
+
+ if (spr) {
+ _vm->_vga->_showQ->remove(spr);
+
+ for (int i = 0; i < _container.size(); i++) {
+ if (spr == &_container[i]) {
+ _container.remove_at(i);
+ }
+ }
+ }
+}
+
+void Spare::dispose(int ref) {
+ dispose(_vm->_vga->_showQ->locate(ref));
+}
+
+void Spare::dispose() {
+ for (int i = 0; i < _container.size(); i++) {
+ if (_container[i]._ref > 255) {
+ dispose(&_container[i]);
+ }
+ }
+}
+
+} // End of namespace CGE2
diff --git a/engines/cge2/spare.h b/engines/cge2/spare.h
new file mode 100644
index 0000000000..8cfb65b905
--- /dev/null
+++ b/engines/cge2/spare.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ */
+
+/*
+ * This code is based on original Sfinx source code
+ * Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon
+ */
+
+#ifndef CGE2_SPARE_H
+#define CGE2_SPARE_H
+
+#include "cge2/vga13h.h"
+
+namespace CGE2 {
+
+class Spare {
+ CGE2Engine *_vm;
+ Common::Array<Sprite> _container;
+public:
+ void make(Sprite *spr);
+ Spare(CGE2Engine *vm);
+ Sprite *take(int ref);
+ void takeCave(int cav);
+ void dispose(Sprite *spr);
+ void dispose(int ref);
+ void dispose();
+ void synchronize();
+ uint16 count() { _container.size(); }
+ void clear();
+};
+
+} // End of namespace CGE2
+
+#endif // CGE2_SPARE_H