aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/engine.cpp14
-rw-r--r--engines/lab/graphics.cpp20
-rw-r--r--engines/lab/graphics.h2
-rw-r--r--engines/lab/interface.h1
-rw-r--r--engines/lab/lab.cpp365
-rw-r--r--engines/lab/lab.h24
-rw-r--r--engines/lab/labfun.h6
-rw-r--r--engines/lab/savegame.cpp10
-rw-r--r--engines/lab/special.cpp338
9 files changed, 396 insertions, 384 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 293c9452cd..f3cda0e8bf 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -121,15 +121,15 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
}
void LabEngine::freeScreens() {
- for (uint16 i = 0; i < 20; i++)
+ for (uint16 i = 0; i < 20; i++) {
delete _moveImages[i];
+ _moveImages[i] = nullptr;
+ }
- if (getPlatform() == Common::kPlatformWindows) {
- for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
- delete _invImages[imgIdx];
- } else {
- for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
- delete _invImages[imgIdx];
+ for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
+ delete _invImages[imgIdx];
+ delete Images[imgIdx];
+ _invImages[imgIdx] = Images[imgIdx] = nullptr;
}
}
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 80888d21e7..be71769bed 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -99,26 +99,6 @@ uint16 DisplayMan::SVGACord(uint16 cord) {
return 0;
}
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
-/*****************************************************************************/
-int VGAUnScaleX(int x) {
- if (g_lab->_isHiRes)
- return (x / 2);
- else
- return x;
-}
-
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
-/*****************************************************************************/
-int VGAUnScaleY(int y) {
- if (g_lab->_isHiRes)
- return ((y * 5) / 12);
- else
- return y;
-}
-
/*---------------------------------------------------------------------------*/
/*------ From readPict.c. Reads in pictures and animations from disk. ------*/
/*---------------------------------------------------------------------------*/
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index de2053a002..aac7e58983 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -53,8 +53,6 @@ public:
int16 VGAScaleX(int16 x);
int16 VGAScaleY(int16 y);
uint16 SVGACord(uint16 cord);
- int VGAUnScaleX(int x);
- int VGAUnScaleY(int y);
bool readPict(const char *filename, bool playOnce);
byte *readPictToMem(const char *filename, uint16 x, uint16 y);
void doScrollBlack();
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index de770f0ae1..42cfb2f0a9 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -29,6 +29,7 @@
*/
#include "common/keyboard.h"
+#include "lab/image.h"
#ifndef LAB_INTEFACE_H
#define LAB_INTEFACE_H
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index efa675299f..33c507873e 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -45,12 +45,28 @@
#include "lab/labfun.h"
#include "lab/resource.h"
#include "lab/anim.h"
-
+#include "lab/graphics.h"
namespace Lab {
LabEngine *g_lab;
+const uint16 INIT_TILE[4][4] = {
+ { 1, 5, 9, 13 },
+ { 2, 6, 10, 14 },
+ { 3, 7, 11, 15 },
+ { 4, 8, 12, 0 }
+};
+
+const uint16 SOLUTION[4][4] = {
+ { 7, 1, 8, 3 },
+ { 2, 11, 15, 4 },
+ { 9, 5, 14, 6 },
+ { 10, 13, 12, 0 }
+};
+
+const int COMBINATION_X[6] = { 45, 83, 129, 166, 211, 248 };
+
LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
: Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
g_lab = this;
@@ -92,8 +108,10 @@ 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;
+ Images[i] = nullptr;
+ }
_moveGadgetList = nullptr;
_invGadgetList = nullptr;
@@ -109,6 +127,17 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
_inventory = 0;
+ for (int i = 0; i < 16; i++)
+ Tiles[i] = nullptr;
+
+ for (int i= 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++)
+ CurTile[i][j] = INIT_TILE[i][j];
+ }
+
+ for (int i = 0; i < 6; i++)
+ combination[i] = 0;
+
//const Common::FSNode gameDataDir(ConfMan.get("path"));
//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
@@ -125,6 +154,9 @@ LabEngine::~LabEngine() {
delete _music;
delete _anim;
delete _graphics;
+
+ for (int i = 0; i < 16; i++)
+ delete Tiles[i];
}
Common::Error LabEngine::run() {
@@ -182,8 +214,333 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
return Common::String::format("%s.%03u", _targetName.c_str(), slot);
}
-/*void LabEngine::showMainMenu() {
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
+/*****************************************************************************/
+int LabEngine::VGAUnScaleX(int x) {
+ if (_isHiRes)
+ return (x / 2);
+ else
+ return x;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords. */
+/*****************************************************************************/
+int LabEngine::VGAUnScaleY(int y) {
+ if (_isHiRes)
+ return ((y * 5) / 12);
+ else
+ return y;
+}
+
+/*****************************************************************************/
+/* Processes mouse clicks and changes the combination. */
+/*****************************************************************************/
+void LabEngine::mouseTile(Common::Point pos) {
+ int x = VGAUnScaleX(pos.x);
+ int y = VGAUnScaleY(pos.y);
+
+ if ((x < 101) || (y < 26))
+ return;
+
+ x = (x - 101) / 30;
+ y = (y - 26) / 25;
+
+ if ((x < 4) && (y < 4))
+ changeTile(x, y);
+}
+
+/*****************************************************************************/
+/* Changes the combination number of one of the slots */
+/*****************************************************************************/
+void LabEngine::changeTile(uint16 col, uint16 row) {
+ int16 scrolltype = -1;
+
+ if (row > 0) {
+ if (CurTile[col] [row - 1] == 0) {
+ CurTile[col] [row - 1] = CurTile[col] [row];
+ CurTile[col] [row] = 0;
+ scrolltype = DOWNSCROLL;
+ }
+ }
+
+ if (col > 0) {
+ if (CurTile[col - 1] [row] == 0) {
+ CurTile[col - 1] [row] = CurTile[col] [row];
+ CurTile[col] [row] = 0;
+ scrolltype = RIGHTSCROLL;
+ }
+ }
+
+ if (row < 3) {
+ if (CurTile[col] [row + 1] == 0) {
+ CurTile[col] [row + 1] = CurTile[col] [row];
+ CurTile[col] [row] = 0;
+ scrolltype = UPSCROLL;
+ }
+ }
+
+ if (col < 3) {
+ if (CurTile[col + 1] [row] == 0) {
+ CurTile[col + 1] [row] = CurTile[col] [row];
+ CurTile[col] [row] = 0;
+ scrolltype = LEFTSCROLL;
+ }
+ }
+
+ if (scrolltype != -1) {
+ doTileScroll(col, row, scrolltype);
+
+ if (getFeatures() & GF_WINDOWS_TRIAL) {
+ GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
+ trialMessage.runModal();
+ return;
+ }
+
+ bool check = true;
+ row = 0;
+ col = 0;
+
+ while (row < 4) {
+ while (col < 4) {
+ check = check && (CurTile[row] [col] == SOLUTION[row] [col]);
+ col++;
+ }
+
+ row++;
+ col = 0;
+ }
+
+ if (check) {
+ _conditions->inclElement(BRICKOPEN); /* unlocked combination */
+ _anim->_doBlack = true;
+ check = _graphics->readPict("p:Up/BDOpen", true);
+ }
+ }
+}
+
+/*****************************************************************************/
+/* Processes mouse clicks and changes the combination. */
+/*****************************************************************************/
+void LabEngine::mouseCombination(Common::Point pos) {
+ uint16 number;
+
+ int x = VGAUnScaleX(pos.x);
+ int y = VGAUnScaleY(pos.y);
+
+ if ((y >= 63) && (y <= 99)) {
+ if ((x >= 44) && (x < 83))
+ number = 0;
+ else if (x < 127)
+ number = 1;
+ else if (x < 165)
+ number = 2;
+ else if (x < 210)
+ number = 3;
+ else if (x < 245)
+ number = 4;
+ else if (x < 286)
+ number = 5;
+ else
+ return;
+
+ changeCombination(number);
+ }
+}
+
+/*****************************************************************************/
+/* Draws the images of the combination lock to the display bitmap. */
+/*****************************************************************************/
+void LabEngine::doTile(bool showsolution) {
+ uint16 row = 0, col = 0, rowm, colm, num;
+ int16 rows, cols;
+
+ if (showsolution) {
+ rowm = _graphics->VGAScaleY(23);
+ colm = _graphics->VGAScaleX(27);
-}*/
+ rows = _graphics->VGAScaleY(31);
+ cols = _graphics->VGAScaleX(105);
+ } else {
+ _graphics->setAPen(0);
+ _graphics->rectFill(_graphics->VGAScaleX(97), _graphics->VGAScaleY(22), _graphics->VGAScaleX(220), _graphics->VGAScaleY(126));
+
+ rowm = _graphics->VGAScaleY(25);
+ colm = _graphics->VGAScaleX(30);
+
+ rows = _graphics->VGAScaleY(25);
+ cols = _graphics->VGAScaleX(100);
+ }
+
+ while (row < 4) {
+ while (col < 4) {
+ if (showsolution)
+ num = SOLUTION[col] [row];
+ else
+ num = CurTile[col] [row];
+
+ if (showsolution || num)
+ Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
+
+ col++;
+ }
+
+ row++;
+ col = 0;
+ }
+}
+
+/*****************************************************************************/
+/* Reads in a backdrop picture. */
+/*****************************************************************************/
+void LabEngine::showTile(const char *filename, bool showsolution) {
+ uint16 start = showsolution ? 0 : 1;
+
+ resetBuffer();
+ g_lab->_anim->_doBlack = true;
+ g_lab->_anim->_noPalChange = true;
+ g_lab->_graphics->readPict(filename, true);
+ g_lab->_anim->_noPalChange = false;
+ g_lab->_graphics->blackScreen();
+
+ Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
+
+ for (uint16 curBit = start; curBit < 16; curBit++)
+ Tiles[curBit] = new Image(tileFile);
+
+ delete tileFile;
+
+ allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
+
+ g_lab->doTile(showsolution);
+ g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+}
+
+/*****************************************************************************/
+/* Does the scrolling for the tiles on the tile puzzle. */
+/*****************************************************************************/
+void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
+ int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
+ uint16 last = 0, x1, y1;
+
+ if (scrolltype == LEFTSCROLL) {
+ dX = g_lab->_graphics->VGAScaleX(5);
+ sx = g_lab->_graphics->VGAScaleX(5);
+ last = 6;
+ } else if (scrolltype == RIGHTSCROLL) {
+ dX = g_lab->_graphics->VGAScaleX(-5);
+ dx = g_lab->_graphics->VGAScaleX(-5);
+ sx = g_lab->_graphics->VGAScaleX(5);
+ last = 6;
+ } else if (scrolltype == UPSCROLL) {
+ dY = g_lab->_graphics->VGAScaleY(5);
+ sy = g_lab->_graphics->VGAScaleY(5);
+ last = 5;
+ } else if (scrolltype == DOWNSCROLL) {
+ dY = g_lab->_graphics->VGAScaleY(-5);
+ dy = g_lab->_graphics->VGAScaleY(-5);
+ sy = g_lab->_graphics->VGAScaleY(5);
+ last = 5;
+ }
+
+ sx += g_lab->_graphics->SVGACord(2);
+
+ x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx;
+ y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy;
+
+ for (uint16 i = 0; i < last; i++) {
+ g_lab->waitTOF();
+ scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy);
+ x1 += dX;
+ y1 += dY;
+ }
+}
+
+/*****************************************************************************/
+/* Changes the combination number of one of the slots */
+/*****************************************************************************/
+void LabEngine::changeCombination(uint16 number) {
+ static const int solution[6] = { 0, 4, 0, 8, 7, 2 };
+
+ Image display;
+ uint16 combnum;
+ bool unlocked = true;
+
+ if (combination[number] < 9)
+ (combination[number])++;
+ else
+ combination[number] = 0;
+
+ combnum = combination[number];
+
+ display._imageData = g_lab->getCurrentDrawingBuffer();
+ display._width = g_lab->_screenWidth;
+ display._height = g_lab->_screenHeight;
+
+ for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
+ if (g_lab->_isHiRes) {
+ if (i & 1)
+ g_lab->waitTOF();
+ } else
+ g_lab->waitTOF();
+
+ display._imageData = g_lab->getCurrentDrawingBuffer();
+
+ g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(COMBINATION_X[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height);
+
+ Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(COMBINATION_X[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
+ }
+
+ for (uint16 i = 0; i < 6; i++)
+ unlocked = (combination[i] == solution[i]) && unlocked;
+
+ if (unlocked)
+ _conditions->inclElement(COMBINATIONUNLOCKED);
+ else
+ _conditions->exclElement(COMBINATIONUNLOCKED);
+}
+
+void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+ if (dx)
+ scrollDisplayX(dx, x1, y1, x2, y2);
+
+ if (dy)
+ scrollDisplayY(dy, x1, y1, x2, y2);
+}
+
+/*****************************************************************************/
+/* Draws the images of the combination lock to the display bitmap. */
+/*****************************************************************************/
+void LabEngine::doCombination() {
+ for (uint16 i = 0; i <= 5; i++)
+ Images[combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
+}
+
+/*****************************************************************************/
+/* Reads in a backdrop picture. */
+/*****************************************************************************/
+void LabEngine::showCombination(const char *filename) {
+ resetBuffer();
+ g_lab->_anim->_doBlack = true;
+ g_lab->_anim->_noPalChange = true;
+ g_lab->_graphics->readPict(filename, true);
+ g_lab->_anim->_noPalChange = false;
+
+ g_lab->_graphics->blackScreen();
+
+ Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers");
+
+ for (uint16 CurBit = 0; CurBit < 10; CurBit++)
+ Images[CurBit] = new Image(numFile);
+
+ delete numFile;
+
+ allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
+
+ doCombination();
+
+ g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+}
} // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 9cf28dfbc8..b109ac61c1 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -52,7 +52,13 @@ enum GameFeatures {
GF_WINDOWS_TRIAL = 1 << 1
};
-#define ONESECOND 1000
+#define ONESECOND 1000
+#define BRICKOPEN 115
+#define COMBINATIONUNLOCKED 130
+#define LEFTSCROLL 1
+#define RIGHTSCROLL 2
+#define UPSCROLL 3
+#define DOWNSCROLL 4
class LabEngine : public Engine {
public:
@@ -124,12 +130,16 @@ public:
Gadget *_invGadgetList;
Image *_moveImages[20];
Image *_invImages[10];
+ Image *Images[10];
+ uint16 CurTile[4][4];
+ byte combination[6];
private:
int _lastWaitTOFTicks;
bool _lastTooLong;
CloseDataPtr _cptr;
InventoryData *_inventory;
+ Image *Tiles[16];
private:
bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
@@ -175,6 +185,18 @@ private:
void mayShowCrumbIndicator();
void mayShowCrumbIndicatorOff();
const char *getInvName(uint16 curInv);
+ int VGAUnScaleX(int x);
+ int VGAUnScaleY(int y);
+ void mouseTile(Common::Point pos);
+ void changeTile(uint16 col, uint16 row);
+ void mouseCombination(Common::Point pos);
+ void doTile(bool showsolution);
+ void showTile(const char *filename, bool showsolution);
+ void doTileScroll(uint16 col, uint16 row, uint16 scrolltype);
+ void changeCombination(uint16 number);
+ void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+ void doCombination();
+ void showCombination(const char *filename);
bool saveRestoreGame();
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index d81de5c4e5..558abe1a80 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -54,7 +54,6 @@ class LabEngine;
#define EAST 2
#define WEST 3
-class Image;
struct TextFont;
struct Gadget;
@@ -140,8 +139,6 @@ public:
/*----- From Machine.c ------*/
/*---------------------------*/
-int VGAUnScaleX(int x);
-int VGAUnScaleY(int y);
char *translateFileName(const char *filename);
/*---------------------------*/
@@ -169,9 +166,6 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
/*--------------------------*/
void showCombination(const char *filename);
-void mouseCombination(Common::Point pos);
-void showTile(const char *filename, bool showsolution);
-void mouseTile(Common::Point pos);
} // End of namespace Lab
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 7f56c8e64e..d97a03688f 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -51,8 +51,6 @@ namespace Lab {
/* Lab: Labyrinth specific */
-extern byte combination[6];
-extern uint16 CurTile[4] [4];
extern char *getPictName(CloseDataPtr *lcptr);
void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
@@ -155,12 +153,12 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
// Combination lock and tile stuff
for (i = 0; i < 6; i++)
- file->writeByte(combination[i]);
+ file->writeByte(g_lab->combination[i]);
// Tiles
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
- file->writeUint16LE(CurTile[i][j]);
+ file->writeUint16LE(g_lab->CurTile[i][j]);
// Breadcrumbs
for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) {
@@ -205,12 +203,12 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
// Combination lock and tile stuff
for (i = 0; i < 6; i++)
- combination[i] = file->readByte();
+ g_lab->combination[i] = file->readByte();
// Tiles
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
- CurTile[i][j] = file->readUint16LE();
+ g_lab->CurTile[i][j] = file->readUint16LE();
// Breadcrumbs
for (i = 0; i < 128; i++) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3be558b8af..3f26fbcbae 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -48,11 +48,6 @@ namespace Lab {
static uint16 MonGadHeight = 1;
static uint16 hipal[20];
-// Combination lock rules
-static Image *Images[10];
-byte combination[6] = { 0, 0, 0, 0, 0, 0 }, solution[] = { 0, 4, 0, 8, 7, 2 };
-static uint16 combx[] = { 45, 83, 129, 166, 211, 248 };
-
static TextFont *journalFont;
static char *journaltext, *journaltexttitle;
static uint16 JPage = 0;
@@ -67,33 +62,13 @@ static const char *TextFileName;
Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
*MonDown, *AltMonDown, *MonUp, *AltMonUp;
-// Tile puzzle rules
-Image *Tiles[16];
-uint16 CurTile[4][4] = {
- { 1, 5, 9, 13 },
- { 2, 6, 10, 14 },
- { 3, 7, 11, 15 },
- { 4, 8, 12, 0 }
-}, TileSolution[4][4] = {
- { 7, 1, 8, 3 },
- { 2, 11, 15, 4 },
- { 9, 5, 14, 6 },
- { 10, 13, 12, 0 }
-};
-
extern uint16 *FadePalette;
extern BitMap *DispBitMap, *DrawBitMap;
extern uint16 Direction;
-#define COMBINATIONUNLOCKED 130
-#define BRICKOPEN 115
#define INCL(BITSET,BIT) ((BITSET) |= (BIT))
#define SETBIT(BITSET,BITNUM) INCL(BITSET, (1 << (BITNUM)))
#define INBIT(BITSET,BITNUM) ( ((1 << (BITNUM)) & (BITSET)) > 0 )
-#define LEFTSCROLL 1
-#define RIGHTSCROLL 2
-#define UPSCROLL 3
-#define DOWNSCROLL 4
#define BRIDGE0 148
#define BRIDGE1 104
#define DIRTY 175
@@ -125,319 +100,6 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
}
/*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap. */
-/*****************************************************************************/
-static void doCombination() {
- for (uint16 i = 0; i <= 5; i++)
- Images[combination[i]]->drawImage(g_lab->_graphics->VGAScaleX(combx[i]), g_lab->_graphics->VGAScaleY(65));
-}
-
-/*****************************************************************************/
-/* Reads in a backdrop picture. */
-/*****************************************************************************/
-void showCombination(const char *filename) {
- resetBuffer();
- g_lab->_anim->_doBlack = true;
- g_lab->_anim->_noPalChange = true;
- g_lab->_graphics->readPict(filename, true);
- g_lab->_anim->_noPalChange = false;
-
- g_lab->_graphics->blackScreen();
-
- Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers");
-
- for (uint16 CurBit = 0; CurBit < 10; CurBit++)
- Images[CurBit] = new Image(numFile);
-
- delete numFile;
-
- allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
-
- doCombination();
-
- g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-}
-
-
-
-/*****************************************************************************/
-/* Changes the combination number of one of the slots */
-/*****************************************************************************/
-static void changeCombination(uint16 number) {
- Image display;
- uint16 combnum;
- bool unlocked = true;
-
- if (combination[number] < 9)
- (combination[number])++;
- else
- combination[number] = 0;
-
- combnum = combination[number];
-
- display._imageData = g_lab->getCurrentDrawingBuffer();
- display._width = g_lab->_screenWidth;
- display._height = g_lab->_screenHeight;
-
- for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
- if (g_lab->_isHiRes) {
- if (i & 1)
- g_lab->waitTOF();
- } else
- g_lab->waitTOF();
-
- display._imageData = g_lab->getCurrentDrawingBuffer();
-
- g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height);
-
- Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
- }
-
- for (uint16 i = 0; i < 6; i++)
- unlocked = (combination[i] == solution[i]) && unlocked;
-
- if (unlocked)
- g_lab->_conditions->inclElement(COMBINATIONUNLOCKED);
- else
- g_lab->_conditions->exclElement(COMBINATIONUNLOCKED);
-}
-
-
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination. */
-/*****************************************************************************/
-void mouseCombination(Common::Point pos) {
- uint16 number;
-
- int x = VGAUnScaleX(pos.x);
- int y = VGAUnScaleY(pos.y);
-
- if ((y >= 63) && (y <= 99)) {
- if ((x >= 44) && (x < 83))
- number = 0;
- else if (x < 127)
- number = 1;
- else if (x < 165)
- number = 2;
- else if (x < 210)
- number = 3;
- else if (x < 245)
- number = 4;
- else if (x < 286)
- number = 5;
- else
- return;
-
- changeCombination(number);
- }
-}
-
-/*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap. */
-/*****************************************************************************/
-static void doTile(bool showsolution) {
- uint16 row = 0, col = 0, rowm, colm, num;
- int16 rows, cols;
-
- if (showsolution) {
- rowm = g_lab->_graphics->VGAScaleY(23);
- colm = g_lab->_graphics->VGAScaleX(27);
-
- rows = g_lab->_graphics->VGAScaleY(31);
- cols = g_lab->_graphics->VGAScaleX(105);
- } else {
- g_lab->_graphics->setAPen(0);
- g_lab->_graphics->rectFill(g_lab->_graphics->VGAScaleX(97), g_lab->_graphics->VGAScaleY(22), g_lab->_graphics->VGAScaleX(220), g_lab->_graphics->VGAScaleY(126));
-
- rowm = g_lab->_graphics->VGAScaleY(25);
- colm = g_lab->_graphics->VGAScaleX(30);
-
- rows = g_lab->_graphics->VGAScaleY(25);
- cols = g_lab->_graphics->VGAScaleX(100);
- }
-
- while (row < 4) {
- while (col < 4) {
- if (showsolution)
- num = TileSolution[col] [row];
- else
- num = CurTile[col] [row];
-
- if (showsolution || num)
- Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
-
- col++;
- }
-
- row++;
- col = 0;
- }
-}
-
-/*****************************************************************************/
-/* Reads in a backdrop picture. */
-/*****************************************************************************/
-void showTile(const char *filename, bool showsolution) {
- uint16 start = showsolution ? 0 : 1;
-
- resetBuffer();
- g_lab->_anim->_doBlack = true;
- g_lab->_anim->_noPalChange = true;
- g_lab->_graphics->readPict(filename, true);
- g_lab->_anim->_noPalChange = false;
- g_lab->_graphics->blackScreen();
-
- Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
-
- for (uint16 curBit = start; curBit < 16; curBit++)
- Tiles[curBit] = new Image(tileFile);
-
- delete tileFile;
-
- allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
-
- doTile(showsolution);
-
- g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-}
-
-static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
- if (dx)
- g_lab->scrollDisplayX(dx, x1, y1, x2, y2);
-
- if (dy)
- g_lab->scrollDisplayY(dy, x1, y1, x2, y2);
-}
-
-/*****************************************************************************/
-/* Does the scrolling for the tiles on the tile puzzle. */
-/*****************************************************************************/
-static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
- int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
- uint16 last = 0, x1, y1;
-
- if (scrolltype == LEFTSCROLL) {
- dX = g_lab->_graphics->VGAScaleX(5);
- sx = g_lab->_graphics->VGAScaleX(5);
- last = 6;
- } else if (scrolltype == RIGHTSCROLL) {
- dX = g_lab->_graphics->VGAScaleX(-5);
- dx = g_lab->_graphics->VGAScaleX(-5);
- sx = g_lab->_graphics->VGAScaleX(5);
- last = 6;
- } else if (scrolltype == UPSCROLL) {
- dY = g_lab->_graphics->VGAScaleY(5);
- sy = g_lab->_graphics->VGAScaleY(5);
- last = 5;
- } else if (scrolltype == DOWNSCROLL) {
- dY = g_lab->_graphics->VGAScaleY(-5);
- dy = g_lab->_graphics->VGAScaleY(-5);
- sy = g_lab->_graphics->VGAScaleY(5);
- last = 5;
- }
-
- sx += g_lab->_graphics->SVGACord(2);
-
- x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx;
- y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy;
-
- for (uint16 i = 0; i < last; i++) {
- g_lab->waitTOF();
- scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy);
- x1 += dX;
- y1 += dY;
- }
-}
-
-/*****************************************************************************/
-/* Changes the combination number of one of the slots */
-/*****************************************************************************/
-static void changeTile(uint16 col, uint16 row) {
- int16 scrolltype = -1;
-
- if (row > 0) {
- if (CurTile[col] [row - 1] == 0) {
- CurTile[col] [row - 1] = CurTile[col] [row];
- CurTile[col] [row] = 0;
- scrolltype = DOWNSCROLL;
- }
- }
-
- if (col > 0) {
- if (CurTile[col - 1] [row] == 0) {
- CurTile[col - 1] [row] = CurTile[col] [row];
- CurTile[col] [row] = 0;
- scrolltype = RIGHTSCROLL;
- }
- }
-
- if (row < 3) {
- if (CurTile[col] [row + 1] == 0) {
- CurTile[col] [row + 1] = CurTile[col] [row];
- CurTile[col] [row] = 0;
- scrolltype = UPSCROLL;
- }
- }
-
- if (col < 3) {
- if (CurTile[col + 1] [row] == 0) {
- CurTile[col + 1] [row] = CurTile[col] [row];
- CurTile[col] [row] = 0;
- scrolltype = LEFTSCROLL;
- }
- }
-
- if (scrolltype != -1) {
- doTileScroll(col, row, scrolltype);
-
- if (g_lab->getFeatures() & GF_WINDOWS_TRIAL) {
- GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
- trialMessage.runModal();
- return;
- }
-
- bool check = true;
- row = 0;
- col = 0;
-
- while (row < 4) {
- while (col < 4) {
- check = check && (CurTile[row] [col] == TileSolution[row] [col]);
- col++;
- }
-
- row++;
- col = 0;
- }
-
- if (check) {
- g_lab->_conditions->inclElement(BRICKOPEN); /* unlocked combination */
- g_lab->_anim->_doBlack = true;
- check = g_lab->_graphics->readPict("p:Up/BDOpen", true);
- }
- }
-}
-
-
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination. */
-/*****************************************************************************/
-void mouseTile(Common::Point pos) {
- int x = VGAUnScaleX(pos.x);
- int y = VGAUnScaleY(pos.y);
-
- if ((x < 101) || (y < 26))
- return;
-
- x = (x - 101) / 30;
- y = (y - 26) / 25;
-
- if ((x < 4) && (y < 4))
- changeTile(x, y);
-}
-
-
-/*****************************************************************************/
/* Does the things to properly set up the detective notes. */
/*****************************************************************************/
void doNotes() {