aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/engine.cpp25
-rw-r--r--engines/lab/graphics.cpp3
-rw-r--r--engines/lab/image.cpp183
-rw-r--r--engines/lab/image.h54
-rw-r--r--engines/lab/interface.cpp9
-rw-r--r--engines/lab/lab.h9
-rw-r--r--engines/lab/labfun.h3
-rw-r--r--engines/lab/map.cpp129
-rw-r--r--engines/lab/module.mk2
-rw-r--r--engines/lab/mouse.cpp9
-rw-r--r--engines/lab/special.cpp25
-rw-r--r--engines/lab/vga.cpp144
12 files changed, 339 insertions, 256 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3a7cd6f561..e401e062ed 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -31,6 +31,7 @@
#include "lab/lab.h"
#include "lab/labfun.h"
#include "lab/anim.h"
+#include "lab/image.h"
#include "lab/text.h"
#include "lab/intro.h"
#include "lab/parsefun.h"
@@ -223,7 +224,7 @@ bool LabEngine::setUpScreens() {
buffer = MovePanelBuffer;
for (uint16 i = 0; i < 20; i++)
- readImage(&buffer, &(MoveImages[i]));
+ MoveImages[i] = new Image(&buffer);
/* Creates the gadgets for the movement control panel */
y = VGAScaleY(173) - SVGACord(2);
@@ -287,7 +288,7 @@ bool LabEngine::setUpScreens() {
if (getPlatform() == Common::kPlatformWindows) {
for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
- readImage(&buffer, &(InvImages[imgIdx]));
+ InvImages[imgIdx] = new Image(&buffer);
InvGadgetList = createButton(24, y, 0, 'm', InvImages[0], InvImages[1]);
curgad = InvGadgetList;
@@ -307,7 +308,7 @@ bool LabEngine::setUpScreens() {
curgad = curgad->NextGadget;
} else {
for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
- readImage(&buffer, &(InvImages[imgIdx]));
+ InvImages[imgIdx] = new Image(&buffer);
InvGadgetList = createButton(58, y, 0, 0, InvImages[0], InvImages[1]);
curgad = InvGadgetList;
@@ -345,7 +346,7 @@ void LabEngine::perFlipGadget(uint16 GadID) {
if (!Alternate) {
_event->mouseHide();
- drawImage(TopGad->Im, TopGad->x, TopGad->y);
+ TopGad->Im->drawImage(TopGad->x, TopGad->y);
_event->mouseShow();
}
@@ -1410,30 +1411,30 @@ int LabEngine::followCrumbs() {
return moveDir;
}
+byte dropCrumbs[] = { 0x00 };
+Image dropCrumbsImage(24, 24, dropCrumbs);
+
void LabEngine::mayShowCrumbIndicator() {
if (getPlatform() != Common::kPlatformWindows)
return;
if (_droppingCrumbs && MainDisplay) {
- static byte dropCrumbs[] = { 0x00 };
- static Image dropCrumbsImage = { 24, 24, dropCrumbs };
-
_event->mouseHide();
- drawMaskImage(&dropCrumbsImage, 612, 4);
+ dropCrumbsImage.drawMaskImage(612, 4);
_event->mouseShow();
}
}
+byte dropCrumbsOff[] = { 0x00 };
+Image dropCrumbsOffImage(24, 24, dropCrumbsOff);
+
void LabEngine::mayShowCrumbIndicatorOff() {
if (getPlatform() != Common::kPlatformWindows)
return;
if (MainDisplay) {
- static byte dropCrumbsOff[] = { 0x00 };
- static Image dropCrumbsOffImage = { 24, 24, dropCrumbsOff };
-
_event->mouseHide();
- drawMaskImage(&dropCrumbsOffImage, 612, 4);
+ dropCrumbsOffImage.drawMaskImage(612, 4);
_event->mouseShow();
}
}
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 145ccb6bba..16283eab5e 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -31,6 +31,7 @@
#include "lab/lab.h"
#include "lab/anim.h"
#include "lab/parsetypes.h"
+#include "lab/image.h"
#include "lab/labfun.h"
#include "lab/parsefun.h"
#include "lab/mouse.h"
@@ -376,7 +377,7 @@ void LabEngine::doScrollBlack() {
im.Height = height;
im.ImageData = mem;
_music->updateMusic();
- readScreenImage(&im, 0, 0);
+ im.readScreenImage(0, 0);
_music->updateMusic();
baseAddr = (uint32 *)getCurrentDrawingBuffer();
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
new file mode 100644
index 0000000000..636ac82d29
--- /dev/null
+++ b/engines/lab/image.cpp
@@ -0,0 +1,183 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/lab.h"
+#include "lab/image.h"
+
+namespace Lab {
+
+/*****************************************************************************/
+/* Reads in an image from disk. */
+/*****************************************************************************/
+Image::Image(byte **buffer) {
+ uint32 size;
+
+ Width = READ_LE_UINT16(*buffer);
+ Height = READ_LE_UINT16(*buffer + 2);
+
+ *buffer += 8; /* sizeof(struct Image); */
+
+ size = Width * Height;
+
+ if (1L & size)
+ size++;
+
+ ImageData = (byte *)(*buffer);
+ (*buffer) += size;
+}
+
+/*****************************************************************************/
+/* Draws an image to the screen. */
+/*****************************************************************************/
+void Image::drawImage(uint16 x, uint16 y) {
+ int sx = 0, sy = 0;
+ int dx = x, dy = y;
+ int w = Width;
+ int h = Height;
+
+ if (dx < 0) {
+ sx -= dx;
+ w += dx;
+ dx = 0;
+ }
+
+ if (dy < 0) {
+ sy -= dy;
+ w += dy;
+ dy = 0;
+ }
+
+ if (dx + w > g_lab->_screenWidth)
+ w = g_lab->_screenWidth - dx;
+
+ if (dy + h > g_lab->_screenHeight)
+ h = g_lab->_screenHeight - dy;
+
+ if ((w > 0) && (h > 0)) {
+ byte *s = ImageData + sy * Width + sx;
+ byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+
+ while (h-- > 0) {
+ memcpy(d, s, w);
+ s += Width;
+ d += g_lab->_screenWidth;
+ }
+ }
+}
+
+/*****************************************************************************/
+/* Draws an image to the screen. */
+/*****************************************************************************/
+void Image::drawMaskImage(uint16 x, uint16 y) {
+ int sx = 0, sy = 0;
+ int dx = x, dy = y;
+ int w = Width;
+ int h = Height;
+
+ if (dx < 0) {
+ sx -= dx;
+ w += dx;
+ dx = 0;
+ }
+
+ if (dy < 0) {
+ sy -= dy;
+ w += dy;
+ dy = 0;
+ }
+
+ if (dx + w > g_lab->_screenWidth)
+ w = g_lab->_screenWidth - dx;
+
+ if (dy + h > g_lab->_screenHeight)
+ h = g_lab->_screenHeight - dy;
+
+ if ((w > 0) && (h > 0)) {
+ byte *s = ImageData + sy * Width + sx;
+ byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+
+ while (h-- > 0) {
+ byte *ss = s;
+ byte *dd = d;
+ int ww = w;
+
+ while (ww-- > 0) {
+ byte c = *ss++;
+
+ if (c) *dd++ = c - 1;
+ else dd++;
+ }
+
+ s += Width;
+ d += g_lab->_screenWidth;
+ }
+ }
+}
+
+/*****************************************************************************/
+/* Reads an image from the screen. */
+/*****************************************************************************/
+void Image::readScreenImage(uint16 x, uint16 y) {
+ int sx = 0, sy = 0;
+ int dx = x, dy = y;
+ int w = Width;
+ int h = Height;
+
+ if (dx < 0) {
+ sx -= dx;
+ w += dx;
+ dx = 0;
+ }
+
+ if (dy < 0) {
+ sy -= dy;
+ w += dy;
+ dy = 0;
+ }
+
+ if (dx + w > g_lab->_screenWidth)
+ w = g_lab->_screenWidth - dx;
+
+ if (dy + h > g_lab->_screenHeight)
+ h = g_lab->_screenHeight - dy;
+
+ if ((w > 0) && (h > 0)) {
+ byte *s = ImageData + sy * Width + sx;
+ byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+
+ while (h-- > 0) {
+ memcpy(s, d, w);
+ s += Width;
+ d += g_lab->_screenWidth;
+ }
+ }
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/image.h b/engines/lab/image.h
new file mode 100644
index 0000000000..c8a001af4d
--- /dev/null
+++ b/engines/lab/image.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_IMAGE_H
+#define LAB_IMAGE_H
+
+namespace Lab {
+
+class Image {
+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(byte **buffer);
+
+ void drawImage(uint16 x, uint16 y);
+ void drawMaskImage(uint16 x, uint16 y);
+ void readScreenImage(uint16 x, uint16 y);
+};
+
+
+} // End of namespace Lab
+
+#endif // LAB_H
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index f786bb8703..fc7ba1e633 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -30,6 +30,7 @@
#include "lab/lab.h"
#include "lab/labfun.h"
+#include "lab/image.h"
#include "lab/interface.h"
#include "lab/mouse.h"
#include "common/util.h"
@@ -81,7 +82,7 @@ void freeButtonList(Gadget *gptrlist) {
/*****************************************************************************/
void drawGadgetList(Gadget *gadlist) {
while (gadlist) {
- g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
+ gadlist->Im->drawImage(gadlist->x, gadlist->y);
if (GADGETOFF & gadlist->GadgetFlags)
ghoastGadget(gadlist, 1);
@@ -105,7 +106,7 @@ void ghoastGadget(Gadget *curgad, uint16 pencolor) {
/* Unghoasts a gadget, and makes it available again. */
/*****************************************************************************/
void unGhoastGadget(Gadget *curgad) {
- g_lab->drawImage(curgad->Im, curgad->x, curgad->y);
+ curgad->Im->drawImage(curgad->x, curgad->y);
curgad->GadgetFlags &= !(GADGETOFF);
}
@@ -132,11 +133,11 @@ Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
(gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
&& !(GADGETOFF & gadlist->GadgetFlags)) {
_event->mouseHide();
- g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+ gadlist->ImAlt->drawImage(gadlist->x, gadlist->y);
_event->mouseShow();
g_system->delayMillis(80);
_event->mouseHide();
- g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
+ gadlist->Im->drawImage(gadlist->x, gadlist->y);
_event->mouseShow();
return gadlist;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 9327dbf562..b7cf6e1771 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -51,12 +51,6 @@ enum GameFeatures {
GF_WINDOWS_TRIAL = 1 << 1
};
-struct Image {
- uint16 Width;
- uint16 Height;
- byte *ImageData;
-};
-
#define ONESECOND 1000
class LabEngine : public Engine {
@@ -143,7 +137,6 @@ public:
void setAPen(byte pennum);
void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
byte *getCurrentDrawingBuffer();
- void readScreenImage(Image *Im, uint16 x, uint16 y);
void screenUpdate();
void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
@@ -153,7 +146,6 @@ public:
void setPalette(void *cmap, uint16 numcolors);
void drawHLine(uint16 x, uint16 y1, uint16 y2);
void drawVLine(uint16 x1, uint16 y, uint16 x2);
- void drawImage(Image *Im, uint16 x, uint16 y);
bool haveNextChar();
uint16 getNextChar();
void processInput(bool can_delay = false);
@@ -193,7 +185,6 @@ private:
/*---------- Drawing Routines ----------*/
- void drawMaskImage(Image *Im, uint16 x, uint16 y);
Common::Point getMousePos();
void changeVolume(int delta);
void applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index c1a6b35a09..52f6034477 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -54,7 +54,7 @@ class LabEngine;
#define EAST 2
#define WEST 3
-struct Image;
+class Image;
struct TextFont;
struct Gadget;
@@ -188,7 +188,6 @@ char *translateFileName(const char *filename);
void fade(bool fadein, uint16 res);
void setAmigaPal(uint16 *pal, uint16 numcolors);
-void readImage(byte **buffer, Image **im);
void doMap(uint16 CurRoom);
void doJournal();
void doNotes();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 1f4f0dbfe1..d7a3e124ca 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -31,6 +31,7 @@
#include "lab/lab.h"
#include "lab/labfun.h"
#include "lab/anim.h"
+#include "lab/image.h"
#include "lab/text.h"
#include "lab/mouse.h"
#include "lab/parsefun.h"
@@ -65,30 +66,6 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
g_lab->writeColorRegsSmooth(vgapal, 0, 16);
}
-
-/*****************************************************************************/
-/* Reads in an image from disk. */
-/*****************************************************************************/
-void readImage(byte **buffer, Image **im) {
- uint32 size;
-
- (*im) = (Image *)(*buffer);
-
- (*im)->Width = READ_LE_UINT16(*buffer);
- (*im)->Height = READ_LE_UINT16(*buffer + 2);
-
- *buffer += 8; /* sizeof(struct Image); */
-
- size = (*im)->Width * (*im)->Height;
-
- if (1L & size)
- size++;
-
- (*im)->ImageData = (byte *)(*buffer);
- (*buffer) += size;
-}
-
-
/*---------------------------------------------------------------------------*/
/*------------------------------ The Map stuff ------------------------------*/
/*---------------------------------------------------------------------------*/
@@ -169,30 +146,30 @@ static bool loadMapData() {
stealBufMem(Size); /* Now freeze that buffer from further use */
- readImage(buffer, &Map);
+ Map = new Image(buffer);
- readImage(buffer, &Room);
- readImage(buffer, &UpArrowRoom);
- readImage(buffer, &DownArrowRoom);
- readImage(buffer, &HRoom);
- readImage(buffer, &VRoom);
- readImage(buffer, &Maze);
- readImage(buffer, &HugeMaze);
+ Room = new Image(buffer);
+ UpArrowRoom = new Image(buffer);
+ DownArrowRoom = new Image(buffer);
+ HRoom = new Image(buffer);
+ VRoom = new Image(buffer);
+ Maze = new Image(buffer);
+ HugeMaze = new Image(buffer);
- readImage(buffer, &MapNorth);
- readImage(buffer, &MapEast);
- readImage(buffer, &MapSouth);
- readImage(buffer, &MapWest);
+ MapNorth = new Image(buffer);
+ MapEast = new Image(buffer);
+ MapSouth = new Image(buffer);
+ MapWest = new Image(buffer);
- readImage(buffer, &Path);
- readImage(buffer, &Bridge);
+ Path = new Image(buffer);
+ Bridge = new Image(buffer);
- readImage(buffer, &Back);
- readImage(buffer, &BackAlt);
- readImage(buffer, &Up);
- readImage(buffer, &UpAlt);
- readImage(buffer, &Down);
- readImage(buffer, &DownAlt);
+ Back = new Image(buffer);
+ BackAlt = new Image(buffer);
+ Up = new Image(buffer);
+ UpAlt = new Image(buffer);
+ Down = new Image(buffer);
+ DownAlt = new Image(buffer);
backgadget.Im = Back;
backgadget.ImAlt = BackAlt;
@@ -325,27 +302,27 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
case UPARROWROOM:
case DOWNARROWROOM:
if (Maps[CurRoom].SpecialID == NORMAL)
- g_lab->drawImage(Room, x, y);
+ Room->drawImage(x, y);
else if (Maps[CurRoom].SpecialID == DOWNARROWROOM)
- g_lab->drawImage(DownArrowRoom, x, y);
+ DownArrowRoom->drawImage(x, y);
else
- g_lab->drawImage(UpArrowRoom, x, y);
+ UpArrowRoom->drawImage(x, y);
offset = (Room->Width - Path->Width) / 2;
if ((NORTHDOOR & flags) && (y >= Path->Height))
- g_lab->drawImage(Path, x + offset, y - Path->Height);
+ Path->drawImage(x + offset, y - Path->Height);
if (SOUTHDOOR & flags)
- g_lab->drawImage(Path, x + offset, y + Room->Height);
+ Path->drawImage(x + offset, y + Room->Height);
offset = (Room->Height - Path->Height) / 2;
if (EASTDOOR & flags)
- g_lab->drawImage(Path, x + Room->Width, y + offset);
+ Path->drawImage(x + Room->Width, y + offset);
if (WESTDOOR & flags)
- g_lab->drawImage(Path, x - Path->Width, y + offset);
+ Path->drawImage(x - Path->Width, y + offset);
xx = x + (Room->Width - XMark->Width) / 2;
xy = y + (Room->Height - XMark->Height) / 2;
@@ -353,7 +330,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
break;
case BRIDGEROOM:
- g_lab->drawImage(Bridge, x, y);
+ Bridge->drawImage(x, y);
xx = x + (Bridge->Width - XMark->Width) / 2;
xy = y + (Bridge->Height - XMark->Height) / 2;
@@ -361,37 +338,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
break;
case VCORRIDOR:
- g_lab->drawImage(VRoom, x, y);
+ VRoom->drawImage(x, y);
offset = (VRoom->Width - Path->Width) / 2;
if (NORTHDOOR & flags)
- g_lab->drawImage(Path, x + offset, y - Path->Height);
+ Path->drawImage(x + offset, y - Path->Height);
if (SOUTHDOOR & flags)
- g_lab->drawImage(Path, x + offset, y + VRoom->Height);
+ Path->drawImage(x + offset, y + VRoom->Height);
offset = (Room->Height - Path->Height) / 2;
if (EASTDOOR & flags)
- g_lab->drawImage(Path, x + VRoom->Width, y + offset);
+ Path->drawImage(x + VRoom->Width, y + offset);
if (WESTDOOR & flags)
- g_lab->drawImage(Path, x - Path->Width, y + offset);
+ Path->drawImage(x - Path->Width, y + offset);
if (EASTBDOOR & flags)
- g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+ Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
if (WESTBDOOR & flags)
- g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+ Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height);
offset = (VRoom->Height - Path->Height) / 2;
if (EASTMDOOR & flags)
- g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+ Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
if (WESTMDOOR & flags)
- g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+ Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height);
xx = x + (VRoom->Width - XMark->Width) / 2;
xy = y + (VRoom->Height - XMark->Height) / 2;
@@ -399,37 +376,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
break;
case HCORRIDOR:
- g_lab->drawImage(HRoom, x, y);
+ HRoom->drawImage(x, y);
offset = (Room->Width - Path->Width) / 2;
if (NORTHDOOR & flags)
- g_lab->drawImage(Path, x + offset, y - Path->Height);
+ Path->drawImage(x + offset, y - Path->Height);
if (SOUTHDOOR & flags)
- g_lab->drawImage(Path, x + offset, y + Room->Height);
+ Path->drawImage(x + offset, y + Room->Height);
if (NORTHRDOOR & flags)
- g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+ Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height);
if (SOUTHRDOOR & flags)
- g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+ Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height);
offset = (HRoom->Width - Path->Width) / 2;
if (NORTHMDOOR & flags)
- g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+ Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height);
if (SOUTHMDOOR & flags)
- g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+ Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height);
offset = (Room->Height - Path->Height) / 2;
if (EASTDOOR & flags)
- g_lab->drawImage(Path, x + HRoom->Width, y + offset);
+ Path->drawImage(x + HRoom->Width, y + offset);
if (WESTDOOR & flags)
- g_lab->drawImage(Path, x - Path->Width, y + offset);
+ Path->drawImage(x - Path->Width, y + offset);
xx = x + (HRoom->Width - XMark->Width) / 2;
xy = y + (HRoom->Height - XMark->Height) / 2;
@@ -441,7 +418,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
}
if (drawx)
- g_lab->drawImage(XMark, xx, xy);
+ XMark->drawImage(xx, xy);
}
/*****************************************************************************/
@@ -528,7 +505,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
setAPen(0);
rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
- drawImage(Map, 0, 0);
+ Map->drawImage(0, 0);
drawGadgetList(MapGadgetList);
for (uint16 i = 1; i <= MaxRooms; i++) {
@@ -562,16 +539,16 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
// Labyrinth specific code
if (Floor == LOWERFLOOR) {
if (onFloor(SURMAZEFLOOR))
- drawImage(Maze, mapScaleX(538), mapScaleY(277));
+ Maze->drawImage(mapScaleX(538), mapScaleY(277));
} else if (Floor == MIDDLEFLOOR) {
if (onFloor(CARNIVAL))
- drawImage(Maze, mapScaleX(358), mapScaleY(72));
+ Maze->drawImage(mapScaleX(358), mapScaleY(72));
if (onFloor(MEDMAZEFLOOR))
- drawImage(Maze, mapScaleX(557), mapScaleY(325));
+ Maze->drawImage(mapScaleX(557), mapScaleY(325));
} else if (Floor == UPPERFLOOR) {
if (onFloor(HEDGEMAZEFLOOR))
- drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
+ HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
} else if (Floor == SURMAZEFLOOR) {
sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 4f1ace8c9c..b21a3ea23b 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
detection.o \
engine.o \
graphics.o \
+ image.o \
interface.o \
intro.o \
lab.o \
@@ -32,4 +33,3 @@ endif
# Include common rules
include $(srcdir)/rules.mk
-
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 9ff5117ff6..4bd6c7f8d8 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -29,6 +29,7 @@
*/
#include "lab/lab.h"
+#include "lab/image.h"
#include "lab/mouse.h"
#include "lab/interface.h"
@@ -76,14 +77,14 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
hitgad = gadlist;
} else {
mouseHide();
- _vm->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+ gadlist->ImAlt->drawImage(gadlist->x, gadlist->y);
mouseShow();
for (uint16 i = 0; i < 3; i++)
_vm->waitTOF();
mouseHide();
- _vm->drawImage(gadlist->Im, gadlist->x, gadlist->y);
+ gadlist->Im->drawImage(gadlist->x, gadlist->y);
mouseShow();
}
@@ -135,14 +136,14 @@ void EventManager::updateMouse() {
if (hitgad) {
mouseHide();
- _vm->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
+ hitgad->ImAlt->drawImage(hitgad->x, hitgad->y);
mouseShow();
for (uint16 i = 0; i < 3; i++)
_vm->waitTOF();
mouseHide();
- _vm->drawImage(hitgad->Im, hitgad->x, hitgad->y);
+ hitgad->Im->drawImage(hitgad->x, hitgad->y);
mouseShow();
doUpdateDisplay = true;
hitgad = NULL;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index afe3efb64f..6f70cb0f1a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -35,6 +35,7 @@
#include "lab/lab.h"
#include "lab/labfun.h"
+#include "lab/image.h"
#include "lab/parsefun.h"
#include "lab/interface.h"
#include "lab/anim.h"
@@ -132,7 +133,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
/*****************************************************************************/
static void doCombination() {
for (uint16 i = 0; i <= 5; i++)
- g_lab->drawImage(Images[combination[i]], VGAScaleX(combx[i]), VGAScaleY(65));
+ Images[combination[i]]->drawImage(VGAScaleX(combx[i]), VGAScaleY(65));
}
/*****************************************************************************/
@@ -152,7 +153,7 @@ void showCombination(const char *filename) {
buffer = g_lab->_music->newOpen("P:Numbers");
for (uint16 CurBit = 0; CurBit < 10; CurBit++)
- readImage(buffer, &(Images[CurBit]));
+ Images[CurBit] = new Image(buffer);
allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
@@ -267,7 +268,7 @@ static void doTile(bool showsolution) {
num = CurTile[col] [row];
if (showsolution || num)
- g_lab->drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm));
+ Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
col++;
}
@@ -303,7 +304,7 @@ void showTile(const char *filename, bool showsolution) {
return;
for (uint16 curBit = start; curBit < 16; curBit++)
- readImage(buffer, &(Tiles[curBit]));
+ Tiles[curBit] = new Image(buffer);
allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
@@ -550,12 +551,12 @@ static bool loadJournalData() {
if (!buffer)
return false;
- readImage(buffer, &(BackG.Im));
- readImage(buffer, &(BackG.ImAlt));
- readImage(buffer, &(ForwardG.Im));
- readImage(buffer, &(ForwardG.ImAlt));
- readImage(buffer, &(CancelG.Im));
- readImage(buffer, &(CancelG.ImAlt));
+ BackG.Im = new Image(buffer);
+ BackG.ImAlt = new Image(buffer);
+ ForwardG.Im = new Image(buffer);
+ ForwardG.ImAlt = new Image(buffer);
+ CancelG.Im = new Image(buffer);
+ CancelG.ImAlt = new Image(buffer);
BackG.KeyEquiv = VKEY_LTARROW;
ForwardG.KeyEquiv = VKEY_RTARROW;
@@ -819,7 +820,7 @@ static void getMonImages() {
if (!buffer)
return;
- readImage(buffer, &MonButton);
+ MonButton = new Image(buffer);
stealBufMem(bufferSize); /* Trick: protects the memory where the buttons are so they won't be over-written */
}
@@ -855,7 +856,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
rectFill(0, 0, _screenWidth - 1, y2);
for (uint16 i = 0; i < numlines; i++)
- drawImage(MonButton, 0, i * MonGadHeight);
+ MonButton->drawImage(0, i * MonGadHeight);
} else if (isinteractive) {
setAPen(0);
rectFill(0, 0, _screenWidth - 1, y2);
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 326b1f4117..4c8169eb6d 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -32,6 +32,7 @@
#include "common/events.h"
#include "lab/lab.h"
+#include "lab/image.h"
#include "lab/mouse.h"
namespace Lab {
@@ -250,133 +251,6 @@ byte *LabEngine::getCurrentDrawingBuffer() {
}
/*****************************************************************************/
-/* Draws an image to the screen. */
-/*****************************************************************************/
-void LabEngine::drawImage(Image *im, uint16 x, uint16 y) {
- int sx = 0, sy = 0;
- int dx = x, dy = y;
- int w = im->Width;
- int h = im->Height;
-
- if (dx < 0) {
- sx -= dx;
- w += dx;
- dx = 0;
- }
-
- if (dy < 0) {
- sy -= dy;
- w += dy;
- dy = 0;
- }
-
- if (dx + w > _screenWidth)
- w = _screenWidth - dx;
-
- if (dy + h > _screenHeight)
- h = _screenHeight - dy;
-
- if ((w > 0) && (h > 0)) {
- byte *s = im->ImageData + sy * im->Width + sx;
- byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
-
- while (h-- > 0) {
- memcpy(d, s, w);
- s += im->Width;
- d += _screenWidth;
- }
- }
-}
-
-/*****************************************************************************/
-/* Draws an image to the screen. */
-/*****************************************************************************/
-void LabEngine::drawMaskImage(Image *im, uint16 x, uint16 y) {
- int sx = 0, sy = 0;
- int dx = x, dy = y;
- int w = im->Width;
- int h = im->Height;
-
- if (dx < 0) {
- sx -= dx;
- w += dx;
- dx = 0;
- }
-
- if (dy < 0) {
- sy -= dy;
- w += dy;
- dy = 0;
- }
-
- if (dx + w > _screenWidth)
- w = _screenWidth - dx;
-
- if (dy + h > _screenHeight)
- h = _screenHeight - dy;
-
- if ((w > 0) && (h > 0)) {
- byte *s = im->ImageData + sy * im->Width + sx;
- byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
-
- while (h-- > 0) {
- byte *ss = s;
- byte *dd = d;
- int ww = w;
-
- while (ww-- > 0) {
- byte c = *ss++;
-
- if (c) *dd++ = c - 1;
- else dd++;
- }
-
- s += im->Width;
- d += _screenWidth;
- }
- }
-}
-
-/*****************************************************************************/
-/* Reads an image from the screen. */
-/*****************************************************************************/
-void LabEngine::readScreenImage(Image *im, uint16 x, uint16 y) {
- int sx = 0, sy = 0;
- int dx = x, dy = y;
- int w = im->Width;
- int h = im->Height;
-
- if (dx < 0) {
- sx -= dx;
- w += dx;
- dx = 0;
- }
-
- if (dy < 0) {
- sy -= dy;
- w += dy;
- dy = 0;
- }
-
- if (dx + w > _screenWidth)
- w = _screenWidth - dx;
-
- if (dy + h > _screenHeight)
- h = _screenHeight - dy;
-
- if ((w > 0) && (h > 0)) {
- byte *s = im->ImageData + sy * im->Width + sx;
- byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
-
- while (h-- > 0) {
- memcpy(s, d, w);
- s += im->Width;
- d += _screenWidth;
- }
- }
-}
-
-/*****************************************************************************/
/* Blits a piece of one image to another. */
/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory. */
/*****************************************************************************/
@@ -448,8 +322,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
im.Width = x2 - x1 + 1 - dx;
im.Height = y2 - y1 + 1;
- readScreenImage(&im, x1, y1);
- drawImage(&im, x1 + dx, y1);
+ im.readScreenImage(x1, y1);
+ im.drawImage(x1 + dx, y1);
setAPen(0);
rectFill(x1, y1, x1 + dx - 1, y2);
@@ -457,8 +331,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
im.Width = x2 - x1 + 1 + dx;
im.Height = y2 - y1 + 1;
- readScreenImage(&im, x1 - dx, y1);
- drawImage(&im, x1, y1);
+ im.readScreenImage(x1 - dx, y1);
+ im.drawImage(x1, y1);
setAPen(0);
rectFill(x2 + dx + 1, y1, x2, y2);
@@ -490,8 +364,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
im.Width = x2 - x1 + 1;
im.Height = y2 - y1 + 1 - dy;
- readScreenImage(&im, x1, y1);
- drawImage(&im, x1, y1 + dy);
+ im.readScreenImage(x1, y1);
+ im.drawImage(x1, y1 + dy);
setAPen(0);
rectFill(x1, y1, x2, y1 + dy - 1);
@@ -499,8 +373,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
im.Width = x2 - x1 + 1;
im.Height = y2 - y1 + 1 + dy;
- readScreenImage(&im, x1, y1 - dy);
- drawImage(&im, x1, y1);
+ im.readScreenImage(x1, y1 - dy);
+ im.drawImage(x1, y1);
setAPen(0);
rectFill(x1, y2 + dy + 1, x2, y2);