diff options
author | Paul Gilbert | 2014-08-10 16:55:06 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-08-10 16:55:06 -0400 |
commit | 6801cb0855cef796ea22c969c9c9f25866cdfa72 (patch) | |
tree | 2b307519cebc92e18f310d0898105f87d8ccd871 /engines | |
parent | 47d75ae128d2b29ace73925373901cf7bbc6325d (diff) | |
download | scummvm-rg350-6801cb0855cef796ea22c969c9c9f25866cdfa72.tar.gz scummvm-rg350-6801cb0855cef796ea22c969c9c9f25866cdfa72.tar.bz2 scummvm-rg350-6801cb0855cef796ea22c969c9c9f25866cdfa72.zip |
ACCESS: Decompress sprite resource frames immediately on creation
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 2 | ||||
-rw-r--r-- | engines/access/amazon/amazon_room.cpp | 2 | ||||
-rw-r--r-- | engines/access/asurface.cpp | 58 | ||||
-rw-r--r-- | engines/access/asurface.h | 20 | ||||
-rw-r--r-- | engines/access/data.cpp | 42 | ||||
-rw-r--r-- | engines/access/data.h | 22 |
6 files changed, 80 insertions, 66 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index f625fa096a..2f505c2ffa 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -45,7 +45,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _destIn = nullptr; _current = nullptr; - clearCellTable(); _pCount = 0; _selectCommand = 0; _normalMouse = true; @@ -82,6 +81,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _intTim[3] = 0; _timer[3] = 0; _timerFlag = false; + Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr); Common::fill(&_establishTable[0], &_establishTable[100], 0); Common::fill(&_flags[0], &_flags[256], 0); _establishFlag = false; diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 056fa8f1eb..5b840afc2e 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -123,7 +123,7 @@ void AmazonRoom::roomSet() { void AmazonRoom::roomMenu() { byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *spr = new SpriteResource(_vm, _icon, _vm->_files->_filesize); + SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); delete[] iconData; _vm->_screen->saveScreen(); diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 438bfbf852..a9d97aa48c 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -21,10 +21,64 @@ */ #include "common/algorithm.h" +#include "common/endian.h" +#include "common/memstream.h" +#include "access/access.h" #include "access/asurface.h" namespace Access { +SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory) { + Common::MemoryReadStream stream(data, size); + Common::Array<uint32> offsets; + int count = stream.readUint16LE(); + + for (int i = 0; i < count; i++) + offsets.push_back(stream.readUint32LE()); + offsets.push_back(size); // For easier calculations of Noctropolis sizes + + // Build up the frames + for (int i = 0; i < count; ++i) { + stream.seek(offsets[i]); + int frameSize = offsets[i + 1] - offsets[i]; + + SpriteFrame *frame = new SpriteFrame(vm, stream, frameSize); + _frames.push_back(frame); + } + + if (disposeMemory == DisposeAfterUse::YES) + delete[] data; +} + +SpriteResource::~SpriteResource() { + for (uint i = 0; i < _frames.size(); ++i) + delete _frames[i]; +} + +SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) { + int w = stream.readUint16LE(); + int h = stream.readUint16LE(); + create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + + // Empty surface + byte *data = (byte *)getPixels(); + Common::fill(data, data + w * h, 0); + + // Decode the data + for (int y = 0; y < h; ++y) { + int offset = stream.readByte(); + int len = stream.readByte(); + assert((offset + len) <= w); + + byte *destP = (byte *)getBasePtr(offset, y); + stream.read(destP, len); + } +} + +SpriteFrame::~SpriteFrame() { + free(); +} /*------------------------------------------------------------------------*/ @@ -114,6 +168,9 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { + return; + +/* byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y); byte *srcP = frame->_data; @@ -144,6 +201,7 @@ void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { warning("TODO: Line draw"); } } + */ } } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index d1e6b64a9e..d726e6aeae 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -25,12 +25,32 @@ #include "common/scummsys.h" #include "common/array.h" +#include "common/memstream.h" #include "common/rect.h" #include "graphics/surface.h" #include "access/data.h" namespace Access { +class SpriteFrame : public Graphics::Surface { +public: + SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize); + ~SpriteFrame(); +}; + +class SpriteResource { +public: + Common::Array<SpriteFrame *> _frames; +public: + SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); + ~SpriteResource(); + + int getCount() { return _frames.size(); } + + SpriteFrame *getFrame(int idx) { return _frames[idx]; } +}; + class ASurface : public Graphics::Surface { public: static int _leftSkip, _rightSkip; diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 3203020322..c3a6bb3d90 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -21,50 +21,8 @@ */ #include "common/algorithm.h" -#include "common/endian.h" -#include "common/memstream.h" -#include "access/access.h" #include "access/data.h" namespace Access { -SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size, - DisposeAfterUse::Flag disposeMemory) { - Common::MemoryReadStream stream(data, size); - Common::Array<uint32> offsets; - int count = stream.readUint16LE(); - - for (int i = 0; i < count; i++) - offsets.push_back(stream.readUint32LE()); - offsets.push_back(size); // For easier calculations of Noctropolis sizes - - // Build up the frames - for (int i = 0; i < count; ++i) { - stream.seek(offsets[i]); - - SpriteFrame *frame = new SpriteFrame(); - frame->_width = stream.readUint16LE(); - frame->_height = stream.readUint16LE(); - frame->_size = (vm->getGameID() == GType_MeanStreets) ? stream.readUint16LE() : - offsets[i + 1] - offsets[i]; - - frame->_data = new byte[frame->_size]; - stream.read(frame->_data, frame->_size); - - _frames.push_back(frame); - } - - if (disposeMemory == DisposeAfterUse::YES) - delete[] data; -} - -SpriteResource::~SpriteResource() { - for (uint i = 0; i < _frames.size(); ++i) - delete _frames[i]; -} - -SpriteFrame::~SpriteFrame() { - delete[] _data; -} - } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index bb5ef90e55..b9da858216 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -59,28 +59,6 @@ public: int _vidSTable1; }; -class SpriteFrame : public Graphics::Surface { -public: - uint16 _width, _height; - byte *_data; - uint32 _size; - - ~SpriteFrame(); -}; - -class SpriteResource { -public: - Common::Array<SpriteFrame *> _frames; -public: - SpriteResource(AccessEngine *vm, const byte *data, uint32 size, - DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); - ~SpriteResource(); - - int getCount() { return _frames.size(); } - - SpriteFrame *getFrame(int idx) { return _frames[idx]; } -}; - } // End of namespace Access #endif /* ACCESS_DATA_H */ |