diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/decfile.cpp | 76 | ||||
-rw-r--r-- | engines/gob/decfile.h | 20 |
2 files changed, 23 insertions, 73 deletions
diff --git a/engines/gob/decfile.cpp b/engines/gob/decfile.cpp index f5910f0654..fb67c52627 100644 --- a/engines/gob/decfile.cpp +++ b/engines/gob/decfile.cpp @@ -29,25 +29,14 @@ #include "gob/dataio.h" #include "gob/surface.h" #include "gob/video.h" -#include "gob/rxyfile.h" +#include "gob/cmpfile.h" #include "gob/decfile.h" namespace Gob { -DECFile::Layer::Layer() : surface(0), coordinates(0) { -} - -DECFile::Layer::~Layer() { - delete coordinates; - delete surface; -} - - DECFile::DECFile(GobEngine *vm, const Common::String &fileName, uint16 width, uint16 height, uint8 bpp) : _vm(vm), - _width(width), _height(height), _bpp(bpp), _hasPadding(false) { - - _backdrop = new Surface(_width, _height, _bpp); + _width(width), _height(height), _bpp(bpp), _hasPadding(false), _backdrop(0) { Common::SeekableReadStream *dec = _vm->_dataIO->getFile(fileName); if (dec) { @@ -77,6 +66,9 @@ DECFile::DECFile(GobEngine *vm, const Common::String &fileName, DECFile::~DECFile() { delete _backdrop; + + for (LayerArray::iterator l = _layers.begin(); l != _layers.end(); ++l) + delete *l; } void DECFile::load(Common::SeekableSubReadStreamEndian &dec, const Common::String &fileName) { @@ -102,9 +94,9 @@ void DECFile::load(Common::SeekableSubReadStreamEndian &dec, const Common::Strin } // Load the layers - _layers.resize(MAX(0, layerCount - 1)); - for (LayerArray::iterator l = _layers.begin(); l != _layers.end(); ++l) - loadLayer(*l, dec); + _layers.reserve(MAX(0, layerCount - 1)); + for (int i = 0; i < layerCount - 1; i++) + _layers.push_back(loadLayer(dec)); // Load the backdrop parts if (backdropCount > 0) @@ -113,43 +105,19 @@ void DECFile::load(Common::SeekableSubReadStreamEndian &dec, const Common::Strin void DECFile::loadBackdrop(Common::SeekableSubReadStreamEndian &dec) { // Interestingly, DEC files reference "FOO.LBM" instead of "FOO.CMP" - Common::String file = Util::setExtension(Util::readString(dec, 13), ".CMP"); + Common::String file = Util::setExtension(Util::readString(dec, 13), ""); if (_hasPadding) dec.skip(1); - if (file.empty() || !_vm->_dataIO->hasFile(file)) - return; - - _vm->_video->drawPackedSprite(file.c_str(), *_backdrop); + _backdrop = new CMPFile(_vm, file, _width, _height, _bpp); } -void DECFile::loadLayer(Layer &layer, Common::SeekableSubReadStreamEndian &dec) { - Common::String file = Util::readString(dec, 13); +CMPFile *DECFile::loadLayer(Common::SeekableSubReadStreamEndian &dec) { + Common::String file = Util::setExtension(Util::readString(dec, 13), ""); if (_hasPadding) dec.skip(1); - if (file.empty()) - return; - - Common::String fileRXY = Util::setExtension(file, ".RXY"); - Common::String fileCMP = Util::setExtension(file, ".CMP"); - if (!_vm->_dataIO->hasFile(fileRXY) || !_vm->_dataIO->hasFile(fileCMP)) - return; - - loadLayer(layer, fileRXY, fileCMP); -} - -void DECFile::loadLayer(Layer &layer, const Common::String &fileRXY, - const Common::String &fileCMP) { - - Common::SeekableReadStream *dataRXY = _vm->_dataIO->getFile(fileRXY); - if (!dataRXY) - return; - - layer.coordinates = new RXYFile(*dataRXY); - layer.surface = new Surface(_width, layer.coordinates->getHeight(), _bpp); - - _vm->_video->drawPackedSprite(fileCMP.c_str(), *layer.surface); + return new CMPFile(_vm, file, _width, _height, _bpp); } void DECFile::loadParts(Common::SeekableSubReadStreamEndian &dec) { @@ -188,7 +156,10 @@ void DECFile::draw(Surface &dest) const { } void DECFile::drawBackdrop(Surface &dest) const { - dest.blit(*_backdrop); + if (!_backdrop) + return; + + _backdrop->draw(dest, 0, 0, 0); } void DECFile::drawLayer(Surface &dest, uint16 layer, uint16 part, @@ -197,18 +168,7 @@ void DECFile::drawLayer(Surface &dest, uint16 layer, uint16 part, if (layer >= _layers.size()) return; - const Layer &l = _layers[layer]; - if (!l.surface || !l.coordinates) - return; - - if (part >= l.coordinates->size()) - return; - - const RXYFile::Coordinates &c = (*l.coordinates)[part]; - if (c.left == 0xFFFF) - return; - - dest.blit(*l.surface, c.left, c.top, c.right, c.bottom, x, y, transp); + _layers[layer]->draw(dest, part, x, y, transp); } } // End of namespace Gob diff --git a/engines/gob/decfile.h b/engines/gob/decfile.h index 31d90180d3..48af740d41 100644 --- a/engines/gob/decfile.h +++ b/engines/gob/decfile.h @@ -34,7 +34,7 @@ namespace Gob { class GobEngine; class Surface; -class RXYFile; +class CMPFile; /** A DEC file, describing a "decal" (background). * @@ -60,14 +60,6 @@ public: uint16 x, uint16 y, int32 transp = -1) const; private: - struct Layer { - Surface *surface; ///< The surface containing the layer sprite. - RXYFile *coordinates; ///< The coordinates describing the layer sprite parts. - - Layer(); - ~Layer(); - }; - struct Part { uint8 layer; uint8 part; @@ -77,8 +69,8 @@ private: bool transp; }; - typedef Common::Array<Layer> LayerArray; - typedef Common::Array<Part> PartArray; + typedef Common::Array<CMPFile *> LayerArray; + typedef Common::Array<Part> PartArray; GobEngine *_vm; @@ -88,7 +80,7 @@ private: byte _hasPadding; - Surface *_backdrop; + CMPFile *_backdrop; LayerArray _layers; PartArray _parts; @@ -98,9 +90,7 @@ private: void loadBackdrop(Common::SeekableSubReadStreamEndian &dec); - void loadLayer(Layer &layer, Common::SeekableSubReadStreamEndian &dec); - void loadLayer(Layer &layer, const Common::String &fileRXY, - const Common::String &fileCMP); + CMPFile *loadLayer(Common::SeekableSubReadStreamEndian &dec); void loadParts(Common::SeekableSubReadStreamEndian &dec); void loadPart(Part &part, Common::SeekableSubReadStreamEndian &dec); |