diff options
author | Filippos Karapetis | 2015-12-10 12:45:21 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:34:00 +0100 |
commit | aa7ec3654dfc8a01c734c41946db5d8e79f3cf9b (patch) | |
tree | d915aa85800a78488e7e06e1db1ae0ee81833d37 /engines/lab/dispman.cpp | |
parent | 9f7ad4b5f25e3c9d6437f0ac0e5e26dba4cab330 (diff) | |
download | scummvm-rg350-aa7ec3654dfc8a01c734c41946db5d8e79f3cf9b.tar.gz scummvm-rg350-aa7ec3654dfc8a01c734c41946db5d8e79f3cf9b.tar.bz2 scummvm-rg350-aa7ec3654dfc8a01c734c41946db5d8e79f3cf9b.zip |
LAB: Refactor readPictToMem()
This fixes crashes in the teleporter and the journal, and plugs several
memory leaks
Diffstat (limited to 'engines/lab/dispman.cpp')
-rw-r--r-- | engines/lab/dispman.cpp | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp index ba2cfc846b..df35f9f29d 100644 --- a/engines/lab/dispman.cpp +++ b/engines/lab/dispman.cpp @@ -80,9 +80,9 @@ void DisplayMan::loadPict(const char *filename) { } /** - * Reads in a picture into the dest bitmap. + * Reads in a picture into the display bitmap. */ -void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData) { +void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) { _vm->_anim->stopDiff(); loadPict(filename); @@ -92,40 +92,15 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData if (!_vm->_music->_doNotFilestopSoundEffect) _vm->_music->stopSoundEffect(); - _dispBitMap->_bytesPerRow = _screenWidth; - _dispBitMap->_rows = _screenHeight; - _dispBitMap->_drawOnScreen = true; + _dispBitMap->_bytesPerRow = _screenWidth; + _dispBitMap->_rows = (maxHeight > 0) ? maxHeight : _screenHeight; + _dispBitMap->_drawOnScreen = (memoryBuffer == nullptr); + if (memoryBuffer) + _dispBitMap->_planes[0] = memoryBuffer; _vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData); } -/** - * Reads in a picture into buffer memory. - */ -byte *DisplayMan::readPictToMem(const char *filename, uint16 width, uint16 height) { - _vm->_anim->stopDiff(); - - loadPict(filename); - - _vm->_music->updateMusic(); - - if (!_vm->_music->_doNotFilestopSoundEffect) - _vm->_music->stopSoundEffect(); - - _dispBitMap->_bytesPerRow = width; - _dispBitMap->_rows = height; - _dispBitMap->_drawOnScreen = false; - _dispBitMap->_planes[0] = _curBitmap; - _dispBitMap->_planes[1] = _dispBitMap->_planes[0] + 0x10000; - _dispBitMap->_planes[2] = _dispBitMap->_planes[1] + 0x10000; - _dispBitMap->_planes[3] = _dispBitMap->_planes[2] + 0x10000; - _dispBitMap->_planes[4] = _dispBitMap->_planes[3] + 0x10000; - - _vm->_anim->readDiff(_curBitmap, true); - - return _curBitmap; -} - void DisplayMan::freePict() { delete _curBitmap; _curBitmap = NULL; |