diff options
-rw-r--r-- | engines/cge2/cge2.cpp | 4 | ||||
-rw-r--r-- | engines/cge2/cge2.h | 2 | ||||
-rw-r--r-- | engines/cge2/module.mk | 3 | ||||
-rw-r--r-- | engines/cge2/spare.cpp | 87 | ||||
-rw-r--r-- | engines/cge2/spare.h | 53 |
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 |