aboutsummaryrefslogtreecommitdiff
path: root/engines/lab
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lab')
-rw-r--r--engines/lab/engine.cpp58
-rw-r--r--engines/lab/graphics.cpp4
-rw-r--r--engines/lab/labfun.h1
-rw-r--r--engines/lab/labtext.cpp113
-rw-r--r--engines/lab/map.cpp29
-rw-r--r--engines/lab/processroom.cpp49
-rw-r--r--engines/lab/resource.h2
7 files changed, 56 insertions, 200 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 571b72d88d..c1883a0fda 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -75,10 +75,6 @@ bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true,
extern const char *NewFileName; /* When ProcessRoom.c decides to change the filename
of the current picture. */
-extern char *LAMPONMSG, *TURNLEFT, *TURNRIGHT;
-extern char *GOFORWARDDIR, *NOPATH, *TAKEITEM, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *NOTHING, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
-
-
#define BUFFERSIZE 850000L
/* LAB: Labyrinth specific code for the special puzzles */
@@ -208,7 +204,7 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
if (Alternate) {
if ((CurInv <= NumInv) && g_lab->_conditions->in(CurInv) && Inventory[CurInv].BInvName) {
if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON)) /* LAB: Labyrith specific */
- drawMessage(LAMPONMSG);
+ drawStaticMessage(kTextLampOn);
else if (Inventory[CurInv].Many > 1) {
Common::String roomMessage = Common::String(Inventory[CurInv].name) + " (" + Common::String::format("%d", Inventory[CurInv].Many) + ")";
drawMessage(roomMessage.c_str());
@@ -536,7 +532,7 @@ static const char *Test;
static bool doUse(uint16 CurInv) {
if (CurInv == MAPNUM) { /* LAB: Labyrinth specific */
- drawMessage(USEMAP);
+ drawStaticMessage(kTextUseMap);
interfaceOff();
stopDiff();
CurFileName = " ";
@@ -548,7 +544,7 @@ static bool doUse(uint16 CurInv) {
}
else if (CurInv == JOURNALNUM) { /* LAB: Labyrinth specific */
- drawMessage(USEJOURNAL);
+ drawStaticMessage(kTextUseJournal);
interfaceOff();
stopDiff();
CurFileName = " ";
@@ -562,10 +558,10 @@ static bool doUse(uint16 CurInv) {
interfaceOff();
if (g_lab->_conditions->in(LAMPON)) {
- drawMessage(TURNLAMPOFF);
+ drawStaticMessage(kTextTurnLampOff);
g_lab->_conditions->exclElement(LAMPON);
} else {
- drawMessage(TURNLAMPON);
+ drawStaticMessage(kTextTurnLampOn);
g_lab->_conditions->inclElement(LAMPON);
}
@@ -588,17 +584,17 @@ static bool doUse(uint16 CurInv) {
else if (CurInv == WHISKEYNUM) { /* LAB: Labyrinth specific */
g_lab->_conditions->inclElement(USEDHELMET);
- drawMessage(USEWHISKEY);
+ drawStaticMessage(kTextUseWhiskey);
}
else if (CurInv == PITHHELMETNUM) { /* LAB: Labyrinth specific */
g_lab->_conditions->inclElement(USEDHELMET);
- drawMessage(USEPITH);
+ drawStaticMessage(kTextUsePith);
}
else if (CurInv == HELMETNUM) { /* LAB: Labyrinth specific */
g_lab->_conditions->inclElement(USEDHELMET);
- drawMessage(USEHELMET);
+ drawStaticMessage(kTextUseHelmet);
}
else
@@ -955,15 +951,15 @@ from_crumbs:
perFlipGadget(ActionMode);
if (GadID == 0)
- drawMessage(TAKEWHAT);
+ drawStaticMessage(kTextTakeWhat);
else if (GadID == 1)
- drawMessage(MOVEWHAT);
+ drawStaticMessage(kTextMoveWhat);
else if (GadID == 2)
- drawMessage(OPENWHAT);
+ drawStaticMessage(kTextOpenWhat);
else if (GadID == 3)
- drawMessage(CLOSEWHAT);
+ drawStaticMessage(kTextCloseWhat);
else if (GadID == 4)
- drawMessage(LOOKWHAT);
+ drawStaticMessage(kTextLookWhat);
WSDL_UpdateScreen();
}
@@ -978,9 +974,9 @@ from_crumbs:
if ((GadID == 6) || (GadID == 8)) {
if (GadID == 6)
- drawMessage(TURNLEFT);
+ drawStaticMessage(kTextTurnLeft);
else
- drawMessage(TURNRIGHT);
+ drawStaticMessage(kTextTurnRight);
CurFileName = " ";
@@ -1006,13 +1002,13 @@ from_crumbs:
processArrow(&Direction, GadID - 6);
if (OldRoomNum != RoomNum) {
- drawMessage(GOFORWARDDIR);
+ drawStaticMessage(kTextGoForward);
g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
CurFileName = " ";
ForceDraw = true;
} else {
DoBlack = true;
- drawMessage(NOPATH);
+ drawStaticMessage(kTextNoPath);
}
}
@@ -1117,7 +1113,7 @@ from_crumbs:
if (Old < 5)
perFlipGadget(Old);
- drawMessage(USEONWHAT);
+ drawStaticMessage(kTextUseOnWhat);
MainDisplay = true;
WSDL_UpdateScreen();
@@ -1211,13 +1207,13 @@ from_crumbs:
if (doActionRule(MouseX, MouseY, ActionMode, RoomNum, &CPtr))
CurFileName = NewFileName;
else if (takeItem(MouseX, MouseY, &CPtr))
- drawMessage(TAKEITEM);
+ drawStaticMessage(kTextTakeItem);
else if (doActionRule(MouseX, MouseY, TAKEDEF - 1, RoomNum, &CPtr))
CurFileName = NewFileName;
else if (doActionRule(MouseX, MouseY, TAKE - 1, 0, &CPtr))
CurFileName = NewFileName;
else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
- drawMessage(NOTHING);
+ drawStaticMessage(kTextNothing);
} else if ((ActionMode == 1) /* Manipulate an object */ ||
(ActionMode == 2) /* Open up a "door" */ ||
(ActionMode == 3)) { /* Close a "door" */
@@ -1225,7 +1221,7 @@ from_crumbs:
CurFileName = NewFileName;
else if (!doActionRule(MouseX, MouseY, ActionMode, 0, &CPtr)) {
if (MouseY < (VGAScaleY(149) + SVGACord(2)))
- drawMessage(NOTHING);
+ drawStaticMessage(kTextNothing);
}
} else if (ActionMode == 4) { /* Look at closeups */
TempCPtr = CPtr;
@@ -1233,15 +1229,15 @@ from_crumbs:
if (CPtr == TempCPtr) {
if (MouseY < (VGAScaleY(149) + SVGACord(2)))
- drawMessage(NOTHING);
+ drawStaticMessage(kTextNothing);
} else if (TempCPtr->GraphicName) {
if (*(TempCPtr->GraphicName)) {
DoBlack = true;
CPtr = TempCPtr;
} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
- drawMessage(NOTHING);
+ drawStaticMessage(kTextNothing);
} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
- drawMessage(NOTHING);
+ drawStaticMessage(kTextNothing);
} else if ((ActionMode == 5) &&
g_lab->_conditions->in(CurInv)) { /* Use an item on something else */
if (doOperateRule(MouseX, MouseY, CurInv, &CPtr)) {
@@ -1250,7 +1246,7 @@ from_crumbs:
if (!g_lab->_conditions->in(CurInv))
decIncInv(&CurInv, false);
} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
- drawMessage(NOTHING);
+ drawStaticMessage(kTextNothing);
}
}
@@ -1356,8 +1352,7 @@ void LabEngine::go() {
initMouse();
- mem = mem && initRoomBuffer() &&
- initLabText();
+ mem = mem && initRoomBuffer();
if (!dointro)
g_music->initMusic();
@@ -1399,7 +1394,6 @@ void LabEngine::go() {
closeFont(MsgFont);
- freeLabText();
freeRoomBuffer();
freeBuffer();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 23e587c047..c8d23e97ce 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -37,6 +37,7 @@
#include "lab/mouse.h"
#include "lab/vga.h"
#include "lab/text.h"
+#include "lab/resource.h"
namespace Lab {
@@ -366,6 +367,9 @@ int32 longDrawMessage(const char *str) {
+void drawStaticMessage(byte index) {
+ drawMessage(g_resource->getStaticText((StaticText)index).c_str());
+}
/******************************************************************************/
/* Draws a message to the message box. */
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 9ed334f431..3a77855f17 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -98,6 +98,7 @@ uint32 flowTextToMem(Image *DestIm, void *font, /* the TextAttr pointer */
uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
void drawMessage(const char *text);
+void drawStaticMessage(byte index);
int32 longDrawMessage(const char *text);
/* The Wipes */
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
index 568ad828bf..9955c43b70 100644
--- a/engines/lab/labtext.cpp
+++ b/engines/lab/labtext.cpp
@@ -37,119 +37,6 @@ static uint32 SizeOfMemChunk;
static char *BeginOfMemChunk, *CurPlace;
-char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG, *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST, *LAMPONMSG, *TURNLEFT, *TURNRIGHT, *GOFORWARDDIR, *NOPATH, *TAKEITEM, *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *NODISKINDRIVE, *WRITEPROTECTED, *SELECTDISK, *FORMATFLOPPY, *FORMATTING, *NOTHING, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
-
-
-#define LABTEXTFILE "Lab:Rooms/LabText"
-
-
-
-
-/*****************************************************************************/
-/* Gets the next string from the list, and changes the end of string marker */
-/* from an end of line to a null character. */
-/*****************************************************************************/
-static void setString(char **string) {
- *string = CurPlace;
-
- while (*CurPlace != '\n')
- CurPlace++;
-
- *CurPlace = 0;
- CurPlace++;
-}
-
-
-
-/*****************************************************************************/
-/* Initializes everything for the Labyrinth text stuff */
-/*****************************************************************************/
-bool initLabText() {
- Common::File *file = openPartial(LABTEXTFILE);
- if (!file)
- return false;
-
- SizeOfMemChunk = file->size();
- if (!SizeOfMemChunk || !(BeginOfMemChunk = (char *)calloc(SizeOfMemChunk, 1)))
- return false;
-
- file->read(BeginOfMemChunk, SizeOfMemChunk);
- file->close();
-
- CurPlace = BeginOfMemChunk;
-
- setString(&LOWERFLOORS);
- setString(&MIDDLEFLOORS);
- setString(&UPPERFLOORS);
- setString(&MEDMAZEFLOORS);
- setString(&HEDGEMAZEFLOORS);
- setString(&SURMAZEFLOORS);
- setString(&CARNIVALFLOOR);
- setString(&SURMAZEMSG);
-
- setString(&FACINGNORTH);
- setString(&FACINGEAST);
- setString(&FACINGSOUTH);
- setString(&FACINGWEST);
-
- setString(&LAMPONMSG);
-
- setString(&TURNLEFT);
- setString(&TURNRIGHT);
- setString(&GOFORWARDDIR);
- setString(&NOPATH);
- setString(&TAKEITEM);
-
- setString(&SAVETEXT);
- setString(&LOADTEXT);
- setString(&BOOKMARKTEXT);
- setString(&PERSONALTEXT);
- setString(&DISKTEXT);
-
- setString(&SAVEBOOK);
- setString(&RESTOREBOOK);
- setString(&SAVEFLASH);
- setString(&RESTOREFLASH);
- setString(&SAVEDISK);
- setString(&RESTOREDISK);
- setString(&NODISKINDRIVE);
- setString(&WRITEPROTECTED);
- setString(&SELECTDISK);
-
- setString(&FORMATFLOPPY);
- setString(&FORMATTING);
-
- setString(&NOTHING);
- setString(&USEONWHAT);
- setString(&TAKEWHAT);
- setString(&MOVEWHAT);
- setString(&OPENWHAT);
- setString(&CLOSEWHAT);
- setString(&LOOKWHAT);
-
- setString(&USEMAP);
- setString(&USEJOURNAL);
- setString(&TURNLAMPON);
- setString(&TURNLAMPOFF);
- setString(&USEWHISKEY);
- setString(&USEPITH);
- setString(&USEHELMET);
-
- return true;
-}
-
-
-/*****************************************************************************/
-/* Frees the memory from the Labyrinth text stuff. */
-/*****************************************************************************/
-void freeLabText() {
- if (SizeOfMemChunk && BeginOfMemChunk)
- free(BeginOfMemChunk);
-}
-
-
-
-
/*****************************************************************************/
/* Decrypts a chunk of text. */
/*****************************************************************************/
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 34eb018f94..06a0ac18d7 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -616,47 +616,42 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
if (Floor == LOWERFLOOR) {
if (onFloor(SURMAZEFLOOR))
drawImage(Maze, mapScaleX(538), mapScaleY(277));
- }
-
- else if (Floor == MIDDLEFLOOR) {
+ } else if (Floor == MIDDLEFLOOR) {
if (onFloor(CARNIVAL))
drawImage(Maze, mapScaleX(358), mapScaleY(72));
if (onFloor(MEDMAZEFLOOR))
drawImage(Maze, mapScaleX(557), mapScaleY(325));
- }
-
- else if (Floor == UPPERFLOOR) {
+ } else if (Floor == UPPERFLOOR) {
if (onFloor(HEDGEMAZEFLOOR))
drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
- }
-
- else if (Floor == SURMAZEFLOOR) {
- flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), SURMAZEMSG);
+ } else if (Floor == SURMAZEFLOOR) {
+ sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str();
+ flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
}
switch (Floor) {
case LOWERFLOOR:
- sptr = LOWERFLOORS;
+ sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str();
break;
case MIDDLEFLOOR:
- sptr = MIDDLEFLOORS;
+ sptr = (char *)g_resource->getStaticText(kTextMiddleFloor).c_str();
break;
case UPPERFLOOR:
- sptr = UPPERFLOORS;
+ sptr = (char *)g_resource->getStaticText(kTextUpperFloor).c_str();
break;
case MEDMAZEFLOOR:
- sptr = MEDMAZEFLOORS;
+ sptr = (char *)g_resource->getStaticText(kTextMedMazeFloor).c_str();
break;
case HEDGEMAZEFLOOR:
- sptr = HEDGEMAZEFLOORS;
+ sptr = (char *)g_resource->getStaticText(kTextHedgeMazeFloor).c_str();
break;
case SURMAZEFLOOR:
- sptr = SURMAZEFLOORS;
+ sptr = (char *)g_resource->getStaticText(kTextSurMazeFloor).c_str();
break;
case CARNIVAL:
- sptr = CARNIVALFLOOR;
+ sptr = (char *)g_resource->getStaticText(kTextCarnivalFloor).c_str();
break;
default:
sptr = NULL;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 3c5d1f62dd..87f3e58549 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -35,6 +35,7 @@
#include "lab/labfun.h"
#include "lab/parsetypes.h"
#include "lab/parsefun.h"
+#include "lab/resource.h"
#include "lab/timing.h"
#include "lab/diff.h"
#include "lab/vga.h"
@@ -55,7 +56,6 @@ extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, Lon
extern char diffcmap[256 * 3];
extern const char *CurFileName;
extern CloseDataPtr CPtr;
-extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
/*****************************************************************************/
/* Generates a random number. */
@@ -195,53 +195,28 @@ char *getPictName(CloseDataPtr *LCPtr) {
/* Draws the current direction to the screen. */
/*****************************************************************************/
void drawDirection(CloseDataPtr LCPtr) {
- char Message[250];
-
- if (LCPtr != NULL) {
- if (LCPtr->Message) {
- drawMessage(LCPtr->Message);
- return;
- }
+ if (LCPtr != NULL && LCPtr->Message) {
+ drawMessage(LCPtr->Message);
+ return;
}
-
- Message[0] = '\0';
+ Common::String message;
if (Rooms[RoomNum].RoomMsg) {
- strcpy(Message, Rooms[RoomNum].RoomMsg);
- strcat(Message, ", ");
+ message += Rooms[RoomNum].RoomMsg;
+ message += ", ";
}
if (Direction == NORTH)
- strcat(Message, FACINGNORTH);
+ message += g_resource->getStaticText(kTextFacingNorth);
else if (Direction == EAST)
- strcat(Message, FACINGEAST);
+ message += g_resource->getStaticText(kTextFacingEast);
else if (Direction == SOUTH)
- strcat(Message, FACINGSOUTH);
+ message += g_resource->getStaticText(kTextFacingSouth);
else if (Direction == WEST)
- strcat(Message, FACINGWEST);
-
- drawMessage(Message);
-}
-
-void getRoomMessage(int MyRoomNum, int MyDirection, char *msg) {
- getViewData(MyRoomNum, MyDirection);
-
- msg[0] = '\0';
-
- if (Rooms[MyRoomNum].RoomMsg) {
- strcpy(msg, Rooms[MyRoomNum].RoomMsg);
- strcat(msg, ", ");
- }
+ message += g_resource->getStaticText(kTextFacingWest);
- if (MyDirection == NORTH)
- strcat(msg, FACINGNORTH);
- else if (MyDirection == EAST)
- strcat(msg, FACINGEAST);
- else if (MyDirection == SOUTH)
- strcat(msg, FACINGSOUTH);
- else if (MyDirection == WEST)
- strcat(msg, FACINGWEST);
+ drawMessage(message.c_str());
}
/*****************************************************************************/
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 9bcd638c7f..59240a3505 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -102,7 +102,7 @@ public:
bool readInventory(const char *fileName);
bool readViews(uint16 roomNum);
TextFont *getFont(const char *filename);
- Common::String getStaticText(byte index) const { return _staticText[index + 1]; }
+ Common::String getStaticText(byte index) const { return _staticText[index]; }
private:
Common::File *openDataFile(const char * fileName, uint32 fileHeader);