aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2015-12-13 22:51:23 +0100
committerWillem Jan Palenstijn2015-12-23 21:34:03 +0100
commitad54a75b853ada2c4ae4b99368ac3038dcd92d33 (patch)
tree69f25b8d3fe0ded70a6d8728157f1dac7a759303
parent2b91bf2f34c3e0ec4e83fa478f1e426d36719cb7 (diff)
downloadscummvm-rg350-ad54a75b853ada2c4ae4b99368ac3038dcd92d33.tar.gz
scummvm-rg350-ad54a75b853ada2c4ae4b99368ac3038dcd92d33.tar.bz2
scummvm-rg350-ad54a75b853ada2c4ae4b99368ac3038dcd92d33.zip
LAB: Add _vm to Image class
-rw-r--r--engines/lab/dispman.cpp16
-rw-r--r--engines/lab/engine.cpp10
-rw-r--r--engines/lab/image.cpp20
-rw-r--r--engines/lab/image.h10
-rw-r--r--engines/lab/lab.cpp9
-rw-r--r--engines/lab/lab.h4
-rw-r--r--engines/lab/map.cpp38
-rw-r--r--engines/lab/special.cpp53
-rw-r--r--engines/lab/tilepuzzle.cpp6
9 files changed, 85 insertions, 81 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 736b7ea043..d4492607df 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -426,7 +426,7 @@ void DisplayMan::setUpScreens() {
Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
for (uint16 i = 0; i < 20; i++)
- _vm->_moveImages[i] = new Image(controlFile);
+ _vm->_moveImages[i] = new Image(controlFile, _vm);
delete controlFile;
// Creates the buttons for the movement control panel
@@ -449,10 +449,10 @@ void DisplayMan::setUpScreens() {
Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
if (_vm->getPlatform() == Common::kPlatformWindows) {
for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
- _vm->_invImages[imgIdx] = new Image(invFile);
+ _vm->_invImages[imgIdx] = new Image(invFile, _vm);
} else {
for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
- _vm->_invImages[imgIdx] = new Image(invFile);
+ _vm->_invImages[imgIdx] = new Image(invFile, _vm);
}
_vm->_invButtonList.push_back(_vm->_event->createButton( 24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]));
_vm->_invButtonList.push_back(_vm->_event->createButton( 56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]));
@@ -772,7 +772,7 @@ void DisplayMan::doScrollBlack() {
_vm->_event->mouseHide();
- Image img;
+ Image img(_vm);
img._width = width;
img._height = height;
img._imageData = mem;
@@ -1007,12 +1007,12 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
setPalette(_vm->_anim->_diffPalette, 256);
- Image imSource;
+ Image imSource(_vm);
imSource._width = _screenWidth;
imSource._height = lastY;
imSource._imageData = bitMapBuffer;
- Image imDest;
+ Image imDest(_vm);
imDest._width = _screenWidth;
imDest._height = _screenHeight;
imDest._imageData = getCurrentDrawingBuffer();
@@ -1113,7 +1113,7 @@ void DisplayMan::blackAllScreen() {
* function will fail.
*/
void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
- Image im;
+ Image im(_vm);
im._imageData = buffer;
if (x1 > x2)
@@ -1147,7 +1147,7 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
* Scrolls the display in the y direction by blitting.
*/
void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
- Image im;
+ Image im(_vm);
im._imageData = buffer;
if (x1 > x2)
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 80ee0bf915..552bdf8645 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1184,10 +1184,10 @@ int LabEngine::followCrumbs() {
return moveDir;
}
-byte dropCrumbs[] = { 0x00 };
-Image dropCrumbsImage(24, 24, dropCrumbs);
void LabEngine::mayShowCrumbIndicator() {
+ static byte dropCrumbs[] = { 0x00 };
+ static Image dropCrumbsImage(24, 24, dropCrumbs, this);
if (getPlatform() != Common::kPlatformWindows)
return;
@@ -1198,10 +1198,10 @@ void LabEngine::mayShowCrumbIndicator() {
}
}
-byte dropCrumbsOff[] = { 0x00 };
-Image dropCrumbsOffImage(24, 24, dropCrumbsOff);
-
void LabEngine::mayShowCrumbIndicatorOff() {
+ static byte dropCrumbsOff[] = { 0x00 };
+ static Image dropCrumbsOffImage(24, 24, dropCrumbsOff, this);
+
if (getPlatform() != Common::kPlatformWindows)
return;
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 20c893dfd5..a947ced1c8 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -40,7 +40,7 @@ namespace Lab {
/**
* Reads in an image from disk.
*/
-Image::Image(Common::File *s) {
+Image::Image(Common::File *s, LabEngine *vm) : _vm(vm) {
_width = s->readUint16LE();
_height = s->readUint16LE();
s->skip(4);
@@ -60,9 +60,9 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
int w = width;
int h = height;
- int destWidth = (imDest) ? imDest->_width : g_lab->_graphics->_screenWidth;
- int destHeight = (imDest) ? imDest->_height : g_lab->_graphics->_screenHeight;
- byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->_graphics->getCurrentDrawingBuffer();
+ int destWidth = (imDest) ? imDest->_width : _vm->_graphics->_screenWidth;
+ int destHeight = (imDest) ? imDest->_height : _vm->_graphics->_screenHeight;
+ byte *destBuffer = (imDest) ? imDest->_imageData : _vm->_graphics->getCurrentDrawingBuffer();
if (xd + w > destWidth)
w = destWidth - xd;
@@ -121,20 +121,20 @@ void Image::readScreenImage(uint16 x, uint16 y) {
int w = _width;
int h = _height;
- if (x + w > g_lab->_graphics->_screenWidth)
- w = g_lab->_graphics->_screenWidth - x;
+ if (x + w > _vm->_graphics->_screenWidth)
+ w = _vm->_graphics->_screenWidth - x;
- if (y + h > g_lab->_graphics->_screenHeight)
- h = g_lab->_graphics->_screenHeight - y;
+ if (y + h > _vm->_graphics->_screenHeight)
+ h = _vm->_graphics->_screenHeight - y;
if ((w > 0) && (h > 0)) {
byte *s = _imageData;
- byte *d = g_lab->_graphics->getCurrentDrawingBuffer() + y * g_lab->_graphics->_screenWidth + x;
+ byte *d = _vm->_graphics->getCurrentDrawingBuffer() + y * _vm->_graphics->_screenWidth + x;
while (h-- > 0) {
memcpy(s, d, w);
s += _width;
- d += g_lab->_graphics->_screenWidth;
+ d += _vm->_graphics->_screenWidth;
}
}
}
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 34e3d36658..90ea1f3ada 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -37,15 +37,19 @@ namespace Common {
namespace Lab {
+class LabEngine;
+
class Image {
+ LabEngine *_vm;
+
public:
uint16 _width;
uint16 _height;
byte *_imageData;
- Image() : _width(0), _height(0), _imageData(0) {}
- Image(int w, int h, byte *d) : _width(w), _height(h), _imageData(d) {}
- Image(Common::File *s);
+ Image(LabEngine *vm) : _width(0), _height(0), _imageData(0), _vm(vm) {}
+ Image(int w, int h, byte *d, LabEngine *vm) : _width(w), _height(h), _imageData(d), _vm(vm) {}
+ Image(Common::File *s, LabEngine *vm);
void drawImage(uint16 x, uint16 y);
void drawMaskImage(uint16 x, uint16 y);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 9ff0cdabe1..19dbef344a 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -88,6 +88,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_rooms = nullptr;
_tilePuzzle = nullptr;
_utils = nullptr;
+ journalBackImage = nullptr;
+ ScreenImage = nullptr;
_lastTooLong = false;
_interfaceOff = false;
@@ -96,9 +98,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
for (int i = 0; i < 20; i++)
_moveImages[i] = nullptr;
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++)
_invImages[i] = nullptr;
- }
_curFileName = nullptr;
_nextFileName = nullptr;
@@ -155,6 +156,8 @@ LabEngine::~LabEngine() {
delete[] _rooms;
delete _tilePuzzle;
delete _utils;
+ delete journalBackImage;
+ delete ScreenImage;
}
Common::Error LabEngine::run() {
@@ -170,6 +173,8 @@ Common::Error LabEngine::run() {
_anim = new Anim(this);
_tilePuzzle = new TilePuzzle(this);
_utils = new Utils(this);
+ journalBackImage = new Image(this);
+ ScreenImage = new Image(this);
if (getPlatform() == Common::kPlatformWindows) {
// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 37cd93f3bb..dbb083af97 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -128,8 +128,8 @@ private:
Common::RandomSource _rnd;
- Image journalBackImage;
- Image ScreenImage;
+ Image *journalBackImage;
+ Image *ScreenImage;
public:
bool _alternate;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 1861ccc6a0..f8207ad844 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -62,25 +62,25 @@ enum MapFloor {
void LabEngine::loadMapData() {
Common::File *mapImages = _resource->openDataFile("P:MapImage");
- _imgMap = new Image(mapImages);
- _imgRoom = new Image(mapImages);
- _imgUpArrowRoom = new Image(mapImages);
- _imgDownArrowRoom = new Image(mapImages);
- _imgHRoom = new Image(mapImages);
- _imgVRoom = new Image(mapImages);
- _imgMaze = new Image(mapImages);
- _imgHugeMaze = new Image(mapImages);
-
- _imgMapX[NORTH] = new Image(mapImages);
- _imgMapX[EAST] = new Image(mapImages);
- _imgMapX[SOUTH] = new Image(mapImages);
- _imgMapX[WEST] = new Image(mapImages);
- _imgPath = new Image(mapImages);
- _imgBridge = new Image(mapImages);
-
- _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages))); // back
- _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages))); // up
- _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages))); // down
+ _imgMap = new Image(mapImages, this);
+ _imgRoom = new Image(mapImages, this);
+ _imgUpArrowRoom = new Image(mapImages, this);
+ _imgDownArrowRoom = new Image(mapImages, this);
+ _imgHRoom = new Image(mapImages, this);
+ _imgVRoom = new Image(mapImages, this);
+ _imgMaze = new Image(mapImages, this);
+ _imgHugeMaze = new Image(mapImages, this);
+
+ _imgMapX[NORTH] = new Image(mapImages, this);
+ _imgMapX[EAST] = new Image(mapImages, this);
+ _imgMapX[SOUTH] = new Image(mapImages, this);
+ _imgMapX[WEST] = new Image(mapImages, this);
+ _imgPath = new Image(mapImages, this);
+ _imgBridge = new Image(mapImages, this);
+
+ _mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages, this), new Image(mapImages, this))); // back
+ _mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages, this), new Image(mapImages, this))); // up
+ _mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages, this), new Image(mapImages, this))); // down
delete mapImages;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 0f5e00b3e2..a629fd94ab 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -106,7 +106,6 @@ void LabEngine::doWestPaper() {
*/
void LabEngine::loadJournalData() {
_journalFont = _resource->getFont("P:Journal.fon");
-
_music->updateMusic();
char filename[20];
@@ -141,21 +140,21 @@ void LabEngine::loadJournalData() {
Common::File *journalFile = _resource->openDataFile("P:JImage");
Utils *utils = _utils;
- _journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile))); // back
- _journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile), new Image(journalFile))); // cancel
- _journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile))); // forward
+ _journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this))); // back
+ _journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2, 0, new Image(journalFile, this), new Image(journalFile, this))); // cancel
+ _journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this))); // forward
delete journalFile;
_anim->_noPalChange = true;
- journalBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
- _graphics->readPict("P:Journal.pic", true, false, journalBackImage._imageData);
+ journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
+ _graphics->readPict("P:Journal.pic", true, false, journalBackImage->_imageData);
_anim->_noPalChange = false;
// Keep a copy of the blank journal
_blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
- memcpy(_blankJournal, journalBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight);
+ memcpy(_blankJournal, journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight);
- ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+ ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
}
/**
@@ -181,16 +180,16 @@ void LabEngine::drawJournalText() {
if (_journalPage <= 1) {
curText = _journalTextTitle;
- _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+ _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
} else {
curText = (char *)(_journalText + charsDrawn);
- charsDrawn += _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+ charsDrawn += _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
}
_music->updateMusic();
curText = (char *)(_journalText + charsDrawn);
_lastPage = (*curText == 0);
- _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
+ _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
curText = (char *)(_journalText + charsDrawn);
_lastPage = _lastPage || (*curText == 0);
@@ -204,15 +203,15 @@ void LabEngine::turnPage(bool fromLeft) {
for (int i = 0; i < _graphics->_screenWidth; i += 8) {
_music->updateMusic();
waitTOF();
- ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
- journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
+ ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+ journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
}
} else {
for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) {
_music->updateMusic();
waitTOF();
- ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
- journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
+ ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+ journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
}
}
}
@@ -227,7 +226,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
_graphics->loadBackPict("P:Journal.pic", _highPalette);
if (wipenum == 0)
- journalBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
+ journalBackImage->blitBitmap(0, 0, ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
else
turnPage((bool)(wipenum == 1));
@@ -248,7 +247,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
_graphics->fade(true, 0);
// Reset the journal background, so that all the text that has been blitted on it is erased
- memcpy(journalBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
+ memcpy(journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
eatMessages();
_event->mouseShow();
@@ -297,19 +296,15 @@ void LabEngine::processJournal() {
*/
void LabEngine::doJournal() {
_graphics->blackAllScreen();
+ _lastPage = false;
- _lastPage = false;
-
- journalBackImage._width = _graphics->_screenWidth;
- journalBackImage._height = _graphics->_screenHeight;
- journalBackImage._imageData = NULL;
-
- ScreenImage = journalBackImage;
- ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+ ScreenImage->_width = journalBackImage->_width = _graphics->_screenWidth;
+ ScreenImage->_height = journalBackImage->_height = _graphics->_screenHeight;
+ journalBackImage->_imageData = nullptr;
+ ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
_music->updateMusic();
loadJournalData();
-
_event->attachButtonList(&_journalButtonList);
drawJournal(0, true);
_event->mouseShow();
@@ -319,11 +314,11 @@ void LabEngine::doJournal() {
_event->mouseHide();
delete[] _blankJournal;
- delete[] journalBackImage._imageData;
+ delete[] journalBackImage->_imageData;
_event->freeButtonList(&_journalButtonList);
_graphics->closeFont(_journalFont);
- ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+ ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
_graphics->setAPen(0);
_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
@@ -508,7 +503,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
TextFont *monitorFont = _resource->getFont("P:Map.fon");
Common::File *buttonFile = _resource->openDataFile("P:MonImage");
- _monitorButton = new Image(buttonFile);
+ _monitorButton = new Image(buttonFile, this);
delete buttonFile;
ntext = _resource->getText(textfile);
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 4d461a8c07..1e227d3b7e 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -264,7 +264,7 @@ void TilePuzzle::showTile(const char *filename, bool showSolution) {
Common::File *tileFile = _vm->_resource->openDataFile(showSolution ? "P:TileSolution" : "P:Tile");
for (uint16 curBit = start; curBit < 16; curBit++)
- _tiles[curBit] = new Image(tileFile);
+ _tiles[curBit] = new Image(tileFile, _vm);
delete tileFile;
@@ -322,7 +322,7 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
void TilePuzzle::changeCombination(uint16 number) {
const int solution[6] = { 0, 4, 0, 8, 7, 2 };
- Image display;
+ Image display(_vm);
uint16 combnum;
bool unlocked = true;
@@ -392,7 +392,7 @@ void TilePuzzle::showCombination(const char *filename) {
Common::File *numFile = _vm->_resource->openDataFile("P:Numbers");
for (uint16 CurBit = 0; CurBit < 10; CurBit++)
- _numberImages[CurBit] = new Image(numFile);
+ _numberImages[CurBit] = new Image(numFile, _vm);
delete numFile;