From 33850b80d294b60e8f25a2f2475d1aa6267122eb Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Fri, 7 Jun 2019 22:28:45 +0530 Subject: HDB: Add cacheTile() to load a Tile into memory --- engines/hdb/draw-manager.cpp | 23 +++++++++++++++++++++++ engines/hdb/draw-manager.h | 1 + 2 files changed, 24 insertions(+) diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp index 564e178f35..85c313ab14 100644 --- a/engines/hdb/draw-manager.cpp +++ b/engines/hdb/draw-manager.cpp @@ -78,6 +78,29 @@ bool DrawMan::init() { return true; } +bool DrawMan::cacheTile(int index) { + + if (index < 0) { + return false; + } + if (index > _numTiles) { + return false; + } + if (_tLookupArray[index].skyIndex) { + // We don't draw Sky Tiles, so return true + return true; + } + + if (_tLookupArray[index].tData == NULL) { + Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(_tLookupArray[index].filename, TYPE_TILE32); + Tile *tile = new Tile; + tile->load(stream); + _tLookupArray[index].tData = tile; + } + + return true; +} + Picture::~Picture() { _surface.free(); } diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h index 2c651dd816..fac91c78ad 100644 --- a/engines/hdb/draw-manager.h +++ b/engines/hdb/draw-manager.h @@ -48,6 +48,7 @@ public: DrawMan(); bool init(); + bool cacheTile(int index); private: int _numTiles; -- cgit v1.2.3